This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Mention symbol name in reportRangeError()
ClosedPublic

Authored by MaskRay on Jan 27 2020, 6:21 PM.

Details

Summary

For an out-of-range relocation referencing a non-local symbol, report the symbol name and the object file that defines the symbol. As an example:

t.o:(function func: .text.func+0x3): relocation R_X86_64_32S out of range: -281474974609120 is not in [-2147483648, 2147483647]

>

t.o:(function func: .text.func+0x3): relocation R_X86_64_32S out of range: -281474974609120 is not in [-2147483648, 2147483647]; references func
>>> defined in t1.o

Diff Detail

Event Timeline

MaskRay created this revision.Jan 27 2020, 6:21 PM
MaskRay edited the summary of this revision. (Show Details)Jan 27 2020, 6:23 PM
MaskRay edited the summary of this revision. (Show Details)Jan 27 2020, 6:26 PM

Unit tests: pass. 62251 tests passed, 0 failed and 816 were skipped.

clang-tidy: fail. clang-tidy found 0 errors and 16 warnings. 0 of them are added as review comments below (why?).

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

Unit tests: pass. 62251 tests passed, 0 failed and 816 were skipped.

clang-tidy: fail. clang-tidy found 0 errors and 16 warnings. 0 of them are added as review comments below (why?).

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

grimar added inline comments.Jan 28 2020, 12:50 AM
lld/ELF/Relocations.cpp
105

It can probably print "references local symbol" for local symbols?

108

Seems there is no test case for this?

grimar added inline comments.Jan 28 2020, 12:51 AM
lld/ELF/Relocations.cpp
108

Ah, nevermind. I did not notice this piece was just moved.

I think this is step in the right direction. I tend to find that relocation out of range errors tend to be more useful to linker developers (via bug reports) as there is often little that a user can do about it, and it often represents either a fault in the linker or a misuse of a relocation in the compiler, I think we could tend to include information that would help us diagnose problems.

lld/ELF/Relocations.cpp
105

Another possibility would be to distinguish between symbol and PLT entry for symbol. I think that could be a future improvement though.

MaskRay marked an inline comment as done.Jan 28 2020, 11:49 PM

The improved diagnostics helped me locate a bug today (D73606) :)

lld/ELF/Relocations.cpp
105

Regarding ; references local symbol

A local symbol can only be referenced from within the same file. It is usually not easy to trigger a relocation overflow.
I think more than 99% cases are relocations referencing global symbols. We can start from global symbols first.

Another possibility would be to distinguish between symbol and PLT entry for symbol. I think that could be a future improvement though.

Ack.

grimar accepted this revision.Jan 29 2020, 12:04 AM

LGTM

This revision is now accepted and ready to land.Jan 29 2020, 12:04 AM
MaskRay updated this revision to Diff 241199.Jan 29 2020, 9:35 AM

Update more tests to improve diagnostics

MaskRay edited the summary of this revision. (Show Details)Jan 29 2020, 9:36 AM
This revision was automatically updated to reflect the committed changes.

Unit tests: pass. 62283 tests passed, 0 failed and 827 were skipped.

clang-tidy: fail. clang-tidy found 0 errors and 16 warnings. 0 of them are added as review comments below (why?).

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.