* config.make.in (weak-symbols): Variable removed.
* configure.in (--with-weak-symbols): Option removed.
(NO_UNDERSCORES, HAVE_ASM_WEAK_DIRECTIVE, HAVE_ASM_WEAKEXT_DIRECTIVE):
New tests.
* config.h.in (HAVE_WEAK_SYMBOLS): #undef removed.
(NO_UNDERSCORES, HAVE_ASM_WEAK_DIRECTIVE, HAVE_ASM_WEAKEXT_DIRECTIVE):
New #undefs.
* libc-symbols.h: Use them instead of HAVE_WEAK_SYMBOLS.
#undef HAVE_GNU_LD
/* Define if using ELF, which supports weak symbols.
- This implies HAVE_WEAK_SYMBOLS; set by --with-elf. */
+ This implies HAVE_ASM_WEAK_DIRECTIVE and NO_UNDERSCORES; set by
+ --with-elf. */
#undef HAVE_ELF
-/* Define if weak symbols are available in the assembler and
- linker being used. Set by --with-weak-symbols. */
-#undef HAVE_WEAK_SYMBOLS
+/* Define if C symbols are asm symbols. Don't define if C symbols
+ have a `_' prepended to make the asm symbol. */
+#undef NO_UNDERSCORES
+
+/* Define if weak symbols are available via the `.weak' directive. */
+#undef HAVE_ASM_WEAK_DIRECTIVE
+
+/* Define if weak symbols are available via the `.weakext' directive. */
+#undef HAVE_ASM_WEAKEXT_DIRECTIVE
/* Define if not using ELF, but `.init' and `.fini' sections are available. */
#undef HAVE_INITFINI
declaring a symbol global (default `.globl'). */
#undef ASM_GLOBAL_DIRECTIVE
-/* ELF has weak symbols, and with GNU ld a.out does too. */
-#ifndef HAVE_WEAK_SYMBOLS
-#if defined (HAVE_ELF) || defined (HAVE_GNU_LD)
-#define HAVE_WEAK_SYMBOLS
-#endif
-#endif
-
/* Define to use GNU libio instead of GNU stdio.
This is defined by configure under --enable-libio. */
#undef USE_IN_LIBIO
config-defines = @DEFS@
elf = @elf@
-weak-symbols = @weak@
have-initfini = @libc_cv_have_initfini@
# Configuration options.
Dnl Process this file with autoconf to produce a configure script.
AC_REVISION([$CVSid$])
-AC_PREREQ(2.4.2)dnl dnl Minimum Autoconf version required.
+AC_PREREQ(2.9)dnl dnl Minimum Autoconf version required.
AC_INIT(features.h)
AC_CONFIG_HEADER(config.h)
AC_ARG_WITH(elf, dnl
--with-elf if using the ELF object format,
elf=$withval, elf=no)
-AC_ARG_WITH(weak-symbols, dnl
- --with-weak-symbols if weak symbols are available in as and ld,
- weak=$withval, weak=no)
AC_ARG_ENABLE(libio, dnl
[ --enable-libio build in GNU libio instead of GNU stdio],
fi
fi
+if test $elf = yes; then
+ libc_cv_asm_underscores=no
+else
+ AC_CACHE_CHECK(for _ prefix on C symbol names, libc_cv_asm_underscores,
+ [AC_TRY_COMPILE([asm ("_glibc_foobar:");], [glibc_foobar ();],
+ libc_cv_asm_underscores=yes,
+ libc_cv_asm_underscores=no)])
+fi
+if test $libc_cv_asm_underscores = no; then
+ AC_DEFINE(NO_UNDERSCORES)
+fi
+
+if test $elf = yes; then
+ libc_cv_weak_symbols=yes
+ libc_cv_asm_weak_directive=yes
+ libc_cv_asm_weakext_directive=no
+else
+ AC_CACHE_CHECK(for assembler .weak directive, libc_cv_asm_weak_directive,
+ [dnl
+cat > conftest.s <<EOF
+.text
+${libc_cv_asm_global_directive} foo
+foo: .long 0
+.weak foo
+.weak bar; bar = foo
+EOF
+ if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
+ libc_cv_asm_weak_directive=yes
+ else
+ libc_cv_asm_weak_directive=no
+ fi
+ rm -f conftest*])
+
+if $libc_cv_asm_weak_directive = no; then
+ AC_CACHE_CHECK(for assembler .weakext directive,
+ libc_cv_asm_weakext_directive,
+ [dnl
+cat > conftest.s <<EOF
+.text
+${libc_cv_asm_global_directive} foo
+foo: .long 0
+.weakext foo
+.weak bar, foo
+EOF
+ if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
+ libc_cv_asm_weakext_directive=yes
+ else
+ libc_cv_asm_weakext_directive=no
+ fi
+ rm -f conftest*])
+
+ fi # no .weak
+fi # not ELF
+
+if test $libc_cv_asm_weak_directive; then
+ AC_DEFINE(HAVE_ASM_WEAK_DIRECTIVE)
+elif test $libc_cv_asm_weakext_directive; then
+ AC_DEFINE(HAVE_ASM_WEAKEXT_DIRECTIVE)
+fi
+
+### End of automated tests.
+### Now run sysdeps configure fragments.
+
# sysdeps configure fragments may set these with files to be linked below.
libc_link_dests=
libc_link_sources=
esac
AC_MSG_RESULT($stdio)
-AC_SUBST(gnu_ld) AC_SUBST(gnu_as) AC_SUBST(elf) AC_SUBST(weak)
+AC_SUBST(gnu_ld) AC_SUBST(gnu_as) AC_SUBST(elf)
if test $gnu_ld = yes; then
AC_DEFINE(HAVE_GNU_LD)
fi
if test $elf = yes; then
AC_DEFINE(HAVE_ELF)
fi
-if test $weak = yes; then
- AC_DEFINE(HAVE_WEAK_SYMBOLS)
-fi
AC_SUBST(shared)
if test $shared = default; then
We include config.h which is generated by configure.
It should define for us the following symbols:
+ * HAVE_ASM_SET_DIRECTIVE if we have `.set B, A' instead of `A = B'.
+ * ASM_GLOBAL_DIRECTIVE with `.globl' or `.global'.
* HAVE_GNU_LD if using GNU ld, with support for weak symbols in a.out,
and for symbol set and warning messages extensions in a.out and ELF.
- This implies HAVE_WEAK_SYMBOLS; set by --with-gnu-ld.
- * HAVE_ELF if using ELF, which supports weak symbols.
- This implies HAVE_WEAK_SYMBOLS; set by --with-elf.
-
- * HAVE_WEAK_SYMBOLS if weak symbols are available in the assembler and
- linker being used. Set by --with-weak-symbols.
+ * HAVE_ELF if using ELF, which supports weak symbols using `.weak'.
+ * HAVE_ASM_WEAK_DIRECTIVE if we have weak symbols using `.weak'.
+ * HAVE_ASM_WEAKEXT_DIRECTIVE if we have weak symbols using `.weakext'.
*/
/*
\f
*/
-/* The symbols in all the user (non-_) macros are C symbols. Predefined
- should be HAVE_WEAK_SYMBOLS and/or HAVE_ELF and/or HAVE_GNU_LD.
- HAVE_WEAK_SYMBOLS is implied by the other two. HAVE_GNU_LD without
- HAVE_ELF implies a.out. */
+/* The symbols in all the user (non-_) macros are C symbols.
+ HAVE_GNU_LD without HAVE_ELF implies a.out. */
-#ifndef HAVE_WEAK_SYMBOLS
-#if defined (HAVE_ELF) || defined (HAVE_GNU_LD)
+#if defined (HAVE_ASM_WEAK_DIRECTIVE) || defined (HAVE_ASM_WEAKEXT_DIRECTIVE)
#define HAVE_WEAK_SYMBOLS
#endif
-#endif
#ifndef __SYMBOL_PREFIX
-#ifdef HAVE_ELF
-#define NO_UNDERSCORES
-#else
-#include <sysdep.h> /* Should define NO_UNDERSCORES. */
-#endif
#ifdef NO_UNDERSCORES
#define __SYMBOL_PREFIX
#else
#ifdef HAVE_WEAK_SYMBOLS
+
#ifdef ASSEMBLER
+#ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
+
+/* Define ALIAS as a weak alias for ORIGINAL.
+ If weak aliases are not available, this defines a strong alias. */
+#define weak_alias(original, alias) \
+ .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
+
+/* Declare SYMBOL to be weak. */
+#define weak_symbol(symbol) .weakext C_SYMBOL_NAME (symbol)
+
+#else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
+
/* Define ALIAS as a weak alias for ORIGINAL.
If weak aliases are not available, this defines a strong alias. */
#define weak_alias(original, alias) \
/* Declare SYMBOL to be weak. */
#define weak_symbol(symbol) .weak C_SYMBOL_NAME (symbol)
-#else
+#endif /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
+
+#else /* ! ASSEMBLER */
+
+#ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
+#define weak_symbol(symbol) asm (".weakext " __SYMBOL_PREFIX #symbol);
+#define weak_alias(original, alias) \
+ asm (".weakext " __SYMBOL_PREFIX #alias ", " __SYMBOL_PREFIX #original);
+#else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
#define weak_symbol(symbol) asm (".weak " __SYMBOL_PREFIX #symbol);
#define weak_alias(original, alias) \
asm (".weak " __SYMBOL_PREFIX #alias "\n" \
__SYMBOL_PREFIX #alias " = " __SYMBOL_PREFIX #original);
-#endif
+#endif /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
+#endif /* ! ASSEMBLER */
#else
#define weak_alias(original, alias) strong_alias(original, alias)
#define weak_symbol(symbol) /* Do nothing. */