This is an archive of the discontinued LLVM Phabricator instance.

[lld] ELF: Support detection of relocation errors during processing
ClosedPublic

Authored by wnewton on Jan 2 2015, 9:21 AM.

Details

Summary

At the moment errors in relocation processing such as out of range
values are not detected or at best trapped by asserts which will not
be present in release builds. This patch adds support for checking
error return values from applyRelocation() calls and printing an
appropriate error message. It also adds support for printing multiple
errors rather than just the first one.

Diff Detail

Repository
rL LLVM

Event Timeline

wnewton updated this revision to Diff 17761.Jan 2 2015, 9:21 AM
wnewton retitled this revision from to [lld] ELF: Support detection of relocation errors during processing.
wnewton updated this object.
wnewton edited the test plan for this revision. (Show Details)
wnewton added reviewers: shankarke, atanasyan.
wnewton set the repository for this revision to rL LLVM.
wnewton added a project: lld.
wnewton added a subscriber: Unknown Object (MLST).
atanasyan added inline comments.Jan 2 2015, 9:32 AM
lib/ReaderWriter/ELF/SectionChunks.h
426

Now parallel_for_each does all tasks in the single thread. But in the future the body of this loop can be parallelized. Does the printError ready to be called from multiple threads?

emaste added a subscriber: emaste.Jan 2 2015, 9:55 AM

Thanks for working on this, it is certainly something that we should handle better. Would it be possible for you to split this up into two patches? One introducing the error and a second actually making use of it in the AArch64 backend to perform range checks?

shankarke added inline comments.Jan 2 2015, 10:27 AM
lib/Core/Error.cpp
122 ↗(On Diff #17761)

I think we should move this error category inside ELF.

compnerd added inline comments.Jan 2 2015, 11:11 AM
lib/Core/Error.cpp
122 ↗(On Diff #17761)

Is there a strong reason to do so? I can see this error category being useful for the PE/COFF backend as well. There are a few relocations in the ARM target that are limited, and it would be nice to be able to return an error instead of asserting that the target is in range.

shankarke accepted this revision.Jan 2 2015, 11:22 AM
shankarke edited edge metadata.
shankarke added inline comments.
lib/Core/Error.cpp
122 ↗(On Diff #17761)

Sounds good then.

This revision is now accepted and ready to land.Jan 2 2015, 11:22 AM
wnewton updated this revision to Diff 17859.Jan 7 2015, 7:57 AM
wnewton updated this object.
wnewton edited the test plan for this revision. (Show Details)
wnewton edited edge metadata.
  1. Split out AArch64 ABS32 overflow checking code to a separate patch
  2. Add a mutex to make sure error output it not interleaved when multi-threaded
ruiu added a subscriber: ruiu.Jan 8 2015, 3:04 PM
ruiu added inline comments.
lib/Core/Error.cpp
123 ↗(On Diff #17859)

Instead of adding a new error category for your purpose, I think it would be better to just use make_dynamic_error_code(). It's simpler to use.

lib/ReaderWriter/ELF/SectionChunks.h
285

This doesn't seems a correct way to use Twine. This should be

(Twine(errorStr) + "in file " ...).str()

instead of

Twine(errorStr + "in file " ...).str()
wnewton updated this revision to Diff 18091.Jan 13 2015, 9:01 AM

Switched to using dynamic error rather than adding a new error category.
Fixed buggy usage of Twine.

ruiu accepted this revision.Jan 14 2015, 2:58 PM
ruiu added a reviewer: ruiu.

LGTM with these fixes.

lib/ReaderWriter/ELF/SectionChunks.h
424

s/EC/ec/

431

if (!success)

reames added a subscriber: reames.Jan 15 2015, 10:02 AM

Your concern is a legitimate one, but it's also not specific to this
patch. The JIT generally makes very little effort to report gracefully
when a compile fails. The current philosophy is more or less that the
frontend is expected to generate IR that is valid to compile; if it
doesn't, that's a fatal bug in the frontend. There is a desire to
change that, but no one has really volunteered to take that on.

Philip

atanasyan accepted this revision.Jan 16 2015, 6:21 AM
atanasyan edited edge metadata.
wnewton closed this revision.Jan 20 2015, 2:40 AM