This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] Display section names for STT_SECTION symbols.
ClosedPublic

Authored by mattd on Feb 28 2019, 2:40 PM.

Details

Summary

This patch will obtain the section name for symbols that refer to a section. Prior to this patch the Name field for STT_SECTIONs was blank, now it is populated.

Before:

Symbol table '.symtab' contains 6 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000000     0 SECTION LOCAL  DEFAULT    1
     2: 0000000000000000     0 SECTION LOCAL  DEFAULT    3
     3: 0000000000000000     0 SECTION LOCAL  DEFAULT    4
     4: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _GLOBAL_OFFSET_TABLE_
     5: 0000000000000000     0 TLS     GLOBAL DEFAULT  UND sym

With this patch:

Symbol table '.symtab' contains 6 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000000     0 SECTION LOCAL  DEFAULT    1 .text
     2: 0000000000000000     0 SECTION LOCAL  DEFAULT    3 .data
     3: 0000000000000000     0 SECTION LOCAL  DEFAULT    4 .bss
     4: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _GLOBAL_OFFSET_TABLE_
     5: 0000000000000000     0 TLS     GLOBAL DEFAULT  UND sym

This fixes PR40788

Diff Detail

Event Timeline

mattd created this revision.Feb 28 2019, 2:40 PM
mattd edited the summary of this revision. (Show Details)Feb 28 2019, 2:41 PM
rupprecht accepted this revision.Feb 28 2019, 5:17 PM
This revision is now accepted and ready to land.Feb 28 2019, 5:17 PM
MaskRay accepted this revision.Feb 28 2019, 9:11 PM
MaskRay added inline comments.
llvm/tools/llvm-readobj/ELFDumper.cpp
818

SymbolName.empty()

MaskRay added inline comments.Feb 28 2019, 9:15 PM
llvm/tools/llvm-readobj/ELFDumper.cpp
821

auto -> Elf_Sym_Range

jhenderson requested changes to this revision.Mar 1 2019, 1:21 AM

The request changes is due to the test. Otherwise this basically looks fine to me.

llvm/test/tools/llvm-readobj/symbols.test
17–19 ↗(On Diff #188791)

There is already a separate test for this that needs updating instead. See gnu-symbols.test.

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

I don't think you need this if at all. If the section name is empty and the symbol name is empty, I think we should just print an empty string (section symbols aren't versioned to my knowledge).

This revision now requires changes to proceed.Mar 1 2019, 1:21 AM
mattd updated this revision to Diff 188924.Mar 1 2019, 9:00 AM
mattd marked 4 inline comments as done.

Thanks for the reviews everyone. This update addresses the feedback, all of which was incorporated.

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