Delay evaluation of alignment expressions in output sections
[deliverable/binutils-gdb.git] / ld / emultempl / ppc64elf.em
1 # This shell script emits a C file. -*- C -*-
2 # Copyright (C) 2002-2018 Free Software Foundation, Inc.
3 #
4 # This file is part of the GNU Binutils.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 # MA 02110-1301, USA.
20 #
21
22 # This file is sourced from elf32.em, and defines extra powerpc64-elf
23 # specific routines.
24 #
25 fragment <<EOF
26
27 #include "ldctor.h"
28 #include "elf-bfd.h"
29 #include "elf64-ppc.h"
30 #include "ldlex.h"
31 #include "elf/ppc64.h"
32
33 static asection *ppc_add_stub_section (const char *, asection *);
34 static void ppc_layout_sections_again (void);
35
36 static struct ppc64_elf_params params = { NULL,
37 &ppc_add_stub_section,
38 &ppc_layout_sections_again,
39 1, -1, 0,
40 ${DEFAULT_PLT_STATIC_CHAIN-0}, -1, 5,
41 -1, 0, -1, -1, 0};
42
43 /* Fake input file for stubs. */
44 static lang_input_statement_type *stub_file;
45
46 /* Whether we need to call ppc_layout_sections_again. */
47 static int need_laying_out = 0;
48
49 /* Whether to add ".foo" entries for each "foo" in a version script. */
50 static int dotsyms = 1;
51
52 /* Whether to run tls optimization. */
53 static int no_tls_opt = 0;
54
55 /* Whether to run opd optimization. */
56 static int no_opd_opt = 0;
57
58 /* Whether to convert inline PLT calls to direct. */
59 static int no_inline_opt = 0;
60
61 /* Whether to run toc optimization. */
62 static int no_toc_opt = 0;
63
64 /* Whether to sort input toc and got sections. */
65 static int no_toc_sort = 0;
66
67 /* Input .toc sections will be placed in this output section. */
68 static const char *toc_section_name = ".got";
69 static asection *toc_section = 0;
70
71 /* This is called before the input files are opened. We create a new
72 fake input file to hold the stub sections. */
73
74 static void
75 ppc_create_output_section_statements (void)
76 {
77 if (!(bfd_get_flavour (link_info.output_bfd) == bfd_target_elf_flavour
78 && elf_object_id (link_info.output_bfd) == PPC64_ELF_DATA))
79 return;
80
81 link_info.wrap_char = '.';
82
83 stub_file = lang_add_input_file ("linker stubs",
84 lang_input_file_is_fake_enum,
85 NULL);
86 stub_file->the_bfd = bfd_create ("linker stubs", link_info.output_bfd);
87 if (stub_file->the_bfd == NULL
88 || !bfd_set_arch_mach (stub_file->the_bfd,
89 bfd_get_arch (link_info.output_bfd),
90 bfd_get_mach (link_info.output_bfd)))
91 {
92 einfo (_("%F%P: can not create BFD: %E\n"));
93 return;
94 }
95
96 stub_file->the_bfd->flags |= BFD_LINKER_CREATED;
97 ldlang_add_file (stub_file);
98 params.stub_bfd = stub_file->the_bfd;
99 if (params.save_restore_funcs < 0)
100 params.save_restore_funcs = !bfd_link_relocatable (&link_info);
101 if (!ppc64_elf_init_stub_bfd (&link_info, &params))
102 einfo (_("%F%P: can not init BFD: %E\n"));
103 }
104
105 /* Called after opening files but before mapping sections. */
106
107 static void
108 ppc_after_open (void)
109 {
110 if (stub_file != NULL && link_info.relro && params.object_in_toc)
111 {
112 /* We have a .toc section that might be written to at run time.
113 Don't put .toc into the .got output section. */
114 lang_output_section_statement_type *got;
115
116 got = lang_output_section_find (".got");
117 if (got != NULL)
118 {
119 lang_statement_union_type *s;
120 for (s = got->children.head; s != NULL; s = s->header.next)
121 if (s->header.type == lang_wild_statement_enum
122 && s->wild_statement.filename == NULL)
123 {
124 struct wildcard_list **i = &s->wild_statement.section_list;
125 while (*i != NULL)
126 if (strcmp ((*i)->spec.name, ".toc") == 0)
127 *i = (*i)->next;
128 else
129 i = &(*i)->next;
130 }
131 /* Instead, .toc input sections will be mapped to the
132 read/write .toc output section. If user scripts don't
133 provide one then we'll lose toc sorting and multi-toc. */
134 toc_section_name = ".toc";
135 }
136 }
137 gld${EMULATION_NAME}_after_open ();
138 }
139
140 /* Move the input section statement at *U which happens to be on LIST
141 to be just before *TO. */
142
143 static void
144 move_input_section (lang_statement_list_type *list,
145 lang_statement_union_type **u,
146 lang_statement_union_type **to)
147 {
148 lang_statement_union_type *s = *u;
149 asection *i = s->input_section.section;
150 asection *p, *n;
151
152 /* Snip the input section from the statement list. If it was the
153 last statement, fix the list tail pointer. */
154 *u = s->header.next;
155 if (*u == NULL)
156 list->tail = u;
157 /* Add it back in the new position. */
158 s->header.next = *to;
159 *to = s;
160 if (list->tail == to)
161 list->tail = &s->header.next;
162
163 /* Trim I off the bfd map_head/map_tail doubly linked lists. */
164 n = i->map_head.s;
165 p = i->map_tail.s;
166 (p != NULL ? p : i->output_section)->map_head.s = n;
167 (n != NULL ? n : i->output_section)->map_tail.s = p;
168
169 /* Add I back on in its new position. */
170 if (s->header.next->header.type == lang_input_section_enum)
171 {
172 n = s->header.next->input_section.section;
173 p = n->map_tail.s;
174 }
175 else
176 {
177 /* If the next statement is not an input section statement then
178 TO must point at the previous input section statement
179 header.next field. */
180 lang_input_section_type *prev = (lang_input_section_type *)
181 ((char *) to - offsetof (lang_statement_union_type, header.next));
182
183 ASSERT (prev->header.type == lang_input_section_enum);
184 p = prev->section;
185 n = p->map_head.s;
186 }
187 i->map_head.s = n;
188 i->map_tail.s = p;
189 (p != NULL ? p : i->output_section)->map_head.s = i;
190 (n != NULL ? n : i->output_section)->map_tail.s = i;
191 }
192
193 /* Sort input section statements in the linker script tree rooted at
194 LIST so that those whose owning bfd happens to have a section
195 called .init or .fini are placed first. Place any TOC sections
196 referenced by small TOC relocs next, with TOC sections referenced
197 only by bigtoc relocs last. */
198
199 static void
200 sort_toc_sections (lang_statement_list_type *list,
201 lang_statement_union_type **ini,
202 lang_statement_union_type **small)
203 {
204 lang_statement_union_type *s, **u;
205 asection *i;
206
207 u = &list->head;
208 while ((s = *u) != NULL)
209 {
210 switch (s->header.type)
211 {
212 case lang_wild_statement_enum:
213 sort_toc_sections (&s->wild_statement.children, ini, small);
214 break;
215
216 case lang_group_statement_enum:
217 sort_toc_sections (&s->group_statement.children, ini, small);
218 break;
219
220 case lang_input_section_enum:
221 i = s->input_section.section;
222 /* Leave the stub_file .got where it is. We put the .got
223 header there. */
224 if (i->owner == stub_file->the_bfd)
225 break;
226 if (bfd_get_section_by_name (i->owner, ".init") != NULL
227 || bfd_get_section_by_name (i->owner, ".fini") != NULL)
228 {
229 if (ini != NULL && *ini != s)
230 {
231 move_input_section (list, u, ini);
232 if (small == ini)
233 small = &s->header.next;
234 ini = &s->header.next;
235 continue;
236 }
237 if (small == ini)
238 small = &s->header.next;
239 ini = &s->header.next;
240 break;
241 }
242 else if (ini == NULL)
243 ini = u;
244
245 if (ppc64_elf_has_small_toc_reloc (i))
246 {
247 if (small != NULL && *small != s)
248 {
249 move_input_section (list, u, small);
250 small = &s->header.next;
251 continue;
252 }
253 small = &s->header.next;
254 }
255 else if (small == NULL)
256 small = u;
257 break;
258
259 default:
260 break;
261 }
262 u = &s->header.next;
263 }
264 }
265
266 static void
267 prelim_size_sections (void)
268 {
269 if (expld.phase != lang_mark_phase_enum)
270 {
271 expld.phase = lang_mark_phase_enum;
272 expld.dataseg.phase = exp_seg_none;
273 one_lang_size_sections_pass (NULL, FALSE);
274 /* We must not cache anything from the preliminary sizing. */
275 lang_reset_memory_regions ();
276 }
277 }
278
279 static void
280 ppc_before_allocation (void)
281 {
282 if (stub_file != NULL)
283 {
284 if (!no_opd_opt
285 && !ppc64_elf_edit_opd (&link_info))
286 einfo (_("%X%P: can not edit %s: %E\n"), "opd");
287
288 if (!no_inline_opt
289 && !bfd_link_relocatable (&link_info))
290 {
291 prelim_size_sections ();
292
293 if (!ppc64_elf_inline_plt (&link_info))
294 einfo (_("%X%P: inline PLT: %E\n"));
295 }
296
297 if (ppc64_elf_tls_setup (&link_info)
298 && !no_tls_opt)
299 {
300 /* Size the sections. This is premature, but we want to know the
301 TLS segment layout so that certain optimizations can be done. */
302 prelim_size_sections ();
303
304 if (!ppc64_elf_tls_optimize (&link_info))
305 einfo (_("%X%P: TLS problem %E\n"));
306 }
307
308 if (!no_toc_opt
309 && !bfd_link_relocatable (&link_info))
310 {
311 prelim_size_sections ();
312
313 if (!ppc64_elf_edit_toc (&link_info))
314 einfo (_("%X%P: can not edit %s: %E\n"), "toc");
315 }
316
317 if (!no_toc_sort)
318 {
319 lang_output_section_statement_type *toc_os;
320
321 toc_os = lang_output_section_find (toc_section_name);
322 if (toc_os != NULL)
323 sort_toc_sections (&toc_os->children, NULL, NULL);
324 }
325 }
326
327 gld${EMULATION_NAME}_before_allocation ();
328 }
329
330 struct hook_stub_info
331 {
332 lang_statement_list_type add;
333 asection *input_section;
334 };
335
336 /* Traverse the linker tree to find the spot where the stub goes. */
337
338 static bfd_boolean
339 hook_in_stub (struct hook_stub_info *info, lang_statement_union_type **lp)
340 {
341 lang_statement_union_type *l;
342 bfd_boolean ret;
343
344 for (; (l = *lp) != NULL; lp = &l->header.next)
345 {
346 switch (l->header.type)
347 {
348 case lang_constructors_statement_enum:
349 ret = hook_in_stub (info, &constructor_list.head);
350 if (ret)
351 return ret;
352 break;
353
354 case lang_output_section_statement_enum:
355 ret = hook_in_stub (info,
356 &l->output_section_statement.children.head);
357 if (ret)
358 return ret;
359 break;
360
361 case lang_wild_statement_enum:
362 ret = hook_in_stub (info, &l->wild_statement.children.head);
363 if (ret)
364 return ret;
365 break;
366
367 case lang_group_statement_enum:
368 ret = hook_in_stub (info, &l->group_statement.children.head);
369 if (ret)
370 return ret;
371 break;
372
373 case lang_input_section_enum:
374 if (l->input_section.section == info->input_section)
375 {
376 /* We've found our section. Insert the stub immediately
377 before its associated input section. */
378 *lp = info->add.head;
379 *(info->add.tail) = l;
380 return TRUE;
381 }
382 break;
383
384 case lang_data_statement_enum:
385 case lang_reloc_statement_enum:
386 case lang_object_symbols_statement_enum:
387 case lang_output_statement_enum:
388 case lang_target_statement_enum:
389 case lang_input_statement_enum:
390 case lang_assignment_statement_enum:
391 case lang_padding_statement_enum:
392 case lang_address_statement_enum:
393 case lang_fill_statement_enum:
394 break;
395
396 default:
397 FAIL ();
398 break;
399 }
400 }
401 return FALSE;
402 }
403
404
405 /* Call-back for ppc64_elf_size_stubs. */
406
407 /* Create a new stub section, and arrange for it to be linked
408 immediately before INPUT_SECTION. */
409
410 static asection *
411 ppc_add_stub_section (const char *stub_sec_name, asection *input_section)
412 {
413 asection *stub_sec;
414 flagword flags;
415 asection *output_section;
416 lang_output_section_statement_type *os;
417 struct hook_stub_info info;
418
419 flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE
420 | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_KEEP);
421 stub_sec = bfd_make_section_anyway_with_flags (stub_file->the_bfd,
422 stub_sec_name, flags);
423 if (stub_sec == NULL
424 || !bfd_set_section_alignment (stub_file->the_bfd, stub_sec,
425 (params.plt_stub_align > 5
426 ? params.plt_stub_align
427 : params.plt_stub_align < -5
428 ? -params.plt_stub_align
429 : 5)))
430 goto err_ret;
431
432 output_section = input_section->output_section;
433 os = lang_output_section_get (output_section);
434
435 info.input_section = input_section;
436 lang_list_init (&info.add);
437 lang_add_section (&info.add, stub_sec, NULL, os);
438
439 if (info.add.head == NULL)
440 goto err_ret;
441
442 if (hook_in_stub (&info, &os->children.head))
443 return stub_sec;
444
445 err_ret:
446 einfo (_("%X%P: can not make stub section: %E\n"));
447 return NULL;
448 }
449
450
451 /* Another call-back for ppc64_elf_size_stubs. */
452
453 static void
454 ppc_layout_sections_again (void)
455 {
456 /* If we have changed sizes of the stub sections, then we need
457 to recalculate all the section offsets. This may mean we need to
458 add even more stubs. */
459 gld${EMULATION_NAME}_map_segments (TRUE);
460
461 if (!bfd_link_relocatable (&link_info))
462 ppc64_elf_set_toc (&link_info, link_info.output_bfd);
463
464 need_laying_out = -1;
465 }
466
467
468 static void
469 build_toc_list (lang_statement_union_type *statement)
470 {
471 if (statement->header.type == lang_input_section_enum)
472 {
473 asection *i = statement->input_section.section;
474
475 if (i->sec_info_type != SEC_INFO_TYPE_JUST_SYMS
476 && (i->flags & SEC_EXCLUDE) == 0
477 && i->output_section == toc_section)
478 {
479 if (!ppc64_elf_next_toc_section (&link_info, i))
480 einfo (_("%X%P: linker script separates .got and .toc\n"));
481 }
482 }
483 }
484
485
486 static void
487 build_section_lists (lang_statement_union_type *statement)
488 {
489 if (statement->header.type == lang_input_section_enum)
490 {
491 asection *i = statement->input_section.section;
492
493 if (!((lang_input_statement_type *) i->owner->usrdata)->flags.just_syms
494 && (i->flags & SEC_EXCLUDE) == 0
495 && i->output_section != NULL
496 && i->output_section->owner == link_info.output_bfd)
497 {
498 if (!ppc64_elf_next_input_section (&link_info, i))
499 einfo (_("%X%P: can not size stub section: %E\n"));
500 }
501 }
502 }
503
504
505 /* Call the back-end function to set TOC base after we have placed all
506 the sections. */
507 static void
508 gld${EMULATION_NAME}_after_allocation (void)
509 {
510 int ret;
511
512 /* If generating a relocatable output file, then we don't have any
513 stubs. */
514 if (stub_file != NULL && !bfd_link_relocatable (&link_info))
515 {
516 ret = ppc64_elf_setup_section_lists (&link_info);
517 if (ret < 0)
518 einfo (_("%X%P: can not size stub section: %E\n"));
519 else
520 {
521 ppc64_elf_start_multitoc_partition (&link_info);
522
523 if (!params.no_multi_toc)
524 {
525 toc_section = bfd_get_section_by_name (link_info.output_bfd,
526 toc_section_name);
527 if (toc_section != NULL)
528 lang_for_each_statement (build_toc_list);
529 }
530
531 if (ppc64_elf_layout_multitoc (&link_info)
532 && !params.no_multi_toc
533 && toc_section != NULL)
534 lang_for_each_statement (build_toc_list);
535
536 ppc64_elf_finish_multitoc_partition (&link_info);
537
538 lang_for_each_statement (build_section_lists);
539
540 if (!ppc64_elf_check_init_fini (&link_info))
541 einfo (_("%P: .init/.fini fragments use differing TOC pointers\n"));
542
543 /* Call into the BFD backend to do the real work. */
544 if (!ppc64_elf_size_stubs (&link_info))
545 einfo (_("%X%P: can not size stub section: %E\n"));
546 }
547 }
548
549 /* We can't parse and merge .eh_frame until the glink .eh_frame has
550 been generated. Otherwise the glink .eh_frame CIE won't be
551 merged with other CIEs, and worse, the glink .eh_frame FDEs won't
552 be listed in .eh_frame_hdr. */
553 ret = bfd_elf_discard_info (link_info.output_bfd, &link_info);
554 if (ret < 0)
555 {
556 einfo (_("%X%P: .eh_frame/.stab edit: %E\n"));
557 return;
558 }
559 else if (ret > 0)
560 need_laying_out = 1;
561
562 /* Call map_segments regardless of the state of need_laying_out.
563 need_laying_out set to -1 means we have just laid everything out,
564 but ppc64_elf_size_stubs strips .branch_lt and .eh_frame if
565 unneeded, after ppc_layout_sections_again. Another call removes
566 these sections from the segment map. Their presence is
567 innocuous except for confusing ELF_SECTION_IN_SEGMENT. */
568 gld${EMULATION_NAME}_map_segments (need_laying_out > 0);
569
570 if (need_laying_out != -1 && !bfd_link_relocatable (&link_info))
571 ppc64_elf_set_toc (&link_info, link_info.output_bfd);
572 }
573
574
575 /* Final emulation specific call. */
576
577 static void
578 gld${EMULATION_NAME}_finish (void)
579 {
580 char *msg = NULL;
581 char *line, *endline;
582
583 /* e_entry on PowerPC64 points to the function descriptor for
584 _start. If _start is missing, default to the first function
585 descriptor in the .opd section. */
586 if (stub_file != NULL
587 && (elf_elfheader (link_info.output_bfd)->e_flags & EF_PPC64_ABI) == 1)
588 entry_section = ".opd";
589
590 if (params.emit_stub_syms < 0)
591 params.emit_stub_syms = 1;
592 if (stub_file != NULL
593 && !bfd_link_relocatable (&link_info)
594 && !ppc64_elf_build_stubs (&link_info, config.stats ? &msg : NULL))
595 einfo (_("%X%P: can not build stubs: %E\n"));
596
597 fflush (stdout);
598 for (line = msg; line != NULL; line = endline)
599 {
600 endline = strchr (line, '\n');
601 if (endline != NULL)
602 *endline++ = '\0';
603 fprintf (stderr, "%s: %s\n", program_name, line);
604 }
605 fflush (stderr);
606 if (msg != NULL)
607 free (msg);
608
609 finish_default ();
610 }
611
612
613 /* Add a pattern matching ".foo" for every "foo" in a version script.
614
615 The reason for doing this is that many shared library version
616 scripts export a selected set of functions or data symbols, forcing
617 others local. eg.
618
619 . VERS_1 {
620 . global:
621 . this; that; some; thing;
622 . local:
623 . *;
624 . };
625
626 To make the above work for PowerPC64, we need to export ".this",
627 ".that" and so on, otherwise only the function descriptor syms are
628 exported. Lack of an exported function code sym may cause a
629 definition to be pulled in from a static library. */
630
631 static struct bfd_elf_version_expr *
632 gld${EMULATION_NAME}_new_vers_pattern (struct bfd_elf_version_expr *entry)
633 {
634 struct bfd_elf_version_expr *dot_entry;
635 unsigned int len;
636 char *dot_pat;
637
638 if (!dotsyms
639 || entry->pattern[0] == '.'
640 || (!entry->literal && entry->pattern[0] == '*'))
641 return entry;
642
643 dot_entry = xmalloc (sizeof *dot_entry);
644 *dot_entry = *entry;
645 dot_entry->next = entry;
646 len = strlen (entry->pattern) + 2;
647 dot_pat = xmalloc (len);
648 dot_pat[0] = '.';
649 memcpy (dot_pat + 1, entry->pattern, len - 1);
650 dot_entry->pattern = dot_pat;
651 dot_entry->script = 1;
652 return dot_entry;
653 }
654
655
656 /* Avoid processing the fake stub_file in vercheck, stat_needed and
657 check_needed routines. */
658
659 static void (*real_func) (lang_input_statement_type *);
660
661 static void ppc_for_each_input_file_wrapper (lang_input_statement_type *l)
662 {
663 if (l != stub_file)
664 (*real_func) (l);
665 }
666
667 static void
668 ppc_lang_for_each_input_file (void (*func) (lang_input_statement_type *))
669 {
670 real_func = func;
671 lang_for_each_input_file (&ppc_for_each_input_file_wrapper);
672 }
673
674 #define lang_for_each_input_file ppc_lang_for_each_input_file
675
676 EOF
677
678 if grep -q 'ld_elf32_spu_emulation' ldemul-list.h; then
679 fragment <<EOF
680 /* Special handling for embedded SPU executables. */
681 extern bfd_boolean embedded_spu_file (lang_input_statement_type *, const char *);
682 static bfd_boolean gld${EMULATION_NAME}_load_symbols (lang_input_statement_type *);
683
684 static bfd_boolean
685 ppc64_recognized_file (lang_input_statement_type *entry)
686 {
687 if (embedded_spu_file (entry, "-m64"))
688 return TRUE;
689
690 return gld${EMULATION_NAME}_load_symbols (entry);
691 }
692 EOF
693 LDEMUL_RECOGNIZED_FILE=ppc64_recognized_file
694 fi
695
696 # Define some shell vars to insert bits of code into the standard elf
697 # parse_args and list_options functions.
698 #
699 PARSE_AND_LIST_PROLOGUE=${PARSE_AND_LIST_PROLOGUE}'
700 enum ppc64_opt
701 {
702 OPTION_STUBGROUP_SIZE = 321,
703 OPTION_PLT_STATIC_CHAIN,
704 OPTION_NO_PLT_STATIC_CHAIN,
705 OPTION_PLT_THREAD_SAFE,
706 OPTION_NO_PLT_THREAD_SAFE,
707 OPTION_PLT_ALIGN,
708 OPTION_NO_PLT_ALIGN,
709 OPTION_PLT_LOCALENTRY,
710 OPTION_NO_PLT_LOCALENTRY,
711 OPTION_STUBSYMS,
712 OPTION_NO_STUBSYMS,
713 OPTION_SAVRES,
714 OPTION_NO_SAVRES,
715 OPTION_DOTSYMS,
716 OPTION_NO_DOTSYMS,
717 OPTION_NO_TLS_OPT,
718 OPTION_TLS_GET_ADDR_OPT,
719 OPTION_NO_TLS_GET_ADDR_OPT,
720 OPTION_NO_OPD_OPT,
721 OPTION_NO_INLINE_OPT,
722 OPTION_NO_TOC_OPT,
723 OPTION_NO_MULTI_TOC,
724 OPTION_NO_TOC_SORT,
725 OPTION_NON_OVERLAPPING_OPD
726 };
727 '
728
729 PARSE_AND_LIST_LONGOPTS=${PARSE_AND_LIST_LONGOPTS}'
730 { "stub-group-size", required_argument, NULL, OPTION_STUBGROUP_SIZE },
731 { "plt-static-chain", no_argument, NULL, OPTION_PLT_STATIC_CHAIN },
732 { "no-plt-static-chain", no_argument, NULL, OPTION_NO_PLT_STATIC_CHAIN },
733 { "plt-thread-safe", no_argument, NULL, OPTION_PLT_THREAD_SAFE },
734 { "no-plt-thread-safe", no_argument, NULL, OPTION_NO_PLT_THREAD_SAFE },
735 { "plt-align", optional_argument, NULL, OPTION_PLT_ALIGN },
736 { "no-plt-align", no_argument, NULL, OPTION_NO_PLT_ALIGN },
737 { "plt-localentry", optional_argument, NULL, OPTION_PLT_LOCALENTRY },
738 { "no-plt-localentry", no_argument, NULL, OPTION_NO_PLT_LOCALENTRY },
739 { "emit-stub-syms", no_argument, NULL, OPTION_STUBSYMS },
740 { "no-emit-stub-syms", no_argument, NULL, OPTION_NO_STUBSYMS },
741 { "dotsyms", no_argument, NULL, OPTION_DOTSYMS },
742 { "no-dotsyms", no_argument, NULL, OPTION_NO_DOTSYMS },
743 { "save-restore-funcs", no_argument, NULL, OPTION_SAVRES },
744 { "no-save-restore-funcs", no_argument, NULL, OPTION_NO_SAVRES },
745 { "no-tls-optimize", no_argument, NULL, OPTION_NO_TLS_OPT },
746 { "tls-get-addr-optimize", no_argument, NULL, OPTION_TLS_GET_ADDR_OPT },
747 { "no-tls-get-addr-optimize", no_argument, NULL, OPTION_NO_TLS_GET_ADDR_OPT },
748 { "no-opd-optimize", no_argument, NULL, OPTION_NO_OPD_OPT },
749 { "no-inline-optimize", no_argument, NULL, OPTION_NO_INLINE_OPT },
750 { "no-toc-optimize", no_argument, NULL, OPTION_NO_TOC_OPT },
751 { "no-multi-toc", no_argument, NULL, OPTION_NO_MULTI_TOC },
752 { "no-toc-sort", no_argument, NULL, OPTION_NO_TOC_SORT },
753 { "non-overlapping-opd", no_argument, NULL, OPTION_NON_OVERLAPPING_OPD },
754 '
755
756 PARSE_AND_LIST_OPTIONS=${PARSE_AND_LIST_OPTIONS}'
757 fprintf (file, _("\
758 --stub-group-size=N Maximum size of a group of input sections that\n\
759 can be handled by one stub section. A negative\n\
760 value locates all stubs before their branches\n\
761 (with a group size of -N), while a positive\n\
762 value allows two groups of input sections, one\n\
763 before, and one after each stub section.\n\
764 Values of +/-1 indicate the linker should\n\
765 choose suitable defaults.\n"
766 ));
767 fprintf (file, _("\
768 --plt-static-chain PLT call stubs should load r11'${DEFAULT_PLT_STATIC_CHAIN- (default)}'\n"
769 ));
770 fprintf (file, _("\
771 --no-plt-static-chain PLT call stubs should not load r11'${DEFAULT_PLT_STATIC_CHAIN+ (default)}'\n"
772 ));
773 fprintf (file, _("\
774 --plt-thread-safe PLT call stubs with load-load barrier\n"
775 ));
776 fprintf (file, _("\
777 --no-plt-thread-safe PLT call stubs without barrier\n"
778 ));
779 fprintf (file, _("\
780 --plt-align [=<align>] Align PLT call stubs to fit cache lines\n"
781 ));
782 fprintf (file, _("\
783 --no-plt-align Dont'\''t align individual PLT call stubs\n"
784 ));
785 fprintf (file, _("\
786 --plt-localentry Optimize calls to ELFv2 localentry:0 functions\n"
787 ));
788 fprintf (file, _("\
789 --no-plt-localentry Don'\''t optimize ELFv2 calls\n"
790 ));
791 fprintf (file, _("\
792 --emit-stub-syms Label linker stubs with a symbol\n"
793 ));
794 fprintf (file, _("\
795 --no-emit-stub-syms Don'\''t label linker stubs with a symbol\n"
796 ));
797 fprintf (file, _("\
798 --dotsyms For every version pattern \"foo\" in a version\n\
799 script, add \".foo\" so that function code\n\
800 symbols are treated the same as function\n\
801 descriptor symbols. Defaults to on.\n"
802 ));
803 fprintf (file, _("\
804 --no-dotsyms Don'\''t do anything special in version scripts\n"
805 ));
806 fprintf (file, _("\
807 --save-restore-funcs Provide register save and restore routines used\n\
808 by gcc -Os code. Defaults to on for normal\n\
809 final link, off for ld -r.\n"
810 ));
811 fprintf (file, _("\
812 --no-save-restore-funcs Don'\''t provide these routines\n"
813 ));
814 fprintf (file, _("\
815 --no-tls-optimize Don'\''t try to optimize TLS accesses\n"
816 ));
817 fprintf (file, _("\
818 --tls-get-addr-optimize Force use of special __tls_get_addr call\n"
819 ));
820 fprintf (file, _("\
821 --no-tls-get-addr-optimize Don'\''t use a special __tls_get_addr call\n"
822 ));
823 fprintf (file, _("\
824 --no-opd-optimize Don'\''t optimize the OPD section\n"
825 ));
826 fprintf (file, _("\
827 --no-inline-optimize Don'\''t convert inline PLT to direct calls\n"
828 ));
829 fprintf (file, _("\
830 --no-toc-optimize Don'\''t optimize the TOC section\n"
831 ));
832 fprintf (file, _("\
833 --no-multi-toc Disallow automatic multiple toc sections\n"
834 ));
835 fprintf (file, _("\
836 --no-toc-sort Don'\''t sort TOC and GOT sections\n"
837 ));
838 fprintf (file, _("\
839 --non-overlapping-opd Canonicalize .opd, so that there are no\n\
840 overlapping .opd entries\n"
841 ));
842 '
843
844 PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LIST_ARGS_CASES}'
845 case OPTION_STUBGROUP_SIZE:
846 {
847 const char *end;
848 params.group_size = bfd_scan_vma (optarg, &end, 0);
849 if (*end)
850 einfo (_("%F%P: invalid number `%s'\''\n"), optarg);
851 }
852 break;
853
854 case OPTION_PLT_STATIC_CHAIN:
855 params.plt_static_chain = 1;
856 break;
857
858 case OPTION_NO_PLT_STATIC_CHAIN:
859 params.plt_static_chain = 0;
860 break;
861
862 case OPTION_PLT_THREAD_SAFE:
863 params.plt_thread_safe = 1;
864 break;
865
866 case OPTION_NO_PLT_THREAD_SAFE:
867 params.plt_thread_safe = 0;
868 break;
869
870 case OPTION_PLT_ALIGN:
871 if (optarg != NULL)
872 {
873 char *end;
874 long val = strtol (optarg, &end, 0);
875 if (*end || (unsigned long) val + 8 > 16)
876 einfo (_("%F%P: invalid --plt-align `%s'\''\n"), optarg);
877 params.plt_stub_align = val;
878 }
879 else
880 params.plt_stub_align = 5;
881 break;
882
883 case OPTION_NO_PLT_ALIGN:
884 params.plt_stub_align = 0;
885 break;
886
887 case OPTION_PLT_LOCALENTRY:
888 params.plt_localentry0 = 1;
889 break;
890
891 case OPTION_NO_PLT_LOCALENTRY:
892 params.plt_localentry0 = 0;
893 break;
894
895 case OPTION_STUBSYMS:
896 params.emit_stub_syms = 1;
897 break;
898
899 case OPTION_NO_STUBSYMS:
900 params.emit_stub_syms = 0;
901 break;
902
903 case OPTION_DOTSYMS:
904 dotsyms = 1;
905 break;
906
907 case OPTION_NO_DOTSYMS:
908 dotsyms = 0;
909 break;
910
911 case OPTION_SAVRES:
912 params.save_restore_funcs = 1;
913 break;
914
915 case OPTION_NO_SAVRES:
916 params.save_restore_funcs = 0;
917 break;
918
919 case OPTION_NO_TLS_OPT:
920 no_tls_opt = 1;
921 break;
922
923 case OPTION_TLS_GET_ADDR_OPT:
924 params.tls_get_addr_opt = 1;
925 break;
926
927 case OPTION_NO_TLS_GET_ADDR_OPT:
928 params.tls_get_addr_opt = 0;
929 break;
930
931 case OPTION_NO_OPD_OPT:
932 no_opd_opt = 1;
933 break;
934
935 case OPTION_NO_INLINE_OPT:
936 no_inline_opt = 1;
937 break;
938
939 case OPTION_NO_TOC_OPT:
940 no_toc_opt = 1;
941 break;
942
943 case OPTION_NO_MULTI_TOC:
944 params.no_multi_toc = 1;
945 break;
946
947 case OPTION_NO_TOC_SORT:
948 no_toc_sort = 1;
949 break;
950
951 case OPTION_NON_OVERLAPPING_OPD:
952 params.non_overlapping_opd = 1;
953 break;
954
955 case OPTION_TRADITIONAL_FORMAT:
956 no_tls_opt = 1;
957 params.tls_get_addr_opt = 0;
958 no_opd_opt = 1;
959 no_toc_opt = 1;
960 params.no_multi_toc = 1;
961 no_toc_sort = 1;
962 params.plt_static_chain = 1;
963 return FALSE;
964 '
965
966 # Put these extra ppc64elf routines in ld_${EMULATION_NAME}_emulation
967 #
968 LDEMUL_NEW_VERS_PATTERN=gld${EMULATION_NAME}_new_vers_pattern
969 LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=ppc_create_output_section_statements
970 LDEMUL_AFTER_OPEN=ppc_after_open
971 LDEMUL_BEFORE_ALLOCATION=ppc_before_allocation
972 LDEMUL_AFTER_ALLOCATION=gld${EMULATION_NAME}_after_allocation
973 LDEMUL_FINISH=gld${EMULATION_NAME}_finish
This page took 0.07102 seconds and 4 git commands to generate.