aboutsummaryrefslogtreecommitdiff
path: root/ld/ldlang.h
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2021-01-13 13:33:34 +1030
committerAlan Modra <amodra@gmail.com>2021-01-13 22:06:02 +1030
commitb209b5a6b8a4433be961a0f016439f381de65bfc (patch)
treeb540de64953f26165ed65e17c6b96a58b95e30c8 /ld/ldlang.h
parent8c4645b4887660eb704f152f2a14c5108d56c9d7 (diff)
downloadgdb-b209b5a6b8a4433be961a0f016439f381de65bfc.zip
gdb-b209b5a6b8a4433be961a0f016439f381de65bfc.tar.gz
gdb-b209b5a6b8a4433be961a0f016439f381de65bfc.tar.bz2
SHF_LINK_ORDER fixup_link_order in ld
This moves the SHF_LINK_ORDER sorting from bfd_elf_final_link to the linker which means generic ELF targets now support SHF_LINK_ORDER and we cope with odd cases that require resizing of output sections. The patch also fixes two bugs in the current implementation, introduced by commit cd6d537c48fa. The pattern test used by that commit meant that sections matching something like "*(.IA_64.unwind* .gnu.linkonce.ia64unw.*)" would not properly sort a mix of sections matching the two wildcards. That commit also assumed a stable qsort. bfd/ PR 27160 * section.c (struct bfd_section): Remove pattern field. (BFD_FAKE_SECTION): Adjust to suit. * bfd-in2.h: Regenerate. * elflink.c (compare_link_order, elf_fixup_link_order): Delete. (bfd_elf_final_link): Don't call elf_fixup_link_order. ld/ PR 27160 * ldlang.h (lang_output_section_statement_type): Add data field. (lang_input_section_type, lang_section_bst_type): Add pattern field. (statement_list): Declare. (lang_add_section): Adjust prototype. * emultempl/aarch64elf.em: Adjust lang_add_section calls. * emultempl/armelf.em: Likewise. * emultempl/beos.em: Likewise. * emultempl/cskyelf.em: Likewise. * emultempl/hppaelf.em: Likewise. * emultempl/m68hc1xelf.em: Likewise. * emultempl/metagelf.em: Likewise. * emultempl/mipself.em: Likewise. * emultempl/mmo.em: Likewise. * emultempl/msp430.em: Likewise. * emultempl/nios2elf.em: Likewise. * emultempl/pe.em: Likewise. * emultempl/pep.em: Likewise. * emultempl/ppc64elf.em: Likewise. * emultempl/spuelf.em: Likewise. * emultempl/vms.em: Likewise. * ldelf.c: Likewise. * ldelfgen.c: Include ldctor.h. (struct os_sections): New. (add_link_order_input_section, link_order_scan): New functions. (compare_link_order, fixup_link_order): New functions. (ldelf_map_segments): Call link_order_scan and fixup_link_order. * ldlang.c (statement_list): Make global. (output_section_callback_fast): Save pattern in tree node. (lang_add_section): Add pattern parameter, save in lang_input_section. (output_section_callback_tree_to_list): Adjust lang_add_section calls. (lang_insert_orphan, output_section_callback): Likewise. (ldlang_place_orphan): Likewise. (gc_section_callback): Don't set section->pattern * testsuite/ld-elf/pr26256-2a.d: Don't xfail generic. * testsuite/ld-elf/pr26256-3b.d: Likewise. * testsuite/ld-elf/pr26256-2b.d: Likewise. notarget xgate.
Diffstat (limited to 'ld/ldlang.h')
-rw-r--r--ld/ldlang.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/ld/ldlang.h b/ld/ldlang.h
index 205c305..3463d4c 100644
--- a/ld/ldlang.h
+++ b/ld/ldlang.h
@@ -158,6 +158,9 @@ typedef struct lang_output_section_statement_struct
lang_output_section_phdr_list *phdrs;
+ /* Used by ELF SHF_LINK_ORDER sorting. */
+ void *data;
+
unsigned int block_value;
int constraint;
flagword flags;
@@ -323,6 +326,7 @@ typedef struct
{
lang_statement_header_type header;
asection *section;
+ void *pattern;
} lang_input_section_type;
struct map_symbol_def {
@@ -364,6 +368,7 @@ typedef bfd_boolean (*lang_match_sec_type_func) (bfd *, const asection *,
typedef struct lang_section_bst
{
asection *section;
+ void *pattern;
struct lang_section_bst *left;
struct lang_section_bst *right;
} lang_section_bst_type;
@@ -506,6 +511,7 @@ extern lang_output_section_statement_type *abs_output_section;
extern lang_statement_list_type lang_os_list;
extern struct lang_input_statement_flags input_flags;
extern bfd_boolean lang_has_input_file;
+extern lang_statement_list_type statement_list;
extern lang_statement_list_type *stat_ptr;
extern bfd_boolean delete_output_file_on_failure;
@@ -650,7 +656,7 @@ extern void lang_enter_group
extern void lang_leave_group
(void);
extern void lang_add_section
- (lang_statement_list_type *, asection *,
+ (lang_statement_list_type *, asection *, struct wildcard_list *,
struct flag_info *, lang_output_section_statement_type *);
extern void lang_new_phdr
(const char *, etree_type *, bfd_boolean, bfd_boolean, etree_type *,