From ba81685d97621f4d7ae09a84aa0ef01da7515871 Mon Sep 17 00:00:00 2001
From: Ingmar Steen <iksteen@gmail.com>
Date: Mon, 9 May 2016 21:40:24 +0200
Subject: [PATCH] Disable relocation addend for all targets.

Since Keystone will not be generating actual ELF files, relocation
addends prevent symbol addresses from being inlined in the output.
---
 llvm/lib/MC/ELFObjectWriter.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 3933183..8f17f7d 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -126,7 +126,9 @@ class ELFObjectWriter : public MCObjectWriter {
     // TargetObjectWriter wrappers.
     bool is64Bit() const { return TargetObjectWriter->is64Bit(); }
     bool hasRelocationAddend() const {
-      return TargetObjectWriter->hasRelocationAddend();
+      // Keystone doesn't want relocation addends.
+      /* return TargetObjectWriter->hasRelocationAddend(); */
+      return false;
     }
     unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
                           const MCFixup &Fixup, bool IsPCRel) const {
-- 
GitLab