This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix attribute usage in libc-symbols.h


We use in libc-symbols for some code the unused attribute.  But this
is wrong, it just shuts up the compiler to not generate unused
warnings.  What we want to tell instead is that they're used in some
magical way and therefore they should not be optimized away.

The following patch has been tested on amd64 with current glibc and a
GCC with -funit-at-a-time enabled.  Without the patch, the compiler
would optimize these away.

Ok to commit?

Andreas

2003-07-22  Andreas Jaeger  <aj@suse.de>

	* include/libc-symbols.h (_elf_set_element): Use attribute used so
	that gcc will not optimize it away.
	(link_warning): Likewise.

============================================================
Index: include/libc-symbols.h
--- include/libc-symbols.h	16 Jun 2003 17:14:50 -0000	1.57
+++ include/libc-symbols.h	22 Jul 2003 18:58:32 -0000
@@ -244,7 +244,7 @@
 #  define link_warning(symbol, msg) \
   __make_section_unallocated (".gnu.warning." #symbol) \
   static const char __evoke_link_warning_##symbol[]	\
-    __attribute__ ((unused, section (".gnu.warning." #symbol __sec_comment))) \
+    __attribute__ ((used, section (".gnu.warning." #symbol __sec_comment))) \
     = msg;
 #  define libc_freeres_ptr(decl) \
   __make_section_unallocated ("__libc_freeres_ptrs, \"aw\", %nobits") \
@@ -344,11 +344,11 @@ for linking")
    because it will need to be relocated at run time anyway.  */
 #   define _elf_set_element(set, symbol) \
   static const void *__elf_set_##set##_element_##symbol##__ \
-    __attribute__ ((unused, section (#set))) = &(symbol)
+    __attribute__ ((used, section (#set))) = &(symbol)
 #  else
 #   define _elf_set_element(set, symbol) \
   static const void *const __elf_set_##set##_element_##symbol##__ \
-    __attribute__ ((unused, section (#set))) = &(symbol)
+    __attribute__ ((used, section (#set))) = &(symbol)
 #  endif
 
 /* Define SET as a symbol set.  This may be required (it is in a.out) to

-- 
 Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj
  SuSE Linux AG, Deutschherrnstr. 15-19, 90429 Nürnberg, Germany
   GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]