0001-binutils-crosssdk-Generate-relocatable-SDKs.patch 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. From a0b23b160d6cfa7be4437c6e623633d76395f2ad Mon Sep 17 00:00:00 2001
  2. From: Khem Raj <raj.khem@gmail.com>
  3. Date: Mon, 2 Mar 2015 01:58:54 +0000
  4. Subject: [PATCH 01/16] binutils-crosssdk: Generate relocatable SDKs
  5. This patch will modify the ELF linker scripts so that the crosssdk
  6. linker will generate binaries with a 4096 bytes PT_INTERP section. When the binaries
  7. will be relocated, at SDK install time, the interpreter path can be easily
  8. changed by the relocating script.
  9. generate larger .interp section for gold linker as well
  10. Upstream-Status: Inappropriate [SDK specific]
  11. Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
  12. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  13. ---
  14. gold/layout.cc | 2 +-
  15. ld/genscripts.sh | 3 +++
  16. ld/scripttempl/elf.sc | 4 ++--
  17. 3 files changed, 6 insertions(+), 3 deletions(-)
  18. diff --git a/gold/layout.cc b/gold/layout.cc
  19. index 13e533aaf21..b0afff16e2e 100644
  20. --- a/gold/layout.cc
  21. +++ b/gold/layout.cc
  22. @@ -5019,7 +5019,7 @@ Layout::create_interp(const Target* target)
  23. gold_assert(interp != NULL);
  24. }
  25. - size_t len = strlen(interp) + 1;
  26. + size_t len = 4096;
  27. Output_section_data* odata = new Output_data_const(interp, len, 1);
  28. diff --git a/ld/genscripts.sh b/ld/genscripts.sh
  29. index 03392d265c7..435689ea144 100755
  30. --- a/ld/genscripts.sh
  31. +++ b/ld/genscripts.sh
  32. @@ -304,6 +304,7 @@ DATA_ALIGNMENT_u="${DATA_ALIGNMENT_u-${DATA_ALIGNMENT_r}}"
  33. LD_FLAG=r
  34. DATA_ALIGNMENT=${DATA_ALIGNMENT_r}
  35. DEFAULT_DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})"
  36. +PARTIAL_LINKING=" "
  37. ( echo "/* Script for -r */"
  38. source_sh ${CUSTOMIZER_SCRIPT}
  39. source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
  40. @@ -312,10 +313,12 @@ DEFAULT_DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})"
  41. LD_FLAG=u
  42. DATA_ALIGNMENT=${DATA_ALIGNMENT_u}
  43. CONSTRUCTING=" "
  44. +PARTIAL_LINKING=" "
  45. ( echo "/* Script for -Ur */"
  46. source_sh ${CUSTOMIZER_SCRIPT}
  47. source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
  48. ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xu
  49. +unset PARTIAL_LINKING
  50. DATA_ALIGNMENT=${DATA_ALIGNMENT_}
  51. RELOCATING=" "
  52. diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
  53. index eb74743e5c3..c9a8a47615f 100644
  54. --- a/ld/scripttempl/elf.sc
  55. +++ b/ld/scripttempl/elf.sc
  56. @@ -143,8 +143,8 @@ if test -z "$DATA_SEGMENT_ALIGN"; then
  57. DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);"
  58. fi
  59. fi
  60. -if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then
  61. - INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }"
  62. +if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}${PARTIAL_LINKING}"; then
  63. + INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp); . = 0x1000; }"
  64. fi
  65. if test -z "$PLT"; then
  66. IPLT=".iplt ${RELOCATING-0} : { *(.iplt) }"
  67. --
  68. 2.28.0