Index: llvm/trunk/test/ThinLTO/X86/strong_non_prevailing.ll =================================================================== --- llvm/trunk/test/ThinLTO/X86/strong_non_prevailing.ll +++ llvm/trunk/test/ThinLTO/X86/strong_non_prevailing.ll @@ -12,5 +12,5 @@ @__llvm_profile_filename = constant [19 x i8] c"default_%m.profraw\00", comdat -; EXPORTED: N __llvm_profile_filename -; NOT_EXPORTED-NOT: N __llvm_profile_filename +; EXPORTED: R __llvm_profile_filename +; NOT_EXPORTED-NOT: R __llvm_profile_filename Index: llvm/trunk/test/tools/llvm-nm/X86/init-fini.test =================================================================== --- llvm/trunk/test/tools/llvm-nm/X86/init-fini.test +++ llvm/trunk/test/tools/llvm-nm/X86/init-fini.test @@ -1,8 +0,0 @@ -# RUN: llvm-nm -B -S %p/Inputs/init-fini.out.elf-x86_64 | FileCheck --match-full-lines %s - -CHECK: 00000000006000c2 0000000000000000 T __bss_start -CHECK: 00000000006000c2 0000000000000000 t __init_array_end -CHECK: 00000000006000ba 0000000000000000 t __init_array_start -CHECK: 00000000006000c2 0000000000000000 T _edata -CHECK: 00000000006000c8 0000000000000000 T _end -CHECK: 00000000004000b0 0000000000000000 T _start Index: llvm/trunk/test/tools/llvm-nm/data.test =================================================================== --- llvm/trunk/test/tools/llvm-nm/data.test +++ llvm/trunk/test/tools/llvm-nm/data.test @@ -0,0 +1,43 @@ +# RUN: yaml2obj %s -o %t +# RUN: llvm-nm --no-sort %t | FileCheck %s + +# CHECK: b mybss_local +# CHECK-NEXT: d mydata_local +# CHECK-NEXT: d mytdata_local +# CHECK-NEXT: B mybss_global +# CHECK-NEXT: D mydata_global +# CHECK-NEXT: D mytdata_global + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 +Sections: + - Name: mybss + Type: SHT_NOBITS + Flags: [ SHF_ALLOC, SHF_WRITE ] + - Name: mydata + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_WRITE ] + - Name: mytdata + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_WRITE, SHF_TLS ] +Symbols: + - Name: mybss_local + Section: mybss + - Name: mydata_local + Section: mydata + - Name: mytdata_local + Section: mytdata + + - Name: mybss_global + Binding: STB_GLOBAL + Section: mybss + - Name: mydata_global + Binding: STB_GLOBAL + Section: mydata + - Name: mytdata_global + Binding: STB_GLOBAL + Section: mytdata Index: llvm/trunk/test/tools/llvm-nm/linker-synthesized.test =================================================================== --- llvm/trunk/test/tools/llvm-nm/linker-synthesized.test +++ llvm/trunk/test/tools/llvm-nm/linker-synthesized.test @@ -0,0 +1,57 @@ +# RUN: yaml2obj %s -o %t +# RUN: llvm-nm --no-sort %t | FileCheck %s + +## We used to be wrong with some linker synthesized symbols. + +## We mark __init_array_start as 'd', as consistent with GNU nm >= 2.33 (older GNU +## nm marks it as 't'). See https://sourceware.org/bugzilla/show_bug.cgi?id=24511 + +# CHECK: d __fini_array_start +# CHECK: d __init_array_start +# CHECK: d __preinit_array_start +# CHECK: B __bss_start +# CHECK: D _edata +# CHECK: B _end + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + - Name: .fini_array + Type: SHT_FINI_ARRAY + Flags: [ SHF_ALLOC, SHF_WRITE ] + - Name: .init_array + Type: SHT_INIT_ARRAY + Flags: [ SHF_ALLOC, SHF_WRITE ] + - Name: .preinit_array + Type: SHT_PREINIT_ARRAY + Flags: [ SHF_ALLOC, SHF_WRITE ] + - Name: .data + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_WRITE ] + - Name: .bss + Type: SHT_NOBITS + Flags: [ SHF_ALLOC, SHF_WRITE ] +Symbols: + - Name: __fini_array_start + Section: .fini_array + - Name: __init_array_start + Section: .init_array + - Name: __preinit_array_start + Section: .preinit_array + + - Name: __bss_start + Section: .bss + Binding: STB_GLOBAL + - Name: _edata + Section: .data + Binding: STB_GLOBAL + - Name: _end + Section: .bss + Binding: STB_GLOBAL Index: llvm/trunk/test/tools/llvm-nm/nobits.test =================================================================== --- llvm/trunk/test/tools/llvm-nm/nobits.test +++ llvm/trunk/test/tools/llvm-nm/nobits.test @@ -0,0 +1,35 @@ +# RUN: yaml2obj %s -o %t +# RUN: llvm-nm --no-sort %t | FileCheck %s + +# CHECK: b mybss_local +# CHECK: b mytbss_local +# CHECK: B mybss_global +# CHECK: B mytbss_global + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: mybss + Type: SHT_NOBITS + Flags: [ SHF_ALLOC, SHF_WRITE ] + - Name: mytbss + Type: SHT_NOBITS + Flags: [ SHF_ALLOC, SHF_WRITE, SHF_TLS ] +Symbols: + - Name: mybss_local + Binding: STB_LOCAL + Section: mybss + - Name: mytbss_local + Binding: STB_LOCAL + Section: mytbss + + - Name: mybss_global + Binding: STB_GLOBAL + Section: mybss + - Name: mytbss_global + Binding: STB_GLOBAL + Section: mytbss Index: llvm/trunk/test/tools/llvm-nm/nonalloc.test =================================================================== --- llvm/trunk/test/tools/llvm-nm/nonalloc.test +++ llvm/trunk/test/tools/llvm-nm/nonalloc.test @@ -0,0 +1,17 @@ +# RUN: yaml2obj %s -o %t +# RUN: llvm-nm --no-sort %t | FileCheck %s + +# CHECK: n debug_info_main + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .debug_info + Type: SHT_PROGBITS +Symbols: + - Name: debug_info_main + Section: .debug_info Index: llvm/trunk/test/tools/llvm-nm/readonly.test =================================================================== --- llvm/trunk/test/tools/llvm-nm/readonly.test +++ llvm/trunk/test/tools/llvm-nm/readonly.test @@ -0,0 +1,43 @@ +# RUN: yaml2obj %s -o %t +# RUN: llvm-nm --no-sort %t | FileCheck %s + +# CHECK: r myrodata0_local +# CHECK-NEXT: r myrodata1_local +# CHECK-NEXT: r myrodata2_local +# CHECK-NEXT: R myrodata0_global +# CHECK-NEXT: R myrodata1_global +# CHECK-NEXT: R myrodata2_global + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 +Sections: + - Name: myrodata0 + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + - Name: myrodata1 + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_MERGE ] + - Name: myrodata2 + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_MERGE, SHF_STRINGS ] +Symbols: + - Name: myrodata0_local + Section: myrodata0 + - Name: myrodata1_local + Section: myrodata1 + - Name: myrodata2_local + Section: myrodata2 + + - Name: myrodata0_global + Binding: STB_GLOBAL + Section: myrodata0 + - Name: myrodata1_global + Binding: STB_GLOBAL + Section: myrodata1 + - Name: myrodata2_global + Binding: STB_GLOBAL + Section: myrodata2 Index: llvm/trunk/tools/llvm-nm/llvm-nm.cpp =================================================================== --- llvm/trunk/tools/llvm-nm/llvm-nm.cpp +++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp @@ -901,27 +901,14 @@ elf_section_iterator SecI = *SecIOrErr; if (SecI != Obj.section_end()) { - switch (SecI->getType()) { - case ELF::SHT_PROGBITS: - case ELF::SHT_DYNAMIC: - switch (SecI->getFlags()) { - case (ELF::SHF_ALLOC | ELF::SHF_EXECINSTR): - return 't'; - case (ELF::SHF_TLS | ELF::SHF_ALLOC | ELF::SHF_WRITE): - case (ELF::SHF_ALLOC | ELF::SHF_WRITE): - return 'd'; - case ELF::SHF_ALLOC: - case (ELF::SHF_ALLOC | ELF::SHF_MERGE): - case (ELF::SHF_ALLOC | ELF::SHF_MERGE | ELF::SHF_STRINGS): - return 'r'; - } - break; - case ELF::SHT_NOBITS: - return 'b'; - case ELF::SHT_INIT_ARRAY: - case ELF::SHT_FINI_ARRAY: + uint32_t Type = SecI->getType(); + uint64_t Flags = SecI->getFlags(); + if (Flags & ELF::SHF_EXECINSTR) return 't'; - } + if (Type == ELF::SHT_NOBITS) + return 'b'; + if (Flags & ELF::SHF_ALLOC) + return Flags & ELF::SHF_WRITE ? 'd' : 'r'; } if (SymI->getELFType() == ELF::STT_SECTION) {