From: Lukasz Majewski <lukma@denx.de>
To: Florian Weimer <fweimer@redhat.com>
Cc: "Szabolcs Nagy" <Szabolcs.Nagy@arm.com>,
"Fāng-ruì Sòng" <maskray@google.com>,
"H.J. Lu" <hjl.tools@gmail.com>,
libc-alpha <libc-alpha@sourceware.org>,
"Patches and discussions about the oe-core layer"
<openembedded-core@lists.openembedded.org>,
"Andreas Schwab" <schwab@linux-m68k.org>,
"Joseph Myers" <joseph@codesourcery.com>
Subject: Re: [PATCH v2] dl: Use "adr" assembler command to get proper load address on ARM
Date: Tue, 19 Oct 2021 14:03:18 +0200 [thread overview]
Message-ID: <20211019140318.08a26ca0@ktm> (raw)
In-Reply-To: <871r4iftvc.fsf@oldenburg.str.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3149 bytes --]
Hi Florian,
> * Szabolcs Nagy:
>
> > i don't know much about pelinking, but i'd expect that ld.so
> > has to be prelinked for it to work:
> >
> > if the kernel can load ld.so anywhere it will conflict with
> > other libraries that prelinking allocated to a fixed location.
>
> I think ld.so can back out prelinking if it detects any conflicts.
> (ld.so doesn't use MAP_FIXED for the initial ET_DYN mapping even when
> prelinking.)
>
> > instead ld.so has to be prelinked to an offset that comes after
> > all other prelinked libraries in the system, then the kernel
> > will place it after all other libraries at runtime.
> >
> > i don't have a prelinked system to check if this is the case.
>
> I tried on glibc 2.12-based system with prelink enabled and got this:
>
> # ldd /bin/bash
> linux-vdso.so.1 => (0x00007ffc7e798000)
> libtinfo.so.5 => /lib64/libtinfo.so.5 (0x0000003da9800000)
> libdl.so.2 => /lib64/libdl.so.2 (0x0000003da7400000)
> libc.so.6 => /lib64/libc.so.6 (0x0000003da7800000)
> /lib64/ld-linux-x86-64.so.2 (0x00007f8dc919c000)
> # ldd /bin/bash
> linux-vdso.so.1 => (0x00007ffef3bf4000)
> libtinfo.so.5 => /lib64/libtinfo.so.5 (0x0000003da9800000)
> libdl.so.2 => /lib64/libdl.so.2 (0x0000003da7400000)
> libc.so.6 => /lib64/libc.so.6 (0x0000003da7800000)
> /lib64/ld-linux-x86-64.so.2 (0x00007ff9e66a6000)
> # eu-readelf -d /lib64/ld-linux-x86-64.so.2
>
> Dynamic segment contains 25 entries:
> Addr: 0x0000003da7220df0 Offset: 0x020df0 Link to section: [ 5]
> '.dynstr' Type Value
> SONAME Library soname: [ld-linux-x86-64.so.2]
> HASH 0x0000003da70001f0
> GNU_HASH 0x0000003da70002a8
> STRTAB 0x0000003da7000608
> SYMTAB 0x0000003da7000380
> STRSZ 380 (bytes)
> SYMENT 24 (bytes)
> PLTGOT 0x0000003da7220f80
> PLTRELSZ 144 (bytes)
> PLTREL RELA
> JMPREL 0x0000003da7000a30
> RELA 0x0000003da7000868
> RELASZ 456 (bytes)
> RELAENT 24 (bytes)
> VERDEF 0x0000003da70007c0
> VERDEFNUM 5
> BIND_NOW
> FLAGS_1 NOW
> VERSYM 0x0000003da7000784
> RELACOUNT 16
> CHECKSUM 0x00000000e90e92bc
> GNU_PRELINKED 0x00000000616d5a26
> NULL
> NULL
> NULL
> #
>
> As expected based on the previous discussion here, the kernel maps
> ld.so at random addresses even though it has been prelinked.
>
> This looks like another place where ASLR layout as to be tweaked
> carefully to avoid obscure failure modes.
Is the approach proposed by Szabolcs acceptable for 32 bit ARM? Or
shall we look for other way to proceed with this issue?
>
> Thanks,
> Florian
>
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2021-10-19 12:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210907131616.23472-1-lukma@denx.de>
[not found] ` <20211015075417.29931-1-lukma@denx.de>
[not found] ` <20211015120915.GD1982710@arm.com>
[not found] ` <CAMe9rOpPM7RmA65MzTNr2DtoC_wMFt87mnyJ4pgvmK5TAorCCQ@mail.gmail.com>
2021-10-15 12:59 ` [PATCH v2] dl: Use "adr" assembler command to get proper load address on ARM Lukasz Majewski
[not found] ` <CAFP8O3+DBOregW5SuaPErkHUt+5aqb=bL98wHGtXu-OwFwud+w@mail.gmail.com>
[not found] ` <20211018110818.GE1982710@arm.com>
[not found] ` <871r4iftvc.fsf@oldenburg.str.redhat.com>
2021-10-19 12:03 ` Lukasz Majewski [this message]
2021-10-25 10:18 ` Lukasz Majewski
[not found] ` <878ryhwgd7.fsf@oldenburg.str.redhat.com>
2021-10-25 10:53 ` Lukasz Majewski
[not found] ` <20211025133425.GN1982710@arm.com>
2021-10-25 14:04 ` Lukasz Majewski
[not found] ` <20211025150904.GO1982710@arm.com>
2021-10-25 18:25 ` Lukasz Majewski
[not found] ` <alpine.DEB.2.22.394.2110251718420.1572984@digraph.polyomino.org.uk>
2021-10-26 13:52 ` Lukasz Majewski
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=20211019140318.08a26ca0@ktm \
--to=lukma@denx.de \
--cc=Szabolcs.Nagy@arm.com \
--cc=fweimer@redhat.com \
--cc=hjl.tools@gmail.com \
--cc=joseph@codesourcery.com \
--cc=libc-alpha@sourceware.org \
--cc=maskray@google.com \
--cc=openembedded-core@lists.openembedded.org \
--cc=schwab@linux-m68k.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.