File tree Expand file tree Collapse file tree 5 files changed +49
-15
lines changed Expand file tree Collapse file tree 5 files changed +49
-15
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,8 @@ src_TESTS = \
3939 no-dynamic-section.sh \
4040 args-from-file.sh \
4141 basic-flags.sh \
42- set-empty-rpath.sh
42+ set-empty-rpath.sh \
43+ phdr-corruption.sh
4344
4445build_TESTS = \
4546 $(no_rpath_arch_TESTS )
@@ -104,7 +105,8 @@ check_DATA = libbig-dynstr.debug
104105# - without libtool, only archives (static libraries) can be built by automake
105106# - with libtool, it is difficult to control options
106107# - with libtool, it is not possible to compile convenience *dynamic* libraries :-(
107- check_PROGRAMS += libfoo.so libfoo-scoped.so libbar.so libbar-scoped.so libsimple.so libbuildid.so libtoomanystrtab.so
108+ check_PROGRAMS += libfoo.so libfoo-scoped.so libbar.so libbar-scoped.so libsimple.so libbuildid.so libtoomanystrtab.so \
109+ phdr-corruption.so
108110
109111libbuildid_so_SOURCES = simple.c
110112libbuildid_so_LDFLAGS = $(LDFLAGS_sharedlib ) -Wl,-build-id
@@ -138,3 +140,7 @@ no_rpath_CFLAGS =
138140contiguous_note_sections_SOURCES = contiguous-note-sections.s contiguous-note-sections.ld
139141contiguous_note_sections_LDFLAGS = -nostdlib -T contiguous-note-sections.ld
140142contiguous_note_sections_CFLAGS = -pie
143+
144+ phdr_corruption_so_SOURCES = void.c phdr-corruption.ld
145+ phdr_corruption_so_LDFLAGS = -nostdlib -shared -Wl,-Tphdr-corruption.ld
146+ phdr_corruption_so_CFLAGS =
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ PHDRS
2+ {
3+ headers PT_PHDR PHDRS ;
4+ text PT_LOAD FILEHDR PHDRS ;
5+ interp PT_INTERP ;
6+ }
7+
8+ SECTIONS
9+ {
10+ . = SIZEOF_HEADERS ;
11+ . = ALIGN (4 );
12+
13+ . = . + 0x1000 ;
14+ .interp : { *(.interp ) } :text :interp
15+ .text : { *(.text ) } :text
16+ }
Original file line number Diff line number Diff line change 1+ #! /bin/sh -e
2+
3+ PATCHELF=" ../src/patchelf"
4+ SONAME=" phdr-corruption.so"
5+ SCRATCH=" scratch/$( basename $0 .sh) "
6+ SCRATCH_SO=" ${SCRATCH} /${SONAME} "
7+
8+ rm -rf " ${SCRATCH} "
9+ mkdir -p " ${SCRATCH} "
10+ cp " ${SONAME} " " ${SCRATCH} "
11+
12+ " ${PATCHELF} " --set-rpath " $( pwd) " " ${SCRATCH_SO} "
13+
14+ # Check for PT_PHDR entry VirtAddr corruption
15+ readelfData=$( readelf -l " ${SCRATCH_SO} " 2>&1 )
16+
17+ if [ $( echo " $readelfData " | grep --count " PHDR" ) != 1 ]; then
18+ # Triggered if PHDR errors appear on stderr
19+ echo " ERROR: Unexpected number of occurences of PHDR in readelf results!"
20+ exit 1
21+ fi
Original file line number Diff line number Diff line change 1+ int main ()
2+ {
3+ return 0 ;
4+ }
You can’t perform that action at this time.
0 commit comments