COFF fix
authorRobert Pengelly <robertapengelly@hotmail.com>
Tue, 10 Jun 2025 14:39:44 +0000 (15:39 +0100)
committerRobert Pengelly <robertapengelly@hotmail.com>
Tue, 10 Jun 2025 14:39:44 +0000 (15:39 +0100)
coff.c
fixup.c
intel.c

diff --git a/coff.c b/coff.c
index 7c9d679a0e4a2026e606d42a562dc4aea4109222..71361e8b8a9c0d3966803e991de9f78483d913a0 100644 (file)
--- a/coff.c
+++ b/coff.c
@@ -86,6 +86,7 @@ static int output_relocation (FILE *outfile, struct fixup *fixup) {
         switch (fixup->reloc_type) {
         
             case RELOC_TYPE_DEFAULT:
+            case RELOC_TYPE_FAR_CALL:
             
                 switch (fixup->size) {
                 
diff --git a/fixup.c b/fixup.c
index a944fc086432b7d82ea2dfefb7511e0b3dbcb9ec..7451b61e27ca398a232e1ae7897223ccd6a46617 100644 (file)
--- a/fixup.c
+++ b/fixup.c
@@ -455,8 +455,8 @@ static unsigned long fixup_section (struct section *section) {
         if (fixup->sub_symbol) {
         
             struct section *sub_symbol_section;
-            
             symbol_resolve_value (fixup->sub_symbol);
+            
             sub_symbol_section = symbol_get_section (fixup->sub_symbol);
             
             if (fixup->add_symbol && add_symbol_section == sub_symbol_section && !symbol_force_reloc (fixup->add_symbol) && !symbol_force_reloc (fixup->add_symbol)) {
diff --git a/intel.c b/intel.c
index 27c7c6c528222dbb61ebdedbf1c58e9601ac8bd4..29b097704fd2eba4a0813da092e3fb9ca371993e 100644 (file)
--- a/intel.c
+++ b/intel.c
@@ -5616,7 +5616,7 @@ static void output_call_or_jumpbyte (void) {
     
     }
     
-    if (fixup && size == 1) {
+    if (fixup) {
     
         switch (size) {
         
@@ -6155,6 +6155,15 @@ void machine_dependent_apply_fixup (struct fixup *fixup, unsigned long value) {
         fixup->done = 1;
     }
     
+    if (state->format == AS_OUTPUT_WIN32 || state->format == AS_OUTPUT_WIN64) {
+    
+        /* Not sure why but COFF requires this adjustment. */
+        if (fixup->pcrel && fixup->add_symbol && symbol_get_section (fixup->add_symbol) != current_section) {
+            value += machine_dependent_pcrel_from (fixup);
+        }
+    
+    }
+    
     if (fixup->reloc_type == RELOC_TYPE_FAR_CALL) {
     
         *(p - 1) = (state->model > 4) ? 0xFF : 0x9A;