Module Name:    src
Committed By:   joerg
Date:           Fri Mar  9 20:15:03 UTC 2018

Modified Files:
        src/tests/libexec/ld.elf_so: h_ifunc.c t_ifunc.c
        src/tests/libexec/ld.elf_so/helper_ifunc_dso: h_helper_ifunc.c

Log Message:
Avoid casting fun by switching ifunc helper functions to return
long long. Dead beef is too useful to switch to a different constant.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/libexec/ld.elf_so/h_ifunc.c
cvs rdiff -u -r1.7 -r1.8 src/tests/libexec/ld.elf_so/t_ifunc.c
cvs rdiff -u -r1.6 -r1.7 \
    src/tests/libexec/ld.elf_so/helper_ifunc_dso/h_helper_ifunc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/libexec/ld.elf_so/h_ifunc.c
diff -u src/tests/libexec/ld.elf_so/h_ifunc.c:1.1 src/tests/libexec/ld.elf_so/h_ifunc.c:1.2
--- src/tests/libexec/ld.elf_so/h_ifunc.c:1.1	Mon Aug 25 20:40:53 2014
+++ src/tests/libexec/ld.elf_so/h_ifunc.c	Fri Mar  9 20:15:03 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: h_ifunc.c,v 1.1 2014/08/25 20:40:53 joerg Exp $	*/
+/*	$NetBSD: h_ifunc.c,v 1.2 2018/03/09 20:15:03 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <stdlib.h>
 
-extern int ifunc(void);
+extern long long ifunc(void);
 
 int
 main(int argc, char **argv)
@@ -39,5 +39,5 @@ main(int argc, char **argv)
 
 	if (argc != 2)
 		return 1;
-	return ifunc() != atoi(argv[1]);
+	return ifunc() != atoll(argv[1]);
 }

Index: src/tests/libexec/ld.elf_so/t_ifunc.c
diff -u src/tests/libexec/ld.elf_so/t_ifunc.c:1.7 src/tests/libexec/ld.elf_so/t_ifunc.c:1.8
--- src/tests/libexec/ld.elf_so/t_ifunc.c:1.7	Mon Jan  1 06:34:13 2018
+++ src/tests/libexec/ld.elf_so/t_ifunc.c	Fri Mar  9 20:15:03 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ifunc.c,v 1.7 2018/01/01 06:34:13 maya Exp $	*/
+/*	$NetBSD: t_ifunc.c,v 1.8 2018/03/09 20:15:03 joerg Exp $	*/
 
 /*
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -53,12 +53,12 @@ ATF_TC_BODY(rtld_ifunc, tc)
 	const char *envstr[] = {
 	    "0", "1"
 	};
-	int expected_result[] = {
-	    0xdeadbeef, 0xbeefdead
+	long long expected_result[] = {
+	    0xdeadbeefll, 0xbeefdeadll
 	};
 	void *handle;
-	int (*sym)(void);
-	int result;
+	long long (*sym)(void);
+	long long result;
 	const char *error;
 	size_t i;
 
@@ -86,7 +86,7 @@ ATF_TC_BODY(rtld_ifunc, tc)
 		ATF_CHECK(error == NULL);
 
 		char *command;
-		easprintf(&command, "%s/h_ifunc %d",
+		easprintf(&command, "%s/h_ifunc %lld",
 		    atf_tc_get_config_var(tc, "srcdir"), expected_result[i]);
 		if (system(command) != EXIT_SUCCESS)
 			atf_tc_fail("Test failed; see output for details");
@@ -106,13 +106,13 @@ ATF_TC_BODY(rtld_hidden_ifunc, tc)
 	const char *envstr[] = {
 	    "0", "1"
 	};
-	int expected_result[] = {
-	    0xdeadbeef, 0xbeefdead
+	long long expected_result[] = {
+	    0xdeadbeefll, 0xbeefdeadll
 	};
 	void *handle;
-	int (*sym)(void);
-	int (*(*sym2)(void))(void);
-	int result;
+	long long (*sym)(void);
+	long long (*(*sym2)(void))(void);
+	long long result;
 	const char *error;
 	size_t i;
 
@@ -149,7 +149,7 @@ ATF_TC_BODY(rtld_hidden_ifunc, tc)
 		ATF_CHECK(error == NULL);
 
 		char *command;
-		easprintf(&command, "%s/h_ifunc %d",
+		easprintf(&command, "%s/h_ifunc %lld",
 		    atf_tc_get_config_var(tc, "srcdir"), expected_result[i]);
 		if (system(command) != EXIT_SUCCESS)
 			atf_tc_fail("Test failed; see output for details");
@@ -165,26 +165,26 @@ ATF_TC_HEAD(rtld_main_ifunc, tc)
 }
 
 #if LINKER_SUPPORT
-static unsigned int
+static long long
 ifunc_helper(void)
 {
-	return 0xdeadbeef;
+	return 0xdeadbeefll;
 }
 
 static __attribute__((used))
-unsigned int (*resolve_ifunc(void))(void)
+long long (*resolve_ifunc(void))(void)
 {
 	return ifunc_helper;
 }
 __hidden_ifunc(ifunc, resolve_ifunc);
 #endif
-unsigned int ifunc(void);
+long long ifunc(void);
 
 ATF_TC_BODY(rtld_main_ifunc, tc)
 {
 	if (!LINKER_SUPPORT)
 		atf_tc_skip("Missing linker support for ifunc relocations");
-	ATF_CHECK(ifunc() == 0xdeadbeef);
+	ATF_CHECK(ifunc() == 0xdeadbeefll);
 }
 
 ATF_TP_ADD_TCS(tp)

Index: src/tests/libexec/ld.elf_so/helper_ifunc_dso/h_helper_ifunc.c
diff -u src/tests/libexec/ld.elf_so/helper_ifunc_dso/h_helper_ifunc.c:1.6 src/tests/libexec/ld.elf_so/helper_ifunc_dso/h_helper_ifunc.c:1.7
--- src/tests/libexec/ld.elf_so/helper_ifunc_dso/h_helper_ifunc.c:1.6	Sat Aug 12 09:03:28 2017
+++ src/tests/libexec/ld.elf_so/helper_ifunc_dso/h_helper_ifunc.c	Fri Mar  9 20:15:03 2018
@@ -30,27 +30,27 @@
 #include <stdlib.h>
 #include <string.h>
 
-static int
+static long long
 ifunc1(void)
 {
-	return 0xdeadbeef;
+	return 0xdeadbeefll;
 }
 
-static int
+static long long
 ifunc2(void)
 {
-	return 0xbeefdead;
+	return 0xbeefdeadll;
 }
 
 static __attribute__((used))
-int (*resolve_ifunc(void))(void)
+long long (*resolve_ifunc(void))(void)
 {
 	const char *e = getenv("USE_IFUNC2");
 	return e && strcmp(e, "1") == 0 ? ifunc2 : ifunc1;
 }
 
 static __attribute__((used))
-int (*resolve_ifunc2(void))(void)
+long long (*resolve_ifunc2(void))(void)
 {
 	const char *e = getenv("USE_IFUNC2");
 	return e && strcmp(e, "1") == 0 ? ifunc1 : ifunc2;
@@ -59,17 +59,17 @@ int (*resolve_ifunc2(void))(void)
 __ifunc(ifunc, resolve_ifunc);
 __hidden_ifunc(ifunc_hidden, resolve_ifunc2);
 
-int ifunc_hidden(void);
-int ifunc_plt(void);
+long long ifunc_hidden(void);
+long long ifunc_plt(void);
 
-int ifunc_plt(void)
+long long ifunc_plt(void)
 {
 	return ifunc_hidden();
 }
 
-int (*ifunc_indirect(void))(void);
+long long (*ifunc_indirect(void))(void);
 
-int (*ifunc_indirect(void))(void)
+long long (*ifunc_indirect(void))(void)
 {
 	return ifunc_hidden;
 }

Reply via email to