Commit Graph

646 Commits

Author SHA1 Message Date
Adam Joseph
cad0212309 patchelf.1: mention new --no-sort option 2022-06-18 22:42:16 -07:00
Adam Joseph
9995113a40 add --no-sort option
This PR adds a command line option `--no-sort` which causes patchelf
to refrain from sorting the program headers and section headers.  A
comment in the preexisting source code says that this was done only
"for neatness".

The `--no-sort` option, combined with `readelf -a` and `colordiff` is
very useful for debugging patchelf problems.  Without `--no-sort` the
diffs are not usable -- everything changes because of the sorting.
2022-06-18 18:39:35 -07:00
Jörg Thalheim
be0cc30a59 Merge pull request #376 from ehmry/null-rpath
modifyRPath: return early if new and old rpath are empty
2022-05-20 17:51:33 +01:00
Emery Hemingway
761b494a9f modifyRPath: return early if new and old rpath are empty 2022-05-20 10:51:19 -05:00
Jörg Thalheim
309806c011 Merge pull request #375 from klemensn/document-print-needed
Document --print-needed
2022-05-11 19:40:36 +01:00
Klemens Nanni
8a633bd31d Document --print-needed
`--help` output has already.
2022-05-03 19:44:14 +02:00
Jörg Thalheim
31d052c1fd Merge pull request #372 from JagoGyselinck/master
Add O_BINARY flag when opening files to allow compilation for Windows
2022-04-07 07:26:17 +01:00
Jörg Thalheim
676326c0cf Update src/patchelf.cc 2022-04-07 07:22:02 +01:00
Jago Gyselinck
a04ca83ad7 Add O_BINARY flag when opening files to allow compilation for Windows 2022-04-06 15:27:33 +02:00
Jörg Thalheim
8f5ac59ade Merge pull request #367 from deadw00d/master
Add --add-debug option
2022-03-26 08:08:33 +00:00
deadwood
b92e442be0 Add test for --add-debug-tag argument 2022-02-23 16:42:51 +01:00
deadwood
86a2cd830f Add documentation for --add-debug-tag argument 2022-02-21 19:36:54 +01:00
deadwood
fd35bb9870 Update argument name to be more descriptive 2022-02-21 19:36:37 +01:00
Jörg Thalheim
a350545042 bump version 0.14.5 2022-02-21 14:26:56 +01:00
Jörg Thalheim
df7c57a032 bump version 0.14.4 2022-02-21 14:22:56 +01:00
deadwood
c6c4304ed6 Add --add-debug option
A shared library (-shared) by default does not receive DT_DEBUG tag.
This means that when a shared library has an entry point (so that it
can be run as an executable), the debugger does not connect to it
correctly and symbols are not resolved.

--add-debug option adds DT_DEBUG tag if it not yet present to an ELF
object.
2022-02-20 11:32:45 +01:00
Jörg Thalheim
a992616722 Merge pull request #365 from a-m-joseph/master
fix incorrect polarity on dyn_offset; closes #364
2022-02-05 07:35:34 +00:00
Eelco Dolstra
8fc7020015 Merge pull request #366 from bjornfor/fix-typo
Fix typo: s/folllow/follow/
2022-02-01 12:59:37 +01:00
Bjørn Forsman
d881452fd3 Fix typo: s/folllow/follow/ 2022-01-31 19:27:30 +01:00
Adam Joseph
457d297922 fix incorrect polarity on dyn_offset; closes #364 2022-01-21 23:37:20 -08:00
Jörg Thalheim
bdb09e90f7 Merge pull request #362 from fzakaria/faridzakaria/musl-flake
Add support to build with musl
2021-12-23 05:36:39 +00:00
Farid Zakaria
15a12d81f0 Make the develop point to the patchelf packages directly.
Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
2021-12-22 14:15:17 -05:00
Farid Zakaria
8aabe512bc Augmented README.md for new develop & build instructions 2021-12-22 09:50:59 -08:00
Farid Zakaria
03385bca80 Added musl devshell 2021-12-22 09:44:14 -08:00
Farid Zakaria
50d4335374 Add support to build with musl
Add support to the flake.nix to build with musl
```
nix build .#patchelf-musl
```
2021-12-22 08:59:14 -08:00
Jörg Thalheim
3d0a58ba10 Merge pull request #361 from fzakaria/faridzakaria/fix-add-replace-for-real
Allow multiple modifications in same call
2021-12-22 05:13:26 +00:00
Farid Zakaria
b92a6e8951 Fix replace-add-needed.sh test for musl 2021-12-21 14:30:45 -08:00
Farid Zakaria
e589fe3387 Merge branch 'master' into faridzakaria/fix-add-replace-for-real 2021-12-21 14:15:52 -08:00
Jörg Thalheim
c172ce6efb Merge pull request #360 from fzakaria/faridzakaria/fix-add-replace
Quality of life readability improvements
2021-12-21 19:47:20 +00:00
Farid Zakaria
4604393fd6 Renamed findSection2 to tryFindSectionHeader 2021-12-21 10:29:03 -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
dc375bc7cd Remove result and add it to gitignore 2021-12-20 17:36:06 -08:00
Farid Zakaria
e268662c32 Add a unit test 2021-12-20 17:34:26 -08:00
Farid Zakaria
d306abeb35 Allow multiple modifications in same call
`patchelf` previously would incorrectly patch the ELF header if it was
called with multiple changes at once such as _add_ & _replace_.

In order to support that, rewrite the sections in between each section
modification.

Fix #359
2021-12-20 16:01:18 -08:00
Farid Zakaria
10712373aa Renamed findSection3 to getSectionIndex 2021-12-20 14:59:15 -08:00
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