Skip to content

Commit 2bf1d7a

Browse files
vathpelamartinezjavier
authored andcommitted
linker scripts: put .sbat after _edata
Our section headers on arm binaries need to include .sbat on fallback and MokManger, and currently they do not. The reason for this is that gnu-efi provides static, (mostly) hand-coded section headers on arm and aarch64, due to having no efi-app-arm and efi-app-aa64 target support in binutils. Additionally, the assembler also generates (IMO pointless) relocations for _esbat/_sbat_size when those are actually inside the section, and relocated symbols can't be used in our section headers. This patch moves the .sbat section to be after _edata, so the sections don't overlap, and moves _esbat and _sbat_size to be after the section, to avoid the relocation. I'm not 100% sure we can't have overlapping sections, but now doesn't seem like the time to find out. Signed-off-by: Peter Jones <[email protected]>
1 parent e02bb35 commit 2bf1d7a

5 files changed

+47
-40
lines changed

elf_aarch64_efi.lds

+9-8
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,6 @@ SECTIONS
5858
*(.vendor_cert)
5959
}
6060
. = ALIGN(4096);
61-
.sbat :
62-
{
63-
_sbat = .;
64-
*(.sbat)
65-
*(.sbat.*)
66-
_esbat = .;
67-
}
68-
. = ALIGN(4096);
6961
.rela :
7062
{
7163
*(.rela.dyn)
@@ -76,6 +68,15 @@ SECTIONS
7668
}
7769
_edata = .;
7870
_data_size = . - _data;
71+
. = ALIGN(4096);
72+
.sbat :
73+
{
74+
_sbat = .;
75+
*(.sbat)
76+
*(.sbat.*)
77+
}
78+
_esbat = .;
79+
_sbat_size = . - _sbat;
7980

8081
. = ALIGN(4096);
8182
.dynsym : { *(.dynsym) }

elf_arm_efi.lds

+9-8
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,6 @@ SECTIONS
5656
*(.vendor_cert)
5757
}
5858
. = ALIGN(4096);
59-
.sbat :
60-
{
61-
_sbat = .;
62-
*(.sbat)
63-
*(.sbat.*)
64-
_esbat = .;
65-
}
66-
. = ALIGN(4096);
6759
.rel :
6860
{
6961
*(.rel.dyn)
@@ -74,6 +66,15 @@ SECTIONS
7466
}
7567
_edata = .;
7668
_data_size = . - _data;
69+
. = ALIGN(4096);
70+
.sbat :
71+
{
72+
_sbat = .;
73+
*(.sbat)
74+
*(.sbat.*)
75+
}
76+
_esbat = .;
77+
_sbat_size = . - _sbat;
7778

7879
. = ALIGN(4096);
7980
.dynsym : { *(.dynsym) }

elf_ia32_efi.lds

+10-8
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,6 @@ SECTIONS
5454
*(.vendor_cert)
5555
}
5656
. = ALIGN(4096);
57-
.sbat :
58-
{
59-
_sbat = .;
60-
*(.sbat)
61-
*(.sbat.*)
62-
_esbat = .;
63-
}
64-
. = ALIGN(4096);
6557
.dynamic : { *(.dynamic) }
6658
. = ALIGN(4096);
6759
.rel :
@@ -77,6 +69,16 @@ SECTIONS
7769
}
7870
_edata = .;
7971
_data_size = . - _data;
72+
. = ALIGN(4096);
73+
.sbat :
74+
{
75+
_sbat = .;
76+
*(.sbat)
77+
*(.sbat.*)
78+
}
79+
_esbat = .;
80+
_sbat_size = . - _sbat;
81+
8082
. = ALIGN(4096);
8183
.dynsym : { *(.dynsym) }
8284
. = ALIGN(4096);

elf_ia64_efi.lds

+10-8
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,6 @@ SECTIONS
5656
*(.vendor_cert)
5757
}
5858
. = ALIGN(4096);
59-
.sbat :
60-
{
61-
_sbat = .;
62-
*(.sbat)
63-
*(.sbat.*)
64-
_esbat = .;
65-
}
66-
. = ALIGN(4096);
6759
.dynamic : { *(.dynamic) }
6860
. = ALIGN(4096);
6961
.rela :
@@ -78,6 +70,16 @@ SECTIONS
7870
}
7971
_edata = .;
8072
_data_size = . - _data;
73+
. = ALIGN(4096);
74+
.sbat :
75+
{
76+
_sbat = .;
77+
*(.sbat)
78+
*(.sbat.*)
79+
}
80+
_esbat = .;
81+
_sbat_size = . - _sbat;
82+
8183
. = ALIGN(4096);
8284
.reloc : /* This is the PECOFF .reloc section! */
8385
{

elf_x86_64_efi.lds

+9-8
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@ SECTIONS
6161
*(.vendor_cert)
6262
}
6363
. = ALIGN(4096);
64-
.sbat :
65-
{
66-
_sbat = .;
67-
*(.sbat)
68-
*(.sbat.*)
69-
_esbat = .;
70-
}
71-
. = ALIGN(4096);
7264
.dynamic : { *(.dynamic) }
7365
. = ALIGN(4096);
7466
.rela :
@@ -79,6 +71,15 @@ SECTIONS
7971
}
8072
_edata = .;
8173
_data_size = . - _data;
74+
. = ALIGN(4096);
75+
.sbat :
76+
{
77+
_sbat = .;
78+
*(.sbat)
79+
*(.sbat.*)
80+
}
81+
_esbat = .;
82+
_sbat_size = . - _sbat;
8283

8384
. = ALIGN(4096);
8485
.dynsym : { *(.dynsym) }

0 commit comments

Comments
 (0)