bfd macro conversion to inline functions
authorAlan Modra <amodra@gmail.com>
Thu, 19 Sep 2019 02:21:04 +0000 (11:51 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 20 Sep 2019 08:34:02 +0000 (18:04 +0930)
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.

26 files changed:
bfd/ChangeLog
bfd/archive.c
bfd/bfd-in.h
bfd/bfd-in2.h
bfd/bfd.c
bfd/targets.c
binutils/ChangeLog
binutils/ar.c
gdb/ChangeLog
gdb/dwarf2read.c
gdb/dwarf2read.h
gdb/gdb_bfd.c
gdb/machoread.c
gdb/solib.c
ld/ChangeLog
ld/emultempl/aarch64elf.em
ld/emultempl/mmo.em
ld/emultempl/pe.em
ld/emultempl/pep.em
ld/emultempl/ppc64elf.em
ld/ldelf.c
ld/ldlang.c
ld/ldlang.h
ld/ldmain.c
sim/ChangeLog
sim/ppc/emul_generic.c

index 6fa38eef4561b59e9e3b96d4fcc834f64564a403..1c700dbfff7f679752ef451143dae6a6bc616fb5 100644 (file)
@@ -1,3 +1,26 @@
+2019-09-20  Alan Modra  <amodra@gmail.com>
+
+       * 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.
+
 2019-09-20  Alan Modra  <amodra@gmail.com>
 
        * elf64-ppc.c (ppc64_glibc_dynamic_reloc): New function.
index dc0400d1cf6bbbe00ca86eb41e066755a04ac901..ccc09ad49f232c1b856bab22c7a067f13c80be70 100644 (file)
@@ -856,7 +856,7 @@ bfd_generic_archive_p (bfd *abfd)
       return NULL;
     }
 
-  bfd_is_thin_archive (abfd) = (strncmp (armag, ARMAGT, SARMAG) == 0);
+  bfd_set_thin_archive (abfd, strncmp (armag, ARMAGT, SARMAG) == 0);
 
   if (strncmp (armag, ARMAG, SARMAG) != 0
       && ! bfd_is_thin_archive (abfd))
index e55e3e90ba7f8983515c585d6c5bb4154ed11ddd..34c1c3ad0e9cfc6495729824ea9a2cb75b1cb989 100644 (file)
@@ -509,38 +509,6 @@ extern int bfd_stat (bfd *, struct stat *);
 #endif
 extern void _bfd_warn_deprecated (const char *, const char *, int, const char *);
 
-#define bfd_get_filename(abfd) ((abfd)->filename)
-#define bfd_get_cacheable(abfd) ((abfd)->cacheable)
-#define bfd_get_format(abfd) ((abfd)->format)
-#define bfd_get_target(abfd) ((abfd)->xvec->name)
-#define bfd_get_flavour(abfd) ((abfd)->xvec->flavour)
-#define bfd_family_coff(abfd) \
-  (bfd_get_flavour (abfd) == bfd_target_coff_flavour || \
-   bfd_get_flavour (abfd) == bfd_target_xcoff_flavour)
-#define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG)
-#define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE)
-#define bfd_header_big_endian(abfd) \
-  ((abfd)->xvec->header_byteorder == BFD_ENDIAN_BIG)
-#define bfd_header_little_endian(abfd) \
-  ((abfd)->xvec->header_byteorder == BFD_ENDIAN_LITTLE)
-#define bfd_get_file_flags(abfd) ((abfd)->flags)
-#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags)
-#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags)
-#define bfd_has_map(abfd) ((abfd)->has_armap)
-#define bfd_is_thin_archive(abfd) ((abfd)->is_thin_archive)
-
-#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types)
-#define bfd_usrdata(abfd) ((abfd)->usrdata)
-
-#define bfd_get_start_address(abfd) ((abfd)->start_address)
-#define bfd_get_symcount(abfd) ((abfd)->symcount)
-#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
-#define bfd_count_sections(abfd) ((abfd)->section_count)
-
-#define bfd_get_dynamic_symcount(abfd) ((abfd)->dynsymcount)
-
-#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
-
 extern bfd_boolean bfd_cache_close
   (bfd *abfd);
 /* NB: This declaration should match the autogenerated one in libbfd.h.  */
index 425f0c6709af6ebe806c9e60b95e5e6ff75cad96..4f158679b2ef49a0103d7a93ccddf31cee113321 100644 (file)
@@ -516,38 +516,6 @@ extern int bfd_stat (bfd *, struct stat *);
 #endif
 extern void _bfd_warn_deprecated (const char *, const char *, int, const char *);
 
-#define bfd_get_filename(abfd) ((abfd)->filename)
-#define bfd_get_cacheable(abfd) ((abfd)->cacheable)
-#define bfd_get_format(abfd) ((abfd)->format)
-#define bfd_get_target(abfd) ((abfd)->xvec->name)
-#define bfd_get_flavour(abfd) ((abfd)->xvec->flavour)
-#define bfd_family_coff(abfd) \
-  (bfd_get_flavour (abfd) == bfd_target_coff_flavour || \
-   bfd_get_flavour (abfd) == bfd_target_xcoff_flavour)
-#define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG)
-#define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE)
-#define bfd_header_big_endian(abfd) \
-  ((abfd)->xvec->header_byteorder == BFD_ENDIAN_BIG)
-#define bfd_header_little_endian(abfd) \
-  ((abfd)->xvec->header_byteorder == BFD_ENDIAN_LITTLE)
-#define bfd_get_file_flags(abfd) ((abfd)->flags)
-#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags)
-#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags)
-#define bfd_has_map(abfd) ((abfd)->has_armap)
-#define bfd_is_thin_archive(abfd) ((abfd)->is_thin_archive)
-
-#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types)
-#define bfd_usrdata(abfd) ((abfd)->usrdata)
-
-#define bfd_get_start_address(abfd) ((abfd)->start_address)
-#define bfd_get_symcount(abfd) ((abfd)->symcount)
-#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
-#define bfd_count_sections(abfd) ((abfd)->section_count)
-
-#define bfd_get_dynamic_symcount(abfd) ((abfd)->dynsymcount)
-
-#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
-
 extern bfd_boolean bfd_cache_close
   (bfd *abfd);
 /* NB: This declaration should match the autogenerated one in libbfd.h.  */
@@ -7321,6 +7289,78 @@ struct bfd
   const struct bfd_build_id *build_id;
 };
 
+static inline const char *
+bfd_get_filename (const bfd *abfd)
+{
+  return abfd->filename;
+}
+
+static inline bfd_boolean
+bfd_get_cacheable (const bfd *abfd)
+{
+  return abfd->cacheable;
+}
+
+static inline enum bfd_format
+bfd_get_format (const bfd *abfd)
+{
+  return abfd->format;
+}
+
+static inline flagword
+bfd_get_file_flags (const bfd *abfd)
+{
+  return abfd->flags;
+}
+
+static inline bfd_vma
+bfd_get_start_address (const bfd *abfd)
+{
+  return abfd->start_address;
+}
+
+static inline unsigned int
+bfd_get_symcount (const bfd *abfd)
+{
+  return abfd->symcount;
+}
+
+static inline unsigned int
+bfd_get_dynamic_symcount (const bfd *abfd)
+{
+  return abfd->dynsymcount;
+}
+
+static inline struct bfd_symbol **
+bfd_get_outsymbols (const bfd *abfd)
+{
+  return abfd->outsymbols;
+}
+
+static inline unsigned int
+bfd_count_sections (const bfd *abfd)
+{
+  return abfd->section_count;
+}
+
+static inline bfd_boolean
+bfd_has_map (const bfd *abfd)
+{
+  return abfd->has_armap;
+}
+
+static inline bfd_boolean
+bfd_is_thin_archive (const bfd *abfd)
+{
+  return abfd->is_thin_archive;
+}
+
+static inline void *
+bfd_usrdata (const bfd *abfd)
+{
+  return abfd->usrdata;
+}
+
 /* See note beside bfd_set_section_userdata.  */
 static inline bfd_boolean
 bfd_set_cacheable (bfd * abfd, bfd_boolean val)
@@ -7329,6 +7369,18 @@ bfd_set_cacheable (bfd * abfd, bfd_boolean val)
   return TRUE;
 }
 
+static inline void
+bfd_set_thin_archive (bfd *abfd, bfd_boolean val)
+{
+  abfd->is_thin_archive = val;
+}
+
+static inline void
+bfd_set_usrdata (bfd *abfd, void *val)
+{
+  abfd->usrdata = val;
+}
+
 
 typedef enum bfd_error
 {
@@ -8023,6 +8075,66 @@ typedef struct bfd_target
 
 } bfd_target;
 
+static inline const char *
+bfd_get_target (const bfd *abfd)
+{
+  return abfd->xvec->name;
+}
+
+static inline enum bfd_flavour
+bfd_get_flavour (const bfd *abfd)
+{
+  return abfd->xvec->flavour;
+}
+
+static inline flagword
+bfd_applicable_file_flags (const bfd *abfd)
+{
+  return abfd->xvec->object_flags;
+}
+
+static inline bfd_boolean
+bfd_family_coff (const bfd *abfd)
+{
+  return (bfd_get_flavour (abfd) == bfd_target_coff_flavour
+          || bfd_get_flavour (abfd) == bfd_target_xcoff_flavour);
+}
+
+static inline bfd_boolean
+bfd_big_endian (const bfd *abfd)
+{
+  return abfd->xvec->byteorder == BFD_ENDIAN_BIG;
+}
+static inline bfd_boolean
+bfd_little_endian (const bfd *abfd)
+{
+  return abfd->xvec->byteorder == BFD_ENDIAN_LITTLE;
+}
+
+static inline bfd_boolean
+bfd_header_big_endian (const bfd *abfd)
+{
+  return abfd->xvec->header_byteorder == BFD_ENDIAN_BIG;
+}
+
+static inline bfd_boolean
+bfd_header_little_endian (const bfd *abfd)
+{
+  return abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE;
+}
+
+static inline flagword
+bfd_applicable_section_flags (const bfd *abfd)
+{
+  return abfd->xvec->section_flags;
+}
+
+static inline char
+bfd_get_symbol_leading_char (const bfd *abfd)
+{
+  return abfd->xvec->symbol_leading_char;
+}
+
 bfd_boolean bfd_set_default_target (const char *name);
 
 const bfd_target *bfd_find_target (const char *target_name, bfd *abfd);
index 7029bf7b85bac4543a915970c04d78524ab8be9c..c11274c187f0b09dca7cdbd3d51f1d25cc82a2af 100644 (file)
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -355,6 +355,78 @@ CODE_FRAGMENT
 .  const struct bfd_build_id *build_id;
 .};
 .
+.static inline const char *
+.bfd_get_filename (const bfd *abfd)
+.{
+.  return abfd->filename;
+.}
+.
+.static inline bfd_boolean
+.bfd_get_cacheable (const bfd *abfd)
+.{
+.  return abfd->cacheable;
+.}
+.
+.static inline enum bfd_format
+.bfd_get_format (const bfd *abfd)
+.{
+.  return abfd->format;
+.}
+.
+.static inline flagword
+.bfd_get_file_flags (const bfd *abfd)
+.{
+.  return abfd->flags;
+.}
+.
+.static inline bfd_vma
+.bfd_get_start_address (const bfd *abfd)
+.{
+.  return abfd->start_address;
+.}
+.
+.static inline unsigned int
+.bfd_get_symcount (const bfd *abfd)
+.{
+.  return abfd->symcount;
+.}
+.
+.static inline unsigned int
+.bfd_get_dynamic_symcount (const bfd *abfd)
+.{
+.  return abfd->dynsymcount;
+.}
+.
+.static inline struct bfd_symbol **
+.bfd_get_outsymbols (const bfd *abfd)
+.{
+.  return abfd->outsymbols;
+.}
+.
+.static inline unsigned int
+.bfd_count_sections (const bfd *abfd)
+.{
+.  return abfd->section_count;
+.}
+.
+.static inline bfd_boolean
+.bfd_has_map (const bfd *abfd)
+.{
+.  return abfd->has_armap;
+.}
+.
+.static inline bfd_boolean
+.bfd_is_thin_archive (const bfd *abfd)
+.{
+.  return abfd->is_thin_archive;
+.}
+.
+.static inline void *
+.bfd_usrdata (const bfd *abfd)
+.{
+.  return abfd->usrdata;
+.}
+.
 .{* See note beside bfd_set_section_userdata.  *}
 .static inline bfd_boolean
 .bfd_set_cacheable (bfd * abfd, bfd_boolean val)
@@ -363,6 +435,18 @@ CODE_FRAGMENT
 .  return TRUE;
 .}
 .
+.static inline void
+.bfd_set_thin_archive (bfd *abfd, bfd_boolean val)
+.{
+.  abfd->is_thin_archive = val;
+.}
+.
+.static inline void
+.bfd_set_usrdata (bfd *abfd, void *val)
+.{
+.  abfd->usrdata = val;
+.}
+.
 */
 
 #include "sysdep.h"
index b02dfc548474f6b3f9ed7c73ae63d32c257c17e6..116a5c34de88d6791faa1c833a72492895764aa6 100644 (file)
@@ -584,6 +584,66 @@ to find an alternative output format that is suitable.
 .
 .} bfd_target;
 .
+.static inline const char *
+.bfd_get_target (const bfd *abfd)
+.{
+.  return abfd->xvec->name;
+.}
+.
+.static inline enum bfd_flavour
+.bfd_get_flavour (const bfd *abfd)
+.{
+.  return abfd->xvec->flavour;
+.}
+.
+.static inline flagword
+.bfd_applicable_file_flags (const bfd *abfd)
+.{
+.  return abfd->xvec->object_flags;
+.}
+.
+.static inline bfd_boolean
+.bfd_family_coff (const bfd *abfd)
+.{
+.  return (bfd_get_flavour (abfd) == bfd_target_coff_flavour
+.          || bfd_get_flavour (abfd) == bfd_target_xcoff_flavour);
+.}
+.
+.static inline bfd_boolean
+.bfd_big_endian (const bfd *abfd)
+.{
+.  return abfd->xvec->byteorder == BFD_ENDIAN_BIG;
+.}
+.static inline bfd_boolean
+.bfd_little_endian (const bfd *abfd)
+.{
+.  return abfd->xvec->byteorder == BFD_ENDIAN_LITTLE;
+.}
+.
+.static inline bfd_boolean
+.bfd_header_big_endian (const bfd *abfd)
+.{
+.  return abfd->xvec->header_byteorder == BFD_ENDIAN_BIG;
+.}
+.
+.static inline bfd_boolean
+.bfd_header_little_endian (const bfd *abfd)
+.{
+.  return abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE;
+.}
+.
+.static inline flagword
+.bfd_applicable_section_flags (const bfd *abfd)
+.{
+.  return abfd->xvec->section_flags;
+.}
+.
+.static inline char
+.bfd_get_symbol_leading_char (const bfd *abfd)
+.{
+.  return abfd->xvec->symbol_leading_char;
+.}
+.
 */
 
 /* All known xvecs (even those that don't compile on all systems).
index 9d1aa848fbf5929b8562e920676dcfef525b8ac0..21dc92dcae1a9b1567382845a4ff3a557821f265 100644 (file)
@@ -1,3 +1,7 @@
+2019-09-20  Alan Modra  <amodra@gmail.com>
+
+       * ar.c (write_archive): Use bfd_set_thin_archive.
+
 2019-09-18  Tamar Christina  <tamar.christina@arm.com>
 
        * testsuite/binutils-all/objdump.exp (objump -S): Update testcases.
index 4e953c054dedbdd6489919b337fb3e5f1919a4a0..6bac862bc73dacba6c321aac9dbeb54ba2efbe72 100644 (file)
@@ -1200,7 +1200,7 @@ write_archive (bfd *iarch)
     obfd->flags |= BFD_DETERMINISTIC_OUTPUT;
 
   if (make_thin_archive || bfd_is_thin_archive (iarch))
-    bfd_is_thin_archive (obfd) = 1;
+    bfd_set_thin_archive (obfd, TRUE);
 
   if (!bfd_set_archive_head (obfd, contents_head))
     bfd_fatal (old_name);
index 41a002498dff1f1d260f82370a37c7850fd779bd..5314b2746bc35d4c0d499b43e2d4a71c6f4a1fa9 100644 (file)
@@ -1,3 +1,12 @@
+2019-09-20  Alan Modra  <amodra@gmail.com>
+
+       * 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.
+
 2019-09-19  Christian Biesinger  <cbiesinger@google.com>
 
        * eval.c: Move declaration of overload_resolution to...
index 5e71ded2039abb7f9326d9dc08cb1aa40a283175..1052501c351de0923ee79df201151337517841f0 100644 (file)
@@ -3584,14 +3584,14 @@ dwarf2_read_gdb_index
        return 0;
 
       if (!read_gdb_index_from_buffer (objfile,
-                                      bfd_get_filename (dwz->dwz_bfd), 1,
-                                      dwz_index_content, &dwz_map,
+                                      bfd_get_filename (dwz->dwz_bfd.get ()),
+                                      1, dwz_index_content, &dwz_map,
                                       &dwz_list, &dwz_list_elements,
                                       &dwz_types_ignore,
                                       &dwz_types_elements_ignore))
        {
          warning (_("could not read '.gdb_index' section from %s; skipping"),
-                  bfd_get_filename (dwz->dwz_bfd));
+                  bfd_get_filename (dwz->dwz_bfd.get ()));
          return 0;
        }
     }
@@ -5596,11 +5596,11 @@ dwarf2_read_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile)
   if (dwz != NULL)
     {
       if (!read_debug_names_from_section (objfile,
-                                         bfd_get_filename (dwz->dwz_bfd),
+                                         bfd_get_filename (dwz->dwz_bfd.get ()),
                                          &dwz->debug_names, dwz_map))
        {
          warning (_("could not read '.debug_names' section from %s; skipping"),
-                  bfd_get_filename (dwz->dwz_bfd));
+                  bfd_get_filename (dwz->dwz_bfd.get ()));
          return false;
        }
     }
@@ -19759,11 +19759,11 @@ read_indirect_string_from_dwz (struct objfile *objfile, struct dwz_file *dwz,
   if (dwz->str.buffer == NULL)
     error (_("DW_FORM_GNU_strp_alt used without .debug_str "
             "section [in module %s]"),
-          bfd_get_filename (dwz->dwz_bfd));
+          bfd_get_filename (dwz->dwz_bfd.get ()));
   if (str_offset >= dwz->str.size)
     error (_("DW_FORM_GNU_strp_alt pointing outside of "
             ".debug_str section [in module %s]"),
-          bfd_get_filename (dwz->dwz_bfd));
+          bfd_get_filename (dwz->dwz_bfd.get ()));
   gdb_assert (HOST_CHAR_BIT == 8);
   if (dwz->str.buffer[str_offset] == '\0')
     return NULL;
index e9b946247b0c3d54940a00ee44b29d5a41dcca4b..d5a02990d41f2a45135e60230ab9096ddffa8e1a 100644 (file)
@@ -417,7 +417,7 @@ struct dwz_file
 
   const char *filename () const
   {
-    return bfd_get_filename (this->dwz_bfd);
+    return bfd_get_filename (this->dwz_bfd.get ());
   }
 
   /* A dwz file can only contain a few sections.  */
index 8a67d5e97d72fe846e6d158cb0891685883d55ab..69618a27e1cc6c0e6d50ddec795956c9ed9afd97 100644 (file)
@@ -546,7 +546,7 @@ gdb_bfd_ref (struct bfd *abfd)
   abfd->flags |= BFD_DECOMPRESS;
 
   gdata = new gdb_bfd_data (abfd);
-  bfd_usrdata (abfd) = gdata;
+  bfd_set_usrdata (abfd, gdata);
   bfd_alloc_data (abfd);
 
   /* This is the first we've seen it, so add it to the hash table.  */
@@ -608,7 +608,7 @@ gdb_bfd_unref (struct bfd *abfd)
 
   bfd_free_data (abfd);
   delete gdata;
-  bfd_usrdata (abfd) = NULL;  /* Paranoia.  */
+  bfd_set_usrdata (abfd, NULL);  /* Paranoia.  */
 
   htab_remove_elt (all_bfds, abfd);
 
index 1795982a3e8200659f676e2cfac1d2c063c97e89..a015d297c38e3797c8a4d46893a473d34536a64a 100644 (file)
@@ -671,7 +671,7 @@ macho_symfile_read_all_oso (std::vector<oso_el> *oso_vector_ptr,
           /* Load all oso in this library.  */
          while (member_bfd != NULL)
            {
-             const char *member_name = member_bfd->filename;
+             const char *member_name = bfd_get_filename (member_bfd.get ());
               int member_len = strlen (member_name);
 
               /* If this member is referenced, add it as a symfile.  */
@@ -685,7 +685,7 @@ macho_symfile_read_all_oso (std::vector<oso_el> *oso_vector_ptr,
                                   member_len))
                     {
                       macho_add_oso_symfile (oso2, member_bfd,
-                                            bfd_get_filename (member_bfd),
+                                            bfd_get_filename (member_bfd.get ()),
                                              main_objfile, symfile_flags);
                       oso2->name = NULL;
                       break;
index 86000f6d61d4ec7ee7915ffc84f728f50b479f68..b9a61e265b1657813bc68636b76a6dd101a52e91 100644 (file)
@@ -502,14 +502,14 @@ solib_bfd_open (const char *pathname)
   /* Check bfd format.  */
   if (!bfd_check_format (abfd.get (), bfd_object))
     error (_("`%s': not in executable format: %s"),
-          bfd_get_filename (abfd), bfd_errmsg (bfd_get_error ()));
+          bfd_get_filename (abfd.get ()), bfd_errmsg (bfd_get_error ()));
 
   /* Check bfd arch.  */
   b = gdbarch_bfd_arch_info (target_gdbarch ());
   if (!b->compatible (b, bfd_get_arch_info (abfd.get ())))
     warning (_("`%s': Shared library architecture %s is not compatible "
-               "with target architecture %s."), bfd_get_filename (abfd),
-             bfd_get_arch_info (abfd.get ())->printable_name,
+              "with target architecture %s."), bfd_get_filename (abfd.get ()),
+            bfd_get_arch_info (abfd.get ())->printable_name,
             b->printable_name);
 
   return abfd;
index 2abb558b9c1e11c118ababb2bf4f090881f26d68..705a2b2de8ddee488b82e7a48efb17a46a3e1a9e 100644 (file)
@@ -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,
index bd5c888782650bed8d0e1be425b880975f09797c..208d169404dfe344bff91e7d6cde1fd2e792937b 100644 (file)
@@ -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)
index fff48942bc43349f63724d31b67bd39d51b970ee..85c5863953396bd97692ad3d0ae23cbaf2613fc1 100644 (file)
@@ -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);
     }
index 70f771cebd782b608e1aaf83c13241820b34e9a5..150c98296f187b5ba171a4d6c99e78884432d238 100644 (file)
@@ -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);
index 6d150d211a92bb725935724c150ef5da9e5cce96..ab2a989bc59133d5c9976d39d820f559f1c16803 100644 (file)
@@ -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);
index ee71f256c657c2f4cc619362b73b0dddb734c93c..aad56cfddd17d971e0f67fc337af70d3da69e66c 100644 (file)
@@ -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)
index 8d4a2e58a1b6c96effc4873d147a259942dca9c1..e43d33d4325a3548327df9371d257c4a2338b629 100644 (file)
@@ -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)
index a3843623fb4beaa5cfaa32fb3af3c15baf841fa9..0ffcf34473ccf8426deb355eb6370fa11169d44f 100644 (file)
@@ -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
index 686e44f8419ece6a7abc15f8d7cb48f829a01a84..9fb10f80a78b283309df2df9e07c69ceaad311e8 100644 (file)
@@ -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;
 
index e24194ef87d8a51ba6ff7467df380be962a7c1b0..34c19223137eed8596e4ff8950c2e634f3128a5a 100644 (file)
@@ -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;
 
index 191e2370a98579a21b2f56d75577eaaa20a50c5a..d4c7d166d2bbc4205cc7cd23894a6df6983ffeb7 100644 (file)
@@ -1,3 +1,7 @@
+2019-09-20  Alan Modra  <amodra@gmail.com>
+
+       * ppc/emul_generic.c (emul_add_tree_options): Delete old bfd code.
+
 2019-09-18  Alan Modra  <amodra@gmail.com>
 
        * common/sim-load.c, * common/sim-utils.c, * cris/sim-if.c,
index dc0b2cf1e0930ffb33f694e01ebb4a1c06920584..64c0219309099fe4733bdc49b7b702f6d59a2c1a 100644 (file)
@@ -262,12 +262,7 @@ emul_add_tree_options(device *tree,
   if (tree_find_property(tree, "/options/little-endian?"))
     little_endian = tree_find_boolean_property(tree, "/options/little-endian?");
   else {
-#ifdef bfd_little_endian       /* new bfd */
     little_endian = (image != NULL && bfd_little_endian(image));
-#else
-    little_endian = (image != NULL &&
-                    !image->xvec->byteorder_big_p);
-#endif
     tree_parse(tree, "/options/little-endian? %s",
               little_endian ? "true" : "false");
   }
This page took 0.049535 seconds and 4 git commands to generate.