diff options
author | Jez Ng <jezng@fb.com> | 2023-03-10 22:29:14 -0500 |
---|---|---|
committer | Jez Ng <jezng@fb.com> | 2023-03-11 01:40:14 -0500 |
commit | 5b21395cc2422d735c632afefcb95f08d8ed4b88 (patch) | |
tree | 98f0849a8a9e504272e1edf74656c4bbe2777f42 /lld/MachO | |
parent | bb69a66ced27918f894fb0d5e58e22fda6958d99 (diff) | |
download | llvm-5b21395cc2422d735c632afefcb95f08d8ed4b88.tar.gz |
[lld-macho] Print archive names in linker map
If a symbol is pulled in from an archive, we should include the archive
name in the map file output. This is what ld64 does.
Note that we aren't using `toString(InputFile*)` here because it
includes the install name for dylibs in its output, and ld64's map file
does not contain those.
Reviewed By: #lld-macho, smeenai
Differential Revision: https://reviews.llvm.org/D145623
Diffstat (limited to 'lld/MachO')
-rw-r--r-- | lld/MachO/MapFile.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lld/MachO/MapFile.cpp b/lld/MachO/MapFile.cpp index c16e046dcd1f..0c1b4f1254d2 100644 --- a/lld/MachO/MapFile.cpp +++ b/lld/MachO/MapFile.cpp @@ -122,8 +122,17 @@ static MapInfo gatherMapInfo() { return info; } +// We use this instead of `toString(const InputFile *)` as we don't want to +// include the dylib install name in our output. +static void printFileName(raw_fd_ostream &os, const InputFile *f) { + if (f->archiveName.empty()) + os << f->getName(); + else + os << f->archiveName << "(" << path::filename(f->getName()) + ")"; +} + // For printing the contents of the __stubs and __la_symbol_ptr sections. -void printStubsEntries( +static void printStubsEntries( raw_fd_ostream &os, const DenseMap<lld::macho::InputFile *, uint32_t> &readerToFileOrdinal, const OutputSection *osec, size_t entrySize) { @@ -134,8 +143,8 @@ void printStubsEntries( sym->getName().str().data()); } -void printNonLazyPointerSection(raw_fd_ostream &os, - NonLazyPointerSectionBase *osec) { +static void printNonLazyPointerSection(raw_fd_ostream &os, + NonLazyPointerSectionBase *osec) { // ld64 considers stubs to belong to particular files, but considers GOT // entries to be linker-synthesized. Not sure why they made that decision, but // I think we can follow suit unless there's demand for better symbol-to-file @@ -171,7 +180,9 @@ void macho::writeMapFile() { uint32_t fileIndex = 1; DenseMap<lld::macho::InputFile *, uint32_t> readerToFileOrdinal; for (InputFile *file : info.files) { - os << format("[%3u] %s\n", fileIndex, file->getName().str().c_str()); + os << format("[%3u] ", fileIndex); + printFileName(os, file); + os << "\n"; readerToFileOrdinal[file] = fileIndex++; } |