[PATCH] PPC and prelink
Jakub Jelinek
jakub@redhat.com
Tue Sep 17 10:24:00 GMT 2002
Hi!
On Tue, Sep 17, 2002 at 04:31:19PM +0930, Alan Modra wrote:
> On Tue, Sep 17, 2002 at 02:35:31AM -0400, Jakub Jelinek wrote:
> > But I'd need to know what should be the PPC canonical *r_offset value...
>
> Zero. powerpc is RELA, so the section contents don't matter. I don't
> think it makes any sense to both apply and emit relocs.
This patch should do the job, at least in my limited testing so far.
It would be good to test non-pic .so if that is supported on ppc
at all though to see if the insn fields are cleared.
2002-09-17 Jakub Jelinek <jakub@redhat.com>
* elf32-ppc.c (ppc_elf_finish_dynamic_symbol): Clear .got word
even if generating R_PPC_RELATIVE reloc.
(ppc_elf_relocate_section): Make sure relocation is performed if
skip == -2. Clear memory at r_offset when creating dynamic
relocation.
--- bfd/elf32-ppc.c.jj 2002-09-10 14:50:43.000000000 +0200
+++ bfd/elf32-ppc.c 2002-09-17 15:10:49.000000000 +0200
@@ -2743,11 +2743,11 @@ ppc_elf_finish_dynamic_symbol (output_bf
else
{
BFD_ASSERT ((h->got.offset & 1) == 0);
- bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset);
rela.r_info = ELF32_R_INFO (h->dynindx, R_PPC_GLOB_DAT);
rela.r_addend = 0;
}
+ bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset);
bfd_elf32_swap_reloca_out (output_bfd, &rela,
((Elf32_External_Rela *) srela->contents
+ srela->reloc_count));
@@ -3287,13 +3287,19 @@ ppc_elf_relocate_section (output_bfd, in
+ sreloc->reloc_count));
++sreloc->reloc_count;
- /* This reloc will be computed at runtime, so there's no
- need to do anything now, unless this is a RELATIVE
- reloc in an unallocated section. */
- if (skip != -1
- || (input_section->flags & SEC_ALLOC) != 0
- || ELF32_R_TYPE (outrel.r_info) != R_PPC_RELATIVE)
+ if (skip == -1)
continue;
+
+ /* This reloc will be computed at runtime. We clear the memory
+ so that it contains predictable value. */
+ if (! skip
+ && ((input_section->flags & SEC_ALLOC) != 0
+ || ELF32_R_TYPE (outrel.r_info) != R_PPC_RELATIVE))
+ {
+ relocation = howto->pc_relative ? outrel.r_offset : 0;
+ addend = 0;
+ break;
+ }
}
/* Arithmetic adjust relocations that aren't going into a
@@ -3390,7 +3396,6 @@ ppc_elf_relocate_section (output_bfd, in
off &= ~1;
else
{
- bfd_put_32 (output_bfd, relocation, sgot->contents + off);
if (info->shared)
{
@@ -3412,8 +3417,10 @@ ppc_elf_relocate_section (output_bfd, in
srelgot->contents)
+ srelgot->reloc_count));
++srelgot->reloc_count;
+ relocation = 0;
}
+ bfd_put_32 (output_bfd, relocation, sgot->contents + off);
local_got_offsets[r_symndx] |= 1;
}
Jakub
More information about the Binutils
mailing list