]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blob - binutils/patches/binutils-2.23.2-kernel-ld-r.patch0
ppp: Re-add ifname patch
[people/ms/ipfire-3.x.git] / binutils / patches / binutils-2.23.2-kernel-ld-r.patch0
1 diff -cpr ../binutils-2.23.2.orig/bfd/bfd.c bfd/bfd.c
2 *** ../binutils-2.23.2.orig/bfd/bfd.c 2013-05-14 16:39:24.681717759 +0100
3 --- bfd/bfd.c 2013-05-14 16:40:06.988718932 +0100
4 *************** CODE_FRAGMENT
5 *** 43,48 ****
6 --- 43,56 ----
7 . both_direction = 3
8 . };
9 .
10 + .enum bfd_lto_object_type
11 + . {
12 + . lto_non_object,
13 + . lto_non_ir_object,
14 + . lto_ir_object,
15 + . lto_mixed_object
16 + . };
17 + .
18 .struct bfd
19 .{
20 . {* A unique identifier of the BFD *}
21 *************** CODE_FRAGMENT
22 *** 190,195 ****
23 --- 198,206 ----
24 . {* The last section on the section list. *}
25 . struct bfd_section *section_last;
26 .
27 + . {* The object-only section on the section list. *}
28 + . struct bfd_section *object_only_section;
29 + .
30 . {* The number of sections. *}
31 . unsigned int section_count;
32 .
33 *************** CODE_FRAGMENT
34 *** 308,313 ****
35 --- 319,327 ----
36 . {* Set if only required symbols should be added in the link hash table for
37 . this object. Used by VMS linkers. *}
38 . unsigned int selective_search : 1;
39 + .
40 + . {* LTO object type. *}
41 + . unsigned int lto_type : 2;
42 .};
43 .
44 */
45 *************** bfd_demangle (bfd *abfd, const char *nam
46 *** 2026,2028 ****
47 --- 2040,2075 ----
48
49 return res;
50 }
51 +
52 + /*
53 + FUNCTION
54 + bfd_group_signature
55 +
56 + SYNOPSIS
57 + asymbol *bfd_group_signature (asection *group, asymbol **isympp);
58 +
59 + DESCRIPTION
60 + Return a pointer to the symbol used as a signature for GROUP.
61 + */
62 +
63 + asymbol *
64 + bfd_group_signature (asection *group, asymbol **isympp)
65 + {
66 + bfd *abfd = group->owner;
67 + Elf_Internal_Shdr *ghdr;
68 +
69 + if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
70 + return NULL;
71 +
72 + ghdr = &elf_section_data (group)->this_hdr;
73 + if (ghdr->sh_link < elf_numsections (abfd))
74 + {
75 + const struct elf_backend_data *bed = get_elf_backend_data (abfd);
76 + Elf_Internal_Shdr *symhdr = elf_elfsections (abfd) [ghdr->sh_link];
77 +
78 + if (symhdr->sh_type == SHT_SYMTAB
79 + && ghdr->sh_info < symhdr->sh_size / bed->s->sizeof_sym)
80 + return isympp[ghdr->sh_info - 1];
81 + }
82 + return NULL;
83 + }
84 diff -cpr ../binutils-2.23.2.orig/bfd/bfd-in2.h bfd/bfd-in2.h
85 *** ../binutils-2.23.2.orig/bfd/bfd-in2.h 2013-05-14 16:39:24.640717758 +0100
86 --- bfd/bfd-in2.h 2013-05-14 16:42:03.217722154 +0100
87 *************** struct bfd_section *bfd_create_gnu_debug
88 *** 1050,1055 ****
89 --- 1050,1058 ----
90 bfd_boolean bfd_fill_in_gnu_debuglink_section
91 (bfd *abfd, struct bfd_section *sect, const char *filename);
92
93 + const char *bfd_extract_object_only_section
94 + (bfd *abfd);
95 +
96 /* Extracted from libbfd.c. */
97
98 /* Byte swapping macros for user section data. */
99 *************** extern asection std_section[4];
100 *** 1594,1599 ****
101 --- 1597,1605 ----
102 || ((SEC) == bfd_com_section_ptr) \
103 || ((SEC) == bfd_ind_section_ptr))
104
105 + /* GNU object-only section name. */
106 + #define GNU_OBJECT_ONLY_SECTION_NAME ".gnu_object_only"
107 +
108 /* Macros to handle insertion and deletion of a bfd's sections. These
109 only handle the list pointers, ie. do not adjust section_count,
110 target_index etc. */
111 *************** enum bfd_direction
112 *** 5681,5686 ****
113 --- 5687,5700 ----
114 both_direction = 3
115 };
116
117 + enum bfd_lto_object_type
118 + {
119 + lto_non_object,
120 + lto_non_ir_object,
121 + lto_ir_object,
122 + lto_mixed_object
123 + };
124 +
125 struct bfd
126 {
127 /* A unique identifier of the BFD */
128 *************** struct bfd
129 *** 5828,5833 ****
130 --- 5842,5850 ----
131 /* The last section on the section list. */
132 struct bfd_section *section_last;
133
134 + /* The object-only section on the section list. */
135 + struct bfd_section *object_only_section;
136 +
137 /* The number of sections. */
138 unsigned int section_count;
139
140 *************** struct bfd
141 *** 5946,5951 ****
142 --- 5963,5971 ----
143 /* Set if only required symbols should be added in the link hash table for
144 this object. Used by VMS linkers. */
145 unsigned int selective_search : 1;
146 +
147 + /* LTO object type. */
148 + unsigned int lto_type : 2;
149 };
150
151 typedef enum bfd_error
152 *************** void bfd_emul_set_commonpagesize (const
153 *** 6167,6172 ****
154 --- 6187,6194 ----
155
156 char *bfd_demangle (bfd *, const char *, int);
157
158 + asymbol *bfd_group_signature (asection *group, asymbol **isympp);
159 +
160 /* Extracted from archive.c. */
161 symindex bfd_get_next_mapent
162 (bfd *abfd, symindex previous, carsym **sym);
163 diff -cpr ../binutils-2.23.2.orig/bfd/elf.c bfd/elf.c
164 *** ../binutils-2.23.2.orig/bfd/elf.c 2013-05-14 16:39:25.317717777 +0100
165 --- bfd/elf.c 2013-05-14 16:40:06.993718932 +0100
166 *************** static const struct bfd_elf_special_sect
167 *** 2092,2097 ****
168 --- 2092,2098 ----
169 { STRING_COMMA_LEN (".gnu.linkonce.b"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE },
170 { STRING_COMMA_LEN (".gnu.lto_"), -1, SHT_PROGBITS, SHF_EXCLUDE },
171 { STRING_COMMA_LEN (".got"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
172 + { STRING_COMMA_LEN (".gnu_object_only"), 0, SHT_GNU_OBJECT_ONLY, SHF_EXCLUDE },
173 { STRING_COMMA_LEN (".gnu.version"), 0, SHT_GNU_versym, 0 },
174 { STRING_COMMA_LEN (".gnu.version_d"), 0, SHT_GNU_verdef, 0 },
175 { STRING_COMMA_LEN (".gnu.version_r"), 0, SHT_GNU_verneed, 0 },
176 diff -cpr ../binutils-2.23.2.orig/bfd/elflink.c bfd/elflink.c
177 *** ../binutils-2.23.2.orig/bfd/elflink.c 2013-05-14 16:39:25.280717776 +0100
178 --- bfd/elflink.c 2013-05-14 16:40:06.997718932 +0100
179 *************** elf_link_add_archive_symbols (bfd *abfd,
180 *** 5127,5132 ****
181 --- 5127,5135 ----
182 something wrong with the archive. */
183 if (element->archive_pass != 0)
184 {
185 + /* Don't load the IR archive member twice. */
186 + if (element->lto_type == lto_ir_object)
187 + continue;
188 bfd_set_error (bfd_error_bad_value);
189 goto error_return;
190 }
191 diff -cpr ../binutils-2.23.2.orig/bfd/format.c bfd/format.c
192 *** ../binutils-2.23.2.orig/bfd/format.c 2013-05-14 16:39:24.265717748 +0100
193 --- bfd/format.c 2013-05-14 16:40:07.006718933 +0100
194 *************** bfd_check_format (bfd *abfd, bfd_format
195 *** 95,100 ****
196 --- 95,127 ----
197 return bfd_check_format_matches (abfd, format, NULL);
198 }
199
200 + /* Set lto_type in ABFD. */
201 +
202 + static void
203 + bfd_set_lto_type (bfd *abfd)
204 + {
205 + if (abfd->format == bfd_object
206 + && abfd->lto_type == lto_non_object
207 + && (abfd->flags & (DYNAMIC | EXEC_P)) == 0)
208 + {
209 + asection *sec;
210 + enum bfd_lto_object_type type = lto_non_ir_object;
211 + for (sec = abfd->sections; sec != NULL; sec = sec->next)
212 + {
213 + if (strcmp (sec->name, GNU_OBJECT_ONLY_SECTION_NAME) == 0)
214 + {
215 + type = lto_mixed_object;
216 + abfd->object_only_section = sec;
217 + break;
218 + }
219 + else if (type != lto_ir_object
220 + && strncmp (sec->name, ".gnu.lto_", 9) == 0)
221 + type = lto_ir_object;
222 + }
223 + abfd->lto_type = type;
224 + }
225 + }
226 +
227 struct bfd_preserve
228 {
229 void *marker;
230 *************** bfd_check_format_matches (bfd *abfd, bfd
231 *** 136,142 ****
232 }
233
234 if (abfd->format != bfd_unknown)
235 ! return abfd->format == format;
236
237 if (matching != NULL || *bfd_associated_vector != NULL)
238 {
239 --- 163,172 ----
240 }
241
242 if (abfd->format != bfd_unknown)
243 ! {
244 ! bfd_set_lto_type (abfd);
245 ! return abfd->format == format;
246 ! }
247
248 if (matching != NULL || *bfd_associated_vector != NULL)
249 {
250 *************** bfd_check_format_matches (bfd *abfd, bfd
251 *** 322,327 ****
252 --- 352,360 ----
253
254 if (matching_vector)
255 free (matching_vector);
256 +
257 + bfd_set_lto_type (abfd);
258 +
259
260 /* File position has moved, BTW. */
261 return TRUE;
262 diff -cpr ../binutils-2.23.2.orig/bfd/opncls.c bfd/opncls.c
263 *** ../binutils-2.23.2.orig/bfd/opncls.c 2013-05-14 16:39:23.701717732 +0100
264 --- bfd/opncls.c 2013-05-14 16:40:07.008718933 +0100
265 *************** bfd_fill_in_gnu_debuglink_section (bfd *
266 *** 1569,1571 ****
267 --- 1569,1637 ----
268
269 return TRUE;
270 }
271 +
272 + /*
273 + FUNCTION
274 + bfd_extract_object_only_section
275 +
276 + SYNOPSIS
277 + const char *bfd_extract_object_only_section
278 + (bfd *abfd);
279 +
280 + DESCRIPTION
281 +
282 + Takes a @var{ABFD} and extract the .gnu_object_only section into
283 + a temporary file.
284 +
285 + RETURNS
286 + The name of the temporary file is returned if all is ok.
287 + Otherwise <<NULL>> is returned and bfd_error is set.
288 + */
289 +
290 + const char *
291 + bfd_extract_object_only_section (bfd *abfd)
292 + {
293 + asection *sec = abfd->object_only_section;
294 + const char *name;
295 + FILE *file;
296 + bfd_byte *memhunk = NULL;
297 + size_t off, size;
298 + bfd_error_type err;
299 +
300 + /* Get a temporary object-only file. */
301 + name = make_temp_file (".obj-only.o");
302 +
303 + /* Open the object-only file. */
304 + file = real_fopen (name, FOPEN_WB);
305 + if (!bfd_get_full_section_contents (abfd, sec, &memhunk))
306 + {
307 + err = bfd_get_error ();
308 +
309 + loser:
310 + free (memhunk);
311 + fclose (file);
312 + unlink (name);
313 + bfd_set_error (err);
314 + return NULL;
315 + }
316 +
317 + off = 0;
318 + size = sec->size;
319 + while (off != size)
320 + {
321 + size_t written, nwrite = size - off;
322 +
323 + written = fwrite (memhunk + off, 1, nwrite, file);
324 + if (written < nwrite && ferror (file))
325 + {
326 + err = bfd_error_system_call;
327 + goto loser;
328 + }
329 +
330 + off += written;
331 + }
332 +
333 + free (memhunk);
334 + fclose (file);
335 + return name;
336 + }
337 diff -cpr ../binutils-2.23.2.orig/bfd/plugin.c bfd/plugin.c
338 *** ../binutils-2.23.2.orig/bfd/plugin.c 2013-05-14 16:39:25.137717772 +0100
339 --- bfd/plugin.c 2013-05-14 16:40:07.010718933 +0100
340 *************** register_claim_file (ld_plugin_claim_fil
341 *** 130,135 ****
342 --- 130,268 ----
343 return LDPS_OK;
344 }
345
346 + static asection bfd_plugin_fake_text_section
347 + = BFD_FAKE_SECTION (bfd_plugin_fake_text_section, 0, 0, ".text", 0);
348 + static asection bfd_plugin_fake_common_section
349 + = BFD_FAKE_SECTION (bfd_plugin_fake_common_section, SEC_IS_COMMON, 0,
350 + NULL, 0);
351 +
352 + /* Get symbols from object only section. */
353 +
354 + static void
355 + bfd_plugin_get_symbols_in_object_only (bfd *abfd)
356 + {
357 + struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data;
358 + const char *object_only_file;
359 + bfd *nbfd;
360 + long storage;
361 + long object_only_nsyms, added_nsyms, i;
362 + asymbol **object_only_syms, **added_syms;
363 +
364 + plugin_data->object_only_syms = NULL;
365 + plugin_data->object_only_nsyms = 0;
366 +
367 + if (abfd->sections == NULL && abfd->my_archive == NULL)
368 + {
369 + nbfd = bfd_openr (abfd->filename, NULL);
370 + if (nbfd == NULL || !bfd_check_format (nbfd, bfd_object))
371 + {
372 + (*_bfd_error_handler)
373 + (_("%s: failed to open to extract object only section: %s"),
374 + abfd->filename, bfd_errmsg (bfd_get_error ()));
375 + bfd_close (nbfd);
376 + return;
377 + }
378 + }
379 + else
380 + {
381 + if (!bfd_check_format (abfd, bfd_object))
382 + {
383 + (*_bfd_error_handler)
384 + (_("%B: invalid file to extract object only section: %s"),
385 + abfd, bfd_errmsg (bfd_get_error ()));
386 + return;
387 + }
388 + nbfd = abfd;
389 + }
390 +
391 + if (nbfd->lto_type == lto_mixed_object
392 + && (nbfd->flags & HAS_SYMS) != 0)
393 + {
394 + object_only_file = bfd_extract_object_only_section (nbfd);
395 + if (object_only_file == NULL)
396 + (*_bfd_error_handler)
397 + (_("%B: failed to extract object only section: %s"),
398 + abfd, bfd_errmsg (bfd_get_error ()));
399 + }
400 + else
401 + object_only_file = NULL;
402 +
403 + /* Close the new bfd we just opened. */
404 + if (nbfd != abfd)
405 + bfd_close (nbfd);
406 +
407 + /* Return if there is no object only section or there is no
408 + symbol in object only section. */
409 + if (!object_only_file)
410 + return;
411 +
412 + /* Open the file containing object only section. */
413 + nbfd = bfd_openr (object_only_file, NULL);
414 + if (!bfd_check_format (nbfd, bfd_object))
415 + {
416 + (*_bfd_error_handler)
417 + (_("%B: failed to open object only section: %s"),
418 + abfd, bfd_errmsg (bfd_get_error ()));
419 + goto quit;
420 + }
421 +
422 + storage = bfd_get_symtab_upper_bound (nbfd);
423 + if (storage <= 0)
424 + {
425 + if (storage < 0)
426 + (*_bfd_error_handler)
427 + (_("%B: failed to get symbol table in object only section: %s"),
428 + abfd, bfd_errmsg (bfd_get_error ()));
429 +
430 + goto quit;
431 + }
432 +
433 + object_only_syms = (asymbol **) bfd_malloc (storage);
434 + object_only_nsyms = bfd_canonicalize_symtab (nbfd, object_only_syms);
435 +
436 + /* FIXME: We waste some spaces if not all symbols are copied. */
437 + added_syms = (asymbol **) bfd_alloc (abfd, storage);
438 + added_nsyms = 0;
439 +
440 + /* Copy only global symbols from object only section. */
441 + for (i = 0; i < object_only_nsyms; i++)
442 + {
443 + asection *sec = object_only_syms[i]->section;
444 + flagword flags = object_only_syms[i]->flags;
445 + asymbol *s;
446 +
447 + if (bfd_is_com_section (sec))
448 + sec = &bfd_plugin_fake_common_section;
449 + else if (bfd_is_und_section (sec))
450 + ;
451 + else if ((flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0)
452 + sec = &bfd_plugin_fake_text_section;
453 + else
454 + continue;
455 +
456 + s = bfd_alloc (abfd, sizeof (asymbol));
457 + BFD_ASSERT (s);
458 + added_syms[added_nsyms++] = s;
459 +
460 + s->section = sec;
461 + s->the_bfd = abfd;
462 + s->name = xstrdup (object_only_syms[i]->name);
463 + s->value = 0;
464 + s->flags = flags;
465 + s->udata.p = NULL;
466 + }
467 +
468 + plugin_data->object_only_syms = added_syms;
469 + plugin_data->object_only_nsyms = added_nsyms;
470 +
471 + free (object_only_syms);
472 +
473 + quit:
474 + /* Close and remove the object only section file. */
475 + bfd_close (nbfd);
476 + unlink (object_only_file);
477 + }
478 +
479 static enum ld_plugin_status
480 add_symbols (void * handle,
481 int nsyms,
482 *************** add_symbols (void * handle,
483 *** 142,148 ****
484 plugin_data->nsyms = nsyms;
485 plugin_data->syms = syms;
486
487 ! if (nsyms != 0)
488 abfd->flags |= HAS_SYMS;
489
490 abfd->tdata.plugin_data = plugin_data;
491 --- 275,283 ----
492 plugin_data->nsyms = nsyms;
493 plugin_data->syms = syms;
494
495 ! bfd_plugin_get_symbols_in_object_only (abfd);
496 !
497 ! if ((nsyms + plugin_data->object_only_nsyms) != 0)
498 abfd->flags |= HAS_SYMS;
499
500 abfd->tdata.plugin_data = plugin_data;
501 *************** static long
502 *** 389,395 ****
503 bfd_plugin_get_symtab_upper_bound (bfd *abfd)
504 {
505 struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data;
506 ! long nsyms = plugin_data->nsyms;
507
508 BFD_ASSERT (nsyms >= 0);
509
510 --- 524,531 ----
511 bfd_plugin_get_symtab_upper_bound (bfd *abfd)
512 {
513 struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data;
514 ! /* Add symbols from object only section. */
515 ! long nsyms = plugin_data->nsyms + plugin_data->object_only_nsyms;
516
517 BFD_ASSERT (nsyms >= 0);
518
519 *************** bfd_plugin_canonicalize_symtab (bfd *abf
520 *** 423,434 ****
521 struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data;
522 long nsyms = plugin_data->nsyms;
523 const struct ld_plugin_symbol *syms = plugin_data->syms;
524 ! static asection fake_section;
525 ! static asection fake_common_section;
526 ! int i;
527 !
528 ! fake_section.name = ".text";
529 ! fake_common_section.flags = SEC_IS_COMMON;
530
531 for (i = 0; i < nsyms; i++)
532 {
533 --- 559,565 ----
534 struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data;
535 long nsyms = plugin_data->nsyms;
536 const struct ld_plugin_symbol *syms = plugin_data->syms;
537 ! int i, j;
538
539 for (i = 0; i < nsyms; i++)
540 {
541 *************** bfd_plugin_canonicalize_symtab (bfd *abf
542 *** 441,450 ****
543 s->name = syms[i].name;
544 s->value = 0;
545 s->flags = convert_flags (&syms[i]);
546 switch (syms[i].def)
547 {
548 case LDPK_COMMON:
549 ! s->section = &fake_common_section;
550 break;
551 case LDPK_UNDEF:
552 case LDPK_WEAKUNDEF:
553 --- 572,582 ----
554 s->name = syms[i].name;
555 s->value = 0;
556 s->flags = convert_flags (&syms[i]);
557 + s->udata.p = NULL;
558 switch (syms[i].def)
559 {
560 case LDPK_COMMON:
561 ! s->section = &bfd_plugin_fake_common_section;
562 break;
563 case LDPK_UNDEF:
564 case LDPK_WEAKUNDEF:
565 *************** bfd_plugin_canonicalize_symtab (bfd *abf
566 *** 452,466 ****
567 break;
568 case LDPK_DEF:
569 case LDPK_WEAKDEF:
570 ! s->section = &fake_section;
571 break;
572 default:
573 BFD_ASSERT (0);
574 }
575 -
576 - s->udata.p = (void *) &syms[i];
577 }
578
579 return nsyms;
580 }
581
582 --- 584,601 ----
583 break;
584 case LDPK_DEF:
585 case LDPK_WEAKDEF:
586 ! s->section = &bfd_plugin_fake_text_section;
587 break;
588 default:
589 BFD_ASSERT (0);
590 }
591 }
592
593 + /* Copy symbols from object only section. */
594 + nsyms += plugin_data->object_only_nsyms;
595 + for (j = 0; j < plugin_data->object_only_nsyms; j++, i++)
596 + alocation[i] = plugin_data->object_only_syms[j];
597 +
598 return nsyms;
599 }
600
601 diff -cpr ../binutils-2.23.2.orig/bfd/plugin.h bfd/plugin.h
602 *** ../binutils-2.23.2.orig/bfd/plugin.h 2013-05-14 16:39:25.481717782 +0100
603 --- bfd/plugin.h 2013-05-14 16:40:07.010718933 +0100
604 *************** typedef struct plugin_data_struct
605 *** 30,35 ****
606 --- 30,37 ----
607 {
608 int nsyms;
609 const struct ld_plugin_symbol *syms;
610 + int object_only_nsyms;
611 + asymbol **object_only_syms;
612 }
613 plugin_data_struct;
614
615 diff -cpr ../binutils-2.23.2.orig/bfd/section.c bfd/section.c
616 *** ../binutils-2.23.2.orig/bfd/section.c 2013-05-14 16:39:26.180717801 +0100
617 --- bfd/section.c 2013-05-14 16:43:06.082723897 +0100
618 *************** CODE_FRAGMENT
619 *** 571,576 ****
620 --- 571,579 ----
621 . || ((SEC) == bfd_com_section_ptr) \
622 . || ((SEC) == bfd_ind_section_ptr))
623 .
624 + .{* GNU object-only section name. *}
625 + .#define GNU_OBJECT_ONLY_SECTION_NAME ".gnu_object_only"
626 + .
627 .{* Macros to handle insertion and deletion of a bfd's sections. These
628 . only handle the list pointers, ie. do not adjust section_count,
629 . target_index etc. *}
630 diff -cpr ../binutils-2.23.2.orig/binutils/objcopy.c binutils/objcopy.c
631 *** ../binutils-2.23.2.orig/binutils/objcopy.c 2013-05-14 16:39:36.214718079 +0100
632 --- binutils/objcopy.c 2013-05-14 16:45:04.631727183 +0100
633 *************** is_specified_symbol (const char *name, h
634 *** 943,972 ****
635 return htab_find (htab, name) != NULL;
636 }
637
638 - /* Return a pointer to the symbol used as a signature for GROUP. */
639 -
640 - static asymbol *
641 - group_signature (asection *group)
642 - {
643 - bfd *abfd = group->owner;
644 - Elf_Internal_Shdr *ghdr;
645 -
646 - if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
647 - return NULL;
648 -
649 - ghdr = &elf_section_data (group)->this_hdr;
650 - if (ghdr->sh_link < elf_numsections (abfd))
651 - {
652 - const struct elf_backend_data *bed = get_elf_backend_data (abfd);
653 - Elf_Internal_Shdr *symhdr = elf_elfsections (abfd) [ghdr->sh_link];
654 -
655 - if (symhdr->sh_type == SHT_SYMTAB
656 - && ghdr->sh_info < symhdr->sh_size / bed->s->sizeof_sym)
657 - return isympp[ghdr->sh_info - 1];
658 - }
659 - return NULL;
660 - }
661 -
662 /* Return TRUE if the section is a DWO section. */
663
664 static bfd_boolean
665 --- 943,948 ----
666 *************** is_strip_section (bfd *abfd ATTRIBUTE_UN
667 *** 1034,1040 ****
668 /* PR binutils/3181
669 If we are going to strip the group signature symbol, then
670 strip the group section too. */
671 ! gsym = group_signature (sec);
672 if (gsym != NULL)
673 gname = gsym->name;
674 else
675 --- 1010,1016 ----
676 /* PR binutils/3181
677 If we are going to strip the group signature symbol, then
678 strip the group section too. */
679 ! gsym = bfd_group_signature (sec, isympp);
680 if (gsym != NULL)
681 gname = gsym->name;
682 else
683 *************** setup_section (bfd *ibfd, sec_ptr isecti
684 *** 2633,2639 ****
685
686 if ((isection->flags & SEC_GROUP) != 0)
687 {
688 ! asymbol *gsym = group_signature (isection);
689
690 if (gsym != NULL)
691 {
692 --- 2609,2615 ----
693
694 if ((isection->flags & SEC_GROUP) != 0)
695 {
696 ! asymbol *gsym = bfd_group_signature (isection, isympp);
697
698 if (gsym != NULL)
699 {
700 diff -cpr ../binutils-2.23.2.orig/binutils/readelf.c binutils/readelf.c
701 *** ../binutils-2.23.2.orig/binutils/readelf.c 2013-05-14 16:39:35.668718064 +0100
702 --- binutils/readelf.c 2013-05-14 16:40:07.022718933 +0100
703 *************** get_section_type_name (unsigned int sh_t
704 *** 3101,3106 ****
705 --- 3101,3107 ----
706 case 0x7ffffffd: return "AUXILIARY";
707 case 0x7fffffff: return "FILTER";
708 case SHT_GNU_LIBLIST: return "GNU_LIBLIST";
709 + case SHT_GNU_OBJECT_ONLY: return "GNU_OBJECT_ONLY";
710
711 default:
712 if ((sh_type >= SHT_LOPROC) && (sh_type <= SHT_HIPROC))
713 diff -cpr ../binutils-2.23.2.orig/include/bfdlink.h include/bfdlink.h
714 *** ../binutils-2.23.2.orig/include/bfdlink.h 2013-05-14 16:39:19.745717623 +0100
715 --- include/bfdlink.h 2013-05-14 16:40:07.023718933 +0100
716 *************** struct bfd_link_info
717 *** 380,385 ****
718 --- 380,391 ----
719 /* TRUE if ok to have multiple definition. */
720 unsigned int allow_multiple_definition: 1;
721
722 + /* TRUE if .gnu_object_only section should be created. */
723 + unsigned int emit_gnu_object_only: 1;
724 +
725 + /* TRUE if .gnu_object_only section is being created. */
726 + unsigned int emitting_gnu_object_only: 1;
727 +
728 /* TRUE if ok to have version with no definition. */
729 unsigned int allow_undefined_version: 1;
730
731 diff -cpr ../binutils-2.23.2.orig/include/elf/common.h include/elf/common.h
732 *** ../binutils-2.23.2.orig/include/elf/common.h 2013-05-14 16:39:19.628717619 +0100
733 --- include/elf/common.h 2013-05-14 16:40:07.023718933 +0100
734 ***************
735 *** 472,477 ****
736 --- 472,478 ----
737 #define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes */
738 #define SHT_GNU_HASH 0x6ffffff6 /* GNU style symbol hash table */
739 #define SHT_GNU_LIBLIST 0x6ffffff7 /* List of prelink dependencies */
740 + #define SHT_GNU_OBJECT_ONLY 0x6ffffff8 /* Object only */
741
742 /* The next three section types are defined by Solaris, and are named
743 SHT_SUNW*. We use them in GNU code, so we also define SHT_GNU*
744 diff -cpr ../binutils-2.23.2.orig/ld/emultempl/alphaelf.em ld/emultempl/alphaelf.em
745 *** ../binutils-2.23.2.orig/ld/emultempl/alphaelf.em 2013-05-14 16:39:37.461718114 +0100
746 --- ld/emultempl/alphaelf.em 2013-05-14 16:40:07.030718933 +0100
747 *************** alpha_finish (void)
748 *** 100,106 ****
749 if (limit_32bit)
750 elf_elfheader (link_info.output_bfd)->e_flags |= EF_ALPHA_32BIT;
751
752 ! finish_default ();
753 }
754 EOF
755
756 --- 100,106 ----
757 if (limit_32bit)
758 elf_elfheader (link_info.output_bfd)->e_flags |= EF_ALPHA_32BIT;
759
760 ! gld${EMULATION_NAME}_finish ();
761 }
762 EOF
763
764 diff -cpr ../binutils-2.23.2.orig/ld/emultempl/armelf.em ld/emultempl/armelf.em
765 *** ../binutils-2.23.2.orig/ld/emultempl/armelf.em 2013-05-14 16:39:37.458718114 +0100
766 --- ld/emultempl/armelf.em 2013-05-14 16:40:07.033718933 +0100
767 *************** gld${EMULATION_NAME}_after_allocation (v
768 *** 366,372 ****
769 }
770
771 static void
772 ! gld${EMULATION_NAME}_finish (void)
773 {
774 struct bfd_link_hash_entry * h;
775
776 --- 366,372 ----
777 }
778
779 static void
780 ! arm_finish (void)
781 {
782 struct bfd_link_hash_entry * h;
783
784 *************** gld${EMULATION_NAME}_finish (void)
785 *** 389,395 ****
786 }
787 }
788
789 ! finish_default ();
790
791 if (thumb_entry_symbol)
792 {
793 --- 389,395 ----
794 }
795 }
796
797 ! gld${EMULATION_NAME}_finish ();
798
799 if (thumb_entry_symbol)
800 {
801 *************** LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=
802 *** 690,693 ****
803 LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME}"_before_parse
804
805 # Call the extra arm-elf function
806 ! LDEMUL_FINISH=gld${EMULATION_NAME}_finish
807 --- 690,693 ----
808 LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME}"_before_parse
809
810 # Call the extra arm-elf function
811 ! LDEMUL_FINISH=arm_finish
812 diff -cpr ../binutils-2.23.2.orig/ld/emultempl/elf32.em ld/emultempl/elf32.em
813 *** ../binutils-2.23.2.orig/ld/emultempl/elf32.em 2013-05-14 16:39:37.465718114 +0100
814 --- ld/emultempl/elf32.em 2013-05-14 16:40:07.035718933 +0100
815 *************** static void gld${EMULATION_NAME}_before_
816 *** 68,73 ****
817 --- 68,74 ----
818 static void gld${EMULATION_NAME}_after_allocation (void);
819 static lang_output_section_statement_type *gld${EMULATION_NAME}_place_orphan
820 (asection *, const char *, int);
821 + static void gld${EMULATION_NAME}_finish (void);
822 EOF
823
824 if [ "x${USE_LIBPATH}" = xyes ] ; then
825 *************** output_rel_find (asection *sec, int isdy
826 *** 1764,1769 ****
827 --- 1765,1772 ----
828 return last;
829 }
830
831 + static int orphan_init_done = 0;
832 +
833 /* Place an orphan section. We use this to put random SHF_ALLOC
834 sections in the right segment. */
835
836 *************** gld${EMULATION_NAME}_place_orphan (asect
837 *** 1772,1778 ****
838 const char *secname,
839 int constraint)
840 {
841 ! static struct orphan_save hold[] =
842 {
843 { ".text",
844 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE,
845 --- 1775,1781 ----
846 const char *secname,
847 int constraint)
848 {
849 ! static struct orphan_save orig_hold[] =
850 {
851 { ".text",
852 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE,
853 *************** gld${EMULATION_NAME}_place_orphan (asect
854 *** 1799,1804 ****
855 --- 1802,1808 ----
856 SEC_HAS_CONTENTS,
857 0, 0, 0, 0 },
858 };
859 + static struct orphan_save hold[ARRAY_SIZE (orig_hold)];
860 enum orphan_save_index
861 {
862 orphan_text = 0,
863 *************** gld${EMULATION_NAME}_place_orphan (asect
864 *** 1810,1816 ****
865 orphan_sdata,
866 orphan_nonalloc
867 };
868 - static int orphan_init_done = 0;
869 struct orphan_save *place;
870 lang_output_section_statement_type *after;
871 lang_output_section_statement_type *os;
872 --- 1814,1819 ----
873 *************** gld${EMULATION_NAME}_place_orphan (asect
874 *** 1887,1901 ****
875
876 if (!orphan_init_done)
877 {
878 ! struct orphan_save *ho;
879
880 for (ho = hold; ho < hold + sizeof (hold) / sizeof (hold[0]); ++ho)
881 if (ho->name != NULL)
882 {
883 ho->os = lang_output_section_find (ho->name);
884 if (ho->os != NULL && ho->os->flags == 0)
885 ho->os->flags = ho->flags;
886 }
887 orphan_init_done = 1;
888 }
889
890 --- 1890,1911 ----
891
892 if (!orphan_init_done)
893 {
894 ! struct orphan_save *ho, *horig;
895
896 for (ho = hold; ho < hold + sizeof (hold) / sizeof (hold[0]); ++ho)
897 + for (ho = hold, horig = orig_hold;
898 + ho < hold + ARRAY_SIZE (hold);
899 + ++ho, ++horig)
900 + {
901 + *ho = *horig;
902 + if (ho->name != NULL)
903 if (ho->name != NULL)
904 {
905 ho->os = lang_output_section_find (ho->name);
906 if (ho->os != NULL && ho->os->flags == 0)
907 ho->os->flags = ho->flags;
908 }
909 + }
910 orphan_init_done = 1;
911 }
912
913 *************** gld${EMULATION_NAME}_place_orphan (asect
914 *** 1965,1970 ****
915 --- 1975,2001 ----
916 EOF
917 fi
918
919 + fragment <<EOF
920 +
921 + /* Final emulation specific call. */
922 +
923 + static void
924 + gld${EMULATION_NAME}_finish (void)
925 + {
926 + EOF
927 + if test x"$LDEMUL_PLACE_ORPHAN" != xgld"$EMULATION_NAME"_place_orphan; then
928 + fragment <<EOF
929 + /* Support the object-only output. */
930 + if (link_info.emit_gnu_object_only)
931 + orphan_init_done = 0;
932 +
933 + EOF
934 + fi
935 + fragment <<EOF
936 + finish_default ();
937 + }
938 + EOF
939 +
940 if test x"$LDEMUL_AFTER_ALLOCATION" != xgld"$EMULATION_NAME"_after_allocation; then
941 fragment <<EOF
942
943 *************** struct ld_emulation_xfer_struct ld_${EMU
944 *** 2497,2503 ****
945 ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
946 "${EMULATION_NAME}",
947 "${OUTPUT_FORMAT}",
948 ! ${LDEMUL_FINISH-finish_default},
949 ${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL},
950 ${LDEMUL_OPEN_DYNAMIC_ARCHIVE-gld${EMULATION_NAME}_open_dynamic_archive},
951 ${LDEMUL_PLACE_ORPHAN-gld${EMULATION_NAME}_place_orphan},
952 --- 2528,2534 ----
953 ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
954 "${EMULATION_NAME}",
955 "${OUTPUT_FORMAT}",
956 ! ${LDEMUL_FINISH-gld${EMULATION_NAME}_finish},
957 ${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL},
958 ${LDEMUL_OPEN_DYNAMIC_ARCHIVE-gld${EMULATION_NAME}_open_dynamic_archive},
959 ${LDEMUL_PLACE_ORPHAN-gld${EMULATION_NAME}_place_orphan},
960 diff -cpr ../binutils-2.23.2.orig/ld/emultempl/ppc64elf.em ld/emultempl/ppc64elf.em
961 *** ../binutils-2.23.2.orig/ld/emultempl/ppc64elf.em 2013-05-14 16:39:37.454718113 +0100
962 --- ld/emultempl/ppc64elf.em 2013-05-14 16:40:07.044718934 +0100
963 *************** gld${EMULATION_NAME}_after_allocation (v
964 *** 533,539 ****
965 /* Final emulation specific call. */
966
967 static void
968 ! gld${EMULATION_NAME}_finish (void)
969 {
970 /* e_entry on PowerPC64 points to the function descriptor for
971 _start. If _start is missing, default to the first function
972 --- 533,539 ----
973 /* Final emulation specific call. */
974
975 static void
976 ! ppc_finish (void)
977 {
978 /* e_entry on PowerPC64 points to the function descriptor for
979 _start. If _start is missing, default to the first function
980 *************** gld${EMULATION_NAME}_finish (void)
981 *** 565,571 ****
982 }
983
984 ppc64_elf_restore_symbols (&link_info);
985 ! finish_default ();
986 }
987
988
989 --- 565,571 ----
990 }
991
992 ppc64_elf_restore_symbols (&link_info);
993 ! gld${EMULATION_NAME}_finish ();
994 }
995
996
997 *************** PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LI
998 *** 867,872 ****
999 #
1000 LDEMUL_BEFORE_ALLOCATION=ppc_before_allocation
1001 LDEMUL_AFTER_ALLOCATION=gld${EMULATION_NAME}_after_allocation
1002 ! LDEMUL_FINISH=gld${EMULATION_NAME}_finish
1003 LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=ppc_create_output_section_statements
1004 LDEMUL_NEW_VERS_PATTERN=gld${EMULATION_NAME}_new_vers_pattern
1005 --- 867,872 ----
1006 #
1007 LDEMUL_BEFORE_ALLOCATION=ppc_before_allocation
1008 LDEMUL_AFTER_ALLOCATION=gld${EMULATION_NAME}_after_allocation
1009 ! LDEMUL_FINISH=ppc_finish
1010 LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=ppc_create_output_section_statements
1011 LDEMUL_NEW_VERS_PATTERN=gld${EMULATION_NAME}_new_vers_pattern
1012 diff -cpr ../binutils-2.23.2.orig/ld/emultempl/spuelf.em ld/emultempl/spuelf.em
1013 *** ../binutils-2.23.2.orig/ld/emultempl/spuelf.em 2013-05-14 16:39:37.453718113 +0100
1014 --- ld/emultempl/spuelf.em 2013-05-14 16:40:07.045718934 +0100
1015 *************** spu_elf_relink (void)
1016 *** 416,422 ****
1017 /* Final emulation specific call. */
1018
1019 static void
1020 ! gld${EMULATION_NAME}_finish (void)
1021 {
1022 if (is_spu_target ())
1023 {
1024 --- 416,422 ----
1025 /* Final emulation specific call. */
1026
1027 static void
1028 ! spu_finish (void)
1029 {
1030 if (is_spu_target ())
1031 {
1032 *************** gld${EMULATION_NAME}_finish (void)
1033 *** 432,438 ****
1034 einfo ("%P: --auto-overlay ignored with zero local store range\n");
1035 }
1036
1037 ! finish_default ();
1038 }
1039
1040 static char *
1041 --- 432,438 ----
1042 einfo ("%P: --auto-overlay ignored with zero local store range\n");
1043 }
1044
1045 ! gld${EMULATION_NAME}_finish ();
1046 }
1047
1048 static char *
1049 *************** PARSE_AND_LIST_ARGS_CASES='
1050 *** 832,836 ****
1051
1052 LDEMUL_AFTER_OPEN=spu_after_open
1053 LDEMUL_BEFORE_ALLOCATION=spu_before_allocation
1054 ! LDEMUL_FINISH=gld${EMULATION_NAME}_finish
1055 LDEMUL_CHOOSE_TARGET=gld${EMULATION_NAME}_choose_target
1056 --- 832,836 ----
1057
1058 LDEMUL_AFTER_OPEN=spu_after_open
1059 LDEMUL_BEFORE_ALLOCATION=spu_before_allocation
1060 ! LDEMUL_FINISH=spu_finish
1061 LDEMUL_CHOOSE_TARGET=gld${EMULATION_NAME}_choose_target
1062 diff -cpr ../binutils-2.23.2.orig/ld/ldfile.c ld/ldfile.c
1063 *** ../binutils-2.23.2.orig/ld/ldfile.c 2013-05-14 16:39:37.164718105 +0100
1064 --- ld/ldfile.c 2013-05-14 16:40:07.046718934 +0100
1065 *************** success:
1066 *** 319,325 ****
1067 --- 319,327 ----
1068 plugin_maybe_claim (&file, entry);
1069 }
1070 }
1071 + else
1072 #endif /* ENABLE_PLUGINS */
1073 + cmdline_check_object_only_section (entry->the_bfd, FALSE);
1074
1075 /* It opened OK, the format checked out, and the plugins have had
1076 their chance to claim it, so this is success. */
1077 diff -cpr ../binutils-2.23.2.orig/ld/ldlang.c ld/ldlang.c
1078 *** ../binutils-2.23.2.orig/ld/ldlang.c 2013-05-14 16:39:39.704718176 +0100
1079 --- ld/ldlang.c 2013-05-14 17:03:54.030758491 +0100
1080 ***************
1081 *** 38,43 ****
1082 --- 38,44 ----
1083 #include "ldctor.h"
1084 #include "ldfile.h"
1085 #include "ldemul.h"
1086 + #include "ldwrite.h"
1087 #include "fnmatch.h"
1088 #include "demangle.h"
1089 #include "hashtab.h"
1090 ***************
1091 *** 46,51 ****
1092 --- 47,55 ----
1093 #include "plugin.h"
1094 #endif /* ENABLE_PLUGINS */
1095
1096 + /* FIXME: Put it here to avoid NAME conflict from ldgram.h. */
1097 + #include "elf-bfd.h"
1098 +
1099 #ifndef offsetof
1100 #define offsetof(TYPE, MEMBER) ((size_t) & (((TYPE*) 0)->MEMBER))
1101 #endif
1102 *************** static struct bfd_hash_table lang_define
1103 *** 69,74 ****
1104 --- 73,81 ----
1105 static lang_statement_list_type *stat_save[10];
1106 static lang_statement_list_type **stat_save_ptr = &stat_save[0];
1107 static struct unique_sections *unique_section_list;
1108 + static cmdline_list_type cmdline_object_only_file_list;
1109 + static cmdline_list_type cmdline_object_only_archive_list;
1110 + static cmdline_list_type cmdline_temp_object_only_list;
1111
1112 /* Forward declarations. */
1113 static void exp_init_os (etree_type *);
1114 *************** static void lang_record_phdrs (void);
1115 *** 89,94 ****
1116 --- 96,105 ----
1117 static void lang_do_version_exports_section (void);
1118 static void lang_finalize_version_expr_head
1119 (struct bfd_elf_version_expr_head *);
1120 + static void cmdline_lists_init (void);
1121 + static void cmdline_get_object_only_input_files (void);
1122 + static void print_cmdline_list (cmdline_union_type *);
1123 + static bfd_boolean cmdline_on_object_only_archive_list_p (bfd *);
1124
1125 /* Exported variables. */
1126 const char *output_target;
1127 *************** output_section_statement_table_free (voi
1128 *** 1204,1217 ****
1129 /* Build enough state so that the parser can build its tree. */
1130
1131 void
1132 ! lang_init (void)
1133 {
1134 ! obstack_begin (&stat_obstack, 1000);
1135
1136 stat_ptr = &statement_list;
1137
1138 output_section_statement_table_init ();
1139
1140 lang_list_init (stat_ptr);
1141
1142 lang_list_init (&input_file_chain);
1143 --- 1215,1231 ----
1144 /* Build enough state so that the parser can build its tree. */
1145
1146 void
1147 ! lang_init (bfd_boolean object_only)
1148 {
1149 ! if (!object_only)
1150 ! obstack_begin (&stat_obstack, 1000);
1151
1152 stat_ptr = &statement_list;
1153
1154 output_section_statement_table_init ();
1155
1156 + cmdline_lists_init ();
1157 +
1158 lang_list_init (stat_ptr);
1159
1160 lang_list_init (&input_file_chain);
1161 *************** lang_init (void)
1162 *** 1230,1239 ****
1163 simpler to re-use working machinery than using a linked list in terms
1164 of code-complexity here in ld, besides the initialization which just
1165 looks like other code here. */
1166 ! if (!bfd_hash_table_init_n (&lang_definedness_table,
1167 ! lang_definedness_newfunc,
1168 ! sizeof (struct lang_definedness_hash_entry),
1169 ! 3))
1170 einfo (_("%P%F: can not create hash table: %E\n"));
1171 }
1172
1173 --- 1244,1254 ----
1174 simpler to re-use working machinery than using a linked list in terms
1175 of code-complexity here in ld, besides the initialization which just
1176 looks like other code here. */
1177 ! if (!object_only
1178 ! && !bfd_hash_table_init_n (&lang_definedness_table,
1179 ! lang_definedness_newfunc,
1180 ! sizeof (struct lang_definedness_hash_entry),
1181 ! 3))
1182 einfo (_("%P%F: can not create hash table: %E\n"));
1183 }
1184
1185 *************** load_symbols (lang_input_statement_type
1186 *** 2769,2774 ****
1187 --- 2784,2795 ----
1188 loaded = FALSE;
1189 }
1190
1191 + if (link_info.emitting_gnu_object_only)
1192 + {
1193 + if (!cmdline_on_object_only_archive_list_p (member))
1194 + continue;
1195 + }
1196 +
1197 subsbfd = member;
1198 if (!(*link_info.callbacks
1199 ->add_archive_element) (&link_info, member,
1200 *************** lang_process (void)
1201 *** 6659,6665 ****
1202 --- 6680,6716 ----
1203 open_input_bfds (statement_list.head, OPEN_BFD_RESCAN);
1204 }
1205 }
1206 + else
1207 #endif /* ENABLE_PLUGINS */
1208 + if (link_info.relocatable)
1209 + {
1210 + /* Check if .gnu_object_only section should be created. */
1211 + bfd *p;
1212 + int object_type;
1213 +
1214 + object_type = 0;
1215 + for (p = link_info.input_bfds; p != (bfd *) NULL; p = p->link_next)
1216 + {
1217 + object_type |= 1 << p->lto_type;
1218 + if ((object_type & (1 << lto_mixed_object)) != 0
1219 + || ((object_type
1220 + & (1 << lto_non_ir_object
1221 + | 1 << lto_ir_object))
1222 + == (1 << lto_non_ir_object | 1 << lto_ir_object)))
1223 + {
1224 + link_info.emit_gnu_object_only = TRUE;
1225 + break;
1226 + }
1227 + }
1228 +
1229 + if (trace_files
1230 + && (cmdline_object_only_file_list.head
1231 + || cmdline_object_only_archive_list.head))
1232 + {
1233 + print_cmdline_list (cmdline_object_only_file_list.head);
1234 + print_cmdline_list (cmdline_object_only_archive_list.head);
1235 + }
1236 + }
1237
1238 link_info.gc_sym_list = &entry_symbol;
1239 if (entry_symbol.name == NULL)
1240 *************** lang_ld_feature (char *str)
1241 *** 8059,8061 ****
1242 --- 8111,9071 ----
1243 p = q;
1244 }
1245 }
1246 +
1247 + static void
1248 + cmdline_lists_init (void)
1249 + {
1250 + cmdline_object_only_file_list.tail
1251 + = &cmdline_object_only_file_list.head;
1252 + cmdline_object_only_archive_list.tail
1253 + = &cmdline_object_only_archive_list.head;
1254 + cmdline_temp_object_only_list.tail
1255 + = &cmdline_temp_object_only_list.head;
1256 + }
1257 +
1258 + /* Allocate an item with TYPE and DATA. */
1259 +
1260 + static cmdline_union_type *
1261 + cmdline_list_new (cmdline_enum_type type, void *data)
1262 + {
1263 + cmdline_union_type *new_opt;
1264 +
1265 + new_opt = (cmdline_union_type *) stat_alloc (sizeof (*new_opt));
1266 + new_opt->header.type = type;
1267 + switch (type)
1268 + {
1269 + default:
1270 + break;
1271 + case cmdline_is_file_enum:
1272 + new_opt->file.filename = (const char *) data;
1273 + break;
1274 + case cmdline_is_bfd_enum:
1275 + new_opt->abfd.abfd = (bfd *) data;
1276 + break;
1277 + }
1278 + return new_opt;
1279 + }
1280 +
1281 + /* Append an item with TYPE and DATA to LIST. */
1282 +
1283 + static void
1284 + cmdline_list_append (cmdline_list_type *list, cmdline_enum_type type,
1285 + void *data)
1286 + {
1287 + cmdline_union_type *new_opt = cmdline_list_new (type, data);
1288 + new_opt->header.next = NULL;
1289 + *list->tail = new_opt;
1290 + list->tail = &new_opt->header.next;
1291 + }
1292 +
1293 + static void
1294 + print_cmdline_list (cmdline_union_type *c)
1295 + {
1296 + for (; c != NULL; c = c->header.next)
1297 + switch (c->header.type)
1298 + {
1299 + default:
1300 + abort ();
1301 + case cmdline_is_file_enum:
1302 + info_msg (" %s", c->file.filename);
1303 + break;
1304 + case cmdline_is_bfd_enum:
1305 + info_msg (" [%B]", c->abfd.abfd);
1306 + break;
1307 + }
1308 +
1309 + info_msg ("\n");
1310 + }
1311 +
1312 + /* Return TRUE if ABFD is on cmdline_object_only_archive_list. */
1313 +
1314 + static bfd_boolean
1315 + cmdline_on_object_only_archive_list_p (bfd *abfd)
1316 + {
1317 + cmdline_union_type *c, *next;
1318 + bfd *archive, *obfd, *oarchive;
1319 + ufile_ptr origin = abfd->origin;
1320 +
1321 + archive = bfd_my_archive (abfd);
1322 + for (c = cmdline_object_only_archive_list.head; c != NULL; c = next)
1323 + {
1324 + if (c->header.type != cmdline_is_bfd_enum)
1325 + abort ();
1326 +
1327 + next = c->header.next;
1328 + obfd = c->abfd.abfd;
1329 + oarchive = bfd_my_archive (obfd);
1330 +
1331 + /* The list is grouped by archive file name and sorted by member
1332 + origin. */
1333 + if (strcmp (archive->filename, oarchive->filename) != 0)
1334 + continue;
1335 +
1336 + if (origin == obfd->origin)
1337 + return TRUE;
1338 + else if (origin < obfd->origin)
1339 + return FALSE;
1340 + }
1341 +
1342 + return FALSE;
1343 + }
1344 +
1345 + /* Append an item with TYPE and DATA to cmdline_object_only_file_list
1346 + or cmdline_object_only_archive_list if needed. */
1347 +
1348 + static void
1349 + cmdline_object_only_list_append (cmdline_enum_type type, void *data)
1350 + {
1351 + cmdline_union_type *c;
1352 + cmdline_union_type *new_opt, *next, **prev;
1353 + bfd *abfd, *archive;
1354 + bfd *obfd, *oarchive;
1355 + bfd *nbfd, *narchive;
1356 + ufile_ptr origin, norigin;
1357 +
1358 + /* Put it on cmdline_object_only_file_list if it isn't an archive
1359 + member. */
1360 + switch (type)
1361 + {
1362 + default:
1363 + abort ();
1364 + case cmdline_is_bfd_enum:
1365 + abfd = (bfd *) data;
1366 + archive = bfd_my_archive (abfd);
1367 + if (archive)
1368 + break;
1369 + case cmdline_is_file_enum:
1370 + cmdline_list_append (&cmdline_object_only_file_list, type, data);
1371 + return;
1372 + }
1373 +
1374 + /* Put archive member on cmdline_object_only_archive_list and sort
1375 + the list by archive name and archive member origin. */
1376 + new_opt = (cmdline_union_type *) stat_alloc (sizeof (*new_opt));
1377 + new_opt->header.type = cmdline_is_bfd_enum;
1378 + new_opt->header.next = NULL;
1379 + new_opt->abfd.abfd = (bfd *) data;
1380 +
1381 + c = cmdline_object_only_archive_list.head;
1382 + if (c == NULL)
1383 + {
1384 + cmdline_object_only_archive_list.head = new_opt;
1385 + cmdline_object_only_archive_list.tail = &new_opt->header.next;
1386 + return;
1387 + }
1388 +
1389 + prev = NULL;
1390 + origin = abfd->origin;
1391 + for (; c != NULL; c = next)
1392 + {
1393 + if (c->header.type != cmdline_is_bfd_enum)
1394 + abort ();
1395 +
1396 + next = c->header.next;
1397 +
1398 + obfd = c->abfd.abfd;
1399 + oarchive = bfd_my_archive (obfd);
1400 +
1401 + if (strcmp (archive->filename, oarchive->filename) == 0)
1402 + {
1403 + bfd_boolean after;
1404 +
1405 + if (origin < obfd->origin)
1406 + {
1407 + /* Insert it before the current. */
1408 + new_opt->header.next = c;
1409 + if (prev)
1410 + *prev = new_opt;
1411 + else
1412 + cmdline_object_only_archive_list.head = new_opt;
1413 + return;
1414 + }
1415 +
1416 + after = TRUE;
1417 +
1418 + /* Check origin. */
1419 + while (next)
1420 + {
1421 + if (next->header.type != cmdline_is_bfd_enum)
1422 + abort ();
1423 +
1424 + nbfd = next->abfd.abfd;
1425 + norigin = nbfd->origin;
1426 + if (origin > norigin)
1427 + {
1428 + /* Insert it after NEXT. */
1429 + break;
1430 + }
1431 +
1432 + narchive = bfd_my_archive (nbfd);
1433 + if (strcmp (archive->filename, narchive->filename) != 0)
1434 + {
1435 + /* Insert it befor NEXT. */
1436 + after = FALSE;
1437 + break;
1438 + }
1439 +
1440 + c = next;
1441 + next = next->header.next;
1442 + }
1443 +
1444 + if (after && next)
1445 + {
1446 + c = next;
1447 + next = next->header.next;
1448 + }
1449 +
1450 + if (*cmdline_object_only_archive_list.tail == c->header.next)
1451 + cmdline_object_only_archive_list.tail
1452 + = &new_opt->header.next;
1453 +
1454 + prev = &c->header.next;
1455 + new_opt->header.next = next;
1456 + *prev = new_opt;
1457 + return;
1458 + }
1459 +
1460 + prev = &c->header.next;
1461 + }
1462 +
1463 + *cmdline_object_only_archive_list.tail = new_opt;
1464 + cmdline_object_only_archive_list.tail = &new_opt->header.next;
1465 + }
1466 +
1467 +
1468 + static void
1469 + cmdline_get_object_only_input_files (void)
1470 + {
1471 + cmdline_union_type *c, *next;
1472 + bfd *abfd, *archive;
1473 + bfd *nbfd, *narchive;
1474 +
1475 + /* Add files first. */
1476 + for (c = cmdline_object_only_file_list.head;
1477 + c != NULL; c = c->header.next)
1478 + switch (c->header.type)
1479 + {
1480 + default:
1481 + abort ();
1482 + case cmdline_is_file_enum:
1483 + lang_add_input_file (c->file.filename,
1484 + lang_input_file_is_file_enum, NULL);
1485 + break;
1486 + case cmdline_is_bfd_enum:
1487 + abfd = c->abfd.abfd;
1488 + if (bfd_my_archive (abfd))
1489 + abort ();
1490 + lang_add_input_file (abfd->filename,
1491 + lang_input_file_is_file_enum, NULL);
1492 + break;
1493 + }
1494 +
1495 + /* Add archive members next. */
1496 + for (c = cmdline_object_only_archive_list.head; c != NULL; c = next)
1497 + {
1498 + if (c->header.type != cmdline_is_bfd_enum)
1499 + abort ();
1500 +
1501 + next = c->header.next;
1502 +
1503 + abfd = c->abfd.abfd;
1504 + archive = bfd_my_archive (abfd);
1505 +
1506 + /* Add the first archive of the archive member group. */
1507 + lang_add_input_file (archive->filename,
1508 + lang_input_file_is_file_enum, NULL);
1509 +
1510 + /* Skip the rest members in the archive member group. */
1511 + do
1512 + {
1513 + if (!next)
1514 + break;
1515 +
1516 + if (next->header.type != cmdline_is_bfd_enum)
1517 + abort ();
1518 +
1519 + next = next->header.next;
1520 + if (!next)
1521 + break;
1522 + nbfd = next->abfd.abfd;
1523 + narchive = bfd_my_archive (nbfd);
1524 + }
1525 + while (strcmp (archive->filename, narchive->filename) == 0);
1526 + }
1527 + }
1528 +
1529 + struct cmdline_arg
1530 + {
1531 + bfd *obfd;
1532 + asymbol **isympp;
1533 + int status;
1534 + };
1535 +
1536 + /* Create a section in OBFD with the same
1537 + name and attributes as ISECTION in IBFD. */
1538 +
1539 + static void
1540 + setup_section (bfd *ibfd, sec_ptr isection, void *p)
1541 + {
1542 + struct cmdline_arg *arg = (struct cmdline_arg *) p;
1543 + bfd *obfd = arg->obfd;
1544 + asymbol **isympp = arg->isympp;
1545 + const char *name = isection->name;
1546 + sec_ptr osection;
1547 + const char *err;
1548 +
1549 + /* Skip the object-only section. */
1550 + if (ibfd->object_only_section == isection)
1551 + return;
1552 +
1553 + /* If we have already failed earlier on, do not keep on generating
1554 + complaints now. */
1555 + if (arg->status)
1556 + return;
1557 +
1558 + osection = bfd_make_section_anyway_with_flags (obfd, name,
1559 + isection->flags);
1560 +
1561 + if (osection == NULL)
1562 + {
1563 + err = _("failed to create output section");
1564 + goto loser;
1565 + }
1566 +
1567 + osection->size = isection->size;
1568 + osection->vma = isection->vma;
1569 + osection->lma = isection->lma;
1570 + osection->alignment_power = isection->alignment_power;
1571 +
1572 + /* Copy merge entity size. */
1573 + osection->entsize = isection->entsize;
1574 +
1575 + /* This used to be mangle_section; we do here to avoid using
1576 + bfd_get_section_by_name since some formats allow multiple
1577 + sections with the same name. */
1578 + isection->output_section = osection;
1579 + isection->output_offset = 0;
1580 +
1581 + if ((isection->flags & SEC_GROUP) != 0)
1582 + {
1583 + asymbol *gsym = bfd_group_signature (isection, isympp);
1584 +
1585 + if (gsym != NULL)
1586 + {
1587 + gsym->flags |= BSF_KEEP;
1588 + if (ibfd->xvec->flavour == bfd_target_elf_flavour)
1589 + elf_group_id (isection) = gsym;
1590 + }
1591 + }
1592 +
1593 + /* Allow the BFD backend to copy any private data it understands
1594 + from the input section to the output section. */
1595 + if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection))
1596 + {
1597 + err = _("failed to copy private data");
1598 + goto loser;
1599 + }
1600 +
1601 + /* All went well. */
1602 + return;
1603 +
1604 + loser:
1605 + arg->status = 1;
1606 + einfo (_("%P%F: setup_section: %s: %s\n"), err, name);
1607 + }
1608 +
1609 + /* Copy the data of input section ISECTION of IBFD
1610 + to an output section with the same name in OBFD.
1611 + If stripping then don't copy any relocation info. */
1612 +
1613 + static void
1614 + copy_section (bfd *ibfd, sec_ptr isection, void *p)
1615 + {
1616 + struct cmdline_arg *arg = (struct cmdline_arg *) p;
1617 + bfd *obfd = arg->obfd;
1618 + asymbol **isympp = arg->isympp;
1619 + arelent **relpp;
1620 + long relcount;
1621 + sec_ptr osection;
1622 + bfd_size_type size;
1623 + long relsize;
1624 + flagword flags;
1625 + const char *err;
1626 +
1627 + /* Skip the object-only section. */
1628 + if (ibfd->object_only_section == isection)
1629 + return;
1630 +
1631 + /* If we have already failed earlier on, do not keep on generating
1632 + complaints now. */
1633 + if (arg->status)
1634 + return;
1635 +
1636 + flags = bfd_get_section_flags (ibfd, isection);
1637 + if ((flags & SEC_GROUP) != 0)
1638 + return;
1639 +
1640 + osection = isection->output_section;
1641 + size = bfd_get_section_size (isection);
1642 +
1643 + if (size == 0 || osection == 0)
1644 + return;
1645 +
1646 + relsize = bfd_get_reloc_upper_bound (ibfd, isection);
1647 +
1648 + if (relsize < 0)
1649 + {
1650 + /* Do not complain if the target does not support relocations. */
1651 + if (relsize == -1
1652 + && bfd_get_error () == bfd_error_invalid_operation)
1653 + relsize = 0;
1654 + else
1655 + {
1656 + err = bfd_errmsg (bfd_get_error ());
1657 + goto loser;
1658 + }
1659 + }
1660 +
1661 + if (relsize == 0)
1662 + bfd_set_reloc (obfd, osection, NULL, 0);
1663 + else
1664 + {
1665 + relpp = (arelent **) xmalloc (relsize);
1666 + relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, isympp);
1667 + if (relcount < 0)
1668 + {
1669 + err = _("relocation count is negative");
1670 + goto loser;
1671 + }
1672 +
1673 + bfd_set_reloc (obfd, osection,
1674 + relcount == 0 ? NULL : relpp, relcount);
1675 + if (relcount == 0)
1676 + free (relpp);
1677 + }
1678 +
1679 + if (bfd_get_section_flags (ibfd, isection) & SEC_HAS_CONTENTS)
1680 + {
1681 + bfd_byte *memhunk = NULL;
1682 +
1683 + if (!bfd_get_full_section_contents (ibfd, isection, &memhunk))
1684 + {
1685 + err = bfd_errmsg (bfd_get_error ());
1686 + goto loser;
1687 + }
1688 +
1689 + if (!bfd_set_section_contents (obfd, osection, memhunk, 0, size))
1690 + {
1691 + err = bfd_errmsg (bfd_get_error ());
1692 + goto loser;
1693 + }
1694 + free (memhunk);
1695 + }
1696 +
1697 + /* All went well. */
1698 + return;
1699 +
1700 + loser:
1701 + einfo (_("%P%F: copy_section: %s: %s\n"), err, isection->name);
1702 + }
1703 + /* Open the temporary bfd created in the same directory as PATH. */
1704 +
1705 + static bfd *
1706 + cmdline_fopen_temp (const char *path, const char *target,
1707 + const char *mode)
1708 + {
1709 + #define template "ldXXXXXX"
1710 + const char *slash = strrchr (path, '/');
1711 + char *tmpname;
1712 + size_t len;
1713 + int fd;
1714 +
1715 + #ifdef HAVE_DOS_BASED_FILE_SYSTEM
1716 + {
1717 + /* We could have foo/bar\\baz, or foo\\bar, or d:bar. */
1718 + char *bslash = strrchr (path, '\\');
1719 +
1720 + if (slash == NULL || (bslash != NULL && bslash > slash))
1721 + slash = bslash;
1722 + if (slash == NULL && path[0] != '\0' && path[1] == ':')
1723 + slash = path + 1;
1724 + }
1725 + #endif
1726 +
1727 + if (slash != (char *) NULL)
1728 + {
1729 + len = slash - path;
1730 + tmpname = (char *) xmalloc (len + sizeof (template) + 2);
1731 + memcpy (tmpname, path, len);
1732 +
1733 + #ifdef HAVE_DOS_BASED_FILE_SYSTEM
1734 + /* If tmpname is "X:", appending a slash will make it a root
1735 + directory on drive X, which is NOT the same as the current
1736 + directory on drive X. */
1737 + if (len == 2 && tmpname[1] == ':')
1738 + tmpname[len++] = '.';
1739 + #endif
1740 + tmpname[len++] = '/';
1741 + }
1742 + else
1743 + {
1744 + tmpname = (char *) xmalloc (sizeof (template));
1745 + len = 0;
1746 + }
1747 +
1748 + memcpy (tmpname + len, template, sizeof (template));
1749 + #undef template
1750 +
1751 + #ifdef HAVE_MKSTEMP
1752 + fd = mkstemp (tmpname);
1753 + #else
1754 + tmpname = mktemp (tmpname);
1755 + if (tmpname == NULL)
1756 + return NULL;
1757 + fd = open (tmpname, O_RDWR | O_CREAT | O_EXCL, 0600);
1758 + #endif
1759 + if (fd == -1)
1760 + return NULL;
1761 + return bfd_fopen (tmpname, target, mode, fd);
1762 + }
1763 +
1764 + /* Add the object-only section. */
1765 +
1766 + static void
1767 + cmdline_add_object_only_section (bfd_byte *contents, size_t size)
1768 + {
1769 + bfd_vma start;
1770 + flagword flags;
1771 + enum bfd_architecture iarch;
1772 + unsigned int imach;
1773 + long symcount;
1774 + long symsize;
1775 + asymbol **isympp = NULL;
1776 + asymbol **osympp = NULL;
1777 + bfd *obfd = NULL, *ibfd;
1778 + const char *err;
1779 + struct arg
1780 + {
1781 + bfd *obfd;
1782 + asymbol **isympp;
1783 + int status;
1784 + } arg;
1785 + char **matching;
1786 + const char *ofilename = NULL;
1787 + asection *sec;
1788 +
1789 + ibfd = bfd_openr (output_filename, output_target);
1790 + if (!ibfd)
1791 + {
1792 + err = bfd_errmsg (bfd_get_error ());
1793 + goto loser;
1794 + }
1795 +
1796 + if (!bfd_check_format_matches (ibfd, bfd_object, &matching))
1797 + {
1798 + err = bfd_errmsg (bfd_get_error ());
1799 + goto loser;
1800 + }
1801 +
1802 + obfd = cmdline_fopen_temp (output_filename, output_target, "w");
1803 + if (!obfd)
1804 + {
1805 + err = bfd_errmsg (bfd_get_error ());
1806 + goto loser;
1807 + }
1808 + ofilename = bfd_get_filename (obfd);
1809 +
1810 + if (!bfd_set_format (obfd, bfd_object))
1811 + {
1812 + err = bfd_errmsg (bfd_get_error ());
1813 + goto loser;
1814 + }
1815 +
1816 + /* Copy the start address, flags and architecture of input file to
1817 + output file. */
1818 + flags = bfd_get_file_flags (ibfd);
1819 + start = bfd_get_start_address (ibfd);
1820 + iarch = bfd_get_arch (ibfd);
1821 + imach = bfd_get_mach (ibfd);
1822 + if (!bfd_set_start_address (obfd, start)
1823 + || !bfd_set_file_flags (obfd, flags)
1824 + || !bfd_set_arch_mach (obfd, iarch, imach))
1825 + {
1826 + err = bfd_errmsg (bfd_get_error ());
1827 + goto loser;
1828 + }
1829 +
1830 + symsize = bfd_get_symtab_upper_bound (ibfd);
1831 + if (symsize < 0)
1832 + {
1833 + err = bfd_errmsg (bfd_get_error ());
1834 + goto loser;
1835 + }
1836 +
1837 + isympp = (asymbol **) xmalloc (symsize);
1838 + symcount = bfd_canonicalize_symtab (ibfd, isympp);
1839 + if (symcount < 0)
1840 + {
1841 + err = bfd_errmsg (bfd_get_error ());
1842 + goto loser;
1843 + }
1844 +
1845 + arg.obfd = obfd;
1846 + arg.isympp = isympp;
1847 + arg.status = 0;
1848 +
1849 + /* BFD mandates that all output sections be created and sizes set before
1850 + any output is done. Thus, we traverse all sections multiple times. */
1851 + bfd_map_over_sections (ibfd, setup_section, &arg);
1852 +
1853 + if (arg.status)
1854 + {
1855 + err = _("error setting up sections");
1856 + goto loser;
1857 + }
1858 +
1859 + /* Allow the BFD backend to copy any private data it understands
1860 + from the input section to the output section. */
1861 + if (! bfd_copy_private_header_data (ibfd, obfd))
1862 + {
1863 + err = _("error copying private header data");
1864 + goto loser;
1865 + }
1866 +
1867 + /* Create the object-only section. */
1868 + sec = bfd_make_section_with_flags (obfd,
1869 + GNU_OBJECT_ONLY_SECTION_NAME,
1870 + (SEC_HAS_CONTENTS
1871 + | SEC_READONLY
1872 + | SEC_DATA
1873 + | SEC_LINKER_CREATED));
1874 + if (sec == NULL)
1875 + {
1876 + err = _("can't create object-only section");
1877 + goto loser;
1878 + }
1879 +
1880 + if (! bfd_set_section_size (obfd, sec, size))
1881 + {
1882 + err = _("can't set object-only section size");
1883 + goto loser;
1884 + }
1885 +
1886 + if (ibfd->object_only_section)
1887 + {
1888 + /* Filter out the object-only section symbol. */
1889 + long src_count = 0, dst_count = 0;
1890 + asymbol **from, **to;
1891 +
1892 + osympp = (asymbol **) xmalloc (symcount * sizeof (asymbol *));
1893 + from = isympp;
1894 + to = osympp;
1895 + for (; src_count < symcount; src_count++)
1896 + {
1897 + asymbol *sym = from[src_count];
1898 + if (bfd_get_section (sym) != ibfd->object_only_section)
1899 + to[dst_count++] = sym;
1900 + }
1901 + to[dst_count] = NULL;
1902 + symcount = dst_count;
1903 + bfd_set_symtab (obfd, osympp, symcount);
1904 + }
1905 + else
1906 + bfd_set_symtab (obfd, isympp, symcount);
1907 +
1908 + /* This has to happen after the symbol table has been set. */
1909 + bfd_map_over_sections (ibfd, copy_section, &arg);
1910 +
1911 + if (arg.status)
1912 + {
1913 + err = _("error copying sections");
1914 + goto loser;
1915 + }
1916 +
1917 + /* Copy the object-only section to the output. */
1918 + if (! bfd_set_section_contents (obfd, sec, contents, 0, size))
1919 + {
1920 + err = _("error adding object-only section");
1921 + goto loser;
1922 + }
1923 +
1924 + /* Allow the BFD backend to copy any private data it understands
1925 + from the input BFD to the output BFD. This is done last to
1926 + permit the routine to look at the filtered symbol table, which is
1927 + important for the ECOFF code at least. */
1928 + if (! bfd_copy_private_bfd_data (ibfd, obfd))
1929 + {
1930 + err = _("error copying private BFD data");
1931 + goto loser;
1932 + }
1933 +
1934 + if (!bfd_close (obfd))
1935 + {
1936 + unlink (ofilename);
1937 + einfo (_("%P%F: failed to finish output with object-only section\n"));
1938 + }
1939 +
1940 + /* Must be freed after bfd_close (). */
1941 + free (isympp);
1942 + if (osympp)
1943 + free (osympp);
1944 +
1945 + if (rename (ofilename, output_filename))
1946 + {
1947 + unlink (ofilename);
1948 + einfo (_("%P%F: failed to rename output with object-only section\n"));
1949 + }
1950 +
1951 + return;
1952 +
1953 + loser:
1954 + if (isympp)
1955 + free (isympp);
1956 + if (osympp)
1957 + free (osympp);
1958 + if (obfd)
1959 + bfd_close (obfd);
1960 + if (ofilename)
1961 + unlink (ofilename);
1962 + einfo (_("%P%F: failed to add object-only section: %s\n"), err);
1963 + }
1964 +
1965 + /* Emit the final output with object-only section. */
1966 +
1967 + void
1968 + cmdline_emit_object_only_section (void)
1969 + {
1970 + const char *saved_output_filename = output_filename;
1971 + int fd;
1972 + size_t size, off;
1973 + bfd_byte *contents;
1974 + struct stat st;
1975 +
1976 + /* Get a temporary object-only file. */
1977 + output_filename = make_temp_file (".obj-only.o");
1978 +
1979 + had_output_filename = FALSE;
1980 + link_info.input_bfds = NULL;
1981 + link_info.input_bfds_tail = &link_info.input_bfds;
1982 +
1983 + lang_init (TRUE);
1984 +
1985 + ld_parse_linker_script ();
1986 +
1987 + /* Set up the object-only output. */
1988 + lang_final ();
1989 +
1990 + /* Open the object-only file for output. */
1991 + lang_for_each_statement (ldlang_open_output);
1992 +
1993 + ldemul_create_output_section_statements ();
1994 +
1995 + if (!bfd_section_already_linked_table_init ())
1996 + einfo (_("%P%F: Failed to create hash table\n"));
1997 +
1998 + /* Call cmdline_on_object_only_archive_list_p to check which member
1999 + should be loaded. */
2000 + input_flags.whole_archive = TRUE;
2001 +
2002 + /* Set it to avoid adding more to cmdline lists. */
2003 + link_info.emitting_gnu_object_only = TRUE;
2004 +
2005 + cmdline_get_object_only_input_files ();
2006 +
2007 + open_input_bfds (statement_list.head, FALSE);
2008 +
2009 + ldemul_after_open ();
2010 +
2011 + bfd_section_already_linked_table_free ();
2012 +
2013 + /* Make sure that we're not mixing architectures. We call this
2014 + after all the input files have been opened, but before we do any
2015 + other processing, so that any operations merge_private_bfd_data
2016 + does on the output file will be known during the rest of the
2017 + link. */
2018 + lang_check ();
2019 +
2020 + /* Size up the common data. */
2021 + lang_common ();
2022 +
2023 + /* Update wild statements. */
2024 + update_wild_statements (statement_list.head);
2025 +
2026 + /* Run through the contours of the script and attach input sections
2027 + to the correct output sections. */
2028 + map_input_to_output_sections (statement_list.head, NULL, NULL);
2029 +
2030 + /* Find any sections not attached explicitly and handle them. */
2031 + lang_place_orphans ();
2032 +
2033 + /* Do anything special before sizing sections. This is where ELF
2034 + and other back-ends size dynamic sections. */
2035 + ldemul_before_allocation ();
2036 +
2037 + /* Size up the sections. */
2038 + lang_size_sections (NULL, ! RELAXATION_ENABLED);
2039 +
2040 + /* See if anything special should be done now we know how big
2041 + everything is. This is where relaxation is done. */
2042 + ldemul_after_allocation ();
2043 +
2044 + ldemul_finish ();
2045 +
2046 + /* Make sure that the section addresses make sense. */
2047 + if (command_line.check_section_addresses)
2048 + lang_check_section_addresses ();
2049 +
2050 + lang_end ();
2051 +
2052 + ldwrite ();
2053 +
2054 + lang_finish ();
2055 +
2056 + if (! bfd_close (link_info.output_bfd))
2057 + einfo (_("%P%F:%s: final close failed on object-only output: %E\n"),
2058 + output_filename);
2059 +
2060 + /* Read in the object-only file. */
2061 + fd = open (output_filename, O_RDONLY | O_BINARY);
2062 + if (fd < 0)
2063 + {
2064 + bfd_set_error (bfd_error_system_call);
2065 + einfo (_("%P%F:%s: cannot open object-only output: %E"),
2066 + output_filename);
2067 + }
2068 +
2069 + /* Get the object-only file size. */
2070 + if (fstat (fd, &st) != 0)
2071 + {
2072 + bfd_set_error (bfd_error_system_call);
2073 + einfo (_("%P%F:%s: cannot stat object-only output: %E"),
2074 + output_filename);
2075 + }
2076 +
2077 + size = st.st_size;
2078 + off = 0;
2079 + contents = (bfd_byte *) xmalloc (size);
2080 + while (off != size)
2081 + {
2082 + ssize_t got;
2083 +
2084 + got = read (fd, contents + off, size - off);
2085 + if (got < 0)
2086 + {
2087 + bfd_set_error (bfd_error_system_call);
2088 + einfo (_("%P%F:%s: read failed on object-only output: %E"),
2089 + output_filename);
2090 + }
2091 +
2092 + off += got;
2093 + }
2094 +
2095 + close (fd);
2096 +
2097 + /* Remove the temporary object-only file. */
2098 + unlink (output_filename);
2099 +
2100 + output_filename = saved_output_filename;
2101 +
2102 + cmdline_add_object_only_section (contents, size);
2103 +
2104 + free (contents);
2105 + }
2106 +
2107 + /* Extract the object-only section. */
2108 +
2109 + static const char *
2110 + cmdline_extract_object_only_section (bfd *abfd)
2111 + {
2112 + const char *name = bfd_extract_object_only_section (abfd);
2113 +
2114 + if (name == NULL)
2115 + einfo (_("%P%F: cannot extract object-only section from %B: %E"),
2116 + abfd);
2117 +
2118 + /* It should be removed after it is done. */
2119 + cmdline_list_append (&cmdline_temp_object_only_list,
2120 + cmdline_is_file_enum, (void *) name);
2121 +
2122 + return name;
2123 + }
2124 +
2125 + /* Check and handle the object-only section. */
2126 +
2127 + void
2128 + cmdline_check_object_only_section (bfd *abfd, bfd_boolean lto)
2129 + {
2130 + const char *filename;
2131 +
2132 + if (link_info.emitting_gnu_object_only
2133 + || abfd->format != bfd_object)
2134 + return;
2135 +
2136 + if (lto)
2137 + {
2138 + /* For LTO link, we only need to extract object-only section
2139 + from the mixed object, add it to input, and put it on LTO
2140 + claimed output. */
2141 + switch (abfd->lto_type)
2142 + {
2143 + default:
2144 + abort ();
2145 + case lto_mixed_object:
2146 + filename = cmdline_extract_object_only_section (abfd);
2147 + lang_add_input_file (filename,
2148 + lang_input_file_is_file_enum, NULL);
2149 + break;
2150 + case lto_non_ir_object:
2151 + case lto_ir_object:
2152 + break;
2153 + }
2154 + }
2155 + else if (link_info.relocatable)
2156 + {
2157 + /* For non-LTO relocatable link, we need to append non-IR object
2158 + file and the object file in object-only section to the object
2159 + only list. */
2160 + switch (abfd->lto_type)
2161 + {
2162 + default:
2163 + abort ();
2164 + case lto_mixed_object:
2165 + filename = cmdline_extract_object_only_section (abfd);
2166 + cmdline_object_only_list_append (cmdline_is_file_enum,
2167 + (void *) filename);
2168 + break;
2169 + case lto_non_ir_object:
2170 + cmdline_object_only_list_append (cmdline_is_bfd_enum, abfd);
2171 + break;
2172 + case lto_ir_object:
2173 + break;
2174 + }
2175 + }
2176 + }
2177 +
2178 + /* Remove temporary object-only files. */
2179 +
2180 + void
2181 + cmdline_remove_object_only_files (void)
2182 + {
2183 + cmdline_union_type *c;
2184 +
2185 + #ifdef ENABLE_PLUGINS
2186 + if (plugin_save_temps)
2187 + return;
2188 + #endif
2189 +
2190 + c = cmdline_temp_object_only_list.head;
2191 + for (; c != NULL; c = c->header.next)
2192 + switch (c->header.type)
2193 + {
2194 + default:
2195 + abort ();
2196 + case cmdline_is_file_enum:
2197 + unlink (c->file.filename);
2198 + break;
2199 + }
2200 + }
2201 +
2202 +
2203 +
2204 diff -cpr ../binutils-2.23.2.orig/ld/ldlang.h ld/ldlang.h
2205 *** ../binutils-2.23.2.orig/ld/ldlang.h 2013-05-14 16:39:36.861718097 +0100
2206 --- ld/ldlang.h 2013-05-14 16:40:07.053718934 +0100
2207 *************** extern lang_statement_list_type input_fi
2208 *** 488,494 ****
2209 extern int lang_statement_iteration;
2210
2211 extern void lang_init
2212 ! (void);
2213 extern void lang_finish
2214 (void);
2215 extern lang_memory_region_type * lang_memory_region_lookup
2216 --- 488,494 ----
2217 extern int lang_statement_iteration;
2218
2219 extern void lang_init
2220 ! (bfd_boolean);
2221 extern void lang_finish
2222 (void);
2223 extern lang_memory_region_type * lang_memory_region_lookup
2224 *************** ldlang_override_segment_assignment
2225 *** 664,667 ****
2226 --- 664,708 ----
2227 extern void
2228 lang_ld_feature (char *);
2229
2230 + typedef enum
2231 + {
2232 + cmdline_is_file_enum,
2233 + cmdline_is_bfd_enum
2234 + } cmdline_enum_type;
2235 +
2236 + typedef struct cmdline_header_struct
2237 + {
2238 + union cmdline_union *next;
2239 + cmdline_enum_type type;
2240 + } cmdline_header_type;
2241 +
2242 + typedef struct cmdline_file_struct
2243 + {
2244 + cmdline_header_type header;
2245 + const char *filename;
2246 + } cmdline_file_type;
2247 +
2248 + typedef struct cmdline_bfd_struct
2249 + {
2250 + cmdline_header_type header;
2251 + bfd *abfd;
2252 + } cmdline_bfd_type;
2253 +
2254 + typedef union cmdline_union
2255 + {
2256 + cmdline_header_type header;
2257 + cmdline_file_type file;
2258 + cmdline_bfd_type abfd;
2259 + } cmdline_union_type;
2260 +
2261 + typedef struct cmdline_list
2262 + {
2263 + cmdline_union_type *head;
2264 + cmdline_union_type **tail;
2265 + } cmdline_list_type;
2266 +
2267 + extern void cmdline_emit_object_only_section (void);
2268 + extern void cmdline_check_object_only_section (bfd *, bfd_boolean);
2269 + extern void cmdline_remove_object_only_files (void);
2270 +
2271 #endif
2272 diff -cpr ../binutils-2.23.2.orig/ld/ldlex.h ld/ldlex.h
2273 *** ../binutils-2.23.2.orig/ld/ldlex.h 2013-05-14 16:39:39.789718178 +0100
2274 --- ld/ldlex.h 2013-05-14 16:47:18.651730898 +0100
2275 *************** enum option_values
2276 *** 133,138 ****
2277 --- 133,139 ----
2278 #ifdef ENABLE_PLUGINS
2279 OPTION_PLUGIN,
2280 OPTION_PLUGIN_OPT,
2281 + OPTION_PLUGIN_SAVE_TEMPS,
2282 #endif /* ENABLE_PLUGINS */
2283 OPTION_DEFAULT_SCRIPT,
2284 OPTION_PRINT_OUTPUT_FORMAT,
2285 diff -cpr ../binutils-2.23.2.orig/ld/ldmain.c ld/ldmain.c
2286 *** ../binutils-2.23.2.orig/ld/ldmain.c 2013-05-14 16:39:36.862718097 +0100
2287 --- ld/ldmain.c 2013-05-14 16:40:07.055718934 +0100
2288 *************** main (int argc, char **argv)
2289 *** 219,224 ****
2290 --- 219,227 ----
2291
2292 xatexit (ld_cleanup);
2293
2294 + /* Remove temporary object-only files. */
2295 + xatexit (cmdline_remove_object_only_files);
2296 +
2297 /* Set up the sysroot directory. */
2298 ld_sysroot = get_sysroot (argc, argv);
2299 if (*ld_sysroot)
2300 *************** main (int argc, char **argv)
2301 *** 295,301 ****
2302 default_target = ldemul_choose_target (argc, argv);
2303 config.maxpagesize = bfd_emul_get_maxpagesize (default_target);
2304 config.commonpagesize = bfd_emul_get_commonpagesize (default_target);
2305 ! lang_init ();
2306 ldemul_before_parse ();
2307 lang_has_input_file = FALSE;
2308 parse_args (argc, argv);
2309 --- 298,304 ----
2310 default_target = ldemul_choose_target (argc, argv);
2311 config.maxpagesize = bfd_emul_get_maxpagesize (default_target);
2312 config.commonpagesize = bfd_emul_get_commonpagesize (default_target);
2313 ! lang_init (FALSE);
2314 ldemul_before_parse ();
2315 lang_has_input_file = FALSE;
2316 parse_args (argc, argv);
2317 *************** main (int argc, char **argv)
2318 *** 310,343 ****
2319
2320 ldemul_set_symbols ();
2321
2322 ! /* If we have not already opened and parsed a linker script,
2323 ! try the default script from command line first. */
2324 ! if (saved_script_handle == NULL
2325 ! && command_line.default_script != NULL)
2326 ! {
2327 ! ldfile_open_command_file (command_line.default_script);
2328 ! parser_input = input_script;
2329 ! yyparse ();
2330 ! }
2331 !
2332 ! /* If we have not already opened and parsed a linker script
2333 ! read the emulation's appropriate default script. */
2334 ! if (saved_script_handle == NULL)
2335 ! {
2336 ! int isfile;
2337 ! char *s = ldemul_get_script (&isfile);
2338 !
2339 ! if (isfile)
2340 ! ldfile_open_default_command_file (s);
2341 ! else
2342 ! {
2343 ! lex_string = s;
2344 ! lex_redirect (s, _("built in linker script"), 1);
2345 ! }
2346 ! parser_input = input_script;
2347 ! yyparse ();
2348 ! lex_string = NULL;
2349 ! }
2350
2351 if (verbose)
2352 {
2353 --- 313,319 ----
2354
2355 ldemul_set_symbols ();
2356
2357 ! ld_parse_linker_script ();
2358
2359 if (verbose)
2360 {
2361 *************** main (int argc, char **argv)
2362 *** 444,449 ****
2363 --- 420,427 ----
2364 if (! bfd_close (link_info.output_bfd))
2365 einfo (_("%F%B: final close failed: %E\n"), link_info.output_bfd);
2366
2367 + link_info.output_bfd = NULL;
2368 +
2369 /* If the --force-exe-suffix is enabled, and we're making an
2370 executable file and it doesn't end in .exe, copy it to one
2371 which does. */
2372 *************** main (int argc, char **argv)
2373 *** 490,495 ****
2374 --- 468,476 ----
2375 }
2376 }
2377
2378 + if (link_info.emit_gnu_object_only)
2379 + cmdline_emit_object_only_section ();
2380 +
2381 END_PROGRESS (program_name);
2382
2383 if (config.stats)
2384 *************** add_archive_element (struct bfd_link_inf
2385 *** 779,785 ****
2386 --- 760,768 ----
2387 }
2388 }
2389 }
2390 + else
2391 #endif /* ENABLE_PLUGINS */
2392 + cmdline_check_object_only_section (input->the_bfd, FALSE);
2393
2394 ldlang_add_file (input);
2395
2396 *************** warning_callback (struct bfd_link_info *
2397 *** 1152,1158 ****
2398 einfo ("%P: %s%s\n", _("warning: "), warning);
2399 else if (symbol == NULL)
2400 einfo ("%B: %s%s\n", abfd, _("warning: "), warning);
2401 ! else
2402 {
2403 struct warning_callback_info cinfo;
2404
2405 --- 1135,1141 ----
2406 einfo ("%P: %s%s\n", _("warning: "), warning);
2407 else if (symbol == NULL)
2408 einfo ("%B: %s%s\n", abfd, _("warning: "), warning);
2409 ! else if ((abfd->flags & BFD_PLUGIN) == 0)
2410 {
2411 struct warning_callback_info cinfo;
2412
2413 *************** notice (struct bfd_link_info *info,
2414 *** 1459,1461 ****
2415 --- 1442,1479 ----
2416
2417 return TRUE;
2418 }
2419 +
2420 + /* Parse the linker script. */
2421 +
2422 + void
2423 + ld_parse_linker_script ()
2424 + {
2425 + /* If we have not already opened and parsed a linker script,
2426 + try the default script from command line first. */
2427 + if (saved_script_handle == NULL
2428 + && command_line.default_script != NULL)
2429 + {
2430 + ldfile_open_command_file (command_line.default_script);
2431 + parser_input = input_script;
2432 + yyparse ();
2433 + }
2434 +
2435 + /* If we have not already opened and parsed a linker script
2436 + read the emulation's appropriate default script. */
2437 + if (saved_script_handle == NULL)
2438 + {
2439 + int isfile;
2440 + char *s = ldemul_get_script (&isfile);
2441 +
2442 + if (isfile)
2443 + ldfile_open_default_command_file (s);
2444 + else
2445 + {
2446 + lex_string = s;
2447 + lex_redirect (s, _("built in linker script"), 1);
2448 + }
2449 + parser_input = input_script;
2450 + yyparse ();
2451 + lex_string = NULL;
2452 + }
2453 + }
2454 diff -cpr ../binutils-2.23.2.orig/ld/ldmain.h ld/ldmain.h
2455 *** ../binutils-2.23.2.orig/ld/ldmain.h 2013-05-14 16:39:39.810718179 +0100
2456 --- ld/ldmain.h 2013-05-14 16:40:07.055718934 +0100
2457 *************** extern void add_ysym (const char *);
2458 *** 43,46 ****
2459 --- 43,48 ----
2460 extern void add_ignoresym (struct bfd_link_info *, const char *);
2461 extern void add_keepsyms_file (const char *);
2462
2463 + extern void ld_parse_linker_script (void);
2464 +
2465 #endif
2466 diff -cpr ../binutils-2.23.2.orig/ld/lexsup.c ld/lexsup.c
2467 *** ../binutils-2.23.2.orig/ld/lexsup.c 2013-05-14 16:39:36.709718093 +0100
2468 --- ld/lexsup.c 2013-05-14 16:40:07.058718934 +0100
2469 *************** static const struct ld_option ld_options
2470 *** 168,173 ****
2471 --- 168,176 ----
2472 '\0', N_("PLUGIN"), N_("Load named plugin"), ONE_DASH },
2473 { {"plugin-opt", required_argument, NULL, OPTION_PLUGIN_OPT},
2474 '\0', N_("ARG"), N_("Send arg to last-loaded plugin"), ONE_DASH },
2475 + { {"plugin-save-temps", no_argument, NULL, OPTION_PLUGIN_SAVE_TEMPS},
2476 + '\0', NULL, N_("Store plugin intermediate files permanently"),
2477 + ONE_DASH },
2478 { {"flto", optional_argument, NULL, OPTION_IGNORE},
2479 '\0', NULL, N_("Ignored for GCC LTO option compatibility"),
2480 ONE_DASH },
2481 *************** parse_args (unsigned argc, char **argv)
2482 *** 958,963 ****
2483 --- 961,969 ----
2484 if (plugin_opt_plugin_arg (optarg))
2485 einfo(_("%P%F: bad -plugin-opt option\n"));
2486 break;
2487 + case OPTION_PLUGIN_SAVE_TEMPS:
2488 + plugin_save_temps = TRUE;
2489 + break;
2490 #endif /* ENABLE_PLUGINS */
2491 case 'q':
2492 link_info.emitrelocations = TRUE;
2493 diff -cpr ../binutils-2.23.2.orig/ld/plugin.c ld/plugin.c
2494 *** ../binutils-2.23.2.orig/ld/plugin.c 2013-05-14 16:39:37.435718113 +0100
2495 --- ld/plugin.c 2013-05-14 16:48:59.039733681 +0100
2496 ***************
2497 *** 39,44 ****
2498 --- 39,47 ----
2499 /* Report plugin symbols. */
2500 bfd_boolean report_plugin_symbols;
2501
2502 + /* Store plugin intermediate files permanently. */
2503 + bfd_boolean plugin_save_temps;
2504 +
2505 /* The suffix to append to the name of the real (claimed) object file
2506 when generating a dummy BFD to hold the IR symbols sent from the
2507 plugin. For cosmetic use only; appears in maps, crefs etc. */
2508 *************** plugin_opt_plugin_arg (const char *arg)
2509 *** 217,222 ****
2510 --- 220,236 ----
2511 if (!last_plugin)
2512 return set_plugin_error (_("<no plugin>"));
2513
2514 + /* Ignore -pass-through= from GCC driver. */
2515 + if (*arg == '-')
2516 + {
2517 + const char *p;
2518 + for (p = arg + 1; p; p++)
2519 + if (*p != '-')
2520 + break;
2521 + if (strncmp (p, "pass-through=", 13) == 0)
2522 + return 0;
2523 + }
2524 +
2525 newarg = xmalloc (sizeof *newarg);
2526 newarg->arg = arg;
2527 newarg->next = NULL;
2528 *************** plugin_maybe_claim (struct ld_plugin_inp
2529 *** 876,881 ****
2530 --- 890,898 ----
2531 close (file->fd);
2532 if (claimed)
2533 {
2534 + /* Check object only section. */
2535 + cmdline_check_object_only_section (entry->the_bfd, TRUE);
2536 +
2537 /* Discard the real file's BFD and substitute the dummy one. */
2538
2539 /* BFD archive handling caches elements so we can't call
2540 *************** plugin_call_cleanup (void)
2541 *** 929,942 ****
2542 {
2543 if (curplug->cleanup_handler && !curplug->cleanup_done)
2544 {
2545 ! enum ld_plugin_status rv;
2546 ! curplug->cleanup_done = TRUE;
2547 ! called_plugin = curplug;
2548 ! rv = (*curplug->cleanup_handler) ();
2549 ! called_plugin = NULL;
2550 ! if (rv != LDPS_OK)
2551 ! info_msg (_("%P: %s: error in plugin cleanup: %d (ignored)\n"),
2552 ! curplug->name, rv);
2553 dlclose (curplug->dlhandle);
2554 }
2555 curplug = curplug->next;
2556 --- 946,962 ----
2557 {
2558 if (curplug->cleanup_handler && !curplug->cleanup_done)
2559 {
2560 ! if (!plugin_save_temps)
2561 ! {
2562 ! enum ld_plugin_status rv;
2563 ! curplug->cleanup_done = TRUE;
2564 ! called_plugin = curplug;
2565 ! rv = (*curplug->cleanup_handler) ();
2566 ! called_plugin = NULL;
2567 ! if (rv != LDPS_OK)
2568 ! info_msg (_("%P: %s: error in plugin cleanup: %d (ignored)\n"),
2569 ! curplug->name, rv);
2570 ! }
2571 dlclose (curplug->dlhandle);
2572 }
2573 curplug = curplug->next;
2574 diff -cpr ../binutils-2.23.2.orig/ld/plugin.h ld/plugin.h
2575 *** ../binutils-2.23.2.orig/ld/plugin.h 2013-05-14 16:39:39.705718176 +0100
2576 --- ld/plugin.h 2013-05-14 16:40:07.059718934 +0100
2577 ***************
2578 *** 24,29 ****
2579 --- 24,32 ----
2580 /* Report plugin symbols. */
2581 extern bfd_boolean report_plugin_symbols;
2582
2583 + /* Store plugin intermediate files permanently. */
2584 + extern bfd_boolean plugin_save_temps;
2585 +
2586 /* Set at all symbols read time, to avoid recursively offering the plugin
2587 its own newly-added input files and libs to claim. */
2588 extern bfd_boolean no_more_claiming;
2589 diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/armbpabi.sc ld/scripttempl/armbpabi.sc
2590 *** ../binutils-2.23.2.orig/ld/scripttempl/armbpabi.sc 2013-05-14 16:39:39.758718177 +0100
2591 --- ld/scripttempl/armbpabi.sc 2013-05-14 16:54:15.657742458 +0100
2592 *************** INTERP=".interp 0 : { *(.interp) }
2593 *** 30,36 ****
2594 PLT=".plt ${RELOCATING-0} : { *(.plt) }"
2595 RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
2596 DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }"
2597 ! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }"
2598 if test -z "${NO_SMALL_DATA}"; then
2599 SBSS=".sbss ${RELOCATING-0} :
2600 {
2601 --- 30,36 ----
2602 PLT=".plt ${RELOCATING-0} : { *(.plt) }"
2603 RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
2604 DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }"
2605 ! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }"
2606 if test -z "${NO_SMALL_DATA}"; then
2607 SBSS=".sbss ${RELOCATING-0} :
2608 {
2609 diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/elf32sh-symbian.sc ld/scripttempl/elf32sh-symbian.sc
2610 *** ../binutils-2.23.2.orig/ld/scripttempl/elf32sh-symbian.sc 2013-05-14 16:39:39.759718177 +0100
2611 --- ld/scripttempl/elf32sh-symbian.sc 2013-05-14 16:40:07.062718934 +0100
2612 *************** fi
2613 *** 83,89 ****
2614 PLT=".plt : { *(.plt) } :dynamic :dyn"
2615 DYNAMIC=".dynamic : { *(.dynamic) } :dynamic :dyn"
2616 RODATA=".rodata ALIGN(4) : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
2617 ! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.directive) *(.gnu.lto_*) }"
2618 test -z "$GOT" && GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.got) } :dynamic :dyn"
2619 INIT_ARRAY=".init_array ${RELOCATING-0} :
2620 {
2621 --- 83,89 ----
2622 PLT=".plt : { *(.plt) } :dynamic :dyn"
2623 DYNAMIC=".dynamic : { *(.dynamic) } :dynamic :dyn"
2624 RODATA=".rodata ALIGN(4) : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
2625 ! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.directive) *(.gnu.lto_*) *(.gnu_object_only) }"
2626 test -z "$GOT" && GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.got) } :dynamic :dyn"
2627 INIT_ARRAY=".init_array ${RELOCATING-0} :
2628 {
2629 diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/elf64hppa.sc ld/scripttempl/elf64hppa.sc
2630 *** ../binutils-2.23.2.orig/ld/scripttempl/elf64hppa.sc 2013-05-14 16:39:39.733718177 +0100
2631 --- ld/scripttempl/elf64hppa.sc 2013-05-14 16:55:16.076744133 +0100
2632 *************** fi
2633 *** 127,133 ****
2634 DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
2635 RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
2636 DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }"
2637 ! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }"
2638 if test -z "${NO_SMALL_DATA}"; then
2639 SBSS=".sbss ${RELOCATING-0} :
2640 {
2641 --- 127,133 ----
2642 DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
2643 RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
2644 DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }"
2645 ! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }"
2646 if test -z "${NO_SMALL_DATA}"; then
2647 SBSS=".sbss ${RELOCATING-0} :
2648 {
2649 diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/elf.sc ld/scripttempl/elf.sc
2650 *** ../binutils-2.23.2.orig/ld/scripttempl/elf.sc 2013-05-14 16:39:39.755718177 +0100
2651 --- ld/scripttempl/elf.sc 2013-05-14 16:54:44.618743261 +0100
2652 *************** RELA_IPLT=".rela.iplt ${RELOCATING-0}
2653 *** 158,164 ****
2654 DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
2655 RODATA=".${RODATA_NAME} ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }"
2656 DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }"
2657 ! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }"
2658 if test -z "${NO_SMALL_DATA}"; then
2659 SBSS=".${SBSS_NAME} ${RELOCATING-0} :
2660 {
2661 --- 158,164 ----
2662 DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
2663 RODATA=".${RODATA_NAME} ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }"
2664 DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }"
2665 ! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }"
2666 if test -z "${NO_SMALL_DATA}"; then
2667 SBSS=".${SBSS_NAME} ${RELOCATING-0} :
2668 {
2669 diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/elfxtensa.sc ld/scripttempl/elfxtensa.sc
2670 *** ../binutils-2.23.2.orig/ld/scripttempl/elfxtensa.sc 2013-05-14 16:39:39.754718177 +0100
2671 --- ld/scripttempl/elfxtensa.sc 2013-05-14 16:55:44.908744932 +0100
2672 *************** fi
2673 *** 140,146 ****
2674 DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
2675 RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
2676 DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }"
2677 ! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }"
2678 INIT_LIT=".init.literal 0 : { *(.init.literal) }"
2679 INIT=".init 0 : { *(.init) }"
2680 FINI_LIT=".fini.literal 0 : { *(.fini.literal) }"
2681 --- 140,146 ----
2682 DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
2683 RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
2684 DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }"
2685 ! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }"
2686 INIT_LIT=".init.literal 0 : { *(.init.literal) }"
2687 INIT=".init 0 : { *(.init) }"
2688 FINI_LIT=".fini.literal 0 : { *(.fini.literal) }"
2689 diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/mep.sc ld/scripttempl/mep.sc
2690 *** ../binutils-2.23.2.orig/ld/scripttempl/mep.sc 2013-05-14 16:39:39.755718177 +0100
2691 --- ld/scripttempl/mep.sc 2013-05-14 16:56:08.605745589 +0100
2692 *************** fi
2693 *** 114,120 ****
2694 DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
2695 RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
2696 DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }"
2697 ! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }"
2698 if test -z "${NO_SMALL_DATA}"; then
2699 SBSS=".sbss ${RELOCATING-0} :
2700 {
2701 --- 114,120 ----
2702 DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
2703 RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
2704 DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }"
2705 ! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }"
2706 if test -z "${NO_SMALL_DATA}"; then
2707 SBSS=".sbss ${RELOCATING-0} :
2708 {
2709 diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/pep.sc ld/scripttempl/pep.sc
2710 *** ../binutils-2.23.2.orig/ld/scripttempl/pep.sc 2013-05-14 16:39:39.755718177 +0100
2711 --- ld/scripttempl/pep.sc 2013-05-14 16:40:07.064718934 +0100
2712 *************** SECTIONS
2713 *** 154,159 ****
2714 --- 154,160 ----
2715 *(.drectve)
2716 ${RELOCATING+ *(.note.GNU-stack)}
2717 ${RELOCATING+ *(.gnu.lto_*)}
2718 + ${RELOCATING+ *(.gnu_object_only)}
2719 }
2720
2721 .idata ${RELOCATING+BLOCK(__section_alignment__)} :
2722 diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/pe.sc ld/scripttempl/pe.sc
2723 *** ../binutils-2.23.2.orig/ld/scripttempl/pe.sc 2013-05-14 16:39:39.758718177 +0100
2724 --- ld/scripttempl/pe.sc 2013-05-14 16:40:07.064718934 +0100
2725 *************** SECTIONS
2726 *** 148,153 ****
2727 --- 148,154 ----
2728 *(.drectve)
2729 ${RELOCATING+ *(.note.GNU-stack)}
2730 ${RELOCATING+ *(.gnu.lto_*)}
2731 + ${RELOCATING+ *(.gnu_object_only)}
2732 }
2733
2734 .idata ${RELOCATING+BLOCK(__section_alignment__)} :