1
1
mirror of https://github.com/rui314/mold.git synced 2024-12-27 02:13:33 +03:00

temporary

This commit is contained in:
Rui Ueyama 2020-11-08 12:36:08 +09:00
parent e42ea4139e
commit da7aac49e4
4 changed files with 15 additions and 15 deletions

View File

@ -155,6 +155,6 @@ void InputSection::scan_relocations() {
}
}
std::string toString(InputSection *isec) {
return (toString(isec->file) + ":(" + isec->name + ")").str();
std::string toString(InputChunk *chunk) {
return (toString(chunk->file) + ":(" + chunk->name + ")").str();
}

12
main.cc
View File

@ -187,7 +187,7 @@ static void bin_sections(std::vector<ObjectFile *> &files) {
int num_osec = OutputSection::instances.size();
std::vector<std::vector<std::vector<InputSection *>>> groups(slices.size());
std::vector<std::vector<std::vector<InputChunk *>>> groups(slices.size());
for (int i = 0; i < groups.size(); i++)
groups[i].resize(num_osec);
@ -204,7 +204,7 @@ static void bin_sections(std::vector<ObjectFile *> &files) {
std::vector<int> sizes(num_osec);
for (ArrayRef<std::vector<InputSection *>> group : groups)
for (ArrayRef<std::vector<InputChunk *>> group : groups)
for (int i = 0; i < group.size(); i++)
sizes[i] += group[i].size();
@ -212,7 +212,7 @@ static void bin_sections(std::vector<ObjectFile *> &files) {
OutputSection::instances[j]->sections.reserve(sizes[j]);
for (int i = 0; i < groups.size(); i++) {
std::vector<InputSection *> &sections = OutputSection::instances[j]->sections;
std::vector<InputChunk *> &sections = OutputSection::instances[j]->sections;
sections.insert(sections.end(), groups[i][j].begin(), groups[i][j].end());
}
});
@ -223,7 +223,7 @@ static void set_isec_offsets() {
if (osec->sections.empty())
return;
std::vector<ArrayRef<InputSection *>> slices = split(osec->sections, 100000);
std::vector<ArrayRef<InputChunk *>> slices = split(osec->sections, 100000);
std::vector<u64> size(slices.size());
std::vector<u32> alignments(slices.size());
@ -231,7 +231,7 @@ static void set_isec_offsets() {
u64 off = 0;
u32 align = 1;
for (InputSection *isec : slices[i]) {
for (InputChunk *isec : slices[i]) {
off = align_to(off, isec->shdr.sh_addralign);
isec->offset = off;
off += isec->shdr.sh_size;
@ -249,7 +249,7 @@ static void set_isec_offsets() {
start[i] = align_to(start[i - 1] + size[i], align);
tbb::parallel_for(1, (int)slices.size(), [&](int i) {
for (InputSection *isec : slices[i])
for (InputChunk *isec : slices[i])
isec->offset += start[i];
});

View File

@ -6,7 +6,7 @@ using namespace llvm;
void print_map(ArrayRef<ObjectFile *> files, ArrayRef<OutputChunk *> output_sections) {
// Construct a section-to-symbol map.
std::unordered_multimap<InputSection *, Symbol *> map;
std::unordered_multimap<InputChunk *, Symbol *> map;
for (ObjectFile *file : files)
for (Symbol *sym : file->symbols)
if (sym->file == file && sym->input_section)
@ -20,7 +20,7 @@ void print_map(ArrayRef<ObjectFile *> files, ArrayRef<OutputChunk *> output_sect
(u64)chunk->shdr.sh_addralign)
<< chunk->name << "\n";
for (InputSection *isec : chunk->sections) {
for (InputChunk *isec : chunk->sections) {
llvm::outs() << format("%16llx %8llx %5lld ",
chunk->shdr.sh_addr + isec->offset,
(u64)isec->shdr.sh_size,

10
mold.h
View File

@ -249,7 +249,7 @@ public:
u32 merged_size = 0;
};
std::string toString(InputSection *isec);
std::string toString(InputChunk *isec);
inline u64 align_to(u64 val, u64 align) {
assert(__builtin_popcount(align) == 1);
@ -270,7 +270,7 @@ public:
int shndx = 0;
bool starts_new_ptload = false;
ELF64LE::Shdr shdr = {};
std::vector<InputSection *> sections;
std::vector<InputChunk *> sections;
};
// ELF header
@ -337,13 +337,13 @@ public:
void copy_to(u8 *buf) override {
if (shdr.sh_type != llvm::ELF::SHT_NOBITS)
tbb::parallel_for_each(sections, [&](InputSection *isec) { isec->copy_to(buf); });
tbb::parallel_for_each(sections, [&](InputChunk *isec) { isec->copy_to(buf); });
}
bool empty() const {
if (!sections.empty())
for (InputSection *isec : sections)
if (isec->shdr.sh_size)
for (InputChunk *chunk : sections)
if (chunk->shdr.sh_size)
return false;
return true;
}