New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sd-boot/sd-stub fails to build with clang-18's lld due to overlapping sections #31637
Labels
Comments
mrc0mmand
added
sd-boot/sd-stub/bootctl
bug 🐛
Programming errors, that need preferential fixing
labels
Mar 5, 2024
keszybz
added a commit
to keszybz/systemd
that referenced
this issue
Mar 14, 2024
RuntimeError is documented as "Unspecified run-time error". It doesn't make much sense for Python. (It originated in Java, where exceptions that can be thrown by a function are declared in the function signature. All code calling such a function must either explicitly catch all possible exception types, or allow them to propagate by listing them in its own exception type list. This is nice in theory, but in practice very annoying. Especially during development, when the list of possible exception types is not finalized, we would end up adding and removing exceptions to functions signatures all the time. Also for code which is designed to call functions recursively, we would soon end up with all functions declaring all possible exception types… To avoid this, people would quite often do fake handling with a block that either prints and ignores an exception, or has just a comment like "fix me later", or even nothing. This often lead to people forgetting to adjust this later on and production code containing such constructs. An escape hatch was opened with RuntimeException and its subclasses, which do not need to be pre-declared. Various memory-related exceptions were added as subclasses of RuntimeException. But later on, people starting using this to not to have to declare all exception types everywhere.) In Python, exceptions do no have to be pre-declared, and for code which just encounters a failure, we should raise a specific exception type. The catch-all class for unexpected input is ValueError. For systemd#31637: BadSectionError: Section '.data' @0x28000 overlaps previous section @0x28000+0x300=@0x28300 Also, exception strings should not contain trailing periods, because they are often embedded in sentences.
keszybz
added a commit
to keszybz/systemd
that referenced
this issue
Mar 14, 2024
Resolves systemd#31637. clang-18 does the section setup differently than older versions. There is a bunch of ordering chagnes, but it also inserts the following: Sections: Idx Name Size VMA LMA File off Algn ... 9 .got 00000000 00000000000283c0 00000000000283c0 000283c0 2**3 CONTENTS, ALLOC, LOAD, DATA 10 .relro_padding 00000c40 00000000000283c0 00000000000283c0 000283c0 2**0 ALLOC 11 .data 00000024 00000000000293c0 00000000000293c0 000283c0 2**4 CONTENTS, ALLOC, LOAD, DATA ... This causes a problem for us, because we try to map the .got to .rodata, and the subsequent .data to .data, and round down the VMA to the nearest page, which causes the PE sections to overlap. llvm/llvm-project#66042 adds .relro_padding to make sure that the RELRO segment is properly write protected and allocated. For our binaries, the .got section is empty, so I think it we can skip it safely, and the .relro_padding section is not useful once .got has been dropped.
keszybz
added a commit
to keszybz/systemd
that referenced
this issue
Mar 17, 2024
Resolves systemd#31637. lld-18 does the section setup differently than older versions. There is a bunch of ordering chagnes, but it also inserts the following: Sections: Idx Name Size VMA LMA File off Algn ... 9 .got 00000000 00000000000283c0 00000000000283c0 000283c0 2**3 CONTENTS, ALLOC, LOAD, DATA 10 .relro_padding 00000c40 00000000000283c0 00000000000283c0 000283c0 2**0 ALLOC 11 .data 00000024 00000000000293c0 00000000000293c0 000283c0 2**4 CONTENTS, ALLOC, LOAD, DATA ... This causes a problem for us, because we try to map the .got to .rodata, and the subsequent .data to .data, and round down the VMA to the nearest page, which causes the PE sections to overlap. llvm/llvm-project#66042 adds .relro_padding to make sure that the RELRO segment is properly write protected and allocated. For our binaries, the .got section is empty, so we can skip it safely, and the .relro_padding section is not useful once .got has been dropped. To make sure that the code does not use the .got section unexpectedly, raise an error if a (non-empty) .got section is found.
chunyi-wu
pushed a commit
to chunyi-wu/systemd
that referenced
this issue
Apr 3, 2024
RuntimeError is documented as "Unspecified run-time error". It doesn't make much sense for Python. (It originated in Java, where exceptions that can be thrown by a function are declared in the function signature. All code calling such a function must either explicitly catch all possible exception types, or allow them to propagate by listing them in its own exception type list. This is nice in theory, but in practice very annoying. Especially during development, when the list of possible exception types is not finalized, we would end up adding and removing exceptions to functions signatures all the time. Also for code which is designed to call functions recursively, we would soon end up with all functions declaring all possible exception types… To avoid this, people would quite often do fake handling with a block that either prints and ignores an exception, or has just a comment like "fix me later", or even nothing. This often lead to people forgetting to adjust this later on and production code containing such constructs. An escape hatch was opened with RuntimeException and its subclasses, which do not need to be pre-declared. Various memory-related exceptions were added as subclasses of RuntimeException. But later on, people starting using this to not to have to declare all exception types everywhere.) In Python, exceptions do no have to be pre-declared, and for code which just encounters a failure, we should raise a specific exception type. The catch-all class for unexpected input is ValueError. For systemd#31637: BadSectionError: Section '.data' @0x28000 overlaps previous section @0x28000+0x300=@0x28300 Also, exception strings should not contain trailing periods, because they are often embedded in sentences.
chunyi-wu
pushed a commit
to chunyi-wu/systemd
that referenced
this issue
Apr 3, 2024
Resolves systemd#31637. lld-18 does the section setup differently than older versions. There is a bunch of ordering chagnes, but it also inserts the following: Sections: Idx Name Size VMA LMA File off Algn ... 9 .got 00000000 00000000000283c0 00000000000283c0 000283c0 2**3 CONTENTS, ALLOC, LOAD, DATA 10 .relro_padding 00000c40 00000000000283c0 00000000000283c0 000283c0 2**0 ALLOC 11 .data 00000024 00000000000293c0 00000000000293c0 000283c0 2**4 CONTENTS, ALLOC, LOAD, DATA ... This causes a problem for us, because we try to map the .got to .rodata, and the subsequent .data to .data, and round down the VMA to the nearest page, which causes the PE sections to overlap. llvm/llvm-project#66042 adds .relro_padding to make sure that the RELRO segment is properly write protected and allocated. For our binaries, the .got section is empty, so we can skip it safely, and the .relro_padding section is not useful once .got has been dropped. We don't expect .got sections, but they are apparently inserted on i386 and aarch64 builds. Emit a warning until we figure out why they are there.
keszybz
added a commit
to systemd/systemd-stable
that referenced
this issue
Apr 23, 2024
RuntimeError is documented as "Unspecified run-time error". It doesn't make much sense for Python. (It originated in Java, where exceptions that can be thrown by a function are declared in the function signature. All code calling such a function must either explicitly catch all possible exception types, or allow them to propagate by listing them in its own exception type list. This is nice in theory, but in practice very annoying. Especially during development, when the list of possible exception types is not finalized, we would end up adding and removing exceptions to functions signatures all the time. Also for code which is designed to call functions recursively, we would soon end up with all functions declaring all possible exception types… To avoid this, people would quite often do fake handling with a block that either prints and ignores an exception, or has just a comment like "fix me later", or even nothing. This often lead to people forgetting to adjust this later on and production code containing such constructs. An escape hatch was opened with RuntimeException and its subclasses, which do not need to be pre-declared. Various memory-related exceptions were added as subclasses of RuntimeException. But later on, people starting using this to not to have to declare all exception types everywhere.) In Python, exceptions do no have to be pre-declared, and for code which just encounters a failure, we should raise a specific exception type. The catch-all class for unexpected input is ValueError. For systemd/systemd#31637: BadSectionError: Section '.data' @0x28000 overlaps previous section @0x28000+0x300=@0x28300 Also, exception strings should not contain trailing periods, because they are often embedded in sentences. (cherry picked from commit 8a75371)
keszybz
added a commit
to systemd/systemd-stable
that referenced
this issue
Apr 23, 2024
Resolves systemd/systemd#31637. lld-18 does the section setup differently than older versions. There is a bunch of ordering chagnes, but it also inserts the following: Sections: Idx Name Size VMA LMA File off Algn ... 9 .got 00000000 00000000000283c0 00000000000283c0 000283c0 2**3 CONTENTS, ALLOC, LOAD, DATA 10 .relro_padding 00000c40 00000000000283c0 00000000000283c0 000283c0 2**0 ALLOC 11 .data 00000024 00000000000293c0 00000000000293c0 000283c0 2**4 CONTENTS, ALLOC, LOAD, DATA ... This causes a problem for us, because we try to map the .got to .rodata, and the subsequent .data to .data, and round down the VMA to the nearest page, which causes the PE sections to overlap. llvm/llvm-project#66042 adds .relro_padding to make sure that the RELRO segment is properly write protected and allocated. For our binaries, the .got section is empty, so we can skip it safely, and the .relro_padding section is not useful once .got has been dropped. We don't expect .got sections, but they are apparently inserted on i386 and aarch64 builds. Emit a warning until we figure out why they are there. (cherry picked from commit 6d03e55)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Spotted in #31633, but can be easily reproduced on the latest Fedora Rawhide as well:
The text was updated successfully, but these errors were encountered: