1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-11 16:58:12 +03:00

temporary

This commit is contained in:
Rui Ueyama 2020-12-01 17:16:28 +09:00
parent 31388ddc57
commit 22018cc5c0
2 changed files with 14 additions and 2 deletions

5
mold.h
View File

@ -274,6 +274,7 @@ public:
ArrayRef<ELF64LE::Rela> rels;
std::vector<StringPieceRef> rel_pieces;
MergeableSection *mergeable = nullptr;
bool is_alive = true;
};
class MergeableSection : public InputChunk {
@ -869,8 +870,10 @@ inline u64 Symbol::get_addr() const {
return piece_ref.piece->get_addr() + piece_ref.addend;
if (copyrel_offset != -1)
return out::copyrel->shdr.sh_addr + copyrel_offset;
if (input_section)
if (input_section) {
assert(input_section->is_alive);
return input_section->get_addr() + value;
}
if (file && file->is_dso && copyrel_offset == -1)
return get_plt_addr();
return value;

View File

@ -440,6 +440,9 @@ void ObjectFile::handle_undefined_weak_symbols() {
}
void ObjectFile::resolve_comdat_groups() {
if (!is_alive)
return;
for (auto &pair : comdat_groups) {
ComdatGroup *group = pair.first;
ObjectFile *cur = group->file;
@ -450,14 +453,20 @@ void ObjectFile::resolve_comdat_groups() {
}
void ObjectFile::eliminate_duplicate_comdat_groups() {
if (!is_alive)
return;
for (auto &pair : comdat_groups) {
ComdatGroup *group = pair.first;
if (group->file == this)
continue;
ArrayRef<ELF64LE::Word> entries = pair.second;
for (u32 i : entries)
for (u32 i : entries) {
if (sections[i])
sections[i]->is_alive = false;
sections[i] = nullptr;
}
static Counter counter("removed_comdat_mem");
counter.inc(entries.size());