gcc creating a huge executable image (RedHat 2.6.18-8.el5, x86_64, Linux)
I'm trying to figure out the mystery of the 64-bit ELF image. I wrote a hello.c little program, compiled with
% gcc hello.c -o hello No problem. Got a "hello" executable image of size 6668 bytes. So far so good. I really want to understand the "-Ttext" linker parameter so I repeated the compilation, this time with a linker parameter: % gcc -Xlinker -Ttext=0x2000 hello.c -o hello Again, a "hello" executable gets created and even runs ok, but the size of the file is roughly 2MB (2102706 to be exact.) So I go looking inside the image for some clues: % dd bs=4092 count=256 if=hello | od -Ax -tx1z -v The image starts with the expected ELF header. Then I found out that the ".text" segment itself was placed in offset 0x2000 in the "hello" file. The ".text" segment was followed by almost 2MB of zeroes. Main questions: What is the meaning of the -Ttext= directive? (I thought it was supposed to tell the loader that I want the ".text" segment in that specific location in physical memory, not in the file itself. I really don't care where they place it in the file.) Did I get this wrong? Does "-Ttext=" really indicate a file offset as opposed to a physical memory address? |
-Ttext is an alias for "--section-start=text", which reads as:
Quote:
|
All times are GMT -5. The time now is 12:27 PM. |