From fc1ab62cf02fd24487523f2feab23ff8d6a9e4c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Rivi=C3=A8re?= Date: Tue, 29 Aug 2023 21:47:26 +0200 Subject: [PATCH] Ensure TPA relocation table is at even offset This is not a strict requirement for TOS/FreeMiNT, but ADEBUG fails to load such program with "Relocation error". https://github.com/freemint/m68k-atari-mint-binutils-gdb/issues/4 The TPA relocation table should always be aligned because it is located just after the ELF Section Headers. --- bfd/elf32-atariprg.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bfd/elf32-atariprg.c b/bfd/elf32-atariprg.c index e5cba487aa3..f72722ecf9c 100644 --- a/bfd/elf32-atariprg.c +++ b/bfd/elf32-atariprg.c @@ -39,6 +39,9 @@ #define ADR_F "0x%08" PRIx32 typedef uint32_t adr_t; +/* Test if an integer is even. */ +#define IS_EVEN(x) (((x) & 1) == 0) + /* The main idea here is to reuse the elf32-m68k target, but with a few overrides to add a PRG extended header before ELF data, and a PRG relocation table just after. So the ELF executable is actually embedded into a standard @@ -637,6 +640,7 @@ write_prgelf_header (bfd *abfd) /* We will write the TPA relocation table right after the ELF data. */ myinfo->tparel_pos = elf_next_file_pos (abfd); + BFD_ASSERT (IS_EVEN (myinfo->tparel_pos)); /* Compute the size of the PRG symbol table. */ prg_symbols_size = myinfo->tparel_pos - myinfo->nonload_pos;