Skip to content

Commit ce64db5

Browse files
committed
use binutils 2.30 for devkitA64
1 parent 573afd6 commit ce64db5

3 files changed

Lines changed: 348 additions & 2 deletions

File tree

dka64/patches/binutils-2.30.patch

Lines changed: 346 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,346 @@
1+
diff -NBaur binutils-2.30/bfd/elfnn-aarch64.c binutils-2.30-dka64/bfd/elfnn-aarch64.c
2+
--- binutils-2.30/bfd/elfnn-aarch64.c 2018-01-17 11:29:21.000000000 +0000
3+
+++ binutils-2.30-dka64/bfd/elfnn-aarch64.c 2018-02-11 19:54:08.141257544 +0000
4+
@@ -2097,6 +2097,12 @@
5+
aarch64_stub_erratum_843419_veneer,
6+
};
7+
8+
+/* Is an undefined weak symbol resolved to 0 ? */
9+
+#define UNDEFINED_WEAK_RESOLVED_TO_ZERO(INFO, EH) \
10+
+ ((EH)->root.root.type == bfd_link_hash_undefweak \
11+
+ && bfd_link_executable (INFO) \
12+
+ && !(INFO)->dynamic_undefined_weak)
13+
+
14+
struct elf_aarch64_stub_hash_entry
15+
{
16+
/* Base hash table entry structure. */
17+
@@ -6088,11 +6094,13 @@
18+
Elf_Internal_Sym *sym;
19+
asection *sec;
20+
struct elf_link_hash_entry *h;
21+
+ struct elf_aarch64_link_hash_entry *eh;
22+
bfd_vma relocation;
23+
bfd_reloc_status_type r;
24+
arelent bfd_reloc;
25+
char sym_type;
26+
bfd_boolean unresolved_reloc = FALSE;
27+
+ bfd_boolean resolved_to_zero = FALSE;
28+
char *error_message = NULL;
29+
30+
r_symndx = ELFNN_R_SYM (rel->r_info);
31+
@@ -6226,6 +6234,10 @@
32+
h, &unresolved_reloc,
33+
save_addend, &addend, sym);
34+
35+
+ eh = (struct elf_aarch64_link_hash_entry *) h;
36+
+ resolved_to_zero = (eh != NULL
37+
+ && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh));
38+
+
39+
switch (elfNN_aarch64_bfd_reloc_from_type (r_type))
40+
{
41+
case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
42+
@@ -6249,7 +6261,7 @@
43+
need_relocs =
44+
(!bfd_link_executable (info) || indx != 0) &&
45+
(h == NULL
46+
- || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
47+
+ || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT && !resolved_to_zero)
48+
|| h->root.type != bfd_link_hash_undefweak);
49+
50+
BFD_ASSERT (globals->root.srelgot != NULL);
51+
@@ -6344,7 +6356,7 @@
52+
need_relocs =
53+
(!bfd_link_executable (info) || indx != 0) &&
54+
(h == NULL
55+
- || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
56+
+ || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT && !resolved_to_zero)
57+
|| h->root.type != bfd_link_hash_undefweak);
58+
59+
BFD_ASSERT (globals->root.srelgot != NULL);
60+
@@ -6393,7 +6405,7 @@
61+
bfd_vma off = symbol_tlsdesc_got_offset (input_bfd, h, r_symndx);
62+
63+
need_relocs = (h == NULL
64+
- || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
65+
+ || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT && !resolved_to_zero)
66+
|| h->root.type != bfd_link_hash_undefweak);
67+
68+
BFD_ASSERT (globals->root.srelgot != NULL);
69+
@@ -6735,6 +6747,26 @@
70+
return FALSE;
71+
}
72+
73+
+/* Remove undefined weak symbol from the dynamic symbol table if it
74+
+ is resolved to 0. */
75+
+
76+
+extern bfd_boolean
77+
+elfNN_aarch64_elf_fixup_symbol (struct bfd_link_info *, struct elf_link_hash_entry *);
78+
+
79+
+bfd_boolean
80+
+elfNN_aarch64_elf_fixup_symbol (struct bfd_link_info *info,
81+
+ struct elf_link_hash_entry *h)
82+
+{
83+
+ if (h->dynindx != -1
84+
+ && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, elf_aarch64_hash_entry (h)))
85+
+ {
86+
+ h->dynindx = -1;
87+
+ _bfd_elf_strtab_delref (elf_hash_table (info)->dynstr,
88+
+ h->dynstr_index);
89+
+ }
90+
+ return TRUE;
91+
+}
92+
+
93+
/* Adjust a symbol defined by a dynamic object and referenced by a
94+
regular object. The current definition is in some section of the
95+
dynamic object, but we're not including those sections. We have to
96+
@@ -7928,6 +7960,7 @@
97+
struct elf_aarch64_link_hash_table *htab;
98+
struct elf_aarch64_link_hash_entry *eh;
99+
struct elf_dyn_relocs *p;
100+
+ bfd_boolean resolved_to_zero;
101+
102+
/* An example of a bfd_link_hash_indirect symbol is versioned
103+
symbol. For example: __gxx_personality_v0(bfd_link_hash_indirect)
104+
@@ -7947,6 +7980,10 @@
105+
info = (struct bfd_link_info *) inf;
106+
htab = elf_aarch64_hash_table (info);
107+
108+
+ eh = (struct elf_aarch64_link_hash_entry *) h;
109+
+ eh->tlsdesc_got_jump_table_offset = (bfd_vma) - 1;
110+
+ resolved_to_zero = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh);
111+
+
112+
/* Since STT_GNU_IFUNC symbol must go through PLT, we handle it
113+
here if it is defined and referenced in a non-shared object. */
114+
if (h->type == STT_GNU_IFUNC
115+
@@ -7956,7 +7993,7 @@
116+
{
117+
/* Make sure this symbol is output as a dynamic symbol.
118+
Undefined weak syms won't yet be marked as dynamic. */
119+
- if (h->dynindx == -1 && !h->forced_local
120+
+ if (h->dynindx == -1 && !h->forced_local && !resolved_to_zero
121+
&& h->root.type == bfd_link_hash_undefweak)
122+
{
123+
if (!bfd_elf_link_record_dynamic_symbol (info, h))
124+
@@ -7990,6 +8027,11 @@
125+
of relaxing into these from the large model PLT entries. */
126+
s->size += PLT_SMALL_ENTRY_SIZE;
127+
128+
+ /* There should be no PLT relocations against resolved undefined
129+
+ weak symbols in the executable. */
130+
+ if (!resolved_to_zero)
131+
+ {
132+
+
133+
/* We also need to make an entry in the .got.plt section, which
134+
will be placed in the .got section by the linker script. */
135+
htab->root.sgotplt->size += GOT_ENTRY_SIZE;
136+
@@ -8012,6 +8054,7 @@
137+
138+
htab->root.srelplt->reloc_count++;
139+
}
140+
+ }
141+
else
142+
{
143+
h->plt.offset = (bfd_vma) - 1;
144+
@@ -8024,9 +8067,6 @@
145+
h->needs_plt = 0;
146+
}
147+
148+
- eh = (struct elf_aarch64_link_hash_entry *) h;
149+
- eh->tlsdesc_got_jump_table_offset = (bfd_vma) - 1;
150+
-
151+
if (h->got.refcount > 0)
152+
{
153+
bfd_boolean dyn;
154+
@@ -8038,7 +8078,7 @@
155+
156+
/* Make sure this symbol is output as a dynamic symbol.
157+
Undefined weak syms won't yet be marked as dynamic. */
158+
- if (dyn && h->dynindx == -1 && !h->forced_local
159+
+ if (dyn && h->dynindx == -1 && !h->forced_local && !resolved_to_zero
160+
&& h->root.type == bfd_link_hash_undefweak)
161+
{
162+
if (!bfd_elf_link_record_dynamic_symbol (info, h))
163+
@@ -8052,7 +8092,7 @@
164+
{
165+
h->got.offset = htab->root.sgot->size;
166+
htab->root.sgot->size += GOT_ENTRY_SIZE;
167+
- if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
168+
+ if (((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT && !resolved_to_zero)
169+
|| h->root.type != bfd_link_hash_undefweak)
170+
&& (bfd_link_pic (info)
171+
|| WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))
172+
@@ -8088,7 +8128,7 @@
173+
}
174+
175+
indx = h && h->dynindx != -1 ? h->dynindx : 0;
176+
- if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
177+
+ if (((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT && !resolved_to_zero)
178+
|| h->root.type != bfd_link_hash_undefweak)
179+
&& (!bfd_link_executable (info)
180+
|| indx != 0
181+
@@ -8154,7 +8194,7 @@
182+
visibility. */
183+
if (eh->dyn_relocs != NULL && h->root.type == bfd_link_hash_undefweak)
184+
{
185+
- if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
186+
+ if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT || resolved_to_zero
187+
|| UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
188+
eh->dyn_relocs = NULL;
189+
190+
@@ -8174,7 +8214,9 @@
191+
symbols which turn out to need copy relocs or are not
192+
dynamic. */
193+
194+
- if (!h->non_got_ref
195+
+ if (!(h->non_got_ref
196+
+ || (h->root.type == bfd_link_hash_undefweak
197+
+ && !resolved_to_zero))
198+
&& ((h->def_dynamic
199+
&& !h->def_regular)
200+
|| (htab->root.dynamic_sections_created
201+
@@ -8185,6 +8227,7 @@
202+
Undefined weak syms won't yet be marked as dynamic. */
203+
if (h->dynindx == -1
204+
&& !h->forced_local
205+
+ && !resolved_to_zero
206+
&& h->root.type == bfd_link_hash_undefweak
207+
&& !bfd_elf_link_record_dynamic_symbol (info, h))
208+
return FALSE;
209+
@@ -8805,8 +8848,17 @@
210+
Elf_Internal_Sym *sym)
211+
{
212+
struct elf_aarch64_link_hash_table *htab;
213+
+ struct elf_aarch64_link_hash_entry *eh;
214+
+ bfd_boolean local_undefweak;
215+
htab = elf_aarch64_hash_table (info);
216+
217+
+ eh = (struct elf_aarch64_link_hash_entry *) h;
218+
+
219+
+ /* We keep PLT/GOT entries without dynamic PLT/GOT relocations for
220+
+ resolved undefined weak symbols in executable so that their
221+
+ references have value 0 at run-time. */
222+
+ local_undefweak = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh);
223+
+
224+
if (h->plt.offset != (bfd_vma) - 1)
225+
{
226+
asection *plt, *gotplt, *relplt;
227+
@@ -8841,7 +8893,7 @@
228+
return FALSE;
229+
230+
elfNN_aarch64_create_small_pltn_entry (h, htab, output_bfd, info);
231+
- if (!h->def_regular)
232+
+ if (!local_undefweak && !h->def_regular)
233+
{
234+
/* Mark the symbol as undefined, rather than as defined in
235+
the .plt section. */
236+
@@ -8860,10 +8912,11 @@
237+
}
238+
239+
if (h->got.offset != (bfd_vma) - 1
240+
- && elf_aarch64_hash_entry (h)->got_type == GOT_NORMAL
241+
+ && elf_aarch64_hash_entry (h)->got_type == GOT_NORMAL
242+
/* Undefined weak symbol in static PIE resolves to 0 without
243+
any dynamic relocations. */
244+
- && !UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
245+
+ && !UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)
246+
+ && !local_undefweak)
247+
{
248+
Elf_Internal_Rela rela;
249+
bfd_byte *loc;
250+
@@ -9357,6 +9410,9 @@
251+
#define elf_backend_init_index_section \
252+
_bfd_elf_init_2_index_sections
253+
254+
+#define elf_backend_fixup_symbol \
255+
+ elfNN_aarch64_elf_fixup_symbol
256+
+
257+
#define elf_backend_finish_dynamic_sections \
258+
elfNN_aarch64_finish_dynamic_sections
259+
260+
diff -NBaur binutils-2.30/ld/emulparams/aarch64elf32.sh binutils-2.30-dka64/ld/emulparams/aarch64elf32.sh
261+
--- binutils-2.30/ld/emulparams/aarch64elf32.sh 2018-01-13 13:31:16.000000000 +0000
262+
+++ binutils-2.30-dka64/ld/emulparams/aarch64elf32.sh 2018-02-11 19:48:08.997273556 +0000
263+
@@ -1,3 +1,5 @@
264+
+. ${srcdir}/emulparams/dynamic_undefined_weak.sh
265+
+
266+
ARCH="aarch64:ilp32"
267+
MACHINE=
268+
NOP=0
269+
diff -NBaur binutils-2.30/ld/emulparams/aarch64elf.sh binutils-2.30-dka64/ld/emulparams/aarch64elf.sh
270+
--- binutils-2.30/ld/emulparams/aarch64elf.sh 2018-01-13 13:31:16.000000000 +0000
271+
+++ binutils-2.30-dka64/ld/emulparams/aarch64elf.sh 2018-02-11 19:48:09.009273555 +0000
272+
@@ -1,3 +1,5 @@
273+
+. ${srcdir}/emulparams/dynamic_undefined_weak.sh
274+
+
275+
ARCH=aarch64
276+
MACHINE=
277+
NOP=0
278+
diff -NBaur binutils-2.30/ld/emultempl/aarch64elf.em binutils-2.30-dka64/ld/emultempl/aarch64elf.em
279+
--- binutils-2.30/ld/emultempl/aarch64elf.em 2018-01-13 13:31:16.000000000 +0000
280+
+++ binutils-2.30-dka64/ld/emultempl/aarch64elf.em 2018-02-11 19:48:09.009273555 +0000
281+
@@ -378,7 +378,7 @@
282+
{ "no-apply-dynamic-relocs", no_argument, NULL, OPTION_NO_APPLY_DYNAMIC_RELOCS},
283+
'
284+
285+
-PARSE_AND_LIST_OPTIONS='
286+
+PARSE_AND_LIST_OPTIONS=${PARSE_AND_LIST_OPTIONS}'
287+
fprintf (file, _(" --no-enum-size-warning Don'\''t warn about objects with incompatible\n"
288+
" enum sizes\n"));
289+
fprintf (file, _(" --no-wchar-size-warning Don'\''t warn about objects with incompatible"
290+
diff -NBaur binutils-2.30/ld/Makefile.am binutils-2.30-dka64/ld/Makefile.am
291+
--- binutils-2.30/ld/Makefile.am 2018-01-13 13:31:16.000000000 +0000
292+
+++ binutils-2.30-dka64/ld/Makefile.am 2018-02-11 19:48:09.021273555 +0000
293+
@@ -1654,19 +1654,23 @@
294+
$(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
295+
296+
eaarch64elf.c: $(srcdir)/emulparams/aarch64elf.sh \
297+
- $(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em \
298+
+ $(srcdir)/emulparams/dynamic_undefined_weak.sh \
299+
+ $(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em ldemul-list.h \
300+
$(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
301+
302+
eaarch64elf32.c: $(srcdir)/emulparams/aarch64elf32.sh \
303+
- $(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em \
304+
+ $(srcdir)/emulparams/dynamic_undefined_weak.sh \
305+
+ $(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em ldemul-list.h \
306+
$(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
307+
308+
eaarch64elfb.c: $(srcdir)/emulparams/aarch64elfb.sh $(srcdir)/emulparams/aarch64elf.sh \
309+
- $(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em \
310+
+ $(srcdir)/emulparams/dynamic_undefined_weak.sh \
311+
+ $(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em ldemul-list.h \
312+
$(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
313+
314+
eaarch64elf32b.c: $(srcdir)/emulparams/aarch64elf32b.sh $(srcdir)/emulparams/aarch64elf32.sh \
315+
- $(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em \
316+
+ $(srcdir)/emulparams/dynamic_undefined_weak.sh \
317+
+ $(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em ldemul-list.h \
318+
$(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
319+
320+
eaarch64cloudabi.c: $(srcdir)/emulparams/aarch64cloudabi.sh \
321+
diff -NBaur binutils-2.30/ld/Makefile.in binutils-2.30-dka64/ld/Makefile.in
322+
--- binutils-2.30/ld/Makefile.in 2018-01-27 15:03:10.000000000 +0000
323+
+++ binutils-2.30-dka64/ld/Makefile.in 2018-02-11 19:48:09.037273554 +0000
324+
@@ -3219,18 +3219,22 @@
325+
326+
eaarch64elf.c: $(srcdir)/emulparams/aarch64elf.sh \
327+
$(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em \
328+
+ $(srcdir)/emulparams/dynamic_undefined_weak.sh \
329+
$(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
330+
331+
eaarch64elf32.c: $(srcdir)/emulparams/aarch64elf32.sh \
332+
$(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em \
333+
+ $(srcdir)/emulparams/dynamic_undefined_weak.sh \
334+
$(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
335+
336+
eaarch64elfb.c: $(srcdir)/emulparams/aarch64elfb.sh $(srcdir)/emulparams/aarch64elf.sh \
337+
$(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em \
338+
+ $(srcdir)/emulparams/dynamic_undefined_weak.sh \
339+
$(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
340+
341+
eaarch64elf32b.c: $(srcdir)/emulparams/aarch64elf32b.sh $(srcdir)/emulparams/aarch64elf32.sh \
342+
$(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em \
343+
+ $(srcdir)/emulparams/dynamic_undefined_weak.sh \
344+
$(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
345+
346+
eaarch64cloudabi.c: $(srcdir)/emulparams/aarch64cloudabi.sh \

dka64/scripts/build-gcc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ then
6262
--prefix=$prefix \
6363
--enable-lto $plugin_ld\
6464
--with-system-zlib \
65-
--with-bugurl="https://github.com/devkitPro/buildscripts/issues" --with-pkgversion="devkitA64 alpha 6" \
65+
--with-bugurl="https://github.com/devkitPro/buildscripts/issues" --with-pkgversion="devkitA64 alpha 7" \
6666
$CROSS_PARAMS \
6767
|| { echo "Error configuring gcc"; exit 1; }
6868
touch configured-gcc

select_toolchain.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ case "$VERSION" in
5252
;;
5353
"3" )
5454
GCC_VER=7.3.0
55-
BINUTILS_VER=2.29.1
55+
BINUTILS_VER=2.30
5656
NEWLIB_VER=3.0.0
5757
GDB_VER=8.0
5858
basedir='dka64'

0 commit comments

Comments
 (0)