[glibc/azanella/clang] elf: Suppress unused function clang for __ifunc_resolver

Adhemerval Zanella azanella@sourceware.org
Wed Aug 30 12:34:26 GMT 2023


https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8b8dfbeabb6456486f7a6aae3989a6a38d6523cd

commit 8b8dfbeabb6456486f7a6aae3989a6a38d6523cd
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Aug 4 09:43:18 2022 -0300

    elf: Suppress unused function clang for __ifunc_resolver

Diff:
---
 elf/ifuncmain9.c           | 4 ++++
 elf/tst-ifunc-fault-lazy.c | 4 ++++
 include/libc-symbols.h     | 6 +++++-
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/elf/ifuncmain9.c b/elf/ifuncmain9.c
index cab26af75c..e37c391f02 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)
@@ -47,6 +50,7 @@ resolver (void)
   ++resolver_called;
   return implementation;
 }
+DIAG_POP_NEEDS_COMMENT_CLANG;
 
 static int magic (void) __attribute__ ((ifunc ("resolver")));
 
diff --git a/elf/tst-ifunc-fault-lazy.c b/elf/tst-ifunc-fault-lazy.c
index 33d60196da..57b0a28306 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 2184522c93..ad3b800ccd 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.  */
@@ -683,7 +684,10 @@ for linking")
 # define __ifunc(type_name, name, expr, arg, init)			\
   extern __typeof (type_name) name __attribute__			\
 			      ((ifunc (#name "_ifunc")));		\
-  __ifunc_resolver (type_name, name, expr, arg, init, static)
+  DIAG_PUSH_NEEDS_COMMENT_CLANG;					\
+  DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wunused-function");		\
+  __ifunc_resolver (type_name, name, expr, arg, init, static);		\
+  DIAG_POP_NEEDS_COMMENT_CLANG;
 
 # define __ifunc_hidden(type_name, name, expr, arg, init)	\
   __ifunc (type_name, name, expr, arg, init)


More information about the Glibc-cvs mailing list