summaryrefslogtreecommitdiff
path: root/libexec/ld.so/alpha
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2018-11-22 21:37:31 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2018-11-22 21:37:31 +0000
commit471845a341fceabc401fe7f6d2ca619b1116dc17 (patch)
treef232d6064154369df1d6cde9c59ba4110618e59d /libexec/ld.so/alpha
parentccb3815c70643d0344d2398bd4d610cf33cb4b4d (diff)
Make alpha less special: _dl_boot_bind() is written to complete
relocation of ld.so's GOT without using it, so _reloc_alpha_got() merely made the call to _dl_boot_bind() from asm simpler...while itself being a call that required special handling. diff and muild baking by miod@ ok guenther@
Diffstat (limited to 'libexec/ld.so/alpha')
-rw-r--r--libexec/ld.so/alpha/archdep.h4
-rw-r--r--libexec/ld.so/alpha/ldasm.S20
-rw-r--r--libexec/ld.so/alpha/rtld_machine.c36
3 files changed, 15 insertions, 45 deletions
diff --git a/libexec/ld.so/alpha/archdep.h b/libexec/ld.so/alpha/archdep.h
index d6ba7224980..02bcc145607 100644
--- a/libexec/ld.so/alpha/archdep.h
+++ b/libexec/ld.so/alpha/archdep.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: archdep.h,v 1.21 2017/10/27 16:47:08 mpi Exp $ */
+/* $OpenBSD: archdep.h,v 1.22 2018/11/22 21:37:30 guenther Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -42,7 +42,7 @@ static inline void
RELOC_DYN(Elf64_Rela *r, const Elf64_Sym *s, Elf64_Addr *p, unsigned long v)
{
if (ELF64_R_TYPE(r->r_info) == RELOC_RELATIVE) {
- /* handled by _reloc_alpha_got */
+ *p += v;
} else if (ELF64_R_TYPE(r->r_info) == RELOC_NONE) {
/* nothing to do */
} else if (ELF64_R_TYPE(r->r_info) == RELOC_JMP_SLOT) {
diff --git a/libexec/ld.so/alpha/ldasm.S b/libexec/ld.so/alpha/ldasm.S
index ebb507b0d70..d1019f63fbf 100644
--- a/libexec/ld.so/alpha/ldasm.S
+++ b/libexec/ld.so/alpha/ldasm.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldasm.S,v 1.41 2018/11/12 02:33:42 guenther Exp $ */
+/* $OpenBSD: ldasm.S,v 1.42 2018/11/22 21:37:30 guenther Exp $ */
/*
* Copyright (c) 2001 Niklas Hallqvist
@@ -70,15 +70,11 @@ L1:
L2: ldiq s3, L2 /* get where the linker thought we were */
subq s2, s3, s2
- mov s2, a1
lda t5, _DYNAMIC
- addq s2, t5, a0
- mov a0, s6
-
- bsr ra, _reloc_alpha_got
+ addq s2, t5, s6
/* allocate stack */
- lda sp, (-8 - ((AUX_entry) * 8))(sp)
+ lda sp, -((AUX_entry + 1) * 8)(sp)
mov s0, a0
mov s2, s1 /* relocation displacement */
@@ -93,7 +89,11 @@ L2: ldiq s3, L2 /* get where the linker thought we were */
lda s2, 0(sp)
mov s2, a1
mov s6, a2 /* &_DYNAMIC */
- CALL(_dl_boot_bind)
+ /* we can't use CALL here as gp would not be set correctly by ldgp,
+ due to the GOT not being relocated yet. */
+ lda pv, _dl_boot_bind
+ addq s1, pv, pv
+ bsr ra, _dl_boot_bind
mov s3, a0 /* **argv */
mov s4, a1 /* **envp */
mov s1, a2 /* loff */
@@ -108,7 +108,7 @@ END(_dl_start)
/*
* Lazy binding entry point, called via secure (read-only) PLT.
*/
-NESTED_NOPROFILE(_dl_bind_secureplt, 0, 168, ra, 0, 0)
+NESTED_NOPROFILE(_dl_bind_start, 0, 160, ra, 0, 0)
.set noat
/* at_reg and t11 already used by PLT code. */
@@ -179,4 +179,4 @@ NESTED_NOPROFILE(_dl_bind_secureplt, 0, 168, ra, 0, 0)
/* Pop the stack frame and turn control to the destination. */
lda sp, 160(sp)
jmp zero, (pv)
-END(_dl_bind_secureplt)
+END(_dl_bind_start)
diff --git a/libexec/ld.so/alpha/rtld_machine.c b/libexec/ld.so/alpha/rtld_machine.c
index 0cb712d2533..6c9a81539ea 100644
--- a/libexec/ld.so/alpha/rtld_machine.c
+++ b/libexec/ld.so/alpha/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.64 2018/11/16 21:15:47 guenther Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.65 2018/11/22 21:37:30 guenther Exp $ */
/*
* Copyright (c) 1999 Dale Rahn
@@ -253,7 +253,7 @@ _dl_bind(elf_object_t *object, int reloff)
return (buf.newval);
}
-void _dl_bind_secureplt(void) __dso_hidden; /* XXX */
+void _dl_bind_start(void) __dso_hidden; /* XXX */
/*
* Relocate the Global Offset Table (GOT).
@@ -290,39 +290,9 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
*addr += object->obj_base;
}
}
- pltgot[0] = (Elf_Addr)_dl_bind_secureplt;
+ pltgot[0] = (Elf_Addr)_dl_bind_start;
pltgot[1] = (Elf_Addr)object;
}
return (fails);
}
-
-/* relocate the GOT early */
-
-void _reloc_alpha_got(Elf_Dyn *dynp, Elf_Addr relocbase);
-
-void
-_reloc_alpha_got(Elf_Dyn *dynp, Elf_Addr relocbase)
-{
- const Elf_RelA *rela = NULL, *relalim;
- Elf_Addr relasz = 0;
- Elf_Addr *where;
-
- for (; dynp->d_tag != DT_NULL; dynp++) {
- switch (dynp->d_tag) {
- case DT_RELA:
- rela = (const Elf_RelA *)(relocbase + dynp->d_un.d_ptr);
- break;
- case DT_RELASZ:
- relasz = dynp->d_un.d_val;
- break;
- }
- }
- relalim = (const Elf_RelA *)((caddr_t)rela + relasz);
- for (; rela < relalim; rela++) {
- if (ELF64_R_TYPE(rela->r_info) != RELOC_RELATIVE)
- continue;
- where = (Elf_Addr *)(relocbase + rela->r_offset);
- *where += (Elf_Addr)relocbase;
- }
-}