A branch instruction in thumb mode might either be narrow or
wide, depending on the offset to the branch location.

armasm seems to have a bug when calculating the difference
between two symbols, where there's such a branch inbetween.
If the branch immediately seems to require a wide instruction,
the symbol difference is calculated properly, but if the
branch is made wide as a consequence from another branch
being made wide, the symbol difference isn't calculated
properly.
---
 gas-preprocessor.pl | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gas-preprocessor.pl b/gas-preprocessor.pl
index 42e1c7f..16e91ab 100755
--- a/gas-preprocessor.pl
+++ b/gas-preprocessor.pl
@@ -837,15 +837,18 @@ sub handle_serialized_line {
 
 
         # Check branch instructions
-        if ($line =~ /(?:^|\n)\s*((\w+\s*:\s*)?bl?x?(..)?(?:\.w)?)\s+(\w+)/) {
+        if ($line =~ /(?:^|\n)\s*(\w+\s*:\s*)?(bl?x?(..)?(\.w)?)\s+(\w+)/) {
+            my $instr = $2;
             my $cond = $3;
-            my $target = $4;
+            my $width = $4;
+            my $target = $5;
             # Don't interpret e.g. bic as b<cc> with ic as conditional code
             if ($cond !~ /|$arm_cond_codes/) {
                 # Not actually a branch
             } elsif ($target =~ /(\d+)([bf])/) {
                 # The target is a local label
                 $line = handle_local_label($line, $1, $2);
+                $line =~ s/\b$instr\b/$&.w/ if $width eq "";
             } elsif (!is_register($target)) {
                 $call_targets{$target}++;
             }
-- 
1.8.5.2 (Apple Git-48)

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to