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)
|
MergeableSection::MergeableSection(InputSection *isec, ArrayRef<u8> contents)
|
||||||
: InputChunk(MERGEABLE, isec->file, isec->shdr, isec->name),
|
: InputChunk(MERGEABLE, isec->file, isec->shdr, isec->name),
|
||||||
original(isec),
|
|
||||||
parent(*MergedSection::get_instance(isec->name, isec->shdr.sh_flags,
|
parent(*MergedSection::get_instance(isec->name, isec->shdr.sh_flags,
|
||||||
isec->shdr.sh_type)) {
|
isec->shdr.sh_type)) {
|
||||||
StringRef data((const char *)&contents[0], contents.size());
|
StringRef data((const char *)&contents[0], contents.size());
|
||||||
|
4
mold.h
4
mold.h
@ -182,7 +182,7 @@ public:
|
|||||||
|
|
||||||
StringRef name;
|
StringRef name;
|
||||||
ObjectFile *file = nullptr;
|
ObjectFile *file = nullptr;
|
||||||
InputChunk *input_section = nullptr;
|
InputSection *input_section = nullptr;
|
||||||
StringPieceRef piece_ref;
|
StringPieceRef piece_ref;
|
||||||
|
|
||||||
u64 value = 0;
|
u64 value = 0;
|
||||||
@ -246,13 +246,13 @@ public:
|
|||||||
|
|
||||||
ArrayRef<ELF64LE::Rela> rels;
|
ArrayRef<ELF64LE::Rela> rels;
|
||||||
std::vector<StringPieceRef> rel_pieces;
|
std::vector<StringPieceRef> rel_pieces;
|
||||||
|
MergeableSection *mergeable = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MergeableSection : public InputChunk {
|
class MergeableSection : public InputChunk {
|
||||||
public:
|
public:
|
||||||
MergeableSection(InputSection *isec, ArrayRef<u8> contents);
|
MergeableSection(InputSection *isec, ArrayRef<u8> contents);
|
||||||
|
|
||||||
InputSection *original;
|
|
||||||
MergedSection &parent;
|
MergedSection &parent;
|
||||||
std::vector<StringPieceRef> pieces;
|
std::vector<StringPieceRef> pieces;
|
||||||
u32 size = 0;
|
u32 size = 0;
|
||||||
|
@ -185,6 +185,7 @@ void ObjectFile::initialize_mergeable_sections() {
|
|||||||
if (isec && is_mergeable(isec->shdr)) {
|
if (isec && is_mergeable(isec->shdr)) {
|
||||||
ArrayRef<u8> contents = CHECK(obj.getSectionContents(isec->shdr), this);
|
ArrayRef<u8> contents = CHECK(obj.getSectionContents(isec->shdr), this);
|
||||||
mergeable_sections.emplace_back(isec, contents);
|
mergeable_sections.emplace_back(isec, contents);
|
||||||
|
isec->mergeable = &mergeable_sections.back();
|
||||||
sections[i] = nullptr;
|
sections[i] = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -215,21 +216,13 @@ void ObjectFile::initialize_mergeable_sections() {
|
|||||||
Symbol &sym = *symbols[sym_idx];
|
Symbol &sym = *symbols[sym_idx];
|
||||||
if (sym.type != STT_SECTION)
|
if (sym.type != STT_SECTION)
|
||||||
continue;
|
continue;
|
||||||
if (!is_mergeable(sym.input_section->shdr))
|
|
||||||
|
MergeableSection *mergeable = sym.input_section->mergeable;
|
||||||
|
if (!mergeable)
|
||||||
continue;
|
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;
|
u32 offset = sym.value + rel.r_addend;
|
||||||
const StringPieceRef *ref = binary_search(pieces, offset);
|
const StringPieceRef *ref = binary_search(mergeable->pieces, offset);
|
||||||
if (!ref)
|
if (!ref)
|
||||||
error(toString(this) + ": bad relocation at " + std::to_string(sym_idx));
|
error(toString(this) + ": bad relocation at " + std::to_string(sym_idx));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user