[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [patch #10393] Fix shared library support on Android
From: |
Bruno Haible |
Subject: |
Re: [patch #10393] Fix shared library support on Android |
Date: |
Tue, 16 Jan 2024 21:54:46 +0100 |
Roumen Petrov wrote:
> Android and Microsoft windows libraries must not use hard coded paths!
> Nevertheless what is supported by linker or loader.
Why do you mention Microsoft Windows? The commit
47c71f61df9ace4956cc943f291480315174726b
has no effect on Microsoft Windows.
> When I read commit I agree that is correct do not have RUNPATH!
> The problem is that commit message is not so clear. Actually commit uses
> rpath flag!
> NO! NO! NO!
Why do you want that executables never have RUNPATH on Android? Just saying
"NO! NO! NO!" is not a justification, and your arguments in [2] were not
sensible either.
If you want a certain binary that you build to have no RUNPATH, use the
Android SDK, not Termux and not libtool. Or use libtool outside of Termux
and don't provide a -R option. It's that easy.
The problem I was encountering, as described in [1], is in the Termux
environment, which uses absolute file names everywhere. In this environment,
the use of RUNPATH is mandatory. Without RUNPATH no executable that uses
a shared library would run. That's why the Termux people added a RUNPATH
value:
$ readelf -d /data/data/com.termux/files/usr/bin/cp | grep '\(RUNPATH\|NEEDED\)'
0x0000001d (RUNPATH) Library runpath:
[/data/data/com.termux/files/usr/lib]
0x00000001 (NEEDED) Shared library: [libandroid-support.so]
0x00000001 (NEEDED) Shared library: [libgmp.so]
0x00000001 (NEEDED) Shared library: [libiconv.so]
0x00000001 (NEEDED) Shared library: [libc.so]
$ readelf -d /data/data/com.termux/files/usr/bin/emacs | grep
'\(RUNPATH\|NEEDED\)'
0x0000001d (RUNPATH) Library runpath:
[/data/data/com.termux/files/usr/lib]
0x00000001 (NEEDED) Shared library: [libxml2.so]
0x00000001 (NEEDED) Shared library: [libncursesw.so.6]
0x00000001 (NEEDED) Shared library: [libgnutls.so]
0x00000001 (NEEDED) Shared library: [libm.so]
0x00000001 (NEEDED) Shared library: [libz.so.1]
0x00000001 (NEEDED) Shared library: [libdl.so]
0x00000001 (NEEDED) Shared library: [libjansson.so]
0x00000001 (NEEDED) Shared library: [libgmp.so]
0x00000001 (NEEDED) Shared library: [libc.so]
The main remaining problem was that if a Termux user configures a
package with a non-default --prefix and that package installs a shared
library, the Termux-provided RUNPATH is insufficient: The program
would always only see the Termux-provided shared libraries. That's
where libtool support for -rpath is necessary.
Bruno
[1] https://lists.gnu.org/archive/html/libtool-patches/2023-09/msg00000.html
[2] https://lists.gnu.org/archive/html/libtool-patches/2023-09/msg00001.html