This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] - Refine --needed-libs implementation and add a test.
ClosedPublic

Authored by grimar on Jan 22 2020, 4:23 AM.

Details

Summary

We have no good test for --needed-libs option.
The one we have as a part of Object/readobj-shared-object.test
is not complete.

In this patch I've did a minor NFC changes to the implementation and
added a test. This allowed to remove this piece from
Object/readobj-shared-object.test

Diff Detail

Event Timeline

grimar created this revision.Jan 22 2020, 4:23 AM
Herald added a project: Restricted Project. · View Herald Transcript
jhenderson added inline comments.Jan 24 2020, 12:38 AM
llvm/test/tools/llvm-readobj/ELF/needed-libs.test
10

libraries -> library

34

This address won't match the computed-via-phdr address. I'd either get rid of it, or add an AddressAlign 0x1000, or possibly just set it to 13(?), or something along those lines.

59

when the dynamic...

You can probably get rid of the word "section" here.

llvm/tools/llvm-readobj/ELFDumper.cpp
2474

What's the reasoning for this change? Won't this potentially change the behaviour where two DT_NEEDED entries have the same string?

2476

StringRef?

grimar marked an inline comment as done.Jan 24 2020, 12:43 AM
grimar added inline comments.
llvm/tools/llvm-readobj/ELFDumper.cpp
2474

We have a std::vector<std::string> here and sorting it to print below.
What is the point to use stable_sort?
If we have "aaa", "bbb", "aaa" then we might end up with one of the following:

  1. "aaa" (1), "aaa" (2), "bbb"
  2. "aaa" (2), "aaa" (1), "bbb"

May be I am missing something, but what is the difference? :)

MaskRay added inline comments.Jan 24 2020, 12:50 AM
llvm/tools/llvm-readobj/ELFDumper.cpp
2476

(I think keeping the original type does not hurt.)

grimar updated this revision to Diff 240123.Jan 24 2020, 1:52 AM
grimar marked 7 inline comments as done.
  • Addressed review comments.
llvm/tools/llvm-readobj/ELFDumper.cpp
2476

I'd also keep the original type. Having a StringRef here is not faster, as adds a one more constructor call,
but I see no benefits from that. It does not improve readability. Instead it raises a question
"why a conversion to StringRef is needed here, is there something wrong with operator << for std::string?"

jhenderson accepted this revision.Jan 24 2020, 1:56 AM

LGTM.

llvm/tools/llvm-readobj/ELFDumper.cpp
2474

Good point!

This revision is now accepted and ready to land.Jan 24 2020, 1:56 AM
This revision was automatically updated to reflect the committed changes.