mirror of
https://github.com/NixOS/patchelf.git
synced 2025-10-19 02:23:15 +08:00
Merge pull request #289 from ovpanait/master
tests: add testcase for alignment issues with contiguous note sections
This commit is contained in:
@@ -6,6 +6,7 @@ AM_INIT_AUTOMAKE([1.11.1 -Wall -Werror dist-bzip2 foreign color-tests parallel-t
|
|||||||
|
|
||||||
AM_PROG_CC_C_O
|
AM_PROG_CC_C_O
|
||||||
AC_PROG_CXX
|
AC_PROG_CXX
|
||||||
|
AM_PROG_AS
|
||||||
|
|
||||||
DEFAULT_PAGESIZE=auto
|
DEFAULT_PAGESIZE=auto
|
||||||
AC_ARG_WITH([page-size],
|
AC_ARG_WITH([page-size],
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
LIBS =
|
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_arch_TESTS = \
|
||||||
no-rpath-amd64.sh \
|
no-rpath-amd64.sh \
|
||||||
@@ -27,7 +27,8 @@ src_TESTS = \
|
|||||||
output-flag.sh \
|
output-flag.sh \
|
||||||
no-rpath-pie-powerpc.sh \
|
no-rpath-pie-powerpc.sh \
|
||||||
build-id.sh \
|
build-id.sh \
|
||||||
invalid-elf.sh
|
invalid-elf.sh \
|
||||||
|
contiguous_note_sections.sh
|
||||||
|
|
||||||
build_TESTS = \
|
build_TESTS = \
|
||||||
$(no_rpath_arch_TESTS)
|
$(no_rpath_arch_TESTS)
|
||||||
@@ -106,3 +107,6 @@ libsimple_so_LDFLAGS = $(LDFLAGS_sharedlib)
|
|||||||
no_rpath_SOURCES = no-rpath.c
|
no_rpath_SOURCES = no-rpath.c
|
||||||
# no -fpic for no-rpath.o
|
# no -fpic for no-rpath.o
|
||||||
no_rpath_CFLAGS =
|
no_rpath_CFLAGS =
|
||||||
|
|
||||||
|
contiguous_note_sections_SOURCES = contiguous_note_sections.s
|
||||||
|
contiguous_note_sections_CFLAGS = -nostdlib -T contiguous_note_sections.ld
|
||||||
|
22
tests/contiguous_note_sections.ld
Normal file
22
tests/contiguous_note_sections.ld
Normal file
@@ -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
|
||||||
|
}
|
23
tests/contiguous_note_sections.s
Normal file
23
tests/contiguous_note_sections.s
Normal file
@@ -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
tests/contiguous_note_sections.sh
Executable file
6
tests/contiguous_note_sections.sh
Executable file
@@ -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
|
Reference in New Issue
Block a user