This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] fix unit test failure on 32bit machines
ClosedPublic

Authored by antmo on Apr 13 2023, 3:07 AM.

Details

Summary

Several bots are failing on 32-bit since https://reviews.llvm.org/D145761 was merged

https://lab.llvm.org/buildbot/#/builders/178/builds/4384

It seems due to the use of uintptr_t (32bit here) for storing 64 bit values.

Issue is fixed by replacing to uint64_t (as suggested by DavidSpickett).

Diff Detail

Event Timeline

antmo created this revision.Apr 13 2023, 3:07 AM
Herald added a project: Restricted Project. · View Herald Transcript
antmo requested review of this revision.Apr 13 2023, 3:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2023, 3:07 AM

My inline suggestion could be tested by using a section with e.g. size 1 and a size tag value of 0x100000001, since on a 32-bit machine, that should not trigger the error (since 0x100000001 is truncated to 1), when an error is expected.

llvm/tools/llvm-readobj/ELFDumper.cpp
6012–6013

The size_t here should probably be changed too, since in theory the dynamic entry value could be greater than the max value of size_t on a 32-bit machine. Using fixed-sized types is generally the approach taken elsewhere in the code, so uint64_t for both seems appropriate to me.

antmo updated this revision to Diff 513160.Apr 13 2023, 3:47 AM

also change size_t as suggested by jhenderson

antmo added a reviewer: hctim.Apr 13 2023, 5:33 AM
jhenderson accepted this revision.Apr 13 2023, 5:39 AM

LGTM, with one suggestion.

llvm/test/tools/llvm-readobj/ELF/AArch64/memtag.test
309

Can you confirm tha this test case fails if using a 32-bit machine without your fix?

Also, please add a small comment explaining that this is to show that the GLOBALSSZ tag is stored in a 64-bit integer even on 32-bit machines.

This revision is now accepted and ready to land.Apr 13 2023, 5:39 AM
antmo updated this revision to Diff 513197.Apr 13 2023, 5:44 AM

update test

antmo added a comment.Apr 13 2023, 5:47 AM

Thanks for the review @jhenderson .
I confirm that the test fails on a 32-bit machine without the fix.
Also, if everything is OK, could someone merge this patch for me please?

@hctim - it was your patch originally, so I'll leave you to commit the fix if you're happy with it.

I'll land this for you.

You'll be needing commit access the more you do buildbot duty, https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access :)

This revision was automatically updated to reflect the committed changes.