c - Finding strings in the text section -


i have example following code:

foo( "test1" );  void foo(const char* const i_test ) {      // logic } 

the i_test pointer in foo() hold pointer string in .rodata section.

is there way search i_text pointer value in binary file find related string? or can produce debug info using gcc hold info?

if talking elf file format, constant strings stored in .rodata (read-only-data) section. basically, instructions (codes) of program stored in .text section in binary file. can investigate these sections using object dump program (e.g. objdump) following:

objdump -drs program.o           // see .text section of program  objdump -s -j .rodata program.o  // see .rodata section of program 

in sample code above, "test1" string passing foo function treated constant string compiler. thus, can find relative memory address before loading stage , i_test pointer pointing constant string. however, if have compiled code position independent (by using -fpic option in gcc), may find out compiler add writable attribute read-only .rodata section. furthermore, may use readelf binary utility display detailed information elf formatted object file's sections.

more information elf file format can found in here


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -