(_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.
Fri Feb 16 12:46:18 1996 Ian Lance Taylor <ian@cygnus.com>
+ * 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 <ian@cygnus.com>
/* 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 <sac@cygnus.com> and
Ian Lance Taylor <ian@cygnus.com>.
/* 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)
{
|| strcmp (sec->name, ".lita") == 0))
lo = sec->vma;
}
- ecoff_data (abfd)->gp = lo + 0x8000;
+ _bfd_set_gp_value (abfd, lo + 0x8000);
}
else
{
|| 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++)
{
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;
lita_sec_data->gp = gp;
}
- ecoff_data (output_bfd)->gp = gp;
+ _bfd_set_gp_value (output_bfd, gp);
}
gp_undefined = (gp == 0);
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;
}
}
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,
/* 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.
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. */
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
{
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;
}
}
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;
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);
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
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)
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,
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
{
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;
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
{
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;
}
}
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;
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
}
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
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;
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
addend = 0;
else
{
- if (elf_gp (output_bfd) == 0)
+ if (gp == 0)
{
if (! ((*info->callbacks->reloc_dangerous)
(info,
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
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)
{
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
{
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,
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;
}
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;
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;
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,
{
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)