aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/bundle-libraries.sh
Commit message (Collapse)AuthorAgeFilesLines
* scripts: bundle-libraries.sh: fix broken SDK compilerPetr Štetiar2020-11-021-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | Recent versions (> 5.33) of `file` report liblto_plugin.so as executable: $ file liblto_plugin.so liblto_plugin.so.0.0.0: ELF 64-bit LSB pie executable ... Which then leads to improper packaging of the plugin, resulting in the broken compiler: configure: checking whether the C compiler works mips-openwrt-linux-musl/bin/ld: liblto_plugin.so: error loading plugin: liblto_plugin.so: invalid ELF header As the LTO compiler plugin library is incorrectly packaged as SDK executable: $ head -1 ~/staging_dir/toolchain...libexec/gcc/.../liblto_plugin.so #!/usr/bin/env bash Fix this by filtering out shared libraries from the patching. Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1296868 Acked-by: Jo-Philipp Wich <jo@mein.io> Signed-off-by: Petr Štetiar <ynezz@true.cz>
* scripts: bundle-libraries.sh: retain preloaded librariesJo-Philipp Wich2020-09-101-1/+1
| | | | | | | | | | | | | | | | Since the introduction of fakeroot support, wrapped SDK executables might be invoked from a shell that has libfakeroot.so preloaded. Since we're using preloading as well in order to mangle argv[0] when invoking the shipped ELF interpreter directly, we must take care of preloading the already preloaded libraries as well, to avoid invoked programs losing their fakeroot capabilities. Extend the bundle-libraries.sh script to take any existing $LD_PRELOAD into account when invoking the target ELF executable with a preloaded runas.so library. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* scripts: bundle-libraries: fix logic flawJo-Philipp Wich2018-08-291-7/+6
| | | | | | | | | | | Previous refactoring of the script moved the LDSO detection into a file-not-exists condition, causing onyl the very first executable to get bundled. Solve the problem by unconditionally checking for LDSO again. Fixes: 9030a78a71 ("scripts: bundle-libraries: prevent loading host locales") Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* scripts: bundle-libraries: prevent loading host locales (FS#1803)Jo-Philipp Wich2018-08-271-5/+21
| | | | | | | | | | | | | Binary patch the bundled glibc library to inhibit loading of host locale archives in order to avoid triggering internal libc assertions when invoking shipped, bundled executables. The problem has been solved with upstream Glibc commit 0062ace229 ("Gracefully handle incompatible locale data") but we still need to deal with older Glibc binaries for some time to come. Fixes FS#1803 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* scripts: bundle-libraries: fix build on OS X (FS#1493)Jo-Philipp Wich2018-04-261-0/+4
| | | | | | | | This allegedly fixes compilation of the library bundler preload library on Apple OS X. The resulting executables have not been runtime tested due to a lack of suitable test hardware. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* build: bundle-libraries.sh: patch bundled ld.soJo-Philipp Wich2018-02-021-0/+13
| | | | | | | | | | | Remove references to /etc/, /lib/ and /usr/ from the bundled ld.so interpreter using simple binary patching. This is needed to prevent loading host system libraries such as libnss_compat.so.2 on foreign systems, which may result in ld.so inconsistency assertions. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* build: bundle-libraries.sh: do not override argv[0] in inner exec callsJo-Philipp Wich2017-07-241-1/+3
| | | | | | | | | | | Only mangle argv[0] of the first executed process and leave the argument vector of subsequent invocations as-is to allow child programs to properly discover resources relative to their binary locations. Fixes "cc1" discovery when executing the host gcc through the bundled "ccache" executable. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* build: fix invocation of bundled ld.so in SDK and ImagebuilderJo-Philipp Wich2017-07-211-15/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | Commit 72d751cba9 "build: rework library bundling" introduced a new helper binary "runas" whose sole purpose was mangling the argv vector passed to the actual called ELF image so that the renamed executable could obtain the proper name from argv[0]. This approach, however totally defeated the purpose of calling bundled ELF executables through the shipped ld.so loader since the execv() invocation performed by "runas" would cause the kernel the interprete the final program image through the system ELF loader again. To solve the problem, use an alternative approach of shipping a shared object "runas.so" which uses an ELF ".init_array" function pointer to obtain the argv[] vector of the to-be-executed main() function and mangle it in-place. The actual argv[0] value to use is communicated out-of-band using an environment variable "RUNAS_ARG0" by the shell wrapper script. The wrapper script also takes care of setting LD_PRELOAD to instruct the shipped ELF loader to preload the actual ELF program image with the "runas.so" helper library. Fixes FS#909. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* build: rework library bundlingJo-Philipp Wich2017-01-101-27/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rework the bundle-libraries.sh implementation to use a more robust approach for executing host binaries through the shipped ELF loader and libraries. The previous approach relied on symlinks pointing to a wrapper script which caused various issues, especially with multicall binaries as the original argv[0] name was not preserved through the ld.so invocation. Another down- side was the fact that the actual binaries got moved into another directory which caused executables to fail looking up resources with paths relative to the executable location. The new library wrapper implements the following improvements: - Instead of symlinks pointing to a common wrapper, each ELF executable is now replaced by a unqiue shell script which retains the original program name getting called - Instead of letting ld.so invoke the ELF executable directly, launch the final ELF binary through a helper program which fixes up the argv[0] argument for the target program - Support sharing a common location for the bundled libraries instead of having one copy in each directory containing wrapped binaries Finally modify the SDK build to wrap the staging_dir and toolchain binaries which allows to use the SDK on systems with a different glibc version. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* treewide: replace jow@openwrt.org with jo@mein.ioJo-Philipp Wich2016-06-071-1/+1
| | | | Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* scripts/bundle-libraries: fall back to only copying binaries if ldd is ↵Felix Fietkau2014-06-021-21/+20
| | | | | | | | unavailable (e.g. non-linux system) Signed-off-by: Felix Fietkau <nbd@openwrt.org> SVN-Revision: 40967
* scripts: bundle-libraries.sh: support mixing 32bit and 64bit binariesJo-Philipp Wich2013-01-281-6/+7
| | | | SVN-Revision: 35349
* fix library bundling when host libraries reside in /lib/tls/ or similarJo-Philipp Wich2012-09-091-5/+1
| | | | SVN-Revision: 33353
* add a helper script to bundle required libraries for host utilitiesJo-Philipp Wich2012-08-151-0/+114
SVN-Revision: 33195