This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] Make sure all section allocations have deterministic contents
ClosedPublic

Authored by jobnoorman on Apr 26 2023, 1:29 AM.

Details

Summary

For empty sections, RuntimeDyld always allocates 1 byte but leaves it
uninitialized. This causes the contents of some output sections to be
non-deterministic.

Note that this issue is also solved by D147544.

Fixes #59008

Diff Detail

Event Timeline

jobnoorman created this revision.Apr 26 2023, 1:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2023, 1:29 AM
jobnoorman requested review of this revision.Apr 26 2023, 1:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2023, 1:29 AM
Amir added a comment.Apr 26 2023, 1:30 PM

Please add a test addressing bb-with-two-tail-calls:

Do we want to hardcode RuntimeDyld's strange behavior of allocating 1 byte for empty sections in tests? This will break with D147544 because empty sections are actually allocated as empty.

maksfb added inline comments.Apr 27 2023, 11:23 AM
bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp
33–34

Could lead to surprising results if someone decides to allocate a section with one byte for whatever reason. I can't think of a much better alternative though, but let's add an assertion that we don't create a one-byte section.

jobnoorman added inline comments.Apr 27 2023, 11:47 PM
bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp
33–34

I don't think this should be a problem as in that case, the section contents will later be overwritten by RuntimeDyld.

maksfb accepted this revision.Apr 28 2023, 1:03 PM

LGTM. I think it's fine to omit the test case as an exception.

bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp
33–34

True.

This revision is now accepted and ready to land.Apr 28 2023, 1:03 PM