1 # This shell script emits a C file. -*- C -*-
2 # Copyright 2003, 2004, 2005, 2006
3 # Free Software Foundation, Inc.
5 # This file is part of GLD, the Gnu Linker.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
22 # This file is sourced from elf32.em, and defines extra xtensa-elf
25 cat >>e${EMULATION_NAME}.c <<EOF
27 #include <xtensa-config.h>
28 #include "../bfd/elf-bfd.h"
29 #include "../bfd/libbfd.h"
30 #include "elf/xtensa.h"
33 static void xtensa_wild_group_interleave (lang_statement_union_type *);
34 static void xtensa_colocate_output_literals (lang_statement_union_type *);
35 static void xtensa_strip_inconsistent_linkonce_sections
36 (lang_statement_list_type *);
39 /* Flag for the emulation-specific "--no-relax" option. */
40 static bfd_boolean disable_relaxation = FALSE;
42 /* This number is irrelevant until we turn on use_literal_pages */
43 static bfd_vma xtensa_page_power = 12; /* 4K pages. */
45 /* To force a page break between literals and text, change
46 xtensa_use_literal_pages to "TRUE". */
47 static bfd_boolean xtensa_use_literal_pages = FALSE;
49 #define EXTRA_VALIDATION 0
53 elf_xtensa_choose_target (int argc ATTRIBUTE_UNUSED,
54 char **argv ATTRIBUTE_UNUSED)
57 return "${BIG_OUTPUT_FORMAT}";
59 return "${LITTLE_OUTPUT_FORMAT}";
64 elf_xtensa_before_parse (void)
66 /* Just call the default hook.... Tensilica's version of this function
67 does some other work that isn't relevant here. */
68 gld${EMULATION_NAME}_before_parse ();
73 remove_section (bfd *abfd, asection *os)
76 for (spp = &abfd->sections; *spp; spp = &(*spp)->next)
80 os->owner->section_count--;
87 replace_insn_sec_with_prop_sec (bfd *abfd,
88 const char *insn_sec_name,
89 const char *prop_sec_name,
94 bfd_byte *prop_contents = NULL;
95 bfd_byte *insn_contents = NULL;
98 Elf_Internal_Shdr *symtab_hdr;
99 Elf_Internal_Rela *internal_relocs = NULL;
100 unsigned reloc_count;
103 insn_sec = bfd_get_section_by_name (abfd, insn_sec_name);
104 if (insn_sec == NULL)
106 entry_count = insn_sec->size / 8;
108 prop_sec = bfd_get_section_by_name (abfd, prop_sec_name);
109 if (prop_sec != NULL && insn_sec != NULL)
111 *error_message = _("file already has property tables");
115 if (insn_sec->size != 0)
117 insn_contents = (bfd_byte *) bfd_malloc (insn_sec->size);
118 if (insn_contents == NULL)
120 *error_message = _("out of memory");
123 if (! bfd_get_section_contents (abfd, insn_sec, insn_contents,
124 (file_ptr) 0, insn_sec->size))
126 *error_message = _("failed to read section contents");
131 /* Create a Property table section and relocation section for it. */
132 prop_sec_name = strdup (prop_sec_name);
133 prop_sec = bfd_make_section (abfd, prop_sec_name);
135 || ! bfd_set_section_flags (abfd, prop_sec,
136 bfd_get_section_flags (abfd, insn_sec))
137 || ! bfd_set_section_alignment (abfd, prop_sec, 2))
139 *error_message = _("could not create new section");
143 if (! bfd_set_section_flags (abfd, prop_sec,
144 bfd_get_section_flags (abfd, insn_sec))
145 || ! bfd_set_section_alignment (abfd, prop_sec, 2))
147 *error_message = _("could not set new section properties");
150 prop_sec->size = entry_count * 12;
151 prop_contents = (bfd_byte *) bfd_zalloc (abfd, prop_sec->size);
152 elf_section_data (prop_sec)->this_hdr.contents = prop_contents;
154 /* The entry size and size must be set to allow the linker to compute
155 the number of relocations since it does not use reloc_count. */
156 elf_section_data (prop_sec)->rel_hdr.sh_entsize =
157 sizeof (Elf32_External_Rela);
158 elf_section_data (prop_sec)->rel_hdr.sh_size =
159 elf_section_data (insn_sec)->rel_hdr.sh_size;
161 if (prop_contents == NULL && prop_sec->size != 0)
163 *error_message = _("could not allocate section contents");
167 /* Read the relocations. */
168 reloc_count = insn_sec->reloc_count;
169 if (reloc_count != 0)
171 /* If there is already an internal_reloc, then save it so that the
172 read_relocs function freshly allocates a copy. */
173 Elf_Internal_Rela *saved_relocs = elf_section_data (insn_sec)->relocs;
175 elf_section_data (insn_sec)->relocs = NULL;
177 _bfd_elf_link_read_relocs (abfd, insn_sec, NULL, NULL, FALSE);
178 elf_section_data (insn_sec)->relocs = saved_relocs;
180 if (internal_relocs == NULL)
182 *error_message = _("out of memory");
187 /* Create a relocation section for the property section. */
188 if (internal_relocs != NULL)
190 elf_section_data (prop_sec)->relocs = internal_relocs;
191 prop_sec->reloc_count = reloc_count;
194 /* Now copy each insn table entry to the prop table entry with
195 appropriate flags. */
196 for (entry = 0; entry < entry_count; ++entry)
199 unsigned flags = (XTENSA_PROP_INSN | XTENSA_PROP_INSN_NO_TRANSFORM
200 | XTENSA_PROP_INSN_NO_REORDER);
201 value = bfd_get_32 (abfd, insn_contents + entry * 8 + 0);
202 bfd_put_32 (abfd, value, prop_contents + entry * 12 + 0);
203 value = bfd_get_32 (abfd, insn_contents + entry * 8 + 4);
204 bfd_put_32 (abfd, value, prop_contents + entry * 12 + 4);
205 bfd_put_32 (abfd, flags, prop_contents + entry * 12 + 8);
208 /* Now copy all of the relocations. Change offsets for the
209 instruction table section to offsets in the property table
214 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
216 for (i = 0; i < reloc_count; i++)
218 Elf_Internal_Rela *rela;
221 rela = &internal_relocs[i];
223 /* If this relocation is to the .xt.insn section,
224 change the section number and the offset. */
225 r_offset = rela->r_offset;
226 r_offset += 4 * (r_offset / 8);
227 rela->r_offset = r_offset;
231 remove_section (abfd, insn_sec);
234 free (insn_contents);
239 if (prop_sec && prop_sec->owner)
240 remove_section (abfd, prop_sec);
242 free (insn_contents);
244 free (internal_relocs);
250 #define PROP_SEC_BASE_NAME ".xt.prop"
251 #define INSN_SEC_BASE_NAME ".xt.insn"
252 #define LINKONCE_SEC_OLD_TEXT_BASE_NAME ".gnu.linkonce.x."
256 replace_instruction_table_sections (bfd *abfd, asection *sec)
259 const char *insn_sec_name = NULL;
260 char *prop_sec_name = NULL;
261 char *owned_prop_sec_name = NULL;
262 const char *sec_name;
264 sec_name = bfd_get_section_name (abfd, sec);
265 if (strcmp (sec_name, INSN_SEC_BASE_NAME) == 0)
267 insn_sec_name = INSN_SEC_BASE_NAME;
268 prop_sec_name = PROP_SEC_BASE_NAME;
270 else if (CONST_STRNEQ (sec_name, LINKONCE_SEC_OLD_TEXT_BASE_NAME))
272 insn_sec_name = sec_name;
273 owned_prop_sec_name = (char *) xmalloc (strlen (sec_name) + 20);
274 prop_sec_name = owned_prop_sec_name;
275 strcpy (prop_sec_name, ".gnu.linkonce.prop.t.");
276 strcat (prop_sec_name,
277 sec_name + strlen (LINKONCE_SEC_OLD_TEXT_BASE_NAME));
279 if (insn_sec_name != NULL)
281 if (! replace_insn_sec_with_prop_sec (abfd, insn_sec_name, prop_sec_name,
284 einfo (_("%P: warning: failed to convert %s table in %B (%s); subsequent disassembly may be incomplete\n"),
285 insn_sec_name, abfd, message);
288 if (owned_prop_sec_name)
289 free (owned_prop_sec_name);
293 /* This is called after all input sections have been opened to convert
294 instruction tables (.xt.insn, gnu.linkonce.x.*) tables into property
295 tables (.xt.prop) before any section placement. */
298 elf_xtensa_after_open (void)
302 /* First call the ELF version. */
303 gld${EMULATION_NAME}_after_open ();
305 /* Now search the input files looking for instruction table sections. */
306 for (abfd = link_info.input_bfds;
308 abfd = abfd->link_next)
310 asection *sec = abfd->sections;
313 /* Do not use bfd_map_over_sections here since we are removing
314 sections as we iterate. */
317 next_sec = sec->next;
318 replace_instruction_table_sections (abfd, sec);
325 /* This is called after the sections have been attached to output
326 sections, but before any sizes or addresses have been set. */
329 elf_xtensa_before_allocation (void)
332 bfd_boolean is_big_endian = XCHAL_HAVE_BE;
334 /* Check that the output endianness matches the Xtensa
335 configuration. The BFD library always includes both big and
336 little endian target vectors for Xtensa, but it only supports the
337 detailed instruction encode/decode operations (such as are
338 required to process relocations) for the selected Xtensa
341 if (is_big_endian && output_bfd->xvec->byteorder == BFD_ENDIAN_LITTLE)
343 einfo (_("%F%P: little endian output does not match "
344 "Xtensa configuration\n"));
346 if (!is_big_endian && output_bfd->xvec->byteorder == BFD_ENDIAN_BIG)
348 einfo (_("%F%P: big endian output does not match "
349 "Xtensa configuration\n"));
352 /* Check that the endianness for each input file matches the output.
353 The merge_private_bfd_data hook has already reported any mismatches
354 as errors, but those errors are not fatal. At this point, we
355 cannot go any further if there are any mismatches. */
357 for (in_bfd = link_info.input_bfds;
359 in_bfd = in_bfd->link_next)
361 if ((is_big_endian && in_bfd->xvec->byteorder == BFD_ENDIAN_LITTLE)
362 || (!is_big_endian && in_bfd->xvec->byteorder == BFD_ENDIAN_BIG))
363 einfo (_("%F%P: cross-endian linking not supported\n"));
366 /* Enable relaxation by default if the "--no-relax" option was not
367 specified. This is done here instead of in the before_parse hook
368 because there is a check in main() to prohibit use of --relax and
369 -r together and that combination should be allowed for Xtensa. */
371 if (!disable_relaxation)
372 command_line.relax = TRUE;
374 xtensa_strip_inconsistent_linkonce_sections (stat_ptr);
376 gld${EMULATION_NAME}_before_allocation ();
378 xtensa_wild_group_interleave (stat_ptr->head);
379 if (command_line.relax)
380 xtensa_colocate_output_literals (stat_ptr->head);
382 /* TBD: We need to force the page alignments to here and only do
383 them as needed for the entire output section. Finally, if this
384 is a relocatable link then we need to add alignment notes so
385 that the literals can be separated later. */
389 typedef struct wildcard_list section_name_list;
391 typedef struct reloc_deps_e_t reloc_deps_e;
392 typedef struct reloc_deps_section_t reloc_deps_section;
393 typedef struct reloc_deps_graph_t reloc_deps_graph;
396 struct reloc_deps_e_t
398 asection *src; /* Contains l32rs. */
399 asection *tgt; /* Contains literals. */
403 /* Place these in the userdata field. */
404 struct reloc_deps_section_t
408 bfd_boolean is_only_literal;
412 struct reloc_deps_graph_t
419 static void xtensa_layout_wild
420 (const reloc_deps_graph *, lang_wild_statement_type *);
422 typedef void (*deps_callback_t) (asection *, /* src_sec */
423 bfd_vma, /* src_offset */
424 asection *, /* target_sec */
425 bfd_vma, /* target_offset */
426 void *); /* closure */
428 extern bfd_boolean xtensa_callback_required_dependence
429 (bfd *, asection *, struct bfd_link_info *, deps_callback_t, void *);
430 static void xtensa_ldlang_clear_addresses (lang_statement_union_type *);
431 static bfd_boolean ld_local_file_relocations_fit
432 (lang_statement_union_type *, const reloc_deps_graph *);
433 static bfd_vma ld_assign_relative_paged_dot
434 (bfd_vma, lang_statement_union_type *, const reloc_deps_graph *,
436 static bfd_vma ld_xtensa_insert_page_offsets
437 (bfd_vma, lang_statement_union_type *, reloc_deps_graph *, bfd_boolean);
439 static size_t ld_count_children (lang_statement_union_type *);
442 extern lang_statement_list_type constructor_list;
444 /* Begin verbatim code from ldlang.c:
445 the following are copied from ldlang.c because they are defined
449 lang_for_each_statement_worker (void (*func) (lang_statement_union_type *),
450 lang_statement_union_type *s)
452 for (; s != (lang_statement_union_type *) NULL; s = s->header.next)
456 switch (s->header.type)
458 case lang_constructors_statement_enum:
459 lang_for_each_statement_worker (func, constructor_list.head);
461 case lang_output_section_statement_enum:
462 lang_for_each_statement_worker
464 s->output_section_statement.children.head);
466 case lang_wild_statement_enum:
467 lang_for_each_statement_worker
469 s->wild_statement.children.head);
471 case lang_group_statement_enum:
472 lang_for_each_statement_worker (func,
473 s->group_statement.children.head);
475 case lang_data_statement_enum:
476 case lang_reloc_statement_enum:
477 case lang_object_symbols_statement_enum:
478 case lang_output_statement_enum:
479 case lang_target_statement_enum:
480 case lang_input_section_enum:
481 case lang_input_statement_enum:
482 case lang_assignment_statement_enum:
483 case lang_padding_statement_enum:
484 case lang_address_statement_enum:
485 case lang_fill_statement_enum:
494 /* End of verbatim code from ldlang.c. */
497 static reloc_deps_section *
498 xtensa_get_section_deps (const reloc_deps_graph *deps ATTRIBUTE_UNUSED,
501 /* We have a separate function for this so that
502 we could in the future keep a completely independent
503 structure that maps a section to its dependence edges.
504 For now, we place these in the sec->userdata field. */
505 reloc_deps_section *sec_deps = sec->userdata;
510 xtensa_set_section_deps (const reloc_deps_graph *deps ATTRIBUTE_UNUSED,
512 reloc_deps_section *deps_section)
514 sec->userdata = deps_section;
518 /* This is used to keep a list of all of the sections participating in
519 the graph so we can clean them up quickly. */
522 xtensa_append_section_deps (reloc_deps_graph *deps, asection *sec)
524 if (deps->size <= deps->count)
526 asection **new_sections;
530 new_size = deps->size * 2;
534 new_sections = xmalloc (sizeof (asection *) * new_size);
535 memset (new_sections, 0, sizeof (asection *) * new_size);
536 for (i = 0; i < deps->count; i++)
538 new_sections[i] = deps->sections[i];
540 if (deps->sections != NULL)
541 free (deps->sections);
542 deps->sections = new_sections;
543 deps->size = new_size;
545 deps->sections[deps->count] = sec;
551 free_reloc_deps_graph (reloc_deps_graph *deps)
554 for (i = 0; i < deps->count; i++)
556 asection *sec = deps->sections[i];
557 reloc_deps_section *sec_deps;
558 sec_deps = xtensa_get_section_deps (deps, sec);
562 while (sec_deps->succs != NULL)
564 next = sec_deps->succs->next;
565 free (sec_deps->succs);
566 sec_deps->succs = next;
569 while (sec_deps->preds != NULL)
571 next = sec_deps->preds->next;
572 free (sec_deps->preds);
573 sec_deps->preds = next;
577 xtensa_set_section_deps (deps, sec, NULL);
580 free (deps->sections);
587 section_is_source (const reloc_deps_graph *deps ATTRIBUTE_UNUSED,
588 lang_statement_union_type *s)
591 const reloc_deps_section *sec_deps;
593 if (s->header.type != lang_input_section_enum)
595 sec = s->input_section.section;
597 sec_deps = xtensa_get_section_deps (deps, sec);
598 return sec_deps && sec_deps->succs != NULL;
603 section_is_target (const reloc_deps_graph *deps ATTRIBUTE_UNUSED,
604 lang_statement_union_type *s)
607 const reloc_deps_section *sec_deps;
609 if (s->header.type != lang_input_section_enum)
611 sec = s->input_section.section;
613 sec_deps = xtensa_get_section_deps (deps, sec);
614 return sec_deps && sec_deps->preds != NULL;
619 section_is_source_or_target (const reloc_deps_graph *deps ATTRIBUTE_UNUSED,
620 lang_statement_union_type *s)
622 return (section_is_source (deps, s)
623 || section_is_target (deps, s));
627 typedef struct xtensa_ld_iter_stack_t xtensa_ld_iter_stack;
628 typedef struct xtensa_ld_iter_t xtensa_ld_iter;
630 struct xtensa_ld_iter_t
632 lang_statement_union_type *parent; /* Parent of the list. */
633 lang_statement_list_type *l; /* List that holds it. */
634 lang_statement_union_type **loc; /* Place in the list. */
637 struct xtensa_ld_iter_stack_t
639 xtensa_ld_iter iterloc; /* List that hold it. */
641 xtensa_ld_iter_stack *next; /* Next in the stack. */
642 xtensa_ld_iter_stack *prev; /* Back pointer for stack. */
647 ld_xtensa_move_section_after (xtensa_ld_iter *to, xtensa_ld_iter *current)
649 lang_statement_union_type *to_next;
650 lang_statement_union_type *current_next;
651 lang_statement_union_type **e;
654 size_t old_to_count, new_to_count;
655 size_t old_current_count, new_current_count;
662 old_to_count = ld_count_children (to->parent);
663 old_current_count = ld_count_children (current->parent);
666 to_next = *(to->loc);
667 current_next = (*current->loc)->header.next;
669 *(to->loc) = *(current->loc);
671 *(current->loc) = current_next;
672 (*(to->loc))->header.next = to_next;
674 /* reset "to" list tail */
675 for (e = &to->l->head; *e != NULL; e = &(*e)->header.next)
679 /* reset "current" list tail */
680 for (e = ¤t->l->head; *e != NULL; e = &(*e)->header.next)
682 current->l->tail = e;
685 new_to_count = ld_count_children (to->parent);
686 new_current_count = ld_count_children (current->parent);
688 ASSERT ((old_to_count + old_current_count)
689 == (new_to_count + new_current_count));
694 /* Can only be called with lang_statements that have lists. Returns
695 FALSE if the list is empty. */
698 iter_stack_empty (xtensa_ld_iter_stack **stack_p)
700 return *stack_p == NULL;
705 iter_stack_push (xtensa_ld_iter_stack **stack_p,
706 lang_statement_union_type *parent)
708 xtensa_ld_iter_stack *stack;
709 lang_statement_list_type *l = NULL;
711 switch (parent->header.type)
713 case lang_output_section_statement_enum:
714 l = &parent->output_section_statement.children;
716 case lang_wild_statement_enum:
717 l = &parent->wild_statement.children;
719 case lang_group_statement_enum:
720 l = &parent->group_statement.children;
727 /* Empty. do not push. */
728 if (l->tail == &l->head)
731 stack = xmalloc (sizeof (xtensa_ld_iter_stack));
732 memset (stack, 0, sizeof (xtensa_ld_iter_stack));
733 stack->iterloc.parent = parent;
734 stack->iterloc.l = l;
735 stack->iterloc.loc = &l->head;
737 stack->next = *stack_p;
739 if (*stack_p != NULL)
740 (*stack_p)->prev = stack;
747 iter_stack_pop (xtensa_ld_iter_stack **stack_p)
749 xtensa_ld_iter_stack *stack;
755 ASSERT (stack != NULL);
759 if (stack->next != NULL)
760 stack->next->prev = NULL;
762 *stack_p = stack->next;
767 /* This MUST be called if, during iteration, the user changes the
768 underlying structure. It will check for a NULL current and advance
772 iter_stack_update (xtensa_ld_iter_stack **stack_p)
774 if (!iter_stack_empty (stack_p)
775 && (*(*stack_p)->iterloc.loc) == NULL)
777 iter_stack_pop (stack_p);
779 while (!iter_stack_empty (stack_p)
780 && ((*(*stack_p)->iterloc.loc)->header.next == NULL))
782 iter_stack_pop (stack_p);
784 if (!iter_stack_empty (stack_p))
785 (*stack_p)->iterloc.loc = &(*(*stack_p)->iterloc.loc)->header.next;
791 iter_stack_next (xtensa_ld_iter_stack **stack_p)
793 xtensa_ld_iter_stack *stack;
794 lang_statement_union_type *current;
797 current = *stack->iterloc.loc;
798 /* If we are on the first element. */
801 switch (current->header.type)
803 case lang_output_section_statement_enum:
804 case lang_wild_statement_enum:
805 case lang_group_statement_enum:
806 /* If the list if not empty, we are done. */
807 if (iter_stack_push (stack_p, *stack->iterloc.loc))
809 /* Otherwise increment the pointer as normal. */
816 while (!iter_stack_empty (stack_p)
817 && ((*(*stack_p)->iterloc.loc)->header.next == NULL))
819 iter_stack_pop (stack_p);
821 if (!iter_stack_empty (stack_p))
822 (*stack_p)->iterloc.loc = &(*(*stack_p)->iterloc.loc)->header.next;
826 static lang_statement_union_type *
827 iter_stack_current (xtensa_ld_iter_stack **stack_p)
829 return *((*stack_p)->iterloc.loc);
833 /* The iter stack is a preorder. */
836 iter_stack_create (xtensa_ld_iter_stack **stack_p,
837 lang_statement_union_type *parent)
839 iter_stack_push (stack_p, parent);
844 iter_stack_copy_current (xtensa_ld_iter_stack **stack_p, xtensa_ld_iter *front)
846 *front = (*stack_p)->iterloc;
851 xtensa_colocate_literals (reloc_deps_graph *deps,
852 lang_statement_union_type *statement)
854 /* Keep a stack of pointers to control iteration through the contours. */
855 xtensa_ld_iter_stack *stack = NULL;
856 xtensa_ld_iter_stack **stack_p = &stack;
858 xtensa_ld_iter front; /* Location where new insertion should occur. */
859 xtensa_ld_iter *front_p = NULL;
861 xtensa_ld_iter current; /* Location we are checking. */
862 xtensa_ld_iter *current_p = NULL;
863 bfd_boolean in_literals = FALSE;
865 if (deps->count == 0)
868 iter_stack_create (stack_p, statement);
870 while (!iter_stack_empty (stack_p))
872 bfd_boolean skip_increment = FALSE;
873 lang_statement_union_type *l = iter_stack_current (stack_p);
875 switch (l->header.type)
877 case lang_assignment_statement_enum:
878 /* Any assignment statement should block reordering across it. */
883 case lang_input_section_enum:
886 in_literals = (section_is_target (deps, l)
887 && !section_is_source (deps, l));
891 iter_stack_copy_current (stack_p, front_p);
896 bfd_boolean is_target;
897 current_p = ¤t;
898 iter_stack_copy_current (stack_p, current_p);
899 is_target = (section_is_target (deps, l)
900 && !section_is_source (deps, l));
904 iter_stack_copy_current (stack_p, front_p);
912 /* Try to insert in place. */
913 ld_xtensa_move_section_after (front_p, current_p);
914 ld_assign_relative_paged_dot (0x100000,
917 xtensa_use_literal_pages);
919 /* We use this code because it's already written. */
920 if (!ld_local_file_relocations_fit (statement, deps))
923 ld_xtensa_move_section_after (current_p, front_p);
924 /* Reset the literal placement. */
925 iter_stack_copy_current (stack_p, front_p);
929 /* Move front pointer up by one. */
930 front_p->loc = &(*front_p->loc)->header.next;
932 /* Do not increment the current pointer. */
933 skip_increment = TRUE;
944 iter_stack_next (stack_p);
946 /* Be careful to update the stack_p if it now is a null. */
947 iter_stack_update (stack_p);
950 lang_for_each_statement_worker (xtensa_ldlang_clear_addresses, statement);
955 xtensa_move_dependencies_to_front (reloc_deps_graph *deps,
956 lang_wild_statement_type *w)
958 /* Keep a front pointer and a current pointer. */
959 lang_statement_union_type **front;
960 lang_statement_union_type **current;
962 /* Walk to the end of the targets. */
963 for (front = &w->children.head;
964 (*front != NULL) && section_is_source_or_target (deps, *front);
965 front = &(*front)->header.next)
971 current = &(*front)->header.next;
972 while (*current != NULL)
974 if (section_is_source_or_target (deps, *current))
976 /* Insert in place. */
977 xtensa_ld_iter front_iter;
978 xtensa_ld_iter current_iter;
980 front_iter.parent = (lang_statement_union_type *) w;
981 front_iter.l = &w->children;
982 front_iter.loc = front;
984 current_iter.parent = (lang_statement_union_type *) w;
985 current_iter.l = &w->children;
986 current_iter.loc = current;
988 ld_xtensa_move_section_after (&front_iter, ¤t_iter);
989 front = &(*front)->header.next;
993 current = &(*current)->header.next;
1000 deps_has_sec_edge (const reloc_deps_graph *deps, asection *src, asection *tgt)
1002 const reloc_deps_section *sec_deps;
1003 const reloc_deps_e *sec_deps_e;
1005 sec_deps = xtensa_get_section_deps (deps, src);
1006 if (sec_deps == NULL)
1009 for (sec_deps_e = sec_deps->succs;
1011 sec_deps_e = sec_deps_e->next)
1013 ASSERT (sec_deps_e->src == src);
1014 if (sec_deps_e->tgt == tgt)
1022 deps_has_edge (const reloc_deps_graph *deps,
1023 lang_statement_union_type *src,
1024 lang_statement_union_type *tgt)
1026 if (!section_is_source (deps, src))
1028 if (!section_is_target (deps, tgt))
1031 if (src->header.type != lang_input_section_enum)
1033 if (tgt->header.type != lang_input_section_enum)
1036 return deps_has_sec_edge (deps, src->input_section.section,
1037 tgt->input_section.section);
1042 add_deps_edge (reloc_deps_graph *deps, asection *src_sec, asection *tgt_sec)
1044 reloc_deps_section *src_sec_deps;
1045 reloc_deps_section *tgt_sec_deps;
1047 reloc_deps_e *src_edge;
1048 reloc_deps_e *tgt_edge;
1050 if (deps_has_sec_edge (deps, src_sec, tgt_sec))
1053 src_sec_deps = xtensa_get_section_deps (deps, src_sec);
1054 if (src_sec_deps == NULL)
1056 /* Add a section. */
1057 src_sec_deps = xmalloc (sizeof (reloc_deps_section));
1058 memset (src_sec_deps, 0, sizeof (reloc_deps_section));
1059 src_sec_deps->is_only_literal = 0;
1060 src_sec_deps->preds = NULL;
1061 src_sec_deps->succs = NULL;
1062 xtensa_set_section_deps (deps, src_sec, src_sec_deps);
1063 xtensa_append_section_deps (deps, src_sec);
1066 tgt_sec_deps = xtensa_get_section_deps (deps, tgt_sec);
1067 if (tgt_sec_deps == NULL)
1069 /* Add a section. */
1070 tgt_sec_deps = xmalloc (sizeof (reloc_deps_section));
1071 memset (tgt_sec_deps, 0, sizeof (reloc_deps_section));
1072 tgt_sec_deps->is_only_literal = 0;
1073 tgt_sec_deps->preds = NULL;
1074 tgt_sec_deps->succs = NULL;
1075 xtensa_set_section_deps (deps, tgt_sec, tgt_sec_deps);
1076 xtensa_append_section_deps (deps, tgt_sec);
1079 /* Add the edges. */
1080 src_edge = xmalloc (sizeof (reloc_deps_e));
1081 memset (src_edge, 0, sizeof (reloc_deps_e));
1082 src_edge->src = src_sec;
1083 src_edge->tgt = tgt_sec;
1084 src_edge->next = src_sec_deps->succs;
1085 src_sec_deps->succs = src_edge;
1087 tgt_edge = xmalloc (sizeof (reloc_deps_e));
1088 memset (tgt_edge, 0, sizeof (reloc_deps_e));
1089 tgt_edge->src = src_sec;
1090 tgt_edge->tgt = tgt_sec;
1091 tgt_edge->next = tgt_sec_deps->preds;
1092 tgt_sec_deps->preds = tgt_edge;
1097 build_deps_graph_callback (asection *src_sec,
1098 bfd_vma src_offset ATTRIBUTE_UNUSED,
1099 asection *target_sec,
1100 bfd_vma target_offset ATTRIBUTE_UNUSED,
1103 reloc_deps_graph *deps = closure;
1105 /* If the target is defined. */
1106 if (target_sec != NULL)
1107 add_deps_edge (deps, src_sec, target_sec);
1111 static reloc_deps_graph *
1112 ld_build_required_section_dependence (lang_statement_union_type *s)
1114 reloc_deps_graph *deps;
1115 xtensa_ld_iter_stack *stack = NULL;
1117 deps = xmalloc (sizeof (reloc_deps_graph));
1118 deps->sections = NULL;
1122 for (iter_stack_create (&stack, s);
1123 !iter_stack_empty (&stack);
1124 iter_stack_next (&stack))
1126 lang_statement_union_type *l = iter_stack_current (&stack);
1128 if (l->header.type == lang_input_section_enum)
1130 lang_input_section_type *input;
1131 input = &l->input_section;
1132 xtensa_callback_required_dependence (input->section->owner,
1135 /* Use the same closure. */
1136 build_deps_graph_callback,
1144 #if EXTRA_VALIDATION
1146 ld_count_children (lang_statement_union_type *s)
1149 xtensa_ld_iter_stack *stack = NULL;
1150 for (iter_stack_create (&stack, s);
1151 !iter_stack_empty (&stack);
1152 iter_stack_next (&stack))
1154 lang_statement_union_type *l = iter_stack_current (&stack);
1160 #endif /* EXTRA_VALIDATION */
1163 /* Check if a particular section is included in the link. This will only
1164 be true for one instance of a particular linkonce section. */
1166 static bfd_boolean input_section_found = FALSE;
1167 static asection *input_section_target = NULL;
1170 input_section_linked_worker (lang_statement_union_type *statement)
1172 if ((statement->header.type == lang_input_section_enum
1173 && (statement->input_section.section == input_section_target)))
1174 input_section_found = TRUE;
1178 input_section_linked (asection *sec)
1180 input_section_found = FALSE;
1181 input_section_target = sec;
1182 lang_for_each_statement_worker (input_section_linked_worker, stat_ptr->head);
1183 return input_section_found;
1187 /* Strip out any linkonce literal sections or property tables where the
1188 associated linkonce text is from a different object file. Normally,
1189 a matching set of linkonce sections is taken from the same object file,
1190 but sometimes the files are compiled differently so that some of the
1191 linkonce sections are not present in all files. Stripping the
1192 inconsistent sections like this is not completely robust -- a much
1193 better solution is to use comdat groups. */
1195 static int linkonce_len = sizeof (".gnu.linkonce.") - 1;
1198 is_inconsistent_linkonce_section (asection *sec)
1200 bfd *abfd = sec->owner;
1201 const char *sec_name = bfd_get_section_name (abfd, sec);
1202 const char *name = 0;
1204 if ((bfd_get_section_flags (abfd, sec) & SEC_LINK_ONCE) == 0
1205 || strncmp (sec_name, ".gnu.linkonce.", linkonce_len) != 0)
1208 /* Check if this is an Xtensa property section. */
1209 if (CONST_STRNEQ (sec_name + linkonce_len, "p."))
1210 name = sec_name + linkonce_len + 2;
1211 else if (CONST_STRNEQ (sec_name + linkonce_len, "prop."))
1212 name = strchr (sec_name + linkonce_len + 5, '.') + 1;
1216 char *dep_sec_name = xmalloc (strlen (sec_name) + 1);
1219 /* Get the associated linkonce text section and check if it is
1220 included in the link. If not, this section is inconsistent
1221 and should be stripped. */
1222 strcpy (dep_sec_name, ".gnu.linkonce.t.");
1223 strcat (dep_sec_name, name);
1224 dep_sec = bfd_get_section_by_name (abfd, dep_sec_name);
1225 if (dep_sec == NULL || ! input_section_linked (dep_sec))
1227 free (dep_sec_name);
1230 free (dep_sec_name);
1238 xtensa_strip_inconsistent_linkonce_sections (lang_statement_list_type *slist)
1240 lang_statement_union_type **s_p = &slist->head;
1243 lang_statement_union_type *s = *s_p;
1244 lang_statement_union_type *s_next = (*s_p)->header.next;
1246 switch (s->header.type)
1248 case lang_input_section_enum:
1249 if (is_inconsistent_linkonce_section (s->input_section.section))
1251 s->input_section.section->output_section = bfd_abs_section_ptr;
1257 case lang_constructors_statement_enum:
1258 xtensa_strip_inconsistent_linkonce_sections (&constructor_list);
1261 case lang_output_section_statement_enum:
1262 if (s->output_section_statement.children.head)
1263 xtensa_strip_inconsistent_linkonce_sections
1264 (&s->output_section_statement.children);
1267 case lang_wild_statement_enum:
1268 xtensa_strip_inconsistent_linkonce_sections
1269 (&s->wild_statement.children);
1272 case lang_group_statement_enum:
1273 xtensa_strip_inconsistent_linkonce_sections
1274 (&s->group_statement.children);
1277 case lang_data_statement_enum:
1278 case lang_reloc_statement_enum:
1279 case lang_object_symbols_statement_enum:
1280 case lang_output_statement_enum:
1281 case lang_target_statement_enum:
1282 case lang_input_statement_enum:
1283 case lang_assignment_statement_enum:
1284 case lang_padding_statement_enum:
1285 case lang_address_statement_enum:
1286 case lang_fill_statement_enum:
1294 s_p = &(*s_p)->header.next;
1297 /* Reset the tail of the list, in case the last entry was removed. */
1298 if (s_p != slist->tail)
1304 xtensa_wild_group_interleave_callback (lang_statement_union_type *statement)
1306 lang_wild_statement_type *w;
1307 reloc_deps_graph *deps;
1308 if (statement->header.type == lang_wild_statement_enum)
1310 #if EXTRA_VALIDATION
1311 size_t old_child_count;
1312 size_t new_child_count;
1314 bfd_boolean no_reorder;
1316 w = &statement->wild_statement;
1320 /* If it has 0 or 1 section bound, then do not reorder. */
1321 if (w->children.head == NULL
1322 || (w->children.head->header.type == lang_input_section_enum
1323 && w->children.head->header.next == NULL))
1326 if (w->filenames_sorted)
1329 /* Check for sorting in a section list wildcard spec as well. */
1332 struct wildcard_list *l;
1333 for (l = w->section_list; l != NULL; l = l->next)
1335 if (l->spec.sorted == TRUE)
1343 /* Special case until the NOREORDER linker directive is supported:
1344 *(.init) output sections and *(.fini) specs may NOT be reordered. */
1346 /* Check for sorting in a section list wildcard spec as well. */
1349 struct wildcard_list *l;
1350 for (l = w->section_list; l != NULL; l = l->next)
1353 && ((strcmp (".init", l->spec.name) == 0)
1354 || (strcmp (".fini", l->spec.name) == 0)))
1362 #if EXTRA_VALIDATION
1363 old_child_count = ld_count_children (statement);
1366 /* It is now officially a target. Build the graph of source
1367 section -> target section (kept as a list of edges). */
1368 deps = ld_build_required_section_dependence (statement);
1370 /* If this wildcard does not reorder.... */
1371 if (!no_reorder && deps->count != 0)
1373 /* First check for reverse dependences. Fix if possible. */
1374 xtensa_layout_wild (deps, w);
1376 xtensa_move_dependencies_to_front (deps, w);
1377 #if EXTRA_VALIDATION
1378 new_child_count = ld_count_children (statement);
1379 ASSERT (new_child_count == old_child_count);
1382 xtensa_colocate_literals (deps, statement);
1384 #if EXTRA_VALIDATION
1385 new_child_count = ld_count_children (statement);
1386 ASSERT (new_child_count == old_child_count);
1391 free_reloc_deps_graph (deps);
1397 xtensa_wild_group_interleave (lang_statement_union_type *s)
1399 lang_for_each_statement_worker (xtensa_wild_group_interleave_callback, s);
1404 xtensa_layout_wild (const reloc_deps_graph *deps, lang_wild_statement_type *w)
1406 /* If it does not fit initially, we need to do this step. Move all
1407 of the wild literal sections to a new list, then move each of
1408 them back in just before the first section they depend on. */
1409 lang_statement_union_type **s_p;
1410 #if EXTRA_VALIDATION
1411 size_t old_count, new_count;
1415 lang_wild_statement_type literal_wild;
1416 literal_wild.header.next = NULL;
1417 literal_wild.header.type = lang_wild_statement_enum;
1418 literal_wild.filename = NULL;
1419 literal_wild.filenames_sorted = FALSE;
1420 literal_wild.section_list = NULL;
1421 literal_wild.keep_sections = FALSE;
1422 literal_wild.children.head = NULL;
1423 literal_wild.children.tail = &literal_wild.children.head;
1425 #if EXTRA_VALIDATION
1426 old_count = ld_count_children ((lang_statement_union_type*) w);
1429 s_p = &w->children.head;
1430 while (*s_p != NULL)
1432 lang_statement_union_type *l = *s_p;
1433 if (l->header.type == lang_input_section_enum)
1435 if (section_is_target (deps, l)
1436 && ! section_is_source (deps, l))
1439 *s_p = l->header.next;
1441 w->children.tail = s_p;
1442 l->header.next = NULL;
1445 *literal_wild.children.tail = l;
1446 literal_wild.children.tail = &l->header.next;
1450 s_p = &(*s_p)->header.next;
1453 #if EXTRA_VALIDATION
1454 ct1 = ld_count_children ((lang_statement_union_type*) w);
1455 ct2 = ld_count_children ((lang_statement_union_type*) &literal_wild);
1457 ASSERT (old_count == (ct1 + ct2));
1460 /* Now place them back in front of their dependent sections. */
1462 while (literal_wild.children.head != NULL)
1464 lang_statement_union_type *lit = literal_wild.children.head;
1465 bfd_boolean placed = FALSE;
1467 #if EXTRA_VALIDATION
1473 literal_wild.children.head = lit->header.next;
1474 if (literal_wild.children.head == NULL)
1475 literal_wild.children.tail = &literal_wild.children.head;
1476 lit->header.next = NULL;
1478 /* Find a spot to place it. */
1479 for (s_p = &w->children.head; *s_p != NULL; s_p = &(*s_p)->header.next)
1481 lang_statement_union_type *src = *s_p;
1482 if (deps_has_edge (deps, src, lit))
1484 /* Place it here. */
1485 lit->header.next = *s_p;
1494 /* Put it at the end. */
1495 *w->children.tail = lit;
1496 w->children.tail = &lit->header.next;
1500 #if EXTRA_VALIDATION
1501 new_count = ld_count_children ((lang_statement_union_type*) w);
1502 ASSERT (new_count == old_count);
1508 xtensa_colocate_output_literals_callback (lang_statement_union_type *statement)
1510 lang_output_section_statement_type *os;
1511 reloc_deps_graph *deps;
1512 if (statement->header.type == lang_output_section_statement_enum)
1514 /* Now, we walk over the contours of the output section statement.
1516 First we build the literal section dependences as before.
1518 At the first uniquely_literal section, we mark it as a good
1519 spot to place other literals. Continue walking (and counting
1520 sizes) until we find the next literal section. If this
1521 section can be moved to the first one, then we move it. If
1522 we every find a modification of ".", start over. If we find
1523 a labeling of the current location, start over. Finally, at
1524 the end, if we require page alignment, add page alignments. */
1526 #if EXTRA_VALIDATION
1527 size_t old_child_count;
1528 size_t new_child_count;
1530 bfd_boolean no_reorder = FALSE;
1532 os = &statement->output_section_statement;
1534 #if EXTRA_VALIDATION
1535 old_child_count = ld_count_children (statement);
1538 /* It is now officially a target. Build the graph of source
1539 section -> target section (kept as a list of edges). */
1541 deps = ld_build_required_section_dependence (statement);
1543 /* If this wildcard does not reorder.... */
1546 /* First check for reverse dependences. Fix if possible. */
1547 xtensa_colocate_literals (deps, statement);
1549 #if EXTRA_VALIDATION
1550 new_child_count = ld_count_children (statement);
1551 ASSERT (new_child_count == old_child_count);
1555 /* Insert align/offset assignment statement. */
1556 if (xtensa_use_literal_pages)
1558 ld_xtensa_insert_page_offsets (0, statement, deps,
1559 xtensa_use_literal_pages);
1560 lang_for_each_statement_worker (xtensa_ldlang_clear_addresses,
1565 free_reloc_deps_graph (deps);
1571 xtensa_colocate_output_literals (lang_statement_union_type *s)
1573 lang_for_each_statement_worker (xtensa_colocate_output_literals_callback, s);
1578 xtensa_ldlang_clear_addresses (lang_statement_union_type *statement)
1580 switch (statement->header.type)
1582 case lang_input_section_enum:
1584 asection *bfd_section = statement->input_section.section;
1585 bfd_section->output_offset = 0;
1595 ld_assign_relative_paged_dot (bfd_vma dot,
1596 lang_statement_union_type *s,
1597 const reloc_deps_graph *deps ATTRIBUTE_UNUSED,
1598 bfd_boolean lit_align)
1600 /* Walk through all of the input statements in this wild statement
1601 assign dot to all of them. */
1603 xtensa_ld_iter_stack *stack = NULL;
1604 xtensa_ld_iter_stack **stack_p = &stack;
1606 bfd_boolean first_section = FALSE;
1607 bfd_boolean in_literals = FALSE;
1609 for (iter_stack_create (stack_p, s);
1610 !iter_stack_empty (stack_p);
1611 iter_stack_next (stack_p))
1613 lang_statement_union_type *l = iter_stack_current (stack_p);
1615 switch (l->header.type)
1617 case lang_input_section_enum:
1619 asection *section = l->input_section.section;
1620 size_t align_pow = section->alignment_power;
1621 bfd_boolean do_xtensa_alignment = FALSE;
1625 bfd_boolean sec_is_target = section_is_target (deps, l);
1626 bfd_boolean sec_is_source = section_is_source (deps, l);
1628 if (section->size != 0
1630 || (in_literals && !sec_is_target)
1631 || (!in_literals && sec_is_target)))
1633 do_xtensa_alignment = TRUE;
1635 first_section = FALSE;
1636 if (section->size != 0)
1637 in_literals = (sec_is_target && !sec_is_source);
1640 if (do_xtensa_alignment && xtensa_page_power != 0)
1641 dot += (1 << xtensa_page_power);
1643 dot = align_power (dot, align_pow);
1644 section->output_offset = dot;
1645 dot += section->size;
1648 case lang_fill_statement_enum:
1649 dot += l->fill_statement.size;
1651 case lang_padding_statement_enum:
1652 dot += l->padding_statement.size;
1663 ld_local_file_relocations_fit (lang_statement_union_type *statement,
1664 const reloc_deps_graph *deps ATTRIBUTE_UNUSED)
1666 /* Walk over all of the dependencies that we identified and make
1667 sure that IF the source and target are here (addr != 0):
1668 1) target addr < source addr
1669 2) (roundup(source + source_size, 4) - rounddown(target, 4))
1670 < (256K - (1 << bad align))
1671 Need a worst-case proof.... */
1673 xtensa_ld_iter_stack *stack = NULL;
1674 xtensa_ld_iter_stack **stack_p = &stack;
1675 size_t max_align_power = 0;
1676 size_t align_penalty = 256;
1680 /* Find the worst-case alignment requirement for this set of statements. */
1681 for (iter_stack_create (stack_p, statement);
1682 !iter_stack_empty (stack_p);
1683 iter_stack_next (stack_p))
1685 lang_statement_union_type *l = iter_stack_current (stack_p);
1686 if (l->header.type == lang_input_section_enum)
1688 lang_input_section_type *input = &l->input_section;
1689 asection *section = input->section;
1690 if (section->alignment_power > max_align_power)
1691 max_align_power = section->alignment_power;
1695 /* Now check that everything fits. */
1696 for (i = 0; i < deps->count; i++)
1698 asection *sec = deps->sections[i];
1699 const reloc_deps_section *deps_section =
1700 xtensa_get_section_deps (deps, sec);
1703 /* We choose to walk through the successors. */
1704 for (e = deps_section->succs; e != NULL; e = e->next)
1706 if (e->src != e->tgt
1707 && e->src->output_section == e->tgt->output_section
1708 && e->src->output_offset != 0
1709 && e->tgt->output_offset != 0)
1712 align_power (e->src->output_offset + e->src->size, 2);
1713 bfd_vma target_addr = e->tgt->output_offset & ~3;
1714 if (l32r_addr < target_addr)
1716 fprintf (stderr, "Warning: "
1717 "l32r target section before l32r\n");
1721 if (l32r_addr - target_addr > 256 * 1024 - align_penalty)
1733 ld_xtensa_insert_page_offsets (bfd_vma dot,
1734 lang_statement_union_type *s,
1735 reloc_deps_graph *deps,
1736 bfd_boolean lit_align)
1738 xtensa_ld_iter_stack *stack = NULL;
1739 xtensa_ld_iter_stack **stack_p = &stack;
1741 bfd_boolean first_section = FALSE;
1742 bfd_boolean in_literals = FALSE;
1747 for (iter_stack_create (stack_p, s);
1748 !iter_stack_empty (stack_p);
1749 iter_stack_next (stack_p))
1751 lang_statement_union_type *l = iter_stack_current (stack_p);
1753 switch (l->header.type)
1755 case lang_input_section_enum:
1757 asection *section = l->input_section.section;
1758 bfd_boolean do_xtensa_alignment = FALSE;
1762 if (section->size != 0
1764 || (in_literals && !section_is_target (deps, l))
1765 || (!in_literals && section_is_target (deps, l))))
1767 do_xtensa_alignment = TRUE;
1769 first_section = FALSE;
1770 if (section->size != 0)
1772 in_literals = (section_is_target (deps, l)
1773 && !section_is_source (deps, l));
1777 if (do_xtensa_alignment && xtensa_page_power != 0)
1779 /* Create an expression that increments the current address,
1780 i.e., "dot", by (1 << xtensa_align_power). */
1781 etree_type *name_op = exp_nameop (NAME, ".");
1782 etree_type *addend_op = exp_intop (1 << xtensa_page_power);
1783 etree_type *add_op = exp_binop ('+', name_op, addend_op);
1784 etree_type *assign_op = exp_assop ('=', ".", add_op);
1786 lang_assignment_statement_type *assign_stmt;
1787 lang_statement_union_type *assign_union;
1788 lang_statement_list_type tmplist;
1789 lang_statement_list_type *old_stat_ptr = stat_ptr;
1791 /* There is hidden state in "lang_add_assignment". It
1792 appends the new assignment statement to the stat_ptr
1793 list. Thus, we swap it before and after the call. */
1795 tmplist.head = NULL;
1796 tmplist.tail = &tmplist.head;
1798 stat_ptr = &tmplist;
1799 /* Warning: side effect; statement appended to stat_ptr. */
1800 assign_stmt = lang_add_assignment (assign_op);
1801 assign_union = (lang_statement_union_type *) assign_stmt;
1802 stat_ptr = old_stat_ptr;
1804 assign_union->header.next = l;
1805 *(*stack_p)->iterloc.loc = assign_union;
1806 iter_stack_next (stack_p);
1819 # Define some shell vars to insert bits of code into the standard ELF
1820 # parse_args and list_options functions.
1822 PARSE_AND_LIST_PROLOGUE='
1823 #define OPTION_OPT_SIZEOPT (300)
1824 #define OPTION_NO_RELAX (OPTION_OPT_SIZEOPT + 1)
1825 #define OPTION_LITERAL_MOVEMENT (OPTION_NO_RELAX + 1)
1826 #define OPTION_NO_LITERAL_MOVEMENT (OPTION_LITERAL_MOVEMENT + 1)
1827 extern int elf32xtensa_size_opt;
1828 extern int elf32xtensa_no_literal_movement;
1831 PARSE_AND_LIST_LONGOPTS='
1832 { "size-opt", no_argument, NULL, OPTION_OPT_SIZEOPT},
1833 { "no-relax", no_argument, NULL, OPTION_NO_RELAX},
1834 { "literal-movement", no_argument, NULL, OPTION_LITERAL_MOVEMENT},
1835 { "no-literal-movement", no_argument, NULL, OPTION_NO_LITERAL_MOVEMENT},
1838 PARSE_AND_LIST_OPTIONS='
1839 fprintf (file, _(" --size-opt\t\tWhen relaxing longcalls, prefer size optimization\n\t\t\t over branch target alignment\n"));
1840 fprintf (file, _(" --no-relax\t\tDo not relax branches or coalesce literals\n"));
1843 PARSE_AND_LIST_ARGS_CASES='
1844 case OPTION_OPT_SIZEOPT:
1845 elf32xtensa_size_opt = 1;
1847 case OPTION_NO_RELAX:
1848 disable_relaxation = TRUE;
1850 case OPTION_LITERAL_MOVEMENT:
1851 elf32xtensa_no_literal_movement = 0;
1853 case OPTION_NO_LITERAL_MOVEMENT:
1854 elf32xtensa_no_literal_movement = 1;
1858 # Replace some of the standard ELF functions with our own versions.
1860 LDEMUL_BEFORE_PARSE=elf_xtensa_before_parse
1861 LDEMUL_AFTER_OPEN=elf_xtensa_after_open
1862 LDEMUL_CHOOSE_TARGET=elf_xtensa_choose_target
1863 LDEMUL_BEFORE_ALLOCATION=elf_xtensa_before_allocation