Workaround for bug #7172: patchelf (branch yem/patchelf)
v2 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
Changes v1 -> v2:
- fix typoes (Thomas DS)
Regards,
Yann E. MORIN.
The following changes since commit 26aefa672c96caefc17adf59a9ab3d327114ad36:
bind: fix static openssl linking (2014-07-30 23:51:51 +0200)
are available in the git repository at:
git://gitorious.org/buildroot/buildroot.git yem/patchelf
for you to fetch changes up to fc8f5090621f94da255a6191eec78125047eb318:
package/patchelf: new host package (2014-07-31 00:44:25 +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 v2 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 unmolested. But it is not that simple either, since it still contains a $ sign, and there is not much certainty as 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
@@ -132,6 +132,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 v2 1/2 toolchain: linker options with a $ sign are not supported
Quoted 49 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...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 unmolested. But it is not that simple either, since it still contains a $ sign, and there is not much certainty as 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
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 140
Quoted 9 lines
toolchain/toolchain-common.in +3
-0@@ -132,6 +132,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
Thomas Petazzoni
AppliedPATCH v2 1/2 toolchain: linker options with a $ sign are not supported
In reply to Yann E. MORINDear Yann E. MORIN,
Quoted 20 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...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 unmolested. But it is not that simple either, since it still contains a $ sign, and there is not much certainty as 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.
Quoted 8 lines
[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(+)
Applied, thanks.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v2 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 if not already present
- do the above to the DT_RPATH tag, too
- set the path to the interpreter
- remove DT_NEEDED tags
- query a binary for the DT_RUNPATH/DT_RPATH tag, or for the interpreter path
Does not really fix #7172, but this is an appropriate 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 v2 2/2 package/patchelf: new host package
Hi Yann,
Quoted 16 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 if not already present
- do the above to theDT_RPATHtag, too
- set the path to the interpreter
- removeDT_NEEDEDtags
- query a binary for the DT_RUNPATH/DT_RPATH tag, or for the interpreter path
Quoted 1 line
Does not really fix #7172, but this is an appropriate workaround.
Maybe this is worth a mention as a workaround to the known issue of #7172 in the manual?
baruch
Signature · 3 lines
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -PATCH v2 2/2 package/patchelf: new host package
In reply to Yann E. MORINQuoted 61 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 if not already present
- do the above to theDT_RPATHtag, too
- set the path to the interpreter
- removeDT_NEEDEDtags
- query a binary for the DT_RUNPATH/DT_RPATH tag, or for the interpreter pathDoes not really fix #7172, but this is an appropriate 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 +2
-0@@ -0,0 +1,12 @@ +################################################################################ +#
package/patchelf/patchelf.mk line 12
Quoted 10 lines
package/patchelf/patchelf.mk new file +10
-0+# 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))
I do agree with Baruch's comment that it will be helpful for users desiring to use $ in the LDFLAGS to know that patchelf exists in buildroot. This could be added in the first patch of this series, or as a third patch.
Best regards,
Thomas
PATCH v2 2/2 package/patchelf: new host package
In reply to Yann E. MORINDear Yann E. MORIN,
Quoted 59 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 if not already present
- do the above to theDT_RPATHtag, too
- set the path to the interpreter
- removeDT_NEEDEDtags
- query a binary for the DT_RUNPATH/DT_RPATH tag, or for the interpreter pathDoes not really fix #7172, but this is an appropriate 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 +0
-0
package/patchelf/patchelf.mk line 9
Quoted 9 lines
package/patchelf/patchelf.mk new file +9
-0@@ -0,0 +1,12 @@ +################################################################################ +# +# patchelf +# +################################################################################ + +PATCHELF_VERSION = 0.8 +PATCHELF_SITE = http://releases.nixos.org/patchelf/patchelf-0.8/ +PATCHELF_LICENSE = GPLv3
The license is actually GPLv3+, see the README file of the project.
package/patchelf/patchelf.mk line 12
Quoted 3 lines
package/patchelf/patchelf.mk new file +3
-0+PATCHELF_LICENSE_FILES = COPYING + +$(eval $(host-autotools-package))
Other than that, applied, thanks!
I think it would be good to use that to make the toolchain relocatable, instead of something like http://patchwork.ozlabs.org/patch/359841/.
What do you think?
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v2 2/2 package/patchelf: new host package
Thomas, Samuel, All,
On 2014-07-31 23:55 +0200, Thomas Petazzoni spake thusly:
Quoted 7 lines · Yann E. MORIN
Quoted 6 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.
[--SNIP--]
Quoted 2 lines
Quoted 1 line
+PATCHELF_LICENSE = GPLv3
The license is actually GPLv3+, see the README file of the project.
[--SNIP--]
Quoted 1 line
Other than that, applied, thanks!
Thanks! :-)
Quoted 3 lines
I think it would be good to use that to make the toolchain relocatable, instead of something like http://patchwork.ozlabs.org/patch/359841/.
What do you think?
I think that Samuel already has a WIP branch on making a relocatable
SDK: https://github.com/tSed/buildroot/tree/sma/reloc-sdk/wip
So, Samuel, what do you think of it? ;-)
(Note how fast I was able to elude and reassign the question?)
Regards,
Yann E. MORIN.
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. | '------------------------------^-------^------------------^--------------------'