[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ORIGIN-based runpaths in Bison
From: |
Jeffrey Walton |
Subject: |
ORIGIN-based runpaths in Bison |
Date: |
Wed, 13 Jan 2021 15:43:23 -0500 |
Hi Everyone/Akim,
I noticed Bison does not handle ORIGIN-based rpaths and runpaths properly.
Here's a test case you can use:
CFLAGS="-I/usr/local/include"
LDFLAGS="-L/usr/local/lib -Wl,-R,'$ORIGIN/../lib'
-Wl,--enable-new-dtags -Wl,-z,origin"
export CFLAGS LDFLAGS
./configure ...
After building an executable or a lib, perform the following to see if
it is munged:
readelf -d <file> | grep -E 'RPATH|RUNPATH'
The '$' should be intact:
readelf -d /usr/local/bin/openssl | grep -E 'RPATH|RUNPATH'
... Library runpath: [$ORIGIN/../lib]
In general, one of the munges is the "$O" in "$ORIGIN" will be
interpreted as a make variable. I have seen this with Bison, too. You
will see:
readelf -d /usr/local/bin/openssl | grep -E 'RPATH|RUNPATH'
... Library runpath: [RIGIN/../lib]
Another munge I have seen is a number getting added to the rpath or
runpath. I have _not_ seen this with Bison. I'm not sure where the
number comes from, but I believe it has to do with using a slash to
[try] preserve the dollar sign in the makefile.
readelf -d /usr/local/bin/openssl | grep -E 'RPATH|RUNPATH'
... Library runpath: [312946ORIGIN/../lib]
Or maybe:
readelf -d /usr/local/bin/openssl | grep -E 'RPATH|RUNPATH'
... Library runpath: [312946$ORIGIN/../lib]
Getting '$ORIGIN/../lib' to pass through configure and the makefile is
tricky. During configure, the '$' is not escaped and you use
'$ORIGIN/../lib'. Otherwise you fail feature tests. During make, '$'
needs to be escaped so you need '$$ORIGIN/../lib' written in the
makefile. Otherwise compilation fails or the runpath gets munged.
ORIGIN-based rpaths (without --enable-new-dtags) and runpaths (with
--enable-new-dtags) are actually covered in the ld(1) man page. There
are three special tokens recognized by ld - $ORIGIN, $LIB and
$PLATFORM. Also see https://man7.org/linux/man-pages/man1/ld.1.html.
Jeff
- ORIGIN-based runpaths in Bison,
Jeffrey Walton <=