This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH 0/6] ld: Add "-z textonly" option to ELF linker
- From: Michael Matz <matz at suse dot de>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Nick Clifton <nickc at redhat dot com>, Binutils <binutils at sourceware dot org>
- Date: Mon, 8 Jan 2018 16:26:17 +0100 (CET)
- Subject: Re: [PATCH 0/6] ld: Add "-z textonly" option to ELF linker
- Authentication-results: sourceware.org; auth=none
- References: <20171113230830.3334-1-hjl.tools@gmail.com> <alpine.LSU.2.21.1711141339340.25295@wotan.suse.de> <CAMe9rOrNabBomX=mC8L0BCwwXqLgOnpsz9xuWu0hKHg6tQE2Ew@mail.gmail.com> <alpine.LSU.2.21.1711141434250.25295@wotan.suse.de> <CAMe9rOqOdfti42WYY+qSfxOF4fqGToRPbQ4=Oi+Zy+Y+1-s=mg@mail.gmail.com> <CAMe9rOrnEdUMa-Jo1XXkkBnXaoCiU2ySZVbGv7re7pTQWEQfaA@mail.gmail.com>
Hi,
On Mon, 8 Jan 2018, H.J. Lu wrote:
> On Tue, Nov 14, 2017 at 6:41 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> > On Tue, Nov 14, 2017 at 5:58 AM, Michael Matz <matz@suse.de> wrote:
> >> Hi,
> >>
> >> On Tue, 14 Nov 2017, H.J. Lu wrote:
> >>
> >>> > This is the result of the above problem, but it's not necessary. Like in
> >>> > a traditional two-LOAD-segment file, which also isn't larger than 2MB,
> >>> > just because the page size is 2MB. It achieves this by mapping the same
> >>> > file bytes multiple times, and you could do the same. E.g. for the file
> >>> > above the better layout would be:
> >>> >
> >>> > LOAD 0x000000 0x00000000 0x00000000 0x00200 0x00200 R 0x200000
> >>> > LOAD 0x000fd0 0x00200fd0 0x00200fd0 0x0002b 0x0002b R E 0x200000
> >>> > LOAD 0x001000 0x00201000 0x00201000 0x00058 0x00058 R 0x200000
> >>> > LOAD 0x001060 0x00401060 0x00401060 0x000a0 0x000a0 RW 0x200000
> >>> >
> >>> > But even then something is wrong: The RE and the second R page are both
> >>> > mapped onto 0x0020xxxx, i.e. the same 2MB page, so can't have different
> >>> > protections. (You'd need 4k pages again, which defeats the whole purpose
> >>> > of having 2MB pages in the file to start with).
> >>>
> >>> You have found out yourself that it is impossible.
> >>
> >> Well, as is the above makes not much sense. It wants to stay at 2MB
> >> alignment but can't actually make use of it due to having protection
> >> changes within one 2MB page (from RE to R). Hmm, which means the very
> >> introduction of GNU_RELRO already broke the whole 2MB pages optimization
> >> :-/ You're just increasing this detrimental effect to now also cause
> >> uselessly huge files.
> >
> > GNU_RELRO is intended for common page size, which is 4K on x86-64. If
> > the page size is 2MB at run-time, GNU_RELRO isn't applied.
> >
> >> Probably 4k pages should be default with "-z textonly" Hmpf :(
> >
> > We can discuss this after "-z textonly" is checked in.
> >
>
> Given what happened, I'd like to check this patch set into binutils
> 2.30.
I'm assuming you mean Spectre and Meltdown? I'm not sure what those have
to do with your patch. I don't see what changed since November; I still
think 4k pages should be default for this new option (and eventually also
for GNU_RELRO, as even there 2MB pages are effectively useless). Note
that I haven't anything against the page per se (and don't have any say
anyway); just the name is a bit generic, "textonly" ... what's that
supposed to mean? :) -z separate-text-segment perhaps?
Ciao,
Michael.