summaryrefslogtreecommitdiff
path: root/debian/patches/aarch64-shim-old.patch
blob: fa24055c9ecfd00597d0d82d27da7840d688caf7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
shim 15.6 onwards needs newer binutils to build on aarch64. That works
better, but we don't have that binutils update in older Debian
releases. Undo the build changes here so that we can build for aarch64
on older stable releases. We're not going to sign them, but we need
the binaries for aarch64.

diff --git a/Make.defaults b/Make.defaults
index dfed9c4a..18677daa 100644
--- a/Make.defaults
+++ b/Make.defaults
@@ -84,7 +84,9 @@ ifeq ($(ARCH),aarch64)
 	ARCH_GNUEFI		?= aarch64
 	ARCH_SUFFIX		?= aa64
 	ARCH_SUFFIX_UPPER	?= AA64
-	ARCH_LDFLAGS		?=
+	FORMAT			:= -O binary
+	SUBSYSTEM		:= 0xa
+	ARCH_LDFLAGS		+= --defsym=EFI_SUBSYSTEM=$(SUBSYSTEM)
 	ARCH_CFLAGS		?=
 endif
 ifeq ($(ARCH),arm)
diff --git a/elf_aarch64_efi.lds b/elf_aarch64_efi.lds
index 0861f5e8..3837b98b 100644
--- a/elf_aarch64_efi.lds
+++ b/elf_aarch64_efi.lds
@@ -3,98 +3,110 @@ OUTPUT_ARCH(aarch64)
 ENTRY(_start)
 SECTIONS
 {
-  . = 0;
-  ImageBase = .;
-  .hash : { *(.hash) }	/* this MUST come first! */
-  . = ALIGN(4096);
-  .eh_frame :
-  {
-    *(.eh_frame)
-  }
-  . = ALIGN(4096);
-  .text :
-  {
-   _text = .;
-   *(.text)
-   *(.text.*)
-   *(.gnu.linkonce.t.*)
-   _etext = .;
-  }
-  . = ALIGN(4096);
-  .reloc :
-  {
-   *(.reloc)
-  }
-  . = ALIGN(4096);
-  .note.gnu.build-id : {
-    *(.note.gnu.build-id)
-  }
-
-  . = ALIGN(4096);
-  .data.ident : {
-    *(.data.ident)
-  }
-  . = ALIGN(4096);
-  .sbatlevel : {
-    *(.sbatlevel)
+  .text 0x0 : {
+    _text = .;
+    *(.text.head)
+    *(.text)
+    *(.text.*)
+    *(.gnu.linkonce.t.*)
+    _evtext = .;
+    . = ALIGN(4096);
   }
+  _etext = .;
+  _text_size = . - _text;
+  _text_vsize = _evtext - _text;
 
   . = ALIGN(4096);
   .data :
   {
    _data = .;
-   *(.rodata*)
+   *(.sdata)
+   *(.data)
+   *(.data1)
+   *(.data.*)
    *(.got.plt)
    *(.got)
-   *(.data*)
-   *(.sdata)
+
+   *(.dynamic)
+
    /* the EFI loader doesn't seem to like a .bss section, so we stick
       it all into .data: */
+   . = ALIGN(16);
+   _bss = .;
    *(.sbss)
    *(.scommon)
    *(.dynbss)
    *(.bss)
    *(COMMON)
-   *(.rel.local)
+   _evdata = .;
+   . = ALIGN(4096);
+   _bss_end = .;
   }
+  _edata = .;
+  _data_vsize = _evdata - _data;
+  _data_size = . - _data;
 
+  /*
+   * Note that _sbat must be the beginning of the data, and _esbat must be the
+   * end and must be before any section padding.  The sbat self-check uses
+   * _esbat to find the bounds of the data, and if the padding is included, the
+   * CSV parser (correctly) rejects the data as having NUL values in one of the
+   * required columns.
+   */
   . = ALIGN(4096);
-  .vendor_cert :
+  .sbat :
   {
-   *(.vendor_cert)
+    _sbat = .;
+    *(.sbat)
+    *(.sbat.*)
+    _esbat = .;
+    . = ALIGN(4096);
+    _epsbat = .;
   }
+  _sbat_size = _epsbat - _sbat;
+  _sbat_vsize = _esbat - _sbat;
+
   . = ALIGN(4096);
-  .dynamic  : { *(.dynamic) }
+  .rodata :
+  {
+    _rodata = .;
+    *(.rodata*)
+    *(.srodata)
+    . = ALIGN(16);
+    *(.note.gnu.build-id)
+    . = ALIGN(4096);
+    *(.vendor_cert)
+    *(.data.ident)
+    *(.sbatlevel)
+    . = ALIGN(4096);
+  }
   . = ALIGN(4096);
   .rela :
   {
+    *(.rela.dyn)
+    *(.rela.plt)
+    *(.rela.got)
+    *(.rela.data)
     *(.rela.data*)
-    *(.rela.got*)
-    *(.rela.stab*)
   }
-  _edata = .;
-  _data_size = . - _data;
   . = ALIGN(4096);
-  .sbat :
+  .dyn :
   {
-    _sbat = .;
-    *(.sbat)
-    *(.sbat.*)
+    *(.dynsym)
+    *(.dynstr)
+    _evrodata = .;
+    . = ALIGN(4096);
   }
-  _esbat = .;
-  _sbat_size = . - _sbat;
+  _erodata = .;
+  _rodata_size = . - _rodata;
+  _rodata_vsize = _evrodata - _rodata;
+  _alldata_size = . - _data;
 
-  . = ALIGN(4096);
-  .dynsym   : { *(.dynsym) }
-  . = ALIGN(4096);
-  .dynstr   : { *(.dynstr) }
-  . = ALIGN(4096);
-  .ignored.reloc :
+  /DISCARD/ :
   {
-    *(.rela.reloc)
+    *(.rel.reloc)
     *(.eh_frame)
     *(.note.GNU-stack)
   }
   .comment 0 : { *(.comment) }
-  .note.gnu.build-id : { *(.note.gnu.build-id) }
 }