2020-10-28 14:49:43 +03:00
|
|
|
#include "mold.h"
|
2020-10-29 06:24:54 +03:00
|
|
|
|
2020-12-10 16:32:47 +03:00
|
|
|
#include <iomanip>
|
|
|
|
#include <ios>
|
2020-12-12 14:34:13 +03:00
|
|
|
#include <unordered_map>
|
2020-10-29 06:24:54 +03:00
|
|
|
|
2020-11-24 08:31:05 +03:00
|
|
|
void print_map() {
|
2020-10-29 06:24:54 +03:00
|
|
|
// Construct a section-to-symbol map.
|
2020-12-12 14:34:13 +03:00
|
|
|
std::unordered_map<InputChunk *, std::vector<Symbol *>> map;
|
2020-11-24 08:31:05 +03:00
|
|
|
for (ObjectFile *file : out::objs)
|
2020-10-29 06:24:54 +03:00
|
|
|
for (Symbol *sym : file->symbols)
|
|
|
|
if (sym->file == file && sym->input_section)
|
2020-12-12 14:34:13 +03:00
|
|
|
map[sym->input_section].push_back(sym);
|
|
|
|
|
|
|
|
for (auto &pair : map) {
|
|
|
|
std::vector<Symbol *> &vec = pair.second;
|
2020-12-21 12:42:14 +03:00
|
|
|
sort(vec, [](Symbol *a, Symbol *b) { return a->value < b->value; });
|
2020-12-12 14:34:13 +03:00
|
|
|
}
|
2020-10-29 06:24:54 +03:00
|
|
|
|
2020-12-10 16:32:47 +03:00
|
|
|
std::cout << " VMA Size Align Out In Symbol\n";
|
2020-11-24 08:31:05 +03:00
|
|
|
for (OutputChunk *osec : out::chunks) {
|
2020-12-10 16:32:47 +03:00
|
|
|
std::cout << std::setw(16) << (u64)osec->shdr.sh_addr
|
2020-12-12 09:09:50 +03:00
|
|
|
<< std::setw(9) << (u64)osec->shdr.sh_size
|
|
|
|
<< std::setw(6) << (u64)osec->shdr.sh_addralign
|
2020-12-10 16:32:47 +03:00
|
|
|
<< " " << 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-12-10 16:32:47 +03:00
|
|
|
std::cout << std::setw(16) << (osec->shdr.sh_addr + mem->offset)
|
2020-12-12 09:09:50 +03:00
|
|
|
<< std::setw(9) << (u64)mem->shdr.sh_size
|
|
|
|
<< std::setw(6) << (u64)mem->shdr.sh_addralign
|
|
|
|
<< " " << to_string(mem) << "\n";
|
2020-10-29 06:24:54 +03:00
|
|
|
|
2020-12-12 14:34:13 +03:00
|
|
|
auto it = map.find(mem);
|
|
|
|
if (it == map.end())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
std::vector<Symbol *> syms = it->second;
|
|
|
|
for (Symbol *sym : syms)
|
2020-12-10 16:32:47 +03:00
|
|
|
std::cout << std::setw(16) << sym->get_addr()
|
2020-12-12 09:09:50 +03:00
|
|
|
<< " 0 0 "
|
2020-12-10 16:32:47 +03:00
|
|
|
<< sym->name << "\n";
|
2020-10-29 06:24:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|