diff options
author | Maciej W. Rozycki <macro@imgtec.com> | 2016-06-29 01:38:50 +0100 |
---|---|---|
committer | Maciej W. Rozycki <macro@imgtec.com> | 2016-06-30 15:11:23 +0100 |
commit | 93a24ba79b59ec343611c16cd0024a116a705274 (patch) | |
tree | b01b653cdbe407338f62f9284bd08cf5cabc95f8 /gas | |
parent | 038d48680941f014349256aeb7bab14b3f01d58e (diff) | |
download | binutils-gdb-93a24ba79b59ec343611c16cd0024a116a705274.tar.gz |
PR gas/20312: Do not pad sections to alignment on failed assembly
Correct a regression from commit 85024cd8bcb9 ("Run write_object_file
after errors") causing unsuccessful assembly, which may be due to any
reason, such as supplying a valid source like this:
.text
.byte 0
.err
to terminate with an assertion failure like:
test.s: Assembler messages:
test.s:3: Error: .err encountered
../as-new: BFD (GNU Binutils) 2.24.51.20140628 internal error, aborting at .../gas/write.c line 608 in size_seg
../as-new: Please report this bug.
on targets whose default text section alignment is above 0, typically
RISC machines.
This is due to an attempt to set last text section's frag alignment to
0, requested from `subsegs_finish_section' where `frag_align_code
(alignment, 0)' is called with `alignment' set to 0 rather than the
section alignment if `had_errors' has returned true. The call to
`subsegs_finish_section' is made from `subsegs_finish' from
`write_object_file' at unsuccessful completion, which previously wasn't
made.
Always set last section's frag alignment from the section alignment
then, forcing no section padding instead if completing unsuccessfully,
so that in that case alignment padding is still suppressed from any
listing generated, fixing assertion failures for these targets:
alpha-linuxecoff -FAIL: all pr20312
arm-aout -FAIL: all pr20312
mips-freebsd -FAIL: all pr20312
mips-img-linux -FAIL: all pr20312
mips-linux -FAIL: all pr20312
mips-mti-linux -FAIL: all pr20312
mips-netbsd -FAIL: all pr20312
mips-sgi-irix5 -FAIL: all pr20312
mips-sgi-irix6 -FAIL: all pr20312
mips-vxworks -FAIL: all pr20312
mips64-freebsd -FAIL: all pr20312
mips64-img-linux -FAIL: all pr20312
mips64-linux -FAIL: all pr20312
mips64-mti-linux -FAIL: all pr20312
mips64-openbsd -FAIL: all pr20312
mips64el-freebsd -FAIL: all pr20312
mips64el-img-linux -FAIL: all pr20312
mips64el-linux -FAIL: all pr20312
mips64el-mti-linux -FAIL: all pr20312
mips64el-openbsd -FAIL: all pr20312
mipsel-freebsd -FAIL: all pr20312
mipsel-img-linux -FAIL: all pr20312
mipsel-linux -FAIL: all pr20312
mipsel-mti-linux -FAIL: all pr20312
mipsel-netbsd -FAIL: all pr20312
mipsel-vxworks -FAIL: all pr20312
mipsisa32-linux -FAIL: all pr20312
mipsisa32el-linux -FAIL: all pr20312
mipsisa64-linux -FAIL: all pr20312
mipsisa64el-linux -FAIL: all pr20312
sh-pe -FAIL: all pr20312
sparc-aout -FAIL: all pr20312
gas/
PR gas/20312
* write.c (subsegs_finish_section): Force no section padding to
alignment on failed assembly, always set last frag's alignment
from section.
* testsuite/gas/all/pr20312.l: New list test.
* testsuite/gas/all/pr20312.s: New test source.
* testsuite/gas/all/gas.exp: Run the new test
Diffstat (limited to 'gas')
-rw-r--r-- | gas/ChangeLog | 10 | ||||
-rw-r--r-- | gas/testsuite/gas/all/gas.exp | 2 | ||||
-rw-r--r-- | gas/testsuite/gas/all/pr20312.l | 2 | ||||
-rw-r--r-- | gas/testsuite/gas/all/pr20312.s | 3 | ||||
-rw-r--r-- | gas/write.c | 32 |
5 files changed, 33 insertions, 16 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 04a84fab418..300d5ca37b7 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,13 @@ +2016-06-30 Maciej W. Rozycki <macro@imgtec.com> + + PR gas/20312 + * write.c (subsegs_finish_section): Force no section padding to + alignment on failed assembly, always set last frag's alignment + from section. + * testsuite/gas/all/pr20312.l: New list test. + * testsuite/gas/all/pr20312.s: New test source. + * testsuite/gas/all/gas.exp: Run the new test + 2016-06-30 Matthew Wahab <matthew.wahab@arm.com> * testsuite/gas/arm/armv8_2+rdma.d: New. diff --git a/gas/testsuite/gas/all/gas.exp b/gas/testsuite/gas/all/gas.exp index d5d2445ab63..bfb13ed22cd 100644 --- a/gas/testsuite/gas/all/gas.exp +++ b/gas/testsuite/gas/all/gas.exp @@ -448,6 +448,8 @@ if [is_elf_format] { run_dump_test quoted-sym-names +run_list_test pr20312 + load_lib gas-dg.exp dg-init dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/$subdir/warn-*.s]] "" "" diff --git a/gas/testsuite/gas/all/pr20312.l b/gas/testsuite/gas/all/pr20312.l new file mode 100644 index 00000000000..47328e7b9a9 --- /dev/null +++ b/gas/testsuite/gas/all/pr20312.l @@ -0,0 +1,2 @@ +.*: Assembler messages: +.*:3: Error: \.err encountered diff --git a/gas/testsuite/gas/all/pr20312.s b/gas/testsuite/gas/all/pr20312.s new file mode 100644 index 00000000000..d88c6ba627d --- /dev/null +++ b/gas/testsuite/gas/all/pr20312.s @@ -0,0 +1,3 @@ + .text + .byte 0 + .err diff --git a/gas/write.c b/gas/write.c index 8873e5519f4..c502b08aed6 100644 --- a/gas/write.c +++ b/gas/write.c @@ -1732,31 +1732,31 @@ subsegs_finish_section (asection *s) frchainP != NULL; frchainP = frchainP->frch_next) { - int alignment = 0; + int alignment; subseg_set (s, frchainP->frch_subseg); /* This now gets called even if we had errors. In that case, any alignment is meaningless, and, moreover, will look weird if we are generating a listing. */ - if (!had_errors ()) - { - alignment = SUB_SEGMENT_ALIGN (now_seg, frchainP); - if ((bfd_get_section_flags (now_seg->owner, now_seg) & SEC_MERGE) - && now_seg->entsize) - { - unsigned int entsize = now_seg->entsize; - int entalign = 0; + if (had_errors ()) + do_not_pad_sections_to_alignment = 1; - while ((entsize & 1) == 0) - { - ++entalign; - entsize >>= 1; - } + alignment = SUB_SEGMENT_ALIGN (now_seg, frchainP); + if ((bfd_get_section_flags (now_seg->owner, now_seg) & SEC_MERGE) + && now_seg->entsize) + { + unsigned int entsize = now_seg->entsize; + int entalign = 0; - if (entalign > alignment) - alignment = entalign; + while ((entsize & 1) == 0) + { + ++entalign; + entsize >>= 1; } + + if (entalign > alignment) + alignment = entalign; } if (subseg_text_p (now_seg)) |