1
1
mirror of https://github.com/rui314/mold.git synced 2024-12-26 01:44:29 +03:00

temporary

This commit is contained in:
Rui Ueyama 2020-11-08 15:56:17 +09:00
parent 9fec3b9728
commit 7547f74740
3 changed files with 7 additions and 15 deletions

View File

@ -158,7 +158,6 @@ void InputSection::scan_relocations() {
MergeableSection::MergeableSection(InputSection *isec, ArrayRef<u8> contents)
: InputChunk(MERGEABLE, isec->file, isec->shdr, isec->name),
original(isec),
parent(*MergedSection::get_instance(isec->name, isec->shdr.sh_flags,
isec->shdr.sh_type)) {
StringRef data((const char *)&contents[0], contents.size());

4
mold.h
View File

@ -182,7 +182,7 @@ public:
StringRef name;
ObjectFile *file = nullptr;
InputChunk *input_section = nullptr;
InputSection *input_section = nullptr;
StringPieceRef piece_ref;
u64 value = 0;
@ -246,13 +246,13 @@ public:
ArrayRef<ELF64LE::Rela> rels;
std::vector<StringPieceRef> rel_pieces;
MergeableSection *mergeable = nullptr;
};
class MergeableSection : public InputChunk {
public:
MergeableSection(InputSection *isec, ArrayRef<u8> contents);
InputSection *original;
MergedSection &parent;
std::vector<StringPieceRef> pieces;
u32 size = 0;

View File

@ -185,6 +185,7 @@ void ObjectFile::initialize_mergeable_sections() {
if (isec && is_mergeable(isec->shdr)) {
ArrayRef<u8> contents = CHECK(obj.getSectionContents(isec->shdr), this);
mergeable_sections.emplace_back(isec, contents);
isec->mergeable = &mergeable_sections.back();
sections[i] = nullptr;
}
}
@ -215,21 +216,13 @@ void ObjectFile::initialize_mergeable_sections() {
Symbol &sym = *symbols[sym_idx];
if (sym.type != STT_SECTION)
continue;
if (!is_mergeable(sym.input_section->shdr))
MergeableSection *mergeable = sym.input_section->mergeable;
if (!mergeable)
continue;
ArrayRef<StringPieceRef> pieces;
for (MergeableSection &isec : mergeable_sections) {
if (isec.original == sym.input_section) {
pieces = isec.pieces;
break;
}
}
assert(!pieces.empty());
u32 offset = sym.value + rel.r_addend;
const StringPieceRef *ref = binary_search(pieces, offset);
const StringPieceRef *ref = binary_search(mergeable->pieces, offset);
if (!ref)
error(toString(this) + ": bad relocation at " + std::to_string(sym_idx));