blob: 6581bad119c4a3c94a9fd18186037f018f01ceb9 [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001From 5bcd884f8af5106d0fa380c42cffe07f3c993ed2 Mon Sep 17 00:00:00 2001
Brad Bishop6e60e8b2018-02-01 10:27:11 -05002From: Khem Raj <raj.khem@gmail.com>
3Date: Mon, 2 Mar 2015 01:58:54 +0000
4Subject: [PATCH 01/15] binutils-crosssdk: Generate relocatable SDKs
5
6This patch will modify the ELF linker scripts so that the crosssdk
7linker will generate binaries with a 4096 bytes PT_INTERP section. When the binaries
8will be relocated, at SDK install time, the interpreter path can be easily
9changed by the relocating script.
10
11Upstream-Status: Inappropriate [SDK specific]
12
13Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
14Signed-off-by: Khem Raj <raj.khem@gmail.com>
15---
16 ld/genscripts.sh | 3 +++
17 ld/scripttempl/elf.sc | 4 ++--
18 2 files changed, 5 insertions(+), 2 deletions(-)
19
20diff --git a/ld/genscripts.sh b/ld/genscripts.sh
Brad Bishop19323692019-04-05 15:28:33 -040021index 77ddbbc8f8..d789e77943 100755
Brad Bishop6e60e8b2018-02-01 10:27:11 -050022--- a/ld/genscripts.sh
23+++ b/ld/genscripts.sh
Brad Bishop19323692019-04-05 15:28:33 -040024@@ -310,6 +310,7 @@ DATA_ALIGNMENT_u="${DATA_ALIGNMENT_u-${DATA_ALIGNMENT_r}}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050025 LD_FLAG=r
26 DATA_ALIGNMENT=${DATA_ALIGNMENT_r}
27 DEFAULT_DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})"
28+PARTIAL_LINKING=" "
29 ( echo "/* Script for ld -r: link without relocation */"
30 . ${CUSTOMIZER_SCRIPT}
31 . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
Brad Bishop19323692019-04-05 15:28:33 -040032@@ -318,10 +319,12 @@ DEFAULT_DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050033 LD_FLAG=u
34 DATA_ALIGNMENT=${DATA_ALIGNMENT_u}
35 CONSTRUCTING=" "
36+PARTIAL_LINKING=" "
37 ( echo "/* Script for ld -Ur: link w/out relocation, do create constructors */"
38 . ${CUSTOMIZER_SCRIPT}
39 . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
Brad Bishop316dfdd2018-06-25 12:45:53 -040040 ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xu
Brad Bishop6e60e8b2018-02-01 10:27:11 -050041+unset PARTIAL_LINKING
42
Brad Bishop6e60e8b2018-02-01 10:27:11 -050043 DATA_ALIGNMENT=${DATA_ALIGNMENT_}
Brad Bishop316dfdd2018-06-25 12:45:53 -040044 RELOCATING=" "
Brad Bishop6e60e8b2018-02-01 10:27:11 -050045diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
Brad Bishop19323692019-04-05 15:28:33 -040046index bd7584120e..8bbe052d4b 100644
Brad Bishop6e60e8b2018-02-01 10:27:11 -050047--- a/ld/scripttempl/elf.sc
48+++ b/ld/scripttempl/elf.sc
Brad Bishop316dfdd2018-06-25 12:45:53 -040049@@ -139,8 +139,8 @@ if test -z "$DATA_SEGMENT_ALIGN"; then
Brad Bishop6e60e8b2018-02-01 10:27:11 -050050 DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);"
51 fi
52 fi
53-if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then
54- INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }"
55+if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}${PARTIAL_LINKING}"; then
56+ INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp); . = 0x1000; }"
57 fi
58 if test -z "$PLT"; then
59 IPLT=".iplt ${RELOCATING-0} : { *(.iplt) }"
60--
Brad Bishop19323692019-04-05 15:28:33 -0400612.20.1
Brad Bishop6e60e8b2018-02-01 10:27:11 -050062