This is an archive of the discontinued LLVM Phabricator instance.

undefined behavior warning fix.
AbandonedPublic

Authored by tra on Jan 8 2015, 2:14 PM.

Details

Reviewers
None
Summary

The issue is that ubsan spotted a case where we extract 21 bits from a negative signed addend value in order to encode it into binary representation of reloc.

While behavior is harmless in this case, technically it does fall under undefined behavior. The patch extracts relevant bits into an unsigned variable first and then uses that unsigned value to shift bits around.

Diff Detail

Repository
rL LLVM

Event Timeline

tra updated this revision to Diff 17912.Jan 8 2015, 2:14 PM
tra retitled this revision from to undefined behavior warning fix..
tra updated this object.
tra edited the test plan for this revision. (Show Details)
tra added a reviewer: chandlerc.
tra set the repository for this revision to rL LLVM.

Hi Artem,

+ uint64_t AddressBits = Addend & 0x1FFFFF000;

Isn't this constant too big for an int? I'd expect 0x1FFFFF000LL.

Cheers.

Tim.