Workaround for bug #7172: patchelf (branch yem/patchelf)
cover Workaround for bug #7172: patchelf (branch yem/patchelf)
Hello All!
This series introduces a workaround for the limitations expressed in bug #7172 [0], which explains that a variable containing a $ sign is incorrectly expanded.
Since it is not trivial to actually fix #7172, this series implements a workaround, by:
- explaining the limitation in the menuconfig and the manual
- adding patchelf as a host-package, so users can tweak ELF files after the build (e.g. in a post-build script)
[0] https://bugs.buildroot.org/show_bug.cgi?id=7172
Regards,
Yann E. MORIN.
The following changes since commit 30252ae893298bf3f190b57d33c545e0e46c40db:
libgpgme: disable all tests (2014-07-12 20:47:38 +0200)
are available in the git repository at:
git://ymorin.is-a-geek.org/buildroot yem/patchelf
for you to fetch changes up to a8d871e1d1bf5eb507d24eac6f5dd51cda98a326:
package/patchelf: new host package (2014-07-13 16:38:43 +0200)
----------------------------------------------------------------
Yann E. MORIN (2):
toolchain: linker options with a $ sign are not supported package/patchelf: new host package
docs/manual/known-issues.txt | 4 ++++ package/Config.in.host | 1 + package/patchelf/Config.in.host | 7 +++++++ package/patchelf/patchelf.mk | 12 ++++++++++++ toolchain/toolchain-common.in | 3 +++ 5 files changed, 27 insertions(+) create mode 100644 package/patchelf/Config.in.host create mode 100644 package/patchelf/patchelf.mk
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 1/2 toolchain: linker options with a $ sign are not supported
As reported in bug #7172 [0], setting BR2_TARGET_LDFLAGS to a value containing a $ sign can lead to unexpected results.
This is because it is very hard to know when the $ sign gets evaluated:
- in the Buildroot-level make
- in the shell called by the Buildroot-level make
- in the package's own build-system, either at configure time, in the Makefile, in a shell in the Makefile...
So, it is very difficult to know how much escaping that would need.
A proposal is to use a shell variable to pass such values in-molested. But it is not that simple either, since it still contains a $ sign, and there no much certainty to when it would be evaluated.
Instead, just document this limitation, both in the help text for BR2_TARGET_LDFLAGS, and in the known-issues section in the manual.
Does not really fix #7172, but at least the limitation is documented.
[0] https://bugs.buildroot.org/show_bug.cgi?id=7172
--- docs/manual/known-issues.txt | 4 ++++ toolchain/toolchain-common.in | 3 +++ 2 files changed, 7 insertions(+)
docs/manual/known-issues.txt +4 -0
@@ -3,6 +3,10 @@ = Known issues +* It is not possible to pass extra linker options via +BR2_TARGET_LDFLAGS+ + if such options contain a +$+ sign. For example, the following is known + to break: +BR2_TARGET_LDFLAGS="-Wl,-rpath=\'$ORIGIN/../lib'"+ + * The +ltp-testsuite+ package does not build with the default uClibc configuration used by the Buildroot toolchain backend. The LTP testsuite uses several functions that are considered obsolete, such
toolchain/toolchain-common.in +3 -0
@@ -110,6 +110,9 @@ config BR2_TARGET_LDFLAGS help Extra options to pass to the linker when building for the target. + Note that options with a '$' sign (eg. -Wl,-rpath='$ORIGIN/../lib') + are not supported. + config BR2_ECLIPSE_REGISTER bool "Register toolchain within Eclipse Buildroot plug-in" help
Signature · 1 line
1.9.1
PATCH 1/2 toolchain: linker options with a $ sign are not supported
Hi Yann,
Quoted 9 lines · Yann E. MORIN
As reported in bug #7172 [0], setting
BR2_TARGET_LDFLAGSto a value containing a $ sign can lead to unexpected results.This is because it is very hard to know when the $ sign gets evaluated:
- in the Buildroot-level make
- in the shell called by the Buildroot-level make
- in the package's own build-system, either at configure time, in theMakefile, in a shell in theMakefile...
Quoted 3 lines
So, it is very difficult to know how much escaping that would need.
A proposal is to use a shell variable to pass such values in-molested.
'in-molested' sounds very odd to me. If you want to keep the expressive value ;-) you could maybe write non-molested, or unmolested (I don't really know the right prefix here, but I'm pretty sure that 'in' is not the one), or otherwise maybe 'untouched' ?
Quoted 2 lines
But it is not that simple either, since it still contains a $ sign, and there no much certainty to when it would be evaluated.
s/no/not/
Quoted 35 lines
Instead, just document this limitation, both in the help text for
BR2_TARGET_LDFLAGS, and in the known-issues section in the manual.Does not really fix #7172, but at least the limitation is documented.
[0] https://bugs.buildroot.org/show_bug.cgi?id=7172
Signed-off-by "Yann E. MORIN" <[email protected]>Cc Mike Zick <[email protected]>--- docs/manual/known-issues.txt | 4 ++++ toolchain/toolchain-common.in | 3 +++ 2 files changed, 7 insertions(+)docs/manual/known-issues.txt +4
-0@@ -3,6 +3,10 @@ = Known issues +* It is not possible to pass extra linker options via +BR2_TARGET_LDFLAGS+ + if such options contain a +$+ sign. For example, the following is known + to break: +BR2_TARGET_LDFLAGS="-Wl,-rpath=\'$ORIGIN/../lib'"+ + * The +ltp-testsuite+ package does not build with the default uClibc configuration used by the Buildroot toolchain backend. The LTP testsuite uses several functions that are considered obsolete, suchtoolchain/toolchain-common.in +0
-0
toolchain/toolchain-common.in config BR2_TARGET_LDFLAGS · line 118
Quoted 9 lines
toolchain/toolchain-common.in +3
-0@@ -110,6 +110,9 @@ config BR2_TARGET_LDFLAGS help Extra options to pass to the linker when building for the target. + Note that options with a '$' sign (eg. -Wl,-rpath='$ORIGIN/../lib') + are not supported. + config BR2_ECLIPSE_REGISTER bool "Register toolchain within Eclipse Buildroot plug-in" help
Thanks for working on this!
Best regards,
Thomas
PATCH 1/2 toolchain: linker options with a $ sign are not supported
Thomas, All,
On 2014-07-14 10:16 +0200, Thomas De Schampheleire spake thusly:
Quoted 10 lines · Yann E. MORIN
Quoted 9 lines
As reported in bug #7172 [0], setting
BR2_TARGET_LDFLAGSto a value containing a $ sign can lead to unexpected results.This is because it is very hard to know when the $ sign gets evaluated:
- in the Buildroot-level make
- in the shell called by the Buildroot-level make
- in the package's own build-system, either at configure time, in theMakefile, in a shell in theMakefile...
Quoted 8 lines
Quoted 3 lines
So, it is very difficult to know how much escaping that would need.
A proposal is to use a shell variable to pass such values in-molested.
'in-molested' sounds very odd to me. If you want to keep the expressive value ;-) you could maybe write non-molested, or unmolested (I don't really know the right prefix here, but I'm pretty sure that 'in' is not the one), or otherwise maybe 'untouched' ?
Yep, my fingers are not so precise, and hit the wrong key. No matter how many times I re-read myself, I always miss typoes.
Quoted 3 lines
Quoted 2 lines
But it is not that simple either, since it still contains a $ sign, and there no much certainty to when it would be evaluated.
s/no/not/
Both fixed, thanks.
Regards,
Yann E. MORIN.
Quoted 49 lines
Quoted 34 lines
Instead, just document this limitation, both in the help text for
BR2_TARGET_LDFLAGS, and in the known-issues section in the manual.Does not really fix #7172, but at least the limitation is documented.
[0] https://bugs.buildroot.org/show_bug.cgi?id=7172
Signed-off-by "Yann E. MORIN" <[email protected]>Cc Mike Zick <[email protected]>--- docs/manual/known-issues.txt | 4 ++++ toolchain/toolchain-common.in | 3 +++ 2 files changed, 7 insertions(+)docs/manual/known-issues.txt +4
-0@@ -3,6 +3,10 @@ = Known issues +* It is not possible to pass extra linker options via +BR2_TARGET_LDFLAGS+ + if such options contain a +$+ sign. For example, the following is known + to break: +BR2_TARGET_LDFLAGS="-Wl,-rpath=\'$ORIGIN/../lib'"+ + * The +ltp-testsuite+ package does not build with the default uClibc configuration used by the Buildroot toolchain backend. The LTP testsuite uses several functions that are considered obsolete, suchtoolchain/toolchain-common.in +0
-0toolchain/toolchain-common.in config BR2_TARGET_LDFLAGS · line 118
Quoted 9 lines
toolchain/toolchain-common.in +3
-0@@ -110,6 +110,9 @@ config BR2_TARGET_LDFLAGS help Extra options to pass to the linker when building for the target. + Note that options with a '$' sign (eg. -Wl,-rpath='$ORIGIN/../lib') + are not supported. + config BR2_ECLIPSE_REGISTER bool "Register toolchain within Eclipse Buildroot plug-in" helpThanks for working on this!
Best regards,
Thomas
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 2/2 package/patchelf: new host package
In reply to Yann E. MORINIn some situations, users may want to tweak the dynamic section of the binaries (for example to add/set the RPATH to $ORIGIN/../lib).
Because it is not trivial to do it properly from the Buildroot infrastructure, allow those users to use patchelf (e.g. from a post-build script) to tweak binaries.
patchelf is able to:
- modify an existing DT_RUNPATH tags
- add a DT_RUNPATH tag is not already present
- do the above to the DT_RPATH tag, too
- set the path to the interpreter
- remove DT_NEEDED tags
- query a inary for the DT_RUNPATH/DT_RPATH tag, or for the interpreter path
Does not really fix #7172, but this is workaround.
--- package/Config.in.host | 1 + package/patchelf/Config.in.host | 7 +++++++ package/patchelf/patchelf.mk | 12 ++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 package/patchelf/Config.in.host create mode 100644 package/patchelf/patchelf.mk
package/Config.in.host +1 -0
@@ -13,6 +13,7 @@ menu "Host utilities" source "package/omap-u-boot-utils/Config.in.host" source "package/openocd/Config.in.host" source "package/parted/Config.in.host" + source "package/patchelf/Config.in.host" source "package/pwgen/Config.in.host" source "package/sam-ba/Config.in.host" source "package/squashfs/Config.in.host"
package/patchelf/Config.in.host new file +7 -0
@@ -0,0 +1,7 @@ +config BR2_PACKAGE_HOST_PATCHELF + bool "host patchelf" + help + PatchELF is a small utility to modify the dynamic linker + and RPATH of ELF executables. + + http://nixos.org/patchelf.html
package/patchelf/patchelf.mk new file +12 -0
@@ -0,0 +1,12 @@ +################################################################################ +# +# patchelf +# +################################################################################ + +PATCHELF_VERSION = 0.8 +PATCHELF_SITE = http://releases.nixos.org/patchelf/patchelf-0.8/ +PATCHELF_LICENSE = GPLv3 +PATCHELF_LICENSE_FILES = COPYING + +$(eval $(host-autotools-package))
Signature · 1 line
1.9.1
PATCH 2/2 package/patchelf: new host package
Hi Yann,
Quoted 10 lines · Yann E. MORIN
In some situations, users may want to tweak the dynamic section of the binaries (for example to add/set the RPATH to $ORIGIN/../lib).
Because it is not trivial to do it properly from the Buildroot infrastructure, allow those users to use patchelf (e.g. from a post-build script) to tweak binaries.
patchelf is able to:
- modify an existingDT_RUNPATHtags
- add aDT_RUNPATHtag is not already present
s/is/if/
Quoted 4 lines
- do the above to the
DT_RPATHtag, too
- set the path to the interpreter
- removeDT_NEEDEDtags
- query a inary for the DT_RUNPATH/DT_RPATH tag, or for the
s/inary/binary/
Quoted 48 lines
interpreter path
Does not really fix #7172, but this is workaround.
Signed-off-by "Yann E. MORIN" <[email protected]>Cc Mike Zick <[email protected]>--- package/Config.in.host | 1 + package/patchelf/Config.in.host | 7 +++++++ package/patchelf/patchelf.mk | 12 ++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 package/patchelf/Config.in.host create mode 100644 package/patchelf/patchelf.mkpackage/Config.in.host +1
-0@@ -13,6 +13,7 @@ menu "Host utilities" source "package/omap-u-boot-utils/Config.in.host" source "package/openocd/Config.in.host" source "package/parted/Config.in.host" + source "package/patchelf/Config.in.host" source "package/pwgen/Config.in.host" source "package/sam-ba/Config.in.host" source "package/squashfs/Config.in.host"package/patchelf/Config.in.host new file +7
-0@@ -0,0 +1,7 @@ +config BR2_PACKAGE_HOST_PATCHELF + bool "host patchelf" + help + PatchELF is a small utility to modify the dynamic linker + and RPATH of ELF executables. + + http://nixos.org/patchelf.htmlpackage/patchelf/patchelf.mk new file +3
-0@@ -0,0 +1,12 @@ +################################################################################ +# +# patchelf
package/patchelf/patchelf.mk
Quoted 10 lines
package/patchelf/patchelf.mk new file +9
-1+# +################################################################################ + +PATCHELF_VERSION = 0.8 +PATCHELF_SITE = http://releases.nixos.org/patchelf/patchelf-0.8/ +PATCHELF_LICENSE = GPLv3 +PATCHELF_LICENSE_FILES = COPYING + +$(eval $(host-autotools-package)) --
Best regards,
Thomas
PATCH 2/2 package/patchelf: new host package
Thomas, All,
On 2014-07-14 10:18 +0200, Thomas De Schampheleire spake thusly:
Quoted 12 lines · Yann E. MORIN
Quoted 10 lines
In some situations, users may want to tweak the dynamic section of the binaries (for example to add/set the RPATH to $ORIGIN/../lib).
Because it is not trivial to do it properly from the Buildroot infrastructure, allow those users to use patchelf (e.g. from a post-build script) to tweak binaries.
patchelf is able to:
- modify an existingDT_RUNPATHtags
- add aDT_RUNPATHtag is not already present
Quoted 8 lines
s/is/if/
Quoted 4 lines
- do the above to the
DT_RPATHtag, too
- set the path to the interpreter
- removeDT_NEEDEDtags
- query a inary for the DT_RUNPATH/DT_RPATH tag, or for thes/inary/binary/
Both fixed, thanks
Regards,
Yann E. MORIN.
Quoted 61 lines
Quoted 48 lines
interpreter path
Does not really fix #7172, but this is workaround.
Signed-off-by "Yann E. MORIN" <[email protected]>Cc Mike Zick <[email protected]>--- package/Config.in.host | 1 + package/patchelf/Config.in.host | 7 +++++++ package/patchelf/patchelf.mk | 12 ++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 package/patchelf/Config.in.host create mode 100644 package/patchelf/patchelf.mkpackage/Config.in.host +1
-0@@ -13,6 +13,7 @@ menu "Host utilities" source "package/omap-u-boot-utils/Config.in.host" source "package/openocd/Config.in.host" source "package/parted/Config.in.host" + source "package/patchelf/Config.in.host" source "package/pwgen/Config.in.host" source "package/sam-ba/Config.in.host" source "package/squashfs/Config.in.host"package/patchelf/Config.in.host new file +7
-0@@ -0,0 +1,7 @@ +config BR2_PACKAGE_HOST_PATCHELF + bool "host patchelf" + help + PatchELF is a small utility to modify the dynamic linker + and RPATH of ELF executables. + + http://nixos.org/patchelf.htmlpackage/patchelf/patchelf.mk new file +3
-0@@ -0,0 +1,12 @@ +################################################################################ +# +# patchelfpackage/patchelf/patchelf.mk
Quoted 10 lines
package/patchelf/patchelf.mk new file +9
-1+# +################################################################################ + +PATCHELF_VERSION = 0.8 +PATCHELF_SITE = http://releases.nixos.org/patchelf/patchelf-0.8/ +PATCHELF_LICENSE = GPLv3 +PATCHELF_LICENSE_FILES = COPYING + +$(eval $(host-autotools-package)) --Best regards,
Thomas
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'