l i n u x - u s e r s - g r o u p - o f - d a v i s
Next Meeting:
July 7: Social gathering
Next Installfest:
Latest News:
Jun. 14: June LUGOD meeting cancelled
Page last updated:
2004 Nov 24 11:10

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] Understanding a C hello world program
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] Understanding a C hello world program

Peter Jay Salzman wrote:
> Consider this program:
> <snip>
>    p@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@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
    .string "hello world\n"

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

Bryan Richter
UCDTT President
UC Davis Undergrad, Physics Dept.
A PGP signature is (probably) attached to this email. 

Attachment: signature.asc
Description: Digital signature

vox-tech mailing list

LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Sunset Systems
Who graciously hosts our website & mailing lists!