Commit Graph

147 Commits

Author SHA1 Message Date
Patryk Wychowaniec
43b75fbc9f Allocate PHT & SHT at the end of the *.elf file 2025-01-07 07:29:30 +01:00
Jörg Thalheim
769337c227 fix shellcheck 2024-11-18 12:44:49 +01:00
Yuta Hayama
5017be7ae0 Add test to set interpreter of same name 2024-11-18 11:57:58 +01:00
Jörg Thalheim
d985189c25 partially revert "Fix page size on Alpha"
this broke tests on other architectures
2024-11-18 11:46:09 +01:00
Jörg Thalheim
7cd6f031c0 use more portable command -v to test if gzip exists
This also works with the busybox version.
2024-11-18 11:46:09 +01:00
Patryk Wychowaniec
065c8484e3 tests: Check uname before gzip 2024-11-18 11:46:09 +01:00
Klemens Nanni
1ded8392b1 tests/short-first-segment: fix uname(1) usage and skip message
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
2024-11-18 11:08:47 +01:00
matoro
1c443aa1c7 Fix page size on Alpha
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.
2024-11-18 11:07:31 +01:00
Martin Jambor
b6cf11a31b Fix rename-dynamic-symbols.sh test (issue #503)
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.
2024-11-18 11:05:01 +01:00
Heiko Becker
1ab6930d15 Also respect a prefixed nm and strings too 2023-04-24 22:44:12 +02:00
Heiko Becker
d0c418fe38 Respect a possibly prefixed readelf
...i case of cross-compiling. Already done for other tests with
07bbf47e9c.
2023-04-24 22:42:59 +02:00
Jörg Thalheim
acee2a4bb4 tests: use proper exit code to mark tests as skipped 2023-04-23 13:29:37 +02:00
Breno Rodrigues Guimaraes
65cdee9044 Resize segment mapping rewritten sections if needed 2023-04-23 13:13:07 +02:00
bors[bot]
6e7b82e839 Merge #481
481: Do not let modifyRPath taint shared strings in strtab. Fix #315 r=Mic92 a=brenoguim



Co-authored-by: Breno Rodrigues Guimaraes <brenorg@gmail.com>
2023-04-23 10:51:58 +00:00
cedric84
7eace058f1 Update build-id.sh
This prevents the test to fail when when readelf is localized.
2023-03-26 13:32:22 +02:00
Breno Rodrigues Guimaraes
860c04dbd6 Add test 2023-03-17 19:11:45 -03:00
Breno Rodrigues Guimaraes
8adc31ed7b Fix all shellcheck issues 2023-03-11 11:37:11 -03:00
Breno Rodrigues Guimarães
27cbc89d48 Merge pull request #469 from brenoguim/breno.446
Add one extra page to avoid overlapping with next page if its rounded…
2023-03-11 11:01:43 -03:00
Breno Rodrigues Guimarães
80f6866936 Filter with awk instead of grep
Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
2023-03-08 16:35:12 -03:00
Breno Rodrigues Guimaraes
9f1c0af97b Set the alignment of the new LOAD segment the same as others 2023-03-07 21:10:26 -03:00
bors[bot]
ea2fca765c Merge #473
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>
2023-03-07 11:22:56 +00:00
Breno Rodrigues Guimaraes
fcb8fb7317 Other switches might set changed as true. Use extraStrings size 2023-03-04 14:04:07 -03:00
Breno Rodrigues Guimaraes
de3e1f5e11 Add one extra page to avoid overlapping with next page if its rounded down 2023-02-24 20:39:11 -03:00
Breno Rodrigues Guimaraes
eb9ea0094b Shellcheck fixes 2023-02-23 22:15:12 -03:00
Breno Rodrigues Guimarães
70a477a252 Merge branch 'NixOS:master' into breno.457 2023-02-23 22:07:41 -03:00
Breno Rodrigues Guimarães
afca68f86a Update tests/repeated-updates.sh
Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
2023-02-23 17:35:25 -03:00
Breno Rodrigues Guimarães
b9474398c5 Merge branch 'NixOS:master' into breno.rename_syms 2023-02-21 06:23:42 -03:00
Jörg Thalheim
be4b84635f tests: apply suggestions from shellcheck 2023-02-20 23:18:33 +01:00
Breno Rodrigues Guimaraes
0b6b666873 Add support for symbol name remapping 2023-02-20 18:43:01 -03:00
Jörg Thalheim
d5f6de07e5 Merge branch 'master' into breno.457 2023-02-20 22:32:50 +01:00
Breno Rodrigues Guimaraes
d925e8c91d Avoid overlapping program header table with section header table #457
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.
2023-02-19 02:31:36 -03:00
Christian Göttsche
f7d304eeb1 Add options to print, clear and set executable stack state
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.
2023-01-28 23:27:34 +01:00
Heiko Becker
d9ff398634 Also pass STRIP to the tests
It is used in tests/no-gnu-hash.sh.
2022-11-08 00:21:26 +01:00
Jörg Thalheim
f7b184c004 fix checkPhase for cross builds
fixes https://github.com/NixOS/patchelf/issues/417
2022-11-06 22:40:51 +01:00
Jörg Thalheim
b0599fe776 make objdump/objcopy/readelf configurable and respect cross-compiling related prefixes 2022-11-06 15:38:38 +01:00
Bo Anderson
15f02b0f7a Skip empty PT_NOTE sections
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.
2022-10-26 08:20:56 +02:00
Bo Anderson
a93de9d4ce tests/contiguous-note-sections.sh: use scratch directory 2022-10-10 15:14:31 +01:00
Jörg Thalheim
683e41d340 Merge pull request #381 from crystax/master
Add --print-os-abi and --set-os-abi options
2022-09-28 11:44:58 +02:00
Robert Scheck
f7053d0237 Handle glibc-hwcaps on ppc64le on CentOS/RHEL/Rocky 8 for tests/replace-add-needed.sh (fixes #406)
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
2022-09-27 00:41:51 +02:00
Dmitry Moskalchuk
5faf453436 Add documentation and test case for --print-os-abi and --set-os-abi
Signed-off-by: Dmitry Moskalchuk <dm@crystax.net>
2022-09-17 16:20:49 +03:00
deadwood
b92e442be0 Add test for --add-debug-tag argument 2022-02-23 16:42:51 +01:00
Farid Zakaria
b92a6e8951 Fix replace-add-needed.sh test for musl 2021-12-21 14:30:45 -08:00
Farid Zakaria
d02a3ecdd7 Code clarity and test working with musl
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
2021-12-21 06:05:13 -08:00
Farid Zakaria
e268662c32 Add a unit test 2021-12-20 17:34:26 -08:00
Klemens Nanni
5f6cc74be8 Avoid GNU seq(1)
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.
2021-12-07 20:41:26 +01:00
Jörg Thalheim
a4027142bf tests/grow-file.sh: fix compat with non-gnu systems 2021-12-07 19:44:37 +01:00
Jörg Thalheim
ba000786e9 tests/too-many-strtab: fix linking with lld
llvm's lld also tests the section type and fails otherwise

fixes https://github.com/NixOS/patchelf/issues/350
2021-12-07 19:44:37 +01:00
Jörg Thalheim
44fea0de2f tests/endianess.sh: fix out-of-tree build 2021-12-07 17:05:01 +01:00
Jörg Thalheim
ce99c93c57 Merge pull request #353 from klemensn/out-of-tree-build
Use absoloute paths to linker scripts
2021-12-07 15:44:42 +00:00
Jörg Thalheim
301aa6ae34 fix build-id test on openbsd 2021-12-06 21:45:26 +01:00