Address of string literals are determined at compile time. This address and the string literal can be found in the built executable program (In ELF format). For example, the following code outputs String Literal: 0x400674
printf("String Literal: %p\n", "Hello World");
And objdump -s -j .rodata test1
shows
Contents of section .rodata:
400670 01000200 48656c6c 6f20576f 726c6400 ....Hello World.
....
So it looks like I can get the virtual address of "Hello World" by reading the executable program itself.
Question: How can I build a table/map/dictionary between the address of string literal and the the string itself, by reading the ELF format?
I am trying to writeup a standalone python script or c++ program to read the elf program and generate the table. It's OK if extra mapping(not the string literal) in the table, as long as the table contains the whole mapping of string literals.