From 382f2a3d75c1c09a1b63334d045d13f621a7a32b Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 26 Jan 1993 19:54:07 +0000 Subject: [PATCH] Tue Jan 26 11:43:14 1993 Ian Lance Taylor (ian@cygnus.com) * section.c (SEC_IS_COMMON): New section flag, needed for MIPS ECOFF which has two common sections. (bfd_com_section): Set SEC_IS_COMMON flag. * bfd-in.h (bfd_is_com_section): New macro to test SEC_IS_COMMON. * aoutx.h, archive.c, bout.c, coff-a29k.c, coff-m88k.c, coff-mips.c, coffgen.c, ieee.c, oasys.c, reloc.c, syms.: Use bfd_is_com_section macro rather than checking for equality to bfd_com_section. --- bfd/ChangeLog | 11 +++++++++++ bfd/aoutx.h | 30 +++++++++++++++--------------- bfd/bout.c | 6 +++--- bfd/coff-a29k.c | 2 +- bfd/coff-mips.c | 28 +++++++++++----------------- 5 files changed, 41 insertions(+), 36 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 37b90fa3b0..733191580d 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,14 @@ +Tue Jan 26 11:43:14 1993 Ian Lance Taylor (ian@cygnus.com) + + * section.c (SEC_IS_COMMON): New section flag, needed for MIPS + ECOFF which has two common sections. + (bfd_com_section): Set SEC_IS_COMMON flag. + * bfd-in.h (bfd_is_com_section): New macro to test SEC_IS_COMMON. + * aoutx.h, archive.c, bout.c, coff-a29k.c, coff-m88k.c, + coff-mips.c, coffgen.c, ieee.c, oasys.c, reloc.c, syms.: Use + bfd_is_com_section macro rather than checking for equality to + bfd_com_section. + Mon Jan 25 15:27:36 1993 Ian Lance Taylor (ian@cygnus.com) * coffcode.h (_bfd_coff_mkobject_hook): Pass aouthdr argument. diff --git a/bfd/aoutx.h b/bfd/aoutx.h index eeaa2ba306..2c5907dedb 100644 --- a/bfd/aoutx.h +++ b/bfd/aoutx.h @@ -1213,7 +1213,7 @@ DEFUN(translate_to_native_sym_flags,(sym_pointer, cache_ptr, abfd), { sym_pointer->e_type[0] = (N_UNDF | N_EXT); } - else if (bfd_get_output_section(cache_ptr) == &bfd_com_section) { + else if (bfd_is_com_section (bfd_get_output_section (cache_ptr))) { sym_pointer->e_type[0] = (N_UNDF | N_EXT); } else { @@ -1469,7 +1469,7 @@ DEFUN(NAME(aout,swap_std_reloc_out),(abfd, g, natptr), */ - if (output_section == &bfd_com_section + if (bfd_is_com_section (output_section) || output_section == &bfd_abs_section || output_section == &bfd_und_section) { @@ -1553,7 +1553,7 @@ DEFUN(NAME(aout,swap_ext_reloc_out),(abfd, g, natptr), check for that here */ - if (output_section == &bfd_com_section + if (bfd_is_com_section (output_section) || output_section == &bfd_abs_section || output_section == &bfd_und_section) { @@ -1656,16 +1656,16 @@ DEFUN(NAME(aout,swap_ext_reloc_in), (abfd, bytes, cache_ptr, symbols), /* now the fun stuff */ if (abfd->xvec->header_byteorder_big_p != false) { - r_index = ( ((int) bytes->r_index[0] << 16) - | ((int) bytes->r_index[1] << 8) - | (int) bytes->r_index[2]); + r_index = (bytes->r_index[0] << 16) + | (bytes->r_index[1] << 8) + | bytes->r_index[2]; r_extern = (0 != (bytes->r_type[0] & RELOC_EXT_BITS_EXTERN_BIG)); r_type = (bytes->r_type[0] & RELOC_EXT_BITS_TYPE_BIG) >> RELOC_EXT_BITS_TYPE_SH_BIG; } else { - r_index = ( ((int) bytes->r_index[2] << 16) - | ((int) bytes->r_index[1] << 8) - | (int) bytes->r_index[0]); + r_index = (bytes->r_index[2] << 16) + | (bytes->r_index[1] << 8) + | bytes->r_index[0]; r_extern = (0 != (bytes->r_type[0] & RELOC_EXT_BITS_EXTERN_LITTLE)); r_type = (bytes->r_type[0] & RELOC_EXT_BITS_TYPE_LITTLE) >> RELOC_EXT_BITS_TYPE_SH_LITTLE; @@ -1693,9 +1693,9 @@ DEFUN(NAME(aout,swap_std_reloc_in), (abfd, bytes, cache_ptr, symbols), /* now the fun stuff */ if (abfd->xvec->header_byteorder_big_p != false) { - r_index = ( ((int) bytes->r_index[0] << 16) - | ((int) bytes->r_index[1] << 8) - | (int) bytes->r_index[2]); + r_index = (bytes->r_index[0] << 16) + | (bytes->r_index[1] << 8) + | bytes->r_index[2]; r_extern = (0 != (bytes->r_type[0] & RELOC_STD_BITS_EXTERN_BIG)); r_pcrel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_PCREL_BIG)); r_baserel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_BASEREL_BIG)); @@ -1704,9 +1704,9 @@ DEFUN(NAME(aout,swap_std_reloc_in), (abfd, bytes, cache_ptr, symbols), r_length = (bytes->r_type[0] & RELOC_STD_BITS_LENGTH_BIG) >> RELOC_STD_BITS_LENGTH_SH_BIG; } else { - r_index = ( ((int) bytes->r_index[2] << 16) - | ((int) bytes->r_index[1] << 8) - | (int) bytes->r_index[0]); + r_index = (bytes->r_index[2] << 16) + | (bytes->r_index[1] << 8) + | bytes->r_index[0]; r_extern = (0 != (bytes->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE)); r_pcrel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE)); r_baserel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_BASEREL_LITTLE)); diff --git a/bfd/bout.c b/bfd/bout.c index 25a6b256a9..23687b38b0 100644 --- a/bfd/bout.c +++ b/bfd/bout.c @@ -522,11 +522,11 @@ b_out_slurp_reloc_table (abfd, asect, symbols) cache_ptr->howto = 0; if (abfd->xvec->header_byteorder_big_p) { - symnum = ((int) raw[4] << 16) | ((int) raw[5] << 8) | (int) raw[6]; + symnum = (raw[4] << 16) | (raw[5] << 8) | raw[6]; } else { - symnum = ((int) raw[6] << 16) | ((int) raw[5] << 8) | (int) raw[4]; + symnum = (raw[6] << 16) | (raw[5] << 8) | raw[4]; } if (raw[7] & extern_mask) @@ -745,7 +745,7 @@ b_out_squirt_out_relocs (abfd, section) if (r_idx != 0) /* already mucked with r_extern, r_idx */; - else if (output_section == &bfd_com_section + else if (bfd_is_com_section (output_section) || output_section == &bfd_abs_section || output_section == &bfd_und_section) { diff --git a/bfd/coff-a29k.c b/bfd/coff-a29k.c index 3dd4fac436..ccc50f6335 100644 --- a/bfd/coff-a29k.c +++ b/bfd/coff-a29k.c @@ -42,7 +42,7 @@ asymbol *symbol; { long relocation = 0; - if (symbol->section == &bfd_com_section) + if (bfd_is_com_section (symbol->section)) { relocation = 0; } diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c index 57dd096f1a..210a493f95 100644 --- a/bfd/coff-mips.c +++ b/bfd/coff-mips.c @@ -191,7 +191,7 @@ DEFUN (ecoff_new_section_hook, (abfd, section), section->flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC | SEC_READONLY; else if (strcmp (section->name, _BSS) == 0 || strcmp (section->name, _SBSS) == 0) - section->flags |= SEC_ALLOC; + section->flags |= SEC_ALLOC | SEC_IS_COMMON; /* Probably any other section name is SEC_NEVER_LOAD, but I'm uncertain about .init on some systems and I don't know how shared @@ -617,17 +617,8 @@ DEFUN (ecoff_set_symbol_info, (abfd, ecoff_sym, asym, ext), asym->value -= asym->section->vma; break; case scSBss: - /* FIXME: putting global .sbss symbols in the common section is - wrong, because it means they may not be accessible via the gp - register. But the linker checks the section a symbol is in - rather than checking the flags. */ - if (ext) - asym->section = &bfd_com_section; - else - { - asym->section = bfd_make_section_old_way (abfd, ".sbss"); - asym->value -= asym->section->vma; - } + asym->section = bfd_make_section_old_way (abfd, ".sbss"); + asym->value -= asym->section->vma; break; case scRData: asym->section = bfd_make_section_old_way (abfd, ".rdata"); @@ -637,9 +628,12 @@ DEFUN (ecoff_set_symbol_info, (abfd, ecoff_sym, asym, ext), asym->flags = BSF_DEBUGGING; break; case scCommon: - case scSCommon: asym->section = &bfd_com_section; break; + case scSCommon: + asym->section = bfd_make_section_old_way (abfd, ".sbss"); + asym->value -= asym->section->vma; + break; case scVarRegister: case scVariant: asym->flags = BSF_DEBUGGING; @@ -1408,7 +1402,7 @@ DEFUN (ecoff_refhi_reloc, (abfd, BFD_ASSERT (rello->howto->type == ECOFF_R_REFLO && *rello->sym_ptr_ptr == *reloc_entry->sym_ptr_ptr); - if (symbol->section == &bfd_com_section) + if (bfd_is_com_section (symbol->section)) relocation = 0; else relocation = symbol->value; @@ -1527,7 +1521,7 @@ DEFUN (ecoff_gprel_reloc, (abfd, } } - if (symbol->section == &bfd_com_section) + if (bfd_is_com_section (symbol->section)) relocation = 0; else relocation = symbol->value; @@ -2355,7 +2349,7 @@ DEFUN (ecoff_get_debug, (output_bfd, seclet, section), SYMR sym; ecoff_swap_sym_in (input_bfd, esym_ptr->native.lnative, &sym); - if (esym_ptr->symbol.section != &bfd_com_section + if (! bfd_is_com_section (esym_ptr->symbol.section) && (esym_ptr->symbol.flags & BSF_DEBUGGING) == 0 && esym_ptr->symbol.section != &bfd_und_section) sym.value = (esym_ptr->symbol.value @@ -2814,7 +2808,7 @@ DEFUN (ecoff_bfd_seclet_link, (abfd, data, relocateable), esym.asym.iss = symhdr->issExtMax; - if (sym_ptr->section == &bfd_com_section + if (bfd_is_com_section (sym_ptr->section) || sym_ptr->section == &bfd_und_section) esym.asym.value = sym_ptr->value; else -- 2.34.1