This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objdump][test] Reorganize ELF --syms tests
ClosedPublic

Authored by MaskRay on Mar 6 2020, 8:51 PM.

Details

Summary

Merge symbol-table-elf.test and common-symbol-elf.test, and add some
more tests (SHN_UNDEF, SHN_ABS, SHN_COMMON, STB_GNU_UNIQUE,
STT_GNU_IFUNC) to test/llvm-objdump/ELF/symbol-table.test

The naming follows test/llvm-{readobj,objcopy}/ELF .

Some discrepancy from GNU objdump:

  • STT_COMMON: can be produced with ld.bfd -r -z common, but it almost never exists in practice
  • STT_GNU_IFUNC: will be fixed by D75793
  • STB_GNU_UNIQUE: will be fixed by D75797
  • STT_TLS: GNU objdump does not print 'O'
  • unknown binding: GNU objdump does not print 'g'. This probably does

not matter.

  • A reserved symbol index is displayed as *ABS* in GNU objdump. It is not clear what we should print.

Diff Detail

Event Timeline

MaskRay created this revision.Mar 6 2020, 8:51 PM
Herald added a project: Restricted Project. · View Herald Transcript
grimar added inline comments.Mar 7 2020, 1:57 AM
llvm/test/tools/llvm-objdump/ELF/symbol-table.test
7

Add a file/test comment?

41
69

I'd replace %08x with words. I.e. "we print addresses as 32 bit values" or alike.
(It is not really important how exactly this logic is implemented, with %08x or something different).

MaskRay updated this revision to Diff 248933.Mar 7 2020, 8:12 AM
MaskRay marked an inline comment as done.

Address comments

MaskRay marked an inline comment as done.Mar 7 2020, 8:13 AM

You should probably extend the test case to enumerate the possible section types supported by LLVM + 1 other unknown value. Similarly, an unknown binding value might be good to test. Testing more section index values might be wise too, i.e. values >= SHN_LORESERVE that don't correspond to a special value, and SHN_XINDEX, where the real section index is stored elsewhere.

What does llvm-objdump do if you specify an invalid section index? That should be tested too, I guess. Ditto an invalid name?

Finally, what about non-zero st_other values? Does llvm-objdump print those at all?

MaskRay updated this revision to Diff 249108.Mar 9 2020, 8:24 AM
MaskRay edited the summary of this revision. (Show Details)

Add SHN_LOPROC/SHN_LOOS/reserved tests

We need a SHN_XINDEX test, but that can be done a in subsequent patch.
(The corresponding llvm-readobj tests are not trivial.)

MaskRay updated this revision to Diff 249116.Mar 9 2020, 8:40 AM

Fix test

Add SHN_LOPROC/SHN_LOOS/reserved tests

We need a SHN_XINDEX test, but that can be done a in subsequent patch.
(The corresponding llvm-readobj tests are not trivial.)

Deferring SHN_XINDEX is probably fine. What about the other STT_* types and an unknown binding as suggested?

MaskRay updated this revision to Diff 249416.Mar 10 2020, 9:23 AM
MaskRay edited the summary of this revision. (Show Details)

Improve tests

Does this patch look good now?

grimar accepted this revision.Mar 12 2020, 1:43 AM

LGTM with 2 nits, please wait to see if @jhenderson is happy too.

llvm/test/tools/llvm-objdump/ELF/symbol-table.test
41

nit: I think you can remove empty "Name".

98

nit: missing the 64-bit version.

105

Perhaps it can be

#      ADDR:SYMBOL TABLE:
# ADDR-NEXT:[[NULL]]         *UND*  [[NULL]] sym

> FileCheck -D NULL=00000000 ...
> FileCheck -D NULL=0000000000000000 ....

(I am not sure we want it. It has its pros and cons)

This revision is now accepted and ready to land.Mar 12 2020, 1:43 AM

Still looks like you're missing some cases:

STT_NOTYPE, STT_COMMON, STT_LOPROC/STT_LOOS values.

STT_ and STB_ values outside recognised or reserved ranges.

MaskRay updated this revision to Diff 249929.Mar 12 2020, 7:40 AM
MaskRay edited the summary of this revision. (Show Details)

Add STT_COMMON, STT_HIOS and STT_LOPROC

MaskRay updated this revision to Diff 249930.Mar 12 2020, 7:43 AM
MaskRay marked 3 inline comments as done.

Address comments

llvm/test/tools/llvm-objdump/ELF/symbol-table.test
105

With --match-full-lines --strict-whitespace, may be fine keeping the original literal form...

MaskRay updated this revision to Diff 249934.Mar 12 2020, 7:48 AM

More tests

Harbormaster completed remote builds in B48984: Diff 249929.
Harbormaster completed remote builds in B48985: Diff 249930.
This revision was automatically updated to reflect the committed changes.
llvm/test/tools/llvm-objdump/ELF/symbol-table.test