aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-09-19 11:51:04 +0930
committerAlan Modra <amodra@gmail.com>2019-09-20 18:04:02 +0930
commit00f93c449228e69f2161405b1f49b406e88785f0 (patch)
tree89558e119955a9ae7847d60870efdfaa3d42dfe7 /ld
parent3f9aad111cea2f25877d0a6b404956769c14faee (diff)
downloadgdb-00f93c449228e69f2161405b1f49b406e88785f0.zip
gdb-00f93c449228e69f2161405b1f49b406e88785f0.tar.gz
gdb-00f93c449228e69f2161405b1f49b406e88785f0.tar.bz2
bfd macro conversion to inline functions
This converts some of the macros that access struct bfd fields to inline functions. bfd/ * archive.c (bfd_generic_archive_p): Use bfd_set_thin_archive. * bfd-in.h (bfd_get_filename, bfd_get_cacheable, bfd_get_format), (bfd_get_target, bfd_get_flavour, bfd_family_coff, bfd_big_endian), (bfd_little_endian, bfd_header_big_endian, bfd_header_little_endian), (bfd_get_file_flags, bfd_applicable_file_flags), (bfd_applicable_section_flags, bfd_has_map, bfd_is_thin_archive), (bfd_valid_reloc_types, bfd_usrdata, bfd_get_start_address), (bfd_get_symcount, bfd_get_outsymbols, bfd_count_sections), (bfd_get_dynamic_symcount, bfd_get_symbol_leading_char): Delete. * bfd/bfd.c (bfd_get_filename, bfd_get_cacheable, bfd_get_format), (bfd_get_file_flags, bfd_get_start_address, bfd_get_symcount), (bfd_get_dynamic_symcount, bfd_get_outsymbols, bfd_count_sections), (bfd_has_map, bfd_is_thin_archive, bfd_set_thin_archive), (bfd_usrdata, bfd_set_usrdata): New inline functions. * targets.c (bfd_get_target, bfd_get_flavour), (bfd_applicable_file_flags, bfd_family_coff, bfd_big_endian), (bfd_little_endian, bfd_header_big_endian), (bfd_header_little_endian, bfd_applicable_section_flags), (bfd_get_symbol_leading_char): New inline functions. * bfd-in2.h: Regenerate. binutils/ * ar.c (write_archive): Use bfd_set_thin_archive. gdb/ * gdb_bfd.c (gdb_bfd_ref, gdb_bfd_unref): Use bfd_set_usrdata. * dwarf2read.c (dwarf2_read_gdb_index, dwarf2_read_debug_names), (read_indirect_string_from_dwz): Use bfd accessor. * dwarf2read.h (struct dwz_file <filename>): Likewise. * machoread.c (macho_symfile_read_all_oso): Likewise. * solib.c (solib_bfd_open): Likewise. ld/ * ldelf.c (ldelf_after_open, ldelf_place_orphan * ldlang.c (walk_wild_file, lang_process): Use bfd_usrdata. (load_symbols, ldlang_add_file): Use bfd_set_usrdata. * ldmain.c (add_archive_element): Use bfd_usrdata. * ldlang.h (bfd_input_just_syms): New inline function. * emultempl/aarch64elf.em (build_section_lists): Use it. * emultempl/mmo.em (mmo_place_orphan): Likewise. * emultempl/pe.em (gld_${EMULATION_NAME}_place_orphan): Likewise. * emultempl/pep.em (gld_${EMULATION_NAME}_place_orphan): Likewise. * emultempl/ppc64elf.em (build_section_lists): Likewise. sim/ * ppc/emul_generic.c (emul_add_tree_options): Delete old bfd code.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog13
-rw-r--r--ld/emultempl/aarch64elf.em2
-rw-r--r--ld/emultempl/mmo.em4
-rw-r--r--ld/emultempl/pe.em4
-rw-r--r--ld/emultempl/pep.em4
-rw-r--r--ld/emultempl/ppc64elf.em2
-rw-r--r--ld/ldelf.c8
-rw-r--r--ld/ldlang.c14
-rw-r--r--ld/ldlang.h6
-rw-r--r--ld/ldmain.c2
10 files changed, 33 insertions, 26 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 2abb558..705a2b2 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,16 @@
+2019-09-20 Alan Modra <amodra@gmail.com>
+
+ * ldelf.c (ldelf_after_open, ldelf_place_orphan
+ * ldlang.c (walk_wild_file, lang_process): Use bfd_usrdata.
+ (load_symbols, ldlang_add_file): Use bfd_set_usrdata.
+ * ldmain.c (add_archive_element): Use bfd_usrdata.
+ * ldlang.h (bfd_input_just_syms): New inline function.
+ * emultempl/aarch64elf.em (build_section_lists): Use it.
+ * emultempl/mmo.em (mmo_place_orphan): Likewise.
+ * emultempl/pe.em (gld_${EMULATION_NAME}_place_orphan): Likewise.
+ * emultempl/pep.em (gld_${EMULATION_NAME}_place_orphan): Likewise.
+ * emultempl/ppc64elf.em (build_section_lists): Likewise.
+
2019-09-18 Alan Modra <amodra@gmail.com>
* ldcref.c, * ldctor.c, * ldelf.c, * ldlang.c, * pe-dll.c,
diff --git a/ld/emultempl/aarch64elf.em b/ld/emultempl/aarch64elf.em
index bd5c888..208d169 100644
--- a/ld/emultempl/aarch64elf.em
+++ b/ld/emultempl/aarch64elf.em
@@ -217,7 +217,7 @@ build_section_lists (lang_statement_union_type *statement)
{
asection *i = statement->input_section.section;
- if (!((lang_input_statement_type *) i->owner->usrdata)->flags.just_syms
+ if (!bfd_input_just_syms (i->owner)
&& (i->flags & SEC_EXCLUDE) == 0
&& i->output_section != NULL
&& i->output_section->owner == link_info.output_bfd)
diff --git a/ld/emultempl/mmo.em b/ld/emultempl/mmo.em
index fff4894..85c5863 100644
--- a/ld/emultempl/mmo.em
+++ b/ld/emultempl/mmo.em
@@ -116,9 +116,7 @@ mmo_place_orphan (asection *s,
&& (nexts->flags & SEC_EXCLUDE) == 0
&& ((nexts->flags ^ flags) & (SEC_LOAD | SEC_ALLOC)) == 0
&& (nexts->owner->flags & DYNAMIC) == 0
- && nexts->owner->usrdata != NULL
- && !(((lang_input_statement_type *) nexts->owner->usrdata)
- ->flags.just_syms))
+ && !bfd_input_just_syms (nexts->owner))
flags = (((flags ^ SEC_READONLY) | (nexts->flags ^ SEC_READONLY))
^ SEC_READONLY);
}
diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em
index 70f771c..150c982 100644
--- a/ld/emultempl/pe.em
+++ b/ld/emultempl/pe.em
@@ -2116,9 +2116,7 @@ gld_${EMULATION_NAME}_place_orphan (asection *s,
&& (nexts->flags & SEC_EXCLUDE) == 0
&& ((nexts->flags ^ flags) & (SEC_LOAD | SEC_ALLOC)) == 0
&& (nexts->owner->flags & DYNAMIC) == 0
- && nexts->owner->usrdata != NULL
- && !(((lang_input_statement_type *) nexts->owner->usrdata)
- ->flags.just_syms))
+ && !bfd_input_just_syms (nexts->owner))
flags = (((flags ^ SEC_READONLY)
| (nexts->flags ^ SEC_READONLY))
^ SEC_READONLY);
diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em
index 6d150d2..ab2a989 100644
--- a/ld/emultempl/pep.em
+++ b/ld/emultempl/pep.em
@@ -1914,9 +1914,7 @@ gld_${EMULATION_NAME}_place_orphan (asection *s,
&& (nexts->flags & SEC_EXCLUDE) == 0
&& ((nexts->flags ^ flags) & (SEC_LOAD | SEC_ALLOC)) == 0
&& (nexts->owner->flags & DYNAMIC) == 0
- && nexts->owner->usrdata != NULL
- && !(((lang_input_statement_type *) nexts->owner->usrdata)
- ->flags.just_syms))
+ && !bfd_input_just_syms (nexts->owner))
flags = (((flags ^ SEC_READONLY)
| (nexts->flags ^ SEC_READONLY))
^ SEC_READONLY);
diff --git a/ld/emultempl/ppc64elf.em b/ld/emultempl/ppc64elf.em
index ee71f25..aad56cf 100644
--- a/ld/emultempl/ppc64elf.em
+++ b/ld/emultempl/ppc64elf.em
@@ -489,7 +489,7 @@ build_section_lists (lang_statement_union_type *statement)
{
asection *i = statement->input_section.section;
- if (!((lang_input_statement_type *) i->owner->usrdata)->flags.just_syms
+ if (!bfd_input_just_syms (i->owner)
&& (i->flags & SEC_EXCLUDE) == 0
&& i->output_section != NULL
&& i->output_section->owner == link_info.output_bfd)
diff --git a/ld/ldelf.c b/ld/ldelf.c
index 8d4a2e5..e43d33d 100644
--- a/ld/ldelf.c
+++ b/ld/ldelf.c
@@ -1018,7 +1018,7 @@ ldelf_after_open (int use_libpath, int native, int is_linux, int is_freebsd,
abfd != (bfd *) NULL; abfd = abfd->link.next)
if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
&& bfd_count_sections (abfd) != 0
- && !((lang_input_statement_type *) abfd->usrdata)->flags.just_syms)
+ && !bfd_input_just_syms (abfd))
break;
/* PR 10555: If there are no ELF input files do not try to
@@ -1060,7 +1060,7 @@ ldelf_after_open (int use_libpath, int native, int is_linux, int is_freebsd,
{
int type = 0;
- if (((lang_input_statement_type *) abfd->usrdata)->flags.just_syms)
+ if (bfd_input_just_syms (abfd))
continue;
for (s = abfd->sections; s && type < COMPACT_EH_HDR; s = s->next)
@@ -2065,9 +2065,7 @@ ldelf_place_orphan (asection *s, const char *secname, int constraint)
&& (nexts->flags & SEC_EXCLUDE) == 0
&& ((nexts->flags ^ flags) & (SEC_LOAD | SEC_ALLOC)) == 0
&& (nexts->owner->flags & DYNAMIC) == 0
- && nexts->owner->usrdata != NULL
- && !(((lang_input_statement_type *) nexts->owner->usrdata)
- ->flags.just_syms)
+ && !bfd_input_just_syms (nexts->owner)
&& _bfd_elf_match_sections_by_type (nexts->owner, nexts,
s->owner, s))
flags = (((flags ^ SEC_READONLY)
diff --git a/ld/ldlang.c b/ld/ldlang.c
index a384362..0ffcf34 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -902,12 +902,8 @@ walk_wild_file (lang_wild_statement_type *s,
archive which is included, BFD will call ldlang_add_file,
which will set the usrdata field of the member to the
lang_input_statement. */
- if (member->usrdata != NULL)
- {
- walk_wild_section (s,
- (lang_input_statement_type *) member->usrdata,
- callback, data);
- }
+ if (bfd_usrdata (member) != NULL)
+ walk_wild_section (s, bfd_usrdata (member), callback, data);
member = bfd_openr_next_archived_file (f->the_bfd, member);
}
@@ -3038,7 +3034,7 @@ load_symbols (lang_input_statement_type *entry,
case bfd_archive:
check_excluded_libs (entry->the_bfd);
- entry->the_bfd->usrdata = entry;
+ bfd_set_usrdata (entry->the_bfd, entry);
if (entry->flags.whole_archive)
{
bfd *member = NULL;
@@ -6898,7 +6894,7 @@ ldlang_add_file (lang_input_statement_type *entry)
*link_info.input_bfds_tail = entry->the_bfd;
link_info.input_bfds_tail = &entry->the_bfd->link.next;
- entry->the_bfd->usrdata = entry;
+ bfd_set_usrdata (entry->the_bfd, entry);
bfd_set_gp_size (entry->the_bfd, g_switch_value);
/* Look through the sections and check for any which should not be
@@ -7540,7 +7536,7 @@ lang_process (void)
*iter = temp;
if (my_arch != NULL)
{
- lang_input_statement_type *parent = my_arch->usrdata;
+ lang_input_statement_type *parent = bfd_usrdata (my_arch);
if (parent != NULL)
parent->next = (lang_input_statement_type *)
((char *) iter
diff --git a/ld/ldlang.h b/ld/ldlang.h
index 686e44f..9fb10f8 100644
--- a/ld/ldlang.h
+++ b/ld/ldlang.h
@@ -331,6 +331,12 @@ typedef struct input_section_userdata_struct
#define get_userdata(x) ((x)->userdata)
+static inline bfd_boolean
+bfd_input_just_syms (const bfd *abfd)
+{
+ lang_input_statement_type *is = bfd_usrdata (abfd);
+ return is != NULL && is->flags.just_syms;
+}
typedef struct lang_wild_statement_struct lang_wild_statement_type;
diff --git a/ld/ldmain.c b/ld/ldmain.c
index e24194e..34c1922 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -816,7 +816,7 @@ add_archive_element (struct bfd_link_info *info,
input->local_sym_name = abfd->filename;
input->the_bfd = abfd;
- parent = abfd->my_archive->usrdata;
+ parent = bfd_usrdata (abfd->my_archive);
if (parent != NULL && !parent->flags.reload)
parent->next = input;