[syslinux] [PATCH 0/2] Fixes for gcc 5

celelibi at gmail.com celelibi at gmail.com
Mon Sep 28 21:46:45 PDT 2015

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

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

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

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(-)


More information about the Syslinux mailing list