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

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

[PATCH] Add __attribute__((used)) where needed


Hi!

gcc 3.1 at -O3 blows away _dl_start, fixup and profile_fixup (the alloca
trick for the latter 2 doesn't seem to work any longer).
Alex added __attribute__((used)) which is a request that eventhough a
function looks unused to gcc, it emits it anyway (similar to
__attribute__((unused)), the difference is that the new attribute not only
supresses the warning, but also ensures it is emitted).

2001-10-19  Jakub Jelinek  <jakub@redhat.com>

	* misc/sys/cdefs.h (__attribute_used__): Define.
	* elf/rtld.c (_dl_start): Add __attribute_used__.
	* elf/dl-runtime.c (fixup, profile_fixup): Likewise.

--- libc/elf/rtld.c.jj	Thu Sep 27 23:26:30 2001
+++ libc/elf/rtld.c	Fri Oct 19 14:08:02 2001
@@ -145,7 +145,7 @@ RTLD_START
 # error "sysdeps/MACHINE/dl-machine.h fails to define RTLD_START"
 #endif
 
-static ElfW(Addr)
+static ElfW(Addr) __attribute_used__
 _dl_start (void *arg)
 {
   struct link_map bootstrap_map;
--- libc/elf/dl-runtime.c.jj	Thu Sep 27 23:26:27 2001
+++ libc/elf/dl-runtime.c	Fri Oct 19 14:10:33 2001
@@ -42,7 +42,7 @@
    function.  */
 
 #ifndef ELF_MACHINE_NO_PLT
-static ElfW(Addr) __attribute__ ((unused))
+static ElfW(Addr) __attribute_used__
 fixup (
 # ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS
         ELF_MACHINE_RUNTIME_FIXUP_ARGS,
@@ -126,7 +126,7 @@ fixup (
 
 #if !defined PROF && !defined ELF_MACHINE_NO_PLT && !__BOUNDED_POINTERS__
 
-static ElfW(Addr) __attribute__ ((unused))
+static ElfW(Addr) __attribute_used__
 profile_fixup (
 #ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS
        ELF_MACHINE_RUNTIME_FIXUP_ARGS,
--- libc/misc/sys/cdefs.h.jj	Thu Aug 23 18:48:38 2001
+++ libc/misc/sys/cdefs.h	Fri Oct 19 14:09:42 2001
@@ -160,6 +160,15 @@
 # define __attribute_pure__ /* Ignore */
 #endif
 
+/* At some point during the gcc 3.1 development the `used' attribute
+   for functions was introduced.  We don't want to use it unconditionally
+   (although this would be possible) since it generates warnings.  */
+#if __GNUC_PREREQ (3,1)
+# define __attribute_used__ __attribute__ ((__used__))
+#else
+# define __attribute_used__ __attribute__ ((__unused__))
+#endif
+
 /* At some point during the gcc 2.8 development the `format_arg' attribute
    for functions was introduced.  We don't want to use it unconditionally
    (although this would be possible) since it generates warnings.


	Jakub


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