This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Only print symbol name when it is available
ClosedPublic

Authored by phosek on Aug 19 2016, 5:29 PM.

Details

Summary

Not only symbols (like sections) have names, in case where we fail to create relocation against such symbol, we should not print out an empty string, instead we should print a generic message.

Diff Detail

Repository
rL LLVM

Event Timeline

phosek updated this revision to Diff 68751.Aug 19 2016, 5:29 PM
phosek retitled this revision from to [ELF] Only print symbol name when it is available.
phosek updated this object.
phosek added a reviewer: ruiu.
phosek added a project: lld.
phosek added subscribers: llvm-commits, phosek.
ruiu added inline comments.Aug 20 2016, 12:43 AM
ELF/Relocations.cpp
431 ↗(On Diff #68751)

This is a bit scattered. What we want to do here is (1) to get a symbol name, and (2) if it fails use "readonly sement" instead. So how about defining StringRef getSymbolName(elf::ObjectFile<ELFT> &File, SymbolBody &Body) which returns the symbol name or the empty string?

phosek updated this revision to Diff 68796.Aug 20 2016, 10:52 PM
phosek marked an inline comment as done.
ruiu accepted this revision.Aug 21 2016, 9:32 PM
ruiu edited edge metadata.

LGTM with nits.

ELF/Relocations.cpp
413 ↗(On Diff #68796)

Now that this is the only place where getLocalSymbolName is called, so let's inline that function and remove getLocalSymbolName.

414 ↗(On Diff #68796)

Remove else after return.

This revision is now accepted and ready to land.Aug 21 2016, 9:32 PM
phosek updated this revision to Diff 68825.Aug 21 2016, 11:00 PM
phosek edited edge metadata.
phosek marked 2 inline comments as done.
This revision was automatically updated to reflect the committed changes.