974 Commits

Author SHA1 Message Date
Christian Göttsche
fbb12a72ad Add misc functions annotations
Make the behavior of functions more explicit.
2023-02-21 19:40:52 +01:00
Christian Göttsche
ce5907fc40 Add required includes in header file
Enable to parse the header file on its own, e.g. for language servers
(clangd).
2023-02-21 19:40:44 +01:00
Breno Rodrigues Guimaraes
107ebb65ba No need for both assert and exception 2023-02-21 06:51:57 -03:00
Breno Rodrigues Guimaraes
6de67423ca Code polishing to use more spans 2023-02-21 06:49:20 -03:00
Breno Rodrigues Guimaraes
b09b28f3c7 Add out-of-range check for span 2023-02-21 06:37:47 -03:00
Breno Rodrigues Guimarães
b9474398c5 Merge branch 'NixOS:master' into breno.rename_syms 2023-02-21 06:23:42 -03:00
Breno Rodrigues Guimarães
5380f3b3a6 Update patchelf.1
Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
2023-02-21 06:12:44 -03:00
Breno Rodrigues Guimaraes
cd0926c73f Add description to patchelf.1 2023-02-20 19:32:47 -03:00
bors[bot]
8d3188daa7 Merge #463
463: Apply fixes from shellcheck r=Mic92 a=Mic92



Co-authored-by: Jörg Thalheim <joerg@thalheim.io>
2023-02-20 22:20:05 +00:00
Jörg Thalheim
a187790b47 bump github actions version 2023-02-20 23:18:33 +01: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
bors[bot]
365e1e0186 Merge #456
456: Add options to print, clear and set executable stack state r=Mic92 a=cgzones



Co-authored-by: Christian Göttsche <cgzones@googlemail.com>
2023-02-20 21:24:57 +00:00
Breno Rodrigues Guimaraes
2ccf3c385e to trigger ci 2023-02-20 16:55:47 -03:00
Breno Rodrigues Guimarães
313c6115b7 Update src/patchelf.cc
Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
2023-02-19 09:27:44 -03:00
bors[bot]
85b3460be0 Merge #458
458: Bump cachix/install-nix-action from 18 to 19 r=Mic92 a=dependabot[bot]



Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-19 07:01:21 +00: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
dependabot[bot]
0d91ddc99d Bump cachix/install-nix-action from 18 to 19
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 18 to 19.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v18...v19)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-13 02:52:26 +00: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
Jörg Thalheim
5908e16cd5 bump version 0.17.2 2023-01-10 20:37:51 +01:00
bors[bot]
583fd5a360 Merge #447
447: Split segment size fix r=Mic92 a=otherjason



Co-authored-by: Jason <otherjason@nodomain.com>
0.17.1
2023-01-10 17:28:47 +00:00
Jason
3a6d771127 Revert "shiftFile: when splitting a segment into two pieces, preserve the original flags in both"
This reverts commit f4f1848e42.
2022-12-28 23:47:36 -05:00
bors[bot]
c6f4069f6f Merge #452
452: Add bors.toml r=Mic92 a=Mic92



Co-authored-by: Jörg Thalheim <joerg@thalheim.io>
2022-12-27 09:58:34 +00:00
Jörg Thalheim
2b1789b68c bors: add configuration 2022-12-27 10:58:02 +01:00
Jörg Thalheim
ce1009850c bump nixpkgs 2022-12-27 10:16:02 +01:00
Jörg Thalheim
25307883a5 Merge pull request #451 from yairKoskas/master
Fix Out-of-bounds read in the function modifySoname
2022-12-27 09:09:45 +00:00
yairKoskas
e9d3394659 Out-of-bounds read exists in the function modifySoname 2022-12-27 09:19:52 +02:00
Jason
8d2cb4f9ab Fix bug in file shifting that could cause conflicting PT_LOAD segments
When a section in the file needs to be enlarged (e.g. to accommodate
setting a larger RPATH), shiftFile() is used to shift all content
following the growing section to a later position in the file.

Commit 109b771f53 introduced logic to
ensure that, after the segment split, no sections span multiple
segments. This is done by sliding the portion of the segment after the
split point later in the file, then adding a new PT_LOAD segment that
contains the preceding data plus the extra room that is being added. The
existing implementation does this by simply adding
`extraPages*getPageSize()` bytes to the number of bytes ahead of the
split point in the segment.

However, this approach can result in two PT_LOAD segments that overlap
when page boundaries are taken into account. As an example, this PT_LOAD
section (taken from a Python 3.10 binary):

LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000
               0x0000000000000948 0x0000000000000948  R E    0x200000

is split into the following two sections:

LOAD           0x0000000000000000 0x00000000003ff000 0x00000000003ff000
               0x0000000000001594 0x0000000000001594  R E    0x1000
LOAD           0x0000000000001594 0x0000000000400594 0x0000000000400594
               0x00000000000003b4 0x00000000000003b4  R E    0x1000

Note that the two PT_LOAD sections both contain the memory page at
address 0x400000. The Linux kernel's ELF loader (at least as of v4.18)
does not accept this as a valid ELF executable, triggering a segfault
with si_code=SI_KERNEL immediately when the binary is executed.

The fix here is to set the length of the segment that comes before the
split point more carefully; instead of adding `extraPages*getPageSize()`
bytes to the portion of the segment that came before the split, the
actual number of padding bytes that were needed (before rounding up to
the next multiple of the page size) are used. This avoids the overlap
in the PT_LOAD segments and makes the output files executable again.
2022-12-02 10:01:41 -05:00
Jason
f4f1848e42 shiftFile: when splitting a segment into two pieces, preserve the original flags in both 2022-12-02 09:58:49 -05:00
Jörg Thalheim
3f90e4925c Merge pull request #445 from NixOS/win32
switch back to upstream nixpkgs for windows build
2022-11-17 19:31:39 +01:00
Jörg Thalheim
0826d9d4a8 switch back to upstream nixpkgs for windows build 2022-11-17 18:33:59 +01:00
Jörg Thalheim
adf5c05a5e Merge pull request #444 from NixOS/netbsd
cross compile to netbsd
2022-11-14 10:43:54 +01:00
Jörg Thalheim
db6f4e6bb0 cross compile to netbsd 2022-11-14 10:38:29 +01:00
Jörg Thalheim
fe789649fa Merge pull request #443 from heirecka/also-pass-strip-to-tests
Also pass STRIP to the tests
2022-11-08 10:11:25 +01:00
Jörg Thalheim
eab1466d9a Merge pull request #442 from NixOS/ci
Ci
2022-11-08 10:07:07 +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
204f950704 put version name in built exe files 2022-11-07 18:26:36 +01:00
Jörg Thalheim
016ca3d8e0 bump version 2022-11-07 18:26:36 +01:00
Jörg Thalheim
ad0265668f Merge pull request #441 from NixOS/ci
bump version 0.17.0
0.17.0
2022-11-07 10:57:32 +01:00
Jörg Thalheim
e106c599eb bump version 0.17.0 2022-11-06 23:22:11 +01:00
Jörg Thalheim
0e5a9f0cc8 Merge pull request #438 from NixOS/ci
build patchelf on windows
2022-11-06 22:55:54 +01:00
Jörg Thalheim
199b134356 Merge branch 'master' into ci 2022-11-06 22:46:02 +01:00
Jörg Thalheim
d6ee352ee6 Merge pull request #440 from NixOS/fix-cross
fix checkPhase for cross builds
2022-11-06 22:44:10 +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
2b42ac343d ci: build windows binaries
build patchelf on window
2022-11-06 22:18:27 +01:00
Jörg Thalheim
a1f7aa8bda Merge pull request #439 from NixOS/mingw
build patchelf on windows
2022-11-06 21:12:06 +01:00
Jörg Thalheim
efeec8d709 build patchelf on window 2022-11-06 21:08:25 +01:00
Jörg Thalheim
b526538610 build patchelf on window 2022-11-06 20:28:27 +01:00
Jörg Thalheim
07bbf47e9c Merge pull request #437 from NixOS/ci
make objdump/objcopy/readelf configurable and respect cross-compiling…
2022-11-06 15:49:06 +01:00