0001-staticpie.diff 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. --- binutils-2.25.1.orig/bfd/elf32-sh.c
  2. +++ binutils-2.25.1/bfd/elf32-sh.c
  3. @@ -3344,7 +3344,7 @@
  4. if (htab->root.dynamic_sections_created)
  5. {
  6. /* Set the contents of the .interp section to the interpreter. */
  7. - if (info->executable)
  8. + if (info->executable && !info->nointerp)
  9. {
  10. s = bfd_get_linker_section (dynobj, ".interp");
  11. BFD_ASSERT (s != NULL);
  12. --- binutils-2.25.1.orig/bfd/elflink.c
  13. +++ binutils-2.25.1/bfd/elflink.c
  14. @@ -206,7 +206,7 @@
  15. /* A dynamically linked executable has a .interp section, but a
  16. shared library does not. */
  17. - if (info->executable)
  18. + if (info->executable && !info->nointerp)
  19. {
  20. s = bfd_make_section_anyway_with_flags (abfd, ".interp",
  21. flags | SEC_READONLY);
  22. @@ -5620,7 +5620,7 @@
  23. bfd_boolean all_defined;
  24. *sinterpptr = bfd_get_linker_section (dynobj, ".interp");
  25. - BFD_ASSERT (*sinterpptr != NULL || !info->executable);
  26. + BFD_ASSERT (*sinterpptr != NULL || !info->executable || info->nointerp);
  27. if (soname != NULL)
  28. {
  29. --- binutils-2.25.1.orig/include/bfdlink.h
  30. +++ binutils-2.25.1/include/bfdlink.h
  31. @@ -426,6 +426,9 @@
  32. /* TRUE if BND prefix in PLT entries is always generated. */
  33. unsigned int bndplt: 1;
  34. + /* TRUE if generation of .interp/PT_INTERP should be suppressed. */
  35. + unsigned int nointerp: 1;
  36. +
  37. /* Char that may appear as the first char of a symbol, but should be
  38. skipped (like symbol_leading_char) when looking up symbols in
  39. wrap_hash. Used by PowerPC Linux for 'dot' symbols. */
  40. --- binutils-2.25.1.orig/ld/ldlex.h
  41. +++ binutils-2.25.1/ld/ldlex.h
  42. @@ -33,6 +33,7 @@
  43. OPTION_DEFSYM,
  44. OPTION_DEMANGLE,
  45. OPTION_DYNAMIC_LINKER,
  46. + OPTION_NO_DYNAMIC_LINKER,
  47. OPTION_SYSROOT,
  48. OPTION_EB,
  49. OPTION_EL,
  50. --- binutils-2.25.1.orig/ld/lexsup.c
  51. +++ binutils-2.25.1/ld/lexsup.c
  52. @@ -138,6 +138,9 @@
  53. { {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
  54. 'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"),
  55. TWO_DASHES },
  56. + { {"no-dynamic-linker", no_argument, NULL, OPTION_NO_DYNAMIC_LINKER},
  57. + '\0', NULL, N_("Produce an executable with no program interpreter header"),
  58. + TWO_DASHES },
  59. { {"library", required_argument, NULL, 'l'},
  60. 'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES },
  61. { {"library-path", required_argument, NULL, 'L'},
  62. @@ -747,6 +750,11 @@
  63. case 'I': /* Used on Solaris. */
  64. case OPTION_DYNAMIC_LINKER:
  65. command_line.interpreter = optarg;
  66. + link_info.nointerp = 0;
  67. + break;
  68. + case OPTION_NO_DYNAMIC_LINKER:
  69. + command_line.interpreter = NULL;
  70. + link_info.nointerp = 1;
  71. break;
  72. case OPTION_SYSROOT:
  73. /* Already handled in ldmain.c. */