toolchain: binutils: backport patch to fix mipsel_24kc_24kf
[openwrt/staging/nbd.git] / toolchain / binutils / patches / 2.42 / 001-PR-30569-always-call-elf_backend_size_dynamic_sectio.patch
1 From af969b14aedcc0ae27dcefab4327ff2d153dec8b Mon Sep 17 00:00:00 2001
2 From: Alan Modra <amodra@gmail.com>
3 Date: Thu, 28 Mar 2024 19:25:42 +1030
4 Subject: [PATCH 1/2] PR 30569, always call elf_backend_size_dynamic_sections
5
6 This largely mechanical patch is preparation for a followup patch.
7
8 For quite some time I've thought that it would be useful to call
9 elf_backend_size_dynamic_sections even when no dynamic objects are
10 seen by the linker. That's what this patch does, with some renaming.
11 There are no functional changes to the linker, just a move of the
12 dynobj test in bfd_elf_size_dynamic_sections to target backend
13 functions, replacing the asserts/aborts already there. No doubt some
14 of the current always_size_sections functions could be moved to
15 size_dynamic_sections but I haven't made that change.
16
17 Because both hooks are now always called, I have renamed
18 always_size_sections to early_size_sections and size_dynamic_sections
19 to late_size_sections. I condisdered calling late_size_sections plain
20 size_sections, since this is the usual target dynamic section sizing
21 hook, but decided that searching the sources for "size_sections" would
22 then hit early_size_sections and other functions.
23 ---
24 bfd/elf-bfd.h | 35 +++++++++++++++++------------------
25 bfd/elf-m10300.c | 11 ++++++-----
26 bfd/elf32-arc.c | 9 +++++----
27 bfd/elf32-arm.c | 15 ++++++++-------
28 bfd/elf32-bfin.c | 31 ++++++++++++++++---------------
29 bfd/elf32-cr16.c | 11 ++++++-----
30 bfd/elf32-cris.c | 13 +++++++------
31 bfd/elf32-csky.c | 8 ++++----
32 bfd/elf32-frv.c | 23 ++++++++++++-----------
33 bfd/elf32-hppa.c | 8 ++++----
34 bfd/elf32-i386.c | 7 +++----
35 bfd/elf32-lm32.c | 15 ++++++++-------
36 bfd/elf32-m32c.c | 8 ++++----
37 bfd/elf32-m32r.c | 11 ++++++-----
38 bfd/elf32-m68k.c | 16 ++++++++--------
39 bfd/elf32-metag.c | 8 ++++----
40 bfd/elf32-microblaze.c | 9 +++++----
41 bfd/elf32-mips.c | 6 ++----
42 bfd/elf32-nds32.c | 9 +++++----
43 bfd/elf32-nios2.c | 15 ++++++++-------
44 bfd/elf32-or1k.c | 9 +++++----
45 bfd/elf32-ppc.c | 11 ++++++-----
46 bfd/elf32-rl78.c | 8 ++++----
47 bfd/elf32-s390.c | 10 +++++-----
48 bfd/elf32-score.c | 35 ++++++++++++++++++-----------------
49 bfd/elf32-score.h | 4 ++--
50 bfd/elf32-score7.c | 13 +++++++------
51 bfd/elf32-sh.c | 15 +++++++--------
52 bfd/elf32-sparc.c | 3 +--
53 bfd/elf32-tic6x.c | 14 +++++++-------
54 bfd/elf32-tilegx.c | 2 +-
55 bfd/elf32-tilepro.c | 11 +++++------
56 bfd/elf32-vax.c | 16 +++++++---------
57 bfd/elf32-xstormy16.c | 8 ++++----
58 bfd/elf32-xtensa.c | 13 ++++++-------
59 bfd/elf64-alpha.c | 19 ++++++++++---------
60 bfd/elf64-hppa.c | 11 ++++-------
61 bfd/elf64-ia64-vms.c | 13 +++++++------
62 bfd/elf64-mips.c | 8 ++++----
63 bfd/elf64-ppc.c | 12 ++++++------
64 bfd/elf64-s390.c | 10 +++++-----
65 bfd/elf64-sparc.c | 4 ++--
66 bfd/elf64-tilegx.c | 2 +-
67 bfd/elf64-x86-64.c | 7 +++----
68 bfd/elflink.c | 9 ++++-----
69 bfd/elfn32-mips.c | 6 ++----
70 bfd/elfnn-aarch64.c | 21 +++++++++++----------
71 bfd/elfnn-ia64.c | 11 ++++++-----
72 bfd/elfnn-kvx.c | 19 +++++++++----------
73 bfd/elfnn-loongarch.c | 9 +++++----
74 bfd/elfnn-riscv.c | 7 ++++---
75 bfd/elfxx-mips.c | 15 ++++++++-------
76 bfd/elfxx-mips.h | 4 ++--
77 bfd/elfxx-sparc.c | 7 ++++---
78 bfd/elfxx-sparc.h | 2 +-
79 bfd/elfxx-target.h | 12 ++++++------
80 bfd/elfxx-tilegx.c | 7 ++++---
81 bfd/elfxx-tilegx.h | 2 +-
82 bfd/elfxx-x86.c | 8 ++++----
83 bfd/elfxx-x86.h | 8 ++++----
84 ld/emultempl/vms.em | 7 +++----
85 61 files changed, 343 insertions(+), 337 deletions(-)
86
87 --- a/bfd/elf-bfd.h
88 +++ b/bfd/elf-bfd.h
89 @@ -1187,7 +1187,7 @@ struct elf_backend_data
90 /* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend
91 linker for every symbol which is defined by a dynamic object and
92 referenced by a regular object. This is called after all the
93 - input files have been seen, but before the SIZE_DYNAMIC_SECTIONS
94 + input files have been seen, but before the LATE_SIZE_SECTIONS
95 function has been called. The hash table entry should be
96 bfd_link_hash_defined ore bfd_link_hash_defweak, and it should be
97 defined in a section from a dynamic object. Dynamic object
98 @@ -1199,24 +1199,23 @@ struct elf_backend_data
99 bool (*elf_backend_adjust_dynamic_symbol)
100 (struct bfd_link_info *info, struct elf_link_hash_entry *h);
101
102 - /* The ALWAYS_SIZE_SECTIONS function is called by the backend linker
103 - after all the linker input files have been seen but before the
104 - section sizes have been set. This is called after
105 - ADJUST_DYNAMIC_SYMBOL, but before SIZE_DYNAMIC_SECTIONS. */
106 - bool (*elf_backend_always_size_sections)
107 + /* The EARLY_SIZE_SECTIONS and LATE_SIZE_SECTIONS functions are
108 + called by the backend linker after all linker input files have
109 + been seen and sections have been assigned to output sections, but
110 + before the section sizes have been set. Both of these functions
111 + are called even when no dynamic object is seen by the linker.
112 + Between them, they must set the sizes of the dynamic sections and
113 + other backend specific sections, and may fill in their contents.
114 + Most backends need only use LATE_SIZE_SECTIONS.
115 + EARLY_SIZE_SECTIONS is called before --export-dynamic makes some
116 + symbols dynamic and before ADJUST_DYNAMIC_SYMBOL processes
117 + dynamic symbols, LATE_SIZE_SECTIONS afterwards. The generic ELF
118 + linker can handle the .dynsym, .dynstr and .hash sections.
119 + Besides those, these functions must handle the .interp section
120 + and any other sections created by CREATE_DYNAMIC_SECTIONS. */
121 + bool (*elf_backend_early_size_sections)
122 (bfd *output_bfd, struct bfd_link_info *info);
123 -
124 - /* The SIZE_DYNAMIC_SECTIONS function is called by the ELF backend
125 - linker after all the linker input files have been seen but before
126 - the sections sizes have been set. This is called after
127 - ADJUST_DYNAMIC_SYMBOL has been called on all appropriate symbols.
128 - It is only called when linking against a dynamic object. It must
129 - set the sizes of the dynamic sections, and may fill in their
130 - contents as well. The generic ELF linker can handle the .dynsym,
131 - .dynstr and .hash sections. This function must handle the
132 - .interp section and any sections created by the
133 - CREATE_DYNAMIC_SECTIONS entry point. */
134 - bool (*elf_backend_size_dynamic_sections)
135 + bool (*elf_backend_late_size_sections)
136 (bfd *output_bfd, struct bfd_link_info *info);
137
138 /* The STRIP_ZERO_SIZED_DYNAMIC_SECTIONS function is called by the
139 --- a/bfd/elf-m10300.c
140 +++ b/bfd/elf-m10300.c
141 @@ -5015,8 +5015,8 @@ _bfd_mn10300_elf_adjust_dynamic_symbol (
142 /* Set the sizes of the dynamic sections. */
143
144 static bool
145 -_bfd_mn10300_elf_size_dynamic_sections (bfd * output_bfd,
146 - struct bfd_link_info * info)
147 +_bfd_mn10300_elf_late_size_sections (bfd * output_bfd,
148 + struct bfd_link_info * info)
149 {
150 struct elf32_mn10300_link_hash_table *htab = elf32_mn10300_hash_table (info);
151 bfd * dynobj;
152 @@ -5024,7 +5024,8 @@ _bfd_mn10300_elf_size_dynamic_sections (
153 bool relocs;
154
155 dynobj = htab->root.dynobj;
156 - BFD_ASSERT (dynobj != NULL);
157 + if (dynobj == NULL)
158 + return true;
159
160 if (elf_hash_table (info)->dynamic_sections_created)
161 {
162 @@ -5511,8 +5512,8 @@ mn10300_elf_mkobject (bfd *abfd)
163 _bfd_mn10300_elf_create_dynamic_sections
164 #define elf_backend_adjust_dynamic_symbol \
165 _bfd_mn10300_elf_adjust_dynamic_symbol
166 -#define elf_backend_size_dynamic_sections \
167 - _bfd_mn10300_elf_size_dynamic_sections
168 +#define elf_backend_late_size_sections \
169 + _bfd_mn10300_elf_late_size_sections
170 #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all
171 #define elf_backend_finish_dynamic_symbol \
172 _bfd_mn10300_elf_finish_dynamic_symbol
173 --- a/bfd/elf32-arc.c
174 +++ b/bfd/elf32-arc.c
175 @@ -2715,8 +2715,8 @@ elf_arc_finish_dynamic_sections (bfd * o
176
177 /* Set the sizes of the dynamic sections. */
178 static bool
179 -elf_arc_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
180 - struct bfd_link_info *info)
181 +elf_arc_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
182 + struct bfd_link_info *info)
183 {
184 bfd *dynobj;
185 asection *s;
186 @@ -2724,7 +2724,8 @@ elf_arc_size_dynamic_sections (bfd *outp
187 struct elf_link_hash_table *htab = elf_hash_table (info);
188
189 dynobj = htab->dynobj;
190 - BFD_ASSERT (dynobj != NULL);
191 + if (dynobj == NULL)
192 + return true;
193
194 if (htab->dynamic_sections_created)
195 {
196 @@ -3140,7 +3141,7 @@ arc_elf_relax_section (bfd *abfd, asecti
197 #define elf_backend_finish_dynamic_symbol elf_arc_finish_dynamic_symbol
198
199 #define elf_backend_finish_dynamic_sections elf_arc_finish_dynamic_sections
200 -#define elf_backend_size_dynamic_sections elf_arc_size_dynamic_sections
201 +#define elf_backend_late_size_sections elf_arc_late_size_sections
202
203 #define elf_backend_can_gc_sections 1
204 #define elf_backend_want_got_plt 1
205 --- a/bfd/elf32-arm.c
206 +++ b/bfd/elf32-arm.c
207 @@ -16752,8 +16752,8 @@ bfd_elf32_arm_set_byteswap_code (struct
208 /* Set the sizes of the dynamic sections. */
209
210 static bool
211 -elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED,
212 - struct bfd_link_info * info)
213 +elf32_arm_late_size_sections (bfd * output_bfd ATTRIBUTE_UNUSED,
214 + struct bfd_link_info * info)
215 {
216 bfd * dynobj;
217 asection * s;
218 @@ -16766,7 +16766,9 @@ elf32_arm_size_dynamic_sections (bfd * o
219 return false;
220
221 dynobj = elf_hash_table (info)->dynobj;
222 - BFD_ASSERT (dynobj != NULL);
223 + if (dynobj == NULL)
224 + return true;
225 +
226 check_use_blx (htab);
227
228 if (elf_hash_table (info)->dynamic_sections_created)
229 @@ -17138,8 +17140,7 @@ elf32_arm_size_dynamic_sections (bfd * o
230 _TLS_MODULE_BASE_, if needed. */
231
232 static bool
233 -elf32_arm_always_size_sections (bfd *output_bfd,
234 - struct bfd_link_info *info)
235 +elf32_arm_early_size_sections (bfd *output_bfd, struct bfd_link_info *info)
236 {
237 asection *tls_sec;
238 struct elf32_arm_link_hash_table *htab;
239 @@ -20341,8 +20342,8 @@ elf32_arm_backend_symbol_processing (bfd
240 #define elf_backend_create_dynamic_sections elf32_arm_create_dynamic_sections
241 #define elf_backend_finish_dynamic_symbol elf32_arm_finish_dynamic_symbol
242 #define elf_backend_finish_dynamic_sections elf32_arm_finish_dynamic_sections
243 -#define elf_backend_size_dynamic_sections elf32_arm_size_dynamic_sections
244 -#define elf_backend_always_size_sections elf32_arm_always_size_sections
245 +#define elf_backend_late_size_sections elf32_arm_late_size_sections
246 +#define elf_backend_early_size_sections elf32_arm_early_size_sections
247 #define elf_backend_init_index_section _bfd_elf_init_2_index_sections
248 #define elf_backend_init_file_header elf32_arm_init_file_header
249 #define elf_backend_reloc_type_class elf32_arm_reloc_type_class
250 --- a/bfd/elf32-bfin.c
251 +++ b/bfd/elf32-bfin.c
252 @@ -4027,8 +4027,8 @@ _bfinfdpic_size_got_plt (bfd *output_bfd
253 /* Set the sizes of the dynamic sections. */
254
255 static bool
256 -elf32_bfinfdpic_size_dynamic_sections (bfd *output_bfd,
257 - struct bfd_link_info *info)
258 +elf32_bfinfdpic_late_size_sections (bfd *output_bfd,
259 + struct bfd_link_info *info)
260 {
261 struct elf_link_hash_table *htab;
262 bfd *dynobj;
263 @@ -4037,7 +4037,8 @@ elf32_bfinfdpic_size_dynamic_sections (b
264
265 htab = elf_hash_table (info);
266 dynobj = htab->dynobj;
267 - BFD_ASSERT (dynobj != NULL);
268 + if (dynobj == NULL)
269 + return true;
270
271 if (htab->dynamic_sections_created)
272 {
273 @@ -4086,7 +4087,7 @@ elf32_bfinfdpic_size_dynamic_sections (b
274 }
275
276 static bool
277 -elf32_bfinfdpic_always_size_sections (bfd *output_bfd,
278 +elf32_bfinfdpic_early_size_sections (bfd *output_bfd,
279 struct bfd_link_info *info)
280 {
281 if (!bfd_link_relocatable (info)
282 @@ -5123,15 +5124,16 @@ bfin_discard_copies (struct elf_link_has
283 }
284
285 static bool
286 -bfin_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED,
287 - struct bfd_link_info *info)
288 +bfin_late_size_sections (bfd * output_bfd ATTRIBUTE_UNUSED,
289 + struct bfd_link_info *info)
290 {
291 bfd *dynobj;
292 asection *s;
293 bool relocs;
294
295 dynobj = elf_hash_table (info)->dynobj;
296 - BFD_ASSERT (dynobj != NULL);
297 + if (dynobj == NULL)
298 + return true;
299
300 if (elf_hash_table (info)->dynamic_sections_created)
301 {
302 @@ -5423,8 +5425,7 @@ struct bfd_elf_special_section const elf
303 #define elf_backend_check_relocs bfin_check_relocs
304 #define elf_backend_adjust_dynamic_symbol \
305 bfin_adjust_dynamic_symbol
306 -#define elf_backend_size_dynamic_sections \
307 - bfin_size_dynamic_sections
308 +#define elf_backend_late_size_sections bfin_late_size_sections
309 #define elf_backend_relocate_section bfin_relocate_section
310 #define elf_backend_finish_dynamic_symbol \
311 bfin_finish_dynamic_symbol
312 @@ -5470,9 +5471,9 @@ struct bfd_elf_special_section const elf
313 #undef bfd_elf32_bfd_link_hash_table_create
314 #define bfd_elf32_bfd_link_hash_table_create \
315 bfinfdpic_elf_link_hash_table_create
316 -#undef elf_backend_always_size_sections
317 -#define elf_backend_always_size_sections \
318 - elf32_bfinfdpic_always_size_sections
319 +#undef elf_backend_early_size_sections
320 +#define elf_backend_early_size_sections \
321 + elf32_bfinfdpic_early_size_sections
322
323 #undef elf_backend_create_dynamic_sections
324 #define elf_backend_create_dynamic_sections \
325 @@ -5480,9 +5481,9 @@ struct bfd_elf_special_section const elf
326 #undef elf_backend_adjust_dynamic_symbol
327 #define elf_backend_adjust_dynamic_symbol \
328 elf32_bfinfdpic_adjust_dynamic_symbol
329 -#undef elf_backend_size_dynamic_sections
330 -#define elf_backend_size_dynamic_sections \
331 - elf32_bfinfdpic_size_dynamic_sections
332 +#undef elf_backend_late_size_sections
333 +#define elf_backend_late_size_sections \
334 + elf32_bfinfdpic_late_size_sections
335 #undef elf_backend_finish_dynamic_symbol
336 #define elf_backend_finish_dynamic_symbol \
337 elf32_bfinfdpic_finish_dynamic_symbol
338 --- a/bfd/elf32-cr16.c
339 +++ b/bfd/elf32-cr16.c
340 @@ -2391,15 +2391,16 @@ _bfd_cr16_elf_adjust_dynamic_symbol (str
341 /* Set the sizes of the dynamic sections. */
342
343 static bool
344 -_bfd_cr16_elf_size_dynamic_sections (bfd * output_bfd,
345 - struct bfd_link_info * info)
346 +_bfd_cr16_elf_late_size_sections (bfd * output_bfd,
347 + struct bfd_link_info * info)
348 {
349 bfd * dynobj;
350 asection * s;
351 bool relocs;
352
353 dynobj = elf_hash_table (info)->dynobj;
354 - BFD_ASSERT (dynobj != NULL);
355 + if (dynobj == NULL)
356 + return true;
357
358 if (elf_hash_table (info)->dynamic_sections_created)
359 {
360 @@ -2836,8 +2837,8 @@ _bfd_cr16_elf_reloc_type_class (const st
361 _bfd_cr16_elf_create_dynamic_sections
362 #define elf_backend_adjust_dynamic_symbol \
363 _bfd_cr16_elf_adjust_dynamic_symbol
364 -#define elf_backend_size_dynamic_sections \
365 - _bfd_cr16_elf_size_dynamic_sections
366 +#define elf_backend_late_size_sections \
367 + _bfd_cr16_elf_late_size_sections
368 #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all
369 #define elf_backend_finish_dynamic_symbol \
370 _bfd_cr16_elf_finish_dynamic_symbol
371 --- a/bfd/elf32-cris.c
372 +++ b/bfd/elf32-cris.c
373 @@ -2527,7 +2527,7 @@ cris_elf_plt_sym_val (bfd_vma i ATTRIBUT
374 entry but we found we will not create any. Called when we find we will
375 not have any PLT for this symbol, by for example
376 elf_cris_adjust_dynamic_symbol when we're doing a proper dynamic link,
377 - or elf_cris_size_dynamic_sections if no dynamic sections will be
378 + or elf_cris_late_size_sections if no dynamic sections will be
379 created (we're only linking static objects). */
380
381 static bool
382 @@ -3508,8 +3508,8 @@ cris_elf_check_relocs (bfd *abfd,
383 /* Set the sizes of the dynamic sections. */
384
385 static bool
386 -elf_cris_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
387 - struct bfd_link_info *info)
388 +elf_cris_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
389 + struct bfd_link_info *info)
390 {
391 struct elf_cris_link_hash_table * htab;
392 bfd *dynobj;
393 @@ -3521,7 +3521,8 @@ elf_cris_size_dynamic_sections (bfd *out
394 return false;
395
396 dynobj = htab->root.dynobj;
397 - BFD_ASSERT (dynobj != NULL);
398 + if (dynobj == NULL)
399 + return true;
400
401 if (htab->root.dynamic_sections_created)
402 {
403 @@ -4090,8 +4091,8 @@ elf_cris_got_elt_size (bfd *abfd ATTRIBU
404 elf_cris_adjust_dynamic_symbol
405 #define elf_backend_copy_indirect_symbol \
406 elf_cris_copy_indirect_symbol
407 -#define elf_backend_size_dynamic_sections \
408 - elf_cris_size_dynamic_sections
409 +#define elf_backend_late_size_sections \
410 + elf_cris_late_size_sections
411 #define elf_backend_init_index_section _bfd_elf_init_1_index_section
412 #define elf_backend_finish_dynamic_symbol \
413 elf_cris_finish_dynamic_symbol
414 --- a/bfd/elf32-csky.c
415 +++ b/bfd/elf32-csky.c
416 @@ -1893,8 +1893,8 @@ csky_allocate_dynrelocs (struct elf_link
417 /* Set the sizes of the dynamic sections. */
418
419 static bool
420 -csky_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
421 - struct bfd_link_info *info)
422 +csky_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
423 + struct bfd_link_info *info)
424 {
425 struct csky_elf_link_hash_table *htab;
426 bfd *dynobj;
427 @@ -1907,7 +1907,7 @@ csky_elf_size_dynamic_sections (bfd *out
428 return false;
429 dynobj = htab->elf.dynobj;
430 if (dynobj == NULL)
431 - return false;
432 + return true;
433
434 if (htab->elf.dynamic_sections_created)
435 {
436 @@ -5333,7 +5333,7 @@ elf32_csky_obj_attrs_handle_unknown (bfd
437 /* Dynamic relocate related API. */
438 #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections
439 #define elf_backend_adjust_dynamic_symbol csky_elf_adjust_dynamic_symbol
440 -#define elf_backend_size_dynamic_sections csky_elf_size_dynamic_sections
441 +#define elf_backend_late_size_sections csky_elf_late_size_sections
442 #define elf_backend_finish_dynamic_symbol csky_elf_finish_dynamic_symbol
443 #define elf_backend_finish_dynamic_sections csky_elf_finish_dynamic_sections
444 #define elf_backend_rela_normal 1
445 --- a/bfd/elf32-frv.c
446 +++ b/bfd/elf32-frv.c
447 @@ -5423,15 +5423,16 @@ _frvfdpic_size_got_plt (bfd *output_bfd,
448 /* Set the sizes of the dynamic sections. */
449
450 static bool
451 -elf32_frvfdpic_size_dynamic_sections (bfd *output_bfd,
452 - struct bfd_link_info *info)
453 +elf32_frvfdpic_late_size_sections (bfd *output_bfd,
454 + struct bfd_link_info *info)
455 {
456 bfd *dynobj;
457 asection *s;
458 struct _frvfdpic_dynamic_got_plt_info gpinfo;
459
460 dynobj = elf_hash_table (info)->dynobj;
461 - BFD_ASSERT (dynobj != NULL);
462 + if (dynobj == NULL)
463 + return true;
464
465 if (elf_hash_table (info)->dynamic_sections_created)
466 {
467 @@ -5472,8 +5473,8 @@ elf32_frvfdpic_size_dynamic_sections (bf
468 }
469
470 static bool
471 -elf32_frvfdpic_always_size_sections (bfd *output_bfd,
472 - struct bfd_link_info *info)
473 +elf32_frvfdpic_early_size_sections (bfd *output_bfd,
474 + struct bfd_link_info *info)
475 {
476 if (!bfd_link_relocatable (info)
477 && !bfd_elf_stack_segment_size (output_bfd, info,
478 @@ -6817,9 +6818,9 @@ elf32_frv_grok_psinfo (bfd *abfd, Elf_In
479 #undef bfd_elf32_bfd_link_hash_table_create
480 #define bfd_elf32_bfd_link_hash_table_create \
481 frvfdpic_elf_link_hash_table_create
482 -#undef elf_backend_always_size_sections
483 -#define elf_backend_always_size_sections \
484 - elf32_frvfdpic_always_size_sections
485 +#undef elf_backend_early_size_sections
486 +#define elf_backend_early_size_sections \
487 + elf32_frvfdpic_early_size_sections
488
489 #undef elf_backend_create_dynamic_sections
490 #define elf_backend_create_dynamic_sections \
491 @@ -6827,9 +6828,9 @@ elf32_frv_grok_psinfo (bfd *abfd, Elf_In
492 #undef elf_backend_adjust_dynamic_symbol
493 #define elf_backend_adjust_dynamic_symbol \
494 elf32_frvfdpic_adjust_dynamic_symbol
495 -#undef elf_backend_size_dynamic_sections
496 -#define elf_backend_size_dynamic_sections \
497 - elf32_frvfdpic_size_dynamic_sections
498 +#undef elf_backend_late_size_sections
499 +#define elf_backend_late_size_sections \
500 + elf32_frvfdpic_late_size_sections
501 #undef bfd_elf32_bfd_relax_section
502 #define bfd_elf32_bfd_relax_section \
503 elf32_frvfdpic_relax_section
504 --- a/bfd/elf32-hppa.c
505 +++ b/bfd/elf32-hppa.c
506 @@ -2042,8 +2042,8 @@ clobber_millicode_symbols (struct elf_li
507 /* Set the sizes of the dynamic sections. */
508
509 static bool
510 -elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
511 - struct bfd_link_info *info)
512 +elf32_hppa_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
513 + struct bfd_link_info *info)
514 {
515 struct elf32_hppa_link_hash_table *htab;
516 bfd *dynobj;
517 @@ -2057,7 +2057,7 @@ elf32_hppa_size_dynamic_sections (bfd *o
518
519 dynobj = htab->etab.dynobj;
520 if (dynobj == NULL)
521 - abort ();
522 + return true;
523
524 if (htab->etab.dynamic_sections_created)
525 {
526 @@ -4452,7 +4452,7 @@ elf32_hppa_elf_get_symbol_type (Elf_Inte
527 #define elf_backend_hide_symbol elf32_hppa_hide_symbol
528 #define elf_backend_finish_dynamic_symbol elf32_hppa_finish_dynamic_symbol
529 #define elf_backend_finish_dynamic_sections elf32_hppa_finish_dynamic_sections
530 -#define elf_backend_size_dynamic_sections elf32_hppa_size_dynamic_sections
531 +#define elf_backend_late_size_sections elf32_hppa_late_size_sections
532 #define elf_backend_init_index_section _bfd_elf_init_1_index_section
533 #define elf_backend_gc_mark_hook elf32_hppa_gc_mark_hook
534 #define elf_backend_grok_prstatus elf32_hppa_grok_prstatus
535 --- a/bfd/elf32-i386.c
536 +++ b/bfd/elf32-i386.c
537 @@ -1957,8 +1957,7 @@ elf_i386_scan_relocs (bfd *abfd,
538 }
539
540 static bool
541 -elf_i386_always_size_sections (bfd *output_bfd,
542 - struct bfd_link_info *info)
543 +elf_i386_early_size_sections (bfd *output_bfd, struct bfd_link_info *info)
544 {
545 bfd *abfd;
546
547 @@ -1971,7 +1970,7 @@ elf_i386_always_size_sections (bfd *outp
548 elf_i386_scan_relocs))
549 return false;
550
551 - return _bfd_x86_elf_always_size_sections (output_bfd, info);
552 + return _bfd_x86_elf_early_size_sections (output_bfd, info);
553 }
554
555 /* Set the correct type for an x86 ELF section. We do this by the
556 @@ -4479,7 +4478,7 @@ elf_i386_link_setup_gnu_properties (stru
557 #define bfd_elf32_get_synthetic_symtab elf_i386_get_synthetic_symtab
558
559 #define elf_backend_relocs_compatible _bfd_elf_relocs_compatible
560 -#define elf_backend_always_size_sections elf_i386_always_size_sections
561 +#define elf_backend_early_size_sections elf_i386_early_size_sections
562 #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections
563 #define elf_backend_fake_sections elf_i386_fake_sections
564 #define elf_backend_finish_dynamic_sections elf_i386_finish_dynamic_sections
565 --- a/bfd/elf32-lm32.c
566 +++ b/bfd/elf32-lm32.c
567 @@ -1906,8 +1906,8 @@ allocate_dynrelocs (struct elf_link_hash
568 /* Set the sizes of the dynamic sections. */
569
570 static bool
571 -lm32_elf_size_dynamic_sections (bfd *output_bfd,
572 - struct bfd_link_info *info)
573 +lm32_elf_late_size_sections (bfd *output_bfd,
574 + struct bfd_link_info *info)
575 {
576 struct elf_lm32_link_hash_table *htab;
577 bfd *dynobj;
578 @@ -1920,7 +1920,8 @@ lm32_elf_size_dynamic_sections (bfd *out
579 return false;
580
581 dynobj = htab->root.dynobj;
582 - BFD_ASSERT (dynobj != NULL);
583 + if (dynobj == NULL)
584 + return true;
585
586 if (htab->root.dynamic_sections_created)
587 {
588 @@ -2309,7 +2310,7 @@ lm32_elf_create_dynamic_sections (bfd *a
589 }
590
591 static bool
592 -lm32_elf_always_size_sections (bfd *output_bfd, struct bfd_link_info *info)
593 +lm32_elf_early_size_sections (bfd *output_bfd, struct bfd_link_info *info)
594 {
595 if (!bfd_link_relocatable (info))
596 {
597 @@ -2395,7 +2396,7 @@ lm32_elf_fdpic_copy_private_bfd_data (bf
598 #define bfd_elf32_bfd_link_hash_table_create lm32_elf_link_hash_table_create
599 #define elf_backend_check_relocs lm32_elf_check_relocs
600 #define elf_backend_reloc_type_class lm32_elf_reloc_type_class
601 -#define elf_backend_size_dynamic_sections lm32_elf_size_dynamic_sections
602 +#define elf_backend_late_size_sections lm32_elf_late_size_sections
603 #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all
604 #define elf_backend_create_dynamic_sections lm32_elf_create_dynamic_sections
605 #define elf_backend_finish_dynamic_sections lm32_elf_finish_dynamic_sections
606 @@ -2416,8 +2417,8 @@ lm32_elf_fdpic_copy_private_bfd_data (bf
607 #undef elf32_bed
608 #define elf32_bed elf32_lm32fdpic_bed
609
610 -#undef elf_backend_always_size_sections
611 -#define elf_backend_always_size_sections lm32_elf_always_size_sections
612 +#undef elf_backend_early_size_sections
613 +#define elf_backend_early_size_sections lm32_elf_early_size_sections
614 #undef bfd_elf32_bfd_copy_private_bfd_data
615 #define bfd_elf32_bfd_copy_private_bfd_data lm32_elf_fdpic_copy_private_bfd_data
616
617 --- a/bfd/elf32-m32c.c
618 +++ b/bfd/elf32-m32c.c
619 @@ -773,8 +773,8 @@ m32c_elf_finish_dynamic_sections (bfd *a
620 }
621
622 static bool
623 -m32c_elf_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
624 - struct bfd_link_info *info)
625 +m32c_elf_early_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
626 + struct bfd_link_info *info)
627 {
628 bfd *dynobj;
629 asection *splt;
630 @@ -2132,8 +2132,8 @@ _bfd_m32c_elf_eh_frame_address_size (bfd
631 #define elf_backend_check_relocs m32c_elf_check_relocs
632 #define elf_backend_object_p m32c_elf_object_p
633 #define elf_symbol_leading_char ('_')
634 -#define elf_backend_always_size_sections \
635 - m32c_elf_always_size_sections
636 +#define elf_backend_early_size_sections \
637 + m32c_elf_early_size_sections
638 #define elf_backend_finish_dynamic_sections \
639 m32c_elf_finish_dynamic_sections
640
641 --- a/bfd/elf32-m32r.c
642 +++ b/bfd/elf32-m32r.c
643 @@ -1958,8 +1958,8 @@ allocate_dynrelocs (struct elf_link_hash
644 /* Set the sizes of the dynamic sections. */
645
646 static bool
647 -m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
648 - struct bfd_link_info *info)
649 +m32r_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
650 + struct bfd_link_info *info)
651 {
652 struct elf_link_hash_table *htab;
653 bfd *dynobj;
654 @@ -1968,7 +1968,7 @@ m32r_elf_size_dynamic_sections (bfd *out
655 bfd *ibfd;
656
657 #ifdef DEBUG_PIC
658 - printf ("m32r_elf_size_dynamic_sections()\n");
659 + printf ("m32r_elf_late_size_sections()\n");
660 #endif
661
662 htab = m32r_elf_hash_table (info);
663 @@ -1976,7 +1976,8 @@ m32r_elf_size_dynamic_sections (bfd *out
664 return false;
665
666 dynobj = htab->dynobj;
667 - BFD_ASSERT (dynobj != NULL);
668 + if (dynobj == NULL)
669 + return true;
670
671 if (htab->dynamic_sections_created)
672 {
673 @@ -3658,7 +3659,7 @@ m32r_elf_reloc_type_class (const struct
674
675 #define elf_backend_create_dynamic_sections m32r_elf_create_dynamic_sections
676 #define bfd_elf32_bfd_link_hash_table_create m32r_elf_link_hash_table_create
677 -#define elf_backend_size_dynamic_sections m32r_elf_size_dynamic_sections
678 +#define elf_backend_late_size_sections m32r_elf_late_size_sections
679 #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all
680 #define elf_backend_finish_dynamic_sections m32r_elf_finish_dynamic_sections
681 #define elf_backend_adjust_dynamic_symbol m32r_elf_adjust_dynamic_symbol
682 --- a/bfd/elf32-m68k.c
683 +++ b/bfd/elf32-m68k.c
684 @@ -2934,7 +2934,7 @@ elf_m68k_get_plt_info (bfd *output_bfd)
685 It's a convenient place to determine the PLT style. */
686
687 static bool
688 -elf_m68k_always_size_sections (bfd *output_bfd, struct bfd_link_info *info)
689 +elf_m68k_early_size_sections (bfd *output_bfd, struct bfd_link_info *info)
690 {
691 /* Bind input BFDs to GOTs and calculate sizes of .got and .rela.got
692 sections. */
693 @@ -3107,15 +3107,16 @@ elf_m68k_adjust_dynamic_symbol (struct b
694 /* Set the sizes of the dynamic sections. */
695
696 static bool
697 -elf_m68k_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
698 - struct bfd_link_info *info)
699 +elf_m68k_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
700 + struct bfd_link_info *info)
701 {
702 bfd *dynobj;
703 asection *s;
704 bool relocs;
705
706 dynobj = elf_hash_table (info)->dynobj;
707 - BFD_ASSERT (dynobj != NULL);
708 + if (dynobj == NULL)
709 + return true;
710
711 if (elf_hash_table (info)->dynamic_sections_created)
712 {
713 @@ -4628,12 +4629,11 @@ elf_m68k_grok_psinfo (bfd *abfd, Elf_Int
714 #define bfd_elf32_bfd_final_link bfd_elf_final_link
715
716 #define elf_backend_check_relocs elf_m68k_check_relocs
717 -#define elf_backend_always_size_sections \
718 - elf_m68k_always_size_sections
719 +#define elf_backend_early_size_sections \
720 + elf_m68k_early_size_sections
721 #define elf_backend_adjust_dynamic_symbol \
722 elf_m68k_adjust_dynamic_symbol
723 -#define elf_backend_size_dynamic_sections \
724 - elf_m68k_size_dynamic_sections
725 +#define elf_backend_late_size_sections elf_m68k_late_size_sections
726 #define elf_backend_final_write_processing elf_m68k_final_write_processing
727 #define elf_backend_init_index_section _bfd_elf_init_1_index_section
728 #define elf_backend_relocate_section elf_m68k_relocate_section
729 --- a/bfd/elf32-metag.c
730 +++ b/bfd/elf32-metag.c
731 @@ -2717,8 +2717,8 @@ allocate_dynrelocs (struct elf_link_hash
732 /* Set the sizes of the dynamic sections. */
733
734 static bool
735 -elf_metag_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
736 - struct bfd_link_info *info)
737 +elf_metag_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
738 + struct bfd_link_info *info)
739 {
740 struct elf_metag_link_hash_table *htab;
741 bfd *dynobj;
742 @@ -2729,7 +2729,7 @@ elf_metag_size_dynamic_sections (bfd *ou
743 htab = metag_link_hash_table (info);
744 dynobj = htab->etab.dynobj;
745 if (dynobj == NULL)
746 - abort ();
747 + return true;
748
749 if (htab->etab.dynamic_sections_created)
750 {
751 @@ -4019,7 +4019,7 @@ elf_metag_plt_sym_val (bfd_vma i, const
752 #define elf_backend_adjust_dynamic_symbol elf_metag_adjust_dynamic_symbol
753 #define elf_backend_finish_dynamic_symbol elf_metag_finish_dynamic_symbol
754 #define elf_backend_finish_dynamic_sections elf_metag_finish_dynamic_sections
755 -#define elf_backend_size_dynamic_sections elf_metag_size_dynamic_sections
756 +#define elf_backend_late_size_sections elf_metag_late_size_sections
757 #define elf_backend_omit_section_dynsym \
758 _bfd_elf_omit_section_dynsym_all
759 #define elf_backend_init_file_header elf_metag_init_file_header
760 --- a/bfd/elf32-microblaze.c
761 +++ b/bfd/elf32-microblaze.c
762 @@ -2966,8 +2966,8 @@ allocate_dynrelocs (struct elf_link_hash
763 /* Set the sizes of the dynamic sections. */
764
765 static bool
766 -microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
767 - struct bfd_link_info *info)
768 +microblaze_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
769 + struct bfd_link_info *info)
770 {
771 struct elf32_mb_link_hash_table *htab;
772 bfd *dynobj;
773 @@ -2979,7 +2979,8 @@ microblaze_elf_size_dynamic_sections (bf
774 return false;
775
776 dynobj = htab->elf.dynobj;
777 - BFD_ASSERT (dynobj != NULL);
778 + if (dynobj == NULL)
779 + return true;
780
781 /* Set up .got offsets for local syms, and space for local dynamic
782 relocs. */
783 @@ -3497,7 +3498,7 @@ microblaze_elf_add_symbol_hook (bfd *abf
784 #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections
785 #define elf_backend_finish_dynamic_sections microblaze_elf_finish_dynamic_sections
786 #define elf_backend_finish_dynamic_symbol microblaze_elf_finish_dynamic_symbol
787 -#define elf_backend_size_dynamic_sections microblaze_elf_size_dynamic_sections
788 +#define elf_backend_late_size_sections microblaze_elf_late_size_sections
789 #define elf_backend_add_symbol_hook microblaze_elf_add_symbol_hook
790
791 #include "elf32-target.h"
792 --- a/bfd/elf32-mips.c
793 +++ b/bfd/elf32-mips.c
794 @@ -2537,10 +2537,8 @@ static const struct ecoff_debug_swap mip
795 #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag
796 #define elf_backend_adjust_dynamic_symbol \
797 _bfd_mips_elf_adjust_dynamic_symbol
798 -#define elf_backend_always_size_sections \
799 - _bfd_mips_elf_always_size_sections
800 -#define elf_backend_size_dynamic_sections \
801 - _bfd_mips_elf_size_dynamic_sections
802 +#define elf_backend_early_size_sections _bfd_mips_elf_early_size_sections
803 +#define elf_backend_late_size_sections _bfd_mips_elf_late_size_sections
804 #define elf_backend_init_index_section _bfd_elf_init_1_index_section
805 #define elf_backend_relocate_section _bfd_mips_elf_relocate_section
806 #define elf_backend_finish_dynamic_symbol \
807 --- a/bfd/elf32-nds32.c
808 +++ b/bfd/elf32-nds32.c
809 @@ -4302,8 +4302,8 @@ elf32_nds32_add_dynreloc (bfd *output_bf
810 /* Set the sizes of the dynamic sections. */
811
812 static bool
813 -nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
814 - struct bfd_link_info *info)
815 +nds32_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
816 + struct bfd_link_info *info)
817 {
818 struct elf_nds32_link_hash_table *htab;
819 bfd *dynobj;
820 @@ -4316,7 +4316,8 @@ nds32_elf_size_dynamic_sections (bfd *ou
821 return false;
822
823 dynobj = elf_hash_table (info)->dynobj;
824 - BFD_ASSERT (dynobj != NULL);
825 + if (dynobj == NULL)
826 + return true;
827
828 if (elf_hash_table (info)->dynamic_sections_created)
829 {
830 @@ -13984,7 +13985,7 @@ nds32_elf_unify_tls_model (bfd *inbfd, a
831 #define elf_backend_create_dynamic_sections nds32_elf_create_dynamic_sections
832 #define elf_backend_finish_dynamic_sections nds32_elf_finish_dynamic_sections
833 #define elf_backend_finish_dynamic_symbol nds32_elf_finish_dynamic_symbol
834 -#define elf_backend_size_dynamic_sections nds32_elf_size_dynamic_sections
835 +#define elf_backend_late_size_sections nds32_elf_late_size_sections
836 #define elf_backend_relocate_section nds32_elf_relocate_section
837 #define elf_backend_gc_mark_hook nds32_elf_gc_mark_hook
838 #define elf_backend_grok_prstatus nds32_elf_grok_prstatus
839 --- a/bfd/elf32-nios2.c
840 +++ b/bfd/elf32-nios2.c
841 @@ -5405,7 +5405,7 @@ nios2_elf32_adjust_dynamic_symbol (struc
842 return true;
843 }
844
845 -/* Worker function for nios2_elf32_size_dynamic_sections. */
846 +/* Worker function for nios2_elf32_late_size_sections. */
847 static bool
848 adjust_dynrelocs (struct elf_link_hash_entry *h, void *inf)
849 {
850 @@ -5432,7 +5432,7 @@ adjust_dynrelocs (struct elf_link_hash_e
851 return true;
852 }
853
854 -/* Another worker function for nios2_elf32_size_dynamic_sections.
855 +/* Another worker function for nios2_elf32_late_size_sections.
856 Allocate space in .plt, .got and associated reloc sections for
857 dynamic relocs. */
858 static bool
859 @@ -5667,11 +5667,11 @@ allocate_dynrelocs (struct elf_link_hash
860 return true;
861 }
862
863 -/* Implement elf_backend_size_dynamic_sections:
864 +/* Implement elf_backend_late_size_sections:
865 Set the sizes of the dynamic sections. */
866 static bool
867 -nios2_elf32_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
868 - struct bfd_link_info *info)
869 +nios2_elf32_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
870 + struct bfd_link_info *info)
871 {
872 bfd *dynobj;
873 asection *s;
874 @@ -5681,7 +5681,8 @@ nios2_elf32_size_dynamic_sections (bfd *
875
876 htab = elf32_nios2_hash_table (info);
877 dynobj = htab->root.dynobj;
878 - BFD_ASSERT (dynobj != NULL);
879 + if (dynobj == NULL)
880 + return true;
881
882 htab->res_n_size = 0;
883 if (htab->root.dynamic_sections_created)
884 @@ -6052,7 +6053,7 @@ const struct bfd_elf_special_section elf
885 nios2_elf32_finish_dynamic_sections
886 #define elf_backend_adjust_dynamic_symbol nios2_elf32_adjust_dynamic_symbol
887 #define elf_backend_reloc_type_class nios2_elf32_reloc_type_class
888 -#define elf_backend_size_dynamic_sections nios2_elf32_size_dynamic_sections
889 +#define elf_backend_late_size_sections nios2_elf32_late_size_sections
890 #define elf_backend_add_symbol_hook nios2_elf_add_symbol_hook
891 #define elf_backend_copy_indirect_symbol nios2_elf32_copy_indirect_symbol
892 #define elf_backend_object_p nios2_elf32_object_p
893 --- a/bfd/elf32-or1k.c
894 +++ b/bfd/elf32-or1k.c
895 @@ -3047,8 +3047,8 @@ allocate_dynrelocs (struct elf_link_hash
896 /* Set the sizes of the dynamic sections. */
897
898 static bool
899 -or1k_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
900 - struct bfd_link_info *info)
901 +or1k_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
902 + struct bfd_link_info *info)
903 {
904 struct elf_or1k_link_hash_table *htab;
905 bfd *dynobj;
906 @@ -3061,7 +3061,8 @@ or1k_elf_size_dynamic_sections (bfd *out
907 return false;
908
909 dynobj = htab->root.dynobj;
910 - BFD_ASSERT (dynobj != NULL);
911 + if (dynobj == NULL)
912 + return true;
913
914 if (htab->root.dynamic_sections_created)
915 {
916 @@ -3414,7 +3415,7 @@ or1k_grok_psinfo (bfd *abfd, Elf_Interna
917 #define elf_backend_copy_indirect_symbol or1k_elf_copy_indirect_symbol
918 #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections
919 #define elf_backend_finish_dynamic_sections or1k_elf_finish_dynamic_sections
920 -#define elf_backend_size_dynamic_sections or1k_elf_size_dynamic_sections
921 +#define elf_backend_late_size_sections or1k_elf_late_size_sections
922 #define elf_backend_adjust_dynamic_symbol or1k_elf_adjust_dynamic_symbol
923 #define elf_backend_finish_dynamic_symbol or1k_elf_finish_dynamic_symbol
924
925 --- a/bfd/elf32-ppc.c
926 +++ b/bfd/elf32-ppc.c
927 @@ -5479,8 +5479,8 @@ static const unsigned char glink_eh_fram
928 /* Set the sizes of the dynamic sections. */
929
930 static bool
931 -ppc_elf_size_dynamic_sections (bfd *output_bfd,
932 - struct bfd_link_info *info)
933 +ppc_elf_late_size_sections (bfd *output_bfd,
934 + struct bfd_link_info *info)
935 {
936 struct ppc_elf_link_hash_table *htab;
937 asection *s;
938 @@ -5488,11 +5488,12 @@ ppc_elf_size_dynamic_sections (bfd *outp
939 bfd *ibfd;
940
941 #ifdef DEBUG
942 - fprintf (stderr, "ppc_elf_size_dynamic_sections called\n");
943 + fprintf (stderr, "ppc_elf_late_size_sections called\n");
944 #endif
945
946 htab = ppc_elf_hash_table (info);
947 - BFD_ASSERT (htab->elf.dynobj != NULL);
948 + if (htab->elf.dynobj == NULL)
949 + return true;
950
951 if (elf_hash_table (info)->dynamic_sections_created)
952 {
953 @@ -10433,7 +10434,7 @@ ppc_elf_finish_dynamic_sections (bfd *ou
954 #define elf_backend_copy_indirect_symbol ppc_elf_copy_indirect_symbol
955 #define elf_backend_adjust_dynamic_symbol ppc_elf_adjust_dynamic_symbol
956 #define elf_backend_add_symbol_hook ppc_elf_add_symbol_hook
957 -#define elf_backend_size_dynamic_sections ppc_elf_size_dynamic_sections
958 +#define elf_backend_late_size_sections ppc_elf_late_size_sections
959 #define elf_backend_hash_symbol ppc_elf_hash_symbol
960 #define elf_backend_finish_dynamic_symbol ppc_elf_finish_dynamic_symbol
961 #define elf_backend_finish_dynamic_sections ppc_elf_finish_dynamic_sections
962 --- a/bfd/elf32-rl78.c
963 +++ b/bfd/elf32-rl78.c
964 @@ -1440,8 +1440,8 @@ rl78_elf_finish_dynamic_sections (bfd *a
965 }
966
967 static bool
968 -rl78_elf_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
969 - struct bfd_link_info *info)
970 +rl78_elf_early_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
971 + struct bfd_link_info *info)
972 {
973 bfd *dynobj;
974 asection *splt;
975 @@ -2610,8 +2610,8 @@ rl78_elf_relax_section (bfd *abfd,
976
977 #define bfd_elf32_bfd_relax_section rl78_elf_relax_section
978 #define elf_backend_check_relocs rl78_elf_check_relocs
979 -#define elf_backend_always_size_sections \
980 - rl78_elf_always_size_sections
981 +#define elf_backend_early_size_sections \
982 + rl78_elf_early_size_sections
983 #define elf_backend_finish_dynamic_sections \
984 rl78_elf_finish_dynamic_sections
985
986 --- a/bfd/elf32-s390.c
987 +++ b/bfd/elf32-s390.c
988 @@ -1366,7 +1366,7 @@ elf_s390_gc_mark_hook (asection *sec,
989 entry but we found we will not create any. Called when we find we will
990 not have any PLT for this symbol, by for example
991 elf_s390_adjust_dynamic_symbol when we're doing a proper dynamic link,
992 - or elf_s390_size_dynamic_sections if no dynamic sections will be
993 + or elf_s390_late_size_sections if no dynamic sections will be
994 created (we're only linking static objects). */
995
996 static void
997 @@ -1778,8 +1778,8 @@ allocate_dynrelocs (struct elf_link_hash
998 /* Set the sizes of the dynamic sections. */
999
1000 static bool
1001 -elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1002 - struct bfd_link_info *info)
1003 +elf_s390_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1004 + struct bfd_link_info *info)
1005 {
1006 struct elf_s390_link_hash_table *htab;
1007 bfd *dynobj;
1008 @@ -1790,7 +1790,7 @@ elf_s390_size_dynamic_sections (bfd *out
1009 htab = elf_s390_hash_table (info);
1010 dynobj = htab->elf.dynobj;
1011 if (dynobj == NULL)
1012 - abort ();
1013 + return true;
1014
1015 if (htab->elf.dynamic_sections_created)
1016 {
1017 @@ -3926,7 +3926,7 @@ elf32_s390_merge_private_bfd_data (bfd *
1018 #define elf_backend_gc_mark_hook elf_s390_gc_mark_hook
1019 #define elf_backend_reloc_type_class elf_s390_reloc_type_class
1020 #define elf_backend_relocate_section elf_s390_relocate_section
1021 -#define elf_backend_size_dynamic_sections elf_s390_size_dynamic_sections
1022 +#define elf_backend_late_size_sections elf_s390_late_size_sections
1023 #define elf_backend_init_index_section _bfd_elf_init_1_index_section
1024 #define elf_backend_grok_prstatus elf_s390_grok_prstatus
1025 #define elf_backend_grok_psinfo elf_s390_grok_psinfo
1026 --- a/bfd/elf32-score.c
1027 +++ b/bfd/elf32-score.c
1028 @@ -1089,7 +1089,7 @@ score_elf_got_info (bfd *abfd, asection
1029 appear towards the end. This reduces the amount of GOT space
1030 required. MAX_LOCAL is used to set the number of local symbols
1031 known to be in the dynamic symbol table. During
1032 - s3_bfd_score_elf_size_dynamic_sections, this value is 1. Afterward, the
1033 + s3_bfd_score_elf_late_size_sections, this value is 1. Afterward, the
1034 section symbols are added and the count is higher. */
1035 static bool
1036 score_elf_sort_hash_table (struct bfd_link_info *info,
1037 @@ -3160,8 +3160,8 @@ s3_bfd_score_elf_adjust_dynamic_symbol (
1038 /* This function is called after all the input files have been read,
1039 and the input sections have been assigned to output sections. */
1040 static bool
1041 -s3_bfd_score_elf_always_size_sections (bfd *output_bfd,
1042 - struct bfd_link_info *info)
1043 +s3_bfd_score_elf_early_size_sections (bfd *output_bfd,
1044 + struct bfd_link_info *info)
1045 {
1046 bfd *dynobj;
1047 asection *s;
1048 @@ -3237,14 +3237,15 @@ s3_bfd_score_elf_always_size_sections (b
1049
1050 /* Set the sizes of the dynamic sections. */
1051 static bool
1052 -s3_bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
1053 +s3_bfd_score_elf_late_size_sections (bfd *output_bfd, struct bfd_link_info *info)
1054 {
1055 bfd *dynobj;
1056 asection *s;
1057 bool reltext;
1058
1059 dynobj = elf_hash_table (info)->dynobj;
1060 - BFD_ASSERT (dynobj != NULL);
1061 + if (dynobj == NULL)
1062 + return true;
1063
1064 if (elf_hash_table (info)->dynamic_sections_created)
1065 {
1066 @@ -3313,7 +3314,7 @@ s3_bfd_score_elf_size_dynamic_sections (
1067 }
1068 else if (startswith (name, ".got"))
1069 {
1070 - /* s3_bfd_score_elf_always_size_sections() has already done
1071 + /* s3_bfd_score_elf_early_size_sections() has already done
1072 most of the work, but some symbols may have been mapped
1073 to versions that we must now resolve in the got_entries
1074 hash tables. */
1075 @@ -4177,22 +4178,22 @@ _bfd_score_elf_adjust_dynamic_symbol (st
1076 }
1077
1078 static bool
1079 -_bfd_score_elf_always_size_sections (bfd *output_bfd,
1080 - struct bfd_link_info *info)
1081 +_bfd_score_elf_early_size_sections (bfd *output_bfd,
1082 + struct bfd_link_info *info)
1083 {
1084 if (bfd_get_mach (output_bfd) == bfd_mach_score3)
1085 - return s3_bfd_score_elf_always_size_sections (output_bfd, info);
1086 + return s3_bfd_score_elf_early_size_sections (output_bfd, info);
1087 else
1088 - return s7_bfd_score_elf_always_size_sections (output_bfd, info);
1089 + return s7_bfd_score_elf_early_size_sections (output_bfd, info);
1090 }
1091
1092 static bool
1093 -_bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
1094 +_bfd_score_elf_late_size_sections (bfd *output_bfd, struct bfd_link_info *info)
1095 {
1096 if (bfd_get_mach (output_bfd) == bfd_mach_score3)
1097 - return s3_bfd_score_elf_size_dynamic_sections (output_bfd, info);
1098 + return s3_bfd_score_elf_late_size_sections (output_bfd, info);
1099 else
1100 - return s7_bfd_score_elf_size_dynamic_sections (output_bfd, info);
1101 + return s7_bfd_score_elf_late_size_sections (output_bfd, info);
1102 }
1103
1104 static bool
1105 @@ -4455,10 +4456,10 @@ _bfd_score_elf_common_definition (Elf_In
1106 _bfd_score_elf_section_from_bfd_section
1107 #define elf_backend_adjust_dynamic_symbol \
1108 _bfd_score_elf_adjust_dynamic_symbol
1109 -#define elf_backend_always_size_sections \
1110 - _bfd_score_elf_always_size_sections
1111 -#define elf_backend_size_dynamic_sections \
1112 - _bfd_score_elf_size_dynamic_sections
1113 +#define elf_backend_early_size_sections \
1114 + _bfd_score_elf_early_size_sections
1115 +#define elf_backend_late_size_sections \
1116 + _bfd_score_elf_late_size_sections
1117 #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all
1118 #define elf_backend_create_dynamic_sections \
1119 _bfd_score_elf_create_dynamic_sections
1120 --- a/bfd/elf32-score.h
1121 +++ b/bfd/elf32-score.h
1122 @@ -78,10 +78,10 @@ s7_bfd_score_elf_adjust_dynamic_symbol (
1123 struct elf_link_hash_entry *);
1124
1125 extern bool
1126 -s7_bfd_score_elf_always_size_sections (bfd *, struct bfd_link_info *);
1127 +s7_bfd_score_elf_early_size_sections (bfd *, struct bfd_link_info *);
1128
1129 extern bool
1130 -s7_bfd_score_elf_size_dynamic_sections (bfd *, struct bfd_link_info *);
1131 +s7_bfd_score_elf_late_size_sections (bfd *, struct bfd_link_info *);
1132
1133 extern bool
1134 s7_bfd_score_elf_create_dynamic_sections (bfd *, struct bfd_link_info *);
1135 --- a/bfd/elf32-score7.c
1136 +++ b/bfd/elf32-score7.c
1137 @@ -975,7 +975,7 @@ score_elf_got_info (bfd *abfd, asection
1138 appear towards the end. This reduces the amount of GOT space
1139 required. MAX_LOCAL is used to set the number of local symbols
1140 known to be in the dynamic symbol table. During
1141 - s7_bfd_score_elf_size_dynamic_sections, this value is 1. Afterward, the
1142 + s7_bfd_score_elf_late_size_sections, this value is 1. Afterward, the
1143 section symbols are added and the count is higher. */
1144
1145 static bool
1146 @@ -2969,8 +2969,8 @@ s7_bfd_score_elf_adjust_dynamic_symbol (
1147 and the input sections have been assigned to output sections. */
1148
1149 bool
1150 -s7_bfd_score_elf_always_size_sections (bfd *output_bfd,
1151 - struct bfd_link_info *info)
1152 +s7_bfd_score_elf_early_size_sections (bfd *output_bfd,
1153 + struct bfd_link_info *info)
1154 {
1155 bfd *dynobj;
1156 asection *s;
1157 @@ -3047,14 +3047,15 @@ s7_bfd_score_elf_always_size_sections (b
1158 /* Set the sizes of the dynamic sections. */
1159
1160 bool
1161 -s7_bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
1162 +s7_bfd_score_elf_late_size_sections (bfd *output_bfd, struct bfd_link_info *info)
1163 {
1164 bfd *dynobj;
1165 asection *s;
1166 bool reltext;
1167
1168 dynobj = elf_hash_table (info)->dynobj;
1169 - BFD_ASSERT (dynobj != NULL);
1170 + if (dynobj == NULL)
1171 + return true;
1172
1173 if (elf_hash_table (info)->dynamic_sections_created)
1174 {
1175 @@ -3123,7 +3124,7 @@ s7_bfd_score_elf_size_dynamic_sections (
1176 }
1177 else if (startswith (name, ".got"))
1178 {
1179 - /* s7_bfd_score_elf_always_size_sections() has already done
1180 + /* s7_bfd_score_elf_early_size_sections() has already done
1181 most of the work, but some symbols may have been mapped
1182 to versions that we must now resolve in the got_entries
1183 hash tables. */
1184 --- a/bfd/elf32-sh.c
1185 +++ b/bfd/elf32-sh.c
1186 @@ -2927,7 +2927,7 @@ allocate_dynrelocs (struct elf_link_hash
1187 It's a convenient place to determine the PLT style. */
1188
1189 static bool
1190 -sh_elf_always_size_sections (bfd *output_bfd, struct bfd_link_info *info)
1191 +sh_elf_early_size_sections (bfd *output_bfd, struct bfd_link_info *info)
1192 {
1193 sh_elf_hash_table (info)->plt_info = get_plt_info (output_bfd,
1194 bfd_link_pic (info));
1195 @@ -2942,8 +2942,8 @@ sh_elf_always_size_sections (bfd *output
1196 /* Set the sizes of the dynamic sections. */
1197
1198 static bool
1199 -sh_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1200 - struct bfd_link_info *info)
1201 +sh_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1202 + struct bfd_link_info *info)
1203 {
1204 struct elf_sh_link_hash_table *htab;
1205 bfd *dynobj;
1206 @@ -2956,7 +2956,8 @@ sh_elf_size_dynamic_sections (bfd *outpu
1207 return false;
1208
1209 dynobj = htab->root.dynobj;
1210 - BFD_ASSERT (dynobj != NULL);
1211 + if (dynobj == NULL)
1212 + return true;
1213
1214 if (htab->root.dynamic_sections_created)
1215 {
1216 @@ -6600,10 +6601,8 @@ sh_elf_encode_eh_address (bfd *abfd,
1217 sh_elf_link_hash_table_create
1218 #define elf_backend_adjust_dynamic_symbol \
1219 sh_elf_adjust_dynamic_symbol
1220 -#define elf_backend_always_size_sections \
1221 - sh_elf_always_size_sections
1222 -#define elf_backend_size_dynamic_sections \
1223 - sh_elf_size_dynamic_sections
1224 +#define elf_backend_early_size_sections sh_elf_early_size_sections
1225 +#define elf_backend_late_size_sections sh_elf_late_size_sections
1226 #define elf_backend_omit_section_dynsym sh_elf_omit_section_dynsym
1227 #define elf_backend_finish_dynamic_symbol \
1228 sh_elf_finish_dynamic_symbol
1229 --- a/bfd/elf32-sparc.c
1230 +++ b/bfd/elf32-sparc.c
1231 @@ -248,8 +248,7 @@ elf32_sparc_reloc_type_class (const stru
1232 #define elf_backend_adjust_dynamic_symbol \
1233 _bfd_sparc_elf_adjust_dynamic_symbol
1234 #define elf_backend_omit_section_dynsym _bfd_sparc_elf_omit_section_dynsym
1235 -#define elf_backend_size_dynamic_sections \
1236 - _bfd_sparc_elf_size_dynamic_sections
1237 +#define elf_backend_late_size_sections _bfd_sparc_elf_late_size_sections
1238 #define elf_backend_relocate_section _bfd_sparc_elf_relocate_section
1239 #define elf_backend_finish_dynamic_symbol \
1240 _bfd_sparc_elf_finish_dynamic_symbol
1241 --- a/bfd/elf32-tic6x.c
1242 +++ b/bfd/elf32-tic6x.c
1243 @@ -3160,7 +3160,7 @@ elf32_tic6x_allocate_dynrelocs (struct e
1244 /* Set the sizes of the dynamic sections. */
1245
1246 static bool
1247 -elf32_tic6x_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
1248 +elf32_tic6x_late_size_sections (bfd *output_bfd, struct bfd_link_info *info)
1249 {
1250 struct elf32_tic6x_link_hash_table *htab;
1251 bfd *dynobj;
1252 @@ -3171,7 +3171,7 @@ elf32_tic6x_size_dynamic_sections (bfd *
1253 htab = elf32_tic6x_hash_table (info);
1254 dynobj = htab->elf.dynobj;
1255 if (dynobj == NULL)
1256 - abort ();
1257 + return true;
1258
1259 if (htab->elf.dynamic_sections_created)
1260 {
1261 @@ -3358,7 +3358,7 @@ elf32_tic6x_size_dynamic_sections (bfd *
1262 and the input sections have been assigned to output sections. */
1263
1264 static bool
1265 -elf32_tic6x_always_size_sections (bfd *output_bfd, struct bfd_link_info *info)
1266 +elf32_tic6x_early_size_sections (bfd *output_bfd, struct bfd_link_info *info)
1267 {
1268 if (elf32_tic6x_using_dsbt (output_bfd) && !bfd_link_relocatable (info)
1269 && !bfd_elf_stack_segment_size (output_bfd, info,
1270 @@ -4261,10 +4261,10 @@ elf32_tic6x_write_section (bfd *output_b
1271 #define elf_backend_relocs_compatible _bfd_elf_relocs_compatible
1272 #define elf_backend_finish_dynamic_symbol \
1273 elf32_tic6x_finish_dynamic_symbol
1274 -#define elf_backend_always_size_sections \
1275 - elf32_tic6x_always_size_sections
1276 -#define elf_backend_size_dynamic_sections \
1277 - elf32_tic6x_size_dynamic_sections
1278 +#define elf_backend_early_size_sections \
1279 + elf32_tic6x_early_size_sections
1280 +#define elf_backend_late_size_sections \
1281 + elf32_tic6x_late_size_sections
1282 #define elf_backend_finish_dynamic_sections \
1283 elf32_tic6x_finish_dynamic_sections
1284 #define bfd_elf32_bfd_final_link \
1285 --- a/bfd/elf32-tilegx.c
1286 +++ b/bfd/elf32-tilegx.c
1287 @@ -105,7 +105,7 @@ tilegx_elf_grok_psinfo (bfd *abfd, Elf_I
1288 #define elf_backend_check_relocs tilegx_elf_check_relocs
1289 #define elf_backend_adjust_dynamic_symbol tilegx_elf_adjust_dynamic_symbol
1290 #define elf_backend_omit_section_dynsym tilegx_elf_omit_section_dynsym
1291 -#define elf_backend_size_dynamic_sections tilegx_elf_size_dynamic_sections
1292 +#define elf_backend_late_size_sections tilegx_elf_late_size_sections
1293 #define elf_backend_relocate_section tilegx_elf_relocate_section
1294 #define elf_backend_finish_dynamic_symbol tilegx_elf_finish_dynamic_symbol
1295 #define elf_backend_finish_dynamic_sections tilegx_elf_finish_dynamic_sections
1296 --- a/bfd/elf32-tilepro.c
1297 +++ b/bfd/elf32-tilepro.c
1298 @@ -2182,11 +2182,9 @@ tilepro_elf_omit_section_dynsym (bfd *ou
1299 #define ELF32_DYNAMIC_INTERPRETER "/lib/ld.so.1"
1300
1301 static bool
1302 -tilepro_elf_size_dynamic_sections (bfd *output_bfd,
1303 - struct bfd_link_info *info)
1304 +tilepro_elf_late_size_sections (bfd *output_bfd,
1305 + struct bfd_link_info *info)
1306 {
1307 - (void)output_bfd;
1308 -
1309 struct elf_link_hash_table *htab;
1310 bfd *dynobj;
1311 asection *s;
1312 @@ -2195,7 +2193,8 @@ tilepro_elf_size_dynamic_sections (bfd *
1313 htab = tilepro_elf_hash_table (info);
1314 BFD_ASSERT (htab != NULL);
1315 dynobj = htab->dynobj;
1316 - BFD_ASSERT (dynobj != NULL);
1317 + if (dynobj == NULL)
1318 + return true;
1319
1320 if (elf_hash_table (info)->dynamic_sections_created)
1321 {
1322 @@ -3739,7 +3738,7 @@ tilepro_additional_program_headers (bfd
1323 #define elf_backend_check_relocs tilepro_elf_check_relocs
1324 #define elf_backend_adjust_dynamic_symbol tilepro_elf_adjust_dynamic_symbol
1325 #define elf_backend_omit_section_dynsym tilepro_elf_omit_section_dynsym
1326 -#define elf_backend_size_dynamic_sections tilepro_elf_size_dynamic_sections
1327 +#define elf_backend_late_size_sections tilepro_elf_late_size_sections
1328 #define elf_backend_relocate_section tilepro_elf_relocate_section
1329 #define elf_backend_finish_dynamic_symbol tilepro_elf_finish_dynamic_symbol
1330 #define elf_backend_finish_dynamic_sections tilepro_elf_finish_dynamic_sections
1331 --- a/bfd/elf32-vax.c
1332 +++ b/bfd/elf32-vax.c
1333 @@ -36,7 +36,6 @@ static bool elf_vax_check_relocs (bfd *,
1334 asection *, const Elf_Internal_Rela *);
1335 static bool elf_vax_adjust_dynamic_symbol (struct bfd_link_info *,
1336 struct elf_link_hash_entry *);
1337 -static bool elf_vax_size_dynamic_sections (bfd *, struct bfd_link_info *);
1338 static int elf_vax_relocate_section (bfd *, struct bfd_link_info *,
1339 bfd *, asection *, bfd_byte *,
1340 Elf_Internal_Rela *,
1341 @@ -985,8 +984,8 @@ elf_vax_discard_got_entries (struct elf_
1342 /* Discard unused dynamic data if this is a static link. */
1343
1344 static bool
1345 -elf_vax_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1346 - struct bfd_link_info *info)
1347 +elf_vax_early_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1348 + struct bfd_link_info *info)
1349 {
1350 bfd *dynobj;
1351 asection *s;
1352 @@ -1024,14 +1023,15 @@ elf_vax_always_size_sections (bfd *outpu
1353 /* Set the sizes of the dynamic sections. */
1354
1355 static bool
1356 -elf_vax_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
1357 +elf_vax_late_size_sections (bfd *output_bfd, struct bfd_link_info *info)
1358 {
1359 bfd *dynobj;
1360 asection *s;
1361 bool relocs;
1362
1363 dynobj = elf_hash_table (info)->dynobj;
1364 - BFD_ASSERT (dynobj != NULL);
1365 + if (dynobj == NULL)
1366 + return true;
1367
1368 if (elf_hash_table (info)->dynamic_sections_created)
1369 {
1370 @@ -1861,10 +1861,8 @@ elf_vax_plt_sym_val (bfd_vma i, const as
1371 #define elf_backend_check_relocs elf_vax_check_relocs
1372 #define elf_backend_adjust_dynamic_symbol \
1373 elf_vax_adjust_dynamic_symbol
1374 -#define elf_backend_always_size_sections \
1375 - elf_vax_always_size_sections
1376 -#define elf_backend_size_dynamic_sections \
1377 - elf_vax_size_dynamic_sections
1378 +#define elf_backend_early_size_sections elf_vax_early_size_sections
1379 +#define elf_backend_late_size_sections elf_vax_late_size_sections
1380 #define elf_backend_init_index_section _bfd_elf_init_1_index_section
1381 #define elf_backend_relocate_section elf_vax_relocate_section
1382 #define elf_backend_finish_dynamic_symbol \
1383 --- a/bfd/elf32-xstormy16.c
1384 +++ b/bfd/elf32-xstormy16.c
1385 @@ -706,8 +706,8 @@ xstormy16_elf_relax_section (bfd *dynobj
1386 }
1387
1388 static bool
1389 -xstormy16_elf_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1390 - struct bfd_link_info *info)
1391 +xstormy16_elf_early_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1392 + struct bfd_link_info *info)
1393 {
1394 bfd *dynobj;
1395 asection *splt;
1396 @@ -1013,8 +1013,8 @@ xstormy16_elf_gc_mark_hook (asection *se
1397 #define elf_backend_relocate_section xstormy16_elf_relocate_section
1398 #define elf_backend_gc_mark_hook xstormy16_elf_gc_mark_hook
1399 #define elf_backend_check_relocs xstormy16_elf_check_relocs
1400 -#define elf_backend_always_size_sections \
1401 - xstormy16_elf_always_size_sections
1402 +#define elf_backend_early_size_sections \
1403 + xstormy16_elf_early_size_sections
1404 #define elf_backend_omit_section_dynsym \
1405 _bfd_elf_omit_section_dynsym_all
1406 #define elf_backend_finish_dynamic_sections \
1407 --- a/bfd/elf32-xtensa.c
1408 +++ b/bfd/elf32-xtensa.c
1409 @@ -1557,8 +1557,8 @@ elf_xtensa_allocate_local_got_size (stru
1410 /* Set the sizes of the dynamic sections. */
1411
1412 static bool
1413 -elf_xtensa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1414 - struct bfd_link_info *info)
1415 +elf_xtensa_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1416 + struct bfd_link_info *info)
1417 {
1418 struct elf_xtensa_link_hash_table *htab;
1419 bfd *dynobj, *abfd;
1420 @@ -1575,7 +1575,7 @@ elf_xtensa_size_dynamic_sections (bfd *o
1421
1422 dynobj = elf_hash_table (info)->dynobj;
1423 if (dynobj == NULL)
1424 - abort ();
1425 + return true;
1426 srelgot = htab->elf.srelgot;
1427 srelplt = htab->elf.srelplt;
1428
1429 @@ -1780,8 +1780,7 @@ elf_xtensa_size_dynamic_sections (bfd *o
1430 }
1431
1432 static bool
1433 -elf_xtensa_always_size_sections (bfd *output_bfd,
1434 - struct bfd_link_info *info)
1435 +elf_xtensa_early_size_sections (bfd *output_bfd, struct bfd_link_info *info)
1436 {
1437 struct elf_xtensa_link_hash_table *htab;
1438 asection *tls_sec;
1439 @@ -11544,8 +11543,8 @@ static const struct bfd_elf_special_sect
1440 #define elf_backend_object_p elf_xtensa_object_p
1441 #define elf_backend_reloc_type_class elf_xtensa_reloc_type_class
1442 #define elf_backend_relocate_section elf_xtensa_relocate_section
1443 -#define elf_backend_size_dynamic_sections elf_xtensa_size_dynamic_sections
1444 -#define elf_backend_always_size_sections elf_xtensa_always_size_sections
1445 +#define elf_backend_late_size_sections elf_xtensa_late_size_sections
1446 +#define elf_backend_early_size_sections elf_xtensa_early_size_sections
1447 #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all
1448 #define elf_backend_special_sections elf_xtensa_special_sections
1449 #define elf_backend_action_discarded elf_xtensa_action_discarded
1450 --- a/bfd/elf64-alpha.c
1451 +++ b/bfd/elf64-alpha.c
1452 @@ -2562,8 +2562,8 @@ elf64_alpha_size_plt_section (struct bfd
1453 }
1454
1455 static bool
1456 -elf64_alpha_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1457 - struct bfd_link_info *info)
1458 +elf64_alpha_early_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1459 + struct bfd_link_info *info)
1460 {
1461 bfd *i;
1462 struct alpha_elf_link_hash_table * htab;
1463 @@ -2789,8 +2789,8 @@ elf64_alpha_size_rela_got_section (struc
1464 /* Set the sizes of the dynamic sections. */
1465
1466 static bool
1467 -elf64_alpha_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1468 - struct bfd_link_info *info)
1469 +elf64_alpha_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1470 + struct bfd_link_info *info)
1471 {
1472 bfd *dynobj;
1473 asection *s;
1474 @@ -2802,7 +2802,8 @@ elf64_alpha_size_dynamic_sections (bfd *
1475 return false;
1476
1477 dynobj = elf_hash_table(info)->dynobj;
1478 - BFD_ASSERT(dynobj != NULL);
1479 + if (dynobj == NULL)
1480 + return true;
1481
1482 if (elf_hash_table (info)->dynamic_sections_created)
1483 {
1484 @@ -5448,10 +5449,10 @@ static const struct elf_size_info alpha_
1485 elf64_alpha_merge_symbol_attribute
1486 #define elf_backend_copy_indirect_symbol \
1487 elf64_alpha_copy_indirect_symbol
1488 -#define elf_backend_always_size_sections \
1489 - elf64_alpha_always_size_sections
1490 -#define elf_backend_size_dynamic_sections \
1491 - elf64_alpha_size_dynamic_sections
1492 +#define elf_backend_early_size_sections \
1493 + elf64_alpha_early_size_sections
1494 +#define elf_backend_late_size_sections \
1495 + elf64_alpha_late_size_sections
1496 #define elf_backend_omit_section_dynsym \
1497 _bfd_elf_omit_section_dynsym_all
1498 #define elf_backend_relocate_section \
1499 --- a/bfd/elf64-hppa.c
1500 +++ b/bfd/elf64-hppa.c
1501 @@ -176,9 +176,6 @@ static bool elf64_hppa_adjust_dynamic_sy
1502 static bool elf64_hppa_mark_milli_and_exported_functions
1503 (struct elf_link_hash_entry *, void *);
1504
1505 -static bool elf64_hppa_size_dynamic_sections
1506 - (bfd *, struct bfd_link_info *);
1507 -
1508 static int elf64_hppa_link_output_symbol_hook
1509 (struct bfd_link_info *, const char *, Elf_Internal_Sym *,
1510 asection *, struct elf_link_hash_entry *);
1511 @@ -1520,7 +1517,7 @@ elf64_hppa_mark_milli_and_exported_funct
1512 the contents of our special sections. */
1513
1514 static bool
1515 -elf64_hppa_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
1516 +elf64_hppa_late_size_sections (bfd *output_bfd, struct bfd_link_info *info)
1517 {
1518 struct elf64_hppa_link_hash_table *hppa_info;
1519 struct elf64_hppa_allocate_data data;
1520 @@ -1534,7 +1531,8 @@ elf64_hppa_size_dynamic_sections (bfd *o
1521 return false;
1522
1523 dynobj = hppa_info->root.dynobj;
1524 - BFD_ASSERT (dynobj != NULL);
1525 + if (dynobj == NULL)
1526 + return true;
1527
1528 /* Mark each function this program exports so that we will allocate
1529 space in the .opd section for each function's FPTR. If we are
1530 @@ -3984,8 +3982,7 @@ const struct elf_size_info hppa64_elf_si
1531 #define elf_backend_adjust_dynamic_symbol \
1532 elf64_hppa_adjust_dynamic_symbol
1533
1534 -#define elf_backend_size_dynamic_sections \
1535 - elf64_hppa_size_dynamic_sections
1536 +#define elf_backend_late_size_sections elf64_hppa_late_size_sections
1537
1538 #define elf_backend_finish_dynamic_symbol \
1539 elf64_hppa_finish_dynamic_symbol
1540 --- a/bfd/elf64-ia64-vms.c
1541 +++ b/bfd/elf64-ia64-vms.c
1542 @@ -2591,8 +2591,8 @@ elf64_ia64_adjust_dynamic_symbol (struct
1543 }
1544
1545 static bool
1546 -elf64_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1547 - struct bfd_link_info *info)
1548 +elf64_ia64_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1549 + struct bfd_link_info *info)
1550 {
1551 struct elf64_ia64_allocate_data data;
1552 struct elf64_ia64_link_hash_table *ia64_info;
1553 @@ -2601,11 +2601,12 @@ elf64_ia64_size_dynamic_sections (bfd *o
1554 struct elf_link_hash_table *hash_table;
1555
1556 hash_table = elf_hash_table (info);
1557 - dynobj = hash_table->dynobj;
1558 ia64_info = elf64_ia64_hash_table (info);
1559 if (ia64_info == NULL)
1560 return false;
1561 - BFD_ASSERT(dynobj != NULL);
1562 + dynobj = hash_table->dynobj;
1563 + if (dynobj == NULL)
1564 + return true;
1565 data.info = info;
1566
1567 /* Allocate the GOT entries. */
1568 @@ -5488,8 +5489,8 @@ static const struct elf_size_info elf64_
1569 elf64_ia64_check_relocs
1570 #define elf_backend_adjust_dynamic_symbol \
1571 elf64_ia64_adjust_dynamic_symbol
1572 -#define elf_backend_size_dynamic_sections \
1573 - elf64_ia64_size_dynamic_sections
1574 +#define elf_backend_late_size_sections \
1575 + elf64_ia64_late_size_sections
1576 #define elf_backend_omit_section_dynsym \
1577 _bfd_elf_omit_section_dynsym_all
1578 #define elf_backend_relocate_section \
1579 --- a/bfd/elf64-mips.c
1580 +++ b/bfd/elf64-mips.c
1581 @@ -4748,10 +4748,10 @@ const struct elf_size_info mips_elf64_si
1582 #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag
1583 #define elf_backend_adjust_dynamic_symbol \
1584 _bfd_mips_elf_adjust_dynamic_symbol
1585 -#define elf_backend_always_size_sections \
1586 - _bfd_mips_elf_always_size_sections
1587 -#define elf_backend_size_dynamic_sections \
1588 - _bfd_mips_elf_size_dynamic_sections
1589 +#define elf_backend_early_size_sections \
1590 + _bfd_mips_elf_early_size_sections
1591 +#define elf_backend_late_size_sections \
1592 + _bfd_mips_elf_late_size_sections
1593 #define elf_backend_init_index_section _bfd_elf_init_1_index_section
1594 #define elf_backend_relocate_section _bfd_mips_elf_relocate_section
1595 #define elf_backend_finish_dynamic_symbol \
1596 --- a/bfd/elf64-ppc.c
1597 +++ b/bfd/elf64-ppc.c
1598 @@ -119,8 +119,8 @@ static bfd_vma opd_entry_value
1599 #define elf_backend_adjust_dynamic_symbol ppc64_elf_adjust_dynamic_symbol
1600 #define elf_backend_hide_symbol ppc64_elf_hide_symbol
1601 #define elf_backend_maybe_function_sym ppc64_elf_maybe_function_sym
1602 -#define elf_backend_always_size_sections ppc64_elf_edit
1603 -#define elf_backend_size_dynamic_sections ppc64_elf_size_dynamic_sections
1604 +#define elf_backend_early_size_sections ppc64_elf_edit
1605 +#define elf_backend_late_size_sections ppc64_elf_late_size_sections
1606 #define elf_backend_hash_symbol ppc64_elf_hash_symbol
1607 #define elf_backend_init_index_section _bfd_elf_init_2_index_sections
1608 #define elf_backend_action_discarded ppc64_elf_action_discarded
1609 @@ -10148,7 +10148,7 @@ allocate_dynrelocs (struct elf_link_hash
1610 ((((v) & 0x3ffff0000ULL) << 16) | (v & 0xffff))
1611 #define HA34(v) ((v + (1ULL << 33)) >> 34)
1612
1613 -/* Called via elf_link_hash_traverse from ppc64_elf_size_dynamic_sections
1614 +/* Called via elf_link_hash_traverse from ppc64_elf_late_size_sections
1615 to set up space for global entry stubs. These are put in glink,
1616 after the branch table. */
1617
1618 @@ -10225,8 +10225,8 @@ size_global_entry_stubs (struct elf_link
1619 /* Set the sizes of the dynamic sections. */
1620
1621 static bool
1622 -ppc64_elf_size_dynamic_sections (bfd *output_bfd,
1623 - struct bfd_link_info *info)
1624 +ppc64_elf_late_size_sections (bfd *output_bfd,
1625 + struct bfd_link_info *info)
1626 {
1627 struct ppc_link_hash_table *htab;
1628 bfd *dynobj;
1629 @@ -10241,7 +10241,7 @@ ppc64_elf_size_dynamic_sections (bfd *ou
1630
1631 dynobj = htab->elf.dynobj;
1632 if (dynobj == NULL)
1633 - abort ();
1634 + return true;
1635
1636 if (htab->elf.dynamic_sections_created)
1637 {
1638 --- a/bfd/elf64-s390.c
1639 +++ b/bfd/elf64-s390.c
1640 @@ -1301,7 +1301,7 @@ elf_s390_gc_mark_hook (asection *sec,
1641 entry but we found we will not create any. Called when we find we will
1642 not have any PLT for this symbol, by for example
1643 elf_s390_adjust_dynamic_symbol when we're doing a proper dynamic link,
1644 - or elf_s390_size_dynamic_sections if no dynamic sections will be
1645 + or elf_s390_late_size_sections if no dynamic sections will be
1646 created (we're only linking static objects). */
1647
1648 static void
1649 @@ -1714,8 +1714,8 @@ allocate_dynrelocs (struct elf_link_hash
1650 /* Set the sizes of the dynamic sections. */
1651
1652 static bool
1653 -elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1654 - struct bfd_link_info *info)
1655 +elf_s390_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1656 + struct bfd_link_info *info)
1657 {
1658 struct elf_s390_link_hash_table *htab;
1659 bfd *dynobj;
1660 @@ -1729,7 +1729,7 @@ elf_s390_size_dynamic_sections (bfd *out
1661
1662 dynobj = htab->elf.dynobj;
1663 if (dynobj == NULL)
1664 - abort ();
1665 + return true;
1666
1667 if (htab->elf.dynamic_sections_created)
1668 {
1669 @@ -3912,7 +3912,7 @@ const struct elf_size_info s390_elf64_si
1670 #define elf_backend_gc_mark_hook elf_s390_gc_mark_hook
1671 #define elf_backend_reloc_type_class elf_s390_reloc_type_class
1672 #define elf_backend_relocate_section elf_s390_relocate_section
1673 -#define elf_backend_size_dynamic_sections elf_s390_size_dynamic_sections
1674 +#define elf_backend_late_size_sections elf_s390_late_size_sections
1675 #define elf_backend_init_index_section _bfd_elf_init_1_index_section
1676 #define elf_backend_grok_prstatus elf_s390_grok_prstatus
1677 #define elf_backend_grok_psinfo elf_s390_grok_psinfo
1678 --- a/bfd/elf64-sparc.c
1679 +++ b/bfd/elf64-sparc.c
1680 @@ -953,8 +953,8 @@ const struct elf_size_info elf64_sparc_s
1681 _bfd_sparc_elf_adjust_dynamic_symbol
1682 #define elf_backend_omit_section_dynsym \
1683 _bfd_sparc_elf_omit_section_dynsym
1684 -#define elf_backend_size_dynamic_sections \
1685 - _bfd_sparc_elf_size_dynamic_sections
1686 +#define elf_backend_late_size_sections \
1687 + _bfd_sparc_elf_late_size_sections
1688 #define elf_backend_relocate_section \
1689 _bfd_sparc_elf_relocate_section
1690 #define elf_backend_finish_dynamic_symbol \
1691 --- a/bfd/elf64-tilegx.c
1692 +++ b/bfd/elf64-tilegx.c
1693 @@ -106,7 +106,7 @@ tilegx_elf_grok_psinfo (bfd *abfd, Elf_I
1694 #define elf_backend_check_relocs tilegx_elf_check_relocs
1695 #define elf_backend_adjust_dynamic_symbol tilegx_elf_adjust_dynamic_symbol
1696 #define elf_backend_omit_section_dynsym tilegx_elf_omit_section_dynsym
1697 -#define elf_backend_size_dynamic_sections tilegx_elf_size_dynamic_sections
1698 +#define elf_backend_late_size_sections tilegx_elf_late_size_sections
1699 #define elf_backend_relocate_section tilegx_elf_relocate_section
1700 #define elf_backend_finish_dynamic_symbol tilegx_elf_finish_dynamic_symbol
1701 #define elf_backend_finish_dynamic_sections tilegx_elf_finish_dynamic_sections
1702 --- a/bfd/elf64-x86-64.c
1703 +++ b/bfd/elf64-x86-64.c
1704 @@ -2549,8 +2549,7 @@ elf_x86_64_scan_relocs (bfd *abfd, struc
1705 }
1706
1707 static bool
1708 -elf_x86_64_always_size_sections (bfd *output_bfd,
1709 - struct bfd_link_info *info)
1710 +elf_x86_64_early_size_sections (bfd *output_bfd, struct bfd_link_info *info)
1711 {
1712 bfd *abfd;
1713
1714 @@ -2563,7 +2562,7 @@ elf_x86_64_always_size_sections (bfd *ou
1715 elf_x86_64_scan_relocs))
1716 return false;
1717
1718 - return _bfd_x86_elf_always_size_sections (output_bfd, info);
1719 + return _bfd_x86_elf_early_size_sections (output_bfd, info);
1720 }
1721
1722 /* Return the relocation value for @tpoff relocation
1723 @@ -5638,7 +5637,7 @@ elf_x86_64_special_sections[]=
1724 elf_x86_64_reloc_name_lookup
1725
1726 #define elf_backend_relocs_compatible elf_x86_64_relocs_compatible
1727 -#define elf_backend_always_size_sections elf_x86_64_always_size_sections
1728 +#define elf_backend_early_size_sections elf_x86_64_early_size_sections
1729 #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections
1730 #define elf_backend_finish_dynamic_sections elf_x86_64_finish_dynamic_sections
1731 #define elf_backend_finish_dynamic_symbol elf_x86_64_finish_dynamic_symbol
1732 --- a/bfd/elflink.c
1733 +++ b/bfd/elflink.c
1734 @@ -6676,8 +6676,8 @@ bfd_elf_size_dynamic_sections (bfd *outp
1735
1736 /* The backend may have to create some sections regardless of whether
1737 we're dynamic or not. */
1738 - if (bed->elf_backend_always_size_sections
1739 - && ! (*bed->elf_backend_always_size_sections) (output_bfd, info))
1740 + if (bed->elf_backend_early_size_sections
1741 + && !bed->elf_backend_early_size_sections (output_bfd, info))
1742 return false;
1743
1744 dynobj = elf_hash_table (info)->dynobj;
1745 @@ -7483,9 +7483,8 @@ NOTE: This behaviour is deprecated and w
1746
1747 /* The backend must work out the sizes of all the other dynamic
1748 sections. */
1749 - if (dynobj != NULL
1750 - && bed->elf_backend_size_dynamic_sections != NULL
1751 - && ! (*bed->elf_backend_size_dynamic_sections) (output_bfd, info))
1752 + if (bed->elf_backend_late_size_sections != NULL
1753 + && !bed->elf_backend_late_size_sections (output_bfd, info))
1754 return false;
1755
1756 if (dynobj != NULL && elf_hash_table (info)->dynamic_sections_created)
1757 --- a/bfd/elfn32-mips.c
1758 +++ b/bfd/elfn32-mips.c
1759 @@ -4138,10 +4138,8 @@ static const struct ecoff_debug_swap mip
1760 #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag
1761 #define elf_backend_adjust_dynamic_symbol \
1762 _bfd_mips_elf_adjust_dynamic_symbol
1763 -#define elf_backend_always_size_sections \
1764 - _bfd_mips_elf_always_size_sections
1765 -#define elf_backend_size_dynamic_sections \
1766 - _bfd_mips_elf_size_dynamic_sections
1767 +#define elf_backend_early_size_sections _bfd_mips_elf_early_size_sections
1768 +#define elf_backend_late_size_sections _bfd_mips_elf_late_size_sections
1769 #define elf_backend_init_index_section _bfd_elf_init_1_index_section
1770 #define elf_backend_relocate_section _bfd_mips_elf_relocate_section
1771 #define elf_backend_finish_dynamic_symbol \
1772 --- a/bfd/elfnn-aarch64.c
1773 +++ b/bfd/elfnn-aarch64.c
1774 @@ -112,7 +112,7 @@
1775 allocate space for one relocation on the slot. Record the GOT offset
1776 for this symbol.
1777
1778 - elfNN_aarch64_size_dynamic_sections ()
1779 + elfNN_aarch64_late_size_sections ()
1780
1781 Iterate all input BFDS, look for in the local symbol data structure
1782 constructed earlier for local TLS symbols and allocate them double
1783 @@ -9175,8 +9175,8 @@ elfNN_aarch64_allocate_local_ifunc_dynre
1784 though ! */
1785
1786 static bool
1787 -elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1788 - struct bfd_link_info *info)
1789 +elfNN_aarch64_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1790 + struct bfd_link_info *info)
1791 {
1792 struct elf_aarch64_link_hash_table *htab;
1793 bfd *dynobj;
1794 @@ -9187,7 +9187,8 @@ elfNN_aarch64_size_dynamic_sections (bfd
1795 htab = elf_aarch64_hash_table ((info));
1796 dynobj = htab->root.dynobj;
1797
1798 - BFD_ASSERT (dynobj != NULL);
1799 + if (dynobj == NULL)
1800 + return true;
1801
1802 if (htab->root.dynamic_sections_created)
1803 {
1804 @@ -9589,8 +9590,8 @@ elfNN_aarch64_create_small_pltn_entry (s
1805 _TLS_MODULE_BASE_, if needed. */
1806
1807 static bool
1808 -elfNN_aarch64_always_size_sections (bfd *output_bfd,
1809 - struct bfd_link_info *info)
1810 +elfNN_aarch64_early_size_sections (bfd *output_bfd,
1811 + struct bfd_link_info *info)
1812 {
1813 asection *tls_sec;
1814
1815 @@ -10323,8 +10324,8 @@ const struct elf_size_info elfNN_aarch64
1816 #define elf_backend_adjust_dynamic_symbol \
1817 elfNN_aarch64_adjust_dynamic_symbol
1818
1819 -#define elf_backend_always_size_sections \
1820 - elfNN_aarch64_always_size_sections
1821 +#define elf_backend_early_size_sections \
1822 + elfNN_aarch64_early_size_sections
1823
1824 #define elf_backend_check_relocs \
1825 elfNN_aarch64_check_relocs
1826 @@ -10379,8 +10380,8 @@ const struct elf_size_info elfNN_aarch64
1827 #define elf_backend_modify_headers \
1828 elfNN_aarch64_modify_headers
1829
1830 -#define elf_backend_size_dynamic_sections \
1831 - elfNN_aarch64_size_dynamic_sections
1832 +#define elf_backend_late_size_sections \
1833 + elfNN_aarch64_late_size_sections
1834
1835 #define elf_backend_size_info \
1836 elfNN_aarch64_size_info
1837 --- a/bfd/elfnn-ia64.c
1838 +++ b/bfd/elfnn-ia64.c
1839 @@ -2987,8 +2987,8 @@ elfNN_ia64_adjust_dynamic_symbol (struct
1840 }
1841
1842 static bool
1843 -elfNN_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1844 - struct bfd_link_info *info)
1845 +elfNN_ia64_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1846 + struct bfd_link_info *info)
1847 {
1848 struct elfNN_ia64_allocate_data data;
1849 struct elfNN_ia64_link_hash_table *ia64_info;
1850 @@ -2999,8 +2999,9 @@ elfNN_ia64_size_dynamic_sections (bfd *o
1851 if (ia64_info == NULL)
1852 return false;
1853 dynobj = ia64_info->root.dynobj;
1854 + if (dynobj == NULL)
1855 + return true;
1856 ia64_info->self_dtpmod_offset = (bfd_vma) -1;
1857 - BFD_ASSERT(dynobj != NULL);
1858 data.info = info;
1859
1860 /* Set the contents of the .interp section to the interpreter. */
1861 @@ -5036,8 +5037,8 @@ ignore_errors (const char *fmt ATTRIBUTE
1862 elfNN_ia64_check_relocs
1863 #define elf_backend_adjust_dynamic_symbol \
1864 elfNN_ia64_adjust_dynamic_symbol
1865 -#define elf_backend_size_dynamic_sections \
1866 - elfNN_ia64_size_dynamic_sections
1867 +#define elf_backend_late_size_sections \
1868 + elfNN_ia64_late_size_sections
1869 #define elf_backend_omit_section_dynsym \
1870 _bfd_elf_omit_section_dynsym_all
1871 #define elf_backend_relocate_section \
1872 --- a/bfd/elfnn-kvx.c
1873 +++ b/bfd/elfnn-kvx.c
1874 @@ -4033,8 +4033,8 @@ kvx_readonly_dynrelocs (struct elf_link_
1875 /* This is the most important function of all . Innocuosly named
1876 though ! */
1877 static bool
1878 -elfNN_kvx_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1879 - struct bfd_link_info *info)
1880 +elfNN_kvx_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
1881 + struct bfd_link_info *info)
1882 {
1883 struct elf_kvx_link_hash_table *htab;
1884 bfd *dynobj;
1885 @@ -4044,8 +4044,8 @@ elfNN_kvx_size_dynamic_sections (bfd *ou
1886
1887 htab = elf_kvx_hash_table ((info));
1888 dynobj = htab->root.dynobj;
1889 -
1890 - BFD_ASSERT (dynobj != NULL);
1891 + if (dynobj == NULL)
1892 + return true;
1893
1894 if (htab->root.dynamic_sections_created)
1895 {
1896 @@ -4359,8 +4359,7 @@ elfNN_kvx_create_small_pltn_entry (struc
1897 _TLS_MODULE_BASE_, if needed. */
1898
1899 static bool
1900 -elfNN_kvx_always_size_sections (bfd *output_bfd,
1901 - struct bfd_link_info *info)
1902 +elfNN_kvx_early_size_sections (bfd *output_bfd, struct bfd_link_info *info)
1903 {
1904 asection *tls_sec;
1905
1906 @@ -4715,8 +4714,8 @@ elfNN_kvx_plt_sym_val (bfd_vma i, const
1907 #define elf_backend_adjust_dynamic_symbol \
1908 elfNN_kvx_adjust_dynamic_symbol
1909
1910 -#define elf_backend_always_size_sections \
1911 - elfNN_kvx_always_size_sections
1912 +#define elf_backend_early_size_sections \
1913 + elfNN_kvx_early_size_sections
1914
1915 #define elf_backend_check_relocs \
1916 elfNN_kvx_check_relocs
1917 @@ -4759,8 +4758,8 @@ elfNN_kvx_plt_sym_val (bfd_vma i, const
1918 #define elf_backend_reloc_type_class \
1919 elfNN_kvx_reloc_type_class
1920
1921 -#define elf_backend_size_dynamic_sections \
1922 - elfNN_kvx_size_dynamic_sections
1923 +#define elf_backend_late_size_sections \
1924 + elfNN_kvx_late_size_sections
1925
1926 #define elf_backend_can_refcount 1
1927 #define elf_backend_can_gc_sections 1
1928 --- a/bfd/elfnn-loongarch.c
1929 +++ b/bfd/elfnn-loongarch.c
1930 @@ -1731,8 +1731,8 @@ maybe_set_textrel (struct elf_link_hash_
1931 }
1932
1933 static bool
1934 -loongarch_elf_size_dynamic_sections (bfd *output_bfd,
1935 - struct bfd_link_info *info)
1936 +loongarch_elf_late_size_sections (bfd *output_bfd,
1937 + struct bfd_link_info *info)
1938 {
1939 struct loongarch_elf_link_hash_table *htab;
1940 bfd *dynobj;
1941 @@ -1742,7 +1742,8 @@ loongarch_elf_size_dynamic_sections (bfd
1942 htab = loongarch_elf_hash_table (info);
1943 BFD_ASSERT (htab != NULL);
1944 dynobj = htab->elf.dynobj;
1945 - BFD_ASSERT (dynobj != NULL);
1946 + if (dynobj == NULL)
1947 + return true;
1948
1949 if (htab->elf.dynamic_sections_created)
1950 {
1951 @@ -5340,7 +5341,7 @@ elf_loongarch64_hash_symbol (struct elf_
1952 loongarch_elf_create_dynamic_sections
1953 #define elf_backend_check_relocs loongarch_elf_check_relocs
1954 #define elf_backend_adjust_dynamic_symbol loongarch_elf_adjust_dynamic_symbol
1955 -#define elf_backend_size_dynamic_sections loongarch_elf_size_dynamic_sections
1956 +#define elf_backend_late_size_sections loongarch_elf_late_size_sections
1957 #define elf_backend_relocate_section loongarch_elf_relocate_section
1958 #define elf_backend_finish_dynamic_symbol loongarch_elf_finish_dynamic_symbol
1959 #define elf_backend_output_arch_local_syms \
1960 --- a/bfd/elfnn-riscv.c
1961 +++ b/bfd/elfnn-riscv.c
1962 @@ -1482,7 +1482,7 @@ allocate_local_ifunc_dynrelocs (void **s
1963 }
1964
1965 static bool
1966 -riscv_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
1967 +riscv_elf_late_size_sections (bfd *output_bfd, struct bfd_link_info *info)
1968 {
1969 struct riscv_elf_link_hash_table *htab;
1970 bfd *dynobj;
1971 @@ -1492,7 +1492,8 @@ riscv_elf_size_dynamic_sections (bfd *ou
1972 htab = riscv_elf_hash_table (info);
1973 BFD_ASSERT (htab != NULL);
1974 dynobj = htab->elf.dynobj;
1975 - BFD_ASSERT (dynobj != NULL);
1976 + if (dynobj == NULL)
1977 + return true;
1978
1979 if (elf_hash_table (info)->dynamic_sections_created)
1980 {
1981 @@ -5570,7 +5571,7 @@ riscv_elf_merge_symbol_attribute (struct
1982 #define elf_backend_create_dynamic_sections riscv_elf_create_dynamic_sections
1983 #define elf_backend_check_relocs riscv_elf_check_relocs
1984 #define elf_backend_adjust_dynamic_symbol riscv_elf_adjust_dynamic_symbol
1985 -#define elf_backend_size_dynamic_sections riscv_elf_size_dynamic_sections
1986 +#define elf_backend_late_size_sections riscv_elf_late_size_sections
1987 #define elf_backend_relocate_section riscv_elf_relocate_section
1988 #define elf_backend_finish_dynamic_symbol riscv_elf_finish_dynamic_symbol
1989 #define elf_backend_finish_dynamic_sections riscv_elf_finish_dynamic_sections
1990 --- a/bfd/elfxx-mips.c
1991 +++ b/bfd/elfxx-mips.c
1992 @@ -9649,8 +9649,8 @@ _bfd_mips_elf_adjust_dynamic_symbol (str
1993 check for any mips16 stub sections that we can discard. */
1994
1995 bool
1996 -_bfd_mips_elf_always_size_sections (bfd *output_bfd,
1997 - struct bfd_link_info *info)
1998 +_bfd_mips_elf_early_size_sections (bfd *output_bfd,
1999 + struct bfd_link_info *info)
2000 {
2001 asection *sect;
2002 struct mips_elf_link_hash_table *htab;
2003 @@ -9993,8 +9993,8 @@ mips_elf_set_plt_sym_value (struct mips_
2004 /* Set the sizes of the dynamic sections. */
2005
2006 bool
2007 -_bfd_mips_elf_size_dynamic_sections (bfd *output_bfd,
2008 - struct bfd_link_info *info)
2009 +_bfd_mips_elf_late_size_sections (bfd *output_bfd,
2010 + struct bfd_link_info *info)
2011 {
2012 bfd *dynobj;
2013 asection *s, *sreldyn;
2014 @@ -10004,7 +10004,8 @@ _bfd_mips_elf_size_dynamic_sections (bfd
2015 htab = mips_elf_hash_table (info);
2016 BFD_ASSERT (htab != NULL);
2017 dynobj = elf_hash_table (info)->dynobj;
2018 - BFD_ASSERT (dynobj != NULL);
2019 + if (dynobj == NULL)
2020 + return true;
2021
2022 if (elf_hash_table (info)->dynamic_sections_created)
2023 {
2024 @@ -14938,7 +14939,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str
2025 input_section->flags &= ~SEC_HAS_CONTENTS;
2026 }
2027
2028 - /* Size has been set in _bfd_mips_elf_always_size_sections. */
2029 + /* Size has been set in _bfd_mips_elf_early_size_sections. */
2030 BFD_ASSERT(o->size == sizeof (Elf_External_ABIFlags_v0));
2031
2032 /* Skip this section later on (I don't think this currently
2033 @@ -14997,7 +14998,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str
2034 input_section->flags &= ~SEC_HAS_CONTENTS;
2035 }
2036
2037 - /* Size has been set in _bfd_mips_elf_always_size_sections. */
2038 + /* Size has been set in _bfd_mips_elf_early_size_sections. */
2039 BFD_ASSERT(o->size == sizeof (Elf32_External_RegInfo));
2040
2041 /* Skip this section later on (I don't think this currently
2042 --- a/bfd/elfxx-mips.h
2043 +++ b/bfd/elfxx-mips.h
2044 @@ -67,9 +67,9 @@ extern bool _bfd_mips_elf_check_relocs
2045 (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *);
2046 extern bool _bfd_mips_elf_adjust_dynamic_symbol
2047 (struct bfd_link_info *, struct elf_link_hash_entry *);
2048 -extern bool _bfd_mips_elf_always_size_sections
2049 +extern bool _bfd_mips_elf_early_size_sections
2050 (bfd *, struct bfd_link_info *);
2051 -extern bool _bfd_mips_elf_size_dynamic_sections
2052 +extern bool _bfd_mips_elf_late_size_sections
2053 (bfd *, struct bfd_link_info *);
2054 extern int _bfd_mips_elf_relocate_section
2055 (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
2056 --- a/bfd/elfxx-sparc.c
2057 +++ b/bfd/elfxx-sparc.c
2058 @@ -2381,8 +2381,8 @@ _bfd_sparc_elf_omit_section_dynsym (bfd
2059 /* Set the sizes of the dynamic sections. */
2060
2061 bool
2062 -_bfd_sparc_elf_size_dynamic_sections (bfd *output_bfd,
2063 - struct bfd_link_info *info)
2064 +_bfd_sparc_elf_late_size_sections (bfd *output_bfd,
2065 + struct bfd_link_info *info)
2066 {
2067 struct _bfd_sparc_elf_link_hash_table *htab;
2068 bfd *dynobj;
2069 @@ -2392,7 +2392,8 @@ _bfd_sparc_elf_size_dynamic_sections (bf
2070 htab = _bfd_sparc_elf_hash_table (info);
2071 BFD_ASSERT (htab != NULL);
2072 dynobj = htab->elf.dynobj;
2073 - BFD_ASSERT (dynobj != NULL);
2074 + if (dynobj == NULL)
2075 + return true;
2076
2077 if (elf_hash_table (info)->dynamic_sections_created)
2078 {
2079 --- a/bfd/elfxx-sparc.h
2080 +++ b/bfd/elfxx-sparc.h
2081 @@ -117,7 +117,7 @@ extern bool _bfd_sparc_elf_adjust_dynami
2082 (struct bfd_link_info *, struct elf_link_hash_entry *);
2083 extern bool _bfd_sparc_elf_omit_section_dynsym
2084 (bfd *, struct bfd_link_info *, asection *);
2085 -extern bool _bfd_sparc_elf_size_dynamic_sections
2086 +extern bool _bfd_sparc_elf_late_size_sections
2087 (bfd *, struct bfd_link_info *);
2088 extern bool _bfd_sparc_elf_new_section_hook
2089 (bfd *, asection *);
2090 --- a/bfd/elfxx-target.h
2091 +++ b/bfd/elfxx-target.h
2092 @@ -487,11 +487,11 @@
2093 #ifndef elf_backend_adjust_dynamic_symbol
2094 #define elf_backend_adjust_dynamic_symbol 0
2095 #endif
2096 -#ifndef elf_backend_always_size_sections
2097 -#define elf_backend_always_size_sections 0
2098 +#ifndef elf_backend_early_size_sections
2099 +#define elf_backend_early_size_sections 0
2100 #endif
2101 -#ifndef elf_backend_size_dynamic_sections
2102 -#define elf_backend_size_dynamic_sections 0
2103 +#ifndef elf_backend_late_size_sections
2104 +#define elf_backend_late_size_sections 0
2105 #endif
2106 #ifndef elf_backend_strip_zero_sized_dynamic_sections
2107 #define elf_backend_strip_zero_sized_dynamic_sections 0
2108 @@ -853,8 +853,8 @@ static const struct elf_backend_data elf
2109 elf_backend_check_directives,
2110 elf_backend_notice_as_needed,
2111 elf_backend_adjust_dynamic_symbol,
2112 - elf_backend_always_size_sections,
2113 - elf_backend_size_dynamic_sections,
2114 + elf_backend_early_size_sections,
2115 + elf_backend_late_size_sections,
2116 elf_backend_strip_zero_sized_dynamic_sections,
2117 elf_backend_init_index_section,
2118 elf_backend_relocate_section,
2119 --- a/bfd/elfxx-tilegx.c
2120 +++ b/bfd/elfxx-tilegx.c
2121 @@ -2430,8 +2430,8 @@ tilegx_elf_omit_section_dynsym (bfd *out
2122 }
2123
2124 bool
2125 -tilegx_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
2126 - struct bfd_link_info *info)
2127 +tilegx_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
2128 + struct bfd_link_info *info)
2129 {
2130 struct tilegx_elf_link_hash_table *htab;
2131 bfd *dynobj;
2132 @@ -2441,7 +2441,8 @@ tilegx_elf_size_dynamic_sections (bfd *o
2133 htab = tilegx_elf_hash_table (info);
2134 BFD_ASSERT (htab != NULL);
2135 dynobj = htab->elf.dynobj;
2136 - BFD_ASSERT (dynobj != NULL);
2137 + if (dynobj == NULL)
2138 + return true;
2139
2140 if (elf_hash_table (info)->dynamic_sections_created)
2141 {
2142 --- a/bfd/elfxx-tilegx.h
2143 +++ b/bfd/elfxx-tilegx.h
2144 @@ -57,7 +57,7 @@ tilegx_elf_omit_section_dynsym (bfd *,
2145 asection *);
2146
2147 extern bool
2148 -tilegx_elf_size_dynamic_sections (bfd *, struct bfd_link_info *);
2149 +tilegx_elf_late_size_sections (bfd *, struct bfd_link_info *);
2150
2151 extern int
2152 tilegx_elf_relocate_section (bfd *, struct bfd_link_info *,
2153 --- a/bfd/elfxx-x86.c
2154 +++ b/bfd/elfxx-x86.c
2155 @@ -2241,7 +2241,7 @@ _bfd_elf_x86_valid_reloc_p (asection *in
2156 /* Set the sizes of the dynamic sections. */
2157
2158 bool
2159 -_bfd_x86_elf_size_dynamic_sections (bfd *output_bfd,
2160 +_bfd_x86_elf_late_size_sections (bfd *output_bfd,
2161 struct bfd_link_info *info)
2162 {
2163 struct elf_x86_link_hash_table *htab;
2164 @@ -2257,7 +2257,7 @@ _bfd_x86_elf_size_dynamic_sections (bfd
2165 return false;
2166 dynobj = htab->elf.dynobj;
2167 if (dynobj == NULL)
2168 - abort ();
2169 + return true;
2170
2171 /* Set up .got offsets for local syms, and space for local dynamic
2172 relocs. */
2173 @@ -3003,8 +3003,8 @@ _bfd_x86_elf_finish_dynamic_sections (bf
2174
2175
2176 bool
2177 -_bfd_x86_elf_always_size_sections (bfd *output_bfd,
2178 - struct bfd_link_info *info)
2179 +_bfd_x86_elf_early_size_sections (bfd *output_bfd,
2180 + struct bfd_link_info *info)
2181 {
2182 asection *tls_sec = elf_hash_table (info)->tls_sec;
2183
2184 --- a/bfd/elfxx-x86.h
2185 +++ b/bfd/elfxx-x86.h
2186 @@ -850,13 +850,13 @@ extern bool _bfd_elf_x86_valid_reloc_p
2187 const Elf_Internal_Rela *, struct elf_link_hash_entry *,
2188 Elf_Internal_Sym *, Elf_Internal_Shdr *, bool *);
2189
2190 -extern bool _bfd_x86_elf_size_dynamic_sections
2191 +extern bool _bfd_x86_elf_late_size_sections
2192 (bfd *, struct bfd_link_info *);
2193
2194 extern struct elf_x86_link_hash_table *_bfd_x86_elf_finish_dynamic_sections
2195 (bfd *, struct bfd_link_info *);
2196
2197 -extern bool _bfd_x86_elf_always_size_sections
2198 +extern bool _bfd_x86_elf_early_size_sections
2199 (bfd *, struct bfd_link_info *);
2200
2201 extern void _bfd_x86_elf_merge_symbol_attribute
2202 @@ -928,8 +928,8 @@ extern void _bfd_x86_elf_link_report_rel
2203
2204 #define elf_backend_check_relocs \
2205 _bfd_x86_elf_check_relocs
2206 -#define elf_backend_size_dynamic_sections \
2207 - _bfd_x86_elf_size_dynamic_sections
2208 +#define elf_backend_late_size_sections \
2209 + _bfd_x86_elf_late_size_sections
2210 #define elf_backend_merge_symbol_attribute \
2211 _bfd_x86_elf_merge_symbol_attribute
2212 #define elf_backend_copy_indirect_symbol \
2213 --- a/ld/emultempl/vms.em
2214 +++ b/ld/emultempl/vms.em
2215 @@ -197,10 +197,9 @@ gld${EMULATION_NAME}_before_allocation (
2216
2217 /* The backend must work out the sizes of all the other dynamic
2218 sections. */
2219 - if (elf_hash_table (&link_info)->dynamic_sections_created
2220 - && bed->elf_backend_size_dynamic_sections
2221 - && ! (*bed->elf_backend_size_dynamic_sections) (link_info.output_bfd,
2222 - &link_info))
2223 + if (bed->elf_backend_late_size_sections
2224 + && !bed->elf_backend_late_size_sections (link_info.output_bfd,
2225 + &link_info))
2226 einfo (_("%F%P: failed to set dynamic section sizes: %E\n"));
2227
2228 before_allocation_default ();