The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>, Binutils <binutils@sourceware.org>
Subject: Re: RFC: binutils PATCH: Set e_type to ET_EXEC for -pie -Ttext-segment=
Date: Wed, 11 Dec 2013 09:06:15 +1030	[thread overview]
Message-ID: <20131210223615.GA10239@bubble.grove.modra.org> (raw)
In-Reply-To: <CAMe9rOob2T+VWkZyHpaoBy6fUeTyAocpw4-cBpdrar2rtdAeew@mail.gmail.com>

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

  reply	other threads:[~2013-12-10 22:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-10  3:10 RFC: binutils PATCH: Set e_type to ET_EXEC for -pie -Ttext-segment= H.J. Lu
2013-12-10 22:36 ` Alan Modra [this message]
2013-12-10 22:47   ` H.J. Lu
2013-12-12 15:42     ` H.J. Lu
  -- strict thread matches above, loose matches on Subject: below --
2013-12-10 12:20 H.J. Lu
2013-12-10 19:08 ` H. Peter Anvin
2013-12-10 19:15   ` H.J. Lu
2013-12-10 19:26     ` H. Peter Anvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131210223615.GA10239@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=hjl.tools@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox