mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: 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: Thu, 12 Dec 2013 07:42:24 -0800	[thread overview]
Message-ID: <CAMe9rOoJvfJ-R3zBwPEcpiULfCdRXPRpayZCaMmXf3k7014izw@mail.gmail.com> (raw)
In-Reply-To: <CAMe9rOr9L7OmdxGyzgiWuTTBXy4A+qUVa+3Mar+J_hE8H=rRZg@mail.gmail.com>

On Tue, Dec 10, 2013 at 2:47 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Dec 10, 2013 at 2:36 PM, Alan Modra <amodra@gmail.com> wrote:
>> 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.
>>
>
> Kernel should have some freedom on where to load ET_DYN object.
> But when -Ttext-segment= is used, programmer expects the
> executable will be loaded at the specified address.  Setting
> ET_EXEC will guarantee that it will be loaded at that address.
>

I checked it in with 2 testcases.

-- 
H.J.

  reply	other threads:[~2013-12-12 15:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-10  3:10 H.J. Lu
2013-12-10 22:36 ` Alan Modra
2013-12-10 22:47   ` H.J. Lu
2013-12-12 15:42     ` H.J. Lu [this message]
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=CAMe9rOoJvfJ-R3zBwPEcpiULfCdRXPRpayZCaMmXf3k7014izw@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=binutils@sourceware.org \
    --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

all inboxes | Powered by JetHome®