diff mbox

[2/2,v2] package/patchelf: new host package

Message ID fc8f5090621f94da255a6191eec78125047eb318.1406760999.git.yann.morin.1998@free.fr
State Accepted
Headers show

Commit Message

Yann E. MORIN July 30, 2014, 10:57 p.m. UTC
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 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.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Mike Zick <minimod@morethan.org>
---
 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

Comments

Baruch Siach July 31, 2014, 3:26 a.m. UTC | #1
Hi Yann,

On Thu, Jul 31, 2014 at 12:57:16AM +0200, Yann E. MORIN wrote:
> 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 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.

Maybe this is worth a mention as a workaround to the known issue of #7172 in 
the manual?

baruch
Thomas De Schampheleire July 31, 2014, 6:41 a.m. UTC | #2
On Thu, Jul 31, 2014 at 12:57 AM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> 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 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.
>
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Mike Zick <minimod@morethan.org>
> ---
>  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
>
> diff --git a/package/Config.in.host b/package/Config.in.host
> index 062c6c9..e05bbfa 100644
> --- a/package/Config.in.host
> +++ b/package/Config.in.host
> @@ -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"
> diff --git a/package/patchelf/Config.in.host b/package/patchelf/Config.in.host
> new file mode 100644
> index 0000000..d1c8375
> --- /dev/null
> +++ b/package/patchelf/Config.in.host
> @@ -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
> diff --git a/package/patchelf/patchelf.mk b/package/patchelf/patchelf.mk
> new file mode 100644
> index 0000000..1a8e48d
> --- /dev/null
> +++ b/package/patchelf/patchelf.mk
> @@ -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))

Reviewed-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>

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
Thomas Petazzoni July 31, 2014, 9:55 p.m. UTC | #3
Dear Yann E. MORIN,

On Thu, 31 Jul 2014 00:57:16 +0200, Yann E. MORIN wrote:
> 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 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.
> 
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Mike Zick <minimod@morethan.org>
> ---
>  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
> 
> diff --git a/package/Config.in.host b/package/Config.in.host
> index 062c6c9..e05bbfa 100644
> --- a/package/Config.in.host
> +++ b/package/Config.in.host
> @@ -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"
> diff --git a/package/patchelf/Config.in.host b/package/patchelf/Config.in.host
> new file mode 100644
> index 0000000..d1c8375
> --- /dev/null
> +++ b/package/patchelf/Config.in.host
> @@ -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
> diff --git a/package/patchelf/patchelf.mk b/package/patchelf/patchelf.mk
> new file mode 100644
> index 0000000..1a8e48d
> --- /dev/null
> +++ b/package/patchelf/patchelf.mk
> @@ -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.

> +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
Yann E. MORIN July 31, 2014, 10:05 p.m. UTC | #4
Thomas, Samuel, All,

On 2014-07-31 23:55 +0200, Thomas Petazzoni spake thusly:
> On Thu, 31 Jul 2014 00:57:16 +0200, Yann E. MORIN wrote:
> > 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--]
> > +PATCHELF_LICENSE = GPLv3
> The license is actually GPLv3+, see the README file of the project.
[--SNIP--]
> Other than that, applied, thanks!

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?

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.
diff mbox

Patch

diff --git a/package/Config.in.host b/package/Config.in.host
index 062c6c9..e05bbfa 100644
--- a/package/Config.in.host
+++ b/package/Config.in.host
@@ -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"
diff --git a/package/patchelf/Config.in.host b/package/patchelf/Config.in.host
new file mode 100644
index 0000000..d1c8375
--- /dev/null
+++ b/package/patchelf/Config.in.host
@@ -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
diff --git a/package/patchelf/patchelf.mk b/package/patchelf/patchelf.mk
new file mode 100644
index 0000000..1a8e48d
--- /dev/null
+++ b/package/patchelf/patchelf.mk
@@ -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))