dont-guess-alignment.patch 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. From 0cc9a99e560a2f52bcf052fd85b1efae35ee812f Mon Sep 17 00:00:00 2001
  2. From: Sylvain Gault <sylvain.gault@gmail.com>
  3. Date: Tue, 29 Sep 2015 04:45:09 +0200
  4. Subject: [PATCH 1/1] bios: Don't try to guess the sections alignment
  5. For the compression / decompression to succeed, the sections layout must
  6. be the same between the virtual memory and load memory. The section
  7. alignment was kept in sync by introducing aligment that should be
  8. greater or equal to the actual section alignment.
  9. This patch compute the load memory addresses of the sections so that
  10. the layout is the same as the virtual memory addresses.
  11. Signed-off-by: Sylvain Gault <sylvain.gault@gmail.com>
  12. Tested-by: poma <pomidorabelisima@gmail.com>
  13. Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
  14. ---
  15. core/i386/syslinux.ld | 63 ++++++++++---------------------------------------
  16. core/x86_64/syslinux.ld | 63 ++++++++++---------------------------------------
  17. 2 files changed, 24 insertions(+), 102 deletions(-)
  18. diff --git a/core/i386/syslinux.ld b/core/i386/syslinux.ld
  19. index 7390451..92b75b1 100644
  20. --- a/core/i386/syslinux.ld
  21. +++ b/core/i386/syslinux.ld
  22. @@ -255,10 +255,9 @@ SECTIONS
  23. . = 0x100000;
  24. __pm_code_start = .;
  25. + __vma_to_lma = __pm_code_lma - __pm_code_start;
  26. - __text_vma = .;
  27. - __text_lma = __pm_code_lma;
  28. - .text : AT(__text_lma) {
  29. + .text : AT(ADDR(.text) + __vma_to_lma) {
  30. FILL(0x90909090)
  31. __text_start = .;
  32. *(.text)
  33. @@ -266,106 +265,68 @@ SECTIONS
  34. __text_end = .;
  35. }
  36. - . = ALIGN(32);
  37. -
  38. - __rodata_vma = .;
  39. - __rodata_lma = __rodata_vma + __text_lma - __text_vma;
  40. - .rodata : AT(__rodata_lma) {
  41. + .rodata : AT(ADDR(.rodata) + __vma_to_lma) {
  42. __rodata_start = .;
  43. *(.rodata)
  44. *(.rodata.*)
  45. __rodata_end = .;
  46. }
  47. - . = ALIGN(4);
  48. -
  49. - __ctors_vma = .;
  50. - __ctors_lma = __ctors_vma + __text_lma - __text_vma;
  51. - .ctors : AT(__ctors_lma) {
  52. + .ctors : AT(ADDR(.ctors) + __vma_to_lma) {
  53. __ctors_start = .;
  54. KEEP (*(SORT(.ctors.*)))
  55. KEEP (*(.ctors))
  56. __ctors_end = .;
  57. }
  58. - __dtors_vma = .;
  59. - __dtors_lma = __dtors_vma + __text_lma - __text_vma;
  60. - .dtors : AT(__dtors_lma) {
  61. + .dtors : AT(ADDR(.dtors) + __vma_to_lma) {
  62. __dtors_start = .;
  63. KEEP (*(SORT(.dtors.*)))
  64. KEEP (*(.dtors))
  65. __dtors_end = .;
  66. }
  67. - . = ALIGN(4);
  68. -
  69. - __dynsym_vma = .;
  70. - __dynsym_lma = __dynsym_vma + __text_lma - __text_vma;
  71. - .dynsym : AT(__dynsym_lma) {
  72. + .dynsym : AT(ADDR(.dynsym) + __vma_to_lma) {
  73. __dynsym_start = .;
  74. *(.dynsym)
  75. __dynsym_end = .;
  76. }
  77. __dynsym_len = __dynsym_end - __dynsym_start;
  78. - . = ALIGN(4);
  79. -
  80. - __dynstr_vma = .;
  81. - __dynstr_lma = __dynstr_vma + __text_lma - __text_vma;
  82. - .dynstr : AT(__dynstr_lma) {
  83. + .dynstr : AT(ADDR(.dynstr) + __vma_to_lma) {
  84. __dynstr_start = .;
  85. *(.dynstr)
  86. __dynstr_end = .;
  87. }
  88. __dynstr_len = __dynstr_end - __dynstr_start;
  89. - . = ALIGN(4);
  90. -
  91. - __gnu_hash_vma = .;
  92. - __gnu_hash_lma = __gnu_hash_vma + __text_lma - __text_vma;
  93. - .gnu.hash : AT(__gnu_hash_lma) {
  94. + .gnu.hash : AT(ADDR(.gnu.hash) + __vma_to_lma) {
  95. __gnu_hash_start = .;
  96. *(.gnu.hash)
  97. __gnu_hash_end = .;
  98. }
  99. - . = ALIGN(4);
  100. -
  101. - __dynlink_vma = .;
  102. - __dynlink_lma = __dynlink_vma + __text_lma - __text_vma;
  103. - .dynlink : AT(__dynlink_lma) {
  104. + .dynlink : AT(ADDR(.dynlink) + __vma_to_lma) {
  105. __dynlink_start = .;
  106. *(.dynlink)
  107. __dynlink_end = .;
  108. }
  109. - . = ALIGN(4);
  110. -
  111. - __got_vma = .;
  112. - __got_lma = __got_vma + __text_lma - __text_vma;
  113. - .got : AT(__got_lma) {
  114. + .got : AT(ADDR(.got) + __vma_to_lma) {
  115. __got_start = .;
  116. KEEP (*(.got.plt))
  117. KEEP (*(.got))
  118. __got_end = .;
  119. }
  120. - . = ALIGN(4);
  121. -
  122. - __dynamic_vma = .;
  123. - __dynamic_lma = __dynamic_vma + __text_lma - __text_vma;
  124. - .dynamic : AT(__dynamic_lma) {
  125. + .dynamic : AT(ADDR(.dynamic) + __vma_to_lma) {
  126. __dynamic_start = .;
  127. *(.dynamic)
  128. __dynamic_end = .;
  129. }
  130. - . = ALIGN(32);
  131. -
  132. - __data_vma = .;
  133. - __data_lma = __data_vma + __text_lma - __text_vma;
  134. - .data : AT(__data_lma) {
  135. + .data : AT(ADDR(.data) + __vma_to_lma) {
  136. __data_start = .;
  137. *(.data)
  138. *(.data.*)
  139. diff --git a/core/x86_64/syslinux.ld b/core/x86_64/syslinux.ld
  140. index bf815c4..70c6e00 100644
  141. --- a/core/x86_64/syslinux.ld
  142. +++ b/core/x86_64/syslinux.ld
  143. @@ -255,10 +255,9 @@ SECTIONS
  144. . = 0x100000;
  145. __pm_code_start = .;
  146. + __vma_to_lma = __pm_code_lma - __pm_code_start;
  147. - __text_vma = .;
  148. - __text_lma = __pm_code_lma;
  149. - .text : AT(__text_lma) {
  150. + .text : AT(ADDR(.text) + __vma_to_lma) {
  151. FILL(0x90909090)
  152. __text_start = .;
  153. *(.text)
  154. @@ -266,106 +265,68 @@ SECTIONS
  155. __text_end = .;
  156. }
  157. - . = ALIGN(32);
  158. -
  159. - __rodata_vma = .;
  160. - __rodata_lma = __rodata_vma + __text_lma - __text_vma;
  161. - .rodata : AT(__rodata_lma) {
  162. + .rodata : AT(ADDR(.rodata) + __vma_to_lma) {
  163. __rodata_start = .;
  164. *(.rodata)
  165. *(.rodata.*)
  166. __rodata_end = .;
  167. }
  168. - . = ALIGN(4);
  169. -
  170. - __ctors_vma = .;
  171. - __ctors_lma = __ctors_vma + __text_lma - __text_vma;
  172. - .ctors : AT(__ctors_lma) {
  173. + .ctors : AT(ADDR(.ctors) + __vma_to_lma) {
  174. __ctors_start = .;
  175. KEEP (*(SORT(.ctors.*)))
  176. KEEP (*(.ctors))
  177. __ctors_end = .;
  178. }
  179. - __dtors_vma = .;
  180. - __dtors_lma = __dtors_vma + __text_lma - __text_vma;
  181. - .dtors : AT(__dtors_lma) {
  182. + .dtors : AT(ADDR(.dtors) + __vma_to_lma) {
  183. __dtors_start = .;
  184. KEEP (*(SORT(.dtors.*)))
  185. KEEP (*(.dtors))
  186. __dtors_end = .;
  187. }
  188. - . = ALIGN(4);
  189. -
  190. - __dynsym_vma = .;
  191. - __dynsym_lma = __dynsym_vma + __text_lma - __text_vma;
  192. - .dynsym : AT(__dynsym_lma) {
  193. + .dynsym : AT(ADDR(.dynsym) + __vma_to_lma) {
  194. __dynsym_start = .;
  195. *(.dynsym)
  196. __dynsym_end = .;
  197. }
  198. __dynsym_len = __dynsym_end - __dynsym_start;
  199. - . = ALIGN(4);
  200. -
  201. - __dynstr_vma = .;
  202. - __dynstr_lma = __dynstr_vma + __text_lma - __text_vma;
  203. - .dynstr : AT(__dynstr_lma) {
  204. + .dynstr : AT(ADDR(.dynstr) + __vma_to_lma) {
  205. __dynstr_start = .;
  206. *(.dynstr)
  207. __dynstr_end = .;
  208. }
  209. __dynstr_len = __dynstr_end - __dynstr_start;
  210. - . = ALIGN(4);
  211. -
  212. - __gnu_hash_vma = .;
  213. - __gnu_hash_lma = __gnu_hash_vma + __text_lma - __text_vma;
  214. - .gnu.hash : AT(__gnu_hash_lma) {
  215. + .gnu.hash : AT(ADDR(.gnu.hash) + __vma_to_lma) {
  216. __gnu_hash_start = .;
  217. *(.gnu.hash)
  218. __gnu_hash_end = .;
  219. }
  220. - . = ALIGN(4);
  221. -
  222. - __dynlink_vma = .;
  223. - __dynlink_lma = __dynlink_vma + __text_lma - __text_vma;
  224. - .dynlink : AT(__dynlink_lma) {
  225. + .dynlink : AT(ADDR(.dynlink) + __vma_to_lma) {
  226. __dynlink_start = .;
  227. *(.dynlink)
  228. __dynlink_end = .;
  229. }
  230. - . = ALIGN(4);
  231. -
  232. - __got_vma = .;
  233. - __got_lma = __got_vma + __text_lma - __text_vma;
  234. - .got : AT(__got_lma) {
  235. + .got : AT(ADDR(.got) + __vma_to_lma) {
  236. __got_start = .;
  237. KEEP (*(.got.plt))
  238. KEEP (*(.got))
  239. __got_end = .;
  240. }
  241. - . = ALIGN(4);
  242. -
  243. - __dynamic_vma = .;
  244. - __dynamic_lma = __dynamic_vma + __text_lma - __text_vma;
  245. - .dynamic : AT(__dynamic_lma) {
  246. + .dynamic : AT(ADDR(.dynamic) + __vma_to_lma) {
  247. __dynamic_start = .;
  248. *(.dynamic)
  249. __dynamic_end = .;
  250. }
  251. - . = ALIGN(32);
  252. -
  253. - __data_vma = .;
  254. - __data_lma = __data_vma + __text_lma - __text_vma;
  255. - .data : AT(__data_lma) {
  256. + .data : AT(ADDR(.data) + __vma_to_lma) {
  257. __data_start = .;
  258. *(.data)
  259. *(.data.*)
  260. --
  261. 2.5.5.GIT