This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: x86-64: LD default ELF section file offset == LMA ?
- From: Ian Lance Taylor <iant at google dot com>
- To: etienne_lorrain at yahoo dot fr
- Cc: binutils at sourceware dot org
- Date: Fri, 03 Apr 2009 07:50:11 -0700
- Subject: Re: x86-64: LD default ELF section file offset == LMA ?
- References: <222615.82763.qm@web23607.mail.ird.yahoo.com>
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