This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] - Allow dumping partially corrupted SHT_LLVM_CALL_GRAPH_PROFILE sections.
ClosedPublic

Authored by grimar on Jul 3 2020, 6:55 AM.

Details

Summary

The code we have currently reports an error if something is not right with the
profile section. Instead we can report a warning and continue dumping when it is possible.
This patch does it.

Diff Detail

Event Timeline

grimar created this revision.Jul 3 2020, 6:55 AM
Herald added a project: Restricted Project. · View Herald Transcript
jhenderson added inline comments.Jul 6 2020, 12:55 AM
llvm/tools/llvm-readobj/ELFDumper.cpp
6579–6586

This seems like a pattern we're likely to have in several different parts of the ELFDumper. Is there any code we could share to avoid duplication? Maybe it just makes sense to change getStaticSymbolName to report the warning/return the <?> itself?

grimar marked an inline comment as done.Jul 6 2020, 2:44 AM
grimar added inline comments.
llvm/tools/llvm-readobj/ELFDumper.cpp
6579–6586

From what I see, the getStaticSymbolName is used in one more place:

template <class ELFT>
void LLVMStyle<ELFT>::printAddrsig(const ELFFile<ELFT> *Obj) {
...
  for (uint64_t Sym : *V) {
    Expected<std::string> NameOrErr = this->dumper()->getStaticSymbolName(Sym);
    if (NameOrErr) {
      W.printNumber("Sym", *NameOrErr, Sym);
      continue;
    }
    reportWarning(NameOrErr.takeError(), this->FileName);
    W.printNumber("Sym", "<?>", Sym);
  }
}

And it looks like it should be reasonable and possible to do what you suggest. Follow-up?

grimar marked an inline comment as done.
grimar added inline comments.
llvm/tools/llvm-readobj/ELFDumper.cpp
6579–6586

Follow-up: D83208

jhenderson accepted this revision.Jul 7 2020, 12:17 AM

LGTM, but see my inline comment (happy for you to commit the two patches separately or as one).

llvm/tools/llvm-readobj/ELFDumper.cpp
6579–6586

Normally, I'd say yes, follow-up, but in this case, D83208 looks small enough that it could be done as part of this, especially as most of that change is just undoing what some of this change does (in particular, the GetSymName lamdba replaces getStaticSymbolName in this change and then is just replaced back the other way again). I don't feel strongly about this though.

This revision is now accepted and ready to land.Jul 7 2020, 12:17 AM
grimar marked an inline comment as done.Jul 7 2020, 1:09 AM
grimar added inline comments.
llvm/tools/llvm-readobj/ELFDumper.cpp
6579–6586

The problem is that D83208 is not a NFC. It changes the message reported for --addrsig (adds a prefix with the context):

"warning: '[[FILE]]': unable to get symbol from section [index 2]: invalid symbol index (255)" -> "warning: '[[FILE]]': unable to read the name of symbol with index 255: unable to get symbol from section [index 2]: invalid symbol index (255)"

That is why I slightly prefer to keep them separate.

This revision was automatically updated to reflect the committed changes.