This is an archive of the discontinued LLVM Phabricator instance.

Add a relocation for R_AARCH64_ABS32 in ObjectFileELF
ClosedPublic

Authored by lanza on Jul 16 2018, 4:00 PM.

Details

Summary

.rela.debug_info relocations are being done via
ObjectFileELF::ApplyRelocations for aarch64. Currently, the switch case
that iterates over the relocation type is only implemented for a few
different types and assert(false)es over the rest.

Implement the relocation for R_AARCH64_ABS32 in ApplyRelocations

Diff Detail

Repository
rLLDB LLDB

Event Timeline

lanza created this revision.Jul 16 2018, 4:00 PM

Speaking as primarily a linker person; the implementation of the R_AARCH64_ABS32 relocation is correct. You'll need to get some input from an LLDB person about whether extending the function like this is the right approach though, I'm guessing that there are more than just AArch64 and Arm that support relocated debug sections? The more codes that are added the less readable that assert is going to get. Final comment: is there a test case that you can add to show that R_AARCH64_ABS32 is handled correctly, or even just doesn't assert fail?

source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
2705–2706

Is it worth refactoring this assert a little bit. At a microscopic level both

(reloc_type(rel) == R_AARCH64_ABS32 && (value <= UINT32_MAX)));

and

(reloc_type(rel) == R_X86_64_32 && (value <= UINT32_MAX))

are really an instance of:

(IsRelocABS32(rel) && value <= UINT32_MAX)

Where IsRelocABS32 could abstract away the target specific relocation codes.

2705–2706

Not related to this change, just a drive by comment. Should this be an error message and not an assert? If this can happen due to bad input objects (too much debug information) then it would be helpful to the user to have an error message rather than an assert failure.

lanza updated this revision to Diff 159094.Aug 3 2018, 2:31 PM

Refactor assert code

lanza marked 2 inline comments as done.Aug 3 2018, 2:32 PM
lanza updated this revision to Diff 159111.Aug 3 2018, 3:45 PM

Convert assert to a log

lanza updated this revision to Diff 159113.Aug 3 2018, 3:47 PM

fix typo

lanza edited reviewers, added: clayborg; removed: javed.absar, espindola.Aug 3 2018, 3:48 PM
lanza removed subscribers: emaste, arichardson, kristof.beyls.
This revision was not accepted when it landed; it landed in state Needs Review.Aug 6 2018, 3:04 PM
This revision was automatically updated to reflect the committed changes.