mirror of
https://github.com/rui314/mold.git
synced 2024-12-27 10:23:41 +03:00
temporary
This commit is contained in:
parent
79d4986f5d
commit
1f1c217d63
16
main.cc
16
main.cc
@ -247,10 +247,16 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
auto bin_sections = [&]() {
|
||||
for (ObjectFile *file : files)
|
||||
for (InputSection *isec : file->sections)
|
||||
if (isec)
|
||||
isec->output_section->chunks.push_back(isec);
|
||||
for (ObjectFile *file : files) {
|
||||
for (InputSection *isec : file->sections) {
|
||||
if (!isec)
|
||||
continue;
|
||||
OutputSection *osec = isec->output_section;
|
||||
osec->shdr.sh_addralign =
|
||||
std::max<uint32_t>(osec->shdr.sh_addralign, isec->alignment);
|
||||
osec->chunks.push_back(isec);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
auto scan_rels = [&]() {
|
||||
@ -307,7 +313,7 @@ int main(int argc, char **argv) {
|
||||
{
|
||||
MyTimer t("file_offset", before_copy);
|
||||
for (OutputChunk *chunk : output_chunks) {
|
||||
filesize = align_to(filesize, chunk->alignment);
|
||||
filesize = align_to(filesize, chunk->shdr.sh_addralign);
|
||||
chunk->set_fileoff(filesize);
|
||||
filesize += chunk->get_size();
|
||||
}
|
||||
|
5
mold.h
5
mold.h
@ -216,6 +216,8 @@ inline uint64_t align_to(uint64_t val, uint64_t align) {
|
||||
|
||||
class OutputChunk {
|
||||
public:
|
||||
OutputChunk() { shdr.sh_addralign = 1; }
|
||||
|
||||
virtual void copy_to(uint8_t *buf) = 0;
|
||||
virtual void relocate(uint8_t *buf) {}
|
||||
virtual void set_fileoff(uint64_t off) { fileoff = off; }
|
||||
@ -223,7 +225,6 @@ public:
|
||||
|
||||
StringRef name;
|
||||
uint64_t fileoff;
|
||||
uint32_t alignment = 1;
|
||||
ELF64LE::Shdr shdr = {};
|
||||
};
|
||||
|
||||
@ -307,6 +308,8 @@ public:
|
||||
|
||||
void set_fileoff(uint64_t off) override;
|
||||
|
||||
void set_alignment(uint32_t align) { shdr.sh_addralign = align; }
|
||||
|
||||
std::vector<InputSection *> chunks;
|
||||
static std::vector<OutputSection *> all_instances;
|
||||
};
|
||||
|
@ -89,7 +89,7 @@ void OutputPhdr::construct(std::vector<OutputChunk *> &chunks) {
|
||||
}
|
||||
|
||||
for (Phdr &ent : entries)
|
||||
ent.members.front()->alignment = PAGE_SIZE;
|
||||
ent.members.front()->shdr.sh_addralign = PAGE_SIZE;
|
||||
}
|
||||
|
||||
void OutputPhdr::copy_to(uint8_t *buf) {
|
||||
|
Loading…
Reference in New Issue
Block a user