[llvm] def68dc - llvm-tli-checker: Take ifunc symbols into account (#158596)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 26 07:25:25 PDT 2025
Author: Gleb Popov
Date: 2025-09-26T16:25:20+02:00
New Revision: def68dccf71dbcbd2c846138dc9402dcde5a8397
URL: https://github.com/llvm/llvm-project/commit/def68dccf71dbcbd2c846138dc9402dcde5a8397
DIFF: https://github.com/llvm/llvm-project/commit/def68dccf71dbcbd2c846138dc9402dcde5a8397.diff
LOG: llvm-tli-checker: Take ifunc symbols into account (#158596)
FreeBSD libc has a lot of symbols that are ifuncs, which makes TLI
checker believe they are not available. This change makes the tool
consider symbols with the STT_GNU_IFUNC type.
Added:
llvm/test/tools/llvm-tli-checker/ifuncs.yaml
Modified:
llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-tli-checker/ifuncs.yaml b/llvm/test/tools/llvm-tli-checker/ifuncs.yaml
new file mode 100644
index 0000000000000..4eae66c3051a7
--- /dev/null
+++ b/llvm/test/tools/llvm-tli-checker/ifuncs.yaml
@@ -0,0 +1,39 @@
+# REQUIRES: x86-registered-target
+#
+# stpncpy is declared as available in TargetLibraryInfo for FreeBSD, but
+# llvm-tli-checker won't be able to find it unless it knows how to check ifuncs.
+# This test makes sure that llvm-tli-checker supports processing ifuncs.
+#
+# RUN: yaml2obj %s -o=%t1
+# RUN: llvm-tli-checker --triple=x86_64-unknown-freebsd %t1 | FileCheck %s
+#
+# CHECK: == Total TLI yes SDK yes: 1
+#
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ OSABI: ELFOSABI_FREEBSD
+ Type: ET_DYN
+ Machine: EM_X86_64
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ - Name: .rela.plt
+ Type: SHT_RELA
+ Flags: [ SHF_ALLOC, SHF_INFO_LINK ]
+ Address: 0x3CA20
+ Link: .dynsym
+ AddressAlign: 0x8
+ Relocations:
+ - Offset: 0x1E2C68
+ Symbol: stpncpy
+ Type: R_X86_64_JUMP_SLOT
+DynamicSymbols:
+ - Name: stpncpy
+ Type: STT_GNU_IFUNC
+ Section: .text
+ Binding: STB_WEAK
+ Value: 0x15D5E0
+ Size: 0xC
diff --git a/llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp b/llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
index 3cd5d597ee133..0cf8c5c63bef2 100644
--- a/llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
+++ b/llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
@@ -153,8 +153,12 @@ void SDKNameMap::maybeInsertSymbol(const SymbolRef &S, const ObjectFile &O) {
uint32_t Flags = unwrapIgnoreError(S.getFlags());
section_iterator Section = unwrapIgnoreError(S.getSection(),
/*Default=*/O.section_end());
- if (Type == SymbolRef::ST_Function && (Flags & SymbolRef::SF_Global) &&
- Section != O.section_end()) {
+ bool IsRegularFunction = Type == SymbolRef::ST_Function &&
+ (Flags & SymbolRef::SF_Global) &&
+ Section != O.section_end();
+ bool IsIFunc =
+ Type == SymbolRef::ST_Other && (Flags & SymbolRef::SF_Indirect);
+ if (IsRegularFunction || IsIFunc) {
StringRef Name = unwrapIgnoreError(S.getName());
insert({ Name, true });
}
More information about the llvm-commits
mailing list