From: Robert Pengelly Date: Tue, 10 Jun 2025 14:39:44 +0000 (+0100) Subject: COFF fix X-Git-Url: https://git.candlhat.org/?a=commitdiff_plain;h=d2fb415849afa0132f67484a961a0a8dfb89d209;p=sasm.git COFF fix --- diff --git a/coff.c b/coff.c index 7c9d679..71361e8 100644 --- 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 a944fc0..7451b61 100644 --- 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 27c7c6c..29b0977 100644 --- 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;