about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-08-04 09:43:18 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2024-04-17 16:12:10 -0300
commit413a452b5c6e68c90cc85dac19e1142eba88db28 (patch)
tree763b3de3a4c5fba38307f71f8d048d3c15f93040
parent68cbe438b55b250c651f69d731e5cf08f03a11cd (diff)
downloadglibc-413a452b5c6e68c90cc85dac19e1142eba88db28.tar.gz
glibc-413a452b5c6e68c90cc85dac19e1142eba88db28.tar.xz
glibc-413a452b5c6e68c90cc85dac19e1142eba88db28.zip
elf: Suppress unused function clang for __ifunc_resolver
The __ifunc_resolver macro expands to:

  extern __typeof (__redirect_name) name __attribute__ ((ifunc ("iname_ifunc")));
  static __typeof (__redirect_name) *name_ifunc (void) { [...] };

And although NAME_IFUNC is and alias for NAME, clang still emits
an 'unused function 'name_ifunc' [-Werror,-Wunused-function]'
warning.  The static is used to avoid name pollution on static
linkage.
-rw-r--r--elf/ifuncmain9.c4
-rw-r--r--elf/tst-ifunc-fault-lazy.c4
-rw-r--r--include/libc-symbols.h6
3 files changed, 13 insertions, 1 deletions
diff --git a/elf/ifuncmain9.c b/elf/ifuncmain9.c
index 43011452b7..a13020dc6d 100644
--- a/elf/ifuncmain9.c
+++ b/elf/ifuncmain9.c
@@ -22,6 +22,7 @@
 
 # include <stdbool.h>
 # include <stdio.h>
+# include <libc-diag.h>
 
 /* Do not use the test framework, so that the process setup is not
    disturbed.  */
@@ -40,6 +41,8 @@ implementation (void)
   return random_constant;
 }
 
+DIAG_PUSH_NEEDS_COMMENT_CLANG;
+DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wunused-function");
 static __typeof__ (implementation) *
 inhibit_stack_protector
 resolver (void)
@@ -49,6 +52,7 @@ resolver (void)
 }
 
 static int magic (void) __attribute__ ((ifunc ("resolver")));
+DIAG_POP_NEEDS_COMMENT_CLANG;
 
 int
 main (void)
diff --git a/elf/tst-ifunc-fault-lazy.c b/elf/tst-ifunc-fault-lazy.c
index 5157c6cc6c..04448b2b15 100644
--- a/elf/tst-ifunc-fault-lazy.c
+++ b/elf/tst-ifunc-fault-lazy.c
@@ -21,6 +21,7 @@
    relocations.  */
 
 #include <config.h>
+#include <libc-diag.h>
 
 #ifdef HAVE_GCC_IFUNC
 
@@ -34,6 +35,8 @@ implementation (void)
   *p = 0;
 }
 
+DIAG_PUSH_NEEDS_COMMENT_CLANG;
+DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wunused-function");
 static __typeof__ (implementation) *
 resolver (void)
 {
@@ -42,6 +45,7 @@ resolver (void)
   *p = 0;
   return implementation;
 }
+DIAG_POP_NEEDS_COMMENT_CLANG;
 
 static void magic (void) __attribute__ ((ifunc ("resolver")));
 
diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index 0635e0dff7..92b64c09f1 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -86,6 +86,7 @@
 
 /* Obtain the definition of symbol_version_reference.  */
 #include <libc-symver.h>
+#include <libc-diag.h>
 
 /* When PIC is defined and SHARED isn't defined, we are building PIE
    by default.  */
@@ -685,7 +686,10 @@ for linking")
 # define __ifunc_args(type_name, name, expr, init, ...)			\
   extern __typeof (type_name) name __attribute__			\
 			      ((ifunc (#name "_ifunc")));		\
-  __ifunc_resolver (type_name, name, expr, init, static, __VA_ARGS__)
+  DIAG_PUSH_NEEDS_COMMENT_CLANG;					\
+  DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wunused-function");		\
+  __ifunc_resolver (type_name, name, expr, init, static, __VA_ARGS__);	\
+  DIAG_POP_NEEDS_COMMENT_CLANG;
 
 # define __ifunc_args_hidden(type_name, name, expr, init, ...)		\
   __ifunc_args (type_name, name, expr, init, __VA_ARGS__)