[PATCH] D111871: [ELF] Let sections reach the end of the address space

Hristo Venev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 4 09:31:32 PDT 2021


hvenev added a comment.

In D111871#3108247 <https://reviews.llvm.org/D111871#3108247>, @jhenderson wrote:

> In D111871#3107393 <https://reviews.llvm.org/D111871#3107393>, @hvenev wrote:
>
>> There already are test cases for overflowing by 1 byte. These two tests are more or less copies of those, except that we exactly reach the end.
>>
>> Regarding the empty section thing, that's a problem with setting the base address rather than the size. It is something that the linker script interpreter does not handle well, especially in the 64-bit case.
>
> I'm not sure that it is? You can have an empty section immediately following a non-empty section after all, so you'd just need a non-empty section that ends at the end of the address space, followed by an empty section.

The current linker script logic does no overflow checking. Instead, it always truncates addresses to 64 bits. This means that e.g. a section that starts at the end of the 64-bit address space is actually moved to address 0. I think this is a bug.

An empty section at the end of the address space has an invalid base address no matter the section size. Ideally such addresses should not be produced by the linker script interpreter, so in such a test case we should not even reach Writer<ELFT>::checkSections.

If I add tests with empty sections at the end of the address space, should I have the 64-bit case expect an error and add XFAIL?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111871/new/

https://reviews.llvm.org/D111871



More information about the llvm-commits mailing list