This is an archive of the discontinued LLVM Phabricator instance.

Handle invalid values of PLT entry size generated by ld + gcc on arm linux targets.
ClosedPublic

Authored by omjavaid on Apr 18 2016, 6:30 PM.

Details

Summary

This patch provides a fix for wrong plt entry size generated for binaries built with gcc and linked with ld for arm linux targets.

Many tests fail on arm-linux targets for this very issues. Luckily on Android arm32 targets we get a zero size for which there is already a fix available in the code.

Effect of this patch appears when code jumps into plt code and tries to calculate frame for current PC. A wrong calculation of plt entry addresses ranges results in failure to calculate frame hence stepping failures when dealing with any library functions using procedure linkage table.

LD produces 12 byte plt entries for arm and can also produce 16 byte entries but by no means plt entry can be 4 bytes which appears while we decode plt header.

No other architecture in my knowledge uses a PLT slot of less than or equal to 4bytes. I could be wrong but in my knowledge a PLT slot is at least 2 instructions on a 32bit machine s which is 8 bytes and a lot higher for 64 bit machines so I have made the code change to handle all casses below or equal 4 bytes with manual calculation.

This fixes issues on arm targets.

LGTM? or comments?

Diff Detail

Repository
rL LLVM

Event Timeline

omjavaid updated this revision to Diff 54146.Apr 18 2016, 6:30 PM
omjavaid retitled this revision from to Handle invalid values of PLT entry size generated by ld + gcc on arm linux targets..
omjavaid updated this object.
omjavaid added a subscriber: lldb-commits.
clayborg accepted this revision.Apr 19 2016, 9:26 AM
clayborg edited edge metadata.

As long as PLT entries can't possibly be 4 bytes, then this is OK. Another way to fix this would be to make a "CheckPLTSize()" function that checks the architecture of the file, or just the e_machine from the ELF header, and does the right thing based on the architecture.

This revision is now accepted and ready to land.Apr 19 2016, 9:26 AM
tberghammer accepted this revision.Apr 20 2016, 3:36 AM
tberghammer edited edge metadata.

I don't really have an opinion about CheckPLTSize() function Greg proposes but I definitely want to see some comment explaining why we say that a plt entry less then 4 byte is invalid.

This revision was automatically updated to reflect the committed changes.