Commit Graph

725 Commits

Author SHA1 Message Date
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
Stephen Sachs
400f791cf3 Change man page references from RPATH to RUNPATH 2021-10-20 11:53:19 +02:00
Domen Kožar
18a389ba35 Merge pull request #324 from ovpanait/strip
configure.ac: add check for strip
2021-09-26 11:54:19 -05:00
Jörg Thalheim
5875040543 Merge pull request #325 from ovpanait/phdr
tests: add testcase for PT_PHDR VirtAddr corruption
2021-09-26 17:53:39 +01:00
Ovidiu Panait
424d3f5083 tests: add testcase for PT_PHDR VirtAddr corruption
A PT_PHDR corruption was previously reported and fixed in [1]: the issue was
that the VirtAddr field of the PT_PHDR program header would get overwritten
with the file offset of the program header table rather than the virtual
address. A testcase for this was also added in [2]. However, the tescase is not
included in the Makefile.am regression testsuite and also tries to run a x86_64
prebuilt binary unconditionally, which would not work on other architectures.

To fix this, create a standalone testcase for the PT_PHDR VirtAddr field
corruption and include it in Makefile.am. In order to reproduce [1], a binary
with the following characteristics is needed:
- the ELF file type must be ET_DYN
- the ELF file must contain a PT_PHDR program header
- the file offset and the VirtAddr field of the PT_PHDR program header must be
  different

[1] https://github.com/NixOS/patchelf/pull/243
[2] 8f94e116f3

Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
2021-09-26 19:09:55 +03:00
Ovidiu Panait
512c0f3c60 configure.ac: add check for strip
Currently, "make check" fails on Ubuntu 20.04 because the STRIP variable is not
set in the resulting tests/Makefile:
"""
git clone https://github.com/NixOS/patchelf.git
./bootstrap.sh
./configure
make VERBOSE=1 check
...
gcc -fPIC -shared -o libbig-dynstr.so big-dynstr.c
only-keep-debug libbig-dynstr.so -o libbig-dynstr.debug
/bin/bash: only-keep-debug: command not found
make[2]: [Makefile:1526: libbig-dynstr.debug] Error 127 (ignored)
...
FAIL: no-dynamic-section.sh
===========================

patchelf: getting info about 'libbig-dynstr.debug': No such file or directory
FAIL no-dynamic-section.sh (exit status: 1)
"""

strip is used by the regression testsuite, so add a check for it configure.ac.

Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
2021-09-26 19:03:14 +03:00
Jörg Thalheim
4c73989205 use more memory-safe at() function 2021-09-19 20:36:07 +02:00
Jörg Thalheim
a1352e5289 remove raw pointer from findSection2 2021-09-19 20:36:07 +02:00
Jörg Thalheim
3cfd9a6637 Merge pull request #322 from NixOS/memory-safety
Improve memory safety
2021-09-19 16:17:43 +01:00
Jörg Thalheim
e9eecac91c use more memory safe at() function where possible 2021-09-19 17:11:51 +02:00
Jörg Thalheim
724662c272 more idiomatic colon split 2021-09-19 16:08:05 +02:00
Jörg Thalheim
f40a896f72 Merge pull request #256 from andrewla/master
Remove limits on output file size.
2021-09-13 16:59:16 +01:00
Jörg Thalheim
90da38b8cf grow-test: fix on non-gcc systems 2021-09-13 17:55:05 +02:00
Andrew Laucius
a4ae03d638 New test for growing the file 2021-09-13 15:00:44 +00:00
Andrew Laucius
de5354f372 Remove limits on output file size.
The use of self-pointers into a vector<> meant that the vector could not
be relocated, which meant that any growth in the file had to fit within the
inital reservation.

Now, instead of a pointer to a header and a pointer to the contents, those
values are computed dynamically from the underlying vector().
2021-09-13 14:55:18 +00:00
Jörg Thalheim
9469cb3888 Merge pull request #319 from NixOS/fix-empty-rpath
fix setting empty rpath
2021-09-12 09:31:10 +01:00
Jörg Thalheim
de3901853d fix setting empty rpath 2021-09-12 10:27:01 +02:00
Jörg Thalheim
57c3e7db50 Merge pull request #317 from Mic92/clang
also build with clang
2021-09-11 15:32:36 +01:00
Jörg Thalheim
d2f4d2e3b5 also build with clang 2021-09-11 16:24:35 +02:00
Jörg Thalheim
88177c44f8 Merge pull request #316 from andrewla/external-strings
Allow string arguments to be read from files.
2021-09-11 06:37:54 +01:00
Jörg Thalheim
e9ccf62867 rename test: external.sh -> args-from-file.sh 2021-09-11 07:34:42 +02:00
Jörg Thalheim
742d772a7f also test if external file does not exists 2021-09-11 07:33:00 +02:00
Andrew Laucius
d69bafc3b3 Allow string arguments to be read from files.
If a string argument to an option is prefixed with @, then a file with the
following name will be read into that string.
2021-09-10 19:28:32 +00:00
Jörg Thalheim
e9be1641b1 Merge pull request #311 from NixOS/refactoring
make modify rpath function smaller
2021-09-08 10:11:55 +01:00
Jörg Thalheim
c62988a2a8 Merge pull request #312 from NixOS/github
Automatic release tarball upload
2021-08-28 12:32:59 +01:00
Jörg Thalheim
a5f569acfa github: update install-nix-action 2021-08-28 13:30:26 +02:00
Jörg Thalheim
12c790e25c publish tarballs with github workflow 2021-08-28 13:28:47 +02:00
Jörg Thalheim
7db9e2039a ci: remove obsolete option 2021-08-28 13:28:47 +02:00
Jörg Thalheim
3170add8a9 Merge pull request #309 from NixOS/ubsan
add undefined behavior sanitizer
2021-08-28 12:15:10 +01:00
Jörg Thalheim
52a5bb061a when amending rpath don't add empty rpath entries 2021-08-28 08:29:40 +02:00
Jörg Thalheim
354dd23ed4 make modify rpath function smaller
the function is still quite large but hopefull now a bit easier to follow
2021-08-28 08:18:53 +02:00
Jörg Thalheim
385f6b1bff cleanup duplicate sanitizer flags 2021-08-28 06:25:40 +02:00
Jörg Thalheim
07dfd67eb1 Merge pull request #307 from Mic92/coverage
increase test coverage
2021-08-28 05:11:09 +01:00
Jörg Thalheim
c388c5d67a Merge pull request #306 from Mic92/aarch64
fix aarch64 build
2021-08-26 14:03:17 +01:00
Jörg Thalheim
6ecfae69f9 gitignore: add check binary 2021-08-26 07:23:36 +02:00
Jörg Thalheim
c8d3af95d4 add sanitizer build to CI 2021-08-26 07:23:36 +02:00
Jörg Thalheim
a9f5397ee1 add ubsan option 2021-08-26 07:09:35 +02:00