Commit Graph

611 Commits

Author SHA1 Message Date
Farid Zakaria
05e8f673f7 Added patchelf.h
Added a header file to make things easier to navigate.

Renamed findSection3 -> getSectionIndex since thats more sensible to
read.

Renamed findSection -> findSectionHeader to better distinguish sections
from headers.
2021-12-20 14:54:37 -08:00
Jörg Thalheim
b73dbc1c91 Merge pull request #358 from fzakaria/faridzakaria/off-by-one
print-interpreter: fix off by one error
2021-12-19 12:28:38 +00:00
Farid Zakaria
b932eb8700 print-interpreter: fix off by one error
Fix off by one error in the code that reads interpreter from the ELF
file. This was not evident when it was written directly to STDOUT but
became problematic through my exploration of new functionality (#357)
since there was an additional '\0' and the strings would not concatenate
as a result.
2021-12-18 06:08:45 -08:00
Jörg Thalheim
fbf108f581 Merge pull request #356 from klemensn/gnu-sed
Avoid GNU seq(1)
2021-12-07 21:34:02 +00: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
3039b7c0e9 Merge pull request #355 from NixOS/ci
llvm/openbsd fixes
2021-12-07 18:50:12 +00: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
ec1e840372 Merge pull request #354 from NixOS/ci
ci: test out-of-tree build
2021-12-07 17:04:39 +00:00
Jörg Thalheim
44fea0de2f tests/endianess.sh: fix out-of-tree build 2021-12-07 17:05:01 +01:00
Jörg Thalheim
d311cf7d08 ci: test out-of-tree build 2021-12-07 16:44:59 +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
297abedc3a Merge pull request #352 from NixOS/test-fix
fix build-id test on openbsd
2021-12-06 20:51:46 +00:00
Jörg Thalheim
301aa6ae34 fix build-id test on openbsd 2021-12-06 21:45:26 +01:00
Klemens Nanni
fd82dfffab Use absoloute paths to linker scripts
As is common with autotools enabled software, building and testing
happens outside the source directory.

The introduction of `contiguous-note-sections` test in 0.13 broke this
by assuming linker scripts to exist in the current working directory.

Point at the absoloute source directory explicitly to unbreak linking in
such build environments.

Spotted on OpenBSD where source and build assets are commonly separated
iff possible.
2021-12-06 21:25:25 +01:00
Jörg Thalheim
f7a1cc2991 Merge pull request #351 from klemensn/build-id
Use correct double-dashes for ld(1)'s build-id option
2021-12-06 20:20:29 +00:00
Klemens Nanni
b0cdf15e26 Use correct double-dashes for ld(1)'s build-id option
(Old) linkers such as BFD's ld(1) aka. GNU ld (version 2.17 on OpenBSD)
don't know `--build-id`, but they know `-b input-format` which patchelf
triggers by ommitting the second dash.

LLD's ld(1) seems to cope with this, although it's incorrect usage.

Use the double dash for correctness to get accurate error messages with
such incompatible linkers:

	-/usr/bin/ld: invalid BFD target `uild-id'
	+/usr/bin/ld: unrecognized option '--build-id'
	+/usr/bin/ld: use the --help option for usage information
2021-12-06 21:04:26 +01:00
Jörg Thalheim
bf3f37ec29 bump version 0.14.3 2021-12-05 15:39:58 +01:00
Jörg Thalheim
0ae27079bf Merge pull request #349 from mayeut/musl-static-build
Add build & test of static musl binaries to the publish workflow
2021-12-05 14:31:21 +00:00
mayeut
7f840a5adb ci: add static musl binaries
Add build & test of static musl binaries to the publish workflow.

fixes #330
2021-12-04 20:21:09 +01:00
mayeut
e406d98d47 ci: split building & publishing tarballs
This allows testing the tarball builds on each commit.
2021-12-04 20:18:34 +01:00
Jörg Thalheim
2ac5798fdc Merge pull request #347 from NixOS/prepare-release
bump version
0.14.2
2021-11-29 10:02:35 +00:00
Jörg Thalheim
78f05bbcbb bump version 2021-11-29 10:58:57 +01:00
Jörg Thalheim
7bc0e9d9c9 Merge pull request #346 from NixOS/ci
make version in tarball more predictable
2021-11-29 09:55:48 +00:00
Jörg Thalheim
aa945b129d make version more predictable
This makes it easier for packager and fixes https://github.com/NixOS/patchelf/issues/345
2021-11-29 10:44:17 +01:00
Jörg Thalheim
8f7b4a7a36 Merge pull request #344 from NixOS/prepare-release
bump version
0.14.1
2021-11-28 10:50:03 +00:00
Jörg Thalheim
55c0b4f909 bump version 2021-11-28 11:43:47 +01:00
Jörg Thalheim
38b475f7c9 Merge pull request #343 from NixOS/build-fix
add missing <optional> include
2021-11-28 10:40:40 +00:00
Jörg Thalheim
fef6eb7160 add regression test for ubuntu 2021-11-28 11:37:33 +01:00
Jörg Thalheim
61b53ce7cf add missing <optional> include 2021-11-28 11:26:33 +01:00
Jörg Thalheim
520e8327a6 Merge pull request #341 from NixOS/ci
remove aarch64 clang build
2021-11-28 00:03:21 +00:00
Jörg Thalheim
238962a573 disable aarch64 clang build 2021-11-28 00:59:33 +01:00
Jörg Thalheim
d54b3086fa upgrade clang version
7.x seems to be broken on aarch64: https://hydra.nixos.org/build/159776523/nixlog/1
2021-11-28 00:52:14 +01:00
Jörg Thalheim
e3bc959c26 Merge pull request #339 from NixOS/ci
ci: fix bz2 tarball upload
2021-11-27 23:27:55 +00:00
Jörg Thalheim
05c87c767d ci: fix bz2 tarball upload 2021-11-27 19:03:42 +01:00
Jörg Thalheim
babde50a1f Merge pull request #336 from NixOS/prepare-release
bump version
0.14
2021-11-27 17:57:00 +00:00
Jörg Thalheim
34d34daf92 bump version 2021-11-27 18:52:47 +01:00
Harmen Stoppels
fc33f4545c Bump version and update release notes
fixes https://github.com/NixOS/patchelf/pull/338
2021-11-27 18:52:22 +01:00
Jörg Thalheim
0d3df24971 Merge pull request #337 from NixOS/ci
Fix build-sanitized-clang.aarch64-linux build
2021-11-27 16:29:14 +00:00
Jörg Thalheim
31652921fa exclude i686 linux clang build 2021-11-27 17:24:44 +01:00
Jörg Thalheim
ea6035d072 fix coverage build 2021-11-27 17:10:38 +01:00
Jörg Thalheim
b08bdf3f37 flake: bump nixpkgs 2021-11-27 16:37:50 +01:00
Jörg Thalheim
23e955dfac build-sanitized-clang: fix for aarch64 2021-11-27 16:37:39 +01:00
Jörg Thalheim
b7e64b9a19 Merge pull request #335 from NixOS/replace-lib
Rebase of https://github.com/NixOS/patchelf/pull/237
2021-11-27 10:12:46 +00:00
Rolf Eike Beer
b02a14949f avoid adding the same .dynstr entries multiple times
This can happen especially if .gnu.version_r stores the strings in .dynstr, so
replacing the library names would add them twice to the same section. Keep a map
of what was already added and where, and simply reuse the old entries if they
are needed again.
2021-11-27 11:06:49 +01:00
Rolf Eike Beer
b4cb6cac78 fix corrupted library names when using --replace-needed multiple times
When it happens that the .gnu.version_r stores the strings in .dynstr it can
come to corruption of the library names written into DT_NEEDED:

-the library names in DT_NEEDED are replaced, new entries are written to the end
 of .dynstr
-the version library names are replaced, and written to the end of the string
 section.

If the section for the version strings is also ".dynstr", the previous
modifications were _not_ taken into account and things were written from the old
end of .dynstr again. The order in which these strings were written is not the
same as the previous replacement, so things would end up with the same size, but
different offsets. The .gnu.version_r table is correct, the file contents are
fine, but the offsets in the DT_NEEDED entries are wrong. Since they are printed
as 0-terminated strings the first one replaced will always be shown correct,
which also is the case if the argument is only used once as the string is
replaced with itself afterwards.
2021-11-27 11:06:49 +01:00
Jörg Thalheim
a174cf3006 Merge pull request #333 from zhangwenlong8911/master
support loongarch for patchelf
2021-11-16 08:36:56 +00:00
zhangwenlong
4b87d4fa57 support loongarch for patchelf
Signed-off-by: zhangwenlong <zhangwenlong@loongson.cn>
2021-11-16 09:16:36 +00:00
Eelco Dolstra
a0151ef25a Merge pull request #323 from NixOS/less-raw-pointer
remove raw pointer from findSection2
2021-10-26 11:22:09 +02:00
Eelco Dolstra
e18453c710 Merge pull request #331 from stephenmsachs/runpath_man_page
Change man page references from RPATH to RUNPATH
2021-10-26 11:21:16 +02:00