Re: How to lookup the unnamed string constant in the generated object or executable?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 20 Apr 2021 at 06:42, Peng Yu wrote:
>
> Hi,
>
> I am trying to understand where are unnamed string constants are
> defined in symbol tables.
>
> In the following example, the unnamed string constant is "Hello World!".
>
> $ cat a.c
> #include <stdio.h>
> int main() { puts("Hello World!"); }
> $ gcc -c a.c
> $ gcc -o a.out a.o
>
> But I don't find it in the symbol table. Could anybody point to me
> where it is? Thanks.

The ELF format puts string literals in the .rodata section, not the .symtab.


$ readelf -p .rodata  a.out

String dump of section '.rodata':
 [    10]  Hello World!



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux