Re: Accessing String Table Indexes for .rodata

2018-08-31 Thread Mark Wielaard
On Fri, 2018-08-31 at 20:35 +0800, Henry C wrote: > As you mentioned, it is not guaranteed, I wonder under what situation > Elf64_Shdr::sh_addr won't represent the virtual address of the > beginning of .rodata section. Try creating a shared library or compile your application with -pie to make an

Re: Accessing String Table Indexes for .rodata

2018-08-31 Thread Henry C
Hi Mark, I just dumped out my executable (code was in my very first email): $ eu-readelf -l myexec Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align PHDR 0x40 0x00400040 0x00400040 0x0001f8 0x0001f8 R E 0x8 INTERP

Re: Accessing String Table Indexes for .rodata

2018-08-31 Thread Mark Wielaard
On Fri, 2018-08-31 at 19:07 +0800, Henry C wrote: > Thanks for replying. > > I mean for example, > void myprintf(const char* ptr) { > printf("%p\n", ptr); > } > > int main() { > myprintf("hello world"); > } > > Let's say the output is 0x403DE. > > Does it mean that Elf64_Shdr::s

Re: Accessing String Table Indexes for .rodata

2018-08-31 Thread Henry C
Thanks for replying. I mean for example, void myprintf(const char* ptr) { printf("%p\n", ptr); } int main() { myprintf("hello world"); } Let's say the output is 0x403DE. Does it mean that Elf64_Shdr::sh_addr of the string table (of .rodata) + the offset of "hello word" within th

Re: Accessing String Table Indexes for .rodata

2018-08-30 Thread Mark Wielaard
On Tue, Aug 21, 2018 at 12:16:09AM +0800, Henry C wrote: > Tho, I have no clue how to get the index to each of the string in the > string table above. The .rodata section isn't just a simple ELF string table. Otherwise you could use elf_strptr (see libelf.h) to index through them. But .rodata also

Accessing String Table Indexes for .rodata

2018-08-20 Thread Henry C
Hi, I have a sample code like this: #include void myprintf(const char* ptr) { printf("%p\n", ptr); } int main() { myprintf("hello world"); myprintf("\0\0"); myprintf("ab\0cde"); } I would like to access the .rodata by using elf.h. Someone told me this is the ri