This is an archive of the discontinued LLVM Phabricator instance.

[ELF2] Fix an assertion failure on 32-bit platform
ClosedPublic

Authored by ikudrin on Sep 22 2015, 3:57 AM.

Details

Summary

As GOT section has lower address than PLT section, the Delta value is negative and should be calculated and stored in the signed variable.

Diff Detail

Event Timeline

ikudrin updated this revision to Diff 35355.Sep 22 2015, 3:57 AM
ikudrin retitled this revision from to [ELF2] Fix an assertion failure on 32-bit platform.
ikudrin updated this object.
ikudrin added a reviewer: rafael.
ikudrin added a project: lld.
ikudrin added a subscriber: llvm-commits.

The patch fixes the elf2/plt.s test failure on Windows (and probably on other platforms with 32-bit targets).

rafael edited edge metadata.Sep 22 2015, 5:08 AM
rafael added a subscriber: rafael.

How are you building it? The test already passes on a 32 bit linux build.

ikudrin added a comment.EditedSep 22 2015, 5:36 AM

It fails on Windows (target triple i686-pc-win32) with MSVC 14.

A bit more explanation. The type uintprt_t in this situation is equivalent to 32-bit unsigned int. For example, the Delta var may have value 0xffffeffa. And when it's passed to the isInt<32> function, which parameter is 64-bit signed integer, it doesn't extend sign bit.

In Win32 build, uintptr_t is 32 bit unsigned integer. The isInt function
receives
64 bit signed integer as a parameter. A uint32 value converts to int64
without
sign bit extension, so isInt receives a positive value, which cannot be
represented
as signed 32 bit integer value.

I see nothing odd here.

ikudrin accepted this revision.Sep 22 2015, 8:29 PM
ikudrin added a reviewer: ikudrin.

Fixed in r248289

This revision is now accepted and ready to land.Sep 22 2015, 8:29 PM
ikudrin closed this revision.Sep 22 2015, 8:30 PM