All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] general question about patchelf and RPATH
@ 2019-09-30 16:16 Yann Sionneau
  2019-10-01 12:26 ` [Buildroot] [PATCH] Do not remove path from RPATH when it is needed for dlopen at runtime Yann Sionneau
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Yann Sionneau @ 2019-09-30 16:16 UTC (permalink / raw)
  To: buildroot

Hello,

I can see that patchelf does the following:

https://github.com/buildroot/buildroot/blob/master/package/patchelf/0003-Add-option-to-make-the-rpath-relative-under-a-specif.patch#L254

What happens then if the application needs to load a shared object via 
dlopen() (so not in DT_NEEDED) which is in a directory pointed to by 
RPATH like "$ORIGIN/testlib" like the tst-origin unit test of 
uclibc-ng-test does:

https://github.com/wbx-github/uclibc-ng-test/blob/master/test/dlopen/Makefile.in#L25

https://github.com/wbx-github/uclibc-ng-test/blob/master/test/dlopen/tst-origin.c#L15

I can see at least in my build that the RPATH gets stripped from the 
final ELF in the target dir.

see:

[ysionneau at junon build_dev_k1c]$ 
./host/bin/k1-buildroot-linux-uclibc-readelf -aW 
/work1/ysionneau/runpath/workspace/build_buildroot/build_dev_k1c/target/usr/lib/uclibc-ng-test/test/dlopen/tst-origin 
| grep RPATH
 ?0x000000000000000f (RPATH)????????????? Library rpath: [$ORIGIN/testlib]
[ysionneau at junon build_dev_k1c]$ 
/work1/ysionneau/runpath/workspace/build_buildroot/build_dev_k1c/host/bin/patchelf 
--make-rpath-relative 
/work1/ysionneau/runpath/workspace/build_buildroot/build_dev_k1c/target 
--no-standard-lib-dirs 
/work1/ysionneau/runpath/workspace/build_buildroot/build_dev_k1c/target/usr/lib/uclibc-ng-test/test/dlopen/tst-origin
[ysionneau at junon build_dev_k1c]$ 
./host/bin/k1-buildroot-linux-uclibc-readelf -aW 
/work1/ysionneau/runpath/workspace/build_buildroot/build_dev_k1c/target/usr/lib/uclibc-ng-test/test/dlopen/tst-origin 
| grep RPATH
[ysionneau at junon build_dev_k1c]$ 
./host/bin/k1-buildroot-linux-uclibc-readelf -aW 
/work1/ysionneau/runpath/workspace/build_buildroot/build_dev_k1c/target/usr/lib/uclibc-ng-test/test/dlopen/tst-origin 
| grep RUNPATH
 ?0x000000000000001d (RUNPATH)??????????? Library runpath: []

To be more precise, the RPATH is replaced by RUNPATH, but the RUNPATH is 
empty.

Then the unit test fails at runtime for me.

Thanks

-- 

Yann

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH] Do not remove path from RPATH when it is needed for dlopen at runtime
  2019-09-30 16:16 [Buildroot] general question about patchelf and RPATH Yann Sionneau
@ 2019-10-01 12:26 ` Yann Sionneau
  2019-10-01 12:31 ` Yann Sionneau
  2019-10-01 12:33 ` Yann Sionneau
  2 siblings, 0 replies; 8+ messages in thread
From: Yann Sionneau @ 2019-10-01 12:26 UTC (permalink / raw)
  To: buildroot

Summary:
Do not remove path from RPATH when it points to a directory containing no
shared object present as DT_NEEDED in .dynamic section.
This RPATH path can pretty well be needed at runtime for dlopen.

This fixes tst-origin uClibc-ng unit test:
https://github.com/wbx-github/uclibc-ng-test/blob/master/test/dlopen/Makefile.in#L25
https://github.com/wbx-github/uclibc-ng-test/blob/master/test/dlopen/tst-origin.c#L15

---
 ...ption-to-make-the-rpath-relative-under-a-specif.patch | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/package/patchelf/0003-Add-option-to-make-the-rpath-relative-under-a-specif.patch b/package/patchelf/0003-Add-option-to-make-the-rpath-relative-under-a-specif.patch
index feec627..f9f2537 100644
--- a/package/patchelf/0003-Add-option-to-make-the-rpath-relative-under-a-specif.patch
+++ b/package/patchelf/0003-Add-option-to-make-the-rpath-relative-under-a-specif.patch
@@ -167,7 +167,7 @@ index 1d9a772..35b4a33 100644
      if (op == rpShrink && !rpath) {
          debug("no RPATH to shrink\n");
          return;
-@@ -1120,26 +1196,86 @@ void ElfFile<ElfFileParamNames>::modifyRPath(RPathOp op, string newRPath)
+@@ -1120,26 +1196,80 @@ void ElfFile<ElfFileParamNames>::modifyRPath(RPathOp op, string newRPath)
                  continue;
              }
  
@@ -250,12 +250,6 @@ index 1d9a772..35b4a33 100644
 +                }
 +            }
 +
-+            if (!libFoundInRPath(canonicalPath, neededLibs, neededLibFound)) {
-+                debug("removing directory '%s' from RPATH because it does not contain needed libs\n",
-+                      dirName.c_str());
-+                continue;
-+            }
-+
 +            /* Finally make "canonicalPath" relative to "filedir" in "rootDir" */
 +            if (relativeToFile)
 +                concatToRPath(newRPath, makePathRelative(canonicalPath, fileDir));
@@ -268,7 +262,7 @@ index 1d9a772..35b4a33 100644
      if (op == rpRemove) {
          if (!rpath) {
              debug("no RPATH to delete\n");
-@@ -1413,7 +1549,9 @@ static bool shrinkRPath = false;
+@@ -1413,7 +1543,9 @@ static bool shrinkRPath = false;
  static bool removeRPath = false;
  static bool setRPath = false;
  static bool printRPath = false;
@@ -278,7 +272,7 @@ index 1d9a772..35b4a33 100644
  static set<string> neededLibsToRemove;
  static map<string, string> neededLibsToReplace;
  static set<string> neededLibsToAdd;
-@@ -1438,14 +1576,16 @@ static void patchElf2(ElfFile & elfFile)
+@@ -1438,14 +1570,16 @@ static void patchElf2(ElfFile & elfFile)
          elfFile.setInterpreter(newInterpreter);
  
      if (printRPath)
@@ -299,7 +293,7 @@ index 1d9a772..35b4a33 100644
  
      if (printNeeded) elfFile.printNeededLibs();
  
-@@ -1508,6 +1648,9 @@ void showHelp(const string & progName)
+@@ -1508,6 +1642,9 @@ void showHelp(const string & progName)
    [--set-rpath RPATH]\n\
    [--remove-rpath]\n\
    [--shrink-rpath]\n\
@@ -309,7 +303,7 @@ index 1d9a772..35b4a33 100644
    [--print-rpath]\n\
    [--force-rpath]\n\
    [--add-needed LIBRARY]\n\
-@@ -1564,6 +1707,17 @@ int main(int argc, char * * argv)
+@@ -1564,6 +1701,17 @@ int main(int argc, char * * argv)
              setRPath = true;
              newRPath = argv[i];
          }
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH] Do not remove path from RPATH when it is needed for dlopen at runtime
  2019-09-30 16:16 [Buildroot] general question about patchelf and RPATH Yann Sionneau
  2019-10-01 12:26 ` [Buildroot] [PATCH] Do not remove path from RPATH when it is needed for dlopen at runtime Yann Sionneau
@ 2019-10-01 12:31 ` Yann Sionneau
  2019-10-01 12:33   ` Yann Sionneau
  2019-10-01 12:33 ` Yann Sionneau
  2 siblings, 1 reply; 8+ messages in thread
From: Yann Sionneau @ 2019-10-01 12:31 UTC (permalink / raw)
  To: buildroot

Summary:
Do not remove path from RPATH when it points to a directory containing no
shared object present as DT_NEEDED in .dynamic section.
This RPATH path can pretty well be needed at runtime for dlopen.

This fixes tst-origin uClibc-ng unit test:
https://github.com/wbx-github/uclibc-ng-test/blob/master/test/dlopen/Makefile.in#L25
https://github.com/wbx-github/uclibc-ng-test/blob/master/test/dlopen/tst-origin.c#L15

---
 ...ption-to-make-the-rpath-relative-under-a-specif.patch | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/package/patchelf/0003-Add-option-to-make-the-rpath-relative-under-a-specif.patch b/package/patchelf/0003-Add-option-to-make-the-rpath-relative-under-a-specif.patch
index feec627..f9f2537 100644
--- a/package/patchelf/0003-Add-option-to-make-the-rpath-relative-under-a-specif.patch
+++ b/package/patchelf/0003-Add-option-to-make-the-rpath-relative-under-a-specif.patch
@@ -167,7 +167,7 @@ index 1d9a772..35b4a33 100644
      if (op == rpShrink && !rpath) {
          debug("no RPATH to shrink\n");
          return;
-@@ -1120,26 +1196,86 @@ void ElfFile<ElfFileParamNames>::modifyRPath(RPathOp op, string newRPath)
+@@ -1120,26 +1196,80 @@ void ElfFile<ElfFileParamNames>::modifyRPath(RPathOp op, string newRPath)
                  continue;
              }
  
@@ -250,12 +250,6 @@ index 1d9a772..35b4a33 100644
 +                }
 +            }
 +
-+            if (!libFoundInRPath(canonicalPath, neededLibs, neededLibFound)) {
-+                debug("removing directory '%s' from RPATH because it does not contain needed libs\n",
-+                      dirName.c_str());
-+                continue;
-+            }
-+
 +            /* Finally make "canonicalPath" relative to "filedir" in "rootDir" */
 +            if (relativeToFile)
 +                concatToRPath(newRPath, makePathRelative(canonicalPath, fileDir));
@@ -268,7 +262,7 @@ index 1d9a772..35b4a33 100644
      if (op == rpRemove) {
          if (!rpath) {
              debug("no RPATH to delete\n");
-@@ -1413,7 +1549,9 @@ static bool shrinkRPath = false;
+@@ -1413,7 +1543,9 @@ static bool shrinkRPath = false;
  static bool removeRPath = false;
  static bool setRPath = false;
  static bool printRPath = false;
@@ -278,7 +272,7 @@ index 1d9a772..35b4a33 100644
  static set<string> neededLibsToRemove;
  static map<string, string> neededLibsToReplace;
  static set<string> neededLibsToAdd;
-@@ -1438,14 +1576,16 @@ static void patchElf2(ElfFile & elfFile)
+@@ -1438,14 +1570,16 @@ static void patchElf2(ElfFile & elfFile)
          elfFile.setInterpreter(newInterpreter);
  
      if (printRPath)
@@ -299,7 +293,7 @@ index 1d9a772..35b4a33 100644
  
      if (printNeeded) elfFile.printNeededLibs();
  
-@@ -1508,6 +1648,9 @@ void showHelp(const string & progName)
+@@ -1508,6 +1642,9 @@ void showHelp(const string & progName)
    [--set-rpath RPATH]\n\
    [--remove-rpath]\n\
    [--shrink-rpath]\n\
@@ -309,7 +303,7 @@ index 1d9a772..35b4a33 100644
    [--print-rpath]\n\
    [--force-rpath]\n\
    [--add-needed LIBRARY]\n\
-@@ -1564,6 +1707,17 @@ int main(int argc, char * * argv)
+@@ -1564,6 +1701,17 @@ int main(int argc, char * * argv)
              setRPath = true;
              newRPath = argv[i];
          }
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH] Do not remove path from RPATH when it is needed for dlopen at runtime
  2019-10-01 12:31 ` Yann Sionneau
@ 2019-10-01 12:33   ` Yann Sionneau
  0 siblings, 0 replies; 8+ messages in thread
From: Yann Sionneau @ 2019-10-01 12:33 UTC (permalink / raw)
  To: buildroot

I'm trying to add the signed-off-by here, sorry for the noise, hopefully 
the next one will be the last one!

On 10/1/19 2:31 PM, Yann Sionneau wrote:
> Summary:
> Do not remove path from RPATH when it points to a directory containing no
> shared object present as DT_NEEDED in .dynamic section.
> This RPATH path can pretty well be needed at runtime for dlopen.
>
> This fixes tst-origin uClibc-ng unit test:
> https://github.com/wbx-github/uclibc-ng-test/blob/master/test/dlopen/Makefile.in#L25
> https://github.com/wbx-github/uclibc-ng-test/blob/master/test/dlopen/tst-origin.c#L15
>
> ---
>   ...ption-to-make-the-rpath-relative-under-a-specif.patch | 16 +++++-----------
>   1 file changed, 5 insertions(+), 11 deletions(-)
>
> diff --git a/package/patchelf/0003-Add-option-to-make-the-rpath-relative-under-a-specif.patch b/package/patchelf/0003-Add-option-to-make-the-rpath-relative-under-a-specif.patch
> index feec627..f9f2537 100644
> --- a/package/patchelf/0003-Add-option-to-make-the-rpath-relative-under-a-specif.patch
> +++ b/package/patchelf/0003-Add-option-to-make-the-rpath-relative-under-a-specif.patch
> @@ -167,7 +167,7 @@ index 1d9a772..35b4a33 100644
>        if (op == rpShrink && !rpath) {
>            debug("no RPATH to shrink\n");
>            return;
> -@@ -1120,26 +1196,86 @@ void ElfFile<ElfFileParamNames>::modifyRPath(RPathOp op, string newRPath)
> +@@ -1120,26 +1196,80 @@ void ElfFile<ElfFileParamNames>::modifyRPath(RPathOp op, string newRPath)
>                    continue;
>                }
>    
> @@ -250,12 +250,6 @@ index 1d9a772..35b4a33 100644
>   +                }
>   +            }
>   +
> -+            if (!libFoundInRPath(canonicalPath, neededLibs, neededLibFound)) {
> -+                debug("removing directory '%s' from RPATH because it does not contain needed libs\n",
> -+                      dirName.c_str());
> -+                continue;
> -+            }
> -+
>   +            /* Finally make "canonicalPath" relative to "filedir" in "rootDir" */
>   +            if (relativeToFile)
>   +                concatToRPath(newRPath, makePathRelative(canonicalPath, fileDir));
> @@ -268,7 +262,7 @@ index 1d9a772..35b4a33 100644
>        if (op == rpRemove) {
>            if (!rpath) {
>                debug("no RPATH to delete\n");
> -@@ -1413,7 +1549,9 @@ static bool shrinkRPath = false;
> +@@ -1413,7 +1543,9 @@ static bool shrinkRPath = false;
>    static bool removeRPath = false;
>    static bool setRPath = false;
>    static bool printRPath = false;
> @@ -278,7 +272,7 @@ index 1d9a772..35b4a33 100644
>    static set<string> neededLibsToRemove;
>    static map<string, string> neededLibsToReplace;
>    static set<string> neededLibsToAdd;
> -@@ -1438,14 +1576,16 @@ static void patchElf2(ElfFile & elfFile)
> +@@ -1438,14 +1570,16 @@ static void patchElf2(ElfFile & elfFile)
>            elfFile.setInterpreter(newInterpreter);
>    
>        if (printRPath)
> @@ -299,7 +293,7 @@ index 1d9a772..35b4a33 100644
>    
>        if (printNeeded) elfFile.printNeededLibs();
>    
> -@@ -1508,6 +1648,9 @@ void showHelp(const string & progName)
> +@@ -1508,6 +1642,9 @@ void showHelp(const string & progName)
>      [--set-rpath RPATH]\n\
>      [--remove-rpath]\n\
>      [--shrink-rpath]\n\
> @@ -309,7 +303,7 @@ index 1d9a772..35b4a33 100644
>      [--print-rpath]\n\
>      [--force-rpath]\n\
>      [--add-needed LIBRARY]\n\
> -@@ -1564,6 +1707,17 @@ int main(int argc, char * * argv)
> +@@ -1564,6 +1701,17 @@ int main(int argc, char * * argv)
>                setRPath = true;
>                newRPath = argv[i];
>            }

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH] Do not remove path from RPATH when it is needed for dlopen at runtime
  2019-09-30 16:16 [Buildroot] general question about patchelf and RPATH Yann Sionneau
  2019-10-01 12:26 ` [Buildroot] [PATCH] Do not remove path from RPATH when it is needed for dlopen at runtime Yann Sionneau
  2019-10-01 12:31 ` Yann Sionneau
@ 2019-10-01 12:33 ` Yann Sionneau
  2019-10-23 12:06   ` Yann Sionneau
  2020-08-25 12:15   ` Thomas Petazzoni
  2 siblings, 2 replies; 8+ messages in thread
From: Yann Sionneau @ 2019-10-01 12:33 UTC (permalink / raw)
  To: buildroot

Do not remove path from RPATH when it points to a directory containing no
shared object present as DT_NEEDED in .dynamic section.
The RPATH can pretty well be needed at runtime for dlopen.

This fixes tst-origin uClibc-ng unit test:
https://github.com/wbx-github/uclibc-ng-test/blob/master/test/dlopen/Makefile.in#L25
https://github.com/wbx-github/uclibc-ng-test/blob/master/test/dlopen/tst-origin.c#L15

Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
---
 ...ption-to-make-the-rpath-relative-under-a-specif.patch | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/package/patchelf/0003-Add-option-to-make-the-rpath-relative-under-a-specif.patch b/package/patchelf/0003-Add-option-to-make-the-rpath-relative-under-a-specif.patch
index feec627..f9f2537 100644
--- a/package/patchelf/0003-Add-option-to-make-the-rpath-relative-under-a-specif.patch
+++ b/package/patchelf/0003-Add-option-to-make-the-rpath-relative-under-a-specif.patch
@@ -167,7 +167,7 @@ index 1d9a772..35b4a33 100644
      if (op == rpShrink && !rpath) {
          debug("no RPATH to shrink\n");
          return;
-@@ -1120,26 +1196,86 @@ void ElfFile<ElfFileParamNames>::modifyRPath(RPathOp op, string newRPath)
+@@ -1120,26 +1196,80 @@ void ElfFile<ElfFileParamNames>::modifyRPath(RPathOp op, string newRPath)
                  continue;
              }
  
@@ -250,12 +250,6 @@ index 1d9a772..35b4a33 100644
 +                }
 +            }
 +
-+            if (!libFoundInRPath(canonicalPath, neededLibs, neededLibFound)) {
-+                debug("removing directory '%s' from RPATH because it does not contain needed libs\n",
-+                      dirName.c_str());
-+                continue;
-+            }
-+
 +            /* Finally make "canonicalPath" relative to "filedir" in "rootDir" */
 +            if (relativeToFile)
 +                concatToRPath(newRPath, makePathRelative(canonicalPath, fileDir));
@@ -268,7 +262,7 @@ index 1d9a772..35b4a33 100644
      if (op == rpRemove) {
          if (!rpath) {
              debug("no RPATH to delete\n");
-@@ -1413,7 +1549,9 @@ static bool shrinkRPath = false;
+@@ -1413,7 +1543,9 @@ static bool shrinkRPath = false;
  static bool removeRPath = false;
  static bool setRPath = false;
  static bool printRPath = false;
@@ -278,7 +272,7 @@ index 1d9a772..35b4a33 100644
  static set<string> neededLibsToRemove;
  static map<string, string> neededLibsToReplace;
  static set<string> neededLibsToAdd;
-@@ -1438,14 +1576,16 @@ static void patchElf2(ElfFile & elfFile)
+@@ -1438,14 +1570,16 @@ static void patchElf2(ElfFile & elfFile)
          elfFile.setInterpreter(newInterpreter);
  
      if (printRPath)
@@ -299,7 +293,7 @@ index 1d9a772..35b4a33 100644
  
      if (printNeeded) elfFile.printNeededLibs();
  
-@@ -1508,6 +1648,9 @@ void showHelp(const string & progName)
+@@ -1508,6 +1642,9 @@ void showHelp(const string & progName)
    [--set-rpath RPATH]\n\
    [--remove-rpath]\n\
    [--shrink-rpath]\n\
@@ -309,7 +303,7 @@ index 1d9a772..35b4a33 100644
    [--print-rpath]\n\
    [--force-rpath]\n\
    [--add-needed LIBRARY]\n\
-@@ -1564,6 +1707,17 @@ int main(int argc, char * * argv)
+@@ -1564,6 +1701,17 @@ int main(int argc, char * * argv)
              setRPath = true;
              newRPath = argv[i];
          }
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH] Do not remove path from RPATH when it is needed for dlopen at runtime
  2019-10-01 12:33 ` Yann Sionneau
@ 2019-10-23 12:06   ` Yann Sionneau
  2020-08-25 12:15   ` Thomas Petazzoni
  1 sibling, 0 replies; 8+ messages in thread
From: Yann Sionneau @ 2019-10-23 12:06 UTC (permalink / raw)
  To: buildroot

ping?

On 10/1/19 2:33 PM, Yann Sionneau wrote:
> Do not remove path from RPATH when it points to a directory containing no
> shared object present as DT_NEEDED in .dynamic section.
> The RPATH can pretty well be needed at runtime for dlopen.
>
> This fixes tst-origin uClibc-ng unit test:
> https://github.com/wbx-github/uclibc-ng-test/blob/master/test/dlopen/Makefile.in#L25
> https://github.com/wbx-github/uclibc-ng-test/blob/master/test/dlopen/tst-origin.c#L15
>
> Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
> ---
>   ...ption-to-make-the-rpath-relative-under-a-specif.patch | 16 +++++-----------
>   1 file changed, 5 insertions(+), 11 deletions(-)
>
> diff --git a/package/patchelf/0003-Add-option-to-make-the-rpath-relative-under-a-specif.patch b/package/patchelf/0003-Add-option-to-make-the-rpath-relative-under-a-specif.patch
> index feec627..f9f2537 100644
> --- a/package/patchelf/0003-Add-option-to-make-the-rpath-relative-under-a-specif.patch
> +++ b/package/patchelf/0003-Add-option-to-make-the-rpath-relative-under-a-specif.patch
> @@ -167,7 +167,7 @@ index 1d9a772..35b4a33 100644
>        if (op == rpShrink && !rpath) {
>            debug("no RPATH to shrink\n");
>            return;
> -@@ -1120,26 +1196,86 @@ void ElfFile<ElfFileParamNames>::modifyRPath(RPathOp op, string newRPath)
> +@@ -1120,26 +1196,80 @@ void ElfFile<ElfFileParamNames>::modifyRPath(RPathOp op, string newRPath)
>                    continue;
>                }
>    
> @@ -250,12 +250,6 @@ index 1d9a772..35b4a33 100644
>   +                }
>   +            }
>   +
> -+            if (!libFoundInRPath(canonicalPath, neededLibs, neededLibFound)) {
> -+                debug("removing directory '%s' from RPATH because it does not contain needed libs\n",
> -+                      dirName.c_str());
> -+                continue;
> -+            }
> -+
>   +            /* Finally make "canonicalPath" relative to "filedir" in "rootDir" */
>   +            if (relativeToFile)
>   +                concatToRPath(newRPath, makePathRelative(canonicalPath, fileDir));
> @@ -268,7 +262,7 @@ index 1d9a772..35b4a33 100644
>        if (op == rpRemove) {
>            if (!rpath) {
>                debug("no RPATH to delete\n");
> -@@ -1413,7 +1549,9 @@ static bool shrinkRPath = false;
> +@@ -1413,7 +1543,9 @@ static bool shrinkRPath = false;
>    static bool removeRPath = false;
>    static bool setRPath = false;
>    static bool printRPath = false;
> @@ -278,7 +272,7 @@ index 1d9a772..35b4a33 100644
>    static set<string> neededLibsToRemove;
>    static map<string, string> neededLibsToReplace;
>    static set<string> neededLibsToAdd;
> -@@ -1438,14 +1576,16 @@ static void patchElf2(ElfFile & elfFile)
> +@@ -1438,14 +1570,16 @@ static void patchElf2(ElfFile & elfFile)
>            elfFile.setInterpreter(newInterpreter);
>    
>        if (printRPath)
> @@ -299,7 +293,7 @@ index 1d9a772..35b4a33 100644
>    
>        if (printNeeded) elfFile.printNeededLibs();
>    
> -@@ -1508,6 +1648,9 @@ void showHelp(const string & progName)
> +@@ -1508,6 +1642,9 @@ void showHelp(const string & progName)
>      [--set-rpath RPATH]\n\
>      [--remove-rpath]\n\
>      [--shrink-rpath]\n\
> @@ -309,7 +303,7 @@ index 1d9a772..35b4a33 100644
>      [--print-rpath]\n\
>      [--force-rpath]\n\
>      [--add-needed LIBRARY]\n\
> -@@ -1564,6 +1707,17 @@ int main(int argc, char * * argv)
> +@@ -1564,6 +1701,17 @@ int main(int argc, char * * argv)
>                setRPath = true;
>                newRPath = argv[i];
>            }

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH] Do not remove path from RPATH when it is needed for dlopen at runtime
  2019-10-01 12:33 ` Yann Sionneau
  2019-10-23 12:06   ` Yann Sionneau
@ 2020-08-25 12:15   ` Thomas Petazzoni
  2020-08-28 17:23     ` Peter Korsgaard
  1 sibling, 1 reply; 8+ messages in thread
From: Thomas Petazzoni @ 2020-08-25 12:15 UTC (permalink / raw)
  To: buildroot

Hello Yann,

On Tue,  1 Oct 2019 14:33:30 +0200
Yann Sionneau <ysionneau@kalray.eu> wrote:

> Do not remove path from RPATH when it points to a directory containing no
> shared object present as DT_NEEDED in .dynamic section.
> The RPATH can pretty well be needed at runtime for dlopen.
> 
> This fixes tst-origin uClibc-ng unit test:
> https://github.com/wbx-github/uclibc-ng-test/blob/master/test/dlopen/Makefile.in#L25
> https://github.com/wbx-github/uclibc-ng-test/blob/master/test/dlopen/tst-origin.c#L15
> 
> Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>

It's been a long long while, but it turned out I was reported the exact
same issue (though not with uClibc-ng tests), and indeed a simple test
cases shows that patchelf is dropping RPATH entries if there's no
library in that directory with a corresponding DT_NEEDED entry in the
binary, which breaks dlopen() if it relies on RPATH entries.

So I've significantly rewritten your commit log, with more
explanations, and applied your patch to master. Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH] Do not remove path from RPATH when it is needed for dlopen at runtime
  2020-08-25 12:15   ` Thomas Petazzoni
@ 2020-08-28 17:23     ` Peter Korsgaard
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Korsgaard @ 2020-08-28 17:23 UTC (permalink / raw)
  To: buildroot

>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@bootlin.com> writes:

 > Hello Yann,
 > On Tue,  1 Oct 2019 14:33:30 +0200
 > Yann Sionneau <ysionneau@kalray.eu> wrote:

 >> Do not remove path from RPATH when it points to a directory containing no
 >> shared object present as DT_NEEDED in .dynamic section.
 >> The RPATH can pretty well be needed at runtime for dlopen.
 >> 
 >> This fixes tst-origin uClibc-ng unit test:
 >> https://github.com/wbx-github/uclibc-ng-test/blob/master/test/dlopen/Makefile.in#L25
 >> https://github.com/wbx-github/uclibc-ng-test/blob/master/test/dlopen/tst-origin.c#L15
 >> 
 >> Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>

 > It's been a long long while, but it turned out I was reported the exact
 > same issue (though not with uClibc-ng tests), and indeed a simple test
 > cases shows that patchelf is dropping RPATH entries if there's no
 > library in that directory with a corresponding DT_NEEDED entry in the
 > binary, which breaks dlopen() if it relies on RPATH entries.

 > So I've significantly rewritten your commit log, with more
 > explanations, and applied your patch to master. Thanks!

Committed to 2020.02.x and 2020.05.x, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-08-28 17:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-30 16:16 [Buildroot] general question about patchelf and RPATH Yann Sionneau
2019-10-01 12:26 ` [Buildroot] [PATCH] Do not remove path from RPATH when it is needed for dlopen at runtime Yann Sionneau
2019-10-01 12:31 ` Yann Sionneau
2019-10-01 12:33   ` Yann Sionneau
2019-10-01 12:33 ` Yann Sionneau
2019-10-23 12:06   ` Yann Sionneau
2020-08-25 12:15   ` Thomas Petazzoni
2020-08-28 17:23     ` Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.