llvm-project/lld/MachO/MapFile.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

177 lines
5.8 KiB
C++
Raw Normal View History

//===- MapFile.cpp --------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file implements the -map option. It shows lists in order and
// hierarchically the outputFile, arch, input files, output sections and
// symbol:
//
// # Path: test
// # Arch: x86_84
// # Object files:
// [ 0] linker synthesized
// [ 1] a.o
// # Sections:
// # Address Size Segment Section
// 0x1000005C0 0x0000004C __TEXT __text
// # Symbols:
// # Address File Name
// 0x1000005C0 [ 1] _main
//
//===----------------------------------------------------------------------===//
#include "MapFile.h"
#include "Config.h"
#include "InputFiles.h"
#include "InputSection.h"
#include "OutputSection.h"
#include "OutputSegment.h"
#include "Symbols.h"
#include "SyntheticSections.h"
#include "Target.h"
#include "llvm/Support/Parallel.h"
#include "llvm/Support/TimeProfiler.h"
using namespace llvm;
using namespace llvm::sys;
using namespace lld;
using namespace lld::macho;
[lld][Macho] Include dead-stripped symbols in mapfile ld64 outputs dead stripped symbols when using the -dead-strip flag. This change mimics that behavior for lld. ld64's -dead_strip flag outputs: ``` $ ld -map map basics.o -o out -dead_strip -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lSystem $ cat map # Path: out # Arch: x86_64 # Object files: [ 0] linker synthesized [ 1] basics.o # Sections: # Address Size Segment Section 0x100003F97 0x00000021 __TEXT __text 0x100003FB8 0x00000048 __TEXT __unwind_info 0x100004000 0x00000008 __DATA_CONST __got 0x100008000 0x00000010 __DATA __ref_section 0x100008010 0x00000001 __DATA __common # Symbols: # Address Size File Name 0x100003F97 0x00000006 [ 1] _ref_local 0x100003F9D 0x00000001 [ 1] _ref_private_extern 0x100003F9E 0x0000000C [ 1] _main 0x100003FAA 0x00000006 [ 1] _no_dead_strip_globl 0x100003FB0 0x00000001 [ 1] _ref_from_no_dead_strip_globl 0x100003FB1 0x00000006 [ 1] _no_dead_strip_local 0x100003FB7 0x00000001 [ 1] _ref_from_no_dead_strip_local 0x100003FB8 0x00000048 [ 0] compact unwind info 0x100004000 0x00000008 [ 0] non-lazy-pointer-to-local: _ref_com 0x100008000 0x00000008 [ 1] _ref_data 0x100008008 0x00000008 [ 1] l_ref_data 0x100008010 0x00000001 [ 1] _ref_com # Dead Stripped Symbols: # Size File Name <<dead>> 0x00000006 [ 1] _unref_extern <<dead>> 0x00000001 [ 1] _unref_local <<dead>> 0x00000007 [ 1] _unref_private_extern <<dead>> 0x00000001 [ 1] _ref_private_extern_u <<dead>> 0x00000008 [ 1] _unref_data <<dead>> 0x00000008 [ 1] l_unref_data <<dead>> 0x00000001 [ 1] _unref_com ``` Reviewed By: int3, #lld-macho, thevinster Differential Revision: https://reviews.llvm.org/D114737
2022-01-29 02:51:27 +08:00
using Symbols = std::vector<Defined *>;
// Returns a pair where the left element is a container of all live Symbols and
// the right element is a container of all dead symbols.
static std::pair<Symbols, Symbols> getSymbols() {
Symbols liveSymbols, deadSymbols;
for (InputFile *file : inputFiles)
if (isa<ObjFile>(file))
for (Symbol *sym : file->symbols)
[lld/mac] Implement -dead_strip Also adds support for live_support sections, no_dead_strip sections, .no_dead_strip symbols. Chromium Framework 345MB unstripped -> 250MB stripped (vs 290MB unstripped -> 236M stripped with ld64). Doing dead stripping is a bit faster than not, because so much less data needs to be processed: % ministat lld_* x lld_nostrip.txt + lld_strip.txt N Min Max Median Avg Stddev x 10 3.929414 4.07692 4.0269079 4.0089678 0.044214794 + 10 3.8129408 3.9025559 3.8670411 3.8642573 0.024779651 Difference at 95.0% confidence -0.144711 +/- 0.0336749 -3.60967% +/- 0.839989% (Student's t, pooled s = 0.0358398) This interacts with many parts of the linker. I tried to add test coverage for all added `isLive()` checks, so that some test will fail if any of them is removed. I checked that the test expectations for the most part match ld64's behavior (except for live-support-iterations.s, see the comment in the test). Interacts with: - debug info - export tries - import opcodes - flags like -exported_symbol(s_list) - -U / dynamic_lookup - mod_init_funcs, mod_term_funcs - weak symbol handling - unwind info - stubs - map files - -sectcreate - undefined, dylib, common, defined (both absolute and normal) symbols It's possible it interacts with more features I didn't think of, of course. I also did some manual testing: - check-llvm check-clang check-lld work with lld with this patch as host linker and -dead_strip enabled - Chromium still starts - Chromium's base_unittests still pass, including unwind tests Implemenation-wise, this is InputSection-based, so it'll work for object files with .subsections_via_symbols (which includes all object files generated by clang). I first based this on the COFF implementation, but later realized that things are more similar to ELF. I think it'd be good to refactor MarkLive.cpp to look more like the ELF part at some point, but I'd like to get a working state checked in first. Mechanical parts: - Rename canOmitFromOutput to wasCoalesced (no behavior change) since it really is for weak coalesced symbols - Add noDeadStrip to Defined, corresponding to N_NO_DEAD_STRIP (`.no_dead_strip` in asm) Fixes PR49276. Differential Revision: https://reviews.llvm.org/D103324
2021-05-08 05:10:05 +08:00
if (auto *d = dyn_cast_or_null<Defined>(sym))
[lld][Macho] Include dead-stripped symbols in mapfile ld64 outputs dead stripped symbols when using the -dead-strip flag. This change mimics that behavior for lld. ld64's -dead_strip flag outputs: ``` $ ld -map map basics.o -o out -dead_strip -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lSystem $ cat map # Path: out # Arch: x86_64 # Object files: [ 0] linker synthesized [ 1] basics.o # Sections: # Address Size Segment Section 0x100003F97 0x00000021 __TEXT __text 0x100003FB8 0x00000048 __TEXT __unwind_info 0x100004000 0x00000008 __DATA_CONST __got 0x100008000 0x00000010 __DATA __ref_section 0x100008010 0x00000001 __DATA __common # Symbols: # Address Size File Name 0x100003F97 0x00000006 [ 1] _ref_local 0x100003F9D 0x00000001 [ 1] _ref_private_extern 0x100003F9E 0x0000000C [ 1] _main 0x100003FAA 0x00000006 [ 1] _no_dead_strip_globl 0x100003FB0 0x00000001 [ 1] _ref_from_no_dead_strip_globl 0x100003FB1 0x00000006 [ 1] _no_dead_strip_local 0x100003FB7 0x00000001 [ 1] _ref_from_no_dead_strip_local 0x100003FB8 0x00000048 [ 0] compact unwind info 0x100004000 0x00000008 [ 0] non-lazy-pointer-to-local: _ref_com 0x100008000 0x00000008 [ 1] _ref_data 0x100008008 0x00000008 [ 1] l_ref_data 0x100008010 0x00000001 [ 1] _ref_com # Dead Stripped Symbols: # Size File Name <<dead>> 0x00000006 [ 1] _unref_extern <<dead>> 0x00000001 [ 1] _unref_local <<dead>> 0x00000007 [ 1] _unref_private_extern <<dead>> 0x00000001 [ 1] _ref_private_extern_u <<dead>> 0x00000008 [ 1] _unref_data <<dead>> 0x00000008 [ 1] l_unref_data <<dead>> 0x00000001 [ 1] _unref_com ``` Reviewed By: int3, #lld-macho, thevinster Differential Revision: https://reviews.llvm.org/D114737
2022-01-29 02:51:27 +08:00
if (d->isec && d->getFile() == file) {
if (d->isLive()) {
assert(!shouldOmitFromOutput(d->isec));
liveSymbols.push_back(d);
} else {
deadSymbols.push_back(d);
}
}
[lld][Macho] Include dead-stripped symbols in mapfile ld64 outputs dead stripped symbols when using the -dead-strip flag. This change mimics that behavior for lld. ld64's -dead_strip flag outputs: ``` $ ld -map map basics.o -o out -dead_strip -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lSystem $ cat map # Path: out # Arch: x86_64 # Object files: [ 0] linker synthesized [ 1] basics.o # Sections: # Address Size Segment Section 0x100003F97 0x00000021 __TEXT __text 0x100003FB8 0x00000048 __TEXT __unwind_info 0x100004000 0x00000008 __DATA_CONST __got 0x100008000 0x00000010 __DATA __ref_section 0x100008010 0x00000001 __DATA __common # Symbols: # Address Size File Name 0x100003F97 0x00000006 [ 1] _ref_local 0x100003F9D 0x00000001 [ 1] _ref_private_extern 0x100003F9E 0x0000000C [ 1] _main 0x100003FAA 0x00000006 [ 1] _no_dead_strip_globl 0x100003FB0 0x00000001 [ 1] _ref_from_no_dead_strip_globl 0x100003FB1 0x00000006 [ 1] _no_dead_strip_local 0x100003FB7 0x00000001 [ 1] _ref_from_no_dead_strip_local 0x100003FB8 0x00000048 [ 0] compact unwind info 0x100004000 0x00000008 [ 0] non-lazy-pointer-to-local: _ref_com 0x100008000 0x00000008 [ 1] _ref_data 0x100008008 0x00000008 [ 1] l_ref_data 0x100008010 0x00000001 [ 1] _ref_com # Dead Stripped Symbols: # Size File Name <<dead>> 0x00000006 [ 1] _unref_extern <<dead>> 0x00000001 [ 1] _unref_local <<dead>> 0x00000007 [ 1] _unref_private_extern <<dead>> 0x00000001 [ 1] _ref_private_extern_u <<dead>> 0x00000008 [ 1] _unref_data <<dead>> 0x00000008 [ 1] l_unref_data <<dead>> 0x00000001 [ 1] _unref_com ``` Reviewed By: int3, #lld-macho, thevinster Differential Revision: https://reviews.llvm.org/D114737
2022-01-29 02:51:27 +08:00
parallelSort(liveSymbols.begin(), liveSymbols.end(),
[](Defined *a, Defined *b) {
return a->getVA() != b->getVA() ? a->getVA() < b->getVA()
: a->getName() < b->getName();
});
parallelSort(
deadSymbols.begin(), deadSymbols.end(),
[](Defined *a, Defined *b) { return a->getName() < b->getName(); });
return {std::move(liveSymbols), std::move(deadSymbols)};
}
// Construct a map from symbols to their stringified representations.
// Demangling symbols (which is what toString() does) is slow, so
// we do that in batch using parallel-for.
static DenseMap<Symbol *, std::string>
getSymbolStrings(ArrayRef<Defined *> syms) {
std::vector<std::string> str(syms.size());
parallelFor(0, syms.size(), [&](size_t i) {
raw_string_ostream os(str[i]);
Defined *sym = syms[i];
switch (sym->isec->kind()) {
case InputSection::CStringLiteralKind: {
// Output "literal string: <string literal>"
const auto *isec = cast<CStringInputSection>(sym->isec);
const StringPiece &piece = isec->getStringPiece(sym->value);
assert(
sym->value == piece.inSecOff &&
"We expect symbols to always point to the start of a StringPiece.");
StringRef str = isec->getStringRef(&piece - &(*isec->pieces.begin()));
(os << "literal string: ").write_escaped(str);
break;
}
case InputSection::ConcatKind:
case InputSection::WordLiteralKind:
os << toString(*sym);
}
});
DenseMap<Symbol *, std::string> ret;
for (size_t i = 0, e = syms.size(); i < e; ++i)
ret[syms[i]] = std::move(str[i]);
return ret;
}
void macho::writeMapFile() {
if (config->mapFile.empty())
return;
TimeTraceScope timeScope("Write map file");
// Open a map file for writing.
std::error_code ec;
raw_fd_ostream os(config->mapFile, ec, sys::fs::OF_None);
if (ec) {
error("cannot open " + config->mapFile + ": " + ec.message());
return;
}
2021-03-30 02:35:57 +08:00
// Dump output path.
os << format("# Path: %s\n", config->outputFile.str().c_str());
2021-03-30 02:35:57 +08:00
// Dump output architecture.
os << format("# Arch: %s\n",
getArchitectureName(config->arch()).str().c_str());
2021-03-30 02:35:57 +08:00
// Dump table of object files.
os << "# Object files:\n";
os << format("[%3u] %s\n", 0, (const char *)"linker synthesized");
uint32_t fileIndex = 1;
DenseMap<lld::macho::InputFile *, uint32_t> readerToFileOrdinal;
for (InputFile *file : inputFiles) {
if (isa<ObjFile>(file)) {
os << format("[%3u] %s\n", fileIndex, file->getName().str().c_str());
readerToFileOrdinal[file] = fileIndex++;
}
}
// Dump table of sections
os << "# Sections:\n";
os << "# Address\tSize \tSegment\tSection\n";
for (OutputSegment *seg : outputSegments)
for (OutputSection *osec : seg->getSections()) {
if (osec->isHidden())
continue;
os << format("0x%08llX\t0x%08llX\t%s\t%s\n", osec->addr, osec->getSize(),
seg->name.str().c_str(), osec->name.str().c_str());
}
// Dump table of symbols
auto [liveSymbols, deadSymbols] = getSymbols();
[lld][Macho] Include dead-stripped symbols in mapfile ld64 outputs dead stripped symbols when using the -dead-strip flag. This change mimics that behavior for lld. ld64's -dead_strip flag outputs: ``` $ ld -map map basics.o -o out -dead_strip -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lSystem $ cat map # Path: out # Arch: x86_64 # Object files: [ 0] linker synthesized [ 1] basics.o # Sections: # Address Size Segment Section 0x100003F97 0x00000021 __TEXT __text 0x100003FB8 0x00000048 __TEXT __unwind_info 0x100004000 0x00000008 __DATA_CONST __got 0x100008000 0x00000010 __DATA __ref_section 0x100008010 0x00000001 __DATA __common # Symbols: # Address Size File Name 0x100003F97 0x00000006 [ 1] _ref_local 0x100003F9D 0x00000001 [ 1] _ref_private_extern 0x100003F9E 0x0000000C [ 1] _main 0x100003FAA 0x00000006 [ 1] _no_dead_strip_globl 0x100003FB0 0x00000001 [ 1] _ref_from_no_dead_strip_globl 0x100003FB1 0x00000006 [ 1] _no_dead_strip_local 0x100003FB7 0x00000001 [ 1] _ref_from_no_dead_strip_local 0x100003FB8 0x00000048 [ 0] compact unwind info 0x100004000 0x00000008 [ 0] non-lazy-pointer-to-local: _ref_com 0x100008000 0x00000008 [ 1] _ref_data 0x100008008 0x00000008 [ 1] l_ref_data 0x100008010 0x00000001 [ 1] _ref_com # Dead Stripped Symbols: # Size File Name <<dead>> 0x00000006 [ 1] _unref_extern <<dead>> 0x00000001 [ 1] _unref_local <<dead>> 0x00000007 [ 1] _unref_private_extern <<dead>> 0x00000001 [ 1] _ref_private_extern_u <<dead>> 0x00000008 [ 1] _unref_data <<dead>> 0x00000008 [ 1] l_unref_data <<dead>> 0x00000001 [ 1] _unref_com ``` Reviewed By: int3, #lld-macho, thevinster Differential Revision: https://reviews.llvm.org/D114737
2022-01-29 02:51:27 +08:00
DenseMap<Symbol *, std::string> liveSymbolStrings =
getSymbolStrings(liveSymbols);
os << "# Symbols:\n";
os << "# Address\t File Name\n";
[lld][Macho] Include dead-stripped symbols in mapfile ld64 outputs dead stripped symbols when using the -dead-strip flag. This change mimics that behavior for lld. ld64's -dead_strip flag outputs: ``` $ ld -map map basics.o -o out -dead_strip -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lSystem $ cat map # Path: out # Arch: x86_64 # Object files: [ 0] linker synthesized [ 1] basics.o # Sections: # Address Size Segment Section 0x100003F97 0x00000021 __TEXT __text 0x100003FB8 0x00000048 __TEXT __unwind_info 0x100004000 0x00000008 __DATA_CONST __got 0x100008000 0x00000010 __DATA __ref_section 0x100008010 0x00000001 __DATA __common # Symbols: # Address Size File Name 0x100003F97 0x00000006 [ 1] _ref_local 0x100003F9D 0x00000001 [ 1] _ref_private_extern 0x100003F9E 0x0000000C [ 1] _main 0x100003FAA 0x00000006 [ 1] _no_dead_strip_globl 0x100003FB0 0x00000001 [ 1] _ref_from_no_dead_strip_globl 0x100003FB1 0x00000006 [ 1] _no_dead_strip_local 0x100003FB7 0x00000001 [ 1] _ref_from_no_dead_strip_local 0x100003FB8 0x00000048 [ 0] compact unwind info 0x100004000 0x00000008 [ 0] non-lazy-pointer-to-local: _ref_com 0x100008000 0x00000008 [ 1] _ref_data 0x100008008 0x00000008 [ 1] l_ref_data 0x100008010 0x00000001 [ 1] _ref_com # Dead Stripped Symbols: # Size File Name <<dead>> 0x00000006 [ 1] _unref_extern <<dead>> 0x00000001 [ 1] _unref_local <<dead>> 0x00000007 [ 1] _unref_private_extern <<dead>> 0x00000001 [ 1] _ref_private_extern_u <<dead>> 0x00000008 [ 1] _unref_data <<dead>> 0x00000008 [ 1] l_unref_data <<dead>> 0x00000001 [ 1] _unref_com ``` Reviewed By: int3, #lld-macho, thevinster Differential Revision: https://reviews.llvm.org/D114737
2022-01-29 02:51:27 +08:00
for (Symbol *sym : liveSymbols) {
assert(sym->isLive());
[lld][macho] Stop grouping symbols by sections in mapfile. As per [Bug 50689](https://bugs.llvm.org/show_bug.cgi?id=50689), ``` 2. getSectionSyms() puts all the symbols into a map of section -> symbols, but this seems unnecessary. This was likely copied from the ELF port, which prints a section header before the list of symbols it contains. But the Mach-O map file doesn't print these headers. ``` This diff removes `getSectionSyms()` and keeps all symbols in a flat vector. What does ld64's mapfile look like? ``` $ llvm-mc -filetype=obj -triple=x86_64-apple-darwin test.s -o test.o $ llvm-mc -filetype=obj -triple=x86_64-apple-darwin foo.s -o foo.o $ ld -map map test.o foo.o -o out -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lSystem ``` ``` [ 0] linker synthesized [ 1] test.o [ 2] foo.o 0x100003FB7 0x00000001 __TEXT __text 0x100003FB8 0x00000000 __TEXT obj 0x100003FB8 0x00000048 __TEXT __unwind_info 0x100004000 0x00000001 __DATA __common 0x100003FB7 0x00000001 [ 1] _main 0x100003FB8 0x00000000 [ 2] _foo 0x100003FB8 0x00000048 [ 0] compact unwind info 0x100004000 0x00000001 [ 1] _number ``` Perf numbers when linking chromium framework on a 16-Core Intel Xeon W Mac Pro: ``` base diff difference (95% CI) sys_time 1.406 ± 0.020 1.388 ± 0.019 [ -1.9% .. -0.6%] user_time 5.557 ± 0.023 5.914 ± 0.020 [ +6.2% .. +6.6%] wall_time 4.455 ± 0.041 4.436 ± 0.035 [ -0.8% .. -0.0%] samples 35 35 ``` Reviewed By: #lld-macho, int3 Differential Revision: https://reviews.llvm.org/D114735
2022-01-21 04:13:04 +08:00
os << format("0x%08llX\t[%3u] %s\n", sym->getVA(),
[lld][Macho] Include dead-stripped symbols in mapfile ld64 outputs dead stripped symbols when using the -dead-strip flag. This change mimics that behavior for lld. ld64's -dead_strip flag outputs: ``` $ ld -map map basics.o -o out -dead_strip -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lSystem $ cat map # Path: out # Arch: x86_64 # Object files: [ 0] linker synthesized [ 1] basics.o # Sections: # Address Size Segment Section 0x100003F97 0x00000021 __TEXT __text 0x100003FB8 0x00000048 __TEXT __unwind_info 0x100004000 0x00000008 __DATA_CONST __got 0x100008000 0x00000010 __DATA __ref_section 0x100008010 0x00000001 __DATA __common # Symbols: # Address Size File Name 0x100003F97 0x00000006 [ 1] _ref_local 0x100003F9D 0x00000001 [ 1] _ref_private_extern 0x100003F9E 0x0000000C [ 1] _main 0x100003FAA 0x00000006 [ 1] _no_dead_strip_globl 0x100003FB0 0x00000001 [ 1] _ref_from_no_dead_strip_globl 0x100003FB1 0x00000006 [ 1] _no_dead_strip_local 0x100003FB7 0x00000001 [ 1] _ref_from_no_dead_strip_local 0x100003FB8 0x00000048 [ 0] compact unwind info 0x100004000 0x00000008 [ 0] non-lazy-pointer-to-local: _ref_com 0x100008000 0x00000008 [ 1] _ref_data 0x100008008 0x00000008 [ 1] l_ref_data 0x100008010 0x00000001 [ 1] _ref_com # Dead Stripped Symbols: # Size File Name <<dead>> 0x00000006 [ 1] _unref_extern <<dead>> 0x00000001 [ 1] _unref_local <<dead>> 0x00000007 [ 1] _unref_private_extern <<dead>> 0x00000001 [ 1] _ref_private_extern_u <<dead>> 0x00000008 [ 1] _unref_data <<dead>> 0x00000008 [ 1] l_unref_data <<dead>> 0x00000001 [ 1] _unref_com ``` Reviewed By: int3, #lld-macho, thevinster Differential Revision: https://reviews.llvm.org/D114737
2022-01-29 02:51:27 +08:00
readerToFileOrdinal[sym->getFile()],
liveSymbolStrings[sym].c_str());
}
[lld][Macho] Include dead-stripped symbols in mapfile ld64 outputs dead stripped symbols when using the -dead-strip flag. This change mimics that behavior for lld. ld64's -dead_strip flag outputs: ``` $ ld -map map basics.o -o out -dead_strip -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lSystem $ cat map # Path: out # Arch: x86_64 # Object files: [ 0] linker synthesized [ 1] basics.o # Sections: # Address Size Segment Section 0x100003F97 0x00000021 __TEXT __text 0x100003FB8 0x00000048 __TEXT __unwind_info 0x100004000 0x00000008 __DATA_CONST __got 0x100008000 0x00000010 __DATA __ref_section 0x100008010 0x00000001 __DATA __common # Symbols: # Address Size File Name 0x100003F97 0x00000006 [ 1] _ref_local 0x100003F9D 0x00000001 [ 1] _ref_private_extern 0x100003F9E 0x0000000C [ 1] _main 0x100003FAA 0x00000006 [ 1] _no_dead_strip_globl 0x100003FB0 0x00000001 [ 1] _ref_from_no_dead_strip_globl 0x100003FB1 0x00000006 [ 1] _no_dead_strip_local 0x100003FB7 0x00000001 [ 1] _ref_from_no_dead_strip_local 0x100003FB8 0x00000048 [ 0] compact unwind info 0x100004000 0x00000008 [ 0] non-lazy-pointer-to-local: _ref_com 0x100008000 0x00000008 [ 1] _ref_data 0x100008008 0x00000008 [ 1] l_ref_data 0x100008010 0x00000001 [ 1] _ref_com # Dead Stripped Symbols: # Size File Name <<dead>> 0x00000006 [ 1] _unref_extern <<dead>> 0x00000001 [ 1] _unref_local <<dead>> 0x00000007 [ 1] _unref_private_extern <<dead>> 0x00000001 [ 1] _ref_private_extern_u <<dead>> 0x00000008 [ 1] _unref_data <<dead>> 0x00000008 [ 1] l_unref_data <<dead>> 0x00000001 [ 1] _unref_com ``` Reviewed By: int3, #lld-macho, thevinster Differential Revision: https://reviews.llvm.org/D114737
2022-01-29 02:51:27 +08:00
if (config->deadStrip) {
DenseMap<Symbol *, std::string> deadSymbolStrings =
getSymbolStrings(deadSymbols);
os << "# Dead Stripped Symbols:\n";
os << "# Address\t File Name\n";
for (Symbol *sym : deadSymbols) {
assert(!sym->isLive());
os << format("<<dead>>\t[%3u] %s\n", readerToFileOrdinal[sym->getFile()],
deadSymbolStrings[sym].c_str());
}
}
}