summaryrefslogtreecommitdiff
path: root/gas/write.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2010-10-25 03:03:18 +0000
committerAlan Modra <amodra@bigpond.net.au>2010-10-25 03:03:18 +0000
commitd9df8f96690f7b1df47d9fa27870645c8b76696c (patch)
tree7a667221d441d120da91a855ecc8983bfd9f5dd6 /gas/write.c
parentbac04512968bec69da68291f22b04d0d04cc31b9 (diff)
downloadbinutils-redhat-d9df8f96690f7b1df47d9fa27870645c8b76696c.tar.gz
PR gas/12049
* write.c (relax_frag): Don't allow forward branches to temporarily becomde backward branches.
Diffstat (limited to 'gas/write.c')
-rw-r--r--gas/write.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gas/write.c b/gas/write.c
index 080216a240..4b6592f7aa 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -2163,6 +2163,13 @@ relax_frag (segT segment, fragS *fragP, long stretch)
if (stretch < 0
|| sym_frag->region == fragP->region)
target += stretch;
+ /* If we get here we know we have a forward branch. This
+ relax pass may have stretched previous instructions so
+ far that omitting STRETCH would make the branch
+ negative. Don't allow this in case the negative reach is
+ large enough to require a larger branch instruction. */
+ else if (target < address)
+ target = fragP->fr_next->fr_address + stretch;
}
}