Skip to content

Commit 24f2358

Browse files
committed
x86: Fix section alignment for EFI binaries
This patch fixes the section alignment specification in the linker script for the Intel Quark X1000 SoC so that the UEFI GenFw program generates correct EFI binaries. See the added comment in quarkX1000.ld for details.
1 parent fa6771f commit 24f2358

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

cpu/x86/quarkX1000.ld

+16-4
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,26 @@ SECTIONS {
5252
*/
5353
. = 1M + 0x220;
5454

55-
.text ALIGN (32) :
55+
.text : ALIGN (32)
5656
{
5757
KEEP(*(.multiboot))
5858
*(.boot_text)
5959
*(.text*)
6060
}
6161

62-
.rodata ALIGN (32) :
62+
/*
63+
The alignment directive must be placed after the colon so that the desired
64+
alignment is indicated in the ELF section metadata. This metadata is used
65+
by the UEFI GenFw program. It is necessary to avoid specifying a smaller
66+
alignment value in the ELF metadata for some section "B" that follows some
67+
section "A" with an ending address that is not aligned on a 32-byte boundary.
68+
In that case, GenFw may place section "B" at a lower starting address in the
69+
EFI binary than section "B" had in the input ELF file. This may result in
70+
incorrect program behavior. Note that this situation is not directly visible
71+
in the EFI binary metadata, since GenFw combines the ELF .rodata, .data, and
72+
.bss sections into a single .data section in the EFI binary.
73+
*/
74+
.rodata : ALIGN (32)
6375
{
6476
*(.rodata*)
6577

@@ -72,12 +84,12 @@ SECTIONS {
7284
_edata_shared_isr = .;
7385
}
7486

75-
.data ALIGN (32) :
87+
.data : ALIGN (32)
7688
{
7789
*(.data*)
7890
}
7991

80-
.bss ALIGN (32) :
92+
.bss : ALIGN (32)
8193
{
8294
*(COMMON)
8395
*(.main_stack)

0 commit comments

Comments
 (0)