Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 1 | From b05f0be13aadf0b26a0b39dfe7daf2c47a300338 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Mon, 2 Mar 2015 01:58:54 +0000 |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 4 | Subject: [PATCH] binutils-crosssdk: Generate relocatable SDKs |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 5 | |
| 6 | This patch will modify the ELF linker scripts so that the crosssdk |
| 7 | linker will generate binaries with a 4096 bytes PT_INTERP section. When the binaries |
| 8 | will be relocated, at SDK install time, the interpreter path can be easily |
| 9 | changed by the relocating script. |
| 10 | |
| 11 | Upstream-Status: Inappropriate [SDK specific] |
| 12 | |
| 13 | Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com> |
| 14 | Signed-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 | |
| 20 | diff --git a/ld/genscripts.sh b/ld/genscripts.sh |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 21 | index 03392d265c..435689ea14 100755 |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 22 | --- a/ld/genscripts.sh |
| 23 | +++ b/ld/genscripts.sh |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 24 | @@ -304,6 +304,7 @@ DATA_ALIGNMENT_u="${DATA_ALIGNMENT_u-${DATA_ALIGNMENT_r}}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 25 | LD_FLAG=r |
| 26 | DATA_ALIGNMENT=${DATA_ALIGNMENT_r} |
| 27 | DEFAULT_DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})" |
| 28 | +PARTIAL_LINKING=" " |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 29 | ( echo "/* Script for -r */" |
| 30 | source_sh ${CUSTOMIZER_SCRIPT} |
| 31 | source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc |
| 32 | @@ -312,10 +313,12 @@ DEFAULT_DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 33 | LD_FLAG=u |
| 34 | DATA_ALIGNMENT=${DATA_ALIGNMENT_u} |
| 35 | CONSTRUCTING=" " |
| 36 | +PARTIAL_LINKING=" " |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 37 | ( echo "/* Script for -Ur */" |
| 38 | source_sh ${CUSTOMIZER_SCRIPT} |
| 39 | source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 40 | ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xu |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 41 | +unset PARTIAL_LINKING |
| 42 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 43 | DATA_ALIGNMENT=${DATA_ALIGNMENT_} |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 44 | RELOCATING=" " |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 45 | diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 46 | index 0b8b32a440..ee6b71075d 100644 |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 47 | --- a/ld/scripttempl/elf.sc |
| 48 | +++ b/ld/scripttempl/elf.sc |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 49 | @@ -140,8 +140,8 @@ if test -z "$DATA_SEGMENT_ALIGN"; then |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 50 | 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) }" |