This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: RFC: binutils PATCH: Set e_type to ET_EXEC for -pie -Ttext-segment=0xXXX
- From: "H. Peter Anvin" <hpa at zytor dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>, Binutils <binutils at sourceware dot org>
- Cc: Jiri Kosina <jkosina at suse dot cz>, LKML <linux-kernel at vger dot kernel dot org>, Josh Boyer <jwboyer at redhat dot com>
- Date: Mon, 09 Dec 2013 19:23:14 -0800
- Subject: Re: RFC: binutils PATCH: Set e_type to ET_EXEC for -pie -Ttext-segment=0xXXX
- Authentication-results: sourceware.org; auth=none
- References: <CAMe9rOqLzLkRM5J7s22fOob-nui3Lx67TMAswCtmSu+2QdhZrw at mail dot gmail dot com>
On 12/09/2013 07:05 PM, H.J. Lu wrote:
>>
>> I see. Maybe linker can set ET_EXEC if vaddr is non-zero.
>>
>
> Linker sets e_type in ELF header to ET_DYN for -pie -Ttext-segment=0xXXX.
> When I added -Ttext-segment=0xXXX, one goal was to load
> small model executable above 4GB on Linux/x86-64, which
> was done with -pie -Ttext-segment=0xXXX. But -pie sets
> e_type in ELF header to ET_DYN and kernel may ignore
> p_vaddr in ELF header to load ET_DYN binary at a random
> address. This patch changes ld to set e_type in ELF header
> to ET_EXEC if the first PT_LOAD segment has non-zero
> p_vaddr. If this is unacceptable as generic ELF change,
> I can make it specific to x86.
>
Why not just drop the -pie from the command line? I would expect -pie
to set ET_DYN, but if you want to load at a specific address one would
expect to use -Ttext-segment=... and *not* -pie.
-hpa