diff --git a/test/LTO/Resolution/X86/ifunc.ll b/test/LTO/Resolution/X86/ifunc.ll index 5a437fddbcb..7192ea2d5f7 100644 --- a/test/LTO/Resolution/X86/ifunc.ll +++ b/test/LTO/Resolution/X86/ifunc.ll @@ -1,7 +1,7 @@ ; RUN: opt -module-summary -o %t.bc %s ; RUN: llvm-lto2 run %t.bc -r %t.bc,foo,pl -o %t2 ; RUN: llvm-nm %t2.1 | FileCheck %s -; CHECK: T foo +; CHECK: i foo ; CHECK: t foo_ifunc target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" diff --git a/test/tools/llvm-nm/ifunc.test b/test/tools/llvm-nm/ifunc.test new file mode 100644 index 00000000000..fdc3ced971a --- /dev/null +++ b/test/tools/llvm-nm/ifunc.test @@ -0,0 +1,27 @@ +## Test that the symbol type of STT_GNU_IFUNC is 'i'. + +# RUN: yaml2obj %s -o %t +# RUN: llvm-nm --no-sort %t | FileCheck %s + +# CHECK: i ifunc_local +# CHECK-NEXT: i ifunc_global + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] +Symbols: + - Name: ifunc_local + Type: STT_GNU_IFUNC + Binding: STB_LOCAL + Section: .text + - Name: ifunc_global + Type: STT_GNU_IFUNC + Binding: STB_GLOBAL + Section: .text diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index ee55722dc13..107d62b1f2b 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -1133,15 +1133,18 @@ static char getNMSectionTagAndName(SymbolicFile &Obj, basic_symbol_iterator I, Ret = getSymbolNMTypeChar(*MachO, I); else if (WasmObjectFile *Wasm = dyn_cast(&Obj)) Ret = getSymbolNMTypeChar(*Wasm, I); - else - Ret = getSymbolNMTypeChar(cast(Obj), I); + else if (ELFObjectFileBase *ELF = dyn_cast(&Obj)) { + if (ELFSymbolRef(*I).getELFType() == ELF::STT_GNU_IFUNC) + return 'i'; + Ret = getSymbolNMTypeChar(*ELF, I); + if (ELFSymbolRef(*I).getBinding() == ELF::STB_GNU_UNIQUE) + return Ret; + } else + llvm_unreachable("unknown binary format"); if (!(Symflags & object::SymbolRef::SF_Global)) return Ret; - if (Obj.isELF() && ELFSymbolRef(*I).getBinding() == ELF::STB_GNU_UNIQUE) - return Ret; - return toupper(Ret); }