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 21:07:00 +09:00
parent 22018cc5c0
commit 2f81d76add
3 changed files with 20 additions and 6 deletions

View File

@ -312,8 +312,9 @@ static void check_duplicate_symbols() {
const ELF64LE::Sym &esym = file->elf_syms[i];
Symbol &sym = *file->symbols[i];
bool is_weak = (esym.getBinding() == STB_WEAK);
bool is_unique = (esym.getBinding() == STB_GNU_UNIQUE);
return esym.isDefined() && !is_weak && !is_unique && sym.file != file;
bool is_eliminated =
!esym.isAbsolute() && !esym.isCommon() && !file->sections[esym.st_shndx];
return esym.isDefined() && !is_weak && !is_eliminated && sym.file != file;
};
tbb::parallel_for_each(out::objs, [&](ObjectFile *file) {

3
mold.h
View File

@ -274,6 +274,7 @@ public:
ArrayRef<ELF64LE::Rela> rels;
std::vector<StringPieceRef> rel_pieces;
MergeableSection *mergeable = nullptr;
bool is_comdat_member = false;
bool is_alive = true;
};
@ -871,6 +872,8 @@ inline u64 Symbol::get_addr() const {
if (copyrel_offset != -1)
return out::copyrel->shdr.sh_addr + copyrel_offset;
if (input_section) {
if (!input_section->is_alive)
message("file=" + toString(file) + " sym=" + name);
assert(input_section->is_alive);
return input_section->get_addr() + value;
}

View File

@ -98,6 +98,14 @@ void ObjectFile::initialize_sections() {
}
}
}
// Set is_comdat_member bits.
for (auto &pair : comdat_groups) {
ArrayRef<ELF64LE::Word> entries = pair.second;
for (u32 i : entries)
if (this->sections[i])
this->sections[i]->is_comdat_member = true;
}
}
void ObjectFile::initialize_symbols() {
@ -305,7 +313,9 @@ void ObjectFile::parse() {
// 4. Unclaimed (nonexistent) symbol
//
// Ties are broken by file priority.
static u64 get_rank(InputFile *file, const ELF64LE::Sym &esym) {
static u64 get_rank(InputFile *file, const ELF64LE::Sym &esym, InputSection *isec) {
if (isec && isec->is_comdat_member)
return file->priority;
if (esym.isUndefined()) {
assert(esym.getBinding() == STB_WEAK);
return ((u64)2 << 32) + file->priority;
@ -320,7 +330,7 @@ static u64 get_rank(const Symbol &sym) {
return (u64)4 << 32;
if (sym.is_placeholder)
return ((u64)3 << 32) + sym.file->priority;
return get_rank(sym.file, *sym.esym);
return get_rank(sym.file, *sym.esym, sym.input_section);
}
void ObjectFile::maybe_override_symbol(Symbol &sym, int symidx) {
@ -331,7 +341,7 @@ void ObjectFile::maybe_override_symbol(Symbol &sym, int symidx) {
std::lock_guard lock(sym.mu);
u64 new_rank = get_rank(this, esym);
u64 new_rank = get_rank(this, esym, isec);
u64 existing_rank = get_rank(sym);
if (new_rank < existing_rank) {
@ -735,7 +745,7 @@ void SharedFile::resolve_symbols() {
std::lock_guard lock(sym.mu);
u64 new_rank = get_rank(this, esym);
u64 new_rank = get_rank(this, esym, nullptr);
u64 existing_rank = get_rank(sym);
if (new_rank < existing_rank) {