Skip to content

Commit

Permalink
Ensure TPA relocation table is at even offset
Browse files Browse the repository at this point in the history
This is not a strict requirement for TOS/FreeMiNT,
but ADEBUG fails to load such program with "Relocation error".

freemint/m68k-atari-mint-binutils-gdb#4

The TPA relocation table should always be aligned
because it is located just after the ELF Section Headers.
  • Loading branch information
vinriviere authored and th-otto committed Aug 8, 2024
1 parent 8b18b32 commit fc1ab62
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bfd/elf32-atariprg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit fc1ab62

Please sign in to comment.