aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog78
-rw-r--r--bfd/coff-rs6000.c26
-rw-r--r--bfd/coff64-rs6000.c116
-rw-r--r--bfd/elf-bfd.h5
-rw-r--r--bfd/elf-m10200.c26
-rw-r--r--bfd/elf-m10300.c24
-rw-r--r--bfd/elf32-arm.h14
-rw-r--r--bfd/elf32-fr30.c27
-rw-r--r--bfd/elf32-hppa.c14
-rw-r--r--bfd/elf32-i370.c32
-rw-r--r--bfd/elf32-i386.c110
-rw-r--r--bfd/elf32-i860.c28
-rw-r--r--bfd/elf32-m32r.c20
-rw-r--r--bfd/elf32-m68k.c24
-rw-r--r--bfd/elf32-mcore.c33
-rw-r--r--bfd/elf32-openrisc.c25
-rw-r--r--bfd/elf32-ppc.c81
-rw-r--r--bfd/elf32-s390.c27
-rw-r--r--bfd/elf32-xstormy16.c26
-rw-r--r--bfd/elf64-ppc.c35
-rw-r--r--bfd/elf64-s390.c27
-rw-r--r--bfd/elf64-x86-64.c27
-rw-r--r--bfd/elflink.h19
-rw-r--r--bfd/elfxx-ia64.c24
-rw-r--r--bfd/elfxx-target.h5
-rw-r--r--bfd/libxcoff.h10
-rw-r--r--bfd/version.h2
27 files changed, 465 insertions, 420 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 1f0e6d0..a837ebe 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,79 @@
+2002-05-10 Tom Rix <trix@redhat.com>
+
+ * coff64-rs6000.c (xcoff64_reloc_type_br): New function for
+ xcoff64_ppc_relocate_section.
+ * coff-rs6000.c : Extern common xcoff_reloc_type functions.
+ * libxcoff.h: Common xcoff_reloc_type function declaration.
+
+2002-05-10 Alan Modra <amodra@bigpond.net.au>
+
+ * elf32-i386.c (elf_i386_relocate_section): Remove overflow checks
+ addend in 2002-05-09 commit.
+
+ * elf32-hppa.c (elf32_hppa_size_stubs): Revert part of 2002-05-04,
+ don't look for stubs on all undefined syms.
+
+2002-05-09 Alan Modra <amodra@bigpond.net.au>
+
+ * elf64-ppc.c (RA_REGISTER_MASK, RA_REGISTER_SHIFT): Delete.
+ (ppc64_elf_howto_raw <R_PPC64_RELATIVE>): Not pc_relative or
+ pcrel_offset.
+
+ * elf32-i386.c (elf_howto_table): Comments.
+ (elf_i386_relocate_section): Handle more relocs for relocatable
+ linking and against SEC_MERGE sections.
+
+2002-05-08 Alan Modra <amodra@bigpond.net.au>
+
+ * elf32-ppc.c (ppc_elf_create_got): New function.
+ (ppc_elf_create_dynamic_sections): Call ppc_elf_create_got before
+ _bfd_elf_create_dynamic_sections. Correct .plt flags.
+ (ppc_elf_check_relocs): Use ppc_elf_create_got in place of
+ _bfd_elf_create_got_section.
+
+2002-05-07 Alan Modra <amodra@bigpond.net.au>
+
+ * elf-bfd.h (struct elf_backend_data): Add rela_normal.
+ * elfxx-target.h (elf_backend_rela_normal): Define.
+ (elfNN_bed): Init rela_normal.
+ * elflink.h (elf_link_input_bfd <emit_relocs>): Handle adjustment
+ for section symbols here if rela_normal. Simplify abs section test.
+ * elf-m10200.c (mn10200_elf_relocate_section): If relocatable,
+ return immediately. Remove code handling relocatable linking.
+ * elf-m10300.c (mn10300_elf_relocate_section): Likewise.
+ * elf32-fr30.c (fr30_elf_relocate_section): Likewise.
+ * elf32-i370.c (i370_elf_relocate_section): Likewise.
+ * elf32-i860.c (elf32_i860_relocate_section): Likewise.
+ * elf32-m68k.c (elf_m68k_relocate_section): Likewise.
+ * elf32-mcore.c (mcore_elf_relocate_section): Likewise.
+ * elf32-openrisc.c (openrisc_elf_relocate_section): Likewise.
+ * elf32-ppc.c (ppc_elf_relocate_section): Likewise.
+ * elf32-s390.c (elf_s390_relocate_section): Likewise.
+ * elf32-xstormy16.c (xstormy16_elf_relocate_section): Likewise.
+ * elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
+ * elf64-s390.c (elf_s390_relocate_section): Likewise.
+ * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise.
+ * elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise.
+ * elf32-arm.h (elf32_arm_relocate_section): Likewise #ifndef USE_REL.
+ * elf32-m32r.c (m32r_elf_relocate_section): Likewise.
+ * elf-m10200.c (elf_backend_rela_normal): Define.
+ * elf-m10300.c (elf_backend_rela_normal): Define.
+ * elf32-fr30.c (elf_backend_rela_normal): Define.
+ * elf32-i370.c (elf_backend_rela_normal): Define.
+ * elf32-i860.c (elf_backend_rela_normal): Define.
+ * elf32-m68k.c (elf_backend_rela_normal): Define.
+ * elf32-mcore.c (elf_backend_rela_normal): Define.
+ * elf32-openrisc.c (elf_backend_rela_normal): Define.
+ * elf32-ppc.c (elf_backend_rela_normal): Define.
+ * elf32-s390.c (elf_backend_rela_normal): Define.
+ * elf32-xstormy16.c (elf_backend_rela_normal): Define.
+ * elf64-ppc.c (elf_backend_rela_normal): Define.
+ * elf64-s390.c (elf_backend_rela_normal): Define.
+ * elf64-x86-64.c (elf_backend_rela_normal): Define.
+ * elfxx-ia64.c (elf_backend_rela_normal): Define.
+ * elf32-arm.h (elf_backend_rela_normal): Define #ifndef USE_REL.
+ * elf32-m32r.c (elf_backend_rela_normal): Likewise.
+
2002-05-06 Nick Clifton <nickc@cambridge.redhat.com>
* elf32-arm.h (elf32_arm_final_link_relocate): Convert
@@ -60,7 +136,7 @@
(elf32_hppa_size_stubs): Adjust for split out functions. Look for
stubs on undefined syms too.
(elf32_hppa_set_gp): Use bfd_link_hash* instead of elf_link_hash*.
- Only access htab elf fields when we have and elf hash table.
+ Only access htab elf fields when we have an elf hash table.
* elf32-hppa.h (elf32_hppa_setup_section_lists): Declare.
(elf32_hppa_next_input_section): Declare.
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index b1db78f..10ef5df 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -155,15 +155,7 @@ static boolean do_copy PARAMS((bfd *, bfd *));
static boolean do_shared_object_padding PARAMS ((bfd *, bfd *, ufile_ptr *, int));
/* Relocation functions */
-static boolean xcoff_reloc_type_noop PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
-static boolean xcoff_reloc_type_fail PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
-static boolean xcoff_reloc_type_pos PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
-static boolean xcoff_reloc_type_neg PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
-static boolean xcoff_reloc_type_rel PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
-static boolean xcoff_reloc_type_toc PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
-static boolean xcoff_reloc_type_ba PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
static boolean xcoff_reloc_type_br PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
-static boolean xcoff_reloc_type_crel PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
static boolean xcoff_complain_overflow_dont_func
PARAMS ((XCOFF_COMPLAIN_FUNCTION_ARGS));
@@ -2726,7 +2718,7 @@ xcoff_swap_ldrel_out (abfd, src, d)
}
-static boolean
+boolean
xcoff_reloc_type_noop (input_bfd, input_section, output_bfd, rel, sym, howto,
val, addend, relocation, contents)
bfd *input_bfd ATTRIBUTE_UNUSED;
@@ -2743,7 +2735,7 @@ xcoff_reloc_type_noop (input_bfd, input_section, output_bfd, rel, sym, howto,
return true;
}
-static boolean
+boolean
xcoff_reloc_type_fail (input_bfd, input_section, output_bfd, rel, sym, howto,
val, addend, relocation, contents)
bfd *input_bfd;
@@ -2764,7 +2756,7 @@ xcoff_reloc_type_fail (input_bfd, input_section, output_bfd, rel, sym, howto,
return false;
}
-static boolean
+boolean
xcoff_reloc_type_pos (input_bfd, input_section, output_bfd, rel, sym, howto,
val, addend, relocation, contents)
bfd *input_bfd ATTRIBUTE_UNUSED;
@@ -2782,7 +2774,7 @@ xcoff_reloc_type_pos (input_bfd, input_section, output_bfd, rel, sym, howto,
return true;
}
-static boolean
+boolean
xcoff_reloc_type_neg (input_bfd, input_section, output_bfd, rel, sym, howto,
val, addend, relocation, contents)
bfd *input_bfd ATTRIBUTE_UNUSED;
@@ -2800,7 +2792,7 @@ xcoff_reloc_type_neg (input_bfd, input_section, output_bfd, rel, sym, howto,
return true;
}
-static boolean
+boolean
xcoff_reloc_type_rel (input_bfd, input_section, output_bfd, rel, sym, howto,
val, addend, relocation, contents)
bfd *input_bfd ATTRIBUTE_UNUSED;
@@ -2824,7 +2816,8 @@ xcoff_reloc_type_rel (input_bfd, input_section, output_bfd, rel, sym, howto,
input_section->output_offset);
return true;
}
-static boolean
+
+boolean
xcoff_reloc_type_toc (input_bfd, input_section, output_bfd, rel, sym, howto,
val, addend, relocation, contents)
bfd *input_bfd;
@@ -2866,7 +2859,8 @@ xcoff_reloc_type_toc (input_bfd, input_section, output_bfd, rel, sym, howto,
(sym->n_value - xcoff_data (input_bfd)->toc));
return true;
}
-static boolean
+
+boolean
xcoff_reloc_type_ba (input_bfd, input_section, output_bfd, rel, sym, howto,
val, addend, relocation, contents)
bfd *input_bfd ATTRIBUTE_UNUSED;
@@ -2967,7 +2961,7 @@ xcoff_reloc_type_br (input_bfd, input_section, output_bfd, rel, sym, howto,
return true;
}
-static boolean
+boolean
xcoff_reloc_type_crel (input_bfd, input_section, output_bfd, rel, sym, howto,
val, addend, relocation, contents)
bfd *input_bfd ATTRIBUTE_UNUSED;
diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c
index b1bc2f5..931a914 100644
--- a/bfd/coff64-rs6000.c
+++ b/bfd/coff64-rs6000.c
@@ -152,6 +152,42 @@ static boolean xcoff64_generate_rtinit
PARAMS ((bfd *, const char *, const char *, boolean));
static boolean xcoff64_bad_format_hook PARAMS ((bfd *, PTR ));
+/* Relocation functions */
+static boolean xcoff64_reloc_type_br PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
+
+boolean (*xcoff64_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION])
+ (XCOFF_RELOC_FUNCTION_ARGS) =
+{
+ xcoff_reloc_type_pos, /* R_POS (0x00) */
+ xcoff_reloc_type_neg, /* R_NEG (0x01) */
+ xcoff_reloc_type_rel, /* R_REL (0x02) */
+ xcoff_reloc_type_toc, /* R_TOC (0x03) */
+ xcoff_reloc_type_fail, /* R_RTB (0x04) */
+ xcoff_reloc_type_toc, /* R_GL (0x05) */
+ xcoff_reloc_type_toc, /* R_TCL (0x06) */
+ xcoff_reloc_type_fail, /* (0x07) */
+ xcoff_reloc_type_ba, /* R_BA (0x08) */
+ xcoff_reloc_type_fail, /* (0x09) */
+ xcoff64_reloc_type_br, /* R_BR (0x0a) */
+ xcoff_reloc_type_fail, /* (0x0b) */
+ xcoff_reloc_type_pos, /* R_RL (0x0c) */
+ xcoff_reloc_type_pos, /* R_RLA (0x0d) */
+ xcoff_reloc_type_fail, /* (0x0e) */
+ xcoff_reloc_type_noop, /* R_REF (0x0f) */
+ xcoff_reloc_type_fail, /* (0x10) */
+ xcoff_reloc_type_fail, /* (0x11) */
+ xcoff_reloc_type_toc, /* R_TRL (0x12) */
+ xcoff_reloc_type_toc, /* R_TRLA (0x13) */
+ xcoff_reloc_type_fail, /* R_RRTBI (0x14) */
+ xcoff_reloc_type_fail, /* R_RRTBA (0x15) */
+ xcoff_reloc_type_ba, /* R_CAI (0x16) */
+ xcoff_reloc_type_crel, /* R_CREL (0x17) */
+ xcoff_reloc_type_ba, /* R_RBA (0x18) */
+ xcoff_reloc_type_ba, /* R_RBAC (0x19) */
+ xcoff64_reloc_type_br, /* R_RBR (0x1a) */
+ xcoff_reloc_type_ba, /* R_RBRC (0x1b) */
+};
+
/* coffcode.h needs these to be defined. */
/* Internalcoff.h and coffcode.h modify themselves based on these flags. */
#define XCOFF64
@@ -1030,6 +1066,84 @@ xcoff64_write_object_contents (abfd)
return true;
}
+static boolean
+xcoff64_reloc_type_br (input_bfd, input_section, output_bfd, rel, sym, howto,
+ val, addend, relocation, contents)
+ bfd *input_bfd;
+ asection *input_section;
+ bfd *output_bfd ATTRIBUTE_UNUSED;
+ struct internal_reloc *rel;
+ struct internal_syment *sym ATTRIBUTE_UNUSED;
+ struct reloc_howto_struct *howto;
+ bfd_vma val;
+ bfd_vma addend;
+ bfd_vma *relocation;
+ bfd_byte *contents;
+{
+ struct xcoff_link_hash_entry *h;
+
+ if (0 > rel->r_symndx)
+ return false;
+
+ h = obj_xcoff_sym_hashes (input_bfd)[rel->r_symndx];
+
+ /* If we see an R_BR or R_RBR reloc which is jumping to global
+ linkage code, and it is followed by an appropriate cror nop
+ instruction, we replace the cror with ld r2,40(r1). This
+ restores the TOC after the glink code. Contrariwise, if the
+ call is followed by a ld r2,40(r1), but the call is not
+ going to global linkage code, we can replace the load with a
+ cror. */
+ if (NULL != h
+ && bfd_link_hash_defined == h->root.type
+ && (rel->r_vaddr - input_section->vma + 8 <=
+ input_section->_cooked_size))
+ {
+ bfd_byte *pnext;
+ unsigned long next;
+
+ pnext = contents + (rel->r_vaddr - input_section->vma) + 4;
+ next = bfd_get_32 (input_bfd, pnext);
+
+ /* The _ptrgl function is magic. It is used by the AIX compiler to call
+ a function through a pointer. */
+ if (h->smclas == XMC_GL || strcmp (h->root.root.string, "._ptrgl") == 0)
+ {
+ if (next == 0x4def7b82 /* cror 15,15,15 */
+ || next == 0x4ffffb82 /* cror 31,31,31 */
+ || next == 0x60000000) /* ori r0,r0,0 */
+ bfd_put_32 (input_bfd, 0xe8410028, pnext); /* ld r2,40(r1) */
+ }
+ else
+ {
+ if (next == 0xe8410028) /* ld r2,40(r1) */
+ bfd_put_32 (input_bfd, 0x60000000, pnext); /* ori r0,r0,0 */
+ }
+ }
+ else if (NULL != h && bfd_link_hash_undefined == h->root.type)
+ {
+ /* Normally, this relocation is against a defined symbol. In the
+ case where this is a partial link and the output section offset
+ is greater than 2^25, the linker will return an invalid error
+ message that the relocation has been truncated. Yes it has been
+ truncated but no it not important. For this case, disable the
+ overflow checking. */
+ howto->complain_on_overflow = complain_overflow_dont;
+ }
+
+ howto->pc_relative = true;
+ howto->src_mask &= ~3;
+ howto->dst_mask = howto->src_mask;
+
+ /* A PC relative reloc includes the section address. */
+ addend += input_section->vma;
+
+ *relocation = val + addend;
+ *relocation -= (input_section->output_section->vma +
+ input_section->output_offset);
+ return true;
+}
+
/* This is the relocation function for the PowerPC64.
See xcoff_ppc_relocation_section for more information. */
@@ -1146,7 +1260,7 @@ xcoff64_ppc_relocate_section (output_bfd, info, input_bfd,
}
if (rel->r_type >= XCOFF_MAX_CALCULATE_RELOCATION
- || (false == xcoff_calculate_relocation[rel->r_type]
+ || (false == xcoff64_calculate_relocation[rel->r_type]
(input_bfd, input_section, output_bfd, rel, sym, &howto, val,
addend, &relocation, contents)))
return false;
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index ef219e4..5959077 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -804,6 +804,11 @@ struct elf_backend_data
section. */
unsigned default_use_rela_p : 1;
+ /* Set if RELA relocations for a relocatable link can be handled by
+ generic code. Backends that set this flag need do nothing in the
+ backend relocate_section routine for relocatable linking. */
+ unsigned rela_normal : 1;
+
/* True if addresses "naturally" sign extend. This is used when
swapping in from Elf32 when BFD64. */
unsigned sign_extend_vma : 1;
diff --git a/bfd/elf-m10200.c b/bfd/elf-m10200.c
index e514934..4e8de60 100644
--- a/bfd/elf-m10200.c
+++ b/bfd/elf-m10200.c
@@ -1,5 +1,5 @@
/* Matsushita 10200 specific support for 32-bit ELF
- Copyright 1996, 1997, 1998, 1999, 2000, 2001
+ Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
@@ -347,6 +347,9 @@ mn10200_elf_relocate_section (output_bfd, info, input_bfd, input_section,
struct elf_link_hash_entry **sym_hashes;
Elf_Internal_Rela *rel, *relend;
+ if (info->relocateable)
+ return true;
+
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (input_bfd);
@@ -367,26 +370,6 @@ mn10200_elf_relocate_section (output_bfd, info, input_bfd, input_section,
r_type = ELF32_R_TYPE (rel->r_info);
howto = elf_mn10200_howto_table + r_type;
- if (info->relocateable)
- {
- /* This is a relocateable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sec = local_sections[r_symndx];
- rel->r_addend += sec->output_offset + sym->st_value;
- }
- }
-
- continue;
- }
-
- /* This is a final link. */
h = NULL;
sym = NULL;
sec = NULL;
@@ -1572,6 +1555,7 @@ mn10200_elf_get_relocated_section_contents (output_bfd, link_info, link_order,
#define ELF_MACHINE_ALT1 EM_CYGNUS_MN10200
#define ELF_MAXPAGESIZE 0x1000
+#define elf_backend_rela_normal 1
#define elf_info_to_howto mn10200_info_to_howto
#define elf_info_to_howto_rel 0
#define elf_backend_relocate_section mn10200_elf_relocate_section
diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c
index ce68a16..40b4ad6 100644
--- a/bfd/elf-m10300.c
+++ b/bfd/elf-m10300.c
@@ -553,6 +553,9 @@ mn10300_elf_relocate_section (output_bfd, info, input_bfd, input_section,
struct elf32_mn10300_link_hash_entry **sym_hashes;
Elf_Internal_Rela *rel, *relend;
+ if (info->relocateable)
+ return true;
+
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
sym_hashes = (struct elf32_mn10300_link_hash_entry **)
(elf_sym_hashes (input_bfd));
@@ -579,26 +582,6 @@ mn10300_elf_relocate_section (output_bfd, info, input_bfd, input_section,
|| r_type == R_MN10300_GNU_VTENTRY)
continue;
- if (info->relocateable)
- {
- /* This is a relocateable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sec = local_sections[r_symndx];
- rel->r_addend += sec->output_offset + sym->st_value;
- }
- }
-
- continue;
- }
-
- /* This is a final link. */
h = NULL;
sym = NULL;
sec = NULL;
@@ -3101,6 +3084,7 @@ _bfd_mn10300_elf_merge_private_bfd_data (ibfd, obfd)
#define elf_info_to_howto mn10300_info_to_howto
#define elf_info_to_howto_rel 0
#define elf_backend_can_gc_sections 1
+#define elf_backend_rela_normal 1
#define elf_backend_check_relocs mn10300_elf_check_relocs
#define elf_backend_gc_mark_hook mn10300_elf_gc_mark_hook
#define elf_backend_relocate_section mn10300_elf_relocate_section
diff --git a/bfd/elf32-arm.h b/bfd/elf32-arm.h
index 51c51a4..91ea63b 100644
--- a/bfd/elf32-arm.h
+++ b/bfd/elf32-arm.h
@@ -1830,6 +1830,11 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section,
Elf_Internal_Rela * relend;
const char * name;
+#ifndef USE_REL
+ if (info->relocateable)
+ return true;
+#endif
+
symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (input_bfd);
@@ -1862,6 +1867,7 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section,
#endif
howto = bfd_reloc.howto;
+#ifdef USE_REL
if (info->relocateable)
{
/* This is a relocateable link. We don't have to change
@@ -1874,19 +1880,16 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section,
if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
{
sec = local_sections[r_symndx];
-#ifdef USE_REL
arm_add_to_rel (input_bfd, contents + rel->r_offset,
howto,
(bfd_signed_vma) (sec->output_offset
+ sym->st_value));
-#else
- rel->r_addend += (sec->output_offset + sym->st_value);
-#endif
}
}
continue;
}
+#endif
/* This is a final link. */
h = NULL;
@@ -3637,6 +3640,9 @@ elf32_arm_reloc_type_class (rela)
#define elf_backend_plt_readonly 1
#define elf_backend_want_got_plt 1
#define elf_backend_want_plt_sym 0
+#ifndef USE_REL
+#define elf_backend_rela_normal 1
+#endif
#define elf_backend_got_header_size 12
#define elf_backend_plt_header_size PLT_ENTRY_SIZE
diff --git a/bfd/elf32-fr30.c b/bfd/elf32-fr30.c
index 8e31d67..e1bc741 100644
--- a/bfd/elf32-fr30.c
+++ b/bfd/elf32-fr30.c
@@ -1,5 +1,5 @@
/* FR30-specific support for 32-bit ELF.
- Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
@@ -517,6 +517,9 @@ fr30_elf_relocate_section (output_bfd, info, input_bfd, input_section,
Elf_Internal_Rela * rel;
Elf_Internal_Rela * relend;
+ if (info->relocateable)
+ return true;
+
symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (input_bfd);
relend = relocs + input_section->reloc_count;
@@ -541,27 +544,6 @@ fr30_elf_relocate_section (output_bfd, info, input_bfd, input_section,
r_symndx = ELF32_R_SYM (rel->r_info);
- if (info->relocateable)
- {
- /* This is a relocateable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
-
- if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sec = local_sections [r_symndx];
- rel->r_addend += sec->output_offset + sym->st_value;
- }
- }
-
- continue;
- }
-
- /* This is a final link. */
howto = fr30_elf_howto_table + ELF32_R_TYPE (rel->r_info);
h = NULL;
sym = NULL;
@@ -806,6 +788,7 @@ fr30_elf_check_relocs (abfd, info, sec, relocs)
#define elf_backend_check_relocs fr30_elf_check_relocs
#define elf_backend_can_gc_sections 1
+#define elf_backend_rela_normal 1
#define bfd_elf32_bfd_reloc_type_lookup fr30_reloc_type_lookup
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index f0fd549..4dc7e9b 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -3128,9 +3128,19 @@ elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size,
+ sym_sec->output_section->vma);
}
else if (hash->elf.root.type == bfd_link_hash_undefweak)
- ;
+ {
+ if (! info->shared)
+ continue;
+ }
else if (hash->elf.root.type == bfd_link_hash_undefined)
- ;
+ {
+ if (! (info->shared
+ && !info->no_undefined
+ && (ELF_ST_VISIBILITY (hash->elf.other)
+ == STV_DEFAULT)
+ && hash->elf.type != STT_PARISC_MILLI))
+ continue;
+ }
else
{
bfd_set_error (bfd_error_bad_value);
diff --git a/bfd/elf32-i370.c b/bfd/elf32-i370.c
index 07d5f9d..fc82b47 100644
--- a/bfd/elf32-i370.c
+++ b/bfd/elf32-i370.c
@@ -1277,6 +1277,9 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
bfd_vma *local_got_offsets;
boolean ret = true;
+ if (info->relocateable)
+ return true;
+
#ifdef DEBUG
fprintf (stderr, "i370_elf_relocate_section called for %s section %s, %ld relocations%s\n",
bfd_archive_filename (input_bfd),
@@ -1320,34 +1323,6 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
howto = i370_elf_howto_table[(int)r_type];
r_symndx = ELF32_R_SYM (rel->r_info);
- if (info->relocateable)
- {
- /* This is a relocateable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- if ((unsigned)ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sec = local_sections[r_symndx];
- addend = rel->r_addend += sec->output_offset + sym->st_value;
- }
- }
-
-#ifdef DEBUG
- fprintf (stderr, "\ttype = %s (%d), symbol index = %ld, offset = %ld, addend = %ld\n",
- howto->name,
- (int)r_type,
- r_symndx,
- (long)offset,
- (long)addend);
-#endif
- continue;
- }
-
- /* This is a final link. */
if (r_symndx < symtab_hdr->sh_info)
{
sym = local_syms + r_symndx;
@@ -1661,6 +1636,7 @@ i370_elf_post_process_headers (abfd, link_info)
#define elf_backend_plt_not_loaded 1
#define elf_backend_got_symbol_offset 4
+#define elf_backend_rela_normal 1
#define bfd_elf32_bfd_reloc_type_lookup i370_elf_reloc_type_lookup
#define bfd_elf32_bfd_set_private_flags i370_elf_set_private_flags
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 7165e84..760762d 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -154,7 +154,7 @@ static reloc_howto_type elf_howto_table[]=
false, /* partial_inplace */
0, /* src_mask */
0, /* dst_mask */
- false),
+ false), /* pcrel_offset */
/* GNU extension to record C++ vtable member usage. */
HOWTO (R_386_GNU_VTENTRY, /* type */
@@ -169,7 +169,7 @@ static reloc_howto_type elf_howto_table[]=
false, /* partial_inplace */
0, /* src_mask */
0, /* dst_mask */
- false)
+ false) /* pcrel_offset */
#define R_386_vt ((unsigned int) R_386_GNU_VTENTRY + 1 - R_386_vt_offset)
@@ -1745,22 +1745,43 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
if (info->relocateable)
{
+ bfd_vma val;
+ bfd_byte *where;
+
/* This is a relocatable link. We don't have to change
anything, unless the reloc is against a section symbol,
in which case we have to adjust according to where the
section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- bfd_vma val;
+ if (r_symndx >= symtab_hdr->sh_info)
+ continue;
- sec = local_sections[r_symndx];
- val = bfd_get_32 (input_bfd, contents + rel->r_offset);
- val += sec->output_offset + sym->st_value;
- bfd_put_32 (input_bfd, val, contents + rel->r_offset);
- }
+ sym = local_syms + r_symndx;
+ if (ELF_ST_TYPE (sym->st_info) != STT_SECTION)
+ continue;
+
+ sec = local_sections[r_symndx];
+ val = sec->output_offset;
+ if (val == 0)
+ continue;
+
+ where = contents + rel->r_offset;
+ switch (howto->size)
+ {
+ /* FIXME: overflow checks. */
+ case 0:
+ val += bfd_get_8 (input_bfd, where);
+ bfd_put_8 (input_bfd, val, where);
+ break;
+ case 1:
+ val += bfd_get_16 (input_bfd, where);
+ bfd_put_16 (input_bfd, val, where);
+ break;
+ case 2:
+ val += bfd_get_32 (input_bfd, where);
+ bfd_put_32 (input_bfd, val, where);
+ break;
+ default:
+ abort ();
}
continue;
}
@@ -1782,24 +1803,62 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
{
asection *msec;
bfd_vma addend;
+ bfd_byte *where = contents + rel->r_offset;
- if (howto->src_mask != 0xffffffff)
+ switch (howto->size)
{
- (*_bfd_error_handler)
- (_("%s(%s+0x%lx): %s relocation against SEC_MERGE section"),
- bfd_archive_filename (input_bfd),
- bfd_get_section_name (input_bfd, input_section),
- (long) rel->r_offset, howto->name);
- return false;
+ case 0:
+ addend = bfd_get_8 (input_bfd, where);
+ if (howto->pc_relative)
+ {
+ addend = (addend ^ 0x80) - 0x80;
+ addend += 1;
+ }
+ break;
+ case 1:
+ addend = bfd_get_16 (input_bfd, where);
+ if (howto->pc_relative)
+ {
+ addend = (addend ^ 0x8000) - 0x8000;
+ addend += 2;
+ }
+ break;
+ case 2:
+ addend = bfd_get_32 (input_bfd, where);
+ if (howto->pc_relative)
+ {
+ addend = (addend ^ 0x80000000) - 0x80000000;
+ addend += 4;
+ }
+ break;
+ default:
+ abort ();
}
- addend = bfd_get_32 (input_bfd, contents + rel->r_offset);
msec = sec;
- addend =
- _bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend)
- - relocation;
+ addend = _bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend);
+ addend -= relocation;
addend += msec->output_section->vma + msec->output_offset;
- bfd_put_32 (input_bfd, addend, contents + rel->r_offset);
+
+ switch (howto->size)
+ {
+ case 0:
+ /* FIXME: overflow checks. */
+ if (howto->pc_relative)
+ addend -= 1;
+ bfd_put_8 (input_bfd, addend, where);
+ break;
+ case 1:
+ if (howto->pc_relative)
+ addend -= 2;
+ bfd_put_16 (input_bfd, addend, where);
+ break;
+ case 2:
+ if (howto->pc_relative)
+ addend -= 4;
+ bfd_put_32 (input_bfd, addend, where);
+ break;
+ }
}
}
else
@@ -2102,7 +2161,6 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
if (r == bfd_reloc_overflow)
{
-
if (! ((*info->callbacks->reloc_overflow)
(info, name, howto->name, (bfd_vma) 0,
input_bfd, input_section, rel->r_offset)))
diff --git a/bfd/elf32-i860.c b/bfd/elf32-i860.c
index 7b5d052..82c7190 100644
--- a/bfd/elf32-i860.c
+++ b/bfd/elf32-i860.c
@@ -1,5 +1,6 @@
/* Intel i860 specific support for 32-bit ELF.
- Copyright 1993, 1995, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright 1993, 1995, 1999, 2000, 2001, 2002
+ Free Software Foundation, Inc.
Full i860 support contributed by Jason Eckhardt <jle@cygnus.com>.
@@ -878,6 +879,9 @@ elf32_i860_relocate_section (output_bfd, info, input_bfd, input_section,
Elf_Internal_Rela * rel;
Elf_Internal_Rela * relend;
+ if (info->relocateable)
+ return true;
+
symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (input_bfd);
relend = relocs + input_section->reloc_count;
@@ -904,27 +908,6 @@ elf32_i860_relocate_section (output_bfd, info, input_bfd, input_section,
r_symndx = ELF32_R_SYM (rel->r_info);
- if (info->relocateable)
- {
- /* This is a relocateable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
-
- if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sec = local_sections [r_symndx];
- rel->r_addend += sec->output_offset + sym->st_value;
- }
- }
-
- continue;
- }
-
- /* This is a final link. */
howto = lookup_howto ((unsigned) ELF32_R_TYPE (rel->r_info));
h = NULL;
sym = NULL;
@@ -1097,6 +1080,7 @@ elf32_i860_is_local_label_name (abfd, name)
#define ELF_MACHINE_CODE EM_860
#define ELF_MAXPAGESIZE 4096
+#define elf_backend_rela_normal 1
#define elf_info_to_howto_rel NULL
#define elf_info_to_howto elf32_i860_info_to_howto_rela
#define elf_backend_relocate_section elf32_i860_relocate_section
diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c
index b3b6220..e8015a9 100644
--- a/bfd/elf32-m32r.c
+++ b/bfd/elf32-m32r.c
@@ -981,6 +981,11 @@ m32r_elf_relocate_section (output_bfd, info, input_bfd, input_section,
/* Assume success. */
boolean ret = true;
+#ifndef USE_REL
+ if (info->relocateable)
+ return true;
+#endif
+
rel = relocs;
relend = relocs + input_section->reloc_count;
for (; rel < relend; rel++)
@@ -1020,6 +1025,7 @@ m32r_elf_relocate_section (output_bfd, info, input_bfd, input_section,
howto = m32r_elf_howto_table + r_type;
r_symndx = ELF32_R_SYM (rel->r_info);
+#ifdef USE_REL
if (info->relocateable)
{
/* This is a relocateable link. We don't have to change
@@ -1045,16 +1051,7 @@ m32r_elf_relocate_section (output_bfd, info, input_bfd, input_section,
sec = local_sections[r_symndx];
addend += sec->output_offset + sym->st_value;
-#ifndef USE_REL
- /* This can't be done for USE_REL because it doesn't mean anything
- and elf_link_input_bfd asserts this stays zero. */
- rel->r_addend = addend;
-#endif
-#ifndef USE_REL
- /* Addends are stored with relocs. We're done. */
- continue;
-#else /* USE_REL */
/* If partial_inplace, we need to store any additional addend
back in the section. */
if (! howto->partial_inplace)
@@ -1088,9 +1085,9 @@ m32r_elf_relocate_section (output_bfd, info, input_bfd, input_section,
r = _bfd_relocate_contents (howto, input_bfd,
addend, contents + offset);
}
-#endif /* USE_REL */
}
else
+#endif /* USE_REL */
{
bfd_vma relocation;
@@ -2161,6 +2158,9 @@ m32r_elf_check_relocs (abfd, info, sec, relocs)
#define elf_backend_check_relocs m32r_elf_check_relocs
#define elf_backend_can_gc_sections 1
+#ifndef USE_REL
+#define elf_backend_rela_normal 1
+#endif
#if 0 /* not yet */
/* relax support */
#define bfd_elf32_bfd_relax_section m32r_elf_relax_section
diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c
index 9267e47..7d5b016 100644
--- a/bfd/elf32-m68k.c
+++ b/bfd/elf32-m68k.c
@@ -1308,6 +1308,9 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
Elf_Internal_Rela *rel;
Elf_Internal_Rela *relend;
+ if (info->relocateable)
+ return true;
+
dynobj = elf_hash_table (info)->dynobj;
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (input_bfd);
@@ -1340,26 +1343,6 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
r_symndx = ELF32_R_SYM (rel->r_info);
- if (info->relocateable)
- {
- /* This is a relocateable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sec = local_sections[r_symndx];
- rel->r_addend += sec->output_offset + sym->st_value;
- }
- }
-
- continue;
- }
-
- /* This is a final link. */
h = NULL;
sym = NULL;
sec = NULL;
@@ -2325,5 +2308,6 @@ elf32_m68k_reloc_type_class (rela)
#define elf_backend_plt_readonly 1
#define elf_backend_want_plt_sym 0
#define elf_backend_got_header_size 12
+#define elf_backend_rela_normal 1
#include "elf32-target.h"
diff --git a/bfd/elf32-mcore.c b/bfd/elf32-mcore.c
index a0784f6..38e9c13 100644
--- a/bfd/elf32-mcore.c
+++ b/bfd/elf32-mcore.c
@@ -1,5 +1,6 @@
/* Motorola MCore specific support for 32-bit ELF
- Copyright 1994, 1995, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright 1994, 1995, 1999, 2000, 2001, 2002
+ Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
@@ -414,6 +415,9 @@ mcore_elf_relocate_section (output_bfd, info, input_bfd, input_section,
(info->relocateable) ? " (relocatable)" : "");
#endif
+ if (info->relocateable)
+ return true;
+
if (! mcore_elf_howto_table [R_MCORE_PCRELIMM8BY4]) /* Initialize howto table if needed */
mcore_elf_howto_init ();
@@ -447,32 +451,6 @@ mcore_elf_relocate_section (output_bfd, info, input_bfd, input_section,
howto = mcore_elf_howto_table [(int) r_type];
r_symndx = ELF32_R_SYM (rel->r_info);
- if (info->relocateable)
- {
- /* This is a relocateable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
-
- if ((unsigned)ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sec = local_sections[r_symndx];
- addend = rel->r_addend += sec->output_offset + sym->st_value;
- }
- }
-
-#ifdef DEBUG
- fprintf (stderr, "\ttype = %s (%d), symbol index = %ld, offset = %ld, addend = %ld\n",
- howto->name, (int) r_type, r_symndx, (long) offset, (long) addend);
-#endif
- continue;
- }
-
- /* This is a final link. */
-
/* Complain about known relocation that are not yet supported. */
if (howto->special_function == mcore_elf_unsupported_reloc)
{
@@ -726,5 +704,6 @@ mcore_elf_check_relocs (abfd, info, sec, relocs)
#define elf_backend_check_relocs mcore_elf_check_relocs
#define elf_backend_can_gc_sections 1
+#define elf_backend_rela_normal 1
#include "elf32-target.h"
diff --git a/bfd/elf32-openrisc.c b/bfd/elf32-openrisc.c
index 5f60366..34d4d9f 100644
--- a/bfd/elf32-openrisc.c
+++ b/bfd/elf32-openrisc.c
@@ -1,5 +1,5 @@
/* OpenRISC-specific support for 32-bit ELF.
- Copyright 2001 Free Software Foundation, Inc.
+ Copyright 2001, 2002 Free Software Foundation, Inc.
Contributed by Johan Rydberg, jrydberg@opencores.org
This file is part of BFD, the Binary File Descriptor library.
@@ -338,6 +338,9 @@ openrisc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
Elf_Internal_Rela *rel;
Elf_Internal_Rela *relend;
+ if (info->relocateable)
+ return true;
+
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (input_bfd);
relend = relocs + input_section->reloc_count;
@@ -361,25 +364,6 @@ openrisc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
|| r_type == R_OPENRISC_GNU_VTENTRY)
continue;
- if (info->relocateable)
- {
- /* This is a relocateable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
-
- if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sec = local_sections[r_symndx];
- rel->r_addend += sec->output_offset + sym->st_value;
- }
- }
- continue;
- }
-
if ((unsigned int) r_type >
(sizeof openrisc_elf_howto_table / sizeof (reloc_howto_type)))
abort ();
@@ -645,6 +629,7 @@ openrisc_elf_final_write_processing (abfd, linker)
#define elf_backend_check_relocs openrisc_elf_check_relocs
#define elf_backend_can_gc_sections 1
+#define elf_backend_rela_normal 1
#define bfd_elf32_bfd_reloc_type_lookup openrisc_reloc_type_lookup
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index f68d914..31d9e0c 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -1,5 +1,5 @@
/* PowerPC-specific support for 32-bit ELF
- Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+ Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support.
@@ -49,6 +49,8 @@ static boolean ppc_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *));
static int ppc_elf_additional_program_headers PARAMS ((bfd *));
static boolean ppc_elf_modify_segment_map PARAMS ((bfd *));
+static asection *ppc_elf_create_got
+ PARAMS ((bfd *, struct bfd_link_info *));
static boolean ppc_elf_create_dynamic_sections
PARAMS ((bfd *, struct bfd_link_info *));
@@ -1632,6 +1634,30 @@ ppc_elf_modify_segment_map (abfd)
return true;
}
+/* The powerpc .got has a blrl instruction in it. Mark it executable. */
+
+static asection *
+ppc_elf_create_got (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ register asection *s;
+ flagword flags;
+
+ if (!_bfd_elf_create_got_section (abfd, info))
+ return NULL;
+
+ s = bfd_get_section_by_name (abfd, ".got");
+ if (s == NULL)
+ abort ();
+
+ flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED);
+ if (!bfd_set_section_flags (abfd, s, flags))
+ return NULL;
+ return s;
+}
+
/* We have to create .dynsbss and .rela.sbss here so that they get mapped
to output sections (just like _bfd_elf_create_dynamic_sections has
to create .dynbss and .rela.bss). */
@@ -1644,6 +1670,9 @@ ppc_elf_create_dynamic_sections (abfd, info)
register asection *s;
flagword flags;
+ if (!ppc_elf_create_got (abfd, info))
+ return false;
+
if (!_bfd_elf_create_dynamic_sections (abfd, info))
return false;
@@ -1663,7 +1692,13 @@ ppc_elf_create_dynamic_sections (abfd, info)
|| ! bfd_set_section_alignment (abfd, s, 2))
return false;
}
- return true;
+
+ s = bfd_get_section_by_name (abfd, ".plt");
+ if (s == NULL)
+ abort ();
+
+ flags = SEC_ALLOC | SEC_CODE | SEC_IN_MEMORY | SEC_LINKER_CREATED;
+ return bfd_set_section_flags (abfd, s, flags);
}
/* Adjust a symbol defined by a dynamic object and referenced by a
@@ -2119,10 +2154,9 @@ ppc_elf_check_relocs (abfd, info, sec, relocs)
{
if (dynobj == NULL)
elf_hash_table (info)->dynobj = dynobj = abfd;
- if (! _bfd_elf_create_got_section (dynobj, info))
+ sgot = ppc_elf_create_got (dynobj, info);
+ if (sgot == NULL)
return false;
- sgot = bfd_get_section_by_name (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
}
}
@@ -2139,10 +2173,9 @@ ppc_elf_check_relocs (abfd, info, sec, relocs)
{
if (dynobj == NULL)
elf_hash_table (info)->dynobj = dynobj = abfd;
- if (! _bfd_elf_create_got_section (dynobj, info))
+ sgot = ppc_elf_create_got (dynobj, info);
+ if (sgot == NULL)
return false;
- sgot = bfd_get_section_by_name (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
}
if (srelgot == NULL
@@ -2896,6 +2929,9 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
(info->relocateable) ? " (relocatable)" : "");
#endif
+ if (info->relocateable)
+ return true;
+
if (!ppc_elf_howto_table[R_PPC_ADDR32])
/* Initialize howto table if needed. */
ppc_elf_howto_init ();
@@ -2940,34 +2976,6 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
howto = ppc_elf_howto_table[(int) r_type];
r_symndx = ELF32_R_SYM (rel->r_info);
- if (info->relocateable)
- {
- /* This is a relocateable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- if ((unsigned) ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sec = local_sections[r_symndx];
- addend = rel->r_addend += sec->output_offset + sym->st_value;
- }
- }
-
-#ifdef DEBUG
- fprintf (stderr, "\ttype = %s (%d), symbol index = %ld, offset = %ld, addend = %ld\n",
- howto->name,
- (int) r_type,
- r_symndx,
- (long) offset,
- (long) addend);
-#endif
- continue;
- }
-
- /* This is a final link. */
if (r_symndx < symtab_hdr->sh_info)
{
sym = local_syms + r_symndx;
@@ -3781,6 +3789,7 @@ ppc_elf_grok_psinfo (abfd, note)
#define elf_backend_can_refcount 1
#define elf_backend_got_header_size 12
#define elf_backend_plt_header_size PLT_INITIAL_ENTRY_SIZE
+#define elf_backend_rela_normal 1
#define bfd_elf32_bfd_merge_private_bfd_data ppc_elf_merge_private_bfd_data
#define bfd_elf32_bfd_relax_section ppc_elf_relax_section
diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
index 8c6f546..5032a5c 100644
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -1632,6 +1632,9 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
Elf_Internal_Rela *rel;
Elf_Internal_Rela *relend;
+ if (info->relocateable)
+ return true;
+
htab = elf_s390_hash_table (info);
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (input_bfd);
@@ -1661,30 +1664,9 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
bfd_set_error (bfd_error_bad_value);
return false;
}
- howto = elf_howto_table + r_type;
+ howto = elf_howto_table + r_type;
r_symndx = ELF32_R_SYM (rel->r_info);
-
- if (info->relocateable)
- {
- /* This is a relocateable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sec = local_sections[r_symndx];
- rel->r_addend += sec->output_offset + sym->st_value;
- }
- }
-
- continue;
- }
-
- /* This is a final link. */
h = NULL;
sym = NULL;
sec = NULL;
@@ -2467,6 +2449,7 @@ elf_s390_grok_prstatus (abfd, note)
#define elf_backend_want_plt_sym 0
#define elf_backend_got_header_size 12
#define elf_backend_plt_header_size PLT_ENTRY_SIZE
+#define elf_backend_rela_normal 1
#define elf_info_to_howto elf_s390_info_to_howto
diff --git a/bfd/elf32-xstormy16.c b/bfd/elf32-xstormy16.c
index 484acdd..d6b8dd3 100644
--- a/bfd/elf32-xstormy16.c
+++ b/bfd/elf32-xstormy16.c
@@ -790,6 +790,9 @@ xstormy16_elf_relocate_section (output_bfd, info, input_bfd, input_section,
bfd *dynobj;
asection *splt;
+ if (info->relocateable)
+ return true;
+
symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (input_bfd);
relend = relocs + input_section->reloc_count;
@@ -818,28 +821,6 @@ xstormy16_elf_relocate_section (output_bfd, info, input_bfd, input_section,
continue;
r_symndx = ELF32_R_SYM (rel->r_info);
-
- if (info->relocateable)
- {
- /* This is a relocateable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
-
- if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sec = local_sections [r_symndx];
- rel->r_addend += sec->output_offset + sym->st_value;
- }
- }
-
- continue;
- }
-
- /* This is a final link. */
howto = xstormy16_elf_howto_table + ELF32_R_TYPE (rel->r_info);
h = NULL;
sym = NULL;
@@ -1108,6 +1089,7 @@ xstormy16_elf_gc_sweep_hook (abfd, info, sec, relocs)
xstormy16_elf_finish_dynamic_sections
#define elf_backend_can_gc_sections 1
+#define elf_backend_rela_normal 1
#define bfd_elf32_bfd_reloc_type_lookup xstormy16_reloc_type_lookup
#define bfd_elf32_bfd_relax_section xstormy16_elf_relax_section
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 6cff281..5ae3aef 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -63,12 +63,6 @@ static boolean ppc64_elf_section_from_shdr
PARAMS ((bfd *, Elf64_Internal_Shdr *, char *));
-/* Mask to set RA in memory instructions. */
-#define RA_REGISTER_MASK 0x001f0000
-
-/* Value to shift register by to insert RA. */
-#define RA_REGISTER_SHIFT 16
-
/* The name of the dynamic interpreter. This is put in the .interp
section. */
#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
@@ -482,7 +476,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
0, /* rightshift */
4, /* size (0=byte, 1=short, 2=long, 4=64 bits) */
64, /* bitsize */
- true, /* pc_relative */
+ false, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
bfd_elf_generic_reloc, /* special_function */
@@ -490,7 +484,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = {
false, /* partial_inplace */
0, /* src_mask */
0xffffffffffffffff, /* dst_mask */
- true), /* pcrel_offset */
+ false), /* pcrel_offset */
/* Like R_PPC64_ADDR32, but may be unaligned. */
HOWTO (R_PPC64_UADDR32, /* type */
@@ -5051,6 +5045,9 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
/* Disabled until we sort out how ld should choose 'y' vs 'at'. */
boolean is_power4 = false;
+ if (info->relocateable)
+ return true;
+
/* Initialize howto table if needed. */
if (!ppc64_elf_howto_table[R_PPC64_ADDR32])
ppc_howto_init ();
@@ -5085,27 +5082,6 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rel->r_info);
r_symndx = ELF64_R_SYM (rel->r_info);
-
- if (info->relocateable)
- {
- /* This is a relocatable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- if ((unsigned) ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sec = local_sections[r_symndx];
- rel->r_addend += sec->output_offset + sym->st_value;
- }
- }
- continue;
- }
-
- /* This is a final link. */
-
offset = rel->r_offset;
addend = rel->r_addend;
r = bfd_reloc_other;
@@ -6053,6 +6029,7 @@ ppc64_elf_finish_dynamic_sections (output_bfd, info)
#define elf_backend_plt_header_size PLT_INITIAL_ENTRY_SIZE
#define elf_backend_can_gc_sections 1
#define elf_backend_can_refcount 1
+#define elf_backend_rela_normal 1
#define bfd_elf64_bfd_reloc_type_lookup ppc64_elf_reloc_type_lookup
#define bfd_elf64_bfd_set_private_flags ppc64_elf_set_private_flags
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index c4c3c1d..ceb5efa 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -1587,6 +1587,9 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
Elf_Internal_Rela *rel;
Elf_Internal_Rela *relend;
+ if (info->relocateable)
+ return true;
+
htab = elf_s390_hash_table (info);
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (input_bfd);
@@ -1616,30 +1619,9 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
bfd_set_error (bfd_error_bad_value);
return false;
}
- howto = elf_howto_table + r_type;
+ howto = elf_howto_table + r_type;
r_symndx = ELF64_R_SYM (rel->r_info);
-
- if (info->relocateable)
- {
- /* This is a relocateable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sec = local_sections[r_symndx];
- rel->r_addend += sec->output_offset + sym->st_value;
- }
- }
-
- continue;
- }
-
- /* This is a final link. */
h = NULL;
sym = NULL;
sec = NULL;
@@ -2384,6 +2366,7 @@ const struct elf_size_info s390_elf64_size_info =
#define elf_backend_want_plt_sym 0
#define elf_backend_got_header_size 24
#define elf_backend_plt_header_size PLT_ENTRY_SIZE
+#define elf_backend_rela_normal 1
#define elf_info_to_howto elf_s390_info_to_howto
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 5d77e7b..30cc29a 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -1494,6 +1494,9 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
Elf_Internal_Rela *rel;
Elf_Internal_Rela *relend;
+ if (info->relocateable)
+ return true;
+
htab = elf64_x86_64_hash_table (info);
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (input_bfd);
@@ -1524,30 +1527,9 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
bfd_set_error (bfd_error_bad_value);
return false;
}
- howto = x86_64_elf_howto_table + r_type;
+ howto = x86_64_elf_howto_table + r_type;
r_symndx = ELF64_R_SYM (rel->r_info);
-
- if (info->relocateable)
- {
- /* This is a relocateable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sec = local_sections[r_symndx];
- rel->r_addend += sec->output_offset + sym->st_value;
- }
- }
-
- continue;
- }
-
- /* This is a final link. */
h = NULL;
sym = NULL;
sec = NULL;
@@ -2230,6 +2212,7 @@ elf64_x86_64_finish_dynamic_sections (output_bfd, info)
#define elf_backend_want_plt_sym 0
#define elf_backend_got_header_size (GOT_ENTRY_SIZE*3)
#define elf_backend_plt_header_size PLT_ENTRY_SIZE
+#define elf_backend_rela_normal 1
#define elf_info_to_howto elf64_x86_64_info_to_howto
diff --git a/bfd/elflink.h b/bfd/elflink.h
index 37b2150..bfe6374 100644
--- a/bfd/elflink.h
+++ b/bfd/elflink.h
@@ -6754,6 +6754,12 @@ elf_link_input_bfd (finfo, input_bfd)
void (*reloc_emitter) PARAMS ((bfd *, asection *,
Elf_Internal_Shdr *,
Elf_Internal_Rela *));
+ boolean rela_normal;
+
+ input_rel_hdr = &elf_section_data (o)->rel_hdr;
+ rela_normal = (bed->rela_normal
+ && (input_rel_hdr->sh_entsize
+ == sizeof (Elf_External_Rela)));
/* Adjust the reloc addresses and symbol indices. */
@@ -6827,10 +6833,9 @@ elf_link_input_bfd (finfo, input_bfd)
processor specific section. If we have
discarded a section, the output_section will
be the absolute section. */
- if (sec != NULL
- && (bfd_is_abs_section (sec)
- || (sec->output_section != NULL
- && bfd_is_abs_section (sec->output_section))))
+ if (bfd_is_abs_section (sec)
+ || (sec != NULL
+ && bfd_is_abs_section (sec->output_section)))
r_symndx = 0;
else if (sec == NULL || sec->owner == NULL)
{
@@ -6842,6 +6847,11 @@ elf_link_input_bfd (finfo, input_bfd)
r_symndx = sec->output_section->target_index;
BFD_ASSERT (r_symndx != 0);
}
+
+ /* Adjust the addend according to where the
+ section winds up in the output section. */
+ if (rela_normal)
+ irela->r_addend += sec->output_offset;
}
else
{
@@ -6900,7 +6910,6 @@ elf_link_input_bfd (finfo, input_bfd)
else
reloc_emitter = elf_link_output_relocs;
- input_rel_hdr = &elf_section_data (o)->rel_hdr;
(*reloc_emitter) (output_bfd, o, input_rel_hdr, internal_relocs);
input_rel_hdr = elf_section_data (o)->rel_hdr2;
diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c
index aadb963..f92ab6a 100644
--- a/bfd/elfxx-ia64.c
+++ b/bfd/elfxx-ia64.c
@@ -3502,6 +3502,7 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section,
elf_section_data(input_section->output_section)
->this_hdr.sh_flags |= flags;
+ return true;
}
gp_val = _bfd_get_gp_value (output_bfd);
@@ -3534,29 +3535,9 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section,
ret_val = false;
continue;
}
+
howto = lookup_howto (r_type);
r_symndx = ELFNN_R_SYM (rel->r_info);
-
- if (info->relocateable)
- {
- /* This is a relocateable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sym_sec = local_sections[r_symndx];
- rel->r_addend += sym_sec->output_offset;
- }
- }
- continue;
- }
-
- /* This is a final link. */
-
h = NULL;
sym = NULL;
sym_sec = NULL;
@@ -4561,6 +4542,7 @@ elfNN_hpux_backend_section_from_bfd_section (abfd, sec, retval)
#define elf_backend_copy_indirect_symbol elfNN_ia64_hash_copy_indirect
#define elf_backend_hide_symbol elfNN_ia64_hash_hide_symbol
#define elf_backend_reloc_type_class elfNN_ia64_reloc_type_class
+#define elf_backend_rela_normal 1
#include "elfNN-target.h"
diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h
index c1c106f..7d391d4 100644
--- a/bfd/elfxx-target.h
+++ b/bfd/elfxx-target.h
@@ -400,6 +400,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define elf_backend_default_use_rela_p !USE_REL
#endif
+#ifndef elf_backend_rela_normal
+#define elf_backend_rela_normal 0
+#endif
+
#ifndef ELF_MACHINE_ALT1
#define ELF_MACHINE_ALT1 0
#endif
@@ -482,6 +486,7 @@ static const struct elf_backend_data elfNN_bed =
elf_backend_may_use_rel_p,
elf_backend_may_use_rela_p,
elf_backend_default_use_rela_p,
+ elf_backend_rela_normal,
elf_backend_sign_extend_vma,
elf_backend_want_got_plt,
elf_backend_plt_readonly,
diff --git a/bfd/libxcoff.h b/bfd/libxcoff.h
index 5e16fb2..7463eef 100644
--- a/bfd/libxcoff.h
+++ b/bfd/libxcoff.h
@@ -222,4 +222,14 @@ extern boolean (*xcoff_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION])
extern boolean (*xcoff_complain_overflow[XCOFF_MAX_COMPLAIN_OVERFLOW])
(XCOFF_COMPLAIN_FUNCTION_ARGS);
+/* Relocation functions */
+boolean xcoff_reloc_type_noop PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
+boolean xcoff_reloc_type_fail PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
+boolean xcoff_reloc_type_pos PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
+boolean xcoff_reloc_type_neg PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
+boolean xcoff_reloc_type_rel PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
+boolean xcoff_reloc_type_toc PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
+boolean xcoff_reloc_type_ba PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
+boolean xcoff_reloc_type_crel PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
+
#endif /* LIBXCOFF_H */
diff --git a/bfd/version.h b/bfd/version.h
index 952767f..6ab3d30 100644
--- a/bfd/version.h
+++ b/bfd/version.h
@@ -1 +1 @@
-#define BFD_VERSION_DATE 20020506
+#define BFD_VERSION_DATE 20020511