This is an archive of the discontinued LLVM Phabricator instance.

[llvm-nm][ELF] - Use @@ prefix when printing default versions.
ClosedPublic

Authored by grimar on Jan 18 2021, 5:44 AM.

Details

Summary

llvm-readelf prints default versions with @@ prefix.
This patch does the same for llvm-nm.

Depends on https://reviews.llvm.org/D95219

Diff Detail

Event Timeline

grimar created this revision.Jan 18 2021, 5:44 AM
grimar requested review of this revision.Jan 18 2021, 5:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 18 2021, 5:44 AM
MaskRay added inline comments.Jan 19 2021, 12:27 AM
llvm/test/tools/llvm-nm/dynamic.test
64–65

A default version (@@) is only available for defined symbols.

Undefined symbols should use @ everywhere.

(I reported a similar bug to GNU readelf --dyn-syms some time last year)

Seems reasonable in principle.

llvm/tools/llvm-nm/llvm-nm.cpp
1689

I was under the impression that anonymous namespaces were purely for hiding structs and classes, and not functions, based on the coding standards?

grimar added inline comments.Jan 19 2021, 6:11 AM
llvm/test/tools/llvm-nm/dynamic.test
64–65

Seems we have an issue with llvm-readelf too then (with ELFFile<ELFT>::getSymbolVersionByIndex, which returns IsDefault actually).
It should be fixed first, I'll take a look a bit later.

grimar marked an inline comment as done.Jan 22 2021, 3:56 AM
grimar added inline comments.
llvm/tools/llvm-nm/llvm-nm.cpp
1689
grimar marked an inline comment as done.Jan 22 2021, 3:57 AM
grimar added inline comments.
llvm/tools/llvm-nm/llvm-nm.cpp
1689

Posted this a bit too early. Will be fixed in update.

grimar updated this revision to Diff 318486.Jan 22 2021, 4:50 AM
grimar edited the summary of this revision. (Show Details)
  • Addressed review comments.
MaskRay accepted this revision.Jan 22 2021, 9:05 AM

Looks great!

llvm/tools/llvm-nm/llvm-nm.cpp
1691

StringRef can be used.

This revision is now accepted and ready to land.Jan 22 2021, 9:05 AM
grimar marked an inline comment as done.Jan 26 2021, 1:16 AM
grimar added inline comments.
llvm/tools/llvm-nm/llvm-nm.cpp
1691

No, because this string comes from

Expected<SmallVector<Optional<VersionEntry>, 0>> MapOrErr =
    Obj.loadVersionMap(SymVerNeedSec, SymVerDefSec);

which internally builds a string.

This revision was automatically updated to reflect the committed changes.
grimar marked an inline comment as done.