From 45dfa85a1ee44000d43abb7945a4aa7631707563 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sat, 5 May 2012 03:05:32 +0000 Subject: Replace all uses of bfd_abs_section, bfd_com_section, bfd_und_section and bfd_ind_section with their _ptr variants, or use corresponding bfd_is_* macros. --- bfd/ChangeLog | 24 +++++++++++++++++++++++ bfd/aout-arm.c | 10 +++++----- bfd/aout-ns32k.c | 8 ++++---- bfd/aout-tic30.c | 6 +++--- bfd/coff-arm.c | 6 +++--- bfd/coff-tic54x.c | 10 +++++----- bfd/cpu-ns32k.c | 6 +++--- bfd/elf-attrs.c | 12 ++++++------ bfd/elfcode.h | 4 ++-- bfd/peicode.h | 5 +++-- bfd/reloc.c | 2 +- bfd/riscix.c | 10 +++++----- bfd/section.c | 58 +++++++++++++++++++++++++++---------------------------- bfd/versados.c | 6 +++--- 14 files changed, 95 insertions(+), 72 deletions(-) (limited to 'bfd') diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 733c546..21ecb1e 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,27 @@ +2012-05-05 Alan Modra + + * aout-arm.c: Replace all uses of bfd_abs_section, bfd_com_section, + bfd_und_section and bfd_ind_section with their _ptr variants, or + use corresponding bfd_is_* macros. + * aout-ns32k.c: Likewise. + * aout-tic30.c: Likewise. + * coff-arm.c: Likewise. + * coff-tic54x.c: Likewise. + * cpu-ns32k.c: Likewise. + * elf-attrs.c: Likewise. + * elfcode.h: Likewise. + * peicode.h: Likewise. + * reloc.c: Likewise. + * riscix.c: Likewise. + * versados.c: Likewise. + * section.c: Likewise. + (bfd_abs_section, bfd_ind_section, bfd_com_section, + bfd_ind_section): Delete. + (std_section): New array replacing above. + (bfd_abs_section_ptr, bfd_ind_section_ptr, bfd_com_section_ptr, + bfd_ind_section_ptr, STD_SECTION): Update. + (BFD_FAKE_SECTION, GLOBAL_SYM_INIT): Remove unnecessary casts. + 2012-05-03 Sean Keys * cpu-xgate.c: New file. Added XGATE support. diff --git a/bfd/aout-arm.c b/bfd/aout-arm.c index fd93603..9eb9488 100644 --- a/bfd/aout-arm.c +++ b/bfd/aout-arm.c @@ -1,6 +1,6 @@ /* BFD back-end for raw ARM a.out binaries. Copyright 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, - 2007, 2009, 2010, 2011 Free Software Foundation, Inc. + 2007, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org) This file is part of BFD, the Binary File Descriptor library. @@ -247,7 +247,7 @@ MY (fix_pcrel_26) (bfd *abfd, bfd_reloc_status_type flag = bfd_reloc_ok; /* If this is an undefined symbol, return error. */ - if (symbol->section == &bfd_und_section + if (bfd_is_und_section (symbol->section) && (symbol->flags & BSF_WEAK) == 0) return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined; @@ -409,10 +409,10 @@ MY_swap_std_reloc_out (bfd *abfd, check for that here. */ if (bfd_is_com_section (output_section) - || output_section == &bfd_abs_section - || output_section == &bfd_und_section) + || bfd_is_abs_section (output_section) + || bfd_is_und_section (output_section)) { - if (bfd_abs_section.symbol == sym) + if (bfd_abs_section_ptr->symbol == sym) { /* Whoops, looked like an abs symbol, but is really an offset from the abs section. */ diff --git a/bfd/aout-ns32k.c b/bfd/aout-ns32k.c index 9a0737d..5cf5ad4 100644 --- a/bfd/aout-ns32k.c +++ b/bfd/aout-ns32k.c @@ -1,6 +1,6 @@ /* BFD back-end for ns32k a.out-ish binaries. Copyright 1990, 1991, 1992, 1994, 1995, 1996, 1998, 1999, 2000, 2001, - 2002, 2003, 2005, 2006, 2007, 2010 Free Software Foundation, Inc. + 2002, 2003, 2005, 2006, 2007, 2010, 2012 Free Software Foundation, Inc. Contributed by Ian Dall (idall@eleceng.adelaide.edu.au). This file is part of BFD, the Binary File Descriptor library. @@ -303,10 +303,10 @@ MY_swap_std_reloc_out (bfd *abfd, from the abs section, or as a symbol which has an abs value. Check for that here. */ if (bfd_is_com_section (output_section) - || output_section == &bfd_abs_section - || output_section == &bfd_und_section) + || bfd_is_abs_section (output_section) + || bfd_is_und_section (output_section)) { - if (bfd_abs_section.symbol == sym) + if (bfd_abs_section_ptr->symbol == sym) { /* Whoops, looked like an abs symbol, but is really an offset from the abs section. */ diff --git a/bfd/aout-tic30.c b/bfd/aout-tic30.c index 0b01177..f3b0d36 100644 --- a/bfd/aout-tic30.c +++ b/bfd/aout-tic30.c @@ -1,6 +1,6 @@ /* BFD back-end for TMS320C30 a.out binaries. Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2009, - 2010, 2011 + 2010, 2011, 2012 Free Software Foundation, Inc. Contributed by Steven Haworth (steve@pm.cse.rmit.edu.au) @@ -189,7 +189,7 @@ tic30_aout_fix_16 (bfd *abfd, bfd_vma relocation; /* Make sure that the symbol's section is defined. */ - if (symbol->section == &bfd_und_section && (symbol->flags & BSF_WEAK) == 0) + if (bfd_is_und_section (symbol->section) && (symbol->flags & BSF_WEAK) == 0) return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined; /* Get the size of the input section and turn it into the TMS320C30 32-bit address format. */ @@ -214,7 +214,7 @@ tic30_aout_fix_32 (bfd *abfd, bfd_vma relocation; /* Make sure that the symbol's section is defined. */ - if (symbol->section == &bfd_und_section && (symbol->flags & BSF_WEAK) == 0) + if (bfd_is_und_section (symbol->section) && (symbol->flags & BSF_WEAK) == 0) return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined; /* Get the size of the input section and turn it into the TMS320C30 32-bit address format. */ diff --git a/bfd/coff-arm.c b/bfd/coff-arm.c index bdadfb2..4cdf1ac 100644 --- a/bfd/coff-arm.c +++ b/bfd/coff-arm.c @@ -1,6 +1,6 @@ /* BFD back-end for ARM COFF files. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Free Software Foundation, Inc. Written by Cygnus Support. @@ -599,7 +599,7 @@ aoutarm_fix_pcrel_26 (bfd *abfd, bfd_reloc_status_type flag = bfd_reloc_ok; /* If this is an undefined symbol, return error. */ - if (symbol->section == &bfd_und_section + if (bfd_is_und_section (symbol->section) && (symbol->flags & BSF_WEAK) == 0) return output_bfd ? bfd_reloc_continue : bfd_reloc_undefined; @@ -687,7 +687,7 @@ coff_thumb_pcrel_common (bfd *abfd, } /* If this is an undefined symbol, return error. */ - if (symbol->section == &bfd_und_section + if (bfd_is_und_section (symbol->section) && (symbol->flags & BSF_WEAK) == 0) return output_bfd ? bfd_reloc_continue : bfd_reloc_undefined; diff --git a/bfd/coff-tic54x.c b/bfd/coff-tic54x.c index 3c353da..e1b3ccb 100644 --- a/bfd/coff-tic54x.c +++ b/bfd/coff-tic54x.c @@ -1,5 +1,5 @@ /* BFD back-end for TMS320C54X coff binaries. - Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2011 + Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2011, 2012 Free Software Foundation, Inc. Contributed by Timothy Wall (twall@cygnus.com) @@ -111,12 +111,12 @@ bfd_ticoff_get_section_load_page (sect) int page; /* Provide meaningful defaults for predefined sections. */ - if (sect == &bfd_com_section) + if (sect == bfd_com_section_ptr) page = PG_DATA; - else if (sect == &bfd_und_section - || sect == &bfd_abs_section - || sect == &bfd_ind_section) + else if (bfd_is_und_section (sect) + || bfd_is_abs_section (sect) + || bfd_is_ind_section (sect)) page = PG_PROG; else diff --git a/bfd/cpu-ns32k.c b/bfd/cpu-ns32k.c index 28fff5a..4c2dce1 100644 --- a/bfd/cpu-ns32k.c +++ b/bfd/cpu-ns32k.c @@ -1,6 +1,6 @@ /* BFD support for the ns32k architecture. Copyright 1990, 1991, 1994, 1995, 1998, 1999, 2000, 2001, 2002, 2003, - 2004, 2005, 2007 Free Software Foundation, Inc. + 2004, 2005, 2007, 2012 Free Software Foundation, Inc. Almost totally rewritten by Ian Dall from initial work by Andrew Cagney. @@ -177,7 +177,7 @@ do_ns32k_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, asection *reloc_target_output_section; bfd_byte *location; - if ((symbol->section == &bfd_abs_section) + if (bfd_is_abs_section (symbol->section) && output_bfd != (bfd *) NULL) { reloc_entry->address += input_section->output_offset; @@ -187,7 +187,7 @@ do_ns32k_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, /* If we are not producing relocatable output, return an error if the symbol is not defined. An undefined weak symbol is considered to have a value of zero (SVR4 ABI, p. 4-27). */ - if (symbol->section == &bfd_und_section + if (bfd_is_und_section (symbol->section) && (symbol->flags & BSF_WEAK) == 0 && output_bfd == (bfd *) NULL) flag = bfd_reloc_undefined; diff --git a/bfd/elf-attrs.c b/bfd/elf-attrs.c index 569e846..4237af5 100644 --- a/bfd/elf-attrs.c +++ b/bfd/elf-attrs.c @@ -1,5 +1,5 @@ /* ELF attributes support (based on ARM EABI attributes). - Copyright 2005, 2006, 2007, 2009, 2010 + Copyright 2005, 2006, 2007, 2009, 2010, 2012 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -428,7 +428,7 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr) bfd_byte *contents; bfd_byte *p; bfd_vma len; - const char *std_section; + const char *std_sec; contents = (bfd_byte *) bfd_malloc (hdr->sh_size); if (!contents) @@ -440,7 +440,7 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr) return; } p = contents; - std_section = get_elf_backend_data (abfd)->obj_attrs_vendor; + std_sec = get_elf_backend_data (abfd)->obj_attrs_vendor; if (*(p++) == 'A') { len = hdr->sh_size - 1; @@ -455,11 +455,11 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr) if (section_len > len) section_len = len; len -= section_len; - namelen = strlen ((char *)p) + 1; + namelen = strlen ((char *) p) + 1; section_len -= namelen + 4; - if (std_section && strcmp ((char *)p, std_section) == 0) + if (std_sec && strcmp ((char *) p, std_sec) == 0) vendor = OBJ_ATTR_PROC; - else if (strcmp ((char *)p, "gnu") == 0) + else if (strcmp ((char *) p, "gnu") == 0) vendor = OBJ_ATTR_GNU; else { diff --git a/bfd/elfcode.h b/bfd/elfcode.h index 2244874..c985c63 100644 --- a/bfd/elfcode.h +++ b/bfd/elfcode.h @@ -1,6 +1,6 @@ /* ELF executable support for BFD. Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 + 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. Written by Fred Fish @ Cygnus Support, from information published @@ -1450,7 +1450,7 @@ elf_slurp_reloc_table_from_section (bfd *abfd, (*_bfd_error_handler) (_("%s(%s): relocation %d has invalid symbol index %ld"), abfd->filename, asect->name, i, ELF_R_SYM (rela.r_info)); - relent->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr; + relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; } else { diff --git a/bfd/peicode.h b/bfd/peicode.h index 5d10029..e835792 100644 --- a/bfd/peicode.h +++ b/bfd/peicode.h @@ -1,6 +1,7 @@ /* Support for the generic parts of PE/PEI, for BFD. Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. + 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 + Free Software Foundation, Inc. Written by Cygnus Solutions. This file is part of BFD, the Binary File Descriptor library. @@ -545,7 +546,7 @@ pe_ILF_make_a_symbol (pe_ILF_vars * vars, sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); if (section == NULL) - section = (asection_ptr) & bfd_und_section; + section = bfd_und_section_ptr; /* Initialise the external symbol. */ H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, diff --git a/bfd/reloc.c b/bfd/reloc.c index 0ec1b61..29c54c8 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -6448,7 +6448,7 @@ bfd_generic_get_relocated_section_contents (bfd *abfd, p = data + (*parent)->address * bfd_octets_per_byte (input_bfd); _bfd_clear_contents ((*parent)->howto, input_bfd, input_section, p); - (*parent)->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr; + (*parent)->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; (*parent)->addend = 0; (*parent)->howto = &none_howto; r = bfd_reloc_ok; diff --git a/bfd/riscix.c b/bfd/riscix.c index 0d07d01..7e24fd9 100644 --- a/bfd/riscix.c +++ b/bfd/riscix.c @@ -1,6 +1,6 @@ /* BFD back-end for RISC iX (Acorn, arm) binaries. Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, - 2005, 2007, 2010 Free Software Foundation, Inc. + 2005, 2007, 2010, 2012 Free Software Foundation, Inc. Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org) This file is part of BFD, the Binary File Descriptor library. @@ -207,7 +207,7 @@ riscix_fix_pcrel_26 (bfd *abfd, bfd_reloc_status_type flag = bfd_reloc_ok; /* If this is an undefined symbol, return error. */ - if (symbol->section == &bfd_und_section + if (bfd_is_und_section (symbol->section) && (symbol->flags & BSF_WEAK) == 0) return output_bfd ? bfd_reloc_continue : bfd_reloc_undefined; @@ -341,10 +341,10 @@ riscix_swap_std_reloc_out (bfd *abfd, check for that here. */ if (bfd_is_com_section (output_section) - || output_section == & bfd_abs_section - || output_section == & bfd_und_section) + || bfd_is_abs_section (output_section) + || bfd_is_und_section (output_section)) { - if (bfd_abs_section.symbol == sym) + if (bfd_abs_section_ptr->symbol == sym) { /* Whoops, looked like an abs symbol, but is really an offset from the abs section. */ diff --git a/bfd/section.c b/bfd/section.c index 9eb7f69..db7e239 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -547,28 +547,25 @@ CODE_FRAGMENT . .{* These sections are global, and are managed by BFD. The application . and target back end are not permitted to change the values in -. these sections. New code should use the section_ptr macros rather -. than referring directly to the const sections. The const sections -. may eventually vanish. *} +. these sections. *} +.extern asection std_section[4]; +. .#define BFD_ABS_SECTION_NAME "*ABS*" .#define BFD_UND_SECTION_NAME "*UND*" .#define BFD_COM_SECTION_NAME "*COM*" .#define BFD_IND_SECTION_NAME "*IND*" . -.{* The absolute section. *} -.extern asection bfd_abs_section; -.#define bfd_abs_section_ptr ((asection *) &bfd_abs_section) -.#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr) -.{* Pointer to the undefined section. *} -.extern asection bfd_und_section; -.#define bfd_und_section_ptr ((asection *) &bfd_und_section) -.#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr) .{* Pointer to the common section. *} -.extern asection bfd_com_section; -.#define bfd_com_section_ptr ((asection *) &bfd_com_section) +.#define bfd_com_section_ptr (&std_section[0]) +.{* Pointer to the undefined section. *} +.#define bfd_und_section_ptr (&std_section[1]) +.{* Pointer to the absolute section. *} +.#define bfd_abs_section_ptr (&std_section[2]) .{* Pointer to the indirect section. *} -.extern asection bfd_ind_section; -.#define bfd_ind_section_ptr ((asection *) &bfd_ind_section) +.#define bfd_ind_section_ptr (&std_section[3]) +. +.#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr) +.#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr) .#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr) . .#define bfd_is_const_section(SEC) \ @@ -683,8 +680,8 @@ CODE_FRAGMENT . {* vma, lma, size, rawsize, compressed_size, relax, relax_count, *} \ . 0, 0, 0, 0, 0, 0, 0, \ . \ -. {* output_offset, output_section, alignment_power, *} \ -. 0, (struct bfd_section *) &SEC, 0, \ +. {* output_offset, output_section, alignment_power, *} \ +. 0, &SEC, 0, \ . \ . {* relocation, orelocation, reloc_count, filepos, rel_filepos, *} \ . NULL, NULL, 0, 0, 0, \ @@ -716,10 +713,10 @@ CODE_FRAGMENT /* the_bfd, name, value, attr, section [, udata] */ #ifdef __STDC__ #define GLOBAL_SYM_INIT(NAME, SECTION) \ - { 0, NAME, 0, BSF_SECTION_SYM, (asection *) SECTION, { 0 }} + { 0, NAME, 0, BSF_SECTION_SYM, SECTION, { 0 }} #else #define GLOBAL_SYM_INIT(NAME, SECTION) \ - { 0, NAME, 0, BSF_SECTION_SYM, (asection *) SECTION } + { 0, NAME, 0, BSF_SECTION_SYM, SECTION } #endif /* These symbols are global, not specific to any BFD. Therefore, anything @@ -727,20 +724,21 @@ CODE_FRAGMENT static const asymbol global_syms[] = { - GLOBAL_SYM_INIT (BFD_COM_SECTION_NAME, &bfd_com_section), - GLOBAL_SYM_INIT (BFD_UND_SECTION_NAME, &bfd_und_section), - GLOBAL_SYM_INIT (BFD_ABS_SECTION_NAME, &bfd_abs_section), - GLOBAL_SYM_INIT (BFD_IND_SECTION_NAME, &bfd_ind_section) + GLOBAL_SYM_INIT (BFD_COM_SECTION_NAME, bfd_com_section_ptr), + GLOBAL_SYM_INIT (BFD_UND_SECTION_NAME, bfd_und_section_ptr), + GLOBAL_SYM_INIT (BFD_ABS_SECTION_NAME, bfd_abs_section_ptr), + GLOBAL_SYM_INIT (BFD_IND_SECTION_NAME, bfd_ind_section_ptr) }; -#define STD_SECTION(SEC, FLAGS, NAME, IDX) \ - asection SEC = BFD_FAKE_SECTION(SEC, FLAGS, &global_syms[IDX], \ - NAME, IDX) +#define STD_SECTION(NAME, IDX, FLAGS) \ + BFD_FAKE_SECTION(std_section[IDX], FLAGS, &global_syms[IDX], NAME, IDX) -STD_SECTION (bfd_com_section, SEC_IS_COMMON, BFD_COM_SECTION_NAME, 0); -STD_SECTION (bfd_und_section, 0, BFD_UND_SECTION_NAME, 1); -STD_SECTION (bfd_abs_section, 0, BFD_ABS_SECTION_NAME, 2); -STD_SECTION (bfd_ind_section, 0, BFD_IND_SECTION_NAME, 3); +asection std_section[] = { + STD_SECTION (BFD_COM_SECTION_NAME, 0, SEC_IS_COMMON), + STD_SECTION (BFD_UND_SECTION_NAME, 1, 0), + STD_SECTION (BFD_ABS_SECTION_NAME, 2, 0), + STD_SECTION (BFD_IND_SECTION_NAME, 3, 0) +}; #undef STD_SECTION /* Initialize an entry in the section hash table. */ diff --git a/bfd/versados.c b/bfd/versados.c index 7f7766a..ae6f671 100644 --- a/bfd/versados.c +++ b/bfd/versados.c @@ -1,6 +1,6 @@ /* BFD back-end for VERSAdos-E objects. Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2009, 2010, 2011 Free Software Foundation, Inc. + 2006, 2007, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. Written by Steve Chamberlain of Cygnus Support . Versados is a Motorola trademark. @@ -287,7 +287,7 @@ process_esd (bfd *abfd, struct ext_esd *esd, int pass) sec->flags |= SEC_ALLOC; break; case ESD_XDEF_IN_ABS: - sec = (asection *) & bfd_abs_section; + sec = bfd_abs_section_ptr; case ESD_XDEF_IN_SEC: { int snum = VDATA (abfd)->def_idx++; @@ -768,7 +768,7 @@ versados_canonicalize_reloc (bfd *abfd, int esdid = (int) (size_t) src[count].sym_ptr_ptr; if (esdid == 0) - src[count].sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr; + src[count].sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; else if (esdid < ES_BASE) { /* Section relative thing. */ -- cgit v1.1