Skip to content

Commit 795253a

Browse files
committed
Merge branch '0.17-maintenance' into 0.18-maintenance
2 parents 8b1e0ff + 04e83a2 commit 795253a

File tree

4 files changed

+163
-47
lines changed

4 files changed

+163
-47
lines changed

ChangeLog.md

Lines changed: 61 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,45 @@
1-
## Release History
1+
# Release History
2+
3+
## 0.16.2 (Yet to be released)
4+
5+
The release combines the 0.15.1 through 0.15.4 backports with 0.16.1.
6+
7+
* Code quality and infra changes just like 0.15.{1,2}
8+
* Update to a later glibc `elf.h`, just like 0.15.4
29

310
## 0.16.1 (October 28, 2022)
411

512
This release only fixes the incorrect reported version by the 0.16.0 release.
613

714
## 0.16.0 (October 27, 2022)
815

9-
These notes are the remainder of 0.16.0 that was not backported to 0.15.3.
10-
Originally, 0.16.0 would have freshly contained all items from both releases.
16+
Changes from 0.15.3:
1117

1218
* Add `--print-os-abi` and `--set-os-abi` options by @dmsck in https://github.com/NixOS/patchelf/pull/381
1319
* Sync `.note.gnu.property` to `PT_GNU_PROPERTY` by @Bo98 in https://github.com/NixOS/patchelf/pull/414
1420
* Rework file shifting to avoid sections crossing multiple segments by @Bo98 in https://github.com/NixOS/patchelf/pull/415
1521

16-
## 0.15.3 (yet to be released)
22+
(These notes are the remainder of 0.16.0 that was not backported to 0.15.3.
23+
Originally, 0.16.0 was branched from 0.15.0, and those changes were fresh in this release, having never been backported.)
24+
25+
## 0.15.5 (August 12, 2025)
26+
27+
Bugfix backports from 0.18.0:
28+
29+
* Adjust `roundUp` for 0 as input by @cgzones in https://github.com/NixOS/patchelf/pull/466
30+
31+
Bugfix backports from 0.17.{0, 1}:
32+
33+
* Fix page size constants for Itanium and SPARC.
34+
* Fix Out-of-bounds read in the function `modifySoname` by @yairKoskas in https://github.com/NixOS/patchelf/pull/451
35+
36+
## 0.15.4 (August 12, 2025)
37+
38+
* Update to a later glibc `elf.h`.
39+
40+
This should not result in any behavioral changes, except for possibly better architecture-specific support.
41+
42+
## 0.15.3 (August 12, 2025)
1743

1844
This is a backport release made from the simplest fixes from 0.16.0.
1945

@@ -39,13 +65,13 @@ The behavior of this version should be essentially the same as 0.15.0.
3965

4066
## 0.15.0 (July 16, 2022)
4167

42-
* Add --add-debug option by @deadw00d in https://github.com/NixOS/patchelf/pull/367
43-
* Add O_BINARY flag when opening files to allow compilation for Windows by @JagoGyselinck in https://github.com/NixOS/patchelf/pull/372
44-
* Document --print-needed by @klemensn in https://github.com/NixOS/patchelf/pull/375
68+
* Add `--add-debug` option by @deadw00d in https://github.com/NixOS/patchelf/pull/367
69+
* Add `O_BINARY flag` when opening files to allow compilation for Windows by @JagoGyselinck in https://github.com/NixOS/patchelf/pull/372
70+
* Document `--print-needed` by @klemensn in https://github.com/NixOS/patchelf/pull/375
4571
* modifyRPath: return early if new and old rpath are empty by @ehmry in https://github.com/NixOS/patchelf/pull/376
46-
* Add comment explaining calculation for DT_MIPS_RLD_MAP_REL by @amjoseph-nixpkgs in https://github.com/NixOS/patchelf/pull/379
47-
* Add --no-sort option by @amjoseph-nixpkgs in https://github.com/NixOS/patchelf/pull/378
48-
* Handle DT_MIPS_XHASH and .MIPS.xhash by @amjoseph-nixpkgs in https://github.com/NixOS/patchelf/pull/380
72+
* Add comment explaining calculation for `DT_MIPS_RLD_MAP_REL` by @amjoseph-nixpkgs in https://github.com/NixOS/patchelf/pull/379
73+
* Add `--no-sort option` by @amjoseph-nixpkgs in https://github.com/NixOS/patchelf/pull/378
74+
* Handle `DT_MIPS_XHASH` and `.MIPS.xhash` by @amjoseph-nixpkgs in https://github.com/NixOS/patchelf/pull/380
4975

5076
## 0.14.5 (February 21, 2022)
5177

@@ -57,7 +83,7 @@ The behavior of this version should be essentially the same as 0.15.0.
5783
* Allow multiple modifications in same call by @fzakaria in https://github.com/NixOS/patchelf/pull/361
5884
* Add support to build with musl by @fzakaria in https://github.com/NixOS/patchelf/pull/362
5985
* Fix typo: s/folllow/follow/ by @bjornfor in https://github.com/NixOS/patchelf/pull/366
60-
* mips: fix incorrect polarity on dyn_offset; closes #364 by @a-m-joseph in https://github.com/NixOS/patchelf/pull/365
86+
* mips: fix incorrect polarity on `dyn_offset`; closes #364 by @a-m-joseph in https://github.com/NixOS/patchelf/pull/365
6187

6288
## 0.14.3 (December 05, 2021)
6389

@@ -76,13 +102,13 @@ The behavior of this version should be essentially the same as 0.15.0.
76102
Changes compared to 0.13:
77103

78104
* Bug fixes:
79-
- Fix corrupted library names when using --replace-needed multiple times
105+
- Fix corrupted library names when using `--replace-needed` multiple times
80106
- Fix setting an empty rpath
81-
- Don't try to parse .dynamic section of type NOBITS
82-
- Fix use-after-free in normalizeNoteSegments
83-
- Correct EINTR handling in writeFile
84-
- MIPS: Adjust PT_MIPS_ABIFLAGS segment and DT_MIPS_RLD_MAP_REL dynamic section if present
85-
- Fix binaries without .gnu.hash section
107+
- Don't try to parse `.dynamic section` of type `NOBITS`
108+
- Fix use-after-free in `normalizeNoteSegments`
109+
- Correct `EINTR` handling in writeFile
110+
- MIPS: Adjust `PT_MIPS_ABIFLAGS` segment and `DT_MIPS_RLD_MAP_REL` dynamic section if present
111+
- Fix binaries without `.gnu.hash` section
86112
* Support loongarch architecture
87113
* Remove limits on output file size for elf files
88114
* Allow reading rpath from file
@@ -93,12 +119,12 @@ Changes compared to 0.13:
93119
* Bug fixes:
94120
- fix setting empty rpath
95121
- use memcpy instead of strcpy to set rpath
96-
- Don't try to parse .dynamic section of type NOBITS
97-
- fix use-after-free in normalizeNoteSegments
98-
- correct EINTR handling in writeFile
99-
- Adjust PT_MIPS_ABIFLAGS segment if present
100-
- Adjust DT_MIPS_RLD_MAP_REL dynamic section entry if present
101-
- fix binaries without .gnu.hash section
122+
- Don't try to parse `.dynamic section` of type `NOBITS`
123+
- fix use-after-free in `normalizeNoteSegments`
124+
- correct `EINTR` handling in writeFile
125+
- Adjust `PT_MIPS_ABIFLAGS` segment if present
126+
- Adjust `DT_MIPS_RLD_MAP_REL` dynamic section entry if present
127+
- fix binaries without `.gnu.hash` section
102128

103129
## 0.13 (August 5, 2021)
104130

@@ -126,7 +152,7 @@ Changes compared to 0.13:
126152

127153
* Many bug fixes. Please refer to the Git commit log:
128154

129-
https://github.com/NixOS/patchelf/commits/master
155+
https://github.com/NixOS/patchelf/commits/0.10
130156

131157
This release has contributions from Adam Trhoň, Benjamin Hipple,
132158
Bernardo Ramos, Bjørn Forsman, Domen Kožar, Eelco Dolstra, Ezra
@@ -138,7 +164,7 @@ Changes compared to 0.13:
138164

139165
* Lots of new features. Please refer to the Git commit log:
140166

141-
https://github.com/NixOS/patchelf/commits/master
167+
https://github.com/NixOS/patchelf/commits/0.9
142168

143169
This release has contributions from Aaron D. Marasco, Adrien
144170
Devresse, Alexandre Pretyman, Changli Gao, Chingis Dugarzhapov,
@@ -155,7 +181,7 @@ Changes compared to 0.13:
155181
* Rewrite section indices in symbol tables. This for instance allows
156182
gdb to show proper backtraces.
157183

158-
* Added `--remove-needed' option.
184+
* Added `--remove-needed` option.
159185

160186
## 0.6 (November 7, 2011)
161187

@@ -171,7 +197,7 @@ Changes compared to 0.13:
171197

172198
* Various bugfixes.
173199

174-
* `--force-rpath' now deletes the DT_RUNPATH if it is present.
200+
* `--force-rpath` now deletes the `DT_RUNPATH` if it is present.
175201

176202
## 0.4 (June 4, 2008)
177203

@@ -181,18 +207,18 @@ Changes compared to 0.13:
181207

182208
* FreeBSD support.
183209

184-
* `--set-rpath', `--shrink-rpath' and `--print-rpath' now prefer
185-
DT_RUNPATH over DT_RPATH, which is obsolete. When updating, if both
186-
are present, both are updated. If only DT_RPATH is present, it is
187-
converted to DT_RUNPATH unless `--force-rpath' is specified. If
188-
neither is present, a DT_RUNPATH is added unless `--force-rpath' is
189-
specified, in which case a DT_RPATH is added.
210+
* `--set-rpath`, `--shrink-rpath` and `--print-rpath` now prefer
211+
`DT_RUNPATH` over `DT_RPATH`, which is obsolete. When updating, if both
212+
are present, both are updated. If only `DT_RPATH` is present, it is
213+
converted to `DT_RUNPATH` unless `--force-rpath` is specified. If
214+
neither is present, a `DT_RUNPATH` is added unless `--force-rpath` is
215+
specified, in which case a `DT_RPATH` is added.
190216

191217
## 0.3 (May 24, 2007)
192218

193-
* Support for 64-bit ELF binaries (such as on x86_64-linux).
219+
* Support for 64-bit ELF binaries (such as on `x86_64-linux`).
194220

195-
* Support for big-endian ELF binaries (such as on powerpc-linux).
221+
* Support for big-endian ELF binaries (such as on `powerpc-linux`).
196222

197223
* Various bugfixes.
198224

src/elf.h

Lines changed: 75 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This file defines standard ELF types, structures, and macros.
2-
Copyright (C) 1995-2022 Free Software Foundation, Inc.
2+
Copyright (C) 1995-2023 Free Software Foundation, Inc.
33
This file is part of the GNU C Library.
44
55
The GNU C Library is free software; you can redistribute it and/or
@@ -210,7 +210,7 @@ typedef struct
210210
#define EM_68HC12 53 /* Motorola M68HC12 */
211211
#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator */
212212
#define EM_PCP 55 /* Siemens PCP */
213-
#define EM_NCPU 56 /* Sony nCPU embeeded RISC */
213+
#define EM_NCPU 56 /* Sony nCPU embedded RISC */
214214
#define EM_NDR1 57 /* Denso NDR1 microprocessor */
215215
#define EM_STARCORE 58 /* Motorola Start*Core processor */
216216
#define EM_ME16 59 /* Toyota ME16 processor */
@@ -559,7 +559,7 @@ typedef struct
559559

560560
/* Possible bitmasks for si_flags. */
561561
#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */
562-
#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */
562+
#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-through symbol for translator */
563563
#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */
564564
#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy
565565
loaded */
@@ -728,6 +728,7 @@ typedef struct
728728
#define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */
729729
#define PT_GNU_RELRO 0x6474e552 /* Read-only after relocation */
730730
#define PT_GNU_PROPERTY 0x6474e553 /* GNU property */
731+
#define PT_GNU_SFRAME 0x6474e554 /* SFrame segment. */
731732
#define PT_LOSUNW 0x6ffffffa
732733
#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */
733734
#define PT_SUNWSTACK 0x6ffffffb /* Stack segment */
@@ -1223,6 +1224,9 @@ typedef struct
12231224
#define AT_HWCAP2 26 /* More machine-dependent hints about
12241225
processor capabilities. */
12251226

1227+
#define AT_RSEQ_FEATURE_SIZE 27 /* rseq supported feature size. */
1228+
#define AT_RSEQ_ALIGN 28 /* rseq allocation alignment. */
1229+
12261230
#define AT_EXECFN 31 /* Filename of executable. */
12271231

12281232
/* Pointer to the global system page used for system calls and other
@@ -3998,8 +4002,11 @@ enum
39984002
#define R_RISCV_SET32 56
39994003
#define R_RISCV_32_PCREL 57
40004004
#define R_RISCV_IRELATIVE 58
4005+
#define R_RISCV_PLT32 59
4006+
#define R_RISCV_SET_ULEB128 60
4007+
#define R_RISCV_SUB_ULEB128 61
40014008

4002-
#define R_RISCV_NUM 59
4009+
#define R_RISCV_NUM 62
40034010

40044011
/* RISC-V specific values for the st_other field. */
40054012
#define STO_RISCV_VARIANT_CC 0x80 /* Function uses variant calling
@@ -4159,14 +4166,63 @@ enum
41594166
#define R_LARCH_GNU_VTINHERIT 57
41604167
#define R_LARCH_GNU_VTENTRY 58
41614168

4169+
/* reserved 59-63 */
4170+
4171+
#define R_LARCH_B16 64
4172+
#define R_LARCH_B21 65
4173+
#define R_LARCH_B26 66
4174+
#define R_LARCH_ABS_HI20 67
4175+
#define R_LARCH_ABS_LO12 68
4176+
#define R_LARCH_ABS64_LO20 69
4177+
#define R_LARCH_ABS64_HI12 70
4178+
#define R_LARCH_PCALA_HI20 71
4179+
#define R_LARCH_PCALA_LO12 72
4180+
#define R_LARCH_PCALA64_LO20 73
4181+
#define R_LARCH_PCALA64_HI12 74
4182+
#define R_LARCH_GOT_PC_HI20 75
4183+
#define R_LARCH_GOT_PC_LO12 76
4184+
#define R_LARCH_GOT64_PC_LO20 77
4185+
#define R_LARCH_GOT64_PC_HI12 78
4186+
#define R_LARCH_GOT_HI20 79
4187+
#define R_LARCH_GOT_LO12 80
4188+
#define R_LARCH_GOT64_LO20 81
4189+
#define R_LARCH_GOT64_HI12 82
4190+
#define R_LARCH_TLS_LE_HI20 83
4191+
#define R_LARCH_TLS_LE_LO12 84
4192+
#define R_LARCH_TLS_LE64_LO20 85
4193+
#define R_LARCH_TLS_LE64_HI12 86
4194+
#define R_LARCH_TLS_IE_PC_HI20 87
4195+
#define R_LARCH_TLS_IE_PC_LO12 88
4196+
#define R_LARCH_TLS_IE64_PC_LO20 89
4197+
#define R_LARCH_TLS_IE64_PC_HI12 90
4198+
#define R_LARCH_TLS_IE_HI20 91
4199+
#define R_LARCH_TLS_IE_LO12 92
4200+
#define R_LARCH_TLS_IE64_LO20 93
4201+
#define R_LARCH_TLS_IE64_HI12 94
4202+
#define R_LARCH_TLS_LD_PC_HI20 95
4203+
#define R_LARCH_TLS_LD_HI20 96
4204+
#define R_LARCH_TLS_GD_PC_HI20 97
4205+
#define R_LARCH_TLS_GD_HI20 98
4206+
#define R_LARCH_32_PCREL 99
4207+
#define R_LARCH_RELAX 100
4208+
4209+
/* ARC specific declarations. */
4210+
4211+
/* Processor specific flags for the Ehdr e_flags field. */
4212+
#define EF_ARC_MACH_MSK 0x000000ff
4213+
#define EF_ARC_OSABI_MSK 0x00000f00
4214+
#define EF_ARC_ALL_MSK (EF_ARC_MACH_MSK | EF_ARC_OSABI_MSK)
4215+
4216+
/* Processor specific values for the Shdr sh_type field. */
4217+
#define SHT_ARC_ATTRIBUTES (SHT_LOPROC + 1) /* ARC attributes section. */
41624218

41634219
/* ARCompact/ARCv2 specific relocs. */
41644220
#define R_ARC_NONE 0x0
41654221
#define R_ARC_8 0x1
41664222
#define R_ARC_16 0x2
41674223
#define R_ARC_24 0x3
41684224
#define R_ARC_32 0x4
4169-
#define R_ARC_B26 0x5
4225+
41704226
#define R_ARC_B22_PCREL 0x6
41714227
#define R_ARC_H30 0x7
41724228
#define R_ARC_N8 0x8
@@ -4206,16 +4262,23 @@ enum
42064262
#define R_ARC_SECTOFF_ME_2 0x2A
42074263
#define R_ARC_SECTOFF_1 0x2B
42084264
#define R_ARC_SECTOFF_2 0x2C
4265+
#define R_ARC_SDA_12 0x2D
4266+
#define R_ARC_SDA16_ST2 0x30
4267+
#define R_ARC_32_PCREL 0x31
42094268
#define R_ARC_PC32 0x32
42104269
#define R_ARC_GOTPC32 0x33
42114270
#define R_ARC_PLT32 0x34
42124271
#define R_ARC_COPY 0x35
42134272
#define R_ARC_GLOB_DAT 0x36
4214-
#define R_ARC_JUMP_SLOT 0x37
4273+
#define R_ARC_JMP_SLOT 0x37
42154274
#define R_ARC_RELATIVE 0x38
42164275
#define R_ARC_GOTOFF 0x39
42174276
#define R_ARC_GOTPC 0x3A
42184277
#define R_ARC_GOT32 0x3B
4278+
#define R_ARC_S21W_PCREL_PLT 0x3C
4279+
#define R_ARC_S25H_PCREL_PLT 0x3D
4280+
4281+
#define R_ARC_JLI_SECTOFF 0x3F
42194282

42204283
#define R_ARC_TLS_DTPMOD 0x42
42214284
#define R_ARC_TLS_DTPOFF 0x43
@@ -4224,9 +4287,12 @@ enum
42244287
#define R_ARC_TLS_GD_LD 0x46
42254288
#define R_ARC_TLS_GD_CALL 0x47
42264289
#define R_ARC_TLS_IE_GOT 0x48
4227-
#define R_ARC_TLS_DTPOFF_S9 0x4a
4228-
#define R_ARC_TLS_LE_S9 0x4a
4229-
#define R_ARC_TLS_LE_32 0x4b
4290+
#define R_ARC_TLS_DTPOFF_S9 0x49
4291+
#define R_ARC_TLS_LE_S9 0x4A
4292+
#define R_ARC_TLS_LE_32 0x4B
4293+
#define R_ARC_S25W_PCREL_PLT 0x4C
4294+
#define R_ARC_S21H_PCREL_PLT 0x4D
4295+
#define R_ARC_NPS_CMEM16 0x4E
42304296

42314297
/* OpenRISC 1000 specific relocs. */
42324298
#define R_OR1K_NONE 0

tests/invalid-elf.sh

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /bin/sh -u
1+
#! /bin/sh -ue
22

33
# Usage: killed_by_signal $?
44
#
@@ -18,6 +18,24 @@ TEST_DIR=$(dirname "$(readlink -f "$0")")/invalid-elf
1818
TEST_CASES="invalid-shrstrtab-idx invalid-shrstrtab-size invalid-shrstrtab-zero
1919
invalid-shrstrtab-nonterm invalid-shdr-name invalid-phdr-offset"
2020

21+
# Issue #64 regression test. Test ELF provided by issue submitter.
22+
TEST_CASES=$TEST_CASES' invalid-phdr-issue-64'
23+
24+
# shellcheck disable=SC2034
25+
invalid_shrstrtab_idx_MSG='data region extends past file end'
26+
# shellcheck disable=SC2034
27+
invalid_shrstrtab_size_MSG='data region extends past file end'
28+
# shellcheck disable=SC2034
29+
invalid_shrstrtab_zero_MSG='data region extends past file end'
30+
# shellcheck disable=SC2034
31+
invalid_shrstrtab_nonterm_MSG='data region extends past file end'
32+
# shellcheck disable=SC2034
33+
invalid_shdr_name_MSG='data region extends past file end'
34+
# shellcheck disable=SC2034
35+
invalid_phdr_offset_MSG='program header table out of bounds'
36+
# shellcheck disable=SC2034
37+
invalid_phdr_issue_64_MSG='program header table out of bounds'
38+
2139
FAILED_TESTS=""
2240

2341
for tcase in $TEST_CASES; do
@@ -26,10 +44,16 @@ for tcase in $TEST_CASES; do
2644
exit 1
2745
fi
2846

29-
../src/patchelf --output /dev/null "$TEST_DIR/$tcase"
30-
if killed_by_signal $?; then
47+
../src/patchelf --output /dev/null "$TEST_DIR/$tcase" && res=$? || res=$?
48+
if killed_by_signal "$res"; then
3149
FAILED_TESTS="$FAILED_TESTS $tcase"
3250
fi
51+
52+
var=$(echo "$tcase-MSG" | tr '-' '_')
53+
msg=
54+
eval "msg=\${$var}"
55+
../src/patchelf --output /dev/null "$TEST_DIR/$tcase" 2>&1 |
56+
grep "$msg" >/dev/null 2>/dev/null
3357
done
3458

3559
if [ -z "$FAILED_TESTS" ]; then
324 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)