diff --git a/configure.ac b/configure.ac index 3af271f..2d752d4 100644 --- a/configure.ac +++ b/configure.ac @@ -6,6 +6,7 @@ AM_INIT_AUTOMAKE([1.11.1 -Wall -Werror dist-bzip2 foreign color-tests parallel-t AM_PROG_CC_C_O AC_PROG_CXX +AM_PROG_AS DEFAULT_PAGESIZE=auto AC_ARG_WITH([page-size], diff --git a/tests/Makefile.am b/tests/Makefile.am index 91a31b6..9b9e23e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,6 @@ LIBS = -check_PROGRAMS = simple main main-scoped big-dynstr no-rpath +check_PROGRAMS = simple main main-scoped big-dynstr no-rpath contiguous_note_sections no_rpath_arch_TESTS = \ no-rpath-amd64.sh \ @@ -27,7 +27,8 @@ src_TESTS = \ output-flag.sh \ no-rpath-pie-powerpc.sh \ build-id.sh \ - invalid-elf.sh + invalid-elf.sh \ + contiguous_note_sections.sh build_TESTS = \ $(no_rpath_arch_TESTS) @@ -106,3 +107,6 @@ libsimple_so_LDFLAGS = $(LDFLAGS_sharedlib) no_rpath_SOURCES = no-rpath.c # no -fpic for no-rpath.o no_rpath_CFLAGS = + +contiguous_note_sections_SOURCES = contiguous_note_sections.s +contiguous_note_sections_CFLAGS = -nostdlib -T contiguous_note_sections.ld diff --git a/tests/contiguous_note_sections.ld b/tests/contiguous_note_sections.ld new file mode 100644 index 0000000..8678a60 --- /dev/null +++ b/tests/contiguous_note_sections.ld @@ -0,0 +1,22 @@ +PHDRS +{ + headers PT_PHDR PHDRS ; + notes PT_NOTE; + text PT_LOAD FILEHDR PHDRS ; + data PT_LOAD ; + interp PT_INTERP ; + dynamic PT_DYNAMIC ; +} + +SECTIONS +{ + . = SIZEOF_HEADERS; + .note.my-section0 : { *(.note.my-section0) } :notes :text + .note.my-section1 : { *(.note.my-section1) } :notes :text + + .interp : { *(.interp) } :text :interp + .text : { *(.text) } :text + .rodata : { *(.rodata) } /* defaults to :text */ + + .data : { *(.data) } :data +} diff --git a/tests/contiguous_note_sections.s b/tests/contiguous_note_sections.s new file mode 100644 index 0000000..87f6044 --- /dev/null +++ b/tests/contiguous_note_sections.s @@ -0,0 +1,23 @@ +/* + * Testcase for error: + * patchelf: cannot normalize PT_NOTE segment: non-contiguous SHT_NOTE sections + */ +.section ".note.my-section0", "a", @note + .align 4 + .long 1f - 0f /* name length (not including padding) */ + .long 3f - 2f /* desc length (not including padding) */ + .long 1 /* type = NT_VERSION */ +0: .asciz "my-version-12345" /* name */ +1: .align 4 +2: .long 1 /* desc - toolchain version number, 32-bit LE */ +3: .align 4 + +.section ".note.my-section1", "a", @note + .align 8 + .long 1f - 0f /* name length (not including padding) */ + .long 3f - 2f /* desc length (not including padding) */ + .long 1 /* type = NT_VERSION */ +0: .asciz "my-version-1" /* name */ +1: .align 4 +2: .long 1 /* desc - toolchain version number, 32-bit LE */ +3: .align 4 diff --git a/tests/contiguous_note_sections.sh b/tests/contiguous_note_sections.sh new file mode 100755 index 0000000..8bc8f3c --- /dev/null +++ b/tests/contiguous_note_sections.sh @@ -0,0 +1,6 @@ +#! /bin/sh -e + +# Running --set-interpreter on this binary should not produce the following +# error: +# patchelf: cannot normalize PT_NOTE segment: non-contiguous SHT_NOTE sections +../src/patchelf --set-interpreter ld-linux-x86-64.so.2 contiguous_note_sections