This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Implement R_ARM_TARGET1
ClosedPublic

Authored by davide on Jul 29 2016, 6:56 PM.

Details

Summary

I hit this relocation while building some software for ARM and realized the support for that is a little bit weird. In fact, TARGET1 is interpreted as REL32 or ABS32 depending on if --target1-rel or --target1-abs is passed on the cmdline. The default behaviour seems to interpret the relocation as ABS if no option is passed.

Diff Detail

Repository
rL LLVM

Event Timeline

davide updated this revision to Diff 66211.Jul 29 2016, 6:56 PM
davide retitled this revision from to [ELF] Implement R_ARM_TARGET1.
davide updated this object.
davide added a reviewer: ruiu.
davide added a subscriber: llvm-commits.
ruiu added inline comments.Jul 29 2016, 7:16 PM
ELF/Config.h
1 ↗(On Diff #66211)

Revert.

ELF/Relocations.cpp
538 ↗(On Diff #66211)

This affects all targets even though only ARM needs it. It is better to add cases for TARGET1 relocation to ARMTargetInfo::getRelExpr and ARMTargetInfo::relocateOne instead.

davide updated this revision to Diff 66229.Jul 30 2016, 4:30 PM

Makes sense. Virtual calls are expensive, alas :( I also forgot to git add the test, should be in this revision.

ruiu added inline comments.Jul 31 2016, 6:10 AM
ELF/Target.cpp
1505 ↗(On Diff #66229)

I think I'd prefer adding case R_ARM_TARGET1 to the following switches because, by doing so, you don't need to read this function to understand how we handle ARM relocations for all relocation types except TARGET1. See below.

1536 ↗(On Diff #66229)
case R_ARM_TARGET1:
  return Config->Target1Rel ? R_PC : R_ABS;
1558 ↗(On Diff #66229)
if (Type == R_ARM_TARGET1 && !Config->Target1Rel)
  return R_ARM_ABS32;
1641 ↗(On Diff #66229)

Add case R_ARM_TARGET32: so that you can remove modifyARMReloc from this function.

1770 ↗(On Diff #66229)

Ditto

davide updated this revision to Diff 66249.Jul 31 2016, 1:09 PM

Rui's comments.

This revision was automatically updated to reflect the committed changes.
ruiu edited edge metadata.Aug 1 2016, 12:37 PM

LGTM