This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch hjl/secondary created. glibc-2.16-ports-merge-320-g12e981c
- From: hjl at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 9 Sep 2012 22:08:29 -0000
- Subject: GNU C Library master sources branch hjl/secondary created. glibc-2.16-ports-merge-320-g12e981c
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, hjl/secondary has been created
at 12e981c980ee58db2cdbfbb6889b6978cccc5528 (commit)
- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=12e981c980ee58db2cdbfbb6889b6978cccc5528
commit 12e981c980ee58db2cdbfbb6889b6978cccc5528
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed Jul 4 07:55:52 2012 -0700
Add 3 STB_SECONDARY tests
diff --git a/ChangeLog.second b/ChangeLog.second
index 4435ddb..17e32e6 100644
--- a/ChangeLog.second
+++ b/ChangeLog.second
@@ -1,5 +1,24 @@
2012-09-06 H.J. Lu <hongjiu.lu@intel.com>
+ * elf/Makefile (tests): Add tst-secondary1 tst-secondary2
+ tst-secondary3 if STB_SECONDARY is supported by as/ld.
+ (modules-names): Add tst-secondarymod tst-secondary1mod
+ tst-secondary2mod tst-secondary3mod if STB_SECONDARY is supported
+ by as/ld.
+ (LDFLAGS-tst-secondarymod.so): New macro.
+ ($(objpfx)tst-secondary1): New rule.
+ ($(objpfx)tst-secondary2): Likewise.
+ ($(objpfx)tst-secondary3): Likewise.
+
+ * elf/tst-secondary.h: New file.
+ * elf/tst-secondary1.c: Likewise.
+ * elf/tst-secondary1mod.c: Likewise.
+ * elf/tst-secondary2.c: Likewise.
+ * elf/tst-secondary2mod.c: Likewise.
+ * elf/tst-secondary3.c: Likewise.
+ * elf/tst-secondary3mod.c: Likewise.
+ * elf/tst-secondarymod.c: Likewise.
+
* config.h.in: Add HAVE_ASM_SECONDARY_DIRECTIVE.
* config.make.in (have-secondary): New macro.
* configure.in: Check if STB_SECONDARY is supported by as/ld.
diff --git a/elf/Makefile b/elf/Makefile
index b999376..4beb416 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -261,6 +261,11 @@ modules-names += ifuncmod1 ifuncmod3 ifuncmod5 ifuncmod6
endif
endif
+ifeq (yes,$(have-secondary))
+tests += tst-secondary1 tst-secondary2 tst-secondary3
+modules-names += tst-secondarymod tst-secondary1mod tst-secondary2mod \
+ tst-secondary3mod
+endif
include ../Rules
@@ -1103,6 +1108,17 @@ $(objpfx)ifuncmain5static: $(addprefix $(objpfx),ifuncdep5.o)
$(objpfx)ifuncmain5staticpic: $(addprefix $(objpfx),ifuncdep5pic.o)
$(objpfx)ifuncmain5picstatic: $(addprefix $(objpfx),ifuncdep5pic.o)
+LDFLAGS-tst-secondarymod.so = -Wl,-z,secondary
+
+$(objpfx)tst-secondary1: $(objpfx)tst-secondarymod.so \
+ $(objpfx)tst-secondary1mod.so
+
+$(objpfx)tst-secondary2: $(objpfx)tst-secondarymod.so \
+ $(objpfx)tst-secondary2mod.so
+
+$(objpfx)tst-secondary3: $(objpfx)tst-secondarymod.so \
+ $(objpfx)tst-secondary3mod.so
+
$(objpfx)tst-unique1: $(libdl)
$(objpfx)tst-unique1.out: $(objpfx)tst-unique1mod1.so \
$(objpfx)tst-unique1mod2.so
diff --git a/elf/tst-secondary.h b/elf/tst-secondary.h
new file mode 100644
index 0000000..0487e25
--- /dev/null
+++ b/elf/tst-secondary.h
@@ -0,0 +1,3 @@
+#define GLOBAL 1
+#define WEAK 2
+#define SECONDARY 3
diff --git a/elf/tst-secondary1.c b/elf/tst-secondary1.c
new file mode 100644
index 0000000..f4d6edd
--- /dev/null
+++ b/elf/tst-secondary1.c
@@ -0,0 +1,13 @@
+/* Verify that secdonary function is called. */
+
+#include "tst-secondary.h"
+
+extern int bar (void);
+extern void foo (void);
+
+int
+main (void)
+{
+ foo ();
+ return bar () != SECONDARY;
+}
diff --git a/elf/tst-secondary1mod.c b/elf/tst-secondary1mod.c
new file mode 100644
index 0000000..cd0130c
--- /dev/null
+++ b/elf/tst-secondary1mod.c
@@ -0,0 +1,4 @@
+void
+foo (void)
+{
+}
diff --git a/elf/tst-secondary2.c b/elf/tst-secondary2.c
new file mode 100644
index 0000000..3f221cb
--- /dev/null
+++ b/elf/tst-secondary2.c
@@ -0,0 +1,13 @@
+/* Verify that global function is called. */
+
+#include "tst-secondary.h"
+
+extern int bar (void);
+extern void foo (void);
+
+int
+main (void)
+{
+ foo ();
+ return bar () != GLOBAL;
+}
diff --git a/elf/tst-secondary2mod.c b/elf/tst-secondary2mod.c
new file mode 100644
index 0000000..f9407a9
--- /dev/null
+++ b/elf/tst-secondary2mod.c
@@ -0,0 +1,12 @@
+#include "tst-secondary.h"
+
+int
+bar (void)
+{
+ return GLOBAL;
+}
+
+void
+foo (void)
+{
+}
diff --git a/elf/tst-secondary3.c b/elf/tst-secondary3.c
new file mode 100644
index 0000000..b55baea
--- /dev/null
+++ b/elf/tst-secondary3.c
@@ -0,0 +1,13 @@
+/* Verify that weak function is called. */
+
+#include "tst-secondary.h"
+
+extern int bar (void);
+extern void foo (void);
+
+int
+main (void)
+{
+ foo ();
+ return bar () != WEAK;
+}
diff --git a/elf/tst-secondary3mod.c b/elf/tst-secondary3mod.c
new file mode 100644
index 0000000..edfb25b
--- /dev/null
+++ b/elf/tst-secondary3mod.c
@@ -0,0 +1,13 @@
+#include "tst-secondary.h"
+
+int
+__attribute__ ((weak))
+bar (void)
+{
+ return WEAK;
+}
+
+void
+foo (void)
+{
+}
diff --git a/elf/tst-secondarymod.c b/elf/tst-secondarymod.c
new file mode 100644
index 0000000..5363e99
--- /dev/null
+++ b/elf/tst-secondarymod.c
@@ -0,0 +1,9 @@
+#include "tst-secondary.h"
+
+asm (".secondary bar");
+
+int
+bar (void)
+{
+ return SECONDARY;
+}
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=9005e24133c20241a79873cac799ee6e929f2ebf
commit 9005e24133c20241a79873cac799ee6e929f2ebf
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Sun Sep 9 14:38:37 2012 -0700
Check if STB_SECONDARY is supported by as/ld
diff --git a/ChangeLog.second b/ChangeLog.second
index ad3eba0..4435ddb 100644
--- a/ChangeLog.second
+++ b/ChangeLog.second
@@ -1,3 +1,12 @@
+2012-09-06 H.J. Lu <hongjiu.lu@intel.com>
+
+ * config.h.in: Add HAVE_ASM_SECONDARY_DIRECTIVE.
+ * config.make.in (have-secondary): New macro.
+ * configure.in: Check if STB_SECONDARY is supported by as/ld.
+ Define HAVE_ASM_SECONDARY_DIRECTIVE and set have-secondary to yes
+ if the .secondary assembly directive works.
+ * configure: Regenerated.
+
2012-06-30 H.J. Lu <hongjiu.lu@intel.com>
* elf/dl-addr.c (determine_info): Also check STB_SECONDARY.
diff --git a/config.h.in b/config.h.in
index 10a9925..855dc39 100644
--- a/config.h.in
+++ b/config.h.in
@@ -24,6 +24,10 @@
/* Define if weak symbols are available via the `.weakext' directive. */
#undef HAVE_ASM_WEAKEXT_DIRECTIVE
+/* Define if secondary symbols are available via the `.secondary'
+ directive. */
+#undef HAVE_ASM_SECONDARY_DIRECTIVE
+
/* Define if CFI directives are available. */
#undef HAVE_ASM_CFI_DIRECTIVES
diff --git a/config.make.in b/config.make.in
index d84fe38..4e69798 100644
--- a/config.make.in
+++ b/config.make.in
@@ -59,6 +59,7 @@ have-cpp-asm-debuginfo = @libc_cv_cpp_asm_debuginfo@
have-forced-unwind = @libc_cv_forced_unwind@
have-fpie = @libc_cv_fpie@
have-mfma4 = @libc_cv_cc_fma4@
+have-secondary = @libc_cv_ld_secondary@
have-as-vis3 = @libc_cv_sparc_as_vis3@
gnu89-inline-CFLAGS = @gnu89_inline@
have-ssp = @libc_cv_ssp@
diff --git a/configure b/configure
index d159ce0..65c29e9 100755
--- a/configure
+++ b/configure
@@ -608,6 +608,7 @@ have_libaudit
LIBGD
libc_cv_cc_submachine
exceptions
+libc_cv_ld_secondary
gnu89_inline
libc_cv_ssp
fno_unit_at_a_time
@@ -6725,8 +6726,10 @@ if { ac_try='${CC-cc} $ASFLAGS -c conftest.s 1>&5'
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; }; then
libc_cv_asm_weak_directive=yes
+ libc_cv_asm_weak=.weak
else
libc_cv_asm_weak_directive=no
+ libc_cv_asm_weak=
fi
rm -f conftest*
fi
@@ -6755,6 +6758,7 @@ EOF
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; }; then
libc_cv_asm_weakext_directive=yes
+ libc_cv_asm_weak=.weakext
else
libc_cv_asm_weakext_directive=no
fi
@@ -6773,6 +6777,71 @@ elif test $libc_cv_asm_weakext_directive = yes; then
fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for .secondary assembler directive" >&5
+$as_echo_n "checking for .secondary assembler directive... " >&6; }
+if ${libc_cv_asm_secondary_directive+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat > conftest.s <<EOF
+${libc_cv_dot_text}
+_sym:
+.secondary _sym
+EOF
+test -n "$libc_cv_asm_weak" && cat >> conftest.s <<EOF
+$libc_cv_asm_weak _sym
+EOF
+if ${CC-cc} -c $ASFLAGS -o conftest.o conftest.s 1>&5 2>&5; then
+ if $READELF -s conftest.o | fgrep _sym | fgrep SECOND > /dev/null; then
+ libc_cv_asm_secondary_directive=yes
+ else
+ libc_cv_asm_secondary_directive=no
+ fi
+else
+ libc_cv_asm_secondary_directive=no
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_asm_secondary_directive" >&5
+$as_echo "$libc_cv_asm_secondary_directive" >&6; }
+if test $libc_cv_asm_secondary_directive = yes; then
+ $as_echo "#define HAVE_ASM_SECONDARY_DIRECTIVE 1" >>confdefs.h
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for secondary symbol in shared library" >&5
+$as_echo_n "checking for secondary symbol in shared library... " >&6; }
+if ${libc_cv_ld_secondary+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat > conftest.c <<EOF
+asm (".secondary foo");
+void foo (void) { }
+EOF
+ if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
+ -fPIC -shared -o conftest.so conftest.c
+ -nostartfiles -nostdlib
+ 1>&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+ then
+ if $READELF -s conftest.so | fgrep foo | fgrep SECOND > /dev/null; then
+ libc_cv_ld_secondary=yes
+ else
+ libc_cv_ld_secondary=no
+ fi
+ else
+ libc_cv_ld_secondary=no
+ fi
+ rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_ld_secondary" >&5
+$as_echo "$libc_cv_ld_secondary" >&6; }
+else
+ libc_cv_ld_secondary=no
+fi
+
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether CFI directives are supported" >&5
$as_echo_n "checking whether CFI directives are supported... " >&6; }
if ${libc_cv_asm_cfi_directives+:} false; then :
diff --git a/configure.in b/configure.in
index a174646..28b0bfd 100644
--- a/configure.in
+++ b/configure.in
@@ -1757,8 +1757,10 @@ foo:
EOF
if AC_TRY_COMMAND(${CC-cc} $ASFLAGS -c conftest.s 1>&AS_MESSAGE_LOG_FD); then
libc_cv_asm_weak_directive=yes
+ libc_cv_asm_weak=.weak
else
libc_cv_asm_weak_directive=no
+ libc_cv_asm_weak=
fi
rm -f conftest*])
@@ -1777,6 +1779,7 @@ baz:
EOF
if AC_TRY_COMMAND(${CC-cc} $ASFLAGS -c conftest.s 1>&AS_MESSAGE_LOG_FD); then
libc_cv_asm_weakext_directive=yes
+ libc_cv_asm_weak=.weakext
else
libc_cv_asm_weakext_directive=no
fi
@@ -1790,6 +1793,53 @@ elif test $libc_cv_asm_weakext_directive = yes; then
AC_DEFINE(HAVE_ASM_WEAKEXT_DIRECTIVE)
fi
+AC_CACHE_CHECK(for .secondary assembler directive,
+ libc_cv_asm_secondary_directive, [dnl
+cat > conftest.s <<EOF
+${libc_cv_dot_text}
+_sym:
+.secondary _sym
+EOF
+test -n "$libc_cv_asm_weak" && cat >> conftest.s <<EOF
+$libc_cv_asm_weak _sym
+EOF
+if ${CC-cc} -c $ASFLAGS -o conftest.o conftest.s 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
+ if $READELF -s conftest.o | fgrep _sym | fgrep SECOND > /dev/null; then
+ libc_cv_asm_secondary_directive=yes
+ else
+ libc_cv_asm_secondary_directive=no
+ fi
+else
+ libc_cv_asm_secondary_directive=no
+fi
+rm -f conftest*])
+if test $libc_cv_asm_secondary_directive = yes; then
+ AC_DEFINE(HAVE_ASM_SECONDARY_DIRECTIVE)
+ AC_CACHE_CHECK(for secondary symbol in shared library,
+ libc_cv_ld_secondary, [dnl
+cat > conftest.c <<EOF
+asm (".secondary foo");
+void foo (void) { }
+EOF
+ if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
+ -fPIC -shared -o conftest.so conftest.c
+ -nostartfiles -nostdlib
+ 1>&AS_MESSAGE_LOG_FD])
+ then
+ if $READELF -s conftest.so | fgrep foo | fgrep SECOND > /dev/null; then
+ libc_cv_ld_secondary=yes
+ else
+ libc_cv_ld_secondary=no
+ fi
+ else
+ libc_cv_ld_secondary=no
+ fi
+ rm -f conftest*])
+else
+ libc_cv_ld_secondary=no
+fi
+AC_SUBST(libc_cv_ld_secondary)
+
AC_CACHE_CHECK(whether CFI directives are supported, libc_cv_asm_cfi_directives, [dnl
case $machine in
sparc/sparc64*) cfi_offset=2047;;
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=7396527aa47114cc1badd5e655016424aa532ea0
commit 7396527aa47114cc1badd5e655016424aa532ea0
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Sat Jun 30 12:53:04 2012 -0700
Add STB_SECONDARY support
diff --git a/ChangeLog.second b/ChangeLog.second
new file mode 100644
index 0000000..ad3eba0
--- /dev/null
+++ b/ChangeLog.second
@@ -0,0 +1,7 @@
+2012-06-30 H.J. Lu <hongjiu.lu@intel.com>
+
+ * elf/dl-addr.c (determine_info): Also check STB_SECONDARY.
+ * elf/dl-lookup.c (do_lookup_x): Handle STB_SECONDARY.
+ (_dl_lookup_symbol_x): Likewise.
+ * elf/sprof.c (read_symbols): Likewise.
+ * elf/elf.h (STB_SECONDARY): New.
diff --git a/elf/dl-addr.c b/elf/dl-addr.c
index 498faf1..dc2aca3 100644
--- a/elf/dl-addr.c
+++ b/elf/dl-addr.c
@@ -87,7 +87,8 @@ determine_info (const ElfW(Addr) addr, struct link_map *match, Dl_info *info,
for (; (void *) symtab < (void *) symtabend; ++symtab)
if ((ELFW(ST_BIND) (symtab->st_info) == STB_GLOBAL
- || ELFW(ST_BIND) (symtab->st_info) == STB_WEAK)
+ || ELFW(ST_BIND) (symtab->st_info) == STB_WEAK
+ || ELFW(ST_BIND) (symtab->st_info) == STB_SECONDARY)
&& ELFW(ST_TYPE) (symtab->st_info) != STT_TLS
&& (symtab->st_shndx != SHN_UNDEF
|| symtab->st_value != 0)
diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
index e7f7148..0e94d51 100644
--- a/elf/dl-lookup.c
+++ b/elf/dl-lookup.c
@@ -286,10 +286,15 @@ do_lookup_x (const char *undef_name, uint_fast32_t new_hash,
found_it:
switch (__builtin_expect (ELFW(ST_BIND) (sym->st_info), STB_GLOBAL))
{
+ case STB_SECONDARY:
+ /* Secondary definition. Use this value if we don't find
+ another. */
+ goto dynamic_weak;
case STB_WEAK:
/* Weak definition. Use this value if we don't find another. */
if (__builtin_expect (GLRO(dl_dynamic_weak), 0))
{
+dynamic_weak:
if (! result->s)
{
result->s = sym;
@@ -769,7 +774,9 @@ _dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map,
if (__builtin_expect (current_value.s == NULL, 0))
{
- if ((*ref == NULL || ELFW(ST_BIND) ((*ref)->st_info) != STB_WEAK)
+ if ((*ref == NULL
+ || (ELFW(ST_BIND) ((*ref)->st_info) != STB_WEAK
+ && ELFW(ST_BIND) ((*ref)->st_info) != STB_SECONDARY))
&& skip_map == NULL
&& !(GLRO(dl_debug_mask) & DL_DEBUG_UNUSED))
{
diff --git a/elf/elf.h b/elf/elf.h
index 41fc3bd..2b0a0c5 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -444,7 +444,8 @@ typedef struct
#define STB_LOCAL 0 /* Local symbol */
#define STB_GLOBAL 1 /* Global symbol */
#define STB_WEAK 2 /* Weak symbol */
-#define STB_NUM 3 /* Number of defined types. */
+#define STB_SECONDARY 3 /* Secondary symbol */
+#define STB_NUM 4 /* Number of defined types. */
#define STB_LOOS 10 /* Start of OS-specific */
#define STB_GNU_UNIQUE 10 /* Unique symbol. */
#define STB_HIOS 12 /* End of OS-specific */
diff --git a/elf/sprof.c b/elf/sprof.c
index 2097d31..2325180 100644
--- a/elf/sprof.c
+++ b/elf/sprof.c
@@ -1078,7 +1078,8 @@ read_symbols (struct shobj *shobj)
newsym->name = &shobj->strtab[sym->st_name];
newsym->addr = sym->st_value;
newsym->size = sym->st_size;
- newsym->weak = ELFW(ST_BIND) (sym->st_info) == STB_WEAK;
+ newsym->weak = (ELFW(ST_BIND) (sym->st_info) == STB_SECONDARY
+ || ELFW(ST_BIND) (sym->st_info) == STB_WEAK);
newsym->hidden = (ELFW(ST_VISIBILITY) (sym->st_other)
!= STV_DEFAULT);
newsym->ticks = 0;
@@ -1136,7 +1137,8 @@ read_symbols (struct shobj *shobj)
newsym->name = &strtab[symtab->st_name];
newsym->addr = symtab->st_value;
newsym->size = symtab->st_size;
- newsym->weak = ELFW(ST_BIND) (symtab->st_info) == STB_WEAK;
+ newsym->weak = (ELFW(ST_BIND) (symtab->st_info) == STB_SECONDARY
+ || ELFW(ST_BIND) (symtab->st_info) == STB_WEAK);
newsym->hidden = (ELFW(ST_VISIBILITY) (symtab->st_other)
!= STV_DEFAULT);
newsym->ticks = 0;
-----------------------------------------------------------------------
hooks/post-receive
--
GNU C Library master sources