Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Support ifunc on aarch64. The tests pass at least.
details: https://anonhg.NetBSD.org/src/rev/3ce26a44e808
branches: trunk
changeset: 367270:3ce26a44e808
user: skrll <skrll%NetBSD.org@localhost>
date: Tue Jun 21 06:52:17 2022 +0000
description:
Support ifunc on aarch64. The tests pass at least.
diffstat:
lib/csu/common/crt0-common.c | 5 +++--
libexec/ld.elf_so/arch/aarch64/mdreloc.c | 20 ++++++++++++++++----
libexec/ld.elf_so/rtld.h | 3 ++-
tests/lib/csu/h_ifunc_static.c | 3 ++-
tests/lib/csu/t_ifunc_static.sh | 6 +++---
tests/libexec/ld.elf_so/t_ifunc.c | 3 ++-
6 files changed, 28 insertions(+), 12 deletions(-)
diffs (154 lines):
diff -r 9df0a6ec7a5c -r 3ce26a44e808 lib/csu/common/crt0-common.c
--- a/lib/csu/common/crt0-common.c Tue Jun 21 06:47:37 2022 +0000
+++ b/lib/csu/common/crt0-common.c Tue Jun 21 06:52:17 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: crt0-common.c,v 1.26 2022/06/21 06:47:37 skrll Exp $ */
+/* $NetBSD: crt0-common.c,v 1.27 2022/06/21 06:52:17 skrll Exp $ */
/*
* Copyright (c) 1998 Christos Zoulas
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: crt0-common.c,v 1.26 2022/06/21 06:47:37 skrll Exp $");
+__RCSID("$NetBSD: crt0-common.c,v 1.27 2022/06/21 06:52:17 skrll Exp $");
#include <sys/types.h>
#include <sys/exec.h>
@@ -127,6 +127,7 @@
}
#if \
+ defined(__aarch64__) || \
defined(__powerpc__) || \
defined(__sparc__) || \
defined(__x86_64__)
diff -r 9df0a6ec7a5c -r 3ce26a44e808 libexec/ld.elf_so/arch/aarch64/mdreloc.c
--- a/libexec/ld.elf_so/arch/aarch64/mdreloc.c Tue Jun 21 06:47:37 2022 +0000
+++ b/libexec/ld.elf_so/arch/aarch64/mdreloc.c Tue Jun 21 06:52:17 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mdreloc.c,v 1.15 2022/05/31 08:43:14 andvar Exp $ */
+/* $NetBSD: mdreloc.c,v 1.16 2022/06/21 06:52:17 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.15 2022/05/31 08:43:14 andvar Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.16 2022/06/21 06:52:17 skrll Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -248,6 +248,14 @@
obj->path, (void *)tmp, where, defobj->path));
break;
+ case R_TYPE(IRELATIVE):
+ /* IFUNC relocations are handled in _rtld_call_ifunc */
+ if (obj->ifunc_remaining_nonplt == 0)
+ obj->ifunc_remaining_nonplt = obj->relalim - rela;
+ rdbg(("IRELATIVE in %s, %zx", obj->path,
+ obj->ifunc_remaining_nonplt));
+ /* FALLTHROUGH */
+
case R_TYPE(RELATIVE): /* word B + A */
*where = (Elf_Addr)(obj->relocbase + rela->r_addend);
rdbg(("RELATIVE in %s --> %p", obj->path,
@@ -330,8 +338,9 @@
for (const Elf_Rela *rela = obj->pltrela; rela < obj->pltrelalim; rela++) {
Elf_Addr *where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
- assert((ELF_R_TYPE(rela->r_info) == R_TYPE(JUMP_SLOT)) ||
- (ELF_R_TYPE(rela->r_info) == R_TYPE(TLSDESC)));
+ assert(ELF_R_TYPE(rela->r_info) == R_TYPE(JUMP_SLOT) ||
+ ELF_R_TYPE(rela->r_info) == R_TYPE(TLSDESC) ||
+ ELF_R_TYPE(rela->r_info) == R_TYPE(IRELATIVE));
switch (ELF_R_TYPE(rela->r_info)) {
case R_TYPE(JUMP_SLOT):
@@ -342,6 +351,9 @@
case R_TYPE(TLSDESC):
_rtld_tlsdesc_fill(obj, rela, where, SYMLOOK_IN_PLT);
break;
+ case R_TYPE(IRELATIVE):
+ obj->ifunc_remaining = obj->pltrelalim - rela;
+ break;
}
}
diff -r 9df0a6ec7a5c -r 3ce26a44e808 libexec/ld.elf_so/rtld.h
--- a/libexec/ld.elf_so/rtld.h Tue Jun 21 06:47:37 2022 +0000
+++ b/libexec/ld.elf_so/rtld.h Tue Jun 21 06:52:17 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtld.h,v 1.143 2022/06/21 06:47:37 skrll Exp $ */
+/* $NetBSD: rtld.h,v 1.144 2022/06/21 06:52:17 skrll Exp $ */
/*
* Copyright 1996 John D. Polstra.
@@ -303,6 +303,7 @@
/* IRELATIVE relocations */
size_t ifunc_remaining;
#if \
+ defined(__aarch64__) || \
defined(__arm__) || \
defined(__i386__) || \
defined(__powerpc__) || \
diff -r 9df0a6ec7a5c -r 3ce26a44e808 tests/lib/csu/h_ifunc_static.c
--- a/tests/lib/csu/h_ifunc_static.c Tue Jun 21 06:47:37 2022 +0000
+++ b/tests/lib/csu/h_ifunc_static.c Tue Jun 21 06:52:17 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: h_ifunc_static.c,v 1.6 2022/06/21 06:47:38 skrll Exp $ */
+/* $NetBSD: h_ifunc_static.c,v 1.7 2022/06/21 06:52:17 skrll Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,6 +30,7 @@
*/
#if \
+ defined(__aarch64__) || \
defined(__arm__) || \
defined(__i386__) || \
defined(__powerpc__) || \
diff -r 9df0a6ec7a5c -r 3ce26a44e808 tests/lib/csu/t_ifunc_static.sh
--- a/tests/lib/csu/t_ifunc_static.sh Tue Jun 21 06:47:37 2022 +0000
+++ b/tests/lib/csu/t_ifunc_static.sh Tue Jun 21 06:52:17 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_ifunc_static.sh,v 1.2 2019/01/30 12:42:53 martin Exp $
+# $NetBSD: t_ifunc_static.sh,v 1.3 2022/06/21 06:52:17 skrll Exp $
#
# Copyright (c) 2018 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -33,10 +33,10 @@
ifunc_static_body()
{
case `uname -p` in
- i386|x86_64|powerpc|*sparc*|*arm*)
+ i386|x86_64|powerpc|*sparc*|*arm*|*aarch64*)
;;
*)
- atf_skip "ifunc is supposed only on ARM, i386, PowerPC, SPARC and x86-64"
+ atf_skip "ifunc is supposed only on AARCH64, ARM, i386, PowerPC, SPARC and x86-64"
;;
esac
diff -r 9df0a6ec7a5c -r 3ce26a44e808 tests/libexec/ld.elf_so/t_ifunc.c
--- a/tests/libexec/ld.elf_so/t_ifunc.c Tue Jun 21 06:47:37 2022 +0000
+++ b/tests/libexec/ld.elf_so/t_ifunc.c Tue Jun 21 06:52:17 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ifunc.c,v 1.11 2022/06/21 06:47:38 skrll Exp $ */
+/* $NetBSD: t_ifunc.c,v 1.12 2022/06/21 06:52:17 skrll Exp $ */
/*
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -36,6 +36,7 @@
#include "h_macros.h"
#if \
+ defined(__aarch64__) || \
defined(__arm__) || \
defined(__i386__) || \
defined(__sparc__) || \
Home |
Main Index |
Thread Index |
Old Index