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.
|
2020-11-08 06:36:08 +03:00
|
|
|
std::unordered_multimap<InputChunk *, Symbol *> map;
|
2020-10-29 06:24:54 +03:00
|
|
|
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-11-08 06:42:40 +03:00
|
|
|
for (OutputChunk *osec : output_sections) {
|
2020-10-29 06:24:54 +03:00
|
|
|
llvm::outs() << format("%16llx %8llx %5lld ",
|
2020-11-08 06:42:40 +03:00
|
|
|
(u64)osec->shdr.sh_addr,
|
|
|
|
(u64)osec->shdr.sh_size,
|
|
|
|
(u64)osec->shdr.sh_addralign)
|
|
|
|
<< osec->name << "\n";
|
2020-10-29 06:24:54 +03:00
|
|
|
|
2020-11-08 10:09:01 +03:00
|
|
|
if (osec->kind != OutputChunk::REGULAR)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (InputChunk *mem : ((OutputSection *)osec)->members) {
|
2020-10-29 06:24:54 +03:00
|
|
|
llvm::outs() << format("%16llx %8llx %5lld ",
|
2020-11-08 06:42:40 +03:00
|
|
|
osec->shdr.sh_addr + mem->offset,
|
|
|
|
(u64)mem->shdr.sh_size,
|
|
|
|
(u64)mem->shdr.sh_addralign)
|
|
|
|
<< toString(mem) << "\n";
|
2020-10-29 06:24:54 +03:00
|
|
|
|
2020-11-08 06:42:40 +03:00
|
|
|
auto range = map.equal_range(mem);
|
2020-10-29 06:24:54 +03:00
|
|
|
for (auto it = range.first; it != range.second; ++it) {
|
|
|
|
Symbol *sym = it->second;
|
2020-11-06 06:50:26 +03:00
|
|
|
llvm::outs()
|
|
|
|
<< format("%16llx %8llx %5lld ", sym->get_addr(), 0, 0)
|
|
|
|
<< sym->name << "\n";
|
2020-10-29 06:24:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|