aboutsummaryrefslogtreecommitdiff
path: root/gas/sb.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2022-08-11 09:51:03 +0930
committerAlan Modra <amodra@gmail.com>2022-08-11 12:03:05 +0930
commit4d74aab7aa562fe79d4669cdad0c32610531cbc0 (patch)
tree5dc95ed8fd4fc55c369c21cc9942b210b3a47350 /gas/sb.c
parent5291ecf9720c97e2a82e8766a642e33529f890d1 (diff)
downloadbinutils-4d74aab7aa562fe79d4669cdad0c32610531cbc0.zip
binutils-4d74aab7aa562fe79d4669cdad0c32610531cbc0.tar.gz
binutils-4d74aab7aa562fe79d4669cdad0c32610531cbc0.tar.bz2
PR29466, APP/NO_APP with .linefile
Commit 53f2b36a54b9 exposed a bug in sb_scrub_and_add_sb that could result in losing input. If scrubbing results in expansion past the holding capacity of do_scrub_chars output buffer, then do_scrub_chars stashes the extra input for the next call. That call never came because sb_scrub_and_add_sb wrongly decided it was done. Fix that by allowing sb_scrub_and_add_sb to see whether there is pending input. Also allow a little extra space so that in most cases we won't need to resize the output buffer. sb_scrub_and_add_sb also limited output to the size of the input, rather than the actual output buffer size. Fixing that resulted in a fail of gas/testsuite/macros/dot with an extra warning: "end of file not at end of a line; newline inserted". OK, so the macro in dot.s really does finish without end-of-line. Apparently the macro expansion code relied on do_scrub_chars returning early. So fix that too by adding a newline if needed in macro_expand_body. PR 29466 * app.c (do_scrub_pending): New function. * as.h: Declare it. * input-scrub.c (input_scrub_include_sb): Add extra space for two .linefile directives. * sb.c (sb_scrub_and_add_sb): Take into account pending input. Allow output to max. * macro.c (macro_expand_body): Add terminating newline. * testsuite/config/default.exp (SIZE, SIZEFLAGS): Define. * testsuite/gas/macros/app5.d, * testsuite/gas/macros/app5.s: New test. * testsuite/gas/macros/macros.exp: Run it.
Diffstat (limited to 'gas/sb.c')
-rw-r--r--gas/sb.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/gas/sb.c b/gas/sb.c
index c44016a..e83a5f5 100644
--- a/gas/sb.c
+++ b/gas/sb.c
@@ -119,11 +119,12 @@ sb_scrub_and_add_sb (sb *ptr, sb *s)
So we loop until the input S is consumed. */
while (1)
{
- size_t copy = s->len - (scrub_position - s->ptr);
+ size_t copy = s->len - (scrub_position - s->ptr) + do_scrub_pending ();
if (copy == 0)
break;
sb_check (ptr, copy);
- ptr->len += do_scrub_chars (scrub_from_sb, ptr->ptr + ptr->len, copy);
+ ptr->len += do_scrub_chars (scrub_from_sb, ptr->ptr + ptr->len,
+ ptr->max - ptr->len);
}
sb_to_scrub = 0;