From 7e964dd25ed37930144dab92d484b9e2dd1b1471 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 14 Mar 2016 21:08:55 +0100 Subject: [PATCH] Raise the limit on ack.out relocation types by making the size of a relocation structure bigger. Bump ack.out magic number. --HG-- branch : default-branch --- h/out.h | 54 +++++++++++++++++++++++++--------------------- util/led/ack.out.5 | 49 ++++++++++++++++++++--------------------- 2 files changed, 54 insertions(+), 49 deletions(-) diff --git a/h/out.h b/h/out.h index cf6ef7776..16c22be51 100644 --- a/h/out.h +++ b/h/out.h @@ -6,22 +6,25 @@ #ifndef __OUT_H_INCLUDED #define __OUT_H_INCLUDED + +#include + /* * output format for ACK assemblers */ struct outhead { - unsigned short oh_magic; /* magic number */ - unsigned short oh_stamp; /* version stamp */ - unsigned short oh_flags; /* several format flags */ - unsigned short oh_nsect; /* number of outsect structures */ - unsigned short oh_nrelo; /* number of outrelo structures */ - unsigned short oh_nname; /* number of outname structures */ - long oh_nemit; /* sum of all os_flen */ - long oh_nchar; /* size of string area */ + uint16_t oh_magic; /* magic number */ + uint16_t oh_stamp; /* version stamp */ + uint16_t oh_flags; /* several format flags */ + uint16_t oh_nsect; /* number of outsect structures */ + uint16_t oh_nrelo; /* number of outrelo structures */ + uint16_t oh_nname; /* number of outname structures */ + uint32_t oh_nemit; /* sum of all os_flen */ + uint32_t oh_nchar; /* size of string area */ }; -#define O_MAGIC 0x0201 /* magic number of output file */ +#define O_MAGIC 0x0202 /* magic number of output file */ #define O_STAMP 0 /* version stamp */ #define MAXSECT 64 /* Maximum number of sections */ @@ -29,18 +32,19 @@ struct outhead { #define HF_8086 0x0008 /* os_base specially encoded */ struct outsect { - long os_base; /* startaddress in machine */ - long os_size; /* section size in machine */ - long os_foff; /* startaddress in file */ - long os_flen; /* section size in file */ - long os_lign; /* section alignment */ + uint32_t os_base; /* startaddress in machine */ + uint32_t os_size; /* section size in machine */ + uint32_t os_foff; /* startaddress in file */ + uint32_t os_flen; /* section size in file */ + uint32_t os_lign; /* section alignment */ }; struct outrelo { - char or_type; /* type of reference */ - char or_sect; /* referencing section */ - unsigned short or_nami; /* referenced symbol index */ - long or_addr; /* referencing address */ + uint16_t or_type; /* type of reference */ + uint16_t or_sect; /* referencing section */ + uint16_t or_nami; /* referenced symbol index */ + uint16_t _padding; /* padding for alignment */ + uint32_t or_addr; /* referencing address */ }; struct outname { @@ -50,15 +54,15 @@ struct outname { } on_u; #define on_mptr on_u.on_ptr #define on_foff on_u.on_off - unsigned short on_type; /* symbol type */ - unsigned short on_desc; /* debug info */ - long on_valu; /* symbol value */ + uint16_t on_type; /* symbol type */ + uint16_t on_desc; /* debug info */ + uint32_t on_valu; /* symbol value */ }; /* * relocation type bits */ -#define RELSZ 0x07 /* relocation length */ +#define RELSZ 0x0fff /* relocation length */ #define RELO1 1 /* 1 byte */ #define RELO2 2 /* 2 bytes */ #define RELO4 3 /* 4 bytes */ @@ -66,9 +70,9 @@ struct outname { #define RELOH2 5 /* write top 2 bytes of 4 byte word */ #define RELOVC4 6 /* VideoCore IV address in 32-bit instruction */ -#define RELPC 0x08 /* pc relative */ -#define RELBR 0x10 /* High order byte lowest address. */ -#define RELWR 0x20 /* High order word lowest address. */ +#define RELPC 0x2000 /* pc relative */ +#define RELBR 0x4000 /* High order byte lowest address. */ +#define RELWR 0x8000 /* High order word lowest address. */ /* * section type bits and fields diff --git a/util/led/ack.out.5 b/util/led/ack.out.5 index d9e24bff6..3932a7f25 100644 --- a/util/led/ack.out.5 +++ b/util/led/ack.out.5 @@ -44,14 +44,14 @@ The header of an object file has the following structure: .PP .nf struct outhead { - unsigned short oh_magic; /* magic number */ - unsigned short oh_stamp; /* version stamp */ - unsigned short oh_flags; /* several format flags */ - unsigned short oh_nsect; /* number of outsect structures */ - unsigned short oh_nrelo; /* number of outrelo structures */ - unsigned short oh_nname; /* number of outname structures */ - long oh_nemit; /* length of sections */ - long oh_nchar; /* size of string area */ + uint16_t oh_magic; /* magic number */ + uint16_t oh_stamp; /* version stamp */ + uint16_t oh_flags; /* several format flags */ + uint16_t oh_nsect; /* number of outsect structures */ + uint16_t oh_nrelo; /* number of outrelo structures */ + uint16_t oh_nname; /* number of outname structures */ + uint32_t oh_nemit; /* length of sections */ + uint32_t oh_nchar; /* size of string area */ }; .fi .PP @@ -92,11 +92,11 @@ An outsect structure has the following layout: .PP .nf struct outsect { - long os_base; /* start address in machine */ - long os_size; /* section size in machine */ - long os_foff; /* start address in file */ - long os_flen; /* section size in file */ - long os_lign; /* section alignment */ + uint32_t os_base; /* start address in machine */ + uint32_t os_size; /* section size in machine */ + uint32_t os_foff; /* start address in file */ + uint32_t os_flen; /* section size in file */ + uint32_t os_lign; /* section alignment */ }; .fi .PP @@ -147,10 +147,11 @@ relocatable datum. The information has the following structure: .PP .nf struct outrelo { - char or_type; /* type of reference */ - char or_sect; /* referencing section */ - unsigned short or_nami; /* referenced symbol index */ - long or_addr; /* referencing address */ + uint16_t or_type; /* type of reference */ + uint16_t or_sect; /* referencing section */ + uint16_t or_nami; /* referenced symbol index */ + uint16_t _padding; /* padding for alignment; ignore */ + uint32_t or_addr; /* referencing address */ }; .fi .PP @@ -158,16 +159,16 @@ struct outrelo { /* * relocation type bits */ -#define RELSZ 0x07 /* relocation length */ +#define RELSZ 0x0fffi /* relocation length */ #define RELO1 0x01 /* 1 byte */ #define RELO2 0x02 /* 2 bytes */ #define RELO4 0x03 /* 4 bytes */ #define RELOPPC 0x04 /* 26-bit PowerPC address */ #define RELOH2 0x05 /* write top 2 bytes of 4 byte word */ #define RELOVC4 0x06 /* VideoCore IV address in 32-bit insruction */ -#define RELPC 0x08 /* pc relative */ -#define RELBR 0x10 /* High order byte lowest address. */ -#define RELWR 0x20 /* High order word lowest address. */ +#define RELPC 0x2000 /* pc relative */ +#define RELBR 0x4000 /* High order byte lowest address. */ +#define RELWR 0x8000 /* High order word lowest address. */ .fi .PP .nf @@ -232,9 +233,9 @@ struct outname { } on_u; #define on_mptr on_u.on_ptr #define on_foff on_u.on_off - unsigned short on_type; /* symbol type */ - unsigned short on_desc; /* debug info */ - long on_valu; /* symbol value */ + uint16_t on_type; /* symbol type */ + uint16_t on_desc; /* debug info */ + uint32_t on_valu; /* symbol value */ }; .fi .PP -- 2.34.1