diff options
author | Ovidiu Panait <ovpanait@gmail.com> | 2021-09-26 16:51:36 +0300 |
---|---|---|
committer | Ovidiu Panait <ovpanait@gmail.com> | 2021-09-26 19:09:55 +0300 |
commit | 424d3f5083ac08100b9aea233b8133ecf54694b8 (patch) | |
tree | 8e5ae309aa1c94918c7e46cbe95ce857f5edb29c /tests/phdr-corruption.ld | |
parent | 3cfd9a6637a3a1f102839eedff69cab3e0a24985 (diff) | |
download | patchelf-424d3f5083ac08100b9aea233b8133ecf54694b8.tar.gz |
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] https://github.com/NixOS/patchelf/commit/8f94e116f3c63afe224f1ec48ccad6f068f835df
Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
Diffstat (limited to 'tests/phdr-corruption.ld')
-rw-r--r-- | tests/phdr-corruption.ld | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/phdr-corruption.ld b/tests/phdr-corruption.ld new file mode 100644 index 0000000..6cf322c --- /dev/null +++ b/tests/phdr-corruption.ld @@ -0,0 +1,16 @@ +PHDRS +{ + headers PT_PHDR PHDRS; + text PT_LOAD FILEHDR PHDRS; + interp PT_INTERP ; +} + +SECTIONS +{ + . = SIZEOF_HEADERS; + . = ALIGN(4); + + . = . + 0x1000; + .interp : { *(.interp) } :text :interp + .text : { *(.text) } :text +} |