diff options
-rw-r--r-- | ld/ChangeLog | 18 | ||||
-rw-r--r-- | ld/emultempl/aix.em | 5 | ||||
-rw-r--r-- | ld/emultempl/spuelf.em | 6 | ||||
-rw-r--r-- | ld/ldlang.c | 83 | ||||
-rw-r--r-- | ld/ldlang.h | 9 | ||||
-rw-r--r-- | ld/ldmain.c | 2 |
6 files changed, 67 insertions, 56 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 6ff1a47..d4cb36d 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,21 @@ +2019-08-10 Alan Modra <amodra@gmail.com> + + * ldlang.h (lang_input_statement_type): Make next + and next_real_file a lang_input_statement_type pointer. + (lang_statement_append): Delete prototype. + (LANG_FOR_EACH_INPUT_STATEMENT): Update for lang_input_statement_type + change. + * ldmain.c (add_archive_element): Likewise. + * ldlang.c: Likewise throughout. + (lang_statement_append): Make static. Make element and field + void pointers. Remove casts in calls. + (lang_check): Use a lang_input_statement_type pointer for "file". + (find_rescan_insertion): Similarly for "iter" and return value. + (lang_process): Similarly for "insert", "iter" and "temp". + * emultempl/spuelf.em (embedded_spu_file): Likewise. + * emultempl/aix.em (gld${EMULATION_NAME}_before_allocation): Expand + lang_statment_append call. + 2019-08-09 Mihailo Stojanovic <mihailo.stojanovic@rt-rk.com> * emulparams/elf32bmip.sh: Add .MIPS.xhash section. diff --git a/ld/emultempl/aix.em b/ld/emultempl/aix.em index bcf959d..8151a9d 100644 --- a/ld/emultempl/aix.em +++ b/ld/emultempl/aix.em @@ -945,9 +945,8 @@ gld${EMULATION_NAME}_before_allocation (void) else { is->header.next = NULL; - lang_statement_append (&os->children, - (lang_statement_union_type *) is, - &is->header.next); + *os->children.tail = (lang_statement_union_type *) is; + os->children.tail = &is->header.next; } } diff --git a/ld/emultempl/spuelf.em b/ld/emultempl/spuelf.em index f630975..5ddf41c 100644 --- a/ld/emultempl/spuelf.em +++ b/ld/emultempl/spuelf.em @@ -512,9 +512,9 @@ embedded_spu_file (lang_input_statement_type *entry, const char *flags) return FALSE; close (fd); - for (search = (lang_input_statement_type *) input_file_chain.head; + for (search = &input_file_chain.head->input_statement; search != NULL; - search = (lang_input_statement_type *) search->next_real_file) + search = search->next_real_file) if (search->filename != NULL) { const char *infile = base_name (search->filename); @@ -575,7 +575,7 @@ embedded_spu_file (lang_input_statement_type *entry, const char *flags) new_ent->header.next = entry->header.next; entry->header.next = new_ent; new_ent->input_statement.next_real_file = entry->next_real_file; - entry->next_real_file = new_ent; + entry->next_real_file = &new_ent->input_statement; /* Ensure bfd sections are excluded from the output. */ bfd_section_list_clear (entry->the_bfd); diff --git a/ld/ldlang.c b/ld/ldlang.c index 8119cfc..3ec534e 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -1026,6 +1026,15 @@ lang_list_init (lang_statement_list_type *list) list->tail = &list->head; } +static void +lang_statement_append (lang_statement_list_type *list, + void *element, + void *field) +{ + *(list->tail) = element; + list->tail = field; +} + void push_stat_ptr (lang_statement_list_type *new_ptr) { @@ -1142,9 +1151,7 @@ new_afile (const char *name, FAIL (); } - lang_statement_append (&input_file_chain, - (lang_statement_union_type *) p, - &p->next_real_file); + lang_statement_append (&input_file_chain, p, &p->next_real_file); return p; } @@ -1234,9 +1241,7 @@ output_section_statement_newfunc (struct bfd_hash_entry *entry, address, so we store the pointer in a variable and cast that instead. */ nextp = &ret->s.output_section_statement.next; - lang_statement_append (&lang_os_list, - &ret->s, - (lang_statement_union_type **) nextp); + lang_statement_append (&lang_os_list, &ret->s, nextp); return &ret->root; } @@ -2843,9 +2848,9 @@ lookup_name (const char *name) { lang_input_statement_type *search; - for (search = (lang_input_statement_type *) input_file_chain.head; + for (search = &input_file_chain.head->input_statement; search != NULL; - search = (lang_input_statement_type *) search->next_real_file) + search = search->next_real_file) { /* Use the local_sym_name as the name of the file that has already been loaded as filename might have been transformed @@ -6522,18 +6527,20 @@ ignore_bfd_errors (const char *fmt ATTRIBUTE_UNUSED, static void lang_check (void) { - lang_statement_union_type *file; + lang_input_statement_type *file; bfd *input_bfd; const bfd_arch_info_type *compatible; - for (file = file_chain.head; file != NULL; file = file->input_statement.next) + for (file = &file_chain.head->input_statement; + file != NULL; + file = file->next) { #ifdef ENABLE_PLUGINS /* Don't check format of files claimed by plugin. */ - if (file->input_statement.flags.claimed) + if (file->flags.claimed) continue; #endif /* ENABLE_PLUGINS */ - input_bfd = file->input_statement.the_bfd; + input_bfd = file->the_bfd; compatible = bfd_arch_get_compatible (input_bfd, link_info.output_bfd, command_line.accept_unknown_input_arch); @@ -6868,7 +6875,7 @@ lang_for_each_input_file (void (*func) (lang_input_statement_type *)) for (f = &input_file_chain.head->input_statement; f != NULL; - f = &f->next_real_file->input_statement) + f = f->next_real_file) func (f); } @@ -6888,9 +6895,7 @@ lang_for_each_file (void (*func) (lang_input_statement_type *)) void ldlang_add_file (lang_input_statement_type *entry) { - lang_statement_append (&file_chain, - (lang_statement_union_type *) entry, - &entry->next); + lang_statement_append (&file_chain, entry, &entry->next); /* The BFD linker needs to have a list of all input BFDs involved in a link. */ @@ -7232,7 +7237,7 @@ find_replacements_insert_point (bfd_boolean *before) lastobject = &input_file_chain.head->input_statement; for (claim1 = &file_chain.head->input_statement; claim1 != NULL; - claim1 = &claim1->next->input_statement) + claim1 = claim1->next) { if (claim1->flags.claimed) { @@ -7253,14 +7258,14 @@ find_replacements_insert_point (bfd_boolean *before) /* Find where to insert ADD, an archive element or shared library added during a rescan. */ -static lang_statement_union_type ** +static lang_input_statement_type ** find_rescan_insertion (lang_input_statement_type *add) { bfd *add_bfd = add->the_bfd; lang_input_statement_type *f; lang_input_statement_type *last_loaded = NULL; lang_input_statement_type *before = NULL; - lang_statement_union_type **iter = NULL; + lang_input_statement_type **iter = NULL; if (add_bfd->my_archive != NULL) add_bfd = add_bfd->my_archive; @@ -7274,13 +7279,13 @@ find_rescan_insertion (lang_input_statement_type *add) then their input_statement->next points at it. */ for (f = &input_file_chain.head->input_statement; f != NULL; - f = &f->next_real_file->input_statement) + f = f->next_real_file) { if (f->the_bfd == add_bfd) { before = last_loaded; if (f->next != NULL) - return &f->next->input_statement.next; + return &f->next->next; } if (f->the_bfd != NULL && f->next != NULL) last_loaded = f; @@ -7288,9 +7293,9 @@ find_rescan_insertion (lang_input_statement_type *add) for (iter = before ? &before->next : &file_chain.head->input_statement.next; *iter != NULL; - iter = &(*iter)->input_statement.next) - if (!(*iter)->input_statement.flags.claim_archive - && (*iter)->input_statement.the_bfd->my_archive == NULL) + iter = &(*iter)->next) + if (!(*iter)->flags.claim_archive + && (*iter)->the_bfd->my_archive == NULL) break; return iter; @@ -7496,7 +7501,7 @@ lang_process (void) if (before) { prev = find_next_input_statement (prev); - if (*prev != plugin_insert->next_real_file) + if (*prev != (void *) plugin_insert->next_real_file) { /* Huh? We didn't find the expected input statement. */ ASSERT (0); @@ -7506,12 +7511,13 @@ lang_process (void) lang_list_insert_after (stat_ptr, &added, prev); /* Likewise for the file chains. */ lang_list_insert_after (&input_file_chain, &inputfiles, - &plugin_insert->next_real_file); + (void *) &plugin_insert->next_real_file); /* We must be careful when relinking file_chain; we may need to insert the new files at the head of the list if the insert point chosen is the dummy first input file. */ if (plugin_insert->filename) - lang_list_insert_after (&file_chain, &files, &plugin_insert->next); + lang_list_insert_after (&file_chain, &files, + (void *) &plugin_insert->next); else lang_list_insert_after (&file_chain, &files, &file_chain.head); @@ -7522,8 +7528,8 @@ lang_process (void) lang_list_remove_tail (&file_chain, &files); while (files.head != NULL) { - lang_statement_union_type **insert; - lang_statement_union_type **iter, *temp; + lang_input_statement_type **insert; + lang_input_statement_type **iter, *temp; bfd *my_arch; insert = find_rescan_insertion (&files.head->input_statement); @@ -7531,18 +7537,18 @@ lang_process (void) iter = &files.head->input_statement.next; my_arch = files.head->input_statement.the_bfd->my_archive; if (my_arch != NULL) - for (; *iter != NULL; iter = &(*iter)->input_statement.next) - if ((*iter)->input_statement.the_bfd->my_archive != my_arch) + for (; *iter != NULL; iter = &(*iter)->next) + if ((*iter)->the_bfd->my_archive != my_arch) break; temp = *insert; - *insert = files.head; - files.head = *iter; + *insert = &files.head->input_statement; + files.head = (lang_statement_union_type *) *iter; *iter = temp; if (my_arch != NULL) { lang_input_statement_type *parent = my_arch->usrdata; if (parent != NULL) - parent->next = (lang_statement_union_type *) + parent->next = (lang_input_statement_type *) ((char *) iter - offsetof (lang_input_statement_type, next)); } @@ -7954,15 +7960,6 @@ lang_leave_output_section_statement (fill_type *fill, const char *memspec, pop_stat_ptr (); } -void -lang_statement_append (lang_statement_list_type *list, - lang_statement_union_type *element, - lang_statement_union_type **field) -{ - *(list->tail) = element; - list->tail = field; -} - /* Set the output format type. -oformat overrides scripts. */ void diff --git a/ld/ldlang.h b/ld/ldlang.h index 2298cba..6d5fe73 100644 --- a/ld/ldlang.h +++ b/ld/ldlang.h @@ -309,10 +309,10 @@ typedef struct lang_input_statement_struct struct flag_info *section_flag_list; /* Next pointer for file_chain statement list. */ - union lang_statement_union *next; + struct lang_input_statement_struct *next; /* Next pointer for input_file_chain statement list. */ - union lang_statement_union *next_real_file; + struct lang_input_statement_struct *next_real_file; const char *target; @@ -567,9 +567,6 @@ extern void lang_float extern void lang_leave_output_section_statement (fill_type *, const char *, lang_output_section_phdr_list *, const char *); -extern void lang_statement_append - (lang_statement_list_type *, lang_statement_union_type *, - lang_statement_union_type **); extern void lang_for_each_input_file (void (*dothis) (lang_input_statement_type *)); extern void lang_for_each_file @@ -585,7 +582,7 @@ extern asection *section_for_dot lang_input_statement_type *statement; \ for (statement = &file_chain.head->input_statement; \ statement != NULL; \ - statement = &statement->next->input_statement) + statement = statement->next) #define lang_output_section_find(NAME) \ lang_output_section_statement_lookup (NAME, 0, FALSE) diff --git a/ld/ldmain.c b/ld/ldmain.c index a7ca4f4..e24194e 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -818,7 +818,7 @@ add_archive_element (struct bfd_link_info *info, parent = abfd->my_archive->usrdata; if (parent != NULL && !parent->flags.reload) - parent->next = (lang_statement_union_type *) input; + parent->next = input; /* Save the original data for trace files/tries below, as plugins (if enabled) may possibly alter it to point to a replacement |