[PATCH 1/3] bfd/x86-64: support COFF relocation type R_AMD64_ABS

Jan Beulich jbeulich@suse.com
Fri Nov 6 11:11:46 GMT 2026


Much like ELF's R_X86_64_NONE it can be of use, and it is known in the
Windows world as well (as IMAGE_REL_AMD64_ABSOLUTE).
---
Likely other targets (at least aarch64, i386, and sh) would need to
follow suit (the testcase added by the subsequent patch therefore XFAILs
those targets). Interestingly mcore already has the entry properly set up,
yet it's not really usable yet due to mcore_coff_reloc_type_lookup() not
recognizing BFD_RELOC_NONE.

--- a/bfd/coff-x86_64.c
+++ b/bfd/coff-x86_64.c
@@ -224,6 +224,7 @@ static bool
 in_reloc_p (bfd *abfd ATTRIBUTE_UNUSED, reloc_howto_type *howto)
 {
   return ! howto->pc_relative
+    && howto->type != R_AMD64_ABS
     && howto->type != R_AMD64_IMAGEBASE
     && howto->type != R_AMD64_SECREL
     && howto->type != R_AMD64_SECTION;
@@ -236,7 +237,19 @@ in_reloc_p (bfd *abfd ATTRIBUTE_UNUSED,
 
 static reloc_howto_type howto_table[] =
 {
-  EMPTY_HOWTO (0),
+  HOWTO (R_AMD64_ABS,		/* type 0 */
+	 0,			/* rightshift */
+	 0,			/* size */
+	 0,			/* bitsize */
+	 false,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,
+	 NULL,			/* special_function */
+	 "IMAGE_REL_AMD64_ABSOLUTE", /* name */
+	 false,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0,			/* dst_mask */
+	 false),		/* pcrel_offset */
   HOWTO (R_AMD64_DIR64,		/* type  1*/
 	 0,			/* rightshift */
 	 8,			/* size */
@@ -811,6 +824,8 @@ coff_amd64_reloc_type_lookup (bfd *abfd
 {
   switch (code)
     {
+    case BFD_RELOC_NONE:
+      return howto_table + R_AMD64_ABS;
     case BFD_RELOC_RVA:
       return howto_table + R_AMD64_IMAGEBASE;
     case BFD_RELOC_32:



More information about the Binutils mailing list