-
Notifications
You must be signed in to change notification settings - Fork 155
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
Do debug sections really have alignment requirements? #235
Comments
My understanding of ELF is that all headers must always be aligned to the natural alignment for the ELF class (32-bit or 64-bit). For compressed sections, the contents of the section are irrelevant (so the DWARF standard won't have anything to say about this). The alignment of the compressed section should be the alignment requirement of the compression header (4 or 8), and the alignment of the uncompressed data should be stored in the If this bug is common for compressed headers, then maybe we should remove the alignment requirement for it. The performance is hardly likely to be relevant if you need to decompress. |
http://www.linker-aliens.org/blogs/ali/entry/elf_section_compression/ talks about the design of ELF compression, and an explicit goal was for the compression header to be aligned. |
Ah, indeed, thanks for the reference. Looks like there is a bug in binutils that is relevant: https://sourceware.org/bugzilla/show_bug.cgi?id=23919. Weirdly that bug was closed with binutils 2.32, but the misalignment persists for me with 2.34. |
Even with a simple C program I cannot manage to find a toolchain that produces aligned compressed debug sections. I've tried gold/lld too now. Huh. Does everyone just get this wrong?! |
@philipc since it seems like backtrace-rs wants the unaligned feature for other reasons there is no pressing need for any action here! Happy to have this open since it seems like compressed headers are particularly likely to be misaligned and maybe allowing them to be misaligned should be the default, but also happy for you to close this because it does seem like the default behavior is standards-compliant and correct. |
Yep thanks. I'll look into it a bit but the probable outcome is to allow them to be misaligned. |
LLVM fixed its output in https://reviews.llvm.org/D60965 and binutils fixed its output in https://sourceware.org/bugzilla/show_bug.cgi?id=23919. That's still relatively new though, so let's handle misaligned for now, and consider changing it back later. |
I just sent up a PR to backtrace-rs (rust-lang/backtrace-rs#344) to add support for compressed debug info sections. One of the big hiccups was the alignment requirement of the CompressionHeader. Does the header really have alignment requirements? My toolchain does not align them at all, AFAICT:
(GCC 9.3.0, stock Ubuntu Eoan.)
I tracked down some related discussion in #230 and so that backtrace PR flips on the new unaligned feature (great timing, so thanks!). But I'm not it's the right solution in this case—maybe there is no alignment requirement for the compression headers? And if so disabling alignment checks everywhere seems heavyweight. I tried looking through the DWARF standard but couldn't find anything one way or another.
The text was updated successfully, but these errors were encountered: