From: Sylvain Gault <sylvain.gault at gmail.com> TL;DR: The section aligment in linker scripts messed-up the memory mapping needed for the compression / decompression to work. The bug with gcc 5 is not trivial, I'll do my best to explain it here. Basically, there are two memory mappings of the code. One in "virtual memory", and one in "load memory". The one in virtual memory may use the 4G of address space, while the one in "load memory" is more compact. The "load memory" mapping is actually used in syslinux to compress most of the code. The early stages of syslinux decompress the code at the correct virtual address. So both mappings must have the same data layout. The matching between both mappings is done through the ld script by specifying the LMA (load memory address) which is computed from on the VMA (virtual memory address). However, the way the LMA was computed included adding symbols just before the sections to get the VMA. Since the sections are aligned (depending on the alignment of its content), those symbols had to be aligned by hand to avoid to leave a gap. With gcc 5, the .data and .rodata sections got sometime a larger alignment (up to 32 bytes), which is greater than the 16 bytes that were recorded in the linker script. Thus introducing a gap between the real section's VMA and its assumed VMA. The first of these two patches just fix the aligment. The second remove the hand-alignment and compute the LMA of the sections so that the mappings will always match regardless of the aligment the sections need. On a side 2 questions: - Is core/syslinux.ld is still used? it looks like a forgotten file. - Is there really a bios version for x86_64? Looks like the boot files are i386-specific. Tests and comments are welcome. Sylvain Gault core/i386/syslinux.ld | 65 ++++++++++--------------------------------------- core/x86_64/syslinux.ld | 65 ++++++++++--------------------------------------- 2 files changed, 26 insertions(+), 104 deletions(-) -- 2.5.3
celelibi at gmail.com
2015-Sep-29 04:46 UTC
[syslinux] [PATCH 1/2] bios: Fix alignment change with gcc 5
From: Sylvain Gault <sylvain.gault at gmail.com> The section aligment specified in the ld scripts have to be greater or equal to those in the .o files generated by gcc. Signed-off-by: Sylvain Gault <sylvain.gault at gmail.com> --- core/i386/syslinux.ld | 6 +++--- core/x86_64/syslinux.ld | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/i386/syslinux.ld b/core/i386/syslinux.ld index 7b4e012..7390451 100644 --- a/core/i386/syslinux.ld +++ b/core/i386/syslinux.ld @@ -266,7 +266,7 @@ SECTIONS __text_end = .; } - . = ALIGN(16); + . = ALIGN(32); __rodata_vma = .; __rodata_lma = __rodata_vma + __text_lma - __text_vma; @@ -361,7 +361,7 @@ SECTIONS __dynamic_end = .; } - . = ALIGN(16); + . = ALIGN(32); __data_vma = .; __data_lma = __data_vma + __text_lma - __text_vma; @@ -377,7 +377,7 @@ SECTIONS __pm_code_dwords = (__pm_code_len + 3) >> 2; . = ALIGN(128); - + __bss_vma = .; __bss_lma = .; /* Dummy */ .bss (NOLOAD) : AT (__bss_lma) { diff --git a/core/x86_64/syslinux.ld b/core/x86_64/syslinux.ld index 1057112..bf815c4 100644 --- a/core/x86_64/syslinux.ld +++ b/core/x86_64/syslinux.ld @@ -266,7 +266,7 @@ SECTIONS __text_end = .; } - . = ALIGN(16); + . = ALIGN(32); __rodata_vma = .; __rodata_lma = __rodata_vma + __text_lma - __text_vma; @@ -361,7 +361,7 @@ SECTIONS __dynamic_end = .; } - . = ALIGN(16); + . = ALIGN(32); __data_vma = .; __data_lma = __data_vma + __text_lma - __text_vma; @@ -377,7 +377,7 @@ SECTIONS __pm_code_dwords = (__pm_code_len + 3) >> 2; . = ALIGN(128); - + __bss_vma = .; __bss_lma = .; /* Dummy */ .bss (NOLOAD) : AT (__bss_lma) { -- 2.5.3
celelibi at gmail.com
2015-Sep-29 04:46 UTC
[syslinux] [PATCH 2/2] bios: Don't try to guess the sections alignment
From: Sylvain Gault <sylvain.gault at gmail.com> For the compression / decompression to succeed, the sections layout must be the same between the virtual memory and load memory. The section alignment was kept in sync by introducing aligment that should be greater or equal to the actual section alignment. This patch compute the load memory addresses of the sections so that the layout is the same as the virtual memory addresses. Signed-off-by: Sylvain Gault <sylvain.gault at gmail.com> --- core/i386/syslinux.ld | 63 ++++++++++--------------------------------------- core/x86_64/syslinux.ld | 63 ++++++++++--------------------------------------- 2 files changed, 24 insertions(+), 102 deletions(-) diff --git a/core/i386/syslinux.ld b/core/i386/syslinux.ld index 7390451..92b75b1 100644 --- a/core/i386/syslinux.ld +++ b/core/i386/syslinux.ld @@ -255,10 +255,9 @@ SECTIONS . = 0x100000; __pm_code_start = .; + __vma_to_lma = __pm_code_lma - __pm_code_start; - __text_vma = .; - __text_lma = __pm_code_lma; - .text : AT(__text_lma) { + .text : AT(ADDR(.text) + __vma_to_lma) { FILL(0x90909090) __text_start = .; *(.text) @@ -266,106 +265,68 @@ SECTIONS __text_end = .; } - . = ALIGN(32); - - __rodata_vma = .; - __rodata_lma = __rodata_vma + __text_lma - __text_vma; - .rodata : AT(__rodata_lma) { + .rodata : AT(ADDR(.rodata) + __vma_to_lma) { __rodata_start = .; *(.rodata) *(.rodata.*) __rodata_end = .; } - . = ALIGN(4); - - __ctors_vma = .; - __ctors_lma = __ctors_vma + __text_lma - __text_vma; - .ctors : AT(__ctors_lma) { + .ctors : AT(ADDR(.ctors) + __vma_to_lma) { __ctors_start = .; KEEP (*(SORT(.ctors.*))) KEEP (*(.ctors)) __ctors_end = .; } - __dtors_vma = .; - __dtors_lma = __dtors_vma + __text_lma - __text_vma; - .dtors : AT(__dtors_lma) { + .dtors : AT(ADDR(.dtors) + __vma_to_lma) { __dtors_start = .; KEEP (*(SORT(.dtors.*))) KEEP (*(.dtors)) __dtors_end = .; } - . = ALIGN(4); - - __dynsym_vma = .; - __dynsym_lma = __dynsym_vma + __text_lma - __text_vma; - .dynsym : AT(__dynsym_lma) { + .dynsym : AT(ADDR(.dynsym) + __vma_to_lma) { __dynsym_start = .; *(.dynsym) __dynsym_end = .; } __dynsym_len = __dynsym_end - __dynsym_start; - . = ALIGN(4); - - __dynstr_vma = .; - __dynstr_lma = __dynstr_vma + __text_lma - __text_vma; - .dynstr : AT(__dynstr_lma) { + .dynstr : AT(ADDR(.dynstr) + __vma_to_lma) { __dynstr_start = .; *(.dynstr) __dynstr_end = .; } __dynstr_len = __dynstr_end - __dynstr_start; - . = ALIGN(4); - - __gnu_hash_vma = .; - __gnu_hash_lma = __gnu_hash_vma + __text_lma - __text_vma; - .gnu.hash : AT(__gnu_hash_lma) { + .gnu.hash : AT(ADDR(.gnu.hash) + __vma_to_lma) { __gnu_hash_start = .; *(.gnu.hash) __gnu_hash_end = .; } - . = ALIGN(4); - - __dynlink_vma = .; - __dynlink_lma = __dynlink_vma + __text_lma - __text_vma; - .dynlink : AT(__dynlink_lma) { + .dynlink : AT(ADDR(.dynlink) + __vma_to_lma) { __dynlink_start = .; *(.dynlink) __dynlink_end = .; } - . = ALIGN(4); - - __got_vma = .; - __got_lma = __got_vma + __text_lma - __text_vma; - .got : AT(__got_lma) { + .got : AT(ADDR(.got) + __vma_to_lma) { __got_start = .; KEEP (*(.got.plt)) KEEP (*(.got)) __got_end = .; } - . = ALIGN(4); - - __dynamic_vma = .; - __dynamic_lma = __dynamic_vma + __text_lma - __text_vma; - .dynamic : AT(__dynamic_lma) { + .dynamic : AT(ADDR(.dynamic) + __vma_to_lma) { __dynamic_start = .; *(.dynamic) __dynamic_end = .; } - . = ALIGN(32); - - __data_vma = .; - __data_lma = __data_vma + __text_lma - __text_vma; - .data : AT(__data_lma) { + .data : AT(ADDR(.data) + __vma_to_lma) { __data_start = .; *(.data) *(.data.*) diff --git a/core/x86_64/syslinux.ld b/core/x86_64/syslinux.ld index bf815c4..70c6e00 100644 --- a/core/x86_64/syslinux.ld +++ b/core/x86_64/syslinux.ld @@ -255,10 +255,9 @@ SECTIONS . = 0x100000; __pm_code_start = .; + __vma_to_lma = __pm_code_lma - __pm_code_start; - __text_vma = .; - __text_lma = __pm_code_lma; - .text : AT(__text_lma) { + .text : AT(ADDR(.text) + __vma_to_lma) { FILL(0x90909090) __text_start = .; *(.text) @@ -266,106 +265,68 @@ SECTIONS __text_end = .; } - . = ALIGN(32); - - __rodata_vma = .; - __rodata_lma = __rodata_vma + __text_lma - __text_vma; - .rodata : AT(__rodata_lma) { + .rodata : AT(ADDR(.rodata) + __vma_to_lma) { __rodata_start = .; *(.rodata) *(.rodata.*) __rodata_end = .; } - . = ALIGN(4); - - __ctors_vma = .; - __ctors_lma = __ctors_vma + __text_lma - __text_vma; - .ctors : AT(__ctors_lma) { + .ctors : AT(ADDR(.ctors) + __vma_to_lma) { __ctors_start = .; KEEP (*(SORT(.ctors.*))) KEEP (*(.ctors)) __ctors_end = .; } - __dtors_vma = .; - __dtors_lma = __dtors_vma + __text_lma - __text_vma; - .dtors : AT(__dtors_lma) { + .dtors : AT(ADDR(.dtors) + __vma_to_lma) { __dtors_start = .; KEEP (*(SORT(.dtors.*))) KEEP (*(.dtors)) __dtors_end = .; } - . = ALIGN(4); - - __dynsym_vma = .; - __dynsym_lma = __dynsym_vma + __text_lma - __text_vma; - .dynsym : AT(__dynsym_lma) { + .dynsym : AT(ADDR(.dynsym) + __vma_to_lma) { __dynsym_start = .; *(.dynsym) __dynsym_end = .; } __dynsym_len = __dynsym_end - __dynsym_start; - . = ALIGN(4); - - __dynstr_vma = .; - __dynstr_lma = __dynstr_vma + __text_lma - __text_vma; - .dynstr : AT(__dynstr_lma) { + .dynstr : AT(ADDR(.dynstr) + __vma_to_lma) { __dynstr_start = .; *(.dynstr) __dynstr_end = .; } __dynstr_len = __dynstr_end - __dynstr_start; - . = ALIGN(4); - - __gnu_hash_vma = .; - __gnu_hash_lma = __gnu_hash_vma + __text_lma - __text_vma; - .gnu.hash : AT(__gnu_hash_lma) { + .gnu.hash : AT(ADDR(.gnu.hash) + __vma_to_lma) { __gnu_hash_start = .; *(.gnu.hash) __gnu_hash_end = .; } - . = ALIGN(4); - - __dynlink_vma = .; - __dynlink_lma = __dynlink_vma + __text_lma - __text_vma; - .dynlink : AT(__dynlink_lma) { + .dynlink : AT(ADDR(.dynlink) + __vma_to_lma) { __dynlink_start = .; *(.dynlink) __dynlink_end = .; } - . = ALIGN(4); - - __got_vma = .; - __got_lma = __got_vma + __text_lma - __text_vma; - .got : AT(__got_lma) { + .got : AT(ADDR(.got) + __vma_to_lma) { __got_start = .; KEEP (*(.got.plt)) KEEP (*(.got)) __got_end = .; } - . = ALIGN(4); - - __dynamic_vma = .; - __dynamic_lma = __dynamic_vma + __text_lma - __text_vma; - .dynamic : AT(__dynamic_lma) { + .dynamic : AT(ADDR(.dynamic) + __vma_to_lma) { __dynamic_start = .; *(.dynamic) __dynamic_end = .; } - . = ALIGN(32); - - __data_vma = .; - __data_lma = __data_vma + __text_lma - __text_vma; - .data : AT(__data_lma) { + .data : AT(ADDR(.data) + __vma_to_lma) { __data_start = .; *(.data) *(.data.*) -- 2.5.3
On Tue, Sep 29, 2015 at 12:46 AM, celelibi--- via Syslinux <syslinux at zytor.com> wrote:> From: Sylvain Gault <sylvain.gault at gmail.com> > > TL;DR: The section aligment in linker scripts messed-up the memory mapping > needed for the compression / decompression to work. > > The bug with gcc 5 is not trivial, I'll do my best to explain it here. > > Basically, there are two memory mappings of the code. One in "virtual memory", > and one in "load memory". The one in virtual memory may use the 4G of address > space, while the one in "load memory" is more compact. > > The "load memory" mapping is actually used in syslinux to compress most of the > code. The early stages of syslinux decompress the code at the correct virtual > address. So both mappings must have the same data layout. > > The matching between both mappings is done through the ld script by specifying > the LMA (load memory address) which is computed from on the VMA (virtual memory > address). > > However, the way the LMA was computed included adding symbols just before the > sections to get the VMA. Since the sections are aligned (depending on the > alignment of its content), those symbols had to be aligned by hand to avoid to > leave a gap. > > With gcc 5, the .data and .rodata sections got sometime a larger alignment (up > to 32 bytes), which is greater than the 16 bytes that were recorded in the > linker script. Thus introducing a gap between the real section's VMA and its > assumed VMA. > > The first of these two patches just fix the aligment. > The second remove the hand-alignment and compute the LMA of the sections so > that the mappings will always match regardless of the aligment the sections > need. > > > On a side 2 questions: > - Is core/syslinux.ld is still used? it looks like a forgotten file. > - Is there really a bios version for x86_64? Looks like the boot files are > i386-specific. > > Tests and comments are welcome. > > > Sylvain Gault > > core/i386/syslinux.ld | 65 ++++++++++--------------------------------------- > core/x86_64/syslinux.ld | 65 ++++++++++--------------------------------------- > 2 files changed, 26 insertions(+), 104 deletions(-)Excellent job! Issues like this are always a challenge. Thank you. -- -Gene
On 09/28/2015 09:46 PM, celelibi--- via Syslinux wrote:> > On a side 2 questions: > - Is core/syslinux.ld is still used? it looks like a forgotten file. > - Is there really a bios version for x86_64? Looks like the boot files are > i386-specific. >There is no x86-64 version for BIOS, nor does there need to be one. -hpa
On Tue, Sep 29, 2015 at 05:45:01AM -0400, Gene Cumm via Syslinux wrote:> On Tue, Sep 29, 2015 at 12:46 AM, celelibi--- via Syslinux wrote: > > From: Sylvain Gault <sylvain.gault at gmail.com> > > > > TL;DR: The section aligment in linker scripts messed-up the memory mapping > > needed for the compression / decompression to work. > ><snip/>> > > > Tests and comments are welcome. > > > > > > Sylvain Gault > > > > core/i386/syslinux.ld | 65 ++++++++++--------------------------------------- > > core/x86_64/syslinux.ld | 65 ++++++++++--------------------------------------- > > 2 files changed, 26 insertions(+), 104 deletions(-) > > Excellent job! Issues like this are always a challenge. Thank you. >And when will it be pushed to git://repo.or.cz/syslinux.git ?? Groeten Geert Stappers -- Leven en laten leven
poma
2015-Oct-16 13:40 UTC
[syslinux] [PATCH 2/2] bios: Don't try to guess the sections alignment
https://github.com/Celelibi/syslinux/tree/fix/bios/gcc5 - bios: Fix alignment change with gcc 5 0001-bios-Fix-alignment-change-with-gcc-5.patch https://github.com/Celelibi/syslinux/commit/2686a69.patch - bios: Don't try to guess the sections alignment 0002-bios-Don-t-try-to-guess-the-sections-alignment.patch https://github.com/Celelibi/syslinux/commit/ab01326.patch - ldlinux: Fix return pointer to local data 0003-ldlinux-Fix-return-pointer-to-local-data.patch https://github.com/Celelibi/syslinux/commit/9b9d9db.patch Patched on top of http://repo.or.cz/syslinux.git - 9e0926b Built with gcc (GCC) 5.2.1 20150902 (Red Hat 5.2.1-2) ISOLINUX & EXTLINUX tested on baremetal & QEMU/SeaBIOS - both PASSED/BOOTABLE Packages: syslinux-6.04-4.gcc5.2.1.git20151016.fc24.x86_64.rpm syslinux-extlinux-6.04-4.gcc5.2.1.git20151016.fc24.x86_64.rpm syslinux-extlinux-nonlinux-6.04-4.gcc5.2.1.git20151016.fc24.noarch.rpm syslinux-nonlinux-6.04-4.gcc5.2.1.git20151016.fc24.noarch.rpm Tested-by: poma <pomidorabelisima at gmail.com>
On 29.09.2015 06:46, celelibi--- via Syslinux wrote:> From: Sylvain Gault <sylvain.gault at gmail.com> > > The section aligment specified in the ld scripts have to be greater or > equal to those in the .o files generated by gcc. > > Signed-off-by: Sylvain Gault <sylvain.gault at gmail.com> > --- > core/i386/syslinux.ld | 6 +++--- > core/x86_64/syslinux.ld | 6 +++--- > 2 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/core/i386/syslinux.ld b/core/i386/syslinux.ld > index 7b4e012..7390451 100644 > --- a/core/i386/syslinux.ld > +++ b/core/i386/syslinux.ld > @@ -266,7 +266,7 @@ SECTIONS > __text_end = .; > } > > - . = ALIGN(16); > + . = ALIGN(32); > > __rodata_vma = .; > __rodata_lma = __rodata_vma + __text_lma - __text_vma; > @@ -361,7 +361,7 @@ SECTIONS > __dynamic_end = .; > } > > - . = ALIGN(16); > + . = ALIGN(32); > > __data_vma = .; > __data_lma = __data_vma + __text_lma - __text_vma; > @@ -377,7 +377,7 @@ SECTIONS > __pm_code_dwords = (__pm_code_len + 3) >> 2; > > . = ALIGN(128); > - > + > __bss_vma = .; > __bss_lma = .; /* Dummy */ > .bss (NOLOAD) : AT (__bss_lma) { > diff --git a/core/x86_64/syslinux.ld b/core/x86_64/syslinux.ld > index 1057112..bf815c4 100644 > --- a/core/x86_64/syslinux.ld > +++ b/core/x86_64/syslinux.ld > @@ -266,7 +266,7 @@ SECTIONS > __text_end = .; > } > > - . = ALIGN(16); > + . = ALIGN(32); > > __rodata_vma = .; > __rodata_lma = __rodata_vma + __text_lma - __text_vma; > @@ -361,7 +361,7 @@ SECTIONS > __dynamic_end = .; > } > > - . = ALIGN(16); > + . = ALIGN(32); > > __data_vma = .; > __data_lma = __data_vma + __text_lma - __text_vma; > @@ -377,7 +377,7 @@ SECTIONS > __pm_code_dwords = (__pm_code_len + 3) >> 2; > > . = ALIGN(128); > - > + > __bss_vma = .; > __bss_lma = .; /* Dummy */ > .bss (NOLOAD) : AT (__bss_lma) { >Tested-by: poma <pomidorabelisima at gmail.com>
poma
2015-Oct-21 16:00 UTC
[syslinux] [PATCH 2/2] bios: Don't try to guess the sections alignment
On 29.09.2015 06:46, celelibi--- via Syslinux wrote:> From: Sylvain Gault <sylvain.gault at gmail.com> > > For the compression / decompression to succeed, the sections layout must > be the same between the virtual memory and load memory. The section > alignment was kept in sync by introducing aligment that should be > greater or equal to the actual section alignment. > > This patch compute the load memory addresses of the sections so that > the layout is the same as the virtual memory addresses. > > Signed-off-by: Sylvain Gault <sylvain.gault at gmail.com> > --- > core/i386/syslinux.ld | 63 ++++++++++--------------------------------------- > core/x86_64/syslinux.ld | 63 ++++++++++--------------------------------------- > 2 files changed, 24 insertions(+), 102 deletions(-) > > diff --git a/core/i386/syslinux.ld b/core/i386/syslinux.ld > index 7390451..92b75b1 100644 > --- a/core/i386/syslinux.ld > +++ b/core/i386/syslinux.ld > @@ -255,10 +255,9 @@ SECTIONS > . = 0x100000; > > __pm_code_start = .; > + __vma_to_lma = __pm_code_lma - __pm_code_start; > > - __text_vma = .; > - __text_lma = __pm_code_lma; > - .text : AT(__text_lma) { > + .text : AT(ADDR(.text) + __vma_to_lma) { > FILL(0x90909090) > __text_start = .; > *(.text) > @@ -266,106 +265,68 @@ SECTIONS > __text_end = .; > } > > - . = ALIGN(32); > - > - __rodata_vma = .; > - __rodata_lma = __rodata_vma + __text_lma - __text_vma; > - .rodata : AT(__rodata_lma) { > + .rodata : AT(ADDR(.rodata) + __vma_to_lma) { > __rodata_start = .; > *(.rodata) > *(.rodata.*) > __rodata_end = .; > } > > - . = ALIGN(4); > - > - __ctors_vma = .; > - __ctors_lma = __ctors_vma + __text_lma - __text_vma; > - .ctors : AT(__ctors_lma) { > + .ctors : AT(ADDR(.ctors) + __vma_to_lma) { > __ctors_start = .; > KEEP (*(SORT(.ctors.*))) > KEEP (*(.ctors)) > __ctors_end = .; > } > > - __dtors_vma = .; > - __dtors_lma = __dtors_vma + __text_lma - __text_vma; > - .dtors : AT(__dtors_lma) { > + .dtors : AT(ADDR(.dtors) + __vma_to_lma) { > __dtors_start = .; > KEEP (*(SORT(.dtors.*))) > KEEP (*(.dtors)) > __dtors_end = .; > } > > - . = ALIGN(4); > - > - __dynsym_vma = .; > - __dynsym_lma = __dynsym_vma + __text_lma - __text_vma; > - .dynsym : AT(__dynsym_lma) { > + .dynsym : AT(ADDR(.dynsym) + __vma_to_lma) { > __dynsym_start = .; > *(.dynsym) > __dynsym_end = .; > } > __dynsym_len = __dynsym_end - __dynsym_start; > > - . = ALIGN(4); > - > - __dynstr_vma = .; > - __dynstr_lma = __dynstr_vma + __text_lma - __text_vma; > - .dynstr : AT(__dynstr_lma) { > + .dynstr : AT(ADDR(.dynstr) + __vma_to_lma) { > __dynstr_start = .; > *(.dynstr) > __dynstr_end = .; > } > __dynstr_len = __dynstr_end - __dynstr_start; > > - . = ALIGN(4); > - > - __gnu_hash_vma = .; > - __gnu_hash_lma = __gnu_hash_vma + __text_lma - __text_vma; > - .gnu.hash : AT(__gnu_hash_lma) { > + .gnu.hash : AT(ADDR(.gnu.hash) + __vma_to_lma) { > __gnu_hash_start = .; > *(.gnu.hash) > __gnu_hash_end = .; > } > > > - . = ALIGN(4); > - > - __dynlink_vma = .; > - __dynlink_lma = __dynlink_vma + __text_lma - __text_vma; > - .dynlink : AT(__dynlink_lma) { > + .dynlink : AT(ADDR(.dynlink) + __vma_to_lma) { > __dynlink_start = .; > *(.dynlink) > __dynlink_end = .; > } > > - . = ALIGN(4); > - > - __got_vma = .; > - __got_lma = __got_vma + __text_lma - __text_vma; > - .got : AT(__got_lma) { > + .got : AT(ADDR(.got) + __vma_to_lma) { > __got_start = .; > KEEP (*(.got.plt)) > KEEP (*(.got)) > __got_end = .; > } > > - . = ALIGN(4); > - > - __dynamic_vma = .; > - __dynamic_lma = __dynamic_vma + __text_lma - __text_vma; > - .dynamic : AT(__dynamic_lma) { > + .dynamic : AT(ADDR(.dynamic) + __vma_to_lma) { > __dynamic_start = .; > *(.dynamic) > __dynamic_end = .; > } > > - . = ALIGN(32); > - > - __data_vma = .; > - __data_lma = __data_vma + __text_lma - __text_vma; > - .data : AT(__data_lma) { > + .data : AT(ADDR(.data) + __vma_to_lma) { > __data_start = .; > *(.data) > *(.data.*) > diff --git a/core/x86_64/syslinux.ld b/core/x86_64/syslinux.ld > index bf815c4..70c6e00 100644 > --- a/core/x86_64/syslinux.ld > +++ b/core/x86_64/syslinux.ld > @@ -255,10 +255,9 @@ SECTIONS > . = 0x100000; > > __pm_code_start = .; > + __vma_to_lma = __pm_code_lma - __pm_code_start; > > - __text_vma = .; > - __text_lma = __pm_code_lma; > - .text : AT(__text_lma) { > + .text : AT(ADDR(.text) + __vma_to_lma) { > FILL(0x90909090) > __text_start = .; > *(.text) > @@ -266,106 +265,68 @@ SECTIONS > __text_end = .; > } > > - . = ALIGN(32); > - > - __rodata_vma = .; > - __rodata_lma = __rodata_vma + __text_lma - __text_vma; > - .rodata : AT(__rodata_lma) { > + .rodata : AT(ADDR(.rodata) + __vma_to_lma) { > __rodata_start = .; > *(.rodata) > *(.rodata.*) > __rodata_end = .; > } > > - . = ALIGN(4); > - > - __ctors_vma = .; > - __ctors_lma = __ctors_vma + __text_lma - __text_vma; > - .ctors : AT(__ctors_lma) { > + .ctors : AT(ADDR(.ctors) + __vma_to_lma) { > __ctors_start = .; > KEEP (*(SORT(.ctors.*))) > KEEP (*(.ctors)) > __ctors_end = .; > } > > - __dtors_vma = .; > - __dtors_lma = __dtors_vma + __text_lma - __text_vma; > - .dtors : AT(__dtors_lma) { > + .dtors : AT(ADDR(.dtors) + __vma_to_lma) { > __dtors_start = .; > KEEP (*(SORT(.dtors.*))) > KEEP (*(.dtors)) > __dtors_end = .; > } > > - . = ALIGN(4); > - > - __dynsym_vma = .; > - __dynsym_lma = __dynsym_vma + __text_lma - __text_vma; > - .dynsym : AT(__dynsym_lma) { > + .dynsym : AT(ADDR(.dynsym) + __vma_to_lma) { > __dynsym_start = .; > *(.dynsym) > __dynsym_end = .; > } > __dynsym_len = __dynsym_end - __dynsym_start; > > - . = ALIGN(4); > - > - __dynstr_vma = .; > - __dynstr_lma = __dynstr_vma + __text_lma - __text_vma; > - .dynstr : AT(__dynstr_lma) { > + .dynstr : AT(ADDR(.dynstr) + __vma_to_lma) { > __dynstr_start = .; > *(.dynstr) > __dynstr_end = .; > } > __dynstr_len = __dynstr_end - __dynstr_start; > > - . = ALIGN(4); > - > - __gnu_hash_vma = .; > - __gnu_hash_lma = __gnu_hash_vma + __text_lma - __text_vma; > - .gnu.hash : AT(__gnu_hash_lma) { > + .gnu.hash : AT(ADDR(.gnu.hash) + __vma_to_lma) { > __gnu_hash_start = .; > *(.gnu.hash) > __gnu_hash_end = .; > } > > > - . = ALIGN(4); > - > - __dynlink_vma = .; > - __dynlink_lma = __dynlink_vma + __text_lma - __text_vma; > - .dynlink : AT(__dynlink_lma) { > + .dynlink : AT(ADDR(.dynlink) + __vma_to_lma) { > __dynlink_start = .; > *(.dynlink) > __dynlink_end = .; > } > > - . = ALIGN(4); > - > - __got_vma = .; > - __got_lma = __got_vma + __text_lma - __text_vma; > - .got : AT(__got_lma) { > + .got : AT(ADDR(.got) + __vma_to_lma) { > __got_start = .; > KEEP (*(.got.plt)) > KEEP (*(.got)) > __got_end = .; > } > > - . = ALIGN(4); > - > - __dynamic_vma = .; > - __dynamic_lma = __dynamic_vma + __text_lma - __text_vma; > - .dynamic : AT(__dynamic_lma) { > + .dynamic : AT(ADDR(.dynamic) + __vma_to_lma) { > __dynamic_start = .; > *(.dynamic) > __dynamic_end = .; > } > > - . = ALIGN(32); > - > - __data_vma = .; > - __data_lma = __data_vma + __text_lma - __text_vma; > - .data : AT(__data_lma) { > + .data : AT(ADDR(.data) + __vma_to_lma) { > __data_start = .; > *(.data) > *(.data.*) >Tested-by: poma <pomidorabelisima at gmail.com>
Paulo Alcantara
2015-Nov-08 17:53 UTC
[syslinux] [PATCH 1/2] bios: Fix alignment change with gcc 5
On Tue, 29 Sep 2015 06:46:46 +0200 celelibi--- via Syslinux <syslinux at zytor.com> wrote:> From: Sylvain Gault <sylvain.gault at gmail.com> > > The section aligment specified in the ld scripts have to be greater or > equal to those in the .o files generated by gcc. > > Signed-off-by: Sylvain Gault <sylvain.gault at gmail.com> > --- > core/i386/syslinux.ld | 6 +++--- > core/x86_64/syslinux.ld | 6 +++--- > 2 files changed, 6 insertions(+), 6 deletions(-)Thanks, applied. Paulo -- Paulo Alcantara, HP Inc. Speaking for myself only.
Paulo Alcantara
2015-Nov-08 17:54 UTC
[syslinux] [PATCH 2/2] bios: Don't try to guess the sections alignment
On Tue, 29 Sep 2015 06:46:47 +0200 celelibi--- via Syslinux <syslinux at zytor.com> wrote:> From: Sylvain Gault <sylvain.gault at gmail.com> > > For the compression / decompression to succeed, the sections layout > must be the same between the virtual memory and load memory. The > section alignment was kept in sync by introducing aligment that > should be greater or equal to the actual section alignment. > > This patch compute the load memory addresses of the sections so that > the layout is the same as the virtual memory addresses. > > Signed-off-by: Sylvain Gault <sylvain.gault at gmail.com> > --- > core/i386/syslinux.ld | 63 > ++++++++++--------------------------------------- > core/x86_64/syslinux.ld | 63 > ++++++++++--------------------------------------- 2 files changed, 24 > insertions(+), 102 deletions(-)Thanks, applied. Paulo -- Paulo Alcantara, HP Inc. Speaking for myself only.