Created attachment 24204 [details] Patch to use the file from -Map as a target for --cref output. 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. A patch (against the lld imported into the FreeBSD 12.2 tree) that resolves the issue for me is attached.
GNU ld's documentation --cref Output a cross reference table. If a linker map file is being generated, the cross reference table is printed to the map file. Otherwise, it is printed on the standard output. --- The code was there in 1990+. The behavior looks strange.
I'm curious about what was invalid about this. Your comment said that GNU ld prints --cref output to the map file if a map file is specified, stdout otherwise. That is also the behaviour I have observed with GNU ld for many year. That isn't what lld is doing. I read your comment as supporting this as a bug. Was I mistaken?