Replace non-portable GNU `-i, --hardware-platform` with `-m[, --machine]`
to fix "unknown error" usage error on, e.g. OpenBSD.
Also fix the check's backwards logic. OpenBSD/spar64 now prints
-skipping test: not supported on x86_64 Linux
+skipping test: amd64 Linux required
All tests pass.
Also explicitly specifies -no-pie for executables which should have it
disabled, to be compatible with gccs built with --enable-default-pie.
when building and then checking patchelf on openSUSE Leap 15.5, the
rename-dynamic-symbols.sh test fails. The test builds a test library
and executable called many-syms-main, then runs patchelf to rename
symbols and then checks that many-syms-main still runs successfully.
On Leap the run fails with many messages like
./many-syms-main: Symbol `f1947' causes overflow in R_X86_64_PC32 relocation
and then terminates with a Segmentation fault. The interesting bit is
that it however fails so even before patchelf touches it.
The binary is built and linked with option -pie which produces an
executable which is supposedly position independent but does not
actually contain code position independent code which requires
compiler option -fPIE (of -fpie or -fPIC or -fpic). As a result the
calls in the generated assembly do not go through the PLT.
This patch merely adresses that by adding the -fPIE option to the
CFLAGS for the test.
473: Other switches might set changed as true. Use extraStrings size. #416 r=Mic92 a=brenoguim
Co-authored-by: Breno Rodrigues Guimaraes <brenorg@gmail.com>
This patch checks if the section header table is placed right after the
program header table such that it would overlap when we add a new entry
in the program header table.
If that is the case, move the section header table to the end of the file.
Moreover, there is no need to add a new PT_LOAD segment everytime.
Check if the last segment is already a PT_LOAD with the same characteristics
and adjacent. Extend it in this case.
Add options the modify the state of the executable flag of the GNU_STACK
program header. That header indicates whether the object is requiring an
executable stack.
Previous versions of patchelf prior to 0.12 could create empty PT_NOTE sections. For backwards compatibility reasons, we should not error on such binaries.
Fixes#400.
ldd(1) usually returns for ELF binaries output like this:
libc.so.6 => /lib64/libc.so.6 (0x00007fbacd6ca000)
But with glibc-hwcaps, the output could also be like this:
libc.so.6 => /lib64/glibc-hwcaps/power9/libc-2.28.so (0x00007fffb5800000)
See also: https://sourceware.org/pipermail/libc-alpha/2020-June/115250.html
Made changes according to feedback from @Mic92 such as moving the
`rewriteSections` inline into every method.
Improved `replace-add-needed.sh` to work with musl libc
MacOS, FreeBSD and Linux using GNU have it, but at least OpenBSD
does not (the non-compatible BSD equivalent jot(1) exists, though).
Counting up is easy enough to do in POSIX sh(1).
Looks like this after GNU make(1)'s escaping and produces the same
big-dynstr.c file:
```
cat main.c > big-dynstr.c
i=1; while [ $i -le 2000 ]; do echo "void f$i(void) { };"; i=$(($i + 1)); done >> big-dynstr.c
```
This is the last bit required to build and pass all tests on OpenBSD
without local patches/dependencies.