gas 2.20.1 assertion failure when .file directive empty and .stabs directive present

Raymes Khoury raymes@google.com
Tue Aug 31 21:10:00 GMT 2010


That works. But it seems to me that get_stab_string_offset should
still return 1 rather than 0 in this case (for the first NULL value
that gets set). This would also make the assertion correct.

*** stabs.c	Fri Aug 20 17:27:26 2010
--- stabs.c.patched	Tue Aug 31 09:13:29 2010
*************** get_stab_string_offset (const char *stri
*** 119,126 ****

        seg_info (seg)->stabu.stab_string_size += length + 1;
      }
-   else
-     retval = 0;

    subseg_set (save_seg, save_subseg);

--- 119,124 ----



On Mon, Aug 30, 2010 at 10:33 PM, Alan Modra <amodra@gmail.com> wrote:
> On Thu, Aug 26, 2010 at 03:19:23PM -0700, Raymes Khoury wrote:
>> This error can be easily reproduced by executing the following with
>> binutils 2.20.1 (I'm using gcc 4.4.3).
>>
>> $ echo "int main() { return 0; }" | gcc -x c - -gstabs
>> /tmp/ccautrgB.s: Assembler messages:
>> /tmp/ccautrgB.s:2: Internal error!
>> Assertion failure in obj_elf_init_stab_section at
>> ../../gas/config/obj-elf.c line 1782.
>> Please report this bug.
>>
>> When the program is passed from stdin, gcc uses an empty string as the
>> value of the .file directive. The assembler output is as follows:
>>         .file   ""
>>         .stabs  "",100,0,2,.Ltext0
>>         .text
>>         ...
>>
>> The assertion fails in obj_elf_init_stab_section which calls
>> get_stab_string_offset (stabs.c) with the value of the .file
>> directive. When this is an empty string, get_stab_string_offset
>> returns 0 which appears to be a failure value as the offset is
>> actually 1 (and in all other cases it will return a value >= 1).
>> obj_elf_init_stab_section asserts the return value is 1 and thus
>> fails.
> [snip]
>
> Let's just fix the assertion.  There isn't much point in adding
> another NUL to the stab string section.  The first one will do fine.
>
>        * config/obj-elf.c (obj_elf_init_stab_section): Fix assertion.
>
> Index: gas/config/obj-elf.c
> ===================================================================
> RCS file: /cvs/src/src/gas/config/obj-elf.c,v
> retrieving revision 1.129
> diff -u -p -r1.129 obj-elf.c
> --- gas/config/obj-elf.c        17 Aug 2010 20:03:40 -0000      1.129
> +++ gas/config/obj-elf.c        31 Aug 2010 05:31:33 -0000
> @@ -1795,7 +1795,7 @@ obj_elf_init_stab_section (segT seg)
>   strcpy (stabstr_name, segment_name (seg));
>   strcat (stabstr_name, "str");
>   stroff = get_stab_string_offset (file, stabstr_name);
> -  know (stroff == 1);
> +  know (stroff == 1 || (stroff == 0 && file[0] == '\0'));
>   md_number_to_chars (p, stroff, 4);
>   seg_info (seg)->stabu.p = p;
>  }
>
> --
> Alan Modra
> Australia Development Lab, IBM
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stabs.c.diff
Type: application/octet-stream
Size: 319 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20100831/ee861f2a/attachment-0001.obj>


More information about the Binutils mailing list