lkml.org 
[lkml]   [2013]   [Dec]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: RFC: binutils PATCH: Set e_type to ET_EXEC for -pie -Ttext-segment=
On Mon, Dec 09, 2013 at 07:10:23PM -0800, H.J. Lu wrote:
> 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.

Well, I suppose it's a hack to use ET_DYN for executables in the first
place, so one more hack in the linker hardly matters. Why not just
patch the kernel though? The kernel can look at the first PT_LOAD
header just as easily as the linker, and it's the kernel that is doing
the loading after all.

--
Alan Modra
Australia Development Lab, IBM


\
 
 \ /
  Last update: 2013-12-11 00:01    [W:0.488 / U:0.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site