From: Ian Lance Taylor Date: Fri, 16 Feb 1996 19:29:01 +0000 (+0000) Subject: * bfd.c (_bfd_get_gp_value): New function. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cba3f8a9bec5271063c4ef6671147b5b4a7a6024;p=binutils-gdb.git * bfd.c (_bfd_get_gp_value): New function. (_bfd_set_gp_value): New function. * libbfd-in.h (_bfd_get_gp_value): Declare. (_bfd_set_gp_value): Declare. * libbfd.h: Rebuild. * coff-alpha.c (alpha_ecoff_get_relocated_section_contents): Use _bfd_get_gp_value and _bfd_set_gp_value rather than referring directly to the fields in the tdata information. (alpha_relocate_section): Likewise. * coff-mips.c (mips_adjust_reloc_in): Likewise. (mips_gprel_reloc): Likewise. (mips_relocate_section): Likewise. * elf32-mips.c (mips_elf_hi16_reloc): Likewise. (mips_elf_lo16_reloc): Likewise. (mips_elf_final_gp): Likewise. (mips_elf_gprel16_reloc): Likewise. (mips_elf_gprel32_reloc): Likewise. (mips_elf_relocate_section): Likewise. (mips_elf_finish_dynamic_symbol): Likewise. PR 8449. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 92862d0caa9..d059eddcec1 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,25 @@ Fri Feb 16 12:46:18 1996 Ian Lance Taylor + * bfd.c (_bfd_get_gp_value): New function. + (_bfd_set_gp_value): New function. + * libbfd-in.h (_bfd_get_gp_value): Declare. + (_bfd_set_gp_value): Declare. + * libbfd.h: Rebuild. + * coff-alpha.c (alpha_ecoff_get_relocated_section_contents): Use + _bfd_get_gp_value and _bfd_set_gp_value rather than referring + directly to the fields in the tdata information. + (alpha_relocate_section): Likewise. + * coff-mips.c (mips_adjust_reloc_in): Likewise. + (mips_gprel_reloc): Likewise. + (mips_relocate_section): Likewise. + * elf32-mips.c (mips_elf_hi16_reloc): Likewise. + (mips_elf_lo16_reloc): Likewise. + (mips_elf_final_gp): Likewise. + (mips_elf_gprel16_reloc): Likewise. + (mips_elf_gprel32_reloc): Likewise. + (mips_elf_relocate_section): Likewise. + (mips_elf_finish_dynamic_symbol): Likewise. + * bout.c (b_out_set_arch_mach): Recognize bfd_mach_i960_jx. Thu Feb 15 11:29:13 1996 Ian Lance Taylor diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c index 1bbec4c0194..67dc0027ee4 100644 --- a/bfd/coff-alpha.c +++ b/bfd/coff-alpha.c @@ -1,5 +1,5 @@ /* BFD back-end for ALPHA Extended-Coff files. - Copyright 1993, 1994 Free Software Foundation, Inc. + Copyright 1993, 1994, 1995, 1996 Free Software Foundation, Inc. Modified from coff-mips.c by Steve Chamberlain and Ian Lance Taylor . @@ -785,7 +785,7 @@ alpha_ecoff_get_relocated_section_contents (abfd, link_info, link_order, /* Get the GP value for the output BFD. */ gp_undefined = false; - if (ecoff_data (abfd)->gp == 0) + if (_bfd_get_gp_value (abfd) == 0) { if (relocateable != false) { @@ -804,7 +804,7 @@ alpha_ecoff_get_relocated_section_contents (abfd, link_info, link_order, || strcmp (sec->name, ".lita") == 0)) lo = sec->vma; } - ecoff_data (abfd)->gp = lo + 0x8000; + _bfd_set_gp_value (abfd, lo + 0x8000); } else { @@ -816,12 +816,13 @@ alpha_ecoff_get_relocated_section_contents (abfd, link_info, link_order, || h->type != bfd_link_hash_defined) gp_undefined = true; else - ecoff_data (abfd)->gp = (h->u.def.value - + h->u.def.section->output_section->vma - + h->u.def.section->output_offset); + _bfd_set_gp_value (abfd, + (h->u.def.value + + h->u.def.section->output_section->vma + + h->u.def.section->output_offset)); } } - gp = ecoff_data (abfd)->gp; + gp = _bfd_get_gp_value (abfd); for (; *reloc_vector != (arelent *) NULL; reloc_vector++) { @@ -1430,7 +1431,7 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section, output, the .lita section is limited to 64KB. . */ lita_sec = symndx_to_section[RELOC_SECTION_LITA]; - gp = ecoff_data (output_bfd)->gp; + gp = _bfd_get_gp_value (output_bfd); if (! info->relocateable && lita_sec != NULL) { struct ecoff_section_tdata *lita_sec_data; @@ -1489,7 +1490,7 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section, lita_sec_data->gp = gp; } - ecoff_data (output_bfd)->gp = gp; + _bfd_set_gp_value (output_bfd, gp); } gp_undefined = (gp == 0); @@ -1979,7 +1980,8 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section, input_bfd, input_section, r_vaddr - input_section->vma))) return false; /* Only give the error once per link. */ - ecoff_data (output_bfd)->gp = gp = 4; + gp = 4; + _bfd_set_gp_value (output_bfd, gp); gp_undefined = false; } } @@ -2257,7 +2259,7 @@ static const struct ecoff_backend_data alpha_ecoff_backend_data = alpha_ecoff_bad_format_hook, _bfd_ecoff_set_arch_mach_hook, alpha_ecoff_mkobject_hook, _bfd_ecoff_styp_to_sec_flags, _bfd_ecoff_set_alignment_hook, _bfd_ecoff_slurp_symbol_table, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }, /* Supported architecture. */ bfd_arch_alpha, diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c index bab8beba271..2b0a6a7fcd0 100644 --- a/bfd/coff-mips.c +++ b/bfd/coff-mips.c @@ -1,5 +1,5 @@ /* BFD back-end for MIPS Extended-Coff files. - Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. Original version by Per Bothner. Full support added by Ian Lance Taylor, ian@cygnus.com. @@ -538,7 +538,7 @@ mips_adjust_reloc_in (abfd, intern, rptr) if (! intern->r_extern && (intern->r_type == MIPS_R_GPREL || intern->r_type == MIPS_R_LITERAL)) - rptr->addend += ecoff_data (abfd)->gp; + rptr->addend += _bfd_get_gp_value (abfd); /* If the type is MIPS_R_IGNORE, make sure this is a reference to the absolute section so that the reloc is ignored. */ @@ -794,15 +794,15 @@ mips_gprel_reloc (abfd, BFD. If we can't find it, we're stuck. We cache it in the ECOFF target data. We don't need to adjust the symbol value for an external symbol if we are producing relocateable output. */ - if (ecoff_data (output_bfd)->gp == 0 + if (_bfd_get_gp_value (output_bfd) == 0 && (relocateable == false || (symbol->flags & BSF_SECTION_SYM) != 0)) { if (relocateable != false) { /* Make up a value. */ - ecoff_data (output_bfd)->gp = - symbol->section->output_section->vma + 0x4000; + _bfd_set_gp_value (output_bfd, + symbol->section->output_section->vma + 0x4000); } else { @@ -824,7 +824,8 @@ mips_gprel_reloc (abfd, name = bfd_asymbol_name (*sym); if (*name == '_' && strcmp (name, "_gp") == 0) { - ecoff_data (output_bfd)->gp = bfd_asymbol_value (*sym); + _bfd_set_gp_value (output_bfd, + bfd_asymbol_value (*sym)); break; } } @@ -833,7 +834,7 @@ mips_gprel_reloc (abfd, if (i >= count) { /* Only get the error once. */ - ecoff_data (output_bfd)->gp = 4; + _bfd_set_gp_value (output_bfd, 4); *error_message = (char *) "GP relative relocation when _gp not defined"; return bfd_reloc_dangerous; @@ -864,7 +865,7 @@ mips_gprel_reloc (abfd, an external symbol. */ if (relocateable == false || (symbol->flags & BSF_SECTION_SYM) != 0) - val += relocation - ecoff_data (output_bfd)->gp; + val += relocation - _bfd_get_gp_value (output_bfd); insn = (insn &~ 0xffff) | (val & 0xffff); bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address); @@ -1237,7 +1238,7 @@ mips_relocate_section (output_bfd, info, input_bfd, input_section, sym_hashes = ecoff_data (input_bfd)->sym_hashes; - gp = ecoff_data (output_bfd)->gp; + gp = _bfd_get_gp_value (output_bfd); if (gp == 0) gp_undefined = true; else @@ -1356,7 +1357,8 @@ mips_relocate_section (output_bfd, info, input_bfd, input_section, int_rel.r_vaddr - input_section->vma))) return false; /* Only give the error once per link. */ - ecoff_data (output_bfd)->gp = gp = 4; + gp = 4; + _bfd_set_gp_value (output_bfd, gp); gp_undefined = false; } if (! int_rel.r_extern) @@ -2421,7 +2423,7 @@ static const struct ecoff_backend_data mips_ecoff_backend_data = mips_ecoff_bad_format_hook, _bfd_ecoff_set_arch_mach_hook, _bfd_ecoff_mkobject_hook, _bfd_ecoff_styp_to_sec_flags, _bfd_ecoff_set_alignment_hook, _bfd_ecoff_slurp_symbol_table, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }, /* Supported architecture. */ bfd_arch_mips, diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index 20d159fa7c2..8163982a961 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -776,7 +776,7 @@ mips_elf_hi16_reloc (abfd, if (ret != bfd_reloc_ok) return ret; - relocation = elf_gp (output_bfd) - reloc_entry->address; + relocation = _bfd_get_gp_value (output_bfd) - reloc_entry->address; } else { @@ -878,7 +878,7 @@ mips_elf_lo16_reloc (abfd, if (ret != bfd_reloc_ok) return ret; - relocation = elf_gp (output_bfd) - reloc_entry->address; + relocation = _bfd_get_gp_value (output_bfd) - reloc_entry->address; relocation += symbol->section->output_section->vma; relocation += symbol->section->output_offset; relocation += reloc_entry->addend; @@ -967,15 +967,15 @@ mips_elf_final_gp (output_bfd, symbol, relocateable, error_message) if (output_bfd->xvec->flavour != bfd_target_elf_flavour) abort (); - if (elf_gp (output_bfd) == 0 + if (_bfd_get_gp_value (output_bfd) == 0 && (! relocateable || (symbol->flags & BSF_SECTION_SYM) != 0)) { if (relocateable) { /* Make up a value. */ - elf_gp (output_bfd) = - symbol->section->output_section->vma + 0x4000; + _bfd_set_gp_value (output_bfd, + symbol->section->output_section->vma + 0x4000); } else { @@ -997,7 +997,7 @@ mips_elf_final_gp (output_bfd, symbol, relocateable, error_message) name = bfd_asymbol_name (*sym); if (*name == '_' && strcmp (name, "_gp") == 0) { - elf_gp (output_bfd) = bfd_asymbol_value (*sym); + _bfd_set_gp_value (output_bfd, bfd_asymbol_value (*sym)); break; } } @@ -1006,7 +1006,7 @@ mips_elf_final_gp (output_bfd, symbol, relocateable, error_message) if (i >= count) { /* Only get the error once. */ - elf_gp (output_bfd) = 4; + _bfd_set_gp_value (output_bfd, 4); *error_message = (char *) "GP relative relocation when _gp not defined"; return bfd_reloc_dangerous; @@ -1071,7 +1071,8 @@ mips_elf_gprel16_reloc (abfd, return ret; return gprel16_with_gp (abfd, symbol, reloc_entry, input_section, - relocateable, data, elf_gp (output_bfd)); + relocateable, data, + _bfd_get_gp_value (output_bfd)); } static bfd_reloc_status_type @@ -1180,7 +1181,8 @@ mips_elf_gprel32_reloc (abfd, } return gprel32_with_gp (abfd, symbol, reloc_entry, input_section, - relocateable, data, elf_gp (output_bfd)); + relocateable, data, + _bfd_get_gp_value (output_bfd)); } static bfd_reloc_status_type @@ -3801,6 +3803,7 @@ mips_elf_relocate_section (output_bfd, info, input_bfd, input_section, reloc_howto_type *howto; unsigned long r_symndx; bfd_vma addend; + bfd_vma gp; struct elf_link_hash_entry *h; asection *sec; Elf_Internal_Sym *sym; @@ -3835,6 +3838,8 @@ mips_elf_relocate_section (output_bfd, info, input_bfd, input_section, r_symndx = ELF32_R_SYM (rel->r_info); + gp = _bfd_get_gp_value (output_bfd); + /* Mix in the change in GP address for a GP relative reloc. */ if (r_type != R_MIPS_GPREL16 && r_type != R_MIPS_LITERAL @@ -3842,7 +3847,7 @@ mips_elf_relocate_section (output_bfd, info, input_bfd, input_section, addend = 0; else { - if (elf_gp (output_bfd) == 0) + if (gp == 0) { if (! ((*info->callbacks->reloc_dangerous) (info, @@ -3851,7 +3856,8 @@ mips_elf_relocate_section (output_bfd, info, input_bfd, input_section, rel->r_offset))) return false; /* Only give the error once per link. */ - elf_gp (output_bfd) = 4; + gp = 4; + _bfd_set_gp_value (output_bfd, gp); } if (r_symndx < extsymoff @@ -3864,7 +3870,7 @@ mips_elf_relocate_section (output_bfd, info, input_bfd, input_section, must change this to be the difference between the final definition (which will end up in RELOCATION) and the GP value of OUTPUT_BFD (which is in GP). */ - addend = elf_gp (input_bfd) - elf_gp (output_bfd); + addend = elf_gp (input_bfd) - gp; } else if (! info->relocateable) { @@ -3874,7 +3880,7 @@ mips_elf_relocate_section (output_bfd, info, input_bfd, input_section, hold the difference between the final definition of the symbol (which will end up in RELOCATION) and the GP value of OUTPUT_BFD (which is in GP). */ - addend = - elf_gp (output_bfd); + addend = - gp; } else { @@ -3965,7 +3971,7 @@ mips_elf_relocate_section (output_bfd, info, input_bfd, input_section, h = (struct elf_link_hash_entry *) h->root.u.i.link; if (strcmp (h->root.root.string, "_gp_disp") == 0) { - if (elf_gp (output_bfd) == 0) + if (gp == 0) { if (! ((*info->callbacks->reloc_dangerous) (info, @@ -3974,19 +3980,20 @@ mips_elf_relocate_section (output_bfd, info, input_bfd, input_section, rel->r_offset))) return false; /* Only give the error once per link. */ - elf_gp (output_bfd) = 4; + gp = 4; + _bfd_set_gp_value (output_bfd, gp); relocation = 0; } else { sec = input_section; if (sec->output_section != NULL) - relocation = (elf_gp (output_bfd) + relocation = (gp - (rel->r_offset + sec->output_section->vma + sec->output_offset)); else - relocation = elf_gp (output_bfd) - rel->r_offset; + relocation = gp - rel->r_offset; if (r_type == R_MIPS_LO16) relocation += 4; } @@ -4076,7 +4083,7 @@ mips_elf_relocate_section (output_bfd, info, input_bfd, input_section, bfd_put_32 (output_bfd, relocation + addend, sgot->contents + offset); offset = (sgot->output_section->vma + sgot->output_offset - + offset - elf_gp (output_bfd)); + + offset - gp); mips_elf_relocate_global_got (input_bfd, rel, contents, offset); r = bfd_reloc_ok; @@ -4101,7 +4108,7 @@ mips_elf_relocate_section (output_bfd, info, input_bfd, input_section, bfd_put_32 (output_bfd, relocation + addend, sgot->contents + offset); offset = (sgot->output_section->vma + sgot->output_offset - + offset - elf_gp (output_bfd)); + + offset - gp); mips_elf_relocate_hi16 (input_bfd, rel, rel + 1, contents, offset); r = bfd_reloc_ok; @@ -4251,7 +4258,7 @@ mips_elf_relocate_section (output_bfd, info, input_bfd, input_section, case R_MIPS_LITERAL: case R_MIPS_GPREL32: mips_elf_set_cr_type (cptrel, CRT_MIPS_GPHI_LO); - cptrel.konst = elf_gp (output_bfd) - cptrel.vaddr; + cptrel.konst = gp - cptrel.vaddr; mips_elf_set_cr_dist2to (cptrel, 4); cr = scpt->contents + sizeof (Elf32_External_compact_rel); bfd_elf32_swap_crinfo_out (output_bfd, &cptrel, @@ -5231,7 +5238,7 @@ mips_elf_finish_dynamic_symbol (output_bfd, info, h, sym) { sym->st_shndx = SHN_ABS; sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION); - sym->st_value = elf_gp (output_bfd); + sym->st_value = _bfd_get_gp_value (output_bfd); } else if (strcmp (name, mips_elf_dynsym_rtproc_names[0]) == 0 || strcmp (name, mips_elf_dynsym_rtproc_names[1]) == 0)