From 79b9ae539bab769b0d0234fc22ca5df8346f44c3 Mon Sep 17 00:00:00 2001 From: joerg Date: Mon, 6 Nov 2017 21:16:03 +0000 Subject: init/fini for the main program is handled by crt0.o, so ifunc handling is skipped right now as it iterates the same list. Don't repeat that mistake and explicitly take care of it in the dynamic linker. --- tests/libexec/ld.elf_so/t_ifunc.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'tests/libexec') diff --git a/tests/libexec/ld.elf_so/t_ifunc.c b/tests/libexec/ld.elf_so/t_ifunc.c index 356cce67e22..79f8c71e589 100644 --- a/tests/libexec/ld.elf_so/t_ifunc.c +++ b/tests/libexec/ld.elf_so/t_ifunc.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_ifunc.c,v 1.4 2017/08/12 09:03:28 joerg Exp $ */ +/* $NetBSD: t_ifunc.c,v 1.5 2017/11/06 21:16:03 joerg Exp $ */ /* * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -149,9 +149,36 @@ ATF_TC_BODY(rtld_hidden_ifunc, tc) } } +ATF_TC(rtld_main_ifunc); +ATF_TC_HEAD(rtld_main_ifunc, tc) +{ + atf_tc_set_md_var(tc, "descr", + "ifunc functions are resolved in the executable"); +} + +static unsigned int +ifunc_helper(void) +{ + return 0xdeadbeef; +} + +static __attribute__((used)) +unsigned int (*resolve_ifunc(void))(void) +{ + return ifunc_helper; +} +__hidden_ifunc(ifunc, resolve_ifunc); +unsigned int ifunc(void); + +ATF_TC_BODY(rtld_main_ifunc, tc) +{ + ATF_CHECK(ifunc() == 0xdeadbeef); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, rtld_ifunc); ATF_TP_ADD_TC(tp, rtld_hidden_ifunc); + ATF_TP_ADD_TC(tp, rtld_main_ifunc); return 0; } -- cgit