Bug 251251

Summary: --cref on ld.lld writes the cref table to stdout even with -Map=filename
Product: Base System Reporter: Jan Martin Mikkelsen <janm>
Component: binAssignee: freebsd-toolchain (Nobody) <toolchain>
Status: Closed Overcome By Events    
Severity: Affects Some People CC: i, markj
Priority: ---    
Version: 12.2-RELEASE   
Hardware: Any   
OS: Any   
See Also: https://bugs.llvm.org/show_bug.cgi?id=48282
Attachments:
Description Flags
Patch to make --cref output go to the files specified for -Map=name none

Description Jan Martin Mikkelsen 2020-11-19 09:36:35 UTC
The --cref option on ld.lld only seems to write to stdout, ignoring the -Map=filename option. This is a change from GNU ld.

To reproduce, compile and link any code with --cref, for example:

    echo 'int main() { return 0; }' > test.c
    cc -Wl,-Map=test.map -Wl,--cref test.c

The cross reference table is emitted on stdout instead of being written to test.map.
Comment 1 Mark Johnston freebsd_committer freebsd_triage 2020-11-23 16:00:10 UTC
If this is purely an lld bug, which it appears to be, the bug should be filed with the LLVM project instead.
Comment 2 Jan Martin Mikkelsen 2020-11-24 11:35:44 UTC
Created attachment 219921 [details]
Patch to make --cref output go to the files specified for -Map=name

Patch to make --cref output go to the file specified for -Map=name
Comment 3 Jan Martin Mikkelsen 2020-11-24 11:36:42 UTC
(In reply to Mark Johnston from comment #1)

Makes sense, I'll report upstream.

In the meantime, a patch that resolves the issue for me is attached in case someone else comes looking for the same problem.
Comment 4 Jan Martin Mikkelsen 2020-11-24 16:29:13 UTC
Reported to the LLVM project as https://bugs.llvm.org/show_bug.cgi?id=48282
Comment 5 Fangrui Song 2021-11-27 05:24:44 UTC
https://reviews.llvm.org/D114663 will implement the GNU ld/gold behavior. bugs.llvm.org is in read-only mode as the issue tracker is being migrated to GitHub.