This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: gas segfault in files with groups and some error
On Thu, Aug 4, 2011 at 12:48 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Thu, Aug 4, 2011 at 3:24 AM, Alan Modra <amodra@gmail.com> wrote:
>> This avoids an assertion closely followed by a segfault when an input
>> file containing section groups has some other error as in
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49972
>>
>> /tmp/ccMQV8TI.s:105: Error: invalid operands (.text.unlikely and .text.startup sections) for `-'
>> /home/amodra/gnu/powerpc-linux/bin/as: BFD (GNU Binutils) 2.21.52.20110621
>> assertion fail /home/amodra/src/binutils-current/bfd/elf.c:2826
>> g++: internal compiler error: Segmentation fault (program as)
>>
>> ? ? ? ?* write.c (write_object_file): Call set_symtab even if we had
>> ? ? ? ?errors.
>>
>> Index: gas/write.c
>> ===================================================================
>> RCS file: /cvs/src/src/gas/write.c,v
>> retrieving revision 1.142
>> diff -u -p -r1.142 write.c
>> --- gas/write.c 1 Aug 2011 09:05:40 -0000 ? ? ? 1.142
>> +++ gas/write.c 4 Aug 2011 10:16:11 -0000
>> @@ -2073,13 +2073,14 @@ write_object_file (void)
>> ? obj_adjust_symtab ();
>> ?#endif
>>
>> + ?set_symtab ();
>> +
>> ? /* Stop if there is an error. ?*/
>> ? if (had_errors ())
>> ? ? return;
>>
>> ? /* Now that all the sizes are known, and contents correct, we can
>> ? ? ?start writing to the file. ?*/
>> - ?set_symtab ();
>>
>> ? /* If *_frob_file changes the symbol value at this point, it is
>> ? ? ?responsible for moving the changed value into symp->bsym->value
>>
>
> This caused:
>
> http://www.sourceware.org/bugzilla/show_bug.cgi?id=13056
>
> I think it is a bad idea to make such a change without a testcase.
>
I checked in this testcase.
--
H.J.
---
2011-08-04 H.J. Lu <hongjiu.lu@intel.com>
* gas/elf/bad-group.d: New.
* gas/elf/bad-group.err: Likewise.
* gas/elf/bad-group.s: Likewise.
* gas/elf/elf.exp: Run bad-group.
diff --git a/gas/testsuite/gas/elf/bad-group.d
b/gas/testsuite/gas/elf/bad-group.d
new file mode 100644
index 0000000..ba3de04
--- /dev/null
+++ b/gas/testsuite/gas/elf/bad-group.d
@@ -0,0 +1,2 @@
+#name: Check bad group
+#error-output: bad-group.err
diff --git a/gas/testsuite/gas/elf/bad-group.err
b/gas/testsuite/gas/elf/bad-group.err
new file mode 100644
index 0000000..4b650d4
--- /dev/null
+++ b/gas/testsuite/gas/elf/bad-group.err
@@ -0,0 +1,2 @@
+.*bad-group\.s: Assembler messages:
+.*bad-group\.s:.* Error: .*
diff --git a/gas/testsuite/gas/elf/bad-group.s
b/gas/testsuite/gas/elf/bad-group.s
new file mode 100644
index 0000000..69710c7
--- /dev/null
+++ b/gas/testsuite/gas/elf/bad-group.s
@@ -0,0 +1,11 @@
+ .section .text.startup,"ax",%progbits
+ .globl main
+main:
+ .type main, @function
+.LFB0:
+ .section .text.unlikely
+.L5:
+ .globl __gxx_personality_v0
+ .section .gcc_except_table,"a",%progbits
+ .uleb128 .L5-.LFB0
+ .section .data.foo,"awG",%progbits,foo,comdat
diff --git a/gas/testsuite/gas/elf/elf.exp b/gas/testsuite/gas/elf/elf.exp
index 0f5e97b..b6b1f0a 100644
--- a/gas/testsuite/gas/elf/elf.exp
+++ b/gas/testsuite/gas/elf/elf.exp
@@ -181,6 +181,7 @@ if { ([istarget "*-*-*elf*"]
run_dump_test "dwarf2-4"
run_dump_test "bad-section-flag"
run_dump_test "bad-size"
+ run_dump_test "bad-group"
load_lib gas-dg.exp
dg-init