0017-single-load-segment.patch 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. From: Lukas Schwaighofer <lukas@schwaighofer.name>
  2. Date: Sat, 18 Aug 2018 16:56:35 +0200
  3. Subject: Force the linker to put all sections into a single PT_LOAD segment
  4. This is required when using binutils >= 2.31 which writes two PT_LOAD segments
  5. by default. This is not supported by the wrapper.c script used to convert the
  6. shared object into an elf binary.
  7. Forwarded: https://www.syslinux.org/archives/2018-August/026167.html
  8. ---
  9. efi/i386/syslinux.ld | 37 +++++++++++++++++++++----------------
  10. efi/x86_64/syslinux.ld | 37 +++++++++++++++++++++----------------
  11. 2 files changed, 42 insertions(+), 32 deletions(-)
  12. diff --git a/efi/i386/syslinux.ld b/efi/i386/syslinux.ld
  13. index bab3fc7..19c1647 100644
  14. --- a/efi/i386/syslinux.ld
  15. +++ b/efi/i386/syslinux.ld
  16. @@ -19,6 +19,11 @@ OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
  17. OUTPUT_ARCH(i386)
  18. ENTRY(_start)
  19. +PHDRS
  20. +{
  21. + all PT_LOAD ;
  22. +}
  23. +
  24. SECTIONS
  25. {
  26. . = 0;
  27. @@ -31,7 +36,7 @@ SECTIONS
  28. *(.text)
  29. *(.text.*)
  30. __text_end = .;
  31. - }
  32. + } :all
  33. . = ALIGN(16);
  34. @@ -40,7 +45,7 @@ SECTIONS
  35. *(.rodata)
  36. *(.rodata.*)
  37. __rodata_end = .;
  38. - }
  39. + } :all
  40. . = ALIGN(4);
  41. @@ -49,14 +54,14 @@ SECTIONS
  42. KEEP (*(SORT(.ctors.*)))
  43. KEEP (*(.ctors))
  44. __ctors_end = .;
  45. - }
  46. + } :all
  47. .dtors : {
  48. __dtors_start = .;
  49. KEEP (*(SORT(.dtors.*)))
  50. KEEP (*(.dtors))
  51. __dtors_end = .;
  52. - }
  53. + } :all
  54. . = ALIGN(4096);
  55. .rel : {
  56. @@ -64,7 +69,7 @@ SECTIONS
  57. *(.rel.data)
  58. *(.rel.data.*)
  59. *(.rel.ctors)
  60. - }
  61. + } :all
  62. . = ALIGN(4);
  63. @@ -72,14 +77,14 @@ SECTIONS
  64. __gnu_hash_start = .;
  65. *(.gnu.hash)
  66. __gnu_hash_end = .;
  67. - }
  68. + } :all
  69. .dynsym : {
  70. __dynsym_start = .;
  71. *(.dynsym)
  72. __dynsym_end = .;
  73. - }
  74. + } :all
  75. . = ALIGN(4);
  76. @@ -87,7 +92,7 @@ SECTIONS
  77. __dynstr_start = .;
  78. *(.dynstr)
  79. __dynstr_end = .;
  80. - }
  81. + } :all
  82. . = ALIGN(4);
  83. @@ -104,7 +109,7 @@ SECTIONS
  84. KEEP (*(.got.plt))
  85. KEEP (*(.got))
  86. __got_end = .;
  87. - }
  88. + } :all
  89. . = ALIGN(4);
  90. @@ -112,7 +117,7 @@ SECTIONS
  91. __dynamic_start = .;
  92. *(.dynamic)
  93. __dynamic_end = .;
  94. - }
  95. + } :all
  96. . = ALIGN(16);
  97. @@ -122,19 +127,19 @@ SECTIONS
  98. *(.data.*)
  99. *(.lowmem)
  100. __data_end = .;
  101. - }
  102. + } :all
  103. .reloc : {
  104. *(.reloc)
  105. - }
  106. + } :all
  107. .symtab : {
  108. *(.symtab)
  109. - }
  110. + } :all
  111. .strtab : {
  112. *(.strtab)
  113. - }
  114. + } :all
  115. .bss (NOLOAD) : {
  116. /* the EFI loader doesn't seem to like a .bss section,
  117. @@ -148,7 +153,7 @@ SECTIONS
  118. __bss_end = .;
  119. *(.sbss)
  120. *(.scommon)
  121. - }
  122. + } :all
  123. __bss_len = ABSOLUTE(__bss_end) - ABSOLUTE(__bss_start);
  124. __bss_dwords = (__bss_len + 3) >> 2;
  125. @@ -161,7 +166,7 @@ SECTIONS
  126. *(.hugebss)
  127. *(.hugebss.*)
  128. __hugebss_end = .;
  129. - }
  130. + } :all
  131. _end = .;
  132. diff --git a/efi/x86_64/syslinux.ld b/efi/x86_64/syslinux.ld
  133. index 450641c..a2c124f 100644
  134. --- a/efi/x86_64/syslinux.ld
  135. +++ b/efi/x86_64/syslinux.ld
  136. @@ -19,6 +19,11 @@ OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
  137. OUTPUT_ARCH(i386:x86-64)
  138. ENTRY(_start)
  139. +PHDRS
  140. +{
  141. + all PT_LOAD ;
  142. +}
  143. +
  144. SECTIONS
  145. {
  146. . = 0;
  147. @@ -31,7 +36,7 @@ SECTIONS
  148. *(.text)
  149. *(.text.*)
  150. __text_end = .;
  151. - }
  152. + } :all
  153. . = ALIGN(16);
  154. @@ -40,7 +45,7 @@ SECTIONS
  155. *(.rodata)
  156. *(.rodata.*)
  157. __rodata_end = .;
  158. - }
  159. + } :all
  160. . = ALIGN(4);
  161. @@ -49,14 +54,14 @@ SECTIONS
  162. KEEP (*(SORT(.ctors.*)))
  163. KEEP (*(.ctors))
  164. __ctors_end = .;
  165. - }
  166. + } :all
  167. .dtors : {
  168. __dtors_start = .;
  169. KEEP (*(SORT(.dtors.*)))
  170. KEEP (*(.dtors))
  171. __dtors_end = .;
  172. - }
  173. + } :all
  174. . = ALIGN(4096);
  175. .rel : {
  176. @@ -64,7 +69,7 @@ SECTIONS
  177. *(.rel.data)
  178. *(.rel.data.*)
  179. *(.rel.ctors)
  180. - }
  181. + } :all
  182. . = ALIGN(4);
  183. @@ -72,14 +77,14 @@ SECTIONS
  184. __gnu_hash_start = .;
  185. *(.gnu.hash)
  186. __gnu_hash_end = .;
  187. - }
  188. + } :all
  189. .dynsym : {
  190. __dynsym_start = .;
  191. *(.dynsym)
  192. __dynsym_end = .;
  193. - }
  194. + } :all
  195. . = ALIGN(4);
  196. @@ -87,7 +92,7 @@ SECTIONS
  197. __dynstr_start = .;
  198. *(.dynstr)
  199. __dynstr_end = .;
  200. - }
  201. + } :all
  202. . = ALIGN(4);
  203. @@ -104,7 +109,7 @@ SECTIONS
  204. KEEP (*(.got.plt))
  205. KEEP (*(.got))
  206. __got_end = .;
  207. - }
  208. + } :all
  209. . = ALIGN(4);
  210. @@ -112,7 +117,7 @@ SECTIONS
  211. __dynamic_start = .;
  212. *(.dynamic)
  213. __dynamic_end = .;
  214. - }
  215. + } :all
  216. . = ALIGN(16);
  217. @@ -122,19 +127,19 @@ SECTIONS
  218. *(.data.*)
  219. *(.lowmem)
  220. __data_end = .;
  221. - }
  222. + } :all
  223. .reloc : {
  224. *(.reloc)
  225. - }
  226. + } :all
  227. .symtab : {
  228. *(.symtab)
  229. - }
  230. + } :all
  231. .strtab : {
  232. *(.strtab)
  233. - }
  234. + } :all
  235. .bss (NOLOAD) : {
  236. /* the EFI loader doesn't seem to like a .bss section,
  237. @@ -148,7 +153,7 @@ SECTIONS
  238. __bss_end = .;
  239. *(.sbss)
  240. *(.scommon)
  241. - }
  242. + } :all
  243. __bss_len = ABSOLUTE(__bss_end) - ABSOLUTE(__bss_start);
  244. __bss_dwords = (__bss_len + 3) >> 2;
  245. @@ -161,7 +166,7 @@ SECTIONS
  246. *(.hugebss)
  247. *(.hugebss.*)
  248. __hugebss_end = .;
  249. - }
  250. + } :all
  251. _end = .;