Commit Graph

42 Commits

Author SHA1 Message Date
Jörg Thalheim
76486f7643 fix c++17 check
https://github.com/NixOS/patchelf/issues/393

Appearantly there are compilers that support -std=c++17 but do not
really support c++17.

(cherry picked from commit 9921136529)
2025-08-12 18:38:06 -04:00
John Ericson
d27e04333c Merge commit '7281d999e95d6730d1d08fc7517c15e27ddfb65f' into 0.15-maintenance 2025-08-12 18:37:16 -04:00
John Ericson
03746bff2c Backport infra improvements from master to 0.15
This is the version currently used in Nixpkgs as the stable version, so
I am interested in seeing it be developable, even as the hope is to move
to a newer version.
2025-08-12 14:54:44 -04:00
Jörg Thalheim
e89d02f33d add compiler check for c++17 2022-07-16 08:05:26 +02: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
a9f5397ee1 add ubsan option 2021-08-26 07:09:35 +02:00
Ovidiu Panait
d2bb23badf tests: add testcase for alignment issues with contiguous note sections
Add a testcase for the following reported alignment issue with contiguous note
sections (#275):

"""
If a binary has multiple SHT_NOTE sections and corresponding PT_NOTE
headers, we can see the error:

patchelf: cannot normalize PT_NOTE segment: non-contiguous SHT_NOTE sections

if the SHT_NOTE sections aren't sized to end on aligned boundaries. An example
would be a binary with:

[ 2] .note.ABI-tag NOTE 00000000000002f4 000002f4
0000000000000020 0000000000000000 A 0 0 4
[ 3] .note.gnu.propert NOTE 0000000000000318 00000318
0000000000000030 0000000000000000 A 0 0 8
[ 4] .note.gnu.build-i NOTE 0000000000000348 00000348
0000000000000024 0000000000000000 A 0 0 4

NOTE 0x0000000000000318 0x0000000000000318 0x0000000000000318
0x0000000000000030 0x0000000000000030 R 0x8
NOTE 0x00000000000002f4 0x00000000000002f4 0x00000000000002f4
0x0000000000000078 0x0000000000000074 R 0x4

since the PT_NOTE section at 2f4 covers [2] and [3] but the code
calclates curr_off should be 314, not the 318 in the binary. This
is an alignment issue.
"""

Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
2021-08-04 12:31:15 +03:00
Domen Kožar
4d03718b17 Revert "tests: add testcase for alignment issues with contiguous note sections"
This reverts commit fccd901efe.
2021-08-03 16:30:13 +02:00
Ovidiu Panait
fccd901efe tests: add testcase for alignment issues with contiguous note sections
Add a testcase for the following reported alignment issue with contiguous note
sections (#275):

"""
If a binary has multiple SHT_NOTE sections and corresponding PT_NOTE
headers, we can see the error:

patchelf: cannot normalize PT_NOTE segment: non-contiguous SHT_NOTE sections

if the SHT_NOTE sections aren't sized to end on aligned boundaries. An example
would be a binary with:

[ 2] .note.ABI-tag NOTE 00000000000002f4 000002f4
0000000000000020 0000000000000000 A 0 0 4
[ 3] .note.gnu.propert NOTE 0000000000000318 00000318
0000000000000030 0000000000000000 A 0 0 8
[ 4] .note.gnu.build-i NOTE 0000000000000348 00000348
0000000000000024 0000000000000000 A 0 0 4

NOTE 0x0000000000000318 0x0000000000000318 0x0000000000000318
0x0000000000000030 0x0000000000000030 R 0x8
NOTE 0x00000000000002f4 0x00000000000002f4 0x00000000000002f4
0x0000000000000078 0x0000000000000074 R 0x4

since the PT_NOTE section at 2f4 covers [2] and [3] but the code
calclates curr_off should be 314, not the 318 in the binary. This
is an alignment issue.
"""

Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
2021-07-21 22:41:36 +03:00
Pierre Bourdon
0470d6921b Improve the default section alignment choice
Currently patchelf uses the host system's page size (determined at build
time) as the default section load memory alignment. This causes multiple
issues

- Cross-compilation: when using patchelf on ELFs targetting a different
  architecture from the host, the host page size is still used by
  default.

- Variable page size architectures: ARMv8 systems can be configured in
  either 4K, 16K, or 64K page size mode depending on kernel
  configuration. An ARMv8 patchelf built on a 4K page size system will
  end up creating ELFs that cannot be used on a 64K page size system.

- Reproducibility: the page size of the machine that built patchelf
  "leaks" into the binary.

The build time --with-page-size as well as the run time --page-size
options can be used to work around some of these issues. But it's much
better to have patchelf do the right thing without explicit
configuration.

This commit adds support for inferring page size from the ELF header's
"machine" field. The default values are extracted from GNU gold's source
code. Note that both --with-page-size as well as --page-size continue to
work and take precedence on the default value.
2020-06-20 01:46:23 +02:00
Domen Kožar
4dc6e9e3d5 Merge pull request #130 from am813nt/master
Fixed parallel execution of tests (parallel-tests in automake)
2020-06-16 10:18:22 +02:00
Aaron D. Marasco
e522b14edc Add libasan build option and test print-needed
(cherry picked from commit 288eb61a173ce6f4cdf0be0d744c9c6b6b5598a4)
2020-06-10 09:51:37 -04:00
am813nt
54efea9e69 Set automake and autoconf versions required for parallel-tests 2017-08-02 17:00:42 +05:00
am813nt
a6e524c418 Fixed tests to be running with parallel-tests 2017-08-02 16:57:33 +05:00
Bjørn Forsman
3641be10cf configure.ac: use "command -v" instead of "type -p"
"type -p" is a Bash thing, whereas "command -v" is specified by POSIX
(more portable).
2017-08-01 12:08:47 +02:00
James Le Cuirot
4034c6de0b Make tests run in serial as they break in parallel
It would be nice to fix them in parallel but I lack the time.
2016-03-17 22:27:56 +00:00
Eelco Dolstra
a28fd74cc7 Fix PAGESIZE auto-determination
Don't use "which" (which might not exist), and don't redirect getconf
auto to /dev/null.
2016-02-22 20:23:15 +01:00
Felipe Sateler
5c5026e572 Allow specifying page size at configure time 2016-01-14 22:47:00 -03:00
Felipe Sateler
2b3c9602e7 Remove stale sysconf configure check 2016-01-14 22:21:08 -03:00
Eelco Dolstra
6900cf904c Merge branch 'patch-1' of https://github.com/darealshinji/patchelfmod
Conflicts:
	configure.ac
2015-07-23 23:33:27 +02:00
Adrien Devresse
35ecfa7b62 Configure automatically the page size with a runtime call, solve the issue #53 related to prtability on powerpc64 architecture 2015-07-23 23:31:22 +02:00
Alexandre Pretyman
3b9e7913a6 Change configure.ac from OpenWrt to support Mac OS
This change is from the OpenWrt project, from the URL:
https://dev.openwrt.org/ticket/18998
It enables patchelf to sucessfully compile and run under Mac OS and
keeps compatibility with Linux.

Tested under Mac OS X 10.9.5 and Ubuntu 15.04 to patch a binary of type
ELF 32-bit LSB executable - the patch fully worked

This patch is credited to Felix Fietkau
2015-07-17 11:58:59 +02:00
darealshinji
80e25cdfa9 Don't need libattr and libacl anymore 2015-07-13 18:56:15 +02:00
Jeremy Sanders
92fbe1a0e5 Use libattr and libacl to copy permissions if available 2014-07-29 02:46:07 +02:00
Eelco Dolstra
c330f99196 Don't use the "version suffix" stuff in releaseTools.sourceTarball
It's confusing.
2013-03-06 16:58:24 +01:00
Eelco Dolstra
a1ddbd47d3 Fix configure.ac
tests/Makefile.am:20: warning: compiling 'simple.c' with per-target flags requires 'AM_PROG_CC_C_O' in 'configure.ac'

http://hydra.nixos.org/build/2796463
2012-07-17 10:45:37 -04:00
Vincent Danjean
00b2fa4f77 Rewrite tests in automake
- add options in AM_INIT_AUTOMAKE to be more strict
  and to enable more advanced features (color-tests and parallel-tests)
- rewrite tests/Makefile.am to use automake rules for building program and libraries

=> we can now do:
./bootstrap.sh && mkdir build && cd build && ../configure && make -j distcheck
2012-07-10 18:16:24 -04:00
Vincent Danjean
c364c397be Cleanup configure.ac
- quote argument (mostly cosmetic)
- use a file present only once in the sources for AC_CONFIG_SRCDIR
- use AC_CONFIG_AUX_DIR to put all auxilary scripts in a subdirectory
2012-07-10 18:16:24 -04:00
Eelco Dolstra
326f168c02 Use underscores in versions to keep RPM happy
RPM doesn't allow dashes in version numbers, so use an underscore
instead.  Also, let Autoconf generate the RPM spec file.
2011-12-14 16:35:50 +01:00
Eelco Dolstra
0bc577f033 * Put the current version in a separate file so that it can be used in
the release expression.
2009-03-02 13:50:26 +00:00
Eelco Dolstra
4290edae65 * Let the release expression supply a version suffix. 2008-11-25 15:33:30 +00:00
Eelco Dolstra
89318a1950 * Bump the version number. 2008-06-04 11:16:56 +00:00
Eelco Dolstra
6cdd748eb8 * Bake a stable release. 2008-06-04 11:05:05 +00:00
Eelco Dolstra
5dcc6ef25b * Bump the version number to 0.4. 2007-05-24 17:47:57 +00:00
Eelco Dolstra
dcc2a1f003 * Bump the version number. 2007-01-15 12:42:21 +00:00
Eelco Dolstra
7ec0e80c1d * DOH! 2007-01-15 12:24:22 +00:00
Eelco Dolstra
6e68740e37 * Mark as stable. 2007-01-15 12:22:03 +00:00
Eelco Dolstra
020c2393cf * Bump the revision number to 0.2. 2005-10-11 13:23:40 +00:00
Eelco Dolstra
955d3334ed * Use a real programming language. 2005-09-30 09:50:51 +00:00
Eelco Dolstra
8685534261 * Add dist files. 2005-09-29 12:17:56 +00:00
Eelco Dolstra
0da4ea8b65 * Add tests. 2005-09-29 12:03:56 +00:00
Eelco Dolstra
f4f4117040 * Autoconfiscate patchelf. 2004-09-24 22:05:46 +00:00