From: Ian Lance Taylor Date: Fri, 22 Sep 1995 22:06:51 +0000 (+0000) Subject: Change arch info to be const, initialized at compile time. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2ffbb79ae4a6a32d70a5a4228259996f76bfc46d;p=binutils-gdb.git Change arch info to be const, initialized at compile time. * archures.c: Reindent many functions. Change CONST to const. (bfd_arch_info_type): Make arch_name const. Remove disassemble; nothing set it anyhow. Make next const. (bfd_arch_info_list): Remove. (bfd_archures_list): Rename from archures_init_table. Change from a table of function pointers to a table of bfd_arch_info_type structure addresses. (bfd_scan_arch): Rewrite accordingly. Return a const pointer. (bfd_lookup_arch): Likewise. (bfd_set_arch_info): Rewrite accordingly. Change argument to be a const pointer. (bfd_default_arch_struct): Make const. (bfd_arch_init, bfd_arch_linkin): Remove. (bfd_get_arch_info): Return a const pointer. * init.c (bfd_init): Don't call bfd_arch_init. * bfd.c (struct _bfd): Make arch_info const. * bfd-in2.h: Rebuild. * libbfd.h: Rebuild. * configure.in: Put & before everything in $selarchs. * configure: Rebuild. * cpu-*.c: Change bfd_*_arch from a function which calls bfd_arch_linkin to a const structure. * ieee.c (ieee_object_p): Make arch const. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index f0b0ed20a51..1eea4f1c6f2 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,30 @@ +Fri Sep 22 17:44:47 1995 Ian Lance Taylor + + Change arch info to be const, initialized at compile time. + * archures.c: Reindent many functions. Change CONST to const. + (bfd_arch_info_type): Make arch_name const. Remove disassemble; + nothing set it anyhow. Make next const. + (bfd_arch_info_list): Remove. + (bfd_archures_list): Rename from archures_init_table. Change from + a table of function pointers to a table of bfd_arch_info_type + structure addresses. + (bfd_scan_arch): Rewrite accordingly. Return a const pointer. + (bfd_lookup_arch): Likewise. + (bfd_set_arch_info): Rewrite accordingly. Change argument to be a + const pointer. + (bfd_default_arch_struct): Make const. + (bfd_arch_init, bfd_arch_linkin): Remove. + (bfd_get_arch_info): Return a const pointer. + * init.c (bfd_init): Don't call bfd_arch_init. + * bfd.c (struct _bfd): Make arch_info const. + * bfd-in2.h: Rebuild. + * libbfd.h: Rebuild. + * configure.in: Put & before everything in $selarchs. + * configure: Rebuild. + * cpu-*.c: Change bfd_*_arch from a function which calls + bfd_arch_linkin to a const structure. + * ieee.c (ieee_object_p): Make arch const. + Fri Sep 22 16:23:18 1995 Michael Meissner * reloc.c (bfd_reloc_code_type): Add relocations to support all of diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 28834067913..7d24c9ce277 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -1079,39 +1079,32 @@ typedef struct bfd_arch_info int bits_per_byte; enum bfd_architecture arch; unsigned long mach; - char *arch_name; - CONST char *printable_name; + const char *arch_name; + const char *printable_name; unsigned int section_align_power; /* true if this is the default machine for the architecture */ boolean the_default; - CONST struct bfd_arch_info * (*compatible) - PARAMS ((CONST struct bfd_arch_info *a, - CONST struct bfd_arch_info *b)); - - boolean (*scan) PARAMS ((CONST struct bfd_arch_info *, CONST char *)); - /* How to disassemble an instruction, producing a printable - representation on a specified stdio stream. This isn't - defined for most processors at present, because of the size - of the additional tables it would drag in, and because gdb - wants to use a different interface. */ - unsigned int (*disassemble) PARAMS ((bfd_vma addr, CONST char *data, - PTR stream)); - - struct bfd_arch_info *next; + const struct bfd_arch_info * (*compatible) + PARAMS ((const struct bfd_arch_info *a, + const struct bfd_arch_info *b)); + + boolean (*scan) PARAMS ((const struct bfd_arch_info *, const char *)); + + const struct bfd_arch_info *next; } bfd_arch_info_type; -CONST char * +const char * bfd_printable_name PARAMS ((bfd *abfd)); -bfd_arch_info_type * -bfd_scan_arch PARAMS ((CONST char *string)); +const bfd_arch_info_type * +bfd_scan_arch PARAMS ((const char *string)); -CONST bfd_arch_info_type * +const bfd_arch_info_type * bfd_arch_get_compatible PARAMS (( - CONST bfd *abfd, - CONST bfd *bbfd)); + const bfd *abfd, + const bfd *bbfd)); void -bfd_set_arch_info PARAMS ((bfd *abfd, bfd_arch_info_type *arg)); +bfd_set_arch_info PARAMS ((bfd *abfd, const bfd_arch_info_type *arg)); enum bfd_architecture bfd_get_arch PARAMS ((bfd *abfd)); @@ -1125,16 +1118,16 @@ bfd_arch_bits_per_byte PARAMS ((bfd *abfd)); unsigned int bfd_arch_bits_per_address PARAMS ((bfd *abfd)); -bfd_arch_info_type * +const bfd_arch_info_type * bfd_get_arch_info PARAMS ((bfd *abfd)); -bfd_arch_info_type * +const bfd_arch_info_type * bfd_lookup_arch PARAMS ((enum bfd_architecture arch, unsigned long machine)); -CONST char * +const char * bfd_printable_arch_mach PARAMS ((enum bfd_architecture arch, unsigned long machine)); @@ -1849,7 +1842,7 @@ struct _bfd struct symbol_cache_entry **outsymbols; /* Pointer to structure which contains architecture information*/ - struct bfd_arch_info *arch_info; + const struct bfd_arch_info *arch_info; /* Stuff only useful for archives:*/ PTR arelt_data; diff --git a/bfd/bfd.c b/bfd/bfd.c index 7cf65f651b7..006b20197ad 100644 --- a/bfd/bfd.c +++ b/bfd/bfd.c @@ -127,7 +127,7 @@ CODE_FRAGMENT . struct symbol_cache_entry **outsymbols; . . {* Pointer to structure which contains architecture information*} -. struct bfd_arch_info *arch_info; +. const struct bfd_arch_info *arch_info; . . {* Stuff only useful for archives:*} . PTR arelt_data; diff --git a/bfd/configure b/bfd/configure index ff2b97aad43..02a54301d85 100755 --- a/bfd/configure +++ b/bfd/configure @@ -1424,7 +1424,7 @@ else # all_targets is true test -n "$selvecs" && selvecs=`echo $selvecs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'` test -n "$selarchs" && - selarchs=`echo $selarchs | sed -e 's/ \(.\)/,\1/g'` + selarchs=`echo $selarchs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'` fi # all_targets is true case ${host64}-${target64}-${want64} in diff --git a/bfd/configure.in b/bfd/configure.in index cb50ff19b87..c0669bc3b05 100644 --- a/bfd/configure.in +++ b/bfd/configure.in @@ -469,7 +469,7 @@ else # all_targets is true test -n "$selvecs" && selvecs=`echo $selvecs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'` test -n "$selarchs" && - selarchs=`echo $selarchs | sed -e 's/ \(.\)/,\1/g'` + selarchs=`echo $selarchs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'` fi # all_targets is true case ${host64}-${target64}-${want64} in diff --git a/bfd/cpu-a29k.c b/bfd/cpu-a29k.c index 36015513c3c..5bd25a47720 100644 --- a/bfd/cpu-a29k.c +++ b/bfd/cpu-a29k.c @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "sysdep.h" #include "libbfd.h" -static bfd_arch_info_type arch_info_struct = +const bfd_arch_info_type bfd_a29k_arch = { 32, /* 32 bits in a word */ 32, /* 32 bits in an address */ @@ -37,9 +37,3 @@ static bfd_arch_info_type arch_info_struct = bfd_default_scan , 0, }; - -void -bfd_a29k_arch () -{ - bfd_arch_linkin(&arch_info_struct); -} diff --git a/bfd/cpu-rce.c b/bfd/cpu-rce.c index e597e875844..ab2e2160798 100644 --- a/bfd/cpu-rce.c +++ b/bfd/cpu-rce.c @@ -25,9 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ int bfd_default_scan_num_mach(); static boolean -DEFUN(scan_mach,(info, string), -CONST struct bfd_arch_info *info AND -CONST char *string) +scan_mach (info, string) + const struct bfd_arch_info *info; + const char *string; { if (strcmp(string,"rce") == 0) return true; if (strcmp(string,"RCE") == 0) return true; @@ -39,10 +39,10 @@ CONST char *string) /* This routine is provided two arch_infos and returns whether they'd be compatible */ -static CONST bfd_arch_info_type * +static const bfd_arch_info_type * DEFUN(compatible,(a,b), - CONST bfd_arch_info_type *a AND - CONST bfd_arch_info_type *b) + const bfd_arch_info_type *a AND + const bfd_arch_info_type *b) { if (a->arch != b->arch || a->mach != b->mach) return NULL; @@ -50,29 +50,18 @@ DEFUN(compatible,(a,b), } #endif -static bfd_arch_info_type arch_info_struct[] = -{ - { - 32, /* 32 bits in a word */ - 32, /* 32 bits in an address */ - 8, /* 8 bits in a byte */ - bfd_arch_rce, - 0, /* only 1 machine */ - "RCE", /* arch_name */ - "RCE", /* printable name */ - 1, - true, /* the default machine */ - bfd_default_compatible, - scan_mach, - 0, - 0, - }, -}; - - - -void -DEFUN_VOID(bfd_rce_arch) +const bfd_arch_info_type bfd_rce_arch = { - bfd_arch_linkin(&arch_info_struct[0]); -} + 32, /* 32 bits in a word */ + 32, /* 32 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_rce, + 0, /* only 1 machine */ + "RCE", /* arch_name */ + "RCE", /* printable name */ + 1, + true, /* the default machine */ + bfd_default_compatible, + scan_mach, + 0, +}; diff --git a/bfd/init.c b/bfd/init.c index ad1785305f3..9f96bce1934 100644 --- a/bfd/init.c +++ b/bfd/init.c @@ -1,5 +1,5 @@ /* bfd initialization stuff - Copyright (C) 1990-1991 Free Software Foundation, Inc. + Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc. Written by Steve Chamberlain of Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -16,13 +16,13 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "sysdep.h" #include "libbfd.h" -extern void DEFUN_VOID (bfd_section_init); +extern void bfd_section_init (); static boolean initialized = false; @@ -41,18 +41,17 @@ SYNOPSIS void bfd_init(void); DESCRIPTION - This routine must be called before any other libbfd function to + This routine must be called before any other BFD function to initialize magical internal data structures. */ void bfd_init () { - if (initialized == false) { - initialized = true; - - bfd_arch_init(); - } + if (initialized == false) + { + initialized = true; + } } @@ -64,9 +63,9 @@ SYNOPSIS void bfd_check_init(void); DESCRIPTION - This routine is called before any other libbfd function using + This routine is called before any other BFD function using initialized data. It ensures that the structures have - been initialized. Soon this function will go away, and the bfd + been initialized. Soon this function will go away, and the BFD library will assume that <> has been called. */ diff --git a/bfd/libbfd.h b/bfd/libbfd.h index 1850bf8b664..2aaeb8a2606 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -663,25 +663,19 @@ bfd_generic_get_relocated_section_contents PARAMS ((bfd *abfd, boolean relocateable, asymbol **symbols)); -extern bfd_arch_info_type bfd_default_arch_struct; +extern const bfd_arch_info_type bfd_default_arch_struct; boolean bfd_default_set_arch_mach PARAMS ((bfd *abfd, enum bfd_architecture arch, unsigned long mach)); -void -bfd_arch_init PARAMS ((void)); - -void -bfd_arch_linkin PARAMS ((bfd_arch_info_type *ptr)); - -CONST bfd_arch_info_type * +const bfd_arch_info_type * bfd_default_compatible - PARAMS ((CONST bfd_arch_info_type *a, - CONST bfd_arch_info_type *b)); + PARAMS ((const bfd_arch_info_type *a, + const bfd_arch_info_type *b)); boolean -bfd_default_scan PARAMS ((CONST struct bfd_arch_info *info, CONST char *string)); +bfd_default_scan PARAMS ((const struct bfd_arch_info *info, const char *string)); struct elf_internal_shdr * bfd_elf_find_section PARAMS ((bfd *abfd, char *name));