llvm.org GIT mirror llvm / a511b30
[llvm-nm] Generalize ELF symbol types 'N' and 'n' Reviewed By: grimar, jhenderson Differential Revision: https://reviews.llvm.org/D63588 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363918 91177308-0d34-0410-b5e6-96231b3b80d8 Fangrui Song 28 days ago
2 changed file(s) with 31 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
0 # RUN: yaml2obj %s -o %t
11 # RUN: llvm-nm --no-sort %t | FileCheck %s
22
3 # CHECK: n debug_info_main
3 # CHECK: N debug_info_main
4 # CHECK: n readonly_local
5 # CHECK: ? writable_local
6 # CHECK: N readonly_global
7 # CHECK: ? writable_global
48
59 !ELF
610 FileHeader:
1115 Sections:
1216 - Name: .debug_info
1317 Type: SHT_PROGBITS
18 - Name: .readonly
19 Type: SHT_PROGBITS
20 - Name: .writable
21 Type: SHT_PROGBITS
22 Flags: [SHF_WRITE]
1423 Symbols:
1524 - Name: debug_info_main
1625 Section: .debug_info
26 - Name: readonly_local
27 Section: .readonly
28 - Name: writable_local
29 Section: .writable
30
31 - Name: readonly_global
32 Binding: STB_GLOBAL
33 Section: .readonly
34 - Name: writable_global
35 Binding: STB_GLOBAL
36 Section: .writable
906906 return 'b';
907907 if (Flags & ELF::SHF_ALLOC)
908908 return Flags & ELF::SHF_WRITE ? 'd' : 'r';
909 }
910
911 if (SymI->getELFType() == ELF::STT_SECTION) {
912 Expected Name = SymI->getName();
913 if (!Name) {
914 consumeError(Name.takeError());
909
910 StringRef SecName;
911 if (SecI->getName(SecName))
915912 return '?';
916 }
917 return StringSwitch(*Name)
918 .StartsWith(".debug", 'N')
919 .StartsWith(".note", 'n')
920 .StartsWith(".comment", 'n')
921 .Default('?');
922 }
923
924 return 'n';
913 if (SecName.startswith(".debug"))
914 return 'N';
915 if (!(Flags & ELF::SHF_WRITE))
916 return 'n';
917 }
918
919 return '?';
925920 }
926921
927922 static char getSymbolNMTypeChar(COFFObjectFile &Obj, symbol_iterator I) {