From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: buildroot@busybox.net
Subject: [Buildroot] Bug in RPATH fixing logic
Date: Sun, 12 Nov 2017 17:40:13 +0100 [thread overview]
Message-ID: <20171112174013.25d90333@windsurf.home> (raw)
Hello,
I found a bug in the RPATH fixing logic. On ARC, some of the binutils
programs (ar and ranlib at least) are linked with libfl.so.2, which
is provided by Buildroot in $(HOST_DIR)/lib.
However, after "make sdk" has been called, ar and ranlib don't have any
RPATH encoded. I debugged this and here is what happens:
First, fix-rpath fixes the RPATH of $(HOST_DIR)/bin/<tuple>-ar:
/opt/br-arcle-hs38-full-2017.11-rc1/bin/patchelf --debug --make-rpath-relative /opt/br-arcle-hs38-full-2017.11-rc1 --relative-to-file /opt/br-arcle-hs38-full-2017.11-rc1/bin/arc-buildroot-linux-uclibc-ar
patching ELF file `/opt/br-arcle-hs38-full-2017.11-rc1/bin/arc-buildroot-linux-uclibc-ar'
Kernel page size is 4096 bytes
keeping relative path of /opt/br-arcle-hs38-full-2017.11-rc1/lib
new rpath is `$ORIGIN/../lib'
Here, everything is fine, the rpath is $ORIGIN/../lib.
However, fix-rpath moves on and fixes $(HOST_DIR)/<tuple>/bin/ar:
/opt/br-arcle-hs38-full-2017.11-rc1/bin/patchelf --debug --make-rpath-relative /opt/br-arcle-hs38-full-2017.11-rc1 --relative-to-file /opt/br-arcle-hs38-full-2017.11-rc1/arc-buildroot-linux-uclibc/bin/ar
patching ELF file `/opt/br-arcle-hs38-full-2017.11-rc1/arc-buildroot-linux-uclibc/bin/ar'
Kernel page size is 4096 bytes
removing directory '$ORIGIN/../lib' from RPATH because it does not contain needed libs
new rpath is `'
The gotcha is that $(HOST_DIR)/<tuple>/bin/ar and
$(HOST_DIR)/bin/<tuple>-ar are the same files: they are hard links!
So, when $(HOST_DIR)/bin/<tuple>-ar is fixed, everything is fine
because the library we depend on is indeed located
in /opt/br-arcle-hs38-full-2017.11-rc1/lib/, which is the hardcoded
RPATH. It gets fixed to $ORIGIN/../lib, as should be the case.
However, when we get to $(HOST_DIR)/<tuple>/bin/ar, libfl.so.2 is not
found in $ORIGIN/../lib (because it should be $ORIGIN/../../lib), and
patchelf decides to remove the rpath entirely.
So, we have two things that are a bit weird here:
- Why are the binutils linked to libfl ? This happens only on the ARC
architecture, where we use a special version of binutils that gets
autoreconf'ed.
- The absolute rpath in $(HOST_DIR)/<tuple>/bin/ar is wrong in the
first place, but I'm not sure how to fix this.
Wolfgang, Arnout, do you have any idea?
You can reproduce this by building an ARC toolchain, and look at the
(absence of) rpath on bin/<tuple>-ar.
Best regards,
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
next reply other threads:[~2017-11-12 16:40 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-12 16:40 Thomas Petazzoni [this message]
2017-11-12 16:49 ` [Buildroot] Bug in RPATH fixing logic Thomas Petazzoni
2017-11-12 17:15 ` Peter Korsgaard
2017-11-12 17:24 ` Thomas Petazzoni
2017-11-12 17:42 ` Yann E. MORIN
2017-11-13 7:17 ` Wolfgang Grandegger
2017-11-13 13:50 ` Peter Korsgaard
2017-11-13 15:19 ` Wolfgang Grandegger
2017-11-13 17:36 ` Yann E. MORIN
2017-11-13 18:04 ` Wolfgang Grandegger
2017-11-13 20:23 ` Peter Korsgaard
2017-11-13 20:33 ` Yann E. MORIN
2017-11-14 8:00 ` Wolfgang Grandegger
2017-11-14 9:05 ` Wolfgang Grandegger
2017-11-14 10:39 ` Peter Korsgaard
2017-11-12 18:03 ` Peter Korsgaard
2017-11-12 19:04 ` Wolfgang Grandegger
2017-11-12 19:35 ` Wolfgang Grandegger
2017-11-12 20:37 ` Thomas Petazzoni
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=20171112174013.25d90333@windsurf.home \
--to=thomas.petazzoni@free-electrons.com \
--cc=buildroot@busybox.net \
/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