This is an archive of the discontinued LLVM Phabricator instance.

[obj2yaml] - Don't assert when trying to calculate the expected section offset.
ClosedPublic

Authored by grimar on Nov 26 2020, 2:47 AM.

Details

Summary

The following line asserts when sh_addralign > MAX_UINT32 && (uint32_t)sh_addralign == 0:

ExpectedOffset = alignTo(ExpectedOffset,
                         SecHdr.sh_addralign ? SecHdr.sh_addralign : 1);

it happens because sh_addralign is truncated to 32-bit value, but alignTo
doesn't accept Align == 0. We should change 1 to 1uLL.

Diff Detail

Event Timeline

grimar created this revision.Nov 26 2020, 2:47 AM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: emaste. · View Herald Transcript
grimar requested review of this revision.Nov 26 2020, 2:47 AM
jhenderson accepted this revision.Nov 27 2020, 12:05 AM

I'm rather surprised that this is needed, if I'm honest. Intuitively, I'd expect the result of that ternary to be a uin64_t, since that's the type of sh_addralign, but I guess not. LGTM.

This revision is now accepted and ready to land.Nov 27 2020, 12:05 AM