llvm.org GIT mirror llvm / a29d058
Revert [llvm-nm] Fix handling of symbol types + [llvm-nm] Generalize symbol types This reverts r359311 and r359312 (git commit 0bf06a8f59b0074a60871865e828d92db8930c59 and 5f184f17800ea2ac27be5e4ab540cb94a46e80c7) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359830 91177308-0d34-0410-b5e6-96231b3b80d8 Jordan Rupprecht 1 year, 5 months ago
5 changed file(s) with 43 addition(s) and 97 deletion(s). Raw diff Collapse all Expand all
None # RUN: yaml2obj %s -o %t
1 # RUN: llvm-nm -B -S %t | FileCheck %s
2 !ELF
3 FileHeader:
4 Class: ELFCLASS64
5 Data: ELFDATA2LSB
6 Type: ET_EXEC
7 Machine: EM_X86_64
8 Sections:
9 - Name: .text
10 Type: SHT_PROGBITS
11 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
12 - Name: .init_array
13 Type: SHT_INIT_ARRAY
14 Flags: [ SHF_ALLOC, SHF_WRITE ]
15 - Name: .preinit_array
16 Type: SHT_PREINIT_ARRAY
17 Flags: [ SHF_ALLOC, SHF_WRITE ]
18 - Name: .fini_array
19 Type: SHT_FINI_ARRAY
20 Flags: [ SHF_ALLOC, SHF_WRITE ]
21 - Name: .data
22 Type: SHT_PROGBITS
23 Flags: [ SHF_ALLOC, SHF_WRITE ]
24 - Name: .bss
25 Type: SHT_NOBITS
26 Flags: [ SHF_ALLOC, SHF_WRITE ]
27 Symbols:
28 - Name: __init_array_start
29 Section: .init_array
30 - Name: __preinit_array_start
31 Section: .preinit_array
32 - Name: __fini_array_start
33 Section: .fini_array
34 - Name: __bss_start
35 Section: .bss
36 Binding: STB_GLOBAL
37 - Name: _edata
38 Section: .data
39 Binding: STB_GLOBAL
40 - Name: _end
41 Section: .bss
42 Binding: STB_GLOBAL
0 # RUN: llvm-nm -B -S %p/Inputs/init-fini.out.elf-x86_64 | FileCheck --match-full-lines %s
431
44 # CHECK: B __bss_start
45 # CHECK: d __fini_array_start
46 # CHECK: d __init_array_start
47 # CHECK: d __preinit_array_start
48 # CHECK: D _edata
49 # CHECK: B _end
2 CHECK: 00000000006000c2 0000000000000000 T __bss_start
3 CHECK: 00000000006000c2 0000000000000000 t __init_array_end
4 CHECK: 00000000006000ba 0000000000000000 t __init_array_start
5 CHECK: 00000000006000c2 0000000000000000 T _edata
6 CHECK: 00000000006000c8 0000000000000000 T _end
7 CHECK: 00000000004000b0 0000000000000000 T _start
None # RUN: yaml2obj %s -o %t
1 # RUN: llvm-nm -B -S %t | FileCheck --match-full-lines %s
2 # RUN: llvm-nm -W -B -S %t | count 0
3 !ELF
4 FileHeader:
5 Class: ELFCLASS64
6 Data: ELFDATA2LSB
7 Type: ET_REL
8 Machine: EM_X86_64
9 Sections:
10 - Name: .text
11 Type: SHT_PROGBITS
12 - Name: .data
13 Type: SHT_PROGBITS
14 Symbols:
15 - Name: weak_func
16 Type: STT_FUNC
17 Section: .text
18 Binding: STB_WEAK
19 Size: 17
20 - Name: weak_var
21 Type: STT_OBJECT
22 Section: .data
23 Binding: STB_WEAK
24 Size: 4
25 - Name: weak_extern_func
26 Type: STT_FUNC
27 Binding: STB_WEAK
28 - Name: weak_extern_var
29 Type: STT_OBJECT
30 Binding: STB_WEAK
0 # RUN: llvm-nm -B -S %p/Inputs/weak.obj.elf-x86_64 | FileCheck --match-full-lines %s
1 # RUN: llvm-nm -W -B -S %p/Inputs/weak.obj.elf-x86_64 | count 0
312
32 # CHECK: w weak_extern_func
33 # CHECK: v weak_extern_var
34 # CHECK: 0000000000000000 0000000000000011 W weak_func
35 # CHECK: 0000000000000000 0000000000000004 V weak_var
3 CHECK: w weak_extern_func
4 CHECK: w weak_extern_var
5 CHECK: 0000000000000000 0000000000000011 W weak_func
6 CHECK: 0000000000000000 0000000000000004 V weak_var
900900
901901 elf_section_iterator SecI = *SecIOrErr;
902902 if (SecI != Obj.section_end()) {
903 uint32_t Type = SecI->getType();
904 uint64_t Flags = SecI->getFlags();
905 if (Type == ELF::SHT_NOBITS)
903 switch (SecI->getType()) {
904 case ELF::SHT_PROGBITS:
905 case ELF::SHT_DYNAMIC:
906 switch (SecI->getFlags()) {
907 case (ELF::SHF_ALLOC | ELF::SHF_EXECINSTR):
908 return 't';
909 case (ELF::SHF_TLS | ELF::SHF_ALLOC | ELF::SHF_WRITE):
910 case (ELF::SHF_ALLOC | ELF::SHF_WRITE):
911 return 'd';
912 case ELF::SHF_ALLOC:
913 case (ELF::SHF_ALLOC | ELF::SHF_MERGE):
914 case (ELF::SHF_ALLOC | ELF::SHF_MERGE | ELF::SHF_STRINGS):
915 return 'r';
916 }
917 break;
918 case ELF::SHT_NOBITS:
906919 return 'b';
907 if (Flags & ELF::SHF_EXECINSTR)
920 case ELF::SHT_INIT_ARRAY:
921 case ELF::SHT_FINI_ARRAY:
908922 return 't';
909 if (Flags & ELF::SHF_ALLOC)
910 return Flags & ELF::SHF_WRITE ? 'd' : 'r';
923 }
924 }
925
926 if (SymI->getELFType() == ELF::STT_SECTION) {
911927 Expected Name = SymI->getName();
912928 if (!Name) {
913929 consumeError(Name.takeError());
914930 return '?';
915931 }
916 if (Name->startswith(".debug"))
917 return 'N';
918 if (!(Flags & ELF::SHF_WRITE))
919 return 'n';
920 }
921
922 return '?';
932 return StringSwitch(*Name)
933 .StartsWith(".debug", 'N')
934 .StartsWith(".note", 'n')
935 .StartsWith(".comment", 'n')
936 .Default('?');
937 }
938
939 return 'n';
923940 }
924941
925942 static char getSymbolNMTypeChar(COFFObjectFile &Obj, symbol_iterator I) {