mirror of
https://github.com/rui314/mold.git
synced 2024-11-13 09:39:13 +03:00
wip
This commit is contained in:
parent
4816dd8fe1
commit
b70c24c968
2
icf.cc
2
icf.cc
@ -322,7 +322,7 @@ void icf_sections() {
|
||||
tbb::parallel_for_each(entries, [&](Entry &ent) {
|
||||
InputSection &isec = *ent.isec;
|
||||
if (isec.leader)
|
||||
isec.file->kill(isec.get_section_idx());
|
||||
isec.file->kill(isec.section_idx);
|
||||
});
|
||||
|
||||
if (config.print_icf_sections) {
|
||||
|
@ -11,16 +11,6 @@ std::string_view InputChunk::get_contents() const {
|
||||
return file->get_string(shdr);
|
||||
}
|
||||
|
||||
i64 InputChunk::get_section_idx() const {
|
||||
assert(&file->elf_sections.front() <= &shdr &&
|
||||
&shdr < &file->elf_sections.back());
|
||||
return &shdr - &file->elf_sections.front();
|
||||
}
|
||||
|
||||
i64 InputChunk::get_priority() const {
|
||||
return ((i64)file->priority << 32) | get_section_idx();
|
||||
}
|
||||
|
||||
static std::string rel_to_string(u64 r_type) {
|
||||
switch (r_type) {
|
||||
case R_X86_64_NONE: return "R_X86_64_NONE";
|
||||
@ -486,6 +476,10 @@ void InputSection::scan_relocations() {
|
||||
}
|
||||
}
|
||||
|
||||
i64 InputSection::get_priority() const {
|
||||
return ((i64)file->priority << 32) | section_idx;
|
||||
}
|
||||
|
||||
static size_t find_null(std::string_view data, u64 entsize) {
|
||||
if (entsize == 1)
|
||||
return data.find('\0');
|
||||
|
11
mold.h
11
mold.h
@ -300,15 +300,13 @@ public:
|
||||
virtual void copy_buf() {}
|
||||
inline u64 get_addr() const;
|
||||
std::string_view get_contents() const;
|
||||
i64 get_section_idx() const;
|
||||
i64 get_priority() const;
|
||||
|
||||
ObjectFile *file;
|
||||
const ElfShdr &shdr;
|
||||
OutputSection *output_section = nullptr;
|
||||
|
||||
std::string_view name;
|
||||
u32 offset;
|
||||
u32 offset = -1;
|
||||
|
||||
protected:
|
||||
InputChunk(ObjectFile *file, const ElfShdr &shdr, std::string_view name);
|
||||
@ -382,14 +380,16 @@ struct CieRecord {
|
||||
|
||||
class InputSection : public InputChunk {
|
||||
public:
|
||||
InputSection(ObjectFile *file, const ElfShdr &shdr, std::string_view name)
|
||||
: InputChunk(file, shdr, name) {}
|
||||
InputSection(ObjectFile *file, const ElfShdr &shdr, std::string_view name,
|
||||
i64 section_idx)
|
||||
: InputChunk(file, shdr, name), section_idx(section_idx) {}
|
||||
|
||||
void copy_buf() override;
|
||||
void scan_relocations();
|
||||
void report_undefined_symbols();
|
||||
void apply_reloc_alloc(u8 *base);
|
||||
void apply_reloc_nonalloc(u8 *base);
|
||||
i64 get_priority() const;
|
||||
|
||||
std::span<ElfRela> rels;
|
||||
std::vector<bool> has_fragments;
|
||||
@ -397,6 +397,7 @@ public:
|
||||
std::vector<RelType> rel_types;
|
||||
std::span<FdeRecord> fdes;
|
||||
u64 reldyn_offset = 0;
|
||||
u32 section_idx = -1;
|
||||
bool is_comdat_member = false;
|
||||
bool is_ehframe = false;
|
||||
|
||||
|
@ -155,7 +155,7 @@ void ObjectFile::initialize_sections() {
|
||||
counter.inc();
|
||||
|
||||
std::string_view name = shstrtab.data() + shdr.sh_name;
|
||||
this->sections[i] = new InputSection(this, shdr, name);
|
||||
this->sections[i] = new InputSection(this, shdr, name, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -703,7 +703,7 @@ void ObjectFile::convert_common_symbols() {
|
||||
shdr->sh_size = elf_syms[i].st_size;
|
||||
shdr->sh_addralign = 1;
|
||||
|
||||
auto *isec = new InputSection(this, *shdr, ".bss");
|
||||
auto *isec = new InputSection(this, *shdr, ".bss", sections.size());
|
||||
isec->output_section = bss;
|
||||
sections.push_back(isec);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user