[llvm] d4a5bef - ExecutionEngine: support `IMAGE_REL_AMD64_SECTION` relocations

Saleem Abdulrasool via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 27 12:41:01 PDT 2023


Author: Saleem Abdulrasool
Date: 2023-07-27T12:40:42-07:00
New Revision: d4a5bef170ce7c52c9f8bd3763c4b181da7d21c6

URL: https://github.com/llvm/llvm-project/commit/d4a5bef170ce7c52c9f8bd3763c4b181da7d21c6
DIFF: https://github.com/llvm/llvm-project/commit/d4a5bef170ce7c52c9f8bd3763c4b181da7d21c6.diff

LOG: ExecutionEngine: support `IMAGE_REL_AMD64_SECTION` relocations

This relocation type is often used for debug information on Windows.  We
would previously abort due to the unreachable for the unhandled
relocation type.  Add support for this to prevent LLDB from aborting if
it encounters this relocation type.

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
    llvm/test/ExecutionEngine/RuntimeDyld/X86/COFF_x86_64.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
index 89156b992d87ad..43ce64af86852e 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
@@ -134,6 +134,13 @@ class RuntimeDyldCOFFX86_64 : public RuntimeDyldCOFF {
       break;
     }
 
+    case COFF::IMAGE_REL_AMD64_SECTION: {
+      assert(static_cast<int16_t>(RE.SectionID) <= INT16_MAX && "Relocation overflow");
+      assert(static_cast<int16_t>(RE.SectionID) >= INT16_MIN && "Relocation underflow");
+      writeBytesUnaligned(RE.SectionID, Target, 2);
+      break;
+    }
+
     default:
       llvm_unreachable("Relocation type not implemented yet!");
       break;

diff  --git a/llvm/test/ExecutionEngine/RuntimeDyld/X86/COFF_x86_64.s b/llvm/test/ExecutionEngine/RuntimeDyld/X86/COFF_x86_64.s
index e0f77d49421a00..d63bcfc6df3446 100644
--- a/llvm/test/ExecutionEngine/RuntimeDyld/X86/COFF_x86_64.s
+++ b/llvm/test/ExecutionEngine/RuntimeDyld/X86/COFF_x86_64.s
@@ -4,6 +4,15 @@
 # RUN:   -dummy-extern external_data=0x2 -verify -check=%s %t/COFF_x86_64.o
 
 
+	.section section,"rx"
+section:
+	.long 0
+Lreloc:
+	.long 0
+# rtdyld-check: *{2}Lreloc = 1
+	.reloc 4, secidx, section+4
+
+
         .text
 	.def	 F;
 	.scl	2;


        


More information about the llvm-commits mailing list