stdin/stdout on Windows; so add a new system function called
sys_setbinarymode which does it instead. Then find lots more binary mode
flags which need setting.
The follows( ) function uses pa->os_lign when determining
whether an output section pa immediately follows another
section pb.
However, emits( ) was not using this alignment information
when laying out and padding the output sections. This seems
to be a bug.
I suspect that mach/arm/cv/cv.c might need a similar fix.
This should fix at least some instances of the "undefined
reference to `LLnc_recover'" error that happens in some
builds (https://github.com/davidgiven/ack/issues/218).
The bug was that genname( ) used a static `namebuf' buffer
and did not properly check for overflow when writing into
it. The result was that the `non_corr' variable was
sometimes overwritten with a non-zero value when it should
be zero, causing bogus results later.
This proposed patch makes genname( ) dynamically allocate
and resize a buffer for holding a target file name.
I also take this chance to fix a typo in correct_prefix().
The strength reduction (SR) phase mishandled the END pseudo when SR
found at least 2 different expressions in the same loop, and SR made a
new header for the loop.
Since 1987 (commit 159b84e), SR appended the new header to the end of
the procedure. Later, SR fixed the header by adding a BRA branch to
the loop's entry, and moving the END pseudo from the previous basic
block to the header. If SR found multiple expressions, it called
fix_header() multiple times, and tried to move the END again. The
extra move failed assert(INSTR(e) == ps_end), or moved another line
after the END, so opt2 (the peephole optimizer) would crash.
Fix by removing fix_header() and moving the code to make_header(), so
SR adds the BRA and moves the END when it makes the header, and does
so only once for each header.
Adjust init_code(), which inserts code into a header. Stop checking
for an empty header, because make_header() now adds BRA. After
inserting code before BRA, don't move LP_INSTR, because later
insertions should go before BRA, not after END.