This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Support Universal Mach-O binaries with a fat64 header
ClosedPublic

Authored by JDevlieghere on Mar 27 2023, 4:21 PM.

Details

Summary

Support universal Mach-O binaries with a fat64 header. After D146879, dsymutil can now generate such binaries when the offsets would otherwise overflow the 32-bit offsets in the regular fat header.

rdar://107289570

Diff Detail

Event Timeline

JDevlieghere created this revision.Mar 27 2023, 4:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 27 2023, 4:21 PM
aprantl added inline comments.Mar 28 2023, 8:46 AM
lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
205

Should this use AddOverflow?
https://llvm.org/doxygen/MathExtras_8h.html

lldb/test/API/macosx/universal64/TestUniversal64.py
22

would it be easy to verify in the test or the makefile that the dsym indeed has a fat header?

JDevlieghere marked 2 inline comments as done.Mar 28 2023, 9:24 AM
JDevlieghere added inline comments.
lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
205

Yes, but nothing in ObjectContainerUniversalMachO is currently overflow aware. I'll fix up the whole file in a follow-up.

lldb/test/API/macosx/universal64/TestUniversal64.py
22

llvm-objdump can dump the universal headers but that's currently not a dependency of the test suite and I didn't think it was worth adding just for a sanity check.

JDevlieghere marked 2 inline comments as done.Mar 28 2023, 2:50 PM
JDevlieghere added inline comments.
lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
205

Actually, it looks like AddOverflow only checks for signed overflow (std::enable_if_t< std::is_signed< T >::value, T >). I assumed it was going through APInt under the hood. I think that's probably overkill here.

aprantl accepted this revision.Mar 28 2023, 3:07 PM

Thanks for checking!

This revision is now accepted and ready to land.Mar 28 2023, 3:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 28 2023, 3:46 PM