This is an archive of the discontinued LLVM Phabricator instance.

Compute and Print Type and Section columns in "llvm-nm -f sysv" output. Round 2.
ClosedPublic

Authored by Sunil_Srivastava on Mar 6 2019, 4:33 PM.

Details

Summary

This is a re-submission of https://reviews.llvm.org/D58263 or https://reviews.llvm.org/rL354833, for PR39998 and PR39999.

That checkin was reverted due to an Asan failure. This patch fixes that failure.

In the process of fixing the Asan failure, the overall patch has become much smaller, so I am submitting it as a separate review.

The major simplification vs D58263 is that the new virtual function introduced in in that has now been removed. The code in llvm-nm.cpp now relies on Symbol flags already computed earlier.

Other than that there are

  1. minor stylistic changes, and
  2. a test Object/X86/nm-print-size.s has been enhanced to test "-f sysv" output

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptMar 6 2019, 4:33 PM
jhenderson added inline comments.Mar 7 2019, 2:45 AM
tools/llvm-nm/llvm-nm.cpp
888–889

Looks like the indentation got messed up here?

1113

Could you add a comment explaining why we throw away the error rather than reporting it here, please?

Sunil_Srivastava marked 2 inline comments as done.

Replaced tab with spaces.

tools/llvm-nm/llvm-nm.cpp
888–889

Yes, there is a tab there. Fixing.

1113

I have copied the usage from other places in the same file. I am assuming that consumeError is handling the error.

Sunil_Srivastava marked an inline comment as done.Mar 7 2019, 9:47 AM
Sunil_Srivastava added inline comments.
tools/llvm-nm/llvm-nm.cpp
1113

consumeError() is calling handleAllErrors which handles errors.

Sunil_Srivastava marked an inline comment as done.Mar 7 2019, 11:33 AM
Sunil_Srivastava added inline comments.
tools/llvm-nm/llvm-nm.cpp
1113

I see now that consumeError is 'throwing away' errors in some sense.

This function, getNMSectionTagAndName is the rename of getNMTypeChar. getNMTypeChar calls getSymbolNMTypeChar for different kinds of object files.

Since I needed to do something special for ELF, I guarded my code for ELF, and mimicked the code in getSymbolNMTypeChar, the ELF version. getSymbolNMTypeChar for ELF (and also for COFF) has the same call to getSection and consumeError, without any comment indicating what they are doing.

If you have any suggestion as to what comment should go here, I will be happy to add it.

jhenderson accepted this revision.Mar 8 2019, 1:30 AM

LGTM.

tools/llvm-nm/llvm-nm.cpp
1113

Ah, I missed that this is how it is handled elsewhere. No need to worry for now. I might suggest some error handling improvements in the future, but they should be wider and not part of this change then.

This revision is now accepted and ready to land.Mar 8 2019, 1:30 AM
This revision was automatically updated to reflect the committed changes.