Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/ld.elf_so/arch/aarch64 explain AARCH64 PLT design
details: https://anonhg.NetBSD.org/src/rev/6181b4a60c87
branches: trunk
changeset: 356032:6181b4a60c87
user: nisimura <nisimura%NetBSD.org@localhost>
date: Mon Aug 28 06:59:25 2017 +0000
description:
explain AARCH64 PLT design
diffstat:
libexec/ld.elf_so/arch/aarch64/mdreloc.c | 31 +++++++++++++++++++++++++++++--
1 files changed, 29 insertions(+), 2 deletions(-)
diffs (55 lines):
diff -r 79e18ec41233 -r 6181b4a60c87 libexec/ld.elf_so/arch/aarch64/mdreloc.c
--- a/libexec/ld.elf_so/arch/aarch64/mdreloc.c Mon Aug 28 06:18:40 2017 +0000
+++ b/libexec/ld.elf_so/arch/aarch64/mdreloc.c Mon Aug 28 06:59:25 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mdreloc.c,v 1.5 2017/08/23 09:17:48 nisimura Exp $ */
+/* $NetBSD: mdreloc.c,v 1.6 2017/08/28 06:59:25 nisimura Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.5 2017/08/23 09:17:48 nisimura Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.6 2017/08/28 06:59:25 nisimura Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -44,9 +44,36 @@
void _rtld_relocate_nonplt_self(Elf_Dyn *, Elf_Addr);
Elf_Addr _rtld_bind(const Obj_Entry *, Elf_Word);
+/*
+ * AARCH64 PLT looks like this;
+ *
+ * PLT HEADER <8 instructions>
+ * PLT ENTRY #0 <4 instructions>
+ * PLT ENTRY #1 <4 instructions>
+ * .
+ * .
+ * PLT ENTRY #n <4 instructions>
+ *
+ * PLT HEADER
+ * stp x16, x30, [sp, #-16]!
+ * adrp x16, (GOT+16)
+ * ldr x17, [x16, #PLT_GOT+0x10]
+ * add x16, x16, #PLT_GOT+0x10
+ * br x17
+ * nop
+ * nop
+ * nop
+ *
+ * PLT ENTRY #n
+ * adrp x16, PLTGOT + n * 8
+ * ldr x17, [x16, PLTGOT + n * 8]
+ * add x16, x16, :lo12:PLTGOT + n * 8
+ * br x17
+ */
void
_rtld_setup_pltgot(const Obj_Entry *obj)
{
+
obj->pltgot[1] = (Elf_Addr) obj;
obj->pltgot[2] = (Elf_Addr) &_rtld_bind_start;
}
Home |
Main Index |
Thread Index |
Old Index