I found that this check still may be useful in some cases.
At fact since we use uint32_t alignment, then maximum value
that is valid for us is 0x80000000. But some broken files,
for example file from testcase may have greater value.
Because of that offset calculation overflow and crash happens.
Details
Diff Detail
Event Timeline
ELF/InputSection.cpp | ||
---|---|---|
59 | Technically, an alignment greater than 2^32 is not invalid, so this error message is wrong. Please separate the two conditions and print out different messages sh_addralign too large sh_addralign is not a power of 2 |
ELF/InputSection.cpp | ||
---|---|---|
57 | Also, please leave a comment here to say that we reject object files having insanely large alignment requirements and may want to relax this limitation in the future. binutils-ish tools have incredible long lifetime -- GNU ld has been used for decades now for example. We want to leave a hint why we are doing this, so that people who look at this code 10 years later won't have to wonder why we reject 4GB-aligned sections when they are creating 10 terabyte executable. |
Also, please leave a comment here to say that we reject object files having insanely large alignment requirements and may want to relax this limitation in the future.
binutils-ish tools have incredible long lifetime -- GNU ld has been used for decades now for example. We want to leave a hint why we are doing this, so that people who look at this code 10 years later won't have to wonder why we reject 4GB-aligned sections when they are creating 10 terabyte executable.