Bug 251251 - --cref on ld.lld writes the cref table to stdout even with -Map=filename
Summary: --cref on ld.lld writes the cref table to stdout even with -Map=filename
Status: Closed Overcome By Events
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 12.2-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-toolchain (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-19 09:36 UTC by Jan Martin Mikkelsen
Modified: 2021-11-27 05:24 UTC (History)
2 users (show)

See Also:


Attachments
Patch to make --cref output go to the files specified for -Map=name (1.47 KB, patch)
2020-11-24 11:35 UTC, Jan Martin Mikkelsen
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.