[llvm] a3e975d - Fixes handling logic for i386/ELF GOTPC relocation
Kshitij Jain via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 13 21:02:11 PST 2023
Author: Kshitij Jain
Date: 2023-01-14T05:01:49Z
New Revision: a3e975d42efa2ec1349c1a3ce203d78bbd7ee10d
URL: https://github.com/llvm/llvm-project/commit/a3e975d42efa2ec1349c1a3ce203d78bbd7ee10d
DIFF: https://github.com/llvm/llvm-project/commit/a3e975d42efa2ec1349c1a3ce203d78bbd7ee10d.diff
LOG: Fixes handling logic for i386/ELF GOTPC relocation
The i386/ELF JITLink backend was not correctly handling the GOTPC relocation
by skipping the in-built addend, which was manifesting itself in the form of
a segmentation fault in the `LF_external_to_absolute_conversion.s` test. This
CR has fixed that issue.
Reviewed By: lhames
Differential Revision: https://reviews.llvm.org/D141746
Added:
Modified:
llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp
index 07f5ecc789428..dec59e4137a38 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp
@@ -11,14 +11,13 @@
//===----------------------------------------------------------------------===//
#include "llvm/ExecutionEngine/JITLink/ELF_i386.h"
+#include "DefineExternalSectionStartAndEndSymbols.h"
#include "ELFLinkGraphBuilder.h"
#include "JITLinkGeneric.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/ExecutionEngine/JITLink/i386.h"
#include "llvm/Object/ELFObjectFile.h"
-#include "DefineExternalSectionStartAndEndSymbols.h"
-
#define DEBUG_TYPE "jitlink"
using namespace llvm;
@@ -180,9 +179,18 @@ class ELFLinkGraphBuilder_i386 : public ELFLinkGraphBuilder<ELFT> {
if (!Kind)
return Kind.takeError();
+ auto FixupAddress = orc::ExecutorAddr(FixupSection.sh_addr) + Rel.r_offset;
int64_t Addend = 0;
- auto FixupAddress = orc::ExecutorAddr(FixupSection.sh_addr) + Rel.r_offset;
+ switch (*Kind) {
+ case i386::EdgeKind_i386::Delta32: {
+ const char *FixupContent = BlockToFix.getContent().data() +
+ (FixupAddress - BlockToFix.getAddress());
+ Addend = *(const support::ulittle32_t *)FixupContent;
+ break;
+ }
+ }
+
Edge::OffsetT Offset = FixupAddress - BlockToFix.getAddress();
Edge GE(*Kind, Offset, *GraphSymbol, Addend);
LLVM_DEBUG({
More information about the llvm-commits
mailing list