Make the arm2gnu.pl converter handle apple specific details

This allows building the arm assembly for iOS.

This checks for the __APPLE__ preprocessor built-in define to
determine whether this extra handling should be enabled.

Signed-off-by: Timothy B. Terriberry <tterribe@xiph.org>
This commit is contained in:
Martin Storsjo 2014-03-19 21:36:39 +02:00 committed by Timothy B. Terriberry
parent ac0e294b52
commit 76e831d917
3 changed files with 26 additions and 7 deletions

View file

@ -225,7 +225,7 @@ $(CELT_SOURCES_ARM_ASM:%.s=%-gnu.S): $(top_srcdir)/celt/arm/arm2gnu.pl
# convert ARM asm to GNU as format # convert ARM asm to GNU as format
%-gnu.S: $(top_srcdir)/%.s %-gnu.S: $(top_srcdir)/%.s
$(top_srcdir)/celt/arm/arm2gnu.pl < $< > $@ $(top_srcdir)/celt/arm/arm2gnu.pl @ARM2GNU_PARAMS@ < $< > $@
# For autoconf-modified sources (e.g., armopts.s) # For autoconf-modified sources (e.g., armopts.s)
%-gnu.S: %.s %-gnu.S: %.s
$(top_srcdir)/celt/arm/arm2gnu.pl < $< > $@ $(top_srcdir)/celt/arm/arm2gnu.pl < $< > $@

View file

@ -26,6 +26,8 @@
my $bigend; # little/big endian my $bigend; # little/big endian
my $nxstack; my $nxstack;
my $apple = 0;
my $symprefix = "";
$nxstack = 0; $nxstack = 0;
@ -39,6 +41,11 @@ while ($ARGV[0] =~ /^-/) {
$nflag++; $nflag++;
next; next;
} }
if (/^--apple/) {
$apple = 1;
$symprefix = "_";
next;
}
die "I don't recognize this switch: $_\\n"; die "I don't recognize this switch: $_\\n";
} }
$printit++ unless $nflag; $printit++ unless $nflag;
@ -79,7 +86,7 @@ while (<>) {
s/\bINCLUDE[ \t]*([^ \t\n]+)/.include \"$1\"/; s/\bINCLUDE[ \t]*([^ \t\n]+)/.include \"$1\"/;
s/\bGET[ \t]*([^ \t\n]+)/.include \"${ my $x=$1; $x =~ s|\.s|-gnu.S|; \$x }\"/; s/\bGET[ \t]*([^ \t\n]+)/.include \"${ my $x=$1; $x =~ s|\.s|-gnu.S|; \$x }\"/;
s/\bIMPORT\b/.extern/; s/\bIMPORT\b/.extern/;
s/\bEXPORT\b/.global/; s/\bEXPORT\b\s*/.global $symprefix/;
s/^(\s+)\[/$1IF/; s/^(\s+)\[/$1IF/;
s/^(\s+)\|/$1ELSE/; s/^(\s+)\|/$1ELSE/;
s/^(\s+)\]/$1ENDIF/; s/^(\s+)\]/$1ENDIF/;
@ -135,7 +142,7 @@ while (<>) {
# won't match the original source file (we could use the .line # won't match the original source file (we could use the .line
# directive, which is documented to be obsolete, but then gdb will # directive, which is documented to be obsolete, but then gdb will
# show the wrong line in the translated source file). # show the wrong line in the translated source file).
s/$/; .arch armv7-a\n .fpu neon\n .object_arch armv4t/; s/$/; .arch armv7-a\n .fpu neon\n .object_arch armv4t/ unless ($apple);
} }
} }
@ -157,9 +164,13 @@ while (<>) {
$prefix = ""; $prefix = "";
if ($proc) if ($proc)
{ {
$prefix = $prefix.sprintf("\t.type\t%s, %%function; ",$proc); $prefix = $prefix.sprintf("\t.type\t%s, %%function; ",$proc) unless ($apple);
# Make sure we $prefix isn't empty here (for the $apple case).
# We handle mangling the label here, make sure it doesn't match
# the label handling below (if $prefix would be empty).
$prefix = "; ";
push(@proc_stack, $proc); push(@proc_stack, $proc);
s/^[A-Za-z_\.]\w+/$&:/; s/^[A-Za-z_\.]\w+/$symprefix$&:/;
} }
$prefix = $prefix."\t.thumb_func; " if ($thumb); $prefix = $prefix."\t.thumb_func; " if ($thumb);
s/\bPROC\b/@ $&/; s/\bPROC\b/@ $&/;
@ -172,7 +183,7 @@ while (<>) {
my $proc; my $proc;
s/\bENDP\b/@ $&/; s/\bENDP\b/@ $&/;
$proc = pop(@proc_stack); $proc = pop(@proc_stack);
$_ = "\t.size $proc, .-$proc".$_ if ($proc); $_ = "\t.size $proc, .-$proc".$_ if ($proc && !$apple);
} }
s/\bSUBT\b/@ $&/; s/\bSUBT\b/@ $&/;
s/\bDATA\b/@ $&/; # DATA directive is deprecated -- Asm guide, p.7-25 s/\bDATA\b/@ $&/; # DATA directive is deprecated -- Asm guide, p.7-25
@ -337,6 +348,6 @@ while (<>) {
} }
#If we had a code section, mark that this object doesn't need an executable #If we had a code section, mark that this object doesn't need an executable
# stack. # stack.
if ($nxstack) { if ($nxstack && !$apple) {
printf (" .section\t.note.GNU-stack,\"\",\%\%progbits\n"); printf (" .section\t.note.GNU-stack,\"\",\%\%progbits\n");
} }

View file

@ -317,6 +317,14 @@ AS_IF([test x"${enable_asm}" = x"yes"],[
[rtcd_support=ARM"$rtcd_support"], [rtcd_support=ARM"$rtcd_support"],
[rtcd_support="no"] [rtcd_support="no"]
) )
AC_MSG_CHECKING([for apple style tools])
AC_PREPROC_IFELSE([AC_LANG_PROGRAM([
#ifndef __APPLE__
#error 1
#endif],[])],
[AC_MSG_RESULT([yes]); ARM2GNU_PARAMS="--apple"],
[AC_MSG_RESULT([no]); ARM2GNU_PARAMS=""])
AC_SUBST(ARM2GNU_PARAMS)
], ],
[ [
AC_MSG_WARN( AC_MSG_WARN(