Bug 25540 - using the same filename for MAP and DLL fails silently with file corruption
Summary: using the same filename for MAP and DLL fails silently with file corruption
Status: UNCONFIRMED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.30
: P2 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-13 04:33 UTC by Dan Raymond
Modified: 2020-02-13 09:02 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Raymond 2020-02-13 04:33:03 UTC
I discovered this due to an error in my Makefile.  I was using "-Wl,-Map=$(@:.dll=.map) -o $@" on the command line but the target was foo.pyd (not foo.dll).  Therefore I inadvertantly specified the same filename for the map file and the output file.  This caused the linker to fail silently (no warnings or errors) and generate a corrupt output file.  The section headers pointed to areas in the file that did not contain the expected sections.

When doing the same thing using lld it succeeds with a valid output file but no map file is generated.

It would be better for ld to detect the duplicate filename and fail with a helpful error message or to mimic the behavior of lld.
Comment 1 Alan Modra 2020-02-13 09:02:27 UTC
I guess you could do something like we do for gas, where we check that the output st_ino is different from any input.