From 0ba27f807d86490d0563d776ec32719262a54bb4 Mon Sep 17 00:00:00 2001 From: Evgeniy Didin Date: Wed, 15 Apr 2020 13:13:19 +0300 Subject: [PATCH] binutils-crosssdk: Generate relocatable SDKs This patch will modify the ELF linker scripts so that the crosssdk linker will generate binaries with a 4096 bytes PT_INTERP section. When the binaries will be relocated, at SDK install time, the interpreter path can be easily changed by the relocating script. Upstream-Status: Inappropriate [SDK specific] Signed-off-by: Laurentiu Palcu Signed-off-by: Khem Raj Signed-off-by: Evgeniy Didin --- ld/genscripts.sh | 3 +++ ld/scripttempl/elf.sc | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ld/genscripts.sh b/ld/genscripts.sh index cb2b081e9e9..db2e9fd569d 100755 --- a/ld/genscripts.sh +++ b/ld/genscripts.sh @@ -325,6 +325,7 @@ DATA_ALIGNMENT_u="${DATA_ALIGNMENT_u-${DATA_ALIGNMENT_r}}" LD_FLAG=r DATA_ALIGNMENT=${DATA_ALIGNMENT_r} DEFAULT_DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})" +PARTIAL_LINKING=" " ( echo "/* Script for ld -r: link without relocation */" source_sh ${CUSTOMIZER_SCRIPT} source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc @@ -333,10 +334,12 @@ DEFAULT_DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})" LD_FLAG=u DATA_ALIGNMENT=${DATA_ALIGNMENT_u} CONSTRUCTING=" " +PARTIAL_LINKING=" " ( echo "/* Script for ld -Ur: link w/out relocation, do create constructors */" source_sh ${CUSTOMIZER_SCRIPT} source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xu +unset PARTIAL_LINKING DATA_ALIGNMENT=${DATA_ALIGNMENT_} RELOCATING=" " diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc index c3ad467bff4..a847ffecc19 100644 --- a/ld/scripttempl/elf.sc +++ b/ld/scripttempl/elf.sc @@ -140,8 +140,8 @@ if test -z "$DATA_SEGMENT_ALIGN"; then DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);" fi fi -if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then - INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }" +if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}${PARTIAL_LINKING}"; then + INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp); . = 0x1000; }" fi if test -z "$PLT"; then IPLT=".iplt ${RELOCATING-0} : { *(.iplt) }" -- 2.16.2