1
1
mirror of https://github.com/rui314/mold.git synced 2024-12-28 19:04:27 +03:00

temporary

This commit is contained in:
Rui Ueyama 2020-11-03 20:10:14 +09:00
parent 0dac0873ed
commit 5d1407ee4a
2 changed files with 14 additions and 21 deletions

26
main.cc
View File

@ -237,10 +237,10 @@ static void scan_rels(ArrayRef<ObjectFile *> files) {
num_relplt += file->num_relplt;
});
out::got->size = num_got * 8;
out::gotplt->size = num_gotplt * 8;
out::plt->size = num_plt * 16;
out::relplt->size = num_relplt * sizeof(ELF64LE::Rela);
out::got->shdr.sh_size = num_got * 8;
out::gotplt->shdr.sh_size = num_gotplt * 8;
out::plt->shdr.sh_size = num_plt * 16;
out::relplt->shdr.sh_size = num_relplt * sizeof(ELF64LE::Rela);
}
static void assign_got_offsets(ArrayRef<ObjectFile *> files) {
@ -248,10 +248,6 @@ static void assign_got_offsets(ArrayRef<ObjectFile *> files) {
u32 gotplt_offset = 0;
u32 plt_offset = 0;
out::got->symbols.reserve(out::got->size / 8);
out::gotplt->symbols.reserve(out::gotplt->size / 8);
out::plt->symbols.reserve(out::plt->size / 16);
for (ObjectFile *file : files) {
for (Symbol *sym : file->symbols) {
// _nl_current_LC_ADDRESS
@ -286,9 +282,9 @@ static void assign_got_offsets(ArrayRef<ObjectFile *> files) {
}
}
assert(got_offset == out::got->size);
assert(gotplt_offset == out::gotplt->size);
assert(plt_offset == out::plt->size);
assert(got_offset == out::got->shdr.sh_size);
assert(gotplt_offset == out::gotplt->shdr.sh_size);
assert(plt_offset == out::plt->shdr.sh_size);
}
// We want to sort output sections in the following order.
@ -594,13 +590,13 @@ int main(int argc, char **argv) {
if (!osec->empty())
output_chunks.push_back(osec);
if (out::got->size)
if (out::got->shdr.sh_size)
output_chunks.push_back(out::got);
if (out::plt->size)
if (out::plt->shdr.sh_size)
output_chunks.push_back(out::plt);
if (out::gotplt->size)
if (out::gotplt->shdr.sh_size)
output_chunks.push_back(out::gotplt);
if (out::relplt->size)
if (out::relplt->shdr.sh_size)
output_chunks.push_back(out::relplt);
sort_output_chunks(output_chunks);

9
mold.h
View File

@ -374,9 +374,8 @@ public:
void relocate(u8 *buf) override;
u64 get_size() const override { return size; }
u64 get_size() const override { return shdr.sh_size; }
u64 size = 0;
std::vector<std::pair<Kind, Symbol *>> symbols;
};
@ -391,8 +390,7 @@ public:
void relocate(u8 *buf) override;
u64 get_size() const override { return size; }
u64 size = 0;
u64 get_size() const override { return shdr.sh_size; }
std::vector<Symbol *> symbols;
};
@ -409,8 +407,7 @@ public:
void relocate(u8 *buf) override;
u64 get_size() const override { return size; }
u64 size = 0;
u64 get_size() const override { return shdr.sh_size; }
};
class ShstrtabSection : public OutputChunk {