This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: x86-64: LD default ELF section file offset == LMA ?


Etienne Lorrain <etienne_lorrain@yahoo.fr> writes:

> etienne@cygne:~/projet/gujin$ gcc -m64 -Wl,-Ttext=0x110000 -nostartfiles -nodefaultlibs hello_64bits.s hello_64bits.elf

When using GNU ld, the default page size for x86_64 is 0x200000.  If you
don't use -n or -N, sections will always be placed such that the VMA
modulo the page size equals the file offset modulo the page size (this
is to support paging directly from the executable).  So by setting the
text address to 0x110000, you are ensuring that the file offset will be
0x110000.  As can be seen here:


> Idx Name          Size      VMA               LMA               File off  Algn

>   0 .text         00000029  0000000000110000  0000000000110000  00110000  2**2
>                   CONTENTS, ALLOC, LOAD, READONLY, CODE

You can avoid this by using -n, -N, -z max-page-size, or by using gold
which uses a default page size of 0x1000.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]