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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. From 257ad1ce148417e1cefe2332d8acc5c8216c2522 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] 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 a27cb071c75..32b52890b39 100644
  20. --- a/gold/layout.cc
  21. +++ b/gold/layout.cc
  22. @@ -5032,7 +5032,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 088417ef2d5..46a2db7005c 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 29a8f0781d5..75e46f4adaf 100644
  54. --- a/ld/scripttempl/elf.sc
  55. +++ b/ld/scripttempl/elf.sc
  56. @@ -147,8 +147,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) }"