This is an archive of the discontinued LLVM Phabricator instance.

[RuntimeDyld] Don't try to allocate sections with alignment 0.
ClosedPublic

Authored by zturner on Jan 30 2019, 3:37 PM.

Details

Summary

ELF sections allow 0 for the alignment, which is specified to be the same as 1. However many clients do not expect this and will behave poorly in the presence of a 0-aligned section (for
example by trying to modulo something by the section alignment). We can be more polite by making sure that we always pass a non-zero value to clients.

This was discovered when running the LLDB test suite on Linux with a debug build of LLDB / LLVM, and we had several hundred failures do an assertion triggering in MathExtras.h where we tried to call llvm::alignTo(Size, Align=0, ...).

I don't really know this code at all, so I'm not sure if the problem is that the JIT was generating a 0-align section in the first place, but this does at least faithfully match the ELF spec, while also fixing all of the bugs in LLDB's test suite.

Diff Detail

Repository
rL LLVM

Event Timeline

zturner created this revision.Jan 30 2019, 3:37 PM
zturner edited the summary of this revision. (Show Details)Jan 30 2019, 3:37 PM
lhames accepted this revision.Jan 30 2019, 3:45 PM

Nice catch. LGTM. Thanks Zach!

This revision is now accepted and ready to land.Jan 30 2019, 3:45 PM
This revision was automatically updated to reflect the committed changes.