mirror of
https://github.com/rui314/mold.git
synced 2024-12-26 01:44:29 +03:00
temporary
This commit is contained in:
parent
9fec3b9728
commit
7547f74740
@ -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
4
mold.h
@ -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;
|
||||
|
@ -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));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user