OSDN Git Service

Don't use the overloadable attribute if we're not fortified.
authorElliott Hughes <enh@google.com>
Wed, 14 Jun 2017 23:54:32 +0000 (16:54 -0700)
committerElliott Hughes <enh@google.com>
Wed, 14 Jun 2017 23:54:32 +0000 (16:54 -0700)
See code comment.

Bug: N/A
Test: building bash and binutils with a standalone toolchain
Change-Id: I73b5d55716072ca1b03b1b0157d65cb1ceb22841

libc/include/sys/cdefs.h

index 004c6b5..d62206d 100644 (file)
 #define __pass_object_size __pass_object_size_n(__bos_level)
 #define __pass_object_size0 __pass_object_size_n(0)
 
-/* Used to support clangisms with FORTIFY. This isn't in the FORTIFY section
- * because these change how symbols are emitted. The linker must be kept happy.
+/*
+ * Used to support clangisms with FORTIFY. Because these change how symbols are
+ * emitted, we need to ensure that bionic itself is built fortified. But lots
+ * of external code (especially stuff using configure) likes to declare
+ * functions directly, and they can't know that the overloadable attribute
+ * exists. This leads to errors like:
+ *
+ * dcigettext.c:151:7: error: redeclaration of 'getcwd' must have the 'overloadable' attribute
+ * char *getcwd ();
+ *       ^
+ *
+ * To avoid this and keep such software building, don't use overloadable if
+ * we're not using fortify.
  */
-#ifdef __clang__
+#if defined(__clang__) && defined(__BIONIC_FORTIFY)
 #  define __overloadable __attribute__((overloadable))
-// Don't use __RENAME directly because on gcc, this could result in a number of
-// unnecessary renames.
+/* We don't use __RENAME directly because on gcc this could result in unnecessary renames. */
 #  define __RENAME_CLANG(x) __RENAME(x)
 #else
 #  define __overloadable