mirror of
https://sourceware.org/git/glibc.git
synced 2025-12-18 17:24:29 +03:00
(elf_machine_runtime_setup): If we are
not looking at the new thread-safe .plt, don't be lazy about relocs. (_dl_runtime_resolve): Fix up arithmetic for new .plt layout. (elf_alpha_fix_plt): Insert wmb as appropriate to ensure safety.
This commit is contained in:
@@ -86,7 +86,7 @@ elf_machine_load_address (void)
|
|||||||
/* Set up the loaded object described by L so its unrelocated PLT
|
/* Set up the loaded object described by L so its unrelocated PLT
|
||||||
entries will jump to the on-demand fixup code in dl-runtime.c. */
|
entries will jump to the on-demand fixup code in dl-runtime.c. */
|
||||||
|
|
||||||
static inline void
|
static inline int
|
||||||
elf_machine_runtime_setup (struct link_map *l, int lazy)
|
elf_machine_runtime_setup (struct link_map *l, int lazy)
|
||||||
{
|
{
|
||||||
Elf64_Addr plt;
|
Elf64_Addr plt;
|
||||||
@@ -104,7 +104,13 @@ elf_machine_runtime_setup (struct link_map *l, int lazy)
|
|||||||
|
|
||||||
/* Identify this shared object */
|
/* Identify this shared object */
|
||||||
*(Elf64_Addr *)(plt + 24) = (Elf64_Addr) l;
|
*(Elf64_Addr *)(plt + 24) = (Elf64_Addr) l;
|
||||||
|
|
||||||
|
/* If the first instruction of the plt entry is not
|
||||||
|
"br $28, plt0", we cannot do lazy relocation. */
|
||||||
|
lazy = (*(unsigned *)(plt + 32) == 0xc39ffff7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return lazy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This code is used in dl-runtime.c to call the `fixup' function
|
/* This code is used in dl-runtime.c to call the `fixup' function
|
||||||
@@ -145,9 +151,11 @@ _dl_runtime_resolve:
|
|||||||
.prologue 1
|
.prologue 1
|
||||||
/* Set up the arguments for _dl_runtime_resolve. */
|
/* Set up the arguments for _dl_runtime_resolve. */
|
||||||
/* $16 = link_map out of plt0 */
|
/* $16 = link_map out of plt0 */
|
||||||
|
/* $17 = offset of reloc entry = ($28 - $27 - 20) /12 * 24 */
|
||||||
|
subq $28, $27, $17
|
||||||
ldq $16, 8($27)
|
ldq $16, 8($27)
|
||||||
/* $17 = offset of reloc entry */
|
subq $17, 20, $17
|
||||||
mov $28, $17
|
addq $17, $17, $17
|
||||||
/* Do the fixup */
|
/* Do the fixup */
|
||||||
bsr $26, fixup..ng
|
bsr $26, fixup..ng
|
||||||
/* Move the destination address into position. */
|
/* Move the destination address into position. */
|
||||||
@@ -290,14 +298,18 @@ elf_alpha_fix_plt(struct link_map *l,
|
|||||||
lo = (short)hi;
|
lo = (short)hi;
|
||||||
hi = (hi - lo) >> 16;
|
hi = (hi - lo) >> 16;
|
||||||
|
|
||||||
/* Emit "ldah $27,H($27)" */
|
|
||||||
plte[0] = 0x277b0000 | (hi & 0xffff);
|
|
||||||
|
|
||||||
/* Emit "lda $27,L($27)" */
|
/* Emit "lda $27,L($27)" */
|
||||||
plte[1] = 0x237b0000 | (lo & 0xffff);
|
plte[1] = 0x237b0000 | (lo & 0xffff);
|
||||||
|
|
||||||
/* Emit "br $31,function" */
|
/* Emit "br $31,function" */
|
||||||
plte[2] = 0xc3e00000 | (edisp & 0x1fffff);
|
plte[2] = 0xc3e00000 | (edisp & 0x1fffff);
|
||||||
|
|
||||||
|
/* Think about thread-safety -- the previous instructions must be
|
||||||
|
committed to memory before the first is overwritten. */
|
||||||
|
__asm__ __volatile__("wmb" : : : "memory");
|
||||||
|
|
||||||
|
/* Emit "ldah $27,H($27)" */
|
||||||
|
plte[0] = 0x277b0000 | (hi & 0xffff);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -310,14 +322,18 @@ elf_alpha_fix_plt(struct link_map *l,
|
|||||||
lo = (short)hi;
|
lo = (short)hi;
|
||||||
hi = (hi - lo) >> 16;
|
hi = (hi - lo) >> 16;
|
||||||
|
|
||||||
/* Emit "ldah $27,H($27)" */
|
|
||||||
plte[0] = 0x277b0000 | (hi & 0xffff);
|
|
||||||
|
|
||||||
/* Emit "ldq $27,L($27)" */
|
/* Emit "ldq $27,L($27)" */
|
||||||
plte[1] = 0xa77b0000 | (lo & 0xffff);
|
plte[1] = 0xa77b0000 | (lo & 0xffff);
|
||||||
|
|
||||||
/* Emit "jmp $31,($27)" */
|
/* Emit "jmp $31,($27)" */
|
||||||
plte[2] = 0x6bfb0000;
|
plte[2] = 0x6bfb0000;
|
||||||
|
|
||||||
|
/* Think about thread-safety -- the previous instructions must be
|
||||||
|
committed to memory before the first is overwritten. */
|
||||||
|
__asm__ __volatile__("wmb" : : : "memory");
|
||||||
|
|
||||||
|
/* Emit "ldah $27,H($27)" */
|
||||||
|
plte[0] = 0x277b0000 | (hi & 0xffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* At this point, if we've been doing runtime resolution, Icache is dirty.
|
/* At this point, if we've been doing runtime resolution, Icache is dirty.
|
||||||
|
|||||||
Reference in New Issue
Block a user