Bug 6656 - [regression] linking with -g results in assembler error
Summary: [regression] linking with -g results in assembler error
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.19
: P2 normal
Target Milestone: ---
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-18 19:40 UTC by Matthias Klose
Modified: 2008-08-05 08:16 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2008-08-05 08:15:48


Attachments
testcase (.s file generated by GCC-4.3.1) (1.08 KB, application/octet-stream)
2008-06-18 20:31 UTC, Matthias Klose
Details
testcase (.s file for ia64, generated by GCC-4.3.1) (1.06 KB, application/octet-stream)
2008-06-18 20:35 UTC, Matthias Klose
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Klose 2008-06-18 19:40:46 UTC
seen with current trunk, not with the 2.18 branch, testcase taken from the darcs
configury.

echo -e '#include "test2.h"\nint main (int argc, char** argv) {callme(); return
1;}' > test2.c
echo 'int callme() {}' > test2.h
gcc -S -g test2.c -o test2.s; gcc test2.s -o test2 -g
test2.s: Assembler messages:
test2.s:31: Error: file number 2 already allocated

omitting the -g for the linking avoids the error.
Comment 1 Alan Modra 2008-06-18 20:11:14 UTC
target?  gcc version?  Really, for assembler errors, you ought to give us the
assembler input, removing the dependency on gcc.
Comment 2 Matthias Klose 2008-06-18 20:31:04 UTC
Created attachment 2783 [details]
testcase (.s file generated by GCC-4.3.1)

this is on i386-linux-gnu, built with GCC-4.3.1 release.
Comment 3 Matthias Klose 2008-06-18 20:35:47 UTC
Created attachment 2784 [details]
testcase (.s file for ia64, generated by GCC-4.3.1)

on ia64-linux-gnu the testcase fails with both 2.18 branch and the trunk.
Comment 4 Alan Modra 2008-06-22 03:49:02 UTC
Actually, I should have recognized the problem just from the description. 
Asking the assembler to generate dwarf debug info, when the file already has
debug info generated by the compiler, is just one of those things you should not
do.  Of course, the assembler ought to give a better error message..

You see, the compiler emits file and line number info referring to the C (or
other language) source file and line numbers, while "as -g" emits file and line
number info for the assembly file.  Having both sets of debug info doesn't make
much sense, since they give contradictory information.
Comment 5 H.J. Lu 2008-07-12 18:46:11 UTC
Alan is correct. You shouldn't use "gcc -g" on assembly code which
already has debug info.
Comment 6 Alan Modra 2008-08-05 08:14:50 UTC
Fixing.