Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ src_TESTS = \
no-dynamic-section.sh \
args-from-file.sh \
basic-flags.sh \
set-empty-rpath.sh
set-empty-rpath.sh \
phdr-corruption.sh

build_TESTS = \
$(no_rpath_arch_TESTS)
Expand Down Expand Up @@ -104,7 +105,8 @@ check_DATA = libbig-dynstr.debug
# - without libtool, only archives (static libraries) can be built by automake
# - with libtool, it is difficult to control options
# - with libtool, it is not possible to compile convenience *dynamic* libraries :-(
check_PROGRAMS += libfoo.so libfoo-scoped.so libbar.so libbar-scoped.so libsimple.so libbuildid.so libtoomanystrtab.so
check_PROGRAMS += libfoo.so libfoo-scoped.so libbar.so libbar-scoped.so libsimple.so libbuildid.so libtoomanystrtab.so \
phdr-corruption.so

libbuildid_so_SOURCES = simple.c
libbuildid_so_LDFLAGS = $(LDFLAGS_sharedlib) -Wl,-build-id
Expand Down Expand Up @@ -138,3 +140,7 @@ no_rpath_CFLAGS =
contiguous_note_sections_SOURCES = contiguous-note-sections.s contiguous-note-sections.ld
contiguous_note_sections_LDFLAGS = -nostdlib -T contiguous-note-sections.ld
contiguous_note_sections_CFLAGS = -pie

phdr_corruption_so_SOURCES = void.c phdr-corruption.ld
phdr_corruption_so_LDFLAGS = -nostdlib -shared -Wl,-Tphdr-corruption.ld
phdr_corruption_so_CFLAGS =
13 changes: 0 additions & 13 deletions tests/PR243-reproducer.sh

This file was deleted.

16 changes: 16 additions & 0 deletions tests/phdr-corruption.ld
Original file line number Diff line number Diff line change
@@ -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
}
21 changes: 21 additions & 0 deletions tests/phdr-corruption.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#! /bin/sh -e

PATCHELF="../src/patchelf"
SONAME="phdr-corruption.so"
SCRATCH="scratch/$(basename $0 .sh)"
SCRATCH_SO="${SCRATCH}/${SONAME}"

rm -rf "${SCRATCH}"
mkdir -p "${SCRATCH}"
cp "${SONAME}" "${SCRATCH}"

"${PATCHELF}" --set-rpath "$(pwd)" "${SCRATCH_SO}"

# Check for PT_PHDR entry VirtAddr corruption
readelfData=$(readelf -l "${SCRATCH_SO}" 2>&1)

if [ $(echo "$readelfData" | grep --count "PHDR") != 1 ]; then
# Triggered if PHDR errors appear on stderr
echo "ERROR: Unexpected number of occurences of PHDR in readelf results!"
exit 1
fi
4 changes: 4 additions & 0 deletions tests/void.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
int main()
{
return 0;
}