Message ID | 1436824511-1601-3-git-send-email-s.martin49@gmail.com |
---|---|
State | Changes Requested |
Headers | show |
Hi Samuel, On Mon, Jul 13, 2015 at 11:55:09PM +0200, Samuel Martin wrote: > This patch introduces the TARGET_SANITIZE_RPATH_HOOK hook fixing the ELF > files' RPATH of the TARGET_DIR (excluding the sysroot). Are you sure sysroot is excluded? > After running this hook, the RPATH from any target ELF files won't > contain any occurence of the sysroot or some build locations. > > Signed-off-by: Samuel Martin <s.martin49@gmail.com> Tested-by: Baruch Siach <baruch@tkos.co.il> [ Build test only: verified that /sbin/ebtables preserves its RPATH (/lib/ebtables), and that /usr/sbin/visudo also preserves its target RPATH (/usr/libexec/sudo), while dropping the staging part ($(@D)/lib/util/.libs) ] baruch
Hi Baruch, On Tue, Jul 14, 2015 at 7:37 AM, Baruch Siach <baruch@tkos.co.il> wrote: > Hi Samuel, > > On Mon, Jul 13, 2015 at 11:55:09PM +0200, Samuel Martin wrote: >> This patch introduces the TARGET_SANITIZE_RPATH_HOOK hook fixing the ELF >> files' RPATH of the TARGET_DIR (excluding the sysroot). > > Are you sure sysroot is excluded? Yes, via $(STAGING_DIR). During my tests, I only saw /path/to/sysroot/usr/lib in the RPATH. So, I only remove paths similar to this (i.e. standard libdirs from the sysroot) in RPATH. > >> After running this hook, the RPATH from any target ELF files won't >> contain any occurence of the sysroot or some build locations. >> >> Signed-off-by: Samuel Martin <s.martin49@gmail.com> > > Tested-by: Baruch Siach <baruch@tkos.co.il> > > [ Build test only: verified that /sbin/ebtables preserves its RPATH > (/lib/ebtables), and that /usr/sbin/visudo also preserves its target RPATH > (/usr/libexec/sudo), while dropping the staging part ($(@D)/lib/util/.libs) > ] > > baruch > > -- > http://baruch.siach.name/blog/ ~. .~ Tk Open Systems > =}------------------------------------------------ooO--U--Ooo------------{= > - baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il - Thanks a lot for your careful review. :-) Regards,
diff --git a/Makefile b/Makefile index 4b88116..69c1105 100644 --- a/Makefile +++ b/Makefile @@ -558,6 +558,8 @@ endif # RPATH fixing # - The host hook sets RPATH in host ELF binaries, using relative paths to the # library locations. +# - The target hook sanitizes RPATH in target ELF binaries, removing pathes +# pointing to package's build directories or the sysroot's libdirs. PACKAGES += host-patchelf define HOST_FIX_RPATH_HOOK @@ -571,6 +573,17 @@ endef TARGET_FINALIZE_HOOKS += HOST_FIX_RPATH_HOOK +define TARGET_SANITIZE_RPATH_HOOK + $(TOPDIR)/support/scripts/fix_rpaths \ + sanitize $(TARGET_DIR) \ + $(if $(V),--verbose) \ + --patchelf-program $(HOST_DIR)/usr/bin/patchelf \ + --patterns "($(STAGING_DIR)|`readlink -f $(STAGING_DIR)`)/(usr/)?lib$$" \ + "($(BUILD_DIR)|`readlink -f $(BUILD_DIR)`)/.*" +endef + +TARGET_FINALIZE_HOOKS += TARGET_SANITIZE_RPATH_HOOK + $(TARGETS_ROOTFS): target-finalize target-finalize: $(PACKAGES)
This patch introduces the TARGET_SANITIZE_RPATH_HOOK hook fixing the ELF files' RPATH of the TARGET_DIR (excluding the sysroot). After running this hook, the RPATH from any target ELF files won't contain any occurence of the sysroot or some build locations. Signed-off-by: Samuel Martin <s.martin49@gmail.com> --- changes v4->v5: - target hook now sanitizes the rpath (Baruch) - add verbose support - update comment changes v3->v4: - rebase - add comment changes v2->v3: - move hook in Makefile (Baruch) --- Makefile | 13 +++++++++++++ 1 file changed, 13 insertions(+)