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
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
9 changes: 7 additions & 2 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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)
Expand Down Expand Up @@ -106,3 +107,7 @@ 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.ld
contiguous_note_sections_LDFLAGS = -nostdlib -T contiguous_note_sections.ld
contiguous_note_sections_CFLAGS = -pie
24 changes: 24 additions & 0 deletions tests/contiguous_note_sections.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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;
. = ALIGN(4);

.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
}
23 changes: 23 additions & 0 deletions tests/contiguous_note_sections.s
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions tests/contiguous_note_sections.sh
Original file line number Diff line number Diff line change
@@ -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