This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] - Do not skip building of the GNU hash table histogram.
ClosedPublic

Authored by grimar on May 19 2020, 5:39 AM.

Details

Summary

When the --elf-hash-histogram is used, the code first tries to build
a histogram for the .hash table and then for the .gnu.hash table.

The problem is that dumper might return early when unable or do not need to
build a histogram for the .hash.

This patch reorders the code slightly to fix the issue and adds a test case.

Diff Detail

Event Timeline

grimar created this revision.May 19 2020, 5:39 AM
Herald added a project: Restricted Project. · View Herald Transcript
grimar updated this revision to Diff 264870.May 19 2020, 5:41 AM
  • Fix legacy comments.

Another one that somehow didn't get submitted for whatever reason. Sorry!

llvm/test/tools/llvm-readobj/ELF/hash-histogram.test
226

Did you consider the following?

## Case A:
...
# RUN:   FileCheck %s --check-prefix=GNU-HASH --implicit-check-not=Histogram

## Case B:
...
# RUN:   FileCheck %s -DFILE=%t6.o --check-prefixes=WARN,GNU-HASH

# WARN: warning: '[[FILE]]': the hash table at offset 0x78 goes past the end of the file (0x350), nbucket = 4294967295, nchain = 1
# GNU-HASH: Histogram for `.gnu.hash' bucket list length (total of 1 buckets)

It saves having to include two separate checks for the same thing.

240

I'm not sure what this comment is trying to tell me, but since the value is a parameter, perhaps it belongs with where the parameter is specified to be 1.

llvm/tools/llvm-readobj/ELFDumper.cpp
4565–4569

Up to you, but these lambdas are quite large, so it might be easier to follow if they were in independent functions (possibly methods of GNUStyle if needed). I'm also happy if you want to save that for a separate change to make it a pure NFC, so that the logic change here can easily be seen.

grimar marked 6 inline comments as done.
grimar added inline comments.
llvm/test/tools/llvm-readobj/ELF/hash-histogram.test
226

Done.

240

Fixed.

llvm/tools/llvm-readobj/ELFDumper.cpp
4565–4569

Up to you, but these lambdas are quite large, so it might be easier to follow if they were in independent functions

True. I had the same concerns, but stopped on the current version to reduce amount of changes.
I've prepared the follow-up doing this: D80546

grimar updated this revision to Diff 266183.May 26 2020, 6:04 AM
grimar marked 3 inline comments as done.
  • Upload the diff forgotten.
jhenderson accepted this revision.May 27 2020, 1:29 AM

LGTM, thanks.

This revision is now accepted and ready to land.May 27 2020, 1:29 AM