summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog175
-rw-r--r--conform/GlibcConform.pm74
-rw-r--r--conform/Makefile210
-rw-r--r--conform/conformtest.pl12
-rw-r--r--conform/linknamespace.pl241
-rw-r--r--conform/list-header-symbols.pl81
6 files changed, 782 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 177a6d7576..d4c340630d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,180 @@
2014-11-12 Joseph Myers <joseph@codesourcery.com>
+ * conform/GlibcConform.pm: New file.
+ * conform/conformtest.pl: Use GlibcConform module.
+ * conform/linknamespace.pl: New file.
+ * conform/list-header-symbols.pl: Likewise.
+ * conform/Makefile (linknamespace-symlists-base): New variable.
+ (linknamespace-symlists-tests): Likewise.
+ (linknamespace-header-base): Likewise.
+ (linknamespace-header-tests): Likewise.
+ (tests-special): Add new tests.
+ ($(linknamespace-symlists-tests)): New rule.
+ (linknamespace-libs): New variable.
+ ($(objpfx)symlist-stdlibs): New rule.
+ ($(linknamespace-header-tests)): Likewise.
+ (test-xfail-XPG3/varargs.h/linknamespace): New variable.
+ (test-xfail-XPG4/varargs.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/varargs.h/linknamespace): Likewise.
+ (test-xfail-XPG4/ndbm.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/ndbm.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/ndbm.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/ndbm.h/linknamespace): Likewise.
+ (test-xfail-ISO/math.h/linknamespace): Likewise.
+ (test-xfail-ISO/signal.h/linknamespace): Likewise.
+ (test-xfail-ISO/stdio.h/linknamespace): Likewise.
+ (test-xfail-ISO/time.h/linknamespace): Likewise.
+ (test-xfail-ISO99/complex.h/linknamespace): Likewise.
+ (test-xfail-ISO99/ctype.h/linknamespace): Likewise.
+ (test-xfail-ISO99/math.h/linknamespace): Likewise.
+ (test-xfail-ISO99/signal.h/linknamespace): Likewise.
+ (test-xfail-ISO99/stdio.h/linknamespace): Likewise.
+ (test-xfail-ISO99/tgmath.h/linknamespace): Likewise.
+ (test-xfail-ISO11/complex.h/linknamespace): Likewise.
+ (test-xfail-ISO11/ctype.h/linknamespace): Likewise.
+ (test-xfail-ISO11/math.h/linknamespace): Likewise.
+ (test-xfail-ISO11/signal.h/linknamespace): Likewise.
+ (test-xfail-ISO11/stdio.h/linknamespace): Likewise.
+ (test-xfail-ISO11/tgmath.h/linknamespace): Likewise.
+ (test-xfail-XPG3/ctype.h/linknamespace): Likewise.
+ (test-xfail-XPG3/fnmatch.h/linknamespace): Likewise.
+ (test-xfail-XPG3/glob.h/linknamespace): Likewise.
+ (test-xfail-XPG3/math.h/linknamespace): Likewise.
+ (test-xfail-XPG3/regex.h/linknamespace): Likewise.
+ (test-xfail-XPG3/search.h/linknamespace): Likewise.
+ (test-xfail-XPG3/stdio.h/linknamespace): Likewise.
+ (test-xfail-XPG3/time.h/linknamespace): Likewise.
+ (test-xfail-XPG3/unistd.h/linknamespace): Likewise.
+ (test-xfail-XPG3/wordexp.h/linknamespace): Likewise.
+ (test-xfail-XPG4/ctype.h/linknamespace): Likewise.
+ (test-xfail-XPG4/fmtmsg.h/linknamespace): Likewise.
+ (test-xfail-XPG4/fnmatch.h/linknamespace): Likewise.
+ (test-xfail-XPG4/glob.h/linknamespace): Likewise.
+ (test-xfail-XPG4/grp.h/linknamespace): Likewise.
+ (test-xfail-XPG4/libgen.h/linknamespace): Likewise.
+ (test-xfail-XPG4/math.h/linknamespace): Likewise.
+ (test-xfail-XPG4/netdb.h/linknamespace): Likewise.
+ (test-xfail-XPG4/pwd.h/linknamespace): Likewise.
+ (test-xfail-XPG4/regex.h/linknamespace): Likewise.
+ (test-xfail-XPG4/search.h/linknamespace): Likewise.
+ (test-xfail-XPG4/stdio.h/linknamespace): Likewise.
+ (test-xfail-XPG4/stdlib.h/linknamespace): Likewise.
+ (test-xfail-XPG4/sys/mman.h/linknamespace): Likewise.
+ (test-xfail-XPG4/sys/statvfs.h/linknamespace): Likewise.
+ (test-xfail-XPG4/syslog.h/linknamespace): Likewise.
+ (test-xfail-XPG4/time.h/linknamespace): Likewise.
+ (test-xfail-XPG4/unistd.h/linknamespace): Likewise.
+ (test-xfail-XPG4/wordexp.h/linknamespace): Likewise.
+ (test-xfail-POSIX/aio.h/linknamespace): Likewise.
+ (test-xfail-POSIX/fnmatch.h/linknamespace): Likewise.
+ (test-xfail-POSIX/glob.h/linknamespace): Likewise.
+ (test-xfail-POSIX/math.h/linknamespace): Likewise.
+ (test-xfail-POSIX/mqueue.h/linknamespace): Likewise.
+ (test-xfail-POSIX/pthread.h/linknamespace): Likewise.
+ (test-xfail-POSIX/regex.h/linknamespace): Likewise.
+ (test-xfail-POSIX/sched.h/linknamespace): Likewise.
+ (test-xfail-POSIX/semaphore.h/linknamespace): Likewise.
+ (test-xfail-POSIX/sys/mman.h/linknamespace): Likewise.
+ (test-xfail-POSIX/time.h/linknamespace): Likewise.
+ (test-xfail-POSIX/unistd.h/linknamespace): Likewise.
+ (test-xfail-POSIX/wordexp.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/aio.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/ctype.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/fmtmsg.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/fnmatch.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/glob.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/grp.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/libgen.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/math.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/mqueue.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/netdb.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/pthread.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/pwd.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/regex.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/sched.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/search.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/semaphore.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/stdio.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/stdlib.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/sys/mman.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/sys/statvfs.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/syslog.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/time.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/unistd.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/wchar.h/linknamespace): Likewise.
+ (test-xfail-UNIX98/wordexp.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/aio.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/complex.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/fcntl.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/fmtmsg.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/fnmatch.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/glob.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/grp.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/libgen.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/math.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/mqueue.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/net/if.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/netdb.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/pthread.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/pwd.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/regex.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/search.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/semaphore.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/signal.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/spawn.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/stdlib.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/sys/mman.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/sys/statvfs.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/sys/wait.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/syslog.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/tgmath.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/time.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/ucontext.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/unistd.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K/wordexp.h/linknamespace): Likewise.
+ (test-xfail-POSIX2008/aio.h/linknamespace): Likewise.
+ (test-xfail-POSIX2008/complex.h/linknamespace): Likewise.
+ (test-xfail-POSIX2008/ctype.h/linknamespace): Likewise.
+ (test-xfail-POSIX2008/dirent.h/linknamespace): Likewise.
+ (test-xfail-POSIX2008/fcntl.h/linknamespace): Likewise.
+ (test-xfail-POSIX2008/grp.h/linknamespace): Likewise.
+ (test-xfail-POSIX2008/math.h/linknamespace): Likewise.
+ (test-xfail-POSIX2008/mqueue.h/linknamespace): Likewise.
+ (test-xfail-POSIX2008/net/if.h/linknamespace): Likewise.
+ (test-xfail-POSIX2008/netdb.h/linknamespace): Likewise.
+ (test-xfail-POSIX2008/pthread.h/linknamespace): Likewise.
+ (test-xfail-POSIX2008/regex.h/linknamespace): Likewise.
+ (test-xfail-POSIX2008/semaphore.h/linknamespace): Likewise.
+ (test-xfail-POSIX2008/spawn.h/linknamespace): Likewise.
+ (test-xfail-POSIX2008/sys/mman.h/linknamespace): Likewise.
+ (test-xfail-POSIX2008/sys/statvfs.h/linknamespace): Likewise.
+ (test-xfail-POSIX2008/tgmath.h/linknamespace): Likewise.
+ (test-xfail-POSIX2008/time.h/linknamespace): Likewise.
+ (test-xfail-POSIX2008/unistd.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/aio.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/complex.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/dirent.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/fcntl.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/fmtmsg.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/grp.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/libgen.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/math.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/mqueue.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/net/if.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/netdb.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/pthread.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/pwd.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/regex.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/search.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/semaphore.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/spawn.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/sys/mman.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/sys/statvfs.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/syslog.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/tgmath.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/time.h/linknamespace): Likewise.
+ (test-xfail-XOPEN2K8/unistd.h/linknamespace): Likewise.
+
[BZ #17589]
* intl/localealias.c [_LIBC] (FGETS): Use __fgets_unlocked instead
of fgets_unlocked.
diff --git a/conform/GlibcConform.pm b/conform/GlibcConform.pm
new file mode 100644
index 0000000000..2735f4e340
--- /dev/null
+++ b/conform/GlibcConform.pm
@@ -0,0 +1,74 @@
+#! /usr/bin/perl
+
+# Shared code for glibc conformance tests.
+
+# Copyright (C) 2014 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+package GlibcConform;
+require Exporter;
+@ISA = qw(Exporter);
+@EXPORT = qw(%CFLAGS list_exported_functions);
+
+# Compiler options for each standard.
+$CFLAGS{"ISO"} = "-ansi";
+$CFLAGS{"ISO99"} = "-std=c99";
+$CFLAGS{"ISO11"} = "-std=c1x -D_ISOC11_SOURCE";
+$CFLAGS{"POSIX"} = "-D_POSIX_C_SOURCE=199912 -ansi";
+$CFLAGS{"XPG3"} = "-ansi -D_XOPEN_SOURCE";
+$CFLAGS{"XPG4"} = "-ansi -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED";
+$CFLAGS{"UNIX98"} = "-ansi -D_XOPEN_SOURCE=500";
+$CFLAGS{"XOPEN2K"} = "-std=c99 -D_XOPEN_SOURCE=600";
+$CFLAGS{"XOPEN2K8"} = "-std=c99 -D_XOPEN_SOURCE=700";
+$CFLAGS{"POSIX2008"} = "-std=c99 -D_POSIX_C_SOURCE=200809L";
+
+# Return a list of functions exported by a header, empty if an include
+# of the header does not compile.
+sub list_exported_functions {
+ my ($cc, $standard, $header, $tmpdir) = @_;
+ my ($cc_all) = "$cc -D_ISOMAC $CFLAGS{$standard}";
+ my ($tmpfile) = "$tmpdir/list-$$.c";
+ my ($auxfile) = "$tmpdir/list-$$.c.aux";
+ my ($ret);
+ my (%res) = ();
+ open (TMPFILE, ">$tmpfile") || die ("open $tmpfile: $!\n");
+ print TMPFILE "#include <$header>\n";
+ close (TMPFILE) || die ("close $tmpfile: $!\n");
+ $ret = system "$cc_all -c $tmpfile -o /dev/null -aux-info $auxfile > /dev/null";
+ unlink ($tmpfile) || die ("unlink $tmpfile: $!\n");
+ if ($ret != 0) {
+ return;
+ }
+ open (AUXFILE, "<$auxfile") || die ("open $auxfile: $!\n");
+ while (<AUXFILE>) {
+ s|/\*.*?\*/||g;
+ if (/^\s*$/) {
+ next;
+ }
+ # The word before a '(' that isn't '(*' is the function name
+ # before the argument list (not fully general, but sufficient for
+ # -aux-info output on standard headers).
+ if (/(\w+)\s*\([^*]/) {
+ $res{$1} = 1;
+ } else {
+ die ("couldn't parse -aux-info output: $_\n");
+ }
+ }
+ close (AUXFILE) || die ("close $auxfile: $!\n");
+ unlink ($auxfile) || die ("unlink $auxfile: $!\n");
+ return sort keys %res;
+}
diff --git a/conform/Makefile b/conform/Makefile
index 3c14355256..45917a66f3 100644
--- a/conform/Makefile
+++ b/conform/Makefile
@@ -118,6 +118,23 @@ generated += $(conformtest-header-base)
endif
endif
+linknamespace-symlists-base := $(foreach std,$(conformtest-standards),\
+ symlist-$(std))
+linknamespace-symlists-tests := $(addprefix $(objpfx),\
+ $(linknamespace-symlists-base))
+tests-special += $(linknamespace-symlists-tests)
+
+tests-special += $(objpfx)symlist-stdlibs
+
+linknamespace-header-base := $(foreach std,\
+ $(conformtest-standards),\
+ $(foreach h,\
+ $(conformtest-headers-$(std)),\
+ $(std)/$(h)/linknamespace.out))
+linknamespace-header-tests := $(addprefix $(objpfx),\
+ $(linknamespace-header-base))
+tests-special += $(linknamespace-header-tests)
+
include ../Rules
$(conformtest-header-list-tests): $(objpfx)header-list-%.out: \
@@ -269,3 +286,196 @@ $(conformtest-header-tests): $(objpfx)%/conform.out: \
--flags='$(conformtest-cc-flags)' --standard=$$std \
--headers=$$hdr > $@); \
$(evaluate-test)
+
+$(linknamespace-symlists-tests): $(objpfx)symlist-%: list-header-symbols.pl
+ $(PERL) -w $< --tmpdir=$(objpfx) --cc='$(CC)' \
+ --flags='$(conformtest-cc-flags)' --standard=$* \
+ --headers="$(strip $(conformtest-headers-$*))" \
+ > $@ 2> $@.err; \
+ $(evaluate-test)
+
+linknamespace-libs = $(common-objpfx)libc.a $(common-objpfx)math/libm.a \
+ $(common-objpfx)rt/librt.a $(static-thread-library)
+
+$(objpfx)symlist-stdlibs: $(linknamespace-libs)
+ LC_ALL=C $(READELF) -W -s $^ > $@; \
+ $(evaluate-test)
+
+$(linknamespace-header-tests): $(objpfx)%/linknamespace.out: \
+ linknamespace.pl $(objpfx)symlist-stdlibs
+ (set -e; std_hdr=$*; std=$${std_hdr%%/*}; hdr=$${std_hdr#*/}; \
+ mkdir -p $(@D)/scratch; \
+ $(PERL) -w $< --tmpdir=$(@D)/scratch --cc='$(CC)' \
+ --flags='$(conformtest-cc-flags)' --standard=$$std \
+ --stdsyms=$(objpfx)symlist-$$std --header=$$hdr \
+ --libsyms='$(objpfx)symlist-stdlibs' --readelf='$(READELF)' \
+ > $@ 2>&1); \
+ $(evaluate-test)
+
+# Pre-standard C feature no longer supported by GCC (obsoleted in
+# newer POSIX standards).
+test-xfail-XPG3/varargs.h/linknamespace = yes
+test-xfail-XPG4/varargs.h/linknamespace = yes
+test-xfail-UNIX98/varargs.h/linknamespace = yes
+
+# Header not provided by glibc.
+test-xfail-XPG4/ndbm.h/linknamespace = yes
+test-xfail-UNIX98/ndbm.h/linknamespace = yes
+test-xfail-XOPEN2K/ndbm.h/linknamespace = yes
+test-xfail-XOPEN2K8/ndbm.h/linknamespace = yes
+
+# Unsorted expected failures.
+test-xfail-ISO/math.h/linknamespace = yes
+test-xfail-ISO/signal.h/linknamespace = yes
+test-xfail-ISO/stdio.h/linknamespace = yes
+test-xfail-ISO/time.h/linknamespace = yes
+test-xfail-ISO99/complex.h/linknamespace = yes
+test-xfail-ISO99/ctype.h/linknamespace = yes
+test-xfail-ISO99/math.h/linknamespace = yes
+test-xfail-ISO99/signal.h/linknamespace = yes
+test-xfail-ISO99/stdio.h/linknamespace = yes
+test-xfail-ISO99/tgmath.h/linknamespace = yes
+test-xfail-ISO11/complex.h/linknamespace = yes
+test-xfail-ISO11/ctype.h/linknamespace = yes
+test-xfail-ISO11/math.h/linknamespace = yes
+test-xfail-ISO11/signal.h/linknamespace = yes
+test-xfail-ISO11/stdio.h/linknamespace = yes
+test-xfail-ISO11/tgmath.h/linknamespace = yes
+test-xfail-XPG3/ctype.h/linknamespace = yes
+test-xfail-XPG3/fnmatch.h/linknamespace = yes
+test-xfail-XPG3/glob.h/linknamespace = yes
+test-xfail-XPG3/math.h/linknamespace = yes
+test-xfail-XPG3/regex.h/linknamespace = yes
+test-xfail-XPG3/search.h/linknamespace = yes
+test-xfail-XPG3/stdio.h/linknamespace = yes
+test-xfail-XPG3/time.h/linknamespace = yes
+test-xfail-XPG3/unistd.h/linknamespace = yes
+test-xfail-XPG3/wordexp.h/linknamespace = yes
+test-xfail-XPG4/ctype.h/linknamespace = yes
+test-xfail-XPG4/fmtmsg.h/linknamespace = yes
+test-xfail-XPG4/fnmatch.h/linknamespace = yes
+test-xfail-XPG4/glob.h/linknamespace = yes
+test-xfail-XPG4/grp.h/linknamespace = yes
+test-xfail-XPG4/libgen.h/linknamespace = yes
+test-xfail-XPG4/math.h/linknamespace = yes
+test-xfail-XPG4/netdb.h/linknamespace = yes
+test-xfail-XPG4/pwd.h/linknamespace = yes
+test-xfail-XPG4/regex.h/linknamespace = yes
+test-xfail-XPG4/search.h/linknamespace = yes
+test-xfail-XPG4/stdio.h/linknamespace = yes
+test-xfail-XPG4/stdlib.h/linknamespace = yes
+test-xfail-XPG4/sys/mman.h/linknamespace = yes
+test-xfail-XPG4/sys/statvfs.h/linknamespace = yes
+test-xfail-XPG4/syslog.h/linknamespace = yes
+test-xfail-XPG4/time.h/linknamespace = yes
+test-xfail-XPG4/unistd.h/linknamespace = yes
+test-xfail-XPG4/wordexp.h/linknamespace = yes
+test-xfail-POSIX/aio.h/linknamespace = yes
+test-xfail-POSIX/fnmatch.h/linknamespace = yes
+test-xfail-POSIX/glob.h/linknamespace = yes
+test-xfail-POSIX/math.h/linknamespace = yes
+test-xfail-POSIX/mqueue.h/linknamespace = yes
+test-xfail-POSIX/pthread.h/linknamespace = yes
+test-xfail-POSIX/regex.h/linknamespace = yes
+test-xfail-POSIX/sched.h/linknamespace = yes
+test-xfail-POSIX/semaphore.h/linknamespace = yes
+test-xfail-POSIX/sys/mman.h/linknamespace = yes
+test-xfail-POSIX/time.h/linknamespace = yes
+test-xfail-POSIX/unistd.h/linknamespace = yes
+test-xfail-POSIX/wordexp.h/linknamespace = yes
+test-xfail-UNIX98/aio.h/linknamespace = yes
+test-xfail-UNIX98/ctype.h/linknamespace = yes
+test-xfail-UNIX98/fmtmsg.h/linknamespace = yes
+test-xfail-UNIX98/fnmatch.h/linknamespace = yes
+test-xfail-UNIX98/glob.h/linknamespace = yes
+test-xfail-UNIX98/grp.h/linknamespace = yes
+test-xfail-UNIX98/libgen.h/linknamespace = yes
+test-xfail-UNIX98/math.h/linknamespace = yes
+test-xfail-UNIX98/mqueue.h/linknamespace = yes
+test-xfail-UNIX98/netdb.h/linknamespace = yes
+test-xfail-UNIX98/pthread.h/linknamespace = yes
+test-xfail-UNIX98/pwd.h/linknamespace = yes
+test-xfail-UNIX98/regex.h/linknamespace = yes
+test-xfail-UNIX98/sched.h/linknamespace = yes
+test-xfail-UNIX98/search.h/linknamespace = yes
+test-xfail-UNIX98/semaphore.h/linknamespace = yes
+test-xfail-UNIX98/stdio.h/linknamespace = yes
+test-xfail-UNIX98/stdlib.h/linknamespace = yes
+test-xfail-UNIX98/sys/mman.h/linknamespace = yes
+test-xfail-UNIX98/sys/statvfs.h/linknamespace = yes
+test-xfail-UNIX98/syslog.h/linknamespace = yes
+test-xfail-UNIX98/time.h/linknamespace = yes
+test-xfail-UNIX98/unistd.h/linknamespace = yes
+test-xfail-UNIX98/wchar.h/linknamespace = yes
+test-xfail-UNIX98/wordexp.h/linknamespace = yes
+test-xfail-XOPEN2K/aio.h/linknamespace = yes
+test-xfail-XOPEN2K/complex.h/linknamespace = yes
+test-xfail-XOPEN2K/fcntl.h/linknamespace = yes
+test-xfail-XOPEN2K/fmtmsg.h/linknamespace = yes
+test-xfail-XOPEN2K/fnmatch.h/linknamespace = yes
+test-xfail-XOPEN2K/glob.h/linknamespace = yes
+test-xfail-XOPEN2K/grp.h/linknamespace = yes
+test-xfail-XOPEN2K/libgen.h/linknamespace = yes
+test-xfail-XOPEN2K/math.h/linknamespace = yes
+test-xfail-XOPEN2K/mqueue.h/linknamespace = yes
+test-xfail-XOPEN2K/net/if.h/linknamespace = yes
+test-xfail-XOPEN2K/netdb.h/linknamespace = yes
+test-xfail-XOPEN2K/pthread.h/linknamespace = yes
+test-xfail-XOPEN2K/pwd.h/linknamespace = yes
+test-xfail-XOPEN2K/regex.h/linknamespace = yes
+test-xfail-XOPEN2K/search.h/linknamespace = yes
+test-xfail-XOPEN2K/semaphore.h/linknamespace = yes
+test-xfail-XOPEN2K/signal.h/linknamespace = yes
+test-xfail-XOPEN2K/spawn.h/linknamespace = yes
+test-xfail-XOPEN2K/stdlib.h/linknamespace = yes
+test-xfail-XOPEN2K/sys/mman.h/linknamespace = yes
+test-xfail-XOPEN2K/sys/statvfs.h/linknamespace = yes
+test-xfail-XOPEN2K/sys/wait.h/linknamespace = yes
+test-xfail-XOPEN2K/syslog.h/linknamespace = yes
+test-xfail-XOPEN2K/tgmath.h/linknamespace = yes
+test-xfail-XOPEN2K/time.h/linknamespace = yes
+test-xfail-XOPEN2K/ucontext.h/linknamespace = yes
+test-xfail-XOPEN2K/unistd.h/linknamespace = yes
+test-xfail-XOPEN2K/wordexp.h/linknamespace = yes
+test-xfail-POSIX2008/aio.h/linknamespace = yes
+test-xfail-POSIX2008/complex.h/linknamespace = yes
+test-xfail-POSIX2008/ctype.h/linknamespace = yes
+test-xfail-POSIX2008/dirent.h/linknamespace = yes
+test-xfail-POSIX2008/fcntl.h/linknamespace = yes
+test-xfail-POSIX2008/grp.h/linknamespace = yes
+test-xfail-POSIX2008/math.h/linknamespace = yes
+test-xfail-POSIX2008/mqueue.h/linknamespace = yes
+test-xfail-POSIX2008/net/if.h/linknamespace = yes
+test-xfail-POSIX2008/netdb.h/linknamespace = yes
+test-xfail-POSIX2008/pthread.h/linknamespace = yes
+test-xfail-POSIX2008/regex.h/linknamespace = yes
+test-xfail-POSIX2008/semaphore.h/linknamespace = yes
+test-xfail-POSIX2008/spawn.h/linknamespace = yes
+test-xfail-POSIX2008/sys/mman.h/linknamespace = yes
+test-xfail-POSIX2008/sys/statvfs.h/linknamespace = yes
+test-xfail-POSIX2008/tgmath.h/linknamespace = yes
+test-xfail-POSIX2008/time.h/linknamespace = yes
+test-xfail-POSIX2008/unistd.h/linknamespace = yes
+test-xfail-XOPEN2K8/aio.h/linknamespace = yes
+test-xfail-XOPEN2K8/complex.h/linknamespace = yes
+test-xfail-XOPEN2K8/dirent.h/linknamespace = yes
+test-xfail-XOPEN2K8/fcntl.h/linknamespace = yes
+test-xfail-XOPEN2K8/fmtmsg.h/linknamespace = yes
+test-xfail-XOPEN2K8/grp.h/linknamespace = yes
+test-xfail-XOPEN2K8/libgen.h/linknamespace = yes
+test-xfail-XOPEN2K8/math.h/linknamespace = yes
+test-xfail-XOPEN2K8/mqueue.h/linknamespace = yes
+test-xfail-XOPEN2K8/net/if.h/linknamespace = yes
+test-xfail-XOPEN2K8/netdb.h/linknamespace = yes
+test-xfail-XOPEN2K8/pthread.h/linknamespace = yes
+test-xfail-XOPEN2K8/pwd.h/linknamespace = yes
+test-xfail-XOPEN2K8/regex.h/linknamespace = yes
+test-xfail-XOPEN2K8/search.h/linknamespace = yes
+test-xfail-XOPEN2K8/semaphore.h/linknamespace = yes
+test-xfail-XOPEN2K8/spawn.h/linknamespace = yes
+test-xfail-XOPEN2K8/sys/mman.h/linknamespace = yes
+test-xfail-XOPEN2K8/sys/statvfs.h/linknamespace = yes
+test-xfail-XOPEN2K8/syslog.h/linknamespace = yes
+test-xfail-XOPEN2K8/tgmath.h/linknamespace = yes
+test-xfail-XOPEN2K8/time.h/linknamespace = yes
+test-xfail-XOPEN2K8/unistd.h/linknamespace = yes
diff --git a/conform/conformtest.pl b/conform/conformtest.pl
index c8c1d2a839..8d61016bbd 100644
--- a/conform/conformtest.pl
+++ b/conform/conformtest.pl
@@ -1,5 +1,6 @@
#! /usr/bin/perl
+use GlibcConform;
use Getopt::Long;
use POSIX;
@@ -32,17 +33,6 @@ if (@headers == ()) {
"complex.h", "assert.h", "arpa/inet.h", "aio.h");
}
-$CFLAGS{"ISO"} = "-ansi";
-$CFLAGS{"ISO99"} = "-std=c99";
-$CFLAGS{"ISO11"} = "-std=c1x -D_ISOC11_SOURCE";
-$CFLAGS{"POSIX"} = "-D_POSIX_C_SOURCE=199912 -ansi";
-$CFLAGS{"XPG3"} = "-ansi -D_XOPEN_SOURCE";
-$CFLAGS{"XPG4"} = "-ansi -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED";
-$CFLAGS{"UNIX98"} = "-ansi -D_XOPEN_SOURCE=500";
-$CFLAGS{"XOPEN2K"} = "-std=c99 -D_XOPEN_SOURCE=600";
-$CFLAGS{"XOPEN2K8"} = "-std=c99 -D_XOPEN_SOURCE=700";
-$CFLAGS{"POSIX2008"} = "-std=c99 -D_POSIX_C_SOURCE=200809L";
-
$CFLAGS_namespace = "$flags -fno-builtin $CFLAGS{$standard} -D_ISOMAC";
$CFLAGS = "$CFLAGS_namespace '-D__attribute__(x)='";
diff --git a/conform/linknamespace.pl b/conform/linknamespace.pl
new file mode 100644
index 0000000000..fd8c3dc81b
--- /dev/null
+++ b/conform/linknamespace.pl
@@ -0,0 +1,241 @@
+#! /usr/bin/perl
+
+# Check that use of symbols declared in a given header does not result
+# in any symbols being brought in that are not reserved with external
+# linkage for the given standard.
+
+# Copyright (C) 2014 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+use GlibcConform;
+use Getopt::Long;
+
+GetOptions ('header=s' => \$header, 'standard=s' => \$standard,
+ 'flags=s' => \$flags, 'cc=s' => \$CC, 'tmpdir=s' => \$tmpdir,
+ 'stdsyms=s' => \$stdsyms_file, 'libsyms=s' => \$libsyms_file,
+ 'readelf=s' => \$READELF);
+
+# Load the list of symbols that are OK.
+%stdsyms = ();
+open (STDSYMS, "<$stdsyms_file") || die ("open $stdsyms_file: $!\n");
+while (<STDSYMS>) {
+ chomp;
+ $stdsyms{$_} = 1;
+}
+close (STDSYMS) || die ("close $stdsyms_file: $!\n");
+
+# The following whitelisted symbols are also allowed for now.
+#
+# * Bug 15421: lgamma wrongly sets signgam for ISO C.
+#
+# * Bug 17576: stdin, stdout, stderr only reserved with external
+# linkage when stdio.h included (and possibly not then), not
+# generally.
+#
+# * False positive: matherr only used conditionally.
+#
+@whitelist = qw(signgam stdin stdout stderr matherr);
+foreach my $sym (@whitelist) {
+ $stdsyms{$sym} = 1;
+}
+
+# Return information about GLOBAL and WEAK symbols listed in readelf
+# -s output.
+sub list_syms {
+ my ($syms_file) = @_;
+ open (SYMS, "<$syms_file") || die ("open $syms_file: $!\n");
+ my ($file) = $syms_file;
+ my (@ret) = ();
+ while (<SYMS>) {
+ chomp;
+ if (/^File: (.*)/) {
+ $file = $1;
+ $file =~ s|^.*/||;
+ next;
+ }
+ s/^\s*//;
+ my (@fields) = split (/\s+/, $_);
+ if (@fields < 8) {
+ next;
+ }
+ my ($bind) = $fields[4];
+ my ($ndx) = $fields[6];
+ my ($sym) = $fields[7];
+ if ($bind ne "GLOBAL" && $bind ne "WEAK") {
+ next;
+ }
+ if ($sym !~ /^\w+$/) {
+ next;
+ }
+ push (@ret, [$file, $sym, $bind, $ndx ne "UND"]);
+ }
+ close (SYMS) || die ("close $syms_file: $!\n");
+ return @ret;
+}
+
+# Load information about GLOBAL and WEAK symbols defined or used in
+# the standard libraries.
+# Strong symbols (defined or undefined) from a given object.
+%strong_syms = ();
+# Strong undefined symbols from a given object.
+%strong_undef_syms = ();
+# Objects defining a given symbol (strongly or weakly).
+%sym_objs = ();
+@sym_data = list_syms ($libsyms_file);
+foreach my $sym (@sym_data) {
+ my ($file, $name, $bind, $defined) = @$sym;
+ if ($defined) {
+ if (!defined ($sym_objs{$name})) {
+ $sym_objs{$name} = [];
+ }
+ push (@{$sym_objs{$name}}, $file);
+ }
+ if ($bind eq "GLOBAL") {
+ if (!defined ($strong_syms{$file})) {
+ $strong_syms{$file} = [];
+ }
+ push (@{$strong_syms{$file}}, $name);
+ if (!$defined) {
+ if (!defined ($strong_undef_syms{$file})) {
+ $strong_undef_syms{$file} = [];
+ }
+ push (@{$strong_undef_syms{$file}}, $name);
+ }
+ }
+}
+
+# Determine what ELF-level symbols are brought in by use of C-level
+# symbols declared in the given header.
+#
+# The rules followed are heuristic and so may produce false positives
+# and false negatives.
+#
+# * Weak undefined symbols are ignored; however, if a code path that
+# references one (even just to check if its address is 0) is executed,
+# that may conflict with a definition of that symbol in the user's
+# program.
+#
+# * Strong undefined symbols are considered of signficance, but it is
+# possible that (a) any standard library definition is weak, so can be
+# overridden by the user's definition, and (b) the symbol is only used
+# conditionally and not if the program is limited to standard
+# functionality. (matherr is an example of such a false positive.)
+#
+# * For strong undefined symbols, all possible definitions are
+# considered, rather than being restricted to libraries that are
+# relevant to the given standard (e.g. not considering any libpthread
+# definitions of ISO C symbols).
+#
+# * If a symbol reference is only brought in by the user using a data
+# symbol rather than a function from the standard library, this will
+# not be detected.
+#
+# * If a symbol reference is only brought in by crt*.o or libgcc, this
+# will not be detected.
+#
+# * If a symbol reference is only brought in through __builtin_foo in
+# a standard macro being compiled to call foo, this will not be
+# detected.
+#
+# * Header inclusions should be compiled several times with different
+# options such as -O2, -D_FORTIFY_SOURCE and -D_FILE_OFFSET_BITS=64 to
+# find out what symbols are undefined from such a compilation; this is
+# not yet implemented.
+#
+# * This script finds symbols referenced through use of macros on the
+# basis that if a macro calls an internal function, that function must
+# also be declared in the header. However, the header might also
+# declare implementation-namespace functions that are not called by
+# any standard macro in the header, resulting in false positives for
+# any symbols brought in only through use of those
+# implementation-namespace functions.
+#
+# * Namespace issues can apply for dynamic linking as well as static
+# linking, when a call is from one shared library to another or uses a
+# PLT entry for a call within a shared library; such issues are only
+# detected by this script if the same namespace issue applies for
+# static linking.
+
+@c_syms = list_exported_functions ("$CC $flags", $standard, $header, $tmpdir);
+$cincfile = "$tmpdir/undef-$$.c";
+$cincfile_o = "$tmpdir/undef-$$.o";
+$cincfile_sym = "$tmpdir/undef-$$.sym";
+open (CINCFILE, ">$cincfile") || die ("open $cincfile: $!\n");
+print CINCFILE "#include <$header>\n";
+foreach my $sym (sort @c_syms) {
+ print CINCFILE "void *__glibc_test_$sym = (void *) &$sym;\n";
+}
+close CINCFILE || die ("close $cincfile: $!\n");
+system ("$CC $flags -D_ISOMAC $CFLAGS{$standard} -c $cincfile -o $cincfile_o")
+ && die ("compiling failed\n");
+system ("LC_ALL=C $READELF -W -s $cincfile_o > $cincfile_sym")
+ && die ("readelf failed\n");
+@elf_syms = list_syms ($cincfile_sym);
+unlink ($cincfile) || die ("unlink $cincfile: $!\n");
+unlink ($cincfile_o) || die ("unlink $cincfile_o: $!\n");
+unlink ($cincfile_sym) || die ("unlink $cincfile_sym: $!\n");
+
+%strong_seen = ();
+%files_seen = ();
+%all_undef = ();
+%current_undef = ();
+foreach my $sym (@elf_syms) {
+ my ($file, $name, $bind, $defined) = @$sym;
+ if ($bind eq "GLOBAL" && !$defined) {
+ $strong_seen{$name} = "[initial] $name";
+ $all_undef{$name} = "[initial] $name";
+ $current_undef{$name} = "[initial] $name";
+ }
+}
+
+while (%current_undef) {
+ %new_undef = ();
+ foreach my $sym (sort keys %current_undef) {
+ foreach my $file (@{$sym_objs{$sym}}) {
+ if (defined ($files_seen{$file})) {
+ next;
+ }
+ $files_seen{$file} = 1;
+ foreach my $ssym (@{$strong_syms{$file}}) {
+ if (!defined ($strong_seen{$ssym})) {
+ $strong_seen{$ssym} = "$current_undef{$sym} -> [$file] $ssym";
+ }
+ }
+ foreach my $usym (@{$strong_undef_syms{$file}}) {
+ if (!defined ($all_undef{$usym})) {
+ $all_undef{$usym} = "$current_undef{$sym} -> [$file] $usym";
+ $new_undef{$usym} = "$current_undef{$sym} -> [$file] $usym";
+ }
+ }
+ }
+ }
+ %current_undef = %new_undef;
+}
+
+$ret = 0;
+foreach my $sym (sort keys %strong_seen) {
+ if ($sym =~ /^_/) {
+ next;
+ }
+ if (defined ($stdsyms{$sym})) {
+ next;
+ }
+ print "$strong_seen{$sym}\n";
+ $ret = 1;
+}
+
+exit $ret;
diff --git a/conform/list-header-symbols.pl b/conform/list-header-symbols.pl
new file mode 100644
index 0000000000..c0c695cbb0
--- /dev/null
+++ b/conform/list-header-symbols.pl
@@ -0,0 +1,81 @@
+#! /usr/bin/perl
+
+# Print a list of symbols exported by some headers that would
+# otherwise be in the user's namespace.
+
+# Copyright (C) 2014 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+use GlibcConform;
+use Getopt::Long;
+
+GetOptions ('headers=s' => \$headers, 'standard=s' => \$standard,
+ 'flags=s' => \$flags, 'cc=s' => \$CC, 'tmpdir=s' => \$tmpdir);
+@headers = split (/\s+/, $headers);
+
+# Extra symbols possibly not found through -aux-info but still
+# reserved by the standard: either data symbols, or symbols where the
+# standard leaves unspecified whether the identifier is a macro or
+# defined with external linkage.
+$extra_syms{"ISO"} = ["errno", "setjmp", "va_end"];
+$extra_syms{"ISO99"} = ["errno", "math_errhandling", "setjmp", "va_end"];
+# stdatomic.h not yet covered by conformance tests; as per DR#419, all
+# the generic functions there or may not be defined with external
+# linkage (but are reserved in any case).
+$extra_syms{"ISO11"} = ["errno", "math_errhandling", "setjmp", "va_end"];
+# The following lists may not be exhaustive.
+$extra_syms{"POSIX"} = ["errno", "setjmp", "va_end", "environ", "sigsetjmp",
+ "optarg", "optind", "opterr", "optopt", "tzname"];
+$extra_syms{"XPG3"} = ["errno", "setjmp", "va_end", "environ", "signgam",
+ "loc1", "loc2", "locs", "sigsetjmp", "optarg",
+ "optind", "opterr", "optopt", "daylight", "timezone",
+ "tzname"];
+$extra_syms{"XPG4"} = ["errno", "setjmp", "va_end", "environ", "signgam",
+ "loc1", "loc2", "locs", "sigsetjmp", "optarg",
+ "optind", "opterr", "optopt", "daylight", "timezone",
+ "tzname"];
+$extra_syms{"UNIX98"} = ["errno", "setjmp", "va_end", "environ", "signgam",
+ "loc1", "loc2", "locs", "sigsetjmp", "optarg",
+ "optind", "opterr", "optopt", "daylight", "timezone",
+ "tzname"];
+$extra_syms{"XOPEN2K"} = ["errno", "setjmp", "va_end", "environ", "signgam",
+ "sigsetjmp", "optarg", "optind", "opterr", "optopt",
+ "daylight", "timezone", "tzname"];
+$extra_syms{"XOPEN2K8"} = ["errno", "setjmp", "va_end", "environ", "signgam",
+ "sigsetjmp", "optarg", "optind", "opterr", "optopt",
+ "daylight", "timezone", "tzname"];
+$extra_syms{"POSIX2008"} = ["errno", "setjmp", "va_end", "environ",
+ "sigsetjmp", "optarg", "optind", "opterr", "optopt",
+ "tzname"];
+
+%user_syms = ();
+
+foreach my $header (@headers) {
+ @syms = list_exported_functions ("$CC $flags", $standard, $header, $tmpdir);
+ foreach my $sym (@syms) {
+ if ($sym !~ /^_/) {
+ $user_syms{$sym} = 1;
+ }
+ }
+}
+foreach my $sym (@{$extra_syms{$standard}}) {
+ $user_syms{$sym} = 1;
+}
+
+foreach my $sym (sort keys %user_syms) {
+ print "$sym\n";
+}