This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
PATCH: Fix linkonce for ELF/PPC.
On Sun, Oct 28, 2001 at 09:17:16AM -0800, H . J . Lu wrote:
> On Sun, Oct 28, 2001 at 11:29:05PM +1100, matthew green wrote:
> >
> > Alan mentioned that mrg@redhat.com's PPC change brake some PPC targets.
> > See
> >
> > http://sources.redhat.com/ml/binutils/2001-10/msg00473.html
> >
> >
> >
> > yes, i was wondering about the details on that, if it goes
> > beyond that already discussed here?
>
> I think I found the reason. For ELF/PPC, you cannot change the
> relocation type of a relocation against removed a linkonce section
> to R_PPC_NONE. That means we may have to introduce a new function
> to let each ELF target decide what to do with relocations against
> against removed linkonce sections. We can add something like
>
> bfd_vma
> bfd_elf_removed_linkonce_r_info (abfd, r_info);
> bfd *abfd;
> bfd_vma r_info;
> {
> return ELF_R_INFO (0, 0);
> }
>
> Each backend can override it if necassry. Alan, could you please look
> into it?
>
> Thanks.
>
This patch is against the today's CVS. Any comments?
Thanks.
H.J.
-----
2001-10-28 H.J. Lu (hjl@gnu.org)
* elf-bfd.h (struct elf_backend_data): Add
elf_backend_remove_linkonce_relocation.
(_bfd_elf_remove_linkonce_relocation): Delcare.
* elf.c (_bfd_elf_remove_linkonce_relocation): New. Clear the
relocation.
* elf32-ppc.c (ppc_elf_remove_linkonce_relocation): New. Only
clear the ELF_R_SYM bits.
(elf_backend_remove_linkonce_relocation): Define.
* elflink.h (elf_link_input_bfd): Call
elf_backend_remove_linkonce_relocation to remove a linkonce
relocation.
* elfxx-target.h (elf_backend_remove_linkonce_relocation):
Define.
(elfNN_bed): Init elf_backend_remove_linkonce_relocation.
--- bfd/elf-bfd.h.linkonce Mon Oct 15 12:43:09 2001
+++ bfd/elf-bfd.h Sun Oct 28 12:04:10 2001
@@ -699,6 +699,11 @@ struct elf_backend_data
enum elf_reloc_type_class (*elf_backend_reloc_type_class)
PARAMS ((const Elf_Internal_Rela *));
+ /* 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;
@@ -1110,6 +1115,9 @@ extern void _bfd_elf_fprintf_vma
extern enum elf_reloc_type_class _bfd_elf_reloc_type_class
PARAMS ((const Elf_Internal_Rela *));
+extern void _bfd_elf_remove_linkonce_relocation
+ PARAMS ((Elf_Internal_Rela *));
+
extern unsigned long bfd_elf_hash
PARAMS ((const char *));
--- bfd/elf.c.linkonce Sun Oct 28 11:25:36 2001
+++ bfd/elf.c Sun Oct 28 12:04:10 2001
@@ -6282,3 +6282,10 @@ _bfd_elf_reloc_type_class (rela)
{
return reloc_class_normal;
}
+
+void
+_bfd_elf_remove_linkonce_relocation (rel)
+ Elf_Internal_Rela *rel;
+{
+ memset (rel, 0, sizeof (*rel));
+}
--- bfd/elf32-ppc.c.linkonce Sun Oct 28 11:25:38 2001
+++ bfd/elf32-ppc.c Sun Oct 28 12:06:27 2001
@@ -110,6 +110,8 @@ static boolean ppc_elf_finish_dynamic_sy
static boolean ppc_elf_finish_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *));
static enum elf_reloc_type_class ppc_elf_reloc_type_class
PARAMS ((const Elf_Internal_Rela *));
+static void ppc_elf_remove_linkonce_relocation
+ PARAMS ((Elf_Internal_Rela *));
static boolean ppc_elf_grok_prstatus
PARAMS ((bfd *abfd, Elf_Internal_Note *note));
static boolean ppc_elf_grok_psinfo
@@ -3727,6 +3729,14 @@ ppc_elf_reloc_type_class (rela)
return reloc_class_normal;
}
}
+
+static void
+ppc_elf_remove_linkonce_relocation (rel)
+ Elf_Internal_Rela *rel;
+{
+ long r_type = ELF32_R_TYPE (rel->r_info);
+ rel->r_info = ELF32_R_INFO (0, r_type);
+}
/* Support for core dump NOTE sections */
static boolean
@@ -3841,5 +3851,6 @@ ppc_elf_grok_psinfo (abfd, note)
#define elf_backend_grok_prstatus ppc_elf_grok_prstatus
#define elf_backend_grok_psinfo ppc_elf_grok_psinfo
#define elf_backend_reloc_type_class ppc_elf_reloc_type_class
+#define elf_backend_remove_linkonce_relocation ppc_elf_remove_linkonce_relocation
#include "elf32-target.h"
--- bfd/elflink.h.linkonce Sun Oct 28 11:25:39 2001
+++ bfd/elflink.h Sun Oct 28 12:04:10 2001
@@ -6332,7 +6332,7 @@ elf_link_input_bfd (finfo, input_bfd)
_("warning: relocation against removed section; zeroing"),
NULL, input_bfd, o, rel->r_offset);
#endif
- memset (rel, 0, sizeof (*rel));
+ (*bed->elf_backend_remove_linkonce_relocation) (rel);
}
}
}
--- bfd/elfxx-target.h.linkonce Mon Oct 15 12:43:17 2001
+++ bfd/elfxx-target.h Sun Oct 28 12:04:10 2001
@@ -355,6 +355,10 @@ Foundation, Inc., 59 Temple Place - Suit
#ifndef elf_backend_reloc_type_class
#define elf_backend_reloc_type_class _bfd_elf_reloc_type_class
#endif
+#ifndef elf_backend_remove_linkonce_relocation
+#define elf_backend_remove_linkonce_relocation \
+ _bfd_elf_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
@@ -443,6 +447,7 @@ static const struct elf_backend_data elf
elf_backend_sprintf_vma,
elf_backend_fprintf_vma,
elf_backend_reloc_type_class,
+ elf_backend_remove_linkonce_relocation,
elf_backend_ecoff_debug_swap,
ELF_MACHINE_ALT1,
ELF_MACHINE_ALT2,