This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: ld is broken on ia64
On Sat, Nov 17, 2001 at 06:47:13PM -0800, H . J . Lu wrote:
>
> I believe this patch
>
> http://sources.redhat.com/ml/binutils/2001-11/msg00212.html
>
> breaks ia64, specifically
>
> http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/elflink.h.diff?cvsroot=src&r1=1.122&r2=1.123
>
> The problem is around line 3864 in elfxx-ia64.c:
>
> {
> /* If the input section was discarded from the output, then
> do nothing. */
>
> if (bfd_is_abs_section (sym_sec->output_section))
> r = bfd_reloc_ok;
> else
> r = bfd_reloc_notsupported;
> }
>
> since we are no longer clearing the relocation type. The relocations
> against the discarded sections remains, R_IA64_SEGREL64LSB in an unwind
> section. I think we should do something like
>
> http://sources.redhat.com/ml/binutils/2001-10/msg00589.html
>
> That is we have a default and allow each backend to decide what to do
> with relocations against the discarded sections.
>
>
With this patch, I can build shared libstdc++. I am doing a new
bootstrap now.
H.J.
----
2001-11-17 H.J. Lu (hjl@gnu.org)
* elf-bfd.h (struct elf_backend_data): Add
elf_backend_remove_linkonce_relocation.
(_bfd_elf32_remove_linkonce_relocation): Delcare.
(_bfd_elf64_remove_linkonce_relocation): Delcare.
* elfcode.h (elf_remove_linkonce_relocation): Define.
* elflink.h (elf_link_input_bfd): Call
elf_backend_remove_linkonce_relocation to remove a linkonce
relocation.
* elfxx-ia64.c (elfNN_ia64_remove_linkonce_relocation): Define.
(elf_backend_remove_linkonce_relocation): Defined as
elfNN_ia64_remove_linkonce_relocation.
* elfxx-target.h (elf_backend_remove_linkonce_relocation):
Define.
(elfNN_bed): Init elf_backend_remove_linkonce_relocation.
--- bfd/elf-bfd.h.linkonce Fri Nov 16 11:47:06 2001
+++ bfd/elf-bfd.h Sat Nov 17 17:26:49 2001
@@ -737,6 +737,11 @@ struct elf_backend_data
boolean (*elf_backend_write_section)
PARAMS ((bfd *, asection *, bfd_byte *));
+ /* This function modifies a relocation against a removed linkonce
+ section. */
+ void (*elf_backend_remove_linkonce_relocation)
+ PARAMS ((Elf_Internal_Rela *));
+
/* The swapping table to use when dealing with ECOFF information.
Used for the MIPS ELF .mdebug section. */
const struct ecoff_debug_swap *elf_backend_ecoff_debug_swap;
@@ -1459,6 +1464,11 @@ extern boolean _bfd_elf32_gc_record_vtin
PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
extern boolean _bfd_elf32_gc_record_vtentry
PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
+
+extern void _bfd_elf32_remove_linkonce_relocation
+ PARAMS ((Elf_Internal_Rela *));
+extern void _bfd_elf64_remove_linkonce_relocation
+ PARAMS ((Elf_Internal_Rela *));
extern boolean _bfd_elf64_gc_sections
PARAMS ((bfd *, struct bfd_link_info *));
--- bfd/elfcode.h.linkonce Fri Nov 16 11:47:18 2001
+++ bfd/elfcode.h Sat Nov 17 17:35:37 2001
@@ -137,6 +137,8 @@ Foundation, Inc., 59 Temple Place - Suit
#define elf_gc_record_vtentry NAME(_bfd_elf,gc_record_vtentry)
#define elf_link_record_local_dynamic_symbol \
NAME(_bfd_elf,link_record_local_dynamic_symbol)
+#define elf_remove_linkonce_relocation \
+ NAME(_bfd_elf,remove_linkonce_relocation)
#if ARCH_SIZE == 64
#define ELF_R_INFO(X,Y) ELF64_R_INFO(X,Y)
@@ -1432,6 +1434,14 @@ elf_slurp_reloc_table (abfd, asect, symb
asect->relocation = relents;
return true;
+}
+
+void
+elf_remove_linkonce_relocation (rel)
+ Elf_Internal_Rela *rel;
+{
+ rel->r_info = ELF_R_INFO (0, ELF_R_TYPE (rel->r_info));
+ rel->r_addend = 0;
}
#ifdef DEBUG
--- bfd/elflink.h.linkonce Fri Nov 16 11:47:19 2001
+++ bfd/elflink.h Sat Nov 17 17:26:49 2001
@@ -6540,9 +6540,7 @@ elf_link_input_bfd (finfo, input_bfd)
_("warning: relocation against removed section"),
NULL, input_bfd, o, rel->r_offset);
#endif
- rel->r_info
- = ELF_R_INFO (0, ELF_R_TYPE (rel->r_info));
- rel->r_addend = 0;
+ (*bed->elf_backend_remove_linkonce_relocation) (rel) ;
}
else
#endif
--- bfd/elfxx-ia64.c.linkonce Fri Nov 16 11:47:19 2001
+++ bfd/elfxx-ia64.c Sat Nov 17 17:29:49 2001
@@ -302,6 +302,8 @@ static boolean elfNN_ia64_print_private_
PARAMS ((bfd *abfd, PTR ptr));
static enum elf_reloc_type_class elfNN_ia64_reloc_type_class
PARAMS ((const Elf_Internal_Rela *));
+static void elfNN_ia64_remove_linkonce_relocation
+ PARAMS ((Elf_Internal_Rela *));
/* ia64-specific relocation */
@@ -4355,6 +4357,13 @@ elfNN_ia64_reloc_type_class (rela)
return reloc_class_normal;
}
}
+
+static void
+elfNN_ia64_remove_linkonce_relocation (rel)
+ Elf_Internal_Rela *rel;
+{
+ memset (rel, 0, sizeof (*rel));
+}
#define TARGET_LITTLE_SYM bfd_elfNN_ia64_little_vec
#define TARGET_LITTLE_NAME "elfNN-ia64-little"
@@ -4389,6 +4398,8 @@ elfNN_ia64_reloc_type_class (rela)
elfNN_ia64_is_local_label_name
#define bfd_elfNN_bfd_relax_section \
elfNN_ia64_relax_section
+#define elf_backend_remove_linkonce_relocation \
+ elfNN_ia64_remove_linkonce_relocation
/* Stuff for the BFD linker: */
#define bfd_elfNN_bfd_link_hash_table_create \
--- bfd/elfxx-target.h.linkonce Fri Nov 16 11:47:19 2001
+++ bfd/elfxx-target.h Sat Nov 17 17:30:34 2001
@@ -367,6 +367,10 @@ Foundation, Inc., 59 Temple Place - Suit
#ifndef elf_backend_write_section
#define elf_backend_write_section NULL
#endif
+#ifndef elf_backend_remove_linkonce_relocation
+#define elf_backend_remove_linkonce_relocation \
+ _bfd_elfNN_remove_linkonce_relocation
+#endif
/* Previously, backends could only use SHT_REL or SHT_RELA relocation
sections, but not both. They defined USE_REL to indicate SHT_REL
@@ -458,6 +462,7 @@ static const struct elf_backend_data elf
elf_backend_discard_info,
elf_backend_ignore_discarded_relocs,
elf_backend_write_section,
+ elf_backend_remove_linkonce_relocation,
elf_backend_ecoff_debug_swap,
ELF_MACHINE_ALT1,
ELF_MACHINE_ALT2,