diff options
author | Alan Modra <amodra@gmail.com> | 2019-09-19 11:51:04 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2019-09-20 18:04:02 +0930 |
commit | 00f93c449228e69f2161405b1f49b406e88785f0 (patch) | |
tree | 89558e119955a9ae7847d60870efdfaa3d42dfe7 /bfd | |
parent | 3f9aad111cea2f25877d0a6b404956769c14faee (diff) | |
download | gdb-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 'bfd')
-rw-r--r-- | bfd/ChangeLog | 23 | ||||
-rw-r--r-- | bfd/archive.c | 2 | ||||
-rw-r--r-- | bfd/bfd-in.h | 32 | ||||
-rw-r--r-- | bfd/bfd-in2.h | 176 | ||||
-rw-r--r-- | bfd/bfd.c | 84 | ||||
-rw-r--r-- | bfd/targets.c | 60 |
6 files changed, 312 insertions, 65 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 6fa38ee..1c700db 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,28 @@ 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. (ppc64_elf_relocate_section): Warn if emitting unsupported dynamic relocations. diff --git a/bfd/archive.c b/bfd/archive.c index dc0400d..ccc09ad 100644 --- a/bfd/archive.c +++ b/bfd/archive.c @@ -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)) diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index e55e3e9..34c1c3a 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -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. */ diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 425f0c6..4f15867 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -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); @@ -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" diff --git a/bfd/targets.c b/bfd/targets.c index b02dfc5..116a5c3 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -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). |