How can I make GCC compile the .text section as writable in an ELF binary?

后端 未结 4 1639
我寻月下人不归
我寻月下人不归 2020-12-01 17:18

I would like to be able to dynamically change the executable code within a library I am using. Essentially, I would like to dynamically NOP out certain functions if they are

4条回答
  •  离开以前
    2020-12-01 18:01

    Probably the best approach is to use the system specific API to change the writability of the memory you wish to modify, modify it, then change it back.

    On unix family systems, you'd want to look at mprotect. Just keep in mind that it deals with blocks that are multiples of the page size of your system. Likely 4096, so rounding is likely required.

提交回复
热议问题