$T_CONST_LBL = '^\LC\d+:'; # regexp for what such a lbl looks like
$T_POST_LBL = ':';
- $T_MOVE_DIRVS = '^(\s*(\.align \d+|\.text|\.data|\.const_data|\.cstring|\.non_lazy_symbol_pointer|\.const|\.static_const|\.literal4|\.literal8|\.static_data|\.globl \S+|\.section .*|\.lcomm.*)\n)';
+ $T_MOVE_DIRVS = '^(\s*(\.(p2)?align\s.*|\.text|\.data|\.const_data|\.cstring|\.non_lazy_symbol_pointer|\.const|\.static_const|\.literal4|\.literal8|\.static_data|\.globl \S+|\.section .*|\.lcomm.*)\n)';
$T_COPY_DIRVS = '\.(globl|lcomm)';
$T_DOT_WORD = '\.(long|short|byte|fill|space)';
$T_X86_PRE_LLBL = 'L';
$T_X86_BADJMP = '^\tjmp [^L\*]';
- $T_MOVE_DIRVS = '^(\s*(\.align \d+|\.text|\.data|\.const_data|\.cstring|\.non_lazy_symbol_pointer|\.const|\.static_const|\.literal4|\.literal8|\.static_data|\.globl \S+|\.section .*|\.lcomm.*)\n)';
+ $T_MOVE_DIRVS = '^(\s*(\.(p2)?align\s.*|\.text|\.data|\.const_data|\.cstring|\.non_lazy_symbol_pointer|\.const|\.static_const|\.literal4|\.literal8|\.static_data|\.globl \S+|\.section .*|\.lcomm.*)\n)';
$T_COPY_DIRVS = '\.(globl|lcomm)';
$T_DOT_WORD = '\.(long|short|byte|fill|space)';
$T_HDR_vector = "\t\.text\n\t\.align 2\n";
#--------------------------------------------------------#
+ } elsif ( $TargetPlatform =~ /^x86_64-apple-darwin.*/ ) {
+ # Apple PowerPC Darwin/MacOS X.
+ $T_STABBY = 0; # 1 iff .stab things (usually if a.out format)
+ $T_US = '_'; # _ if symbols have an underscore on the front
+ $T_PRE_APP = 'DOESNT APPLY'; # regexp that says what comes before APP/NO_APP
+ $T_CONST_LBL = '^\LC\d+:'; # regexp for what such a lbl looks like
+ $T_POST_LBL = ':';
+
+ $T_MOVE_DIRVS = '^(\s*(\.align \d+|\.text|\.data|\.const_data|\.cstring|\.non_lazy_symbol_pointer|\.const|\.static_const|\.literal4|\.literal8|\.static_data|\.globl \S+|\.section .*|\.lcomm.*)\n)';
+ $T_COPY_DIRVS = '\.(globl|lcomm)';
+
+ $T_DOT_WORD = '\.(quad|long|short|byte|fill|space)';
+ $T_DOT_GLOBAL = '\.globl';
+ $T_HDR_toc = "\.toc\n";
+ $T_HDR_literal16= "\t\.literal8\n\t\.align 4\n";
+ $T_HDR_literal = "\t\.const\n\t\.align 4\n";
+ $T_HDR_misc = "\t\.text\n\t\.align 2\n";
+ $T_HDR_data = "\t\.data\n\t\.align 2\n";
+ $T_HDR_rodata = "\t\.const\n\t\.align 2\n";
+ $T_HDR_relrodata= "\t\.const_data\n\t\.align 2\n";
+ $T_HDR_closure = "\t\.data\n\t\.align 2\n";
+ $T_HDR_info = "\t\.text\n\t\.align 2\n";
+ $T_HDR_entry = "\t\.text\n\t\.align 2\n";
+ $T_HDR_vector = "\t\.text\n\t\.align 2\n";
+
+ #--------------------------------------------------------#
} elsif ( $TargetPlatform =~ /^powerpc-.*-linux/ ) {
# PowerPC Linux
$T_STABBY = 0; # 1 iff .stab things (usually if a.out format)
$T_CONST_LBL = '^\.LLC(\d+):$'; # regexp for what such a lbl looks like
$T_POST_LBL = ':';
- $T_MOVE_DIRVS = '^((\s+\.align\s+\d+|\s+\.proc\s+\d+|\s+\.global\s+\S+|\.text|\.data|\.seg|\.stab.*|\s+?\.section.*|\s+\.type.*|\s+\.size.*)\n)';
- $T_COPY_DIRVS = '\.(global|globl|proc|stab)';
+ $T_MOVE_DIRVS = '^((\s+\.align\s+\d+|\s+\.proc\s+\d+|\s+\.global\s+\S+|\s+\.local\s+\S+|\.text|\.data|\.seg|\.stab.*|\s+?\.section.*|\s+\.type.*|\s+\.size.*)\n)';
+ $T_COPY_DIRVS = '\.(global|local|globl|proc|stab)';
$T_DOT_WORD = '\.(long|word|nword|xword|byte|half|short|skip|uahalf|uaword)';
$T_DOT_GLOBAL = '^\t\.global';
$chkcat[$i] = 'data';
$chksymb[$i] = '';
- } elsif ( /^${T_US}([A-Za-z0-9_]+)_hpc?${T_POST_LBL}$/o ) {
+ } elsif ( /^${T_US}([A-Za-z0-9_]+)_hpc${T_POST_LBL}$/o ) {
# hpc shares tick boxes across modules
$chk[++$i] = $_;
$chkcat[$i] = 'data';
}
}
$numchks = $#chk + 1;
+ $chk[$numchks] = ''; # We might push .note.GNU-stack into this
+ $chkcat[$numchks] = 'verbatim'; # If we do, write it straight back out
# open CHUNKS, ">/tmp/chunks1" or die "Cannot open /tmp/chunks1: $!\n";
# for (my $i = 0; $i < @chk; ++$i) { print CHUNKS "======= $i =======\n", $chk[$i] }
$p =~ s/^\tstw r0,\d+\(r1\)\n//g;
$p =~ s/^\tstwu r1,-\d+\(r1\)\n//;
$p =~ s/^\tstw r\d+,-\d+\(r1\)\n//g;
- $p =~ s/^\tbcl 20,31,L\d+\$pb\n//;
- $p =~ s/^L\d+\$pb:\n//;
+ $p =~ s/^\tbcl 20,31,\"?L\d+\$pb\"?\n//;
+ $p =~ s/^\"?L\d+\$pb\"?:\n//;
$p =~ s/^\tmflr r31\n//;
# This is bad: GCC 3 seems to zero-fill some local variables in the prologue
}
}
- elsif ( $i < ($numchks - 1)
- && ( $to_move =~ /${T_COPY_DIRVS}/
- || ($TargetPlatform =~ /^hppa/ && $to_move =~ /align/ && $chkcat[$i+1] eq 'literal') )) {
- $chk[$i + 1] = $to_move . $chk[$i + 1];
- # otherwise they're tossed
- }
+ elsif ( ( $i < ($numchks - 1)
+ && ( $to_move =~ /${T_COPY_DIRVS}/
+ || ( $TargetPlatform =~ /^hppa/
+ && $to_move =~ /align/
+ && $chkcat[$i+1] eq 'literal')
+ )
+ )
+ || ($to_move =~ /^[ \t]*\.section[ \t]+\.note\.GNU-stack,/)
+ ) {
+ $chk[$i + 1] = $to_move . $chk[$i + 1];
+ # otherwise they're tossed
+ }
$c =~ s/${T_MOVE_DIRVS}FUNNY#END#THING/FUNNY#END#THING/o;
}
}
}
- for ($i = $FIRST_MANGLABLE; $i < $numchks; $i++) {
+ # $numchks + 1 as we have the extra one for .note.GNU-stack
+ for ($i = $FIRST_MANGLABLE; $i < $numchks + 1; $i++) {
# print STDERR "$i: cat $chkcat[$i], symb $chksymb[$i]\n";
next if $chkcat[$i] eq 'DONE ALREADY';
&print_doctored($chk[$i], 0);
}
+ } elsif ( $chkcat[$i] eq 'verbatim' ) {
+ print OUTASM $chk[$i];
+
} elsif ( $chkcat[$i] eq 'toss' ) {
print STDERR "*** NB: TOSSING code for $chksymb[$i] !!! ***\n";
}
}
+ if ( $TargetPlatform =~ /x86_64-apple-darwin/ ) {
+ # Tack a label to the front of the info table, too.
+ # For now, this just serves to work around a crash in Apple's new
+ # 64-bit linker (it seems to assume that there is no data before the
+ # first label in a section).
+
+ # The plan for the future is to do this on all Darwin platforms, and
+ # to add a reference to this label after the entry code, just as the
+ # NCG does, so we can enable dead-code-stripping in the linker without
+ # losing our info tables. (Hence the name _dsp, for dead-strip preventer)
+
+ $before .= "\n${infoname}_dsp:\n";
+ }
+
$tbl = $before
. (($TargetPlatform !~ /^hppa/) ? '' : join("\n", @imports) . "\n")
. join("\n", @words) . "\n"