Fix PLT rewrite when prelinking fails on 32-bit sparc.

When prelinking fails we have to rewrite the PLT, but the code
doing so forgets to adjust all rela->r_offset addresses by the
location of where the object was actually mapped.
This commit is contained in:
David S. Miller 2010-02-20 13:40:59 -08:00
parent 1d204bf294
commit 5c866a8b9b
2 changed files with 15 additions and 6 deletions

View File

@ -1,3 +1,8 @@
2009-02-20 David S. Miller <davem@davemloft.net>
* sysdeps/sparc/sparc32/dl-machine.h (elf_machine_runtime_setup):
Adjust rela->r_offset by l->l_addr when rewriting PLT.
2009-02-20 Joseph Myers <joseph@codesourcery.com> 2009-02-20 Joseph Myers <joseph@codesourcery.com>
* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_runtime_setup): * sysdeps/sparc/sparc64/dl-machine.h (elf_machine_runtime_setup):

View File

@ -166,15 +166,19 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
in .rela.plt. */ in .rela.plt. */
while (rela < relaend) while (rela < relaend)
{ {
*(unsigned int *) rela->r_offset *(unsigned int *) (rela->r_offset + l->l_addr)
= OPCODE_SETHI_G1 | (rela->r_offset - (Elf32_Addr) plt); = OPCODE_SETHI_G1 | (rela->r_offset + l->l_addr
*(unsigned int *) (rela->r_offset + 4) - (Elf32_Addr) plt);
*(unsigned int *) (rela->r_offset + l->l_addr + 4)
= OPCODE_BA | ((((Elf32_Addr) plt = OPCODE_BA | ((((Elf32_Addr) plt
- rela->r_offset - 4) >> 2) & 0x3fffff); - rela->r_offset - l->l_addr - 4) >> 2)
& 0x3fffff);
if (do_flush) if (do_flush)
{ {
__asm __volatile ("flush %0" : : "r"(rela->r_offset)); __asm __volatile ("flush %0" : : "r" (rela->r_offset
__asm __volatile ("flush %0+4" : : "r"(rela->r_offset)); + l->l_addr));
__asm __volatile ("flush %0+4" : : "r" (rela->r_offset
+ l->l_addr));
} }
++rela; ++rela;
} }