2020-10-28 14:49:43 +03:00
|
|
|
#include "mold.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,
|
2020-10-29 10:27:11 +03:00
|
|
|
(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)
|
|
|
|
<< sym->name << "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|