[PATCH] D71803: [llvm-nm] Display STT_GNU_IFUNC as 'i'
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 24 09:54:07 PST 2019
MaskRay updated this revision to Diff 235225.
MaskRay added a comment.
Add llvm_unreachable
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71803/new/
https://reviews.llvm.org/D71803
Files:
lld/test/ELF/ppc64-ifunc.s
llvm/test/LTO/Resolution/X86/ifunc.ll
llvm/test/tools/llvm-nm/ifunc.test
llvm/tools/llvm-nm/llvm-nm.cpp
Index: llvm/tools/llvm-nm/llvm-nm.cpp
===================================================================
--- llvm/tools/llvm-nm/llvm-nm.cpp
+++ llvm/tools/llvm-nm/llvm-nm.cpp
@@ -1133,8 +1133,12 @@
Ret = getSymbolNMTypeChar(*MachO, I);
else if (WasmObjectFile *Wasm = dyn_cast<WasmObjectFile>(&Obj))
Ret = getSymbolNMTypeChar(*Wasm, I);
- else
- Ret = getSymbolNMTypeChar(cast<ELFObjectFileBase>(Obj), I);
+ else if (ELFObjectFileBase *ELF = dyn_cast<ELFObjectFileBase>(&Obj)) {
+ if (elf_symbol_iterator(I)->getELFType() == ELF::STT_GNU_IFUNC)
+ return 'i';
+ Ret = getSymbolNMTypeChar(*ELF, I);
+ } else
+ llvm_unreachable("unknown binary format");
if (!(Symflags & object::SymbolRef::SF_Global))
return Ret;
Index: llvm/test/tools/llvm-nm/ifunc.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-nm/ifunc.test
@@ -0,0 +1,25 @@
+# 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
Index: llvm/test/LTO/Resolution/X86/ifunc.ll
===================================================================
--- llvm/test/LTO/Resolution/X86/ifunc.ll
+++ 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"
Index: lld/test/ELF/ppc64-ifunc.s
===================================================================
--- lld/test/ELF/ppc64-ifunc.s
+++ 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71803.235225.patch
Type: text/x-patch
Size: 2468 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191224/838a2fbc/attachment.bin>
More information about the llvm-commits
mailing list