aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1996-02-13 22:08:52 +0000
committerIan Lance Taylor <ian@airs.com>1996-02-13 22:08:52 +0000
commite9f03cd4509f74e4ffbfb11878149d4b31401923 (patch)
tree834a17e17034d88354ebba1061757baf684b19f0 /bfd
parent9cb8a981e9c0ebe02acfecb366032cc6a2dad7a8 (diff)
downloadgdb-e9f03cd4509f74e4ffbfb11878149d4b31401923.zip
gdb-e9f03cd4509f74e4ffbfb11878149d4b31401923.tar.gz
gdb-e9f03cd4509f74e4ffbfb11878149d4b31401923.tar.bz2
* reloc.c (BFD_RELOC_MIPS_GOT_HI16): Define.
(BFD_RELOC_MIPS_GOT_LO16): Define. * bfd-in2.h, libbfd.h: Rebuild. * elf32-mips.c (mips_reloc_map): Map new relocs.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog5
-rw-r--r--bfd/bfd-in2.h6
-rw-r--r--bfd/elf32-mips.c11
-rw-r--r--bfd/libbfd.h27
-rw-r--r--bfd/reloc.c218
5 files changed, 216 insertions, 51 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 5b9276b..1bbeaea 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -11,6 +11,11 @@ Tue Feb 13 15:36:37 1996 Michael Meissner <meissner@tiktok.cygnus.com>
Tue Feb 13 14:35:15 1996 Ian Lance Taylor <ian@cygnus.com>
+ * reloc.c (BFD_RELOC_MIPS_GOT_HI16): Define.
+ (BFD_RELOC_MIPS_GOT_LO16): Define.
+ * bfd-in2.h, libbfd.h: Rebuild.
+ * elf32-mips.c (mips_reloc_map): Map new relocs.
+
* configure.host: Set HDLFLAGS for *-*-hpux with --enable-shared.
* Makefile.in ($(SHLINK)): Check ts against $(SHLIB), not
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index cd3785a..c19551a 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -1523,7 +1523,9 @@ relocation types already defined. */
BFD_RELOC_SPARC_WDISP16,
BFD_RELOC_SPARC_WDISP19,
BFD_RELOC_SPARC_GLOB_JMP,
- BFD_RELOC_SPARC_LO7,
+ BFD_RELOC_SPARC_7,
+ BFD_RELOC_SPARC_6,
+ BFD_RELOC_SPARC_5,
/* Alpha ECOFF relocations. Some of these treat the symbol or "addend"
in some special way.
@@ -1598,6 +1600,8 @@ to compensate for the borrow when the low bits are added. */
BFD_RELOC_MIPS_GOT16,
BFD_RELOC_MIPS_CALL16,
#define BFD_RELOC_MIPS_GPREL32 BFD_RELOC_GPREL32
+ BFD_RELOC_MIPS_GOT_HI16,
+ BFD_RELOC_MIPS_GOT_LO16,
/* i386/elf relocations */
BFD_RELOC_386_GOT32,
diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c
index b6c544a..e9bdba3 100644
--- a/bfd/elf32-mips.c
+++ b/bfd/elf32-mips.c
@@ -1250,7 +1250,9 @@ static CONST struct elf_reloc_map mips_reloc_map[] =
{ BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
{ BFD_RELOC_16_PCREL, R_MIPS_PC16 },
{ BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
- { BFD_RELOC_MIPS_GPREL32, R_MIPS_GPREL32 }
+ { BFD_RELOC_MIPS_GPREL32, R_MIPS_GPREL32 },
+ { BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
+ { BFD_RELOC_MIPS_GOT_LO16, R_MIPS_GOT_LO16 }
};
/* Given a BFD reloc type, return a howto structure. */
@@ -3956,6 +3958,9 @@ mips_elf_relocate_section (output_bfd, info, input_bfd, input_section,
local = false;
indx = r_symndx - extsymoff;
h = elf_sym_hashes (input_bfd)[indx];
+ while (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning)
+ 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)
@@ -4350,6 +4355,7 @@ mips_elf_create_dynamic_sections (abfd, info)
get_elf_backend_data (abfd)->collect,
(struct bfd_link_hash_entry **) &h)))
return false;
+ h->elf_link_hash_flags &=~ ELF_LINK_NON_ELF;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
h->type = STT_SECTION;
@@ -4388,6 +4394,7 @@ mips_elf_create_dynamic_sections (abfd, info)
get_elf_backend_data (abfd)->collect,
(struct bfd_link_hash_entry **) &h)))
return false;
+ h->elf_link_hash_flags ^=~ ELF_LINK_NON_ELF;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
h->type = STT_SECTION;
@@ -4458,6 +4465,7 @@ mips_elf_create_got_section (abfd, info)
get_elf_backend_data (abfd)->collect,
(struct bfd_link_hash_entry **) &h)))
return false;
+ h->elf_link_hash_flags &=~ ELF_LINK_NON_ELF;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
h->type = STT_OBJECT;
@@ -5832,6 +5840,5 @@ static const struct ecoff_debug_swap mips_elf_ecoff_debug_swap =
mips_elf_finish_dynamic_symbol
#define elf_backend_finish_dynamic_sections \
mips_elf_finish_dynamic_sections
-#define elf_backend_want_hdr_in_seg 1
#include "elf32-target.h"
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 49fb971..6f18e90 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -347,6 +347,11 @@ extern long _bfd_generic_read_minisymbols
extern asymbol *_bfd_generic_minisymbol_to_symbol
PARAMS ((bfd *, boolean, const PTR, asymbol *));
+/* Find the nearest line using .stab/.stabstr sections. */
+extern boolean _bfd_stab_section_find_nearest_line
+ PARAMS ((bfd *, asymbol **, asection *, bfd_vma, boolean *, const char **,
+ const char **, unsigned int *, PTR *));
+
/* A routine to create entries for a bfd_link_hash_table. */
extern struct bfd_hash_entry *_bfd_link_hash_newfunc
PARAMS ((struct bfd_hash_entry *entry,
@@ -601,7 +606,9 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
"BFD_RELOC_SPARC_WDISP16",
"BFD_RELOC_SPARC_WDISP19",
"BFD_RELOC_SPARC_GLOB_JMP",
- "BFD_RELOC_SPARC_LO7",
+ "BFD_RELOC_SPARC_7",
+ "BFD_RELOC_SPARC_6",
+ "BFD_RELOC_SPARC_5",
"BFD_RELOC_ALPHA_GPDISP_HI16",
"BFD_RELOC_ALPHA_GPDISP_LO16",
"BFD_RELOC_ALPHA_LITERAL",
@@ -616,6 +623,8 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
"BFD_RELOC_MIPS_LITERAL",
"BFD_RELOC_MIPS_GOT16",
"BFD_RELOC_MIPS_CALL16",
+ "BFD_RELOC_MIPS_GOT_HI16",
+ "BFD_RELOC_MIPS_GOT_LO16",
"BFD_RELOC_386_GOT32",
"BFD_RELOC_386_PLT32",
"BFD_RELOC_386_COPY",
@@ -650,6 +659,22 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
"BFD_RELOC_PPC_JMP_SLOT",
"BFD_RELOC_PPC_RELATIVE",
"BFD_RELOC_PPC_LOCAL24PC",
+ "BFD_RELOC_PPC_EMB_NADDR32",
+ "BFD_RELOC_PPC_EMB_NADDR16",
+ "BFD_RELOC_PPC_EMB_NADDR16_LO",
+ "BFD_RELOC_PPC_EMB_NADDR16_HI",
+ "BFD_RELOC_PPC_EMB_NADDR16_HA",
+ "BFD_RELOC_PPC_EMB_SDAI16",
+ "BFD_RELOC_PPC_EMB_SDA2I16",
+ "BFD_RELOC_PPC_EMB_SDA2REL",
+ "BFD_RELOC_PPC_EMB_SDA21",
+ "BFD_RELOC_PPC_EMB_MRKREF",
+ "BFD_RELOC_PPC_EMB_RELSEC16",
+ "BFD_RELOC_PPC_EMB_RELST_LO",
+ "BFD_RELOC_PPC_EMB_RELST_HI",
+ "BFD_RELOC_PPC_EMB_RELST_HA",
+ "BFD_RELOC_PPC_EMB_BIT_FLD",
+ "BFD_RELOC_PPC_EMB_RELSDA",
"BFD_RELOC_CTOR",
"BFD_RELOC_ARM_PCREL_BRANCH",
"BFD_RELOC_ARM_IMMEDIATE",
diff --git a/bfd/reloc.c b/bfd/reloc.c
index 3285252..5e6004a 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -1,5 +1,5 @@
/* BFD support for handling relocation entries.
- Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
+ Copyright (C) 1990, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
Written by Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
@@ -16,7 +16,7 @@ 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. */
/*
SECTION
@@ -105,7 +105,7 @@ CODE_FRAGMENT
. bfd_vma addend;
.
. {* Pointer to how to perform the required relocation *}
-. const struct reloc_howto_struct *howto;
+. reloc_howto_type *howto;
.
.} arelent;
@@ -286,9 +286,6 @@ SUBSUBSECTION
CODE_FRAGMENT
.struct symbol_cache_entry; {* Forward declaration *}
.
-.typedef unsigned char bfd_byte;
-.typedef const struct reloc_howto_struct reloc_howto_type;
-.
.struct reloc_howto_struct
.{
. {* The type field has mainly a documetary use - the back end can
@@ -719,16 +716,14 @@ space consuming. For each target:
machine word.
FIXME: We should also do overflow checking on the result after
adding in the value contained in the object file. */
- if (howto->complain_on_overflow != complain_overflow_dont)
+ if (howto->complain_on_overflow != complain_overflow_dont
+ && flag == bfd_reloc_ok)
{
bfd_vma check;
/* Get the value that will be used for the relocation, but
starting at bit position zero. */
- if (howto->rightshift > howto->bitpos)
- check = relocation >> (howto->rightshift - howto->bitpos);
- else
- check = relocation << (howto->bitpos - howto->rightshift);
+ check = relocation >> howto->rightshift;
switch (howto->complain_on_overflow)
{
case complain_overflow_signed:
@@ -739,11 +734,11 @@ space consuming. For each target:
/* The above right shift is incorrect for a signed value.
Fix it up by forcing on the upper bits. */
- if (howto->rightshift > howto->bitpos
+ if (howto->rightshift > 0
&& (bfd_signed_vma) relocation < 0)
check |= ((bfd_vma) - 1
& ~((bfd_vma) - 1
- >> (howto->rightshift - howto->bitpos)));
+ >> howto->rightshift));
if ((bfd_signed_vma) check > reloc_signed_max
|| (bfd_signed_vma) check < reloc_signed_min)
flag = bfd_reloc_overflow;
@@ -774,12 +769,12 @@ space consuming. For each target:
/* The above right shift is incorrect for a signed
value. See if turning on the upper bits fixes the
overflow. */
- if (howto->rightshift > howto->bitpos
+ if (howto->rightshift > 0
&& (bfd_signed_vma) relocation < 0)
{
check |= ((bfd_vma) - 1
& ~((bfd_vma) - 1
- >> (howto->rightshift - howto->bitpos)));
+ >> howto->rightshift));
if (((bfd_vma) check & ~reloc_bits) != (-1 & ~reloc_bits))
flag = bfd_reloc_overflow;
}
@@ -899,6 +894,15 @@ space consuming. For each target:
}
break;
+ case -1:
+ {
+ long x = bfd_get_16 (abfd, (bfd_byte *) data + addr);
+ relocation = -relocation;
+ DOIT (x);
+ bfd_put_16 (abfd, x, (bfd_byte *) data + addr);
+ }
+ break;
+
case 3:
/* Do nothing */
break;
@@ -1176,10 +1180,7 @@ space consuming. For each target:
/* Get the value that will be used for the relocation, but
starting at bit position zero. */
- if (howto->rightshift > howto->bitpos)
- check = relocation >> (howto->rightshift - howto->bitpos);
- else
- check = relocation << (howto->bitpos - howto->rightshift);
+ check = relocation >> howto->rightshift;
switch (howto->complain_on_overflow)
{
case complain_overflow_signed:
@@ -1190,11 +1191,11 @@ space consuming. For each target:
/* The above right shift is incorrect for a signed value.
Fix it up by forcing on the upper bits. */
- if (howto->rightshift > howto->bitpos
+ if (howto->rightshift > 0
&& (bfd_signed_vma) relocation < 0)
check |= ((bfd_vma) - 1
& ~((bfd_vma) - 1
- >> (howto->rightshift - howto->bitpos)));
+ >> howto->rightshift));
if ((bfd_signed_vma) check > reloc_signed_max
|| (bfd_signed_vma) check < reloc_signed_min)
flag = bfd_reloc_overflow;
@@ -1225,12 +1226,12 @@ space consuming. For each target:
/* The above right shift is incorrect for a signed
value. See if turning on the upper bits fixes the
overflow. */
- if (howto->rightshift > howto->bitpos
+ if (howto->rightshift > 0
&& (bfd_signed_vma) relocation < 0)
{
check |= ((bfd_vma) - 1
& ~((bfd_vma) - 1
- >> (howto->rightshift - howto->bitpos)));
+ >> howto->rightshift));
if (((bfd_vma) check & ~reloc_bits) != (-1 & ~reloc_bits))
flag = bfd_reloc_overflow;
}
@@ -1693,11 +1694,69 @@ the section containing the relocation. It depends on the specific target.
The 24-bit relocation is used in some Intel 960 configurations.
ENUM
+ BFD_RELOC_32_GOT_PCREL
+ENUMX
+ BFD_RELOC_16_GOT_PCREL
+ENUMX
+ BFD_RELOC_8_GOT_PCREL
+ENUMX
+ BFD_RELOC_32_GOTOFF
+ENUMX
+ BFD_RELOC_16_GOTOFF
+ENUMX
+ BFD_RELOC_LO16_GOTOFF
+ENUMX
+ BFD_RELOC_HI16_GOTOFF
+ENUMX
+ BFD_RELOC_HI16_S_GOTOFF
+ENUMX
+ BFD_RELOC_8_GOTOFF
+ENUMX
+ BFD_RELOC_32_PLT_PCREL
+ENUMX
+ BFD_RELOC_24_PLT_PCREL
+ENUMX
+ BFD_RELOC_16_PLT_PCREL
+ENUMX
+ BFD_RELOC_8_PLT_PCREL
+ENUMX
+ BFD_RELOC_32_PLTOFF
+ENUMX
+ BFD_RELOC_16_PLTOFF
+ENUMX
+ BFD_RELOC_LO16_PLTOFF
+ENUMX
+ BFD_RELOC_HI16_PLTOFF
+ENUMX
+ BFD_RELOC_HI16_S_PLTOFF
+ENUMX
+ BFD_RELOC_8_PLTOFF
+ENUMDOC
+ For ELF.
+
+ENUM
+ BFD_RELOC_68K_GLOB_DAT
+ENUMX
+ BFD_RELOC_68K_JMP_SLOT
+ENUMX
+ BFD_RELOC_68K_RELATIVE
+ENUMDOC
+ Relocations used by 68K ELF.
+
+ENUM
BFD_RELOC_32_BASEREL
ENUMX
BFD_RELOC_16_BASEREL
ENUMX
+ BFD_RELOC_LO16_BASEREL
+ENUMX
+ BFD_RELOC_HI16_BASEREL
+ENUMX
+ BFD_RELOC_HI16_S_BASEREL
+ENUMX
BFD_RELOC_8_BASEREL
+ENUMX
+ BFD_RELOC_RVA
ENUMDOC
Linkage-table relative.
@@ -1813,7 +1872,11 @@ ENUMX
ENUMX
BFD_RELOC_SPARC_GLOB_JMP
ENUMX
- BFD_RELOC_SPARC_LO7
+ BFD_RELOC_SPARC_7
+ENUMX
+ BFD_RELOC_SPARC_6
+ENUMX
+ BFD_RELOC_SPARC_5
ENUMDOC
Some relocations we're using for SPARC V9 -- subject to change.
@@ -1914,6 +1977,10 @@ ENUMX
ENUMEQX
BFD_RELOC_MIPS_GPREL32
BFD_RELOC_GPREL32
+ENUMX
+ BFD_RELOC_MIPS_GOT_HI16
+ENUMX
+ BFD_RELOC_MIPS_GOT_LO16
ENUMDOC
MIPS ELF relocations.
@@ -1965,18 +2032,66 @@ ENUMDOC
ENUM
BFD_RELOC_PPC_B26
-ENUMDOC
- PowerPC/POWER (RS/6000) relocs.
- 26 bit relative branch. Low two bits must be zero. High 24
- bits installed in bits 6 through 29 of instruction.
-ENUM
+ENUMX
BFD_RELOC_PPC_BA26
-ENUMDOC
- 26 bit absolute branch, like BFD_RELOC_PPC_B26 but absolute.
-ENUM
+ENUMX
BFD_RELOC_PPC_TOC16
+ENUMX
+ BFD_RELOC_PPC_B16
+ENUMX
+ BFD_RELOC_PPC_B16_BRTAKEN
+ENUMX
+ BFD_RELOC_PPC_B16_BRNTAKEN
+ENUMX
+ BFD_RELOC_PPC_BA16
+ENUMX
+ BFD_RELOC_PPC_BA16_BRTAKEN
+ENUMX
+ BFD_RELOC_PPC_BA16_BRNTAKEN
+ENUMX
+ BFD_RELOC_PPC_COPY
+ENUMX
+ BFD_RELOC_PPC_GLOB_DAT
+ENUMX
+ BFD_RELOC_PPC_JMP_SLOT
+ENUMX
+ BFD_RELOC_PPC_RELATIVE
+ENUMX
+ BFD_RELOC_PPC_LOCAL24PC
+ENUMX
+ BFD_RELOC_PPC_EMB_NADDR32
+ENUMX
+ BFD_RELOC_PPC_EMB_NADDR16
+ENUMX
+ BFD_RELOC_PPC_EMB_NADDR16_LO
+ENUMX
+ BFD_RELOC_PPC_EMB_NADDR16_HI
+ENUMX
+ BFD_RELOC_PPC_EMB_NADDR16_HA
+ENUMX
+ BFD_RELOC_PPC_EMB_SDAI16
+ENUMX
+ BFD_RELOC_PPC_EMB_SDA2I16
+ENUMX
+ BFD_RELOC_PPC_EMB_SDA2REL
+ENUMX
+ BFD_RELOC_PPC_EMB_SDA21
+ENUMX
+ BFD_RELOC_PPC_EMB_MRKREF
+ENUMX
+ BFD_RELOC_PPC_EMB_RELSEC16
+ENUMX
+ BFD_RELOC_PPC_EMB_RELST_LO
+ENUMX
+ BFD_RELOC_PPC_EMB_RELST_HI
+ENUMX
+ BFD_RELOC_PPC_EMB_RELST_HA
+ENUMX
+ BFD_RELOC_PPC_EMB_BIT_FLD
+ENUMX
+ BFD_RELOC_PPC_EMB_RELSDA
ENUMDOC
- 16 bit TOC relative reference.
+ Power(rs6000) and PowerPC relocations.
ENUM
BFD_RELOC_CTOR
@@ -2002,6 +2117,14 @@ ENUMX
BFD_RELOC_ARM_MULTI
ENUMX
BFD_RELOC_ARM_CP_OFF_IMM
+ENUMX
+ BFD_RELOC_ARM_ADR_IMM
+ENUMX
+ BFD_RELOC_ARM_LDR_IMM
+ENUMX
+ BFD_RELOC_ARM_LITERAL
+ENUMX
+ BFD_RELOC_ARM_IN_POOL
ENUMDOC
These relocs are only used within the ARM assembler. They are not
(at present) written to any object files.
@@ -2013,14 +2136,18 @@ ENUM
ENUMDOC
Argonaut RISC Core (ARC) relocs.
ARC 22 bit pc-relative branch. The lowest two bits must be zero and are
- not stored in the instruction. High 20 bits installed in bits 7 through 26
- of instruction.
+ not stored in the instruction. The high 20 bits are installed in bits 26
+ through 7 of the instruction.
+ENUM
+ BFD_RELOC_ARC_B26
+ENUMDOC
+ ARC 26 bit absolute branch. The lowest two bits must be zero and are not
+ stored in the instruction. The high 24 bits are installed in bits 23
+ through 0.
COMMENT
{* end-sanitize-arc *}
-
ENDSENUM
BFD_RELOC_UNUSED
-
CODE_FRAGMENT
.
.typedef enum bfd_reloc_code_real bfd_reloc_code_real_type;
@@ -2032,7 +2159,7 @@ FUNCTION
bfd_reloc_type_lookup
SYNOPSIS
- const struct reloc_howto_struct *
+ reloc_howto_type *
bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code);
DESCRIPTION
@@ -2043,7 +2170,7 @@ DESCRIPTION
*/
-const struct reloc_howto_struct *
+reloc_howto_type *
bfd_reloc_type_lookup (abfd, code)
bfd *abfd;
bfd_reloc_code_real_type code;
@@ -2060,7 +2187,7 @@ INTERNAL_FUNCTION
bfd_default_reloc_type_lookup
SYNOPSIS
- const struct reloc_howto_struct *bfd_default_reloc_type_lookup
+ reloc_howto_type *bfd_default_reloc_type_lookup
(bfd *abfd, bfd_reloc_code_real_type code);
DESCRIPTION
@@ -2069,7 +2196,7 @@ DESCRIPTION
*/
-const struct reloc_howto_struct *
+reloc_howto_type *
bfd_default_reloc_type_lookup (abfd, code)
bfd *abfd;
bfd_reloc_code_real_type code;
@@ -2093,7 +2220,7 @@ bfd_default_reloc_type_lookup (abfd, code)
default:
BFD_FAIL ();
}
- return (const struct reloc_howto_struct *) NULL;
+ return (reloc_howto_type *) NULL;
}
/*
@@ -2185,12 +2312,9 @@ bfd_generic_get_relocated_section_contents (abfd, link_info, link_order, data,
if (reloc_size < 0)
goto error_return;
- reloc_vector = (arelent **) malloc (reloc_size);
+ reloc_vector = (arelent **) bfd_malloc ((size_t) reloc_size);
if (reloc_vector == NULL && reloc_size != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
/* read in the section */
if (!bfd_get_section_contents (input_bfd,