mirror of
https://github.com/rui314/mold.git
synced 2024-12-28 10:54:56 +03:00
temporary
This commit is contained in:
parent
0c2e3e30be
commit
86781e9b64
@ -173,15 +173,12 @@ public:
|
|||||||
void copy_to(uint8_t *buf);
|
void copy_to(uint8_t *buf);
|
||||||
uint64_t get_size() const;
|
uint64_t get_size() const;
|
||||||
|
|
||||||
uint64_t get_alignment() const {
|
|
||||||
return (hdr->sh_addralign == 0) ? 1 : hdr->sh_addralign;
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectFile *file;
|
ObjectFile *file;
|
||||||
OutputSection *output_section;
|
OutputSection *output_section;
|
||||||
StringRef output_section_name;
|
StringRef output_section_name;
|
||||||
uint64_t output_file_offset;
|
uint64_t output_file_offset;
|
||||||
int64_t offset = -1;
|
int64_t offset = -1;
|
||||||
|
uint32_t alignment;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const ELF64LE::Shdr *hdr;
|
const ELF64LE::Shdr *hdr;
|
||||||
|
@ -24,8 +24,12 @@ InputSection::InputSection(ObjectFile *file, const ELF64LE::Shdr *hdr, StringRef
|
|||||||
this->name = name;
|
this->name = name;
|
||||||
this->output_section = get_output_section(name);
|
this->output_section = get_output_section(name);
|
||||||
|
|
||||||
if (hdr->sh_addralign > UINT32_MAX)
|
uint64_t align = (hdr->sh_addralign == 0) ? 1 : hdr->sh_addralign;
|
||||||
|
if (align > UINT32_MAX)
|
||||||
error(toString(file) + ": section sh_addralign is too large");
|
error(toString(file) + ": section sh_addralign is too large");
|
||||||
|
if (__builtin_popcount(align) != 1)
|
||||||
|
error(toString(file) + ": section sh_addralign is not a power of two");
|
||||||
|
this->alignment = align;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t InputSection::get_size() const {
|
uint64_t InputSection::get_size() const {
|
||||||
|
8
main.cc
8
main.cc
@ -178,7 +178,7 @@ int main(int argc, char **argv) {
|
|||||||
uint64_t off = 0;
|
uint64_t off = 0;
|
||||||
for (OutputSection *osec : output_sections) {
|
for (OutputSection *osec : output_sections) {
|
||||||
for (InputSection *isec : osec->sections) {
|
for (InputSection *isec : osec->sections) {
|
||||||
off = align_to(off, isec->get_alignment());
|
off = align_to(off, isec->alignment);
|
||||||
isec->output_file_offset = off;
|
isec->output_file_offset = off;
|
||||||
off += isec->get_size();
|
off += isec->get_size();
|
||||||
}
|
}
|
||||||
@ -189,9 +189,9 @@ int main(int argc, char **argv) {
|
|||||||
int max_align = 0;
|
int max_align = 0;
|
||||||
for (OutputSection *osec : output_sections) {
|
for (OutputSection *osec : output_sections) {
|
||||||
for (InputSection *isec : osec->sections) {
|
for (InputSection *isec : osec->sections) {
|
||||||
if (isec->get_alignment() > max_align) {
|
if (isec->alignment > max_align) {
|
||||||
llvm::outs() << toString(isec) << " " << isec->get_alignment() << "\n";
|
llvm::outs() << toString(isec) << " " << isec->alignment << "\n";
|
||||||
max_align = isec->get_alignment();
|
max_align = isec->alignment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user