Move bionic over to GCC's 'warning' attribute.
This is a better solution than the old __warn_references because it's
a compile-time rather than link-time warning, it doesn't rely on something
that doesn't appear to be supported by gold (which is why you only used
to see these warnings on mips builds), and the errors refer to the exact
call site(s) rather than just telling you which object file contains a
reference to the bad function.
This is primarily so we can build bionic for aarch64; building libc.so
caused these warnings to fire (because link time is the wrong time) and
warnings are errors.
Change-Id: I5df9281b2a9d98b164a9b11807ea9472c6faa9e3
diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h
index c7f2ac7..b4dad74 100644
--- a/libc/include/sys/cdefs.h
+++ b/libc/include/sys/cdefs.h
@@ -334,8 +334,10 @@
#if __GNUC_PREREQ__(4, 3)
#define __errordecl(name, msg) extern void name(void) __attribute__((__error__(msg)))
+#define __warnattr(msg) __attribute__((__warning__(msg)))
#else
#define __errordecl(name, msg) extern void name(void)
+#define __warnattr(msg)
#endif
/*
diff --git a/libc/include/sys/cdefs_elf.h b/libc/include/sys/cdefs_elf.h
index 0887fa5..bb846b7 100644
--- a/libc/include/sys/cdefs_elf.h
+++ b/libc/include/sys/cdefs_elf.h
@@ -38,20 +38,10 @@
#define _C_LABEL_STRING(x) x
#endif
-#if __STDC__
#define ___RENAME(x) __asm__(___STRING(_C_LABEL(x)))
-#else
-#ifdef __LEADING_UNDERSCORE
-#define ___RENAME(x) ____RENAME(_/**/x)
-#define ____RENAME(x) __asm__(___STRING(x))
-#else
-#define ___RENAME(x) __asm__(___STRING(x))
-#endif
-#endif
#define __indr_reference(sym,alias) /* nada, since we do weak refs */
-#if __STDC__
#define __strong_alias(alias,sym) \
__asm__(".global " _C_LABEL_STRING(#alias) "\n" \
_C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym));
@@ -61,39 +51,15 @@
_C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym));
#define __weak_extern(sym) \
__asm__(".weak " _C_LABEL_STRING(#sym));
+
+/* We use __warnattr instead of __warn_references.
+ * TODO: remove this and put an empty definition in one of the upstream-* compatibility headers.
+ */
#define __warn_references(sym,msg) \
- __asm__(".section .gnu.warning." #sym "\n\t.ascii \"" msg "\"\n\t.text");
+ /*__asm__(".section .gnu.warning." #sym "\n\t.ascii \"" msg "\"\n\t.text");*/
-#else /* !__STDC__ */
-
-#ifdef __LEADING_UNDERSCORE
-#define __weak_alias(alias,sym) ___weak_alias(_/**/alias,_/**/sym)
-#define ___weak_alias(alias,sym) \
- __asm__(".weak alias\nalias = sym");
-#else
-#define __weak_alias(alias,sym) \
- __asm__(".weak alias\nalias = sym");
-#endif
-#ifdef __LEADING_UNDERSCORE
-#define __weak_extern(sym) ___weak_extern(_/**/sym)
-#define ___weak_extern(sym) \
- __asm__(".weak sym");
-#else
-#define __weak_extern(sym) \
- __asm__(".weak sym");
-#endif
-#define __warn_references(sym,msg) \
- __asm__(".section .gnu.warning.sym\n\t.ascii msg ; .text");
-
-#endif /* !__STDC__ */
-
-#if __STDC__
#define __SECTIONSTRING(_sec, _str) \
__asm__(".section " #_sec "\n\t.asciz \"" _str "\"\n\t.previous")
-#else
-#define __SECTIONSTRING(_sec, _str) \
- __asm__(".section _sec\n\t.asciz _str\n\t.previous")
-#endif
/* GCC visibility helper macro */
/* This must be used to tag non-static functions that are private, i.e.