[vox-tech] Understanding a C hello world program

Bryan Richter btrichter at ucdavis.edu
Wed Nov 24 10:20:18 PST 2004


Peter Jay Salzman wrote:
> Consider this program:
> 
> <snip>
> 
>    p at satan$ size hello_world-1.o 
>       text    data     bss     dec     hex filename
>         48       0       0      48      30 hello_world-1.o
> 
> When I disassemble the object file, I get 35 bytes:
> 
> <snip> 
> 
> p at satan$ objdump -h hello_world-1.o 
> 
> <snip>
> 
> 
> I wish objdump identified hex numbers as hex numbers.  In any event, the text
> section has length x23, which is 35.  The opcodes plus the string.  Further
> evidence that the string lives in the text segment.

Actually, objdump agrees with disassembly- string doesn't live in text region
(35 bytes in both).

> 
> Maybe my immediate question is -- where do read-only strings live?  In the
> text section or the .rodata section?  I've seen evidence that it lives in
> both section.

Maybe gcc -S would be enlightening? It doesn't enlighten me, but then I don't
know what a lot of the directives do (.section, for one). There is no .data
directive, however, and the "hello world\n" definitely comes before the .text
directive. It looks like:

---
    .section .rodata
.LC0:
    .string "hello world\n"
    .text
---

Maybe size, which doesn't seem to recognize .rodata, just lumps ".data" and
"everything else"?

-Bryan
-- 
Bryan Richter
UCDTT President
UC Davis Undergrad, Physics Dept.
-
A PGP signature is (probably) attached to this email. 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: Digital signature
Url : http://ns1.livepenguin.com/pipermail/vox-tech/attachments/20041124/384e437f/attachment.bin


More information about the vox-tech mailing list