This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Do not export no text symbols starting with S_.
authorJarkko Hietaniemi <jhi@iki.fi>
Fri, 29 Jan 2016 23:24:51 +0000 (18:24 -0500)
committerJarkko Hietaniemi <jhi@iki.fi>
Sat, 30 Jan 2016 00:30:29 +0000 (19:30 -0500)
t/porting/libperl.t

index ac9db4b..00f2606 100644 (file)
@@ -205,8 +205,8 @@ sub nm_parse_gnu {
                 $symbols->{data}{const}{$1}{$symbols->{o}}++;
             } elsif (/^r .+$/) {
                 # Skip local const (read only).
-            } elsif (/^[Tti] (\w+)(\..+)?$/) {
-                $symbols->{text}{$1}{$symbols->{o}}++;
+            } elsif (/^([Tti]) (\w+)(\..+)?$/) {
+                $symbols->{text}{$2}{$symbols->{o}}{$1}++;
             } elsif (/^C (\w+)$/) {
                 $symbols->{data}{common}{$1}{$symbols->{o}}++;
             } elsif (/^[BbSs] (\w+)(\.\d+)?$/) {
@@ -257,8 +257,9 @@ sub nm_parse_darwin {
                 # Ignore the cstring unnamed strings.
                 return if $symbol =~ /^L\.str\d+$/;
                 $symbols->{data}{const}{$symbol}{$symbols->{o}}++;
-            } elsif (/^\(__TEXT,__text\) (?:non-)?external _(\w+)$/) {
-                $symbols->{text}{$1}{$symbols->{o}}++;
+            } elsif (/^\(__TEXT,__text\) ((?:non-)?external) _(\w+)$/) {
+                my ($exp, $sym) = ($1, $2);
+                $symbols->{text}{$sym}{$symbols->{o}}{$exp =~ /^non/ ? 't' : 'T'}++;
             } elsif (/^\(__DATA,__\w*?(const|data|bss|common)\w*\) (?:non-)?external _?(\w+)(\.\w+)?$/) {
                 my ($dtype, $symbol, $suffix) = ($1, $2, $3);
                 # Ignore function-local constants like
@@ -531,6 +532,18 @@ for my $symbol (sort keys %unexpected) {
     }
 }
 
+# Check that any text symbols named S_ are not exported.
+my $export_S_prefix = 0;
+for my $t (sort grep { /^S_/ } keys %{$symbols{text}}) {
+    for my $o (sort keys %{$symbols{text}{$t}}) {
+        if (exists $symbols{text}{$t}{$o}{T}) {
+            fail($t, "$t exported from $o");
+            $export_S_prefix++;
+        }
+    }
+}
+is($export_S_prefix, 0, "no S_ exports");
+
 if (defined $nm_err_tmp) {
     if (open(my $nm_err_fh, $nm_err_tmp)) {
         my $error;