[COMMITTED] elf: Fix clang-18 build of ifunc resolver tests
Adhemerval Zanella
adhemerval.zanella@linaro.org
Wed Jun 24 16:45:14 GMT 2026
clang-18 errors on the static ifunc resolvers seen as unused.
---
elf/tst-ifunc-bz28817.c | 1 +
elf/tst-ifunc-plt-lib.c | 11 +++++++----
elf/tst-ifunc-resolver-protector-mod.c | 3 +++
elf/tst-ifunc-resolver-protector-static-mod.c | 1 +
elf/tst-ifunc-tls-init-gd-ld-lib-skeleton.c | 6 +++++-
elf/tst-ifunc-tls-init-lib-skeleton.c | 6 +++++-
elf/tst-ifunc-tls-write-lib.c | 6 +++++-
7 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/elf/tst-ifunc-bz28817.c b/elf/tst-ifunc-bz28817.c
index fe6f400f4ea..21d73d27fd3 100644
--- a/elf/tst-ifunc-bz28817.c
+++ b/elf/tst-ifunc-bz28817.c
@@ -41,6 +41,7 @@ my_foo (void)
static __typeof (foo) *
inhibit_stack_protector
+__attribute_used__
foo_ifunc (void)
{
init_foo ();
diff --git a/elf/tst-ifunc-plt-lib.c b/elf/tst-ifunc-plt-lib.c
index a9c100a8941..e65215059f6 100644
--- a/elf/tst-ifunc-plt-lib.c
+++ b/elf/tst-ifunc-plt-lib.c
@@ -22,6 +22,7 @@
.rel{a}.plt). This verifies that every IRELATIVE entry is deferred
until after .rela.plt has been processed, not just the first one. */
+#include <sys/cdefs.h>
#include <stddef.h>
extern int get_value (void);
@@ -38,14 +39,16 @@ impl_b (void)
return 2;
}
-static int (*
-resolve_a (void)) (void)
+static typeof (impl_a) *
+__attribute_used__
+resolve_a (void)
{
return get_value () == 42 ? impl_a : NULL;
}
-static int (*
-resolve_b (void)) (void)
+static typeof (impl_b) *
+__attribute_used__
+resolve_b (void)
{
return get_value () == 42 ? impl_b : NULL;
}
diff --git a/elf/tst-ifunc-resolver-protector-mod.c b/elf/tst-ifunc-resolver-protector-mod.c
index 36d11f04def..4f18e82e6f1 100644
--- a/elf/tst-ifunc-resolver-protector-mod.c
+++ b/elf/tst-ifunc-resolver-protector-mod.c
@@ -25,6 +25,8 @@
always observe an initialised canary; this test guards against any future
reordering that would break that invariant. */
+#include <sys/cdefs.h>
+
#define SENTINEL 0x5A5A1234
static volatile int resolver_ran;
@@ -44,6 +46,7 @@ impl_ok (int x)
typedef int (*fn_t) (int);
static fn_t
+__attribute_used__
resolver (void)
{
/* Buffer + zero-fill force -fstack-protector-all canary code. */
diff --git a/elf/tst-ifunc-resolver-protector-static-mod.c b/elf/tst-ifunc-resolver-protector-static-mod.c
index b1cb704854e..60d4071c43a 100644
--- a/elf/tst-ifunc-resolver-protector-static-mod.c
+++ b/elf/tst-ifunc-resolver-protector-static-mod.c
@@ -50,6 +50,7 @@ impl_ok (int x)
typedef int (*fn_t) (int);
static fn_t
+__attribute_used__
resolver (void)
{
/* Buffer forces -fstack-protector-all to emit canary code even with
diff --git a/elf/tst-ifunc-tls-init-gd-ld-lib-skeleton.c b/elf/tst-ifunc-tls-init-gd-ld-lib-skeleton.c
index b6fd6cf06e1..3a2f33d1623 100644
--- a/elf/tst-ifunc-tls-init-gd-ld-lib-skeleton.c
+++ b/elf/tst-ifunc-tls-init-gd-ld-lib-skeleton.c
@@ -23,6 +23,8 @@
TLSDESC equivalent). That dynamic-TLS access can lazily allocate a
per-module TLS block, which is the path being exercised. */
+#include <sys/cdefs.h>
+
#ifndef TLS_MODEL
# error "tst-ifunc-tls-init-gd-ld-lib-skeleton.c needs TLS_MODEL defined"
#endif
@@ -58,7 +60,9 @@ get_last_seen_sentinel (void)
return last_seen_sentinel;
}
-static int (*resolver (void)) (void)
+static typeof (impl_ok) *
+__attribute_used__
+resolver (void)
{
int s = sentinel;
last_seen_sentinel = s;
diff --git a/elf/tst-ifunc-tls-init-lib-skeleton.c b/elf/tst-ifunc-tls-init-lib-skeleton.c
index 7b8a1647a4b..1d9592107c4 100644
--- a/elf/tst-ifunc-tls-init-lib-skeleton.c
+++ b/elf/tst-ifunc-tls-init-lib-skeleton.c
@@ -20,6 +20,8 @@
load, so the test is sensitive to whether the static TLS block has been
populated rather than to any __tls_get_addr / DTV-update timing. */
+#include <sys/cdefs.h>
+
#define SENTINEL 0x5A5A1234
/* The 'volatile' avoids constant fold optimization in impl_ok. */
@@ -45,7 +47,9 @@ get_last_seen_sentinel (void)
return last_seen_sentinel;
}
-static int (*resolver (void)) (void)
+static typeof (impl_ok) *
+__attribute_used__
+resolver (void)
{
int s = sentinel;
last_seen_sentinel = s;
diff --git a/elf/tst-ifunc-tls-write-lib.c b/elf/tst-ifunc-tls-write-lib.c
index ef1dff90e01..1d784fbe0ef 100644
--- a/elf/tst-ifunc-tls-write-lib.c
+++ b/elf/tst-ifunc-tls-write-lib.c
@@ -21,6 +21,8 @@
overwrites counter with MARKER, and the test then reads counter back
through a getter. */
+#include <sys/cdefs.h>
+
#define SENTINEL 0x5A5A1234u
#define MARKER 0x32125A5Au
@@ -34,7 +36,9 @@ impl (void)
return 0;
}
-static unsigned int (*resolver (void)) (void)
+static typeof (impl) *
+__attribute_used__
+resolver (void)
{
counter = MARKER;
return impl;
--
2.43.0
More information about the Libc-alpha
mailing list