[llvm] 0136f22 - [MC] Don't resolve relocations referencing STB_LOCAL STT_GNU_IFUNC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 13 23:37:26 PST 2020
Author: Fangrui Song
Date: 2020-01-13T23:36:06-08:00
New Revision: 0136f226c4e46258ea73fcb994f6559cec4a9aa2
URL: https://github.com/llvm/llvm-project/commit/0136f226c4e46258ea73fcb994f6559cec4a9aa2
DIFF: https://github.com/llvm/llvm-project/commit/0136f226c4e46258ea73fcb994f6559cec4a9aa2.diff
LOG: [MC] Don't resolve relocations referencing STB_LOCAL STT_GNU_IFUNC
Added:
Modified:
llvm/lib/MC/ELFObjectWriter.cpp
llvm/test/MC/ELF/target-in-same-section.s
Removed:
################################################################################
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index b421d0b2bf68..6b4b45eb8eff 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -1514,7 +1514,8 @@ bool ELFObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(
const auto &SymA = cast<MCSymbolELF>(SA);
if (IsPCRel) {
assert(!InSet);
- if (SymA.getBinding() != ELF::STB_LOCAL)
+ if (SymA.getBinding() != ELF::STB_LOCAL ||
+ SymA.getType() == ELF::STT_GNU_IFUNC)
return false;
}
return MCObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(Asm, SymA, FB,
diff --git a/llvm/test/MC/ELF/target-in-same-section.s b/llvm/test/MC/ELF/target-in-same-section.s
index dbdacaffdb7f..8e8e1e7c6078 100644
--- a/llvm/test/MC/ELF/target-in-same-section.s
+++ b/llvm/test/MC/ELF/target-in-same-section.s
@@ -9,6 +9,7 @@
# RELOC-NEXT: 0xA R_X86_64_PLT32 weak 0xFFFFFFFFFFFFFFFC
# RELOC-NEXT: 0x19 R_X86_64_PLT32 global 0xFFFFFFFFFFFFFFFC
# RELOC-NEXT: 0x1E R_X86_64_PLT32 weak 0xFFFFFFFFFFFFFFFC
+# RELOC-NEXT: 0x23 R_X86_64_PLT32 ifunc 0xFFFFFFFFFFFFFFFC
# RELOC-NEXT: }
# CHECK: 0: jmp
@@ -19,14 +20,17 @@
# CHECK-NEXT: 13: callq
# CHECK-NEXT: 18: callq
# CHECK-NEXT: 1d: callq
-# CHECK-NEXT: 22: retq
+# CHECK-NEXT: 22: callq
+# CHECK-NEXT: 27: retq
.globl global
.weak weak
+.type ifunc, at gnu_indirect_function
global:
weak:
local:
.set var,global
+ifunc:
jmp var
jmp local
jmp global
@@ -36,4 +40,6 @@ local:
call local
call global
call weak
+
+ call ifunc
ret
More information about the llvm-commits
mailing list