This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Relocs against unalloced sections in shared libraries
- From: Andreas Schwab <schwab at suse dot de>
- To: binutils at sources dot redhat dot com
- Date: 10 Jan 2003 00:31:41 +0100
- Subject: Relocs against unalloced sections in shared libraries
Relocations against unallocated sections should never be propagated
into shared libraries.
Andreas.
2003-01-10 Andreas Schwab <schwab@suse.de>
* elf32-ppc.c (ppc_elf_check_relocs): Don't propagate relocations
against unallocated sections into shared libraries.
(ppc_elf_relocate_section): Likewise. Remove special case for
debugging sections.
--- bfd/elf32-ppc.c.~1.60.~ 2002-12-20 00:34:48.000000000 +0100
+++ bfd/elf32-ppc.c 2003-01-09 17:56:12.000000000 +0100
@@ -1,5 +1,5 @@
/* PowerPC-specific support for 32-bit ELF
- Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+ Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support.
@@ -2401,7 +2401,8 @@ ppc_elf_check_relocs (abfd, info, sec, r
/* fall through */
default:
- if (info->shared)
+ if (info->shared
+ && (sec->flags & SEC_ALLOC) != 0)
{
#ifdef DEBUG
fprintf (stderr, "ppc_elf_check_relocs need to create relocation for %s\n",
@@ -2429,9 +2430,8 @@ ppc_elf_check_relocs (abfd, info, sec, r
sreloc = bfd_make_section (dynobj, name);
flags = (SEC_HAS_CONTENTS | SEC_READONLY
- | SEC_IN_MEMORY | SEC_LINKER_CREATED);
- if ((sec->flags & SEC_ALLOC) != 0)
- flags |= SEC_ALLOC | SEC_LOAD;
+ | SEC_IN_MEMORY | SEC_LINKER_CREATED
+ | SEC_ALLOC | SEC_LOAD);
if (sreloc == NULL
|| ! bfd_set_section_flags (dynobj, sreloc, flags)
|| ! bfd_set_section_alignment (dynobj, sreloc, 2))
@@ -3022,14 +3022,7 @@ ppc_elf_relocate_section (output_bfd, in
&& (! info->shared || ! will_become_local))
|| (info->shared
&& ! will_become_local
- && ((input_section->flags & SEC_ALLOC) != 0
- /* Testing SEC_DEBUGGING here may be wrong.
- It's here to avoid a crash when
- generating a shared library with DWARF
- debugging information. */
- || ((input_section->flags & SEC_DEBUGGING) != 0
- && (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_DYNAMIC) != 0))
+ && (input_section->flags & SEC_ALLOC) != 0
&& (r_type == R_PPC_ADDR32
|| r_type == R_PPC_ADDR24
|| r_type == R_PPC_ADDR16
@@ -3164,7 +3157,9 @@ ppc_elf_relocate_section (output_bfd, in
case (int) R_PPC_ADDR14:
case (int) R_PPC_UADDR32:
case (int) R_PPC_UADDR16:
- if (info->shared && r_symndx != 0)
+ if (info->shared
+ && (input_section->flags & SEC_ALLOC) != 0
+ && r_symndx != 0)
{
Elf_Internal_Rela outrel;
bfd_byte *loc;