This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Map file should map symbols to their original bitcode file
ClosedPublic

Authored by int3 on Oct 20 2022, 2:18 PM.

Details

Summary

... instead of mapping them to the intermediate object file.
This matches ld64.

Diff Detail

Event Timeline

int3 created this revision.Oct 20 2022, 2:18 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 20 2022, 2:18 PM
int3 requested review of this revision.Oct 20 2022, 2:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 20 2022, 2:18 PM
int3 updated this revision to Diff 469359.Oct 20 2022, 2:19 PM

rm unused

int3 updated this revision to Diff 469616.Oct 21 2022, 8:16 AM

rm old comment

Roger accepted this revision.Oct 21 2022, 2:50 PM
Roger added a subscriber: Roger.

Looks good !

lld/MachO/MapFile.cpp
49

Could we make this name more specific? Like "SymbolEmittingFiles" or "EmittingFilese"?

54

can this function be made static?

lld/test/MachO/map-file.ll
6–7

For my benefit, could you explain more what this sentence means? Why would a "redundant object file" be and how would they be emitted?

12

As I understand, this flag makes the output into a dynamic library. Is this feature specific to dynamic libraries?

25–49

If I understand correctly, these two tests are there to show that the maybe_weak symbol gets attributed to the bar file regardless of the order of the input files (because maybe_weak symbol is not weak in the bar file). Could we write that down as a comment here?

This revision is now accepted and ready to land.Oct 21 2022, 2:50 PM
int3 marked 5 inline comments as done.Oct 21 2022, 7:47 PM
int3 added inline comments.
lld/MachO/MapFile.cpp
49

I don't really think that makes things clearer. This entire file contains logic around emitting the map file, and this struct itself is called MapInfo; adding 'emit' here is redundant. We're not writing "emitLiveSymbols" below after all. I think looking at the map file output (of which a sample is contained in the comment at the top of the file) should provide a strong hint as to why this vector exists

lld/test/MachO/map-file.ll
6–7

The intermediate object files referenced in the previous sentence are usually unreferenced, since we are mapping the symbols to the original bitcode files instead. But they may be referenced if they contain a synthesized symbol such as an outlined function. (I'll add a TODO to test that case.)

Object files can also become unreferenced if all the symbols defined within are weak definitions that get overridden. But that's not being tested here.

I'll remove 'redundant' and just say 'intermediate object files'.

12

no, but I don't want to have to define main

25–49

added a comment above the definition of maybe_weak

This revision was automatically updated to reflect the committed changes.
int3 marked 4 inline comments as done.