Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/libexec/ld.elf_so Avoid casting fun by switching ifunc...



details:   https://anonhg.NetBSD.org/src/rev/d456e5379a13
branches:  trunk
changeset: 321297:d456e5379a13
user:      joerg <joerg%NetBSD.org@localhost>
date:      Fri Mar 09 20:15:03 2018 +0000

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

diffstat:

 tests/libexec/ld.elf_so/h_ifunc.c                         |   6 +-
 tests/libexec/ld.elf_so/helper_ifunc_dso/h_helper_ifunc.c |  22 ++++----
 tests/libexec/ld.elf_so/t_ifunc.c                         |  34 +++++++-------
 3 files changed, 31 insertions(+), 31 deletions(-)

diffs (180 lines):

diff -r cb96b7c045ed -r d456e5379a13 tests/libexec/ld.elf_so/h_ifunc.c
--- a/tests/libexec/ld.elf_so/h_ifunc.c Fri Mar 09 18:56:02 2018 +0000
+++ b/tests/libexec/ld.elf_so/h_ifunc.c Fri Mar 09 20:15:03 2018 +0000
@@ -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 @@
 
        if (argc != 2)
                return 1;
-       return ifunc() != atoi(argv[1]);
+       return ifunc() != atoll(argv[1]);
 }
diff -r cb96b7c045ed -r d456e5379a13 tests/libexec/ld.elf_so/helper_ifunc_dso/h_helper_ifunc.c
--- a/tests/libexec/ld.elf_so/helper_ifunc_dso/h_helper_ifunc.c Fri Mar 09 18:56:02 2018 +0000
+++ b/tests/libexec/ld.elf_so/helper_ifunc_dso/h_helper_ifunc.c Fri Mar 09 20:15:03 2018 +0000
@@ -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 @@
 __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;
 }
diff -r cb96b7c045ed -r d456e5379a13 tests/libexec/ld.elf_so/t_ifunc.c
--- a/tests/libexec/ld.elf_so/t_ifunc.c Fri Mar 09 18:56:02 2018 +0000
+++ b/tests/libexec/ld.elf_so/t_ifunc.c Fri Mar 09 20:15:03 2018 +0000
@@ -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 @@
        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_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 @@
        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_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 @@
 }
 
 #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)



Home | Main Index | Thread Index | Old Index