This is an archive of the discontinued LLVM Phabricator instance.

ELF: Add a standard method for unknown relocation errors
ClosedPublic

Authored by wnewton on Dec 4 2014, 4:17 AM.

Details

Summary

At present each TargetRelocationHandler generates a pretty similar error
string and calls llvm_unreachable() when encountering an unknown
relocation. This is not ideal for two reasons:

  1. llvm_unreachable disappears in release builds but we still want to know if we encountered a relocation we couldn't handle in release builds.
  1. Duplication is bad - there is no need to have a per-architecture error message.

This change adds a test for AArch64 to test whether or not the error
message actually works. The other architectures have not been tested
but they compile and check-lld passes.

Diff Detail

Event Timeline

wnewton updated this revision to Diff 16919.Dec 4 2014, 4:17 AM
wnewton retitled this revision from to ELF: Add a standard method for unknown relocation errors.
wnewton updated this object.
wnewton edited the test plan for this revision. (Show Details)
wnewton added reviewers: shankarke, atanasyan.
wnewton added a project: lld.
wnewton added a subscriber: Unknown Object (MLST).
atanasyan edited edge metadata.Dec 4 2014, 5:18 AM

Good idea. Did you consider to factor out the unhandledReferenceType method into the separate class? Some sort of Diagnostic. The LinkingContext might have a reference to this class. That allow us to keep all diagnostics stuff together and simplify implementation of feature-rich diagnostics engine in the future.

lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.h
24

Are these lines clang-formatted?

shankarke accepted this revision.Dec 4 2014, 9:36 AM
shankarke edited edge metadata.

Please clang-format the change.

This revision is now accepted and ready to land.Dec 4 2014, 9:36 AM
In D6523#6, @atanasyan wrote:

Good idea. Did you consider to factor out the unhandledReferenceType method into the separate class? Some sort of Diagnostic. The LinkingContext might have a reference to this class. That allow us to keep all diagnostics stuff together and simplify implementation of feature-rich diagnostics engine in the future.

I noticed that there is the issue of diagnostics to be resolved on the projects list. It is something that should be done I think but at the moment I am not sure I know what it would look like an dhopefully this change can be an incremental step that work easier in future.

I found a couple of bugs in cc-mode that were causing the indentation to be wrong. Hopefully these are all now fixed.

atanasyan accepted this revision.Dec 7 2014, 10:49 PM
atanasyan edited edge metadata.

LGTM

wnewton closed this revision.Jan 7 2015, 7:53 AM

This change has been committed.

r223782 | wnewton | 2014-12-09 16:29:39 +0000 (Tue, 09 Dec 2014) | 17 lines

ELF: Add a standard method for unknown relocation errors

At present each TargetRelocationHandler generates a pretty similar error
string and calls llvm_unreachable() when encountering an unknown
relocation. This is not ideal for two reasons:

  1. llvm_unreachable disappears in release builds but we still want to know if we encountered a relocation we couldn't handle in release builds.
  1. Duplication is bad - there is no need to have a per-architecture error message.

This change adds a test for AArch64 to test whether or not the error
message actually works. The other architectures have not been tested
but they compile and check-lld passes.