gas segfault in files with groups and some error
H.J. Lu
hjl.tools@gmail.com
Thu Aug 4 20:56:00 GMT 2011
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
>
We should simply call bfd_cache_close_all on error.
I checked this in as an obvious fix.
--
H.J.
---
diff --git a/gas/ChangeLog b/gas/ChangeLog
index cb063fb..3a90951 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,11 @@
+2011-08-04 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR gas/13056
+ * output-file.c (output_file_close): Call bfd_cache_close_all
+ on error.
+
+ * write.c (write_object_file): Revert the last change.
+
2011-08-04 Alan Modra <amodra@gmail.com>
* write.c (write_object_file): Call set_symtab even if we had
diff --git a/gas/output-file.c b/gas/output-file.c
index e993033..3e871f0 100644
--- a/gas/output-file.c
+++ b/gas/output-file.c
@@ -59,7 +59,10 @@ output_file_close (char *filename)
return;
/* Close the bfd. */
- res = bfd_close (stdoutput);
+ if (had_errors ())
+ res = bfd_cache_close_all ();
+ else
+ res = bfd_close (stdoutput);
/* Prevent an infinite loop - if the close failed we will call as_fatal
which will call xexit() which may call this function again... */
diff --git a/gas/write.c b/gas/write.c
index 39b88a6..5eb4b56 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -2073,14 +2073,13 @@ 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
More information about the Binutils
mailing list