1
1
mirror of https://github.com/rui314/mold.git synced 2024-09-22 10:27:48 +03:00
mold/mapfile.cc

39 lines
1.4 KiB
C++
Raw Normal View History

2020-10-28 14:49:43 +03:00
#include "mold.h"
2020-10-29 06:24:54 +03:00
2020-11-03 14:49:30 +03:00
#include "llvm/Support/Format.h"
2020-10-29 06:24:54 +03:00
using namespace llvm;
2020-10-29 12:31:06 +03:00
void print_map(ArrayRef<ObjectFile *> files, ArrayRef<OutputChunk *> output_sections) {
2020-10-29 06:24:54 +03:00
// Construct a section-to-symbol map.
std::unordered_multimap<InputSection *, Symbol *> map;
for (ObjectFile *file : files)
for (Symbol *sym : file->symbols)
if (sym->file == file && sym->input_section)
map.insert({sym->input_section, sym});
llvm::outs() << " VMA Size Align Out In Symbol\n";
2020-10-29 12:31:06 +03:00
for (OutputChunk *chunk : output_sections) {
2020-10-29 06:24:54 +03:00
llvm::outs() << format("%16llx %8llx %5lld ",
2020-10-29 12:31:06 +03:00
(u64)chunk->shdr.sh_addr,
(u64)chunk->shdr.sh_size,
(u64)chunk->shdr.sh_addralign)
<< chunk->name << "\n";
2020-10-29 06:24:54 +03:00
2020-10-29 12:31:06 +03:00
for (InputSection *isec : chunk->sections) {
2020-10-29 06:24:54 +03:00
llvm::outs() << format("%16llx %8llx %5lld ",
2020-10-29 12:31:06 +03:00
chunk->shdr.sh_addr + isec->offset,
(u64)isec->shdr.sh_size,
(u64)isec->shdr.sh_addralign)
2020-10-29 06:43:10 +03:00
<< toString(isec) << "\n";
2020-10-29 06:24:54 +03:00
auto range = map.equal_range(isec);
for (auto it = range.first; it != range.second; ++it) {
Symbol *sym = it->second;
llvm::outs() << format("%16llx %8llx %5lld ", sym->addr, 0, 0)
2020-10-29 06:24:54 +03:00
<< sym->name << "\n";
}
}
}
}