diff --git a/lld/test/ELF/ppc64-ifunc.s b/lld/test/ELF/ppc64-ifunc.s --- a/lld/test/ELF/ppc64-ifunc.s +++ b/lld/test/ELF/ppc64-ifunc.s @@ -15,8 +15,8 @@ # RUN: llvm-readobj -r %t | FileCheck --check-prefix=REL %s # NM-DAG: 0000000010028248 d .TOC. -# NM-DAG: 00000000100101f8 T ifunc -# NM-DAG: 00000000100101fc T ifunc2 +# NM-DAG: 00000000100101f8 i ifunc +# NM-DAG: 00000000100101fc i ifunc2 # SECTIONS: .plt NOBITS 0000000010030250 000250 000010 00 WA 0 0 8 diff --git a/llvm/test/LTO/Resolution/X86/ifunc.ll b/llvm/test/LTO/Resolution/X86/ifunc.ll --- a/llvm/test/LTO/Resolution/X86/ifunc.ll +++ b/llvm/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/llvm/test/tools/llvm-nm/ifunc.test b/llvm/test/tools/llvm-nm/ifunc.test new file mode 100644 --- /dev/null +++ b/llvm/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/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp --- a/llvm/tools/llvm-nm/llvm-nm.cpp +++ b/llvm/tools/llvm-nm/llvm-nm.cpp @@ -1133,15 +1133,18 @@ 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); }