162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Some ECOFF definitions. 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#include <stdint.h> 762306a36Sopenharmony_ci 862306a36Sopenharmony_citypedef struct filehdr { 962306a36Sopenharmony_ci uint16_t f_magic; /* magic number */ 1062306a36Sopenharmony_ci uint16_t f_nscns; /* number of sections */ 1162306a36Sopenharmony_ci int32_t f_timdat; /* time & date stamp */ 1262306a36Sopenharmony_ci int32_t f_symptr; /* file pointer to symbolic header */ 1362306a36Sopenharmony_ci int32_t f_nsyms; /* sizeof(symbolic hdr) */ 1462306a36Sopenharmony_ci uint16_t f_opthdr; /* sizeof(optional hdr) */ 1562306a36Sopenharmony_ci uint16_t f_flags; /* flags */ 1662306a36Sopenharmony_ci} FILHDR; 1762306a36Sopenharmony_ci#define FILHSZ sizeof(FILHDR) 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci#define MIPSEBMAGIC 0x160 2062306a36Sopenharmony_ci#define MIPSELMAGIC 0x162 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_citypedef struct scnhdr { 2362306a36Sopenharmony_ci char s_name[8]; /* section name */ 2462306a36Sopenharmony_ci int32_t s_paddr; /* physical address, aliased s_nlib */ 2562306a36Sopenharmony_ci int32_t s_vaddr; /* virtual address */ 2662306a36Sopenharmony_ci int32_t s_size; /* section size */ 2762306a36Sopenharmony_ci int32_t s_scnptr; /* file ptr to raw data for section */ 2862306a36Sopenharmony_ci int32_t s_relptr; /* file ptr to relocation */ 2962306a36Sopenharmony_ci int32_t s_lnnoptr; /* file ptr to gp histogram */ 3062306a36Sopenharmony_ci uint16_t s_nreloc; /* number of relocation entries */ 3162306a36Sopenharmony_ci uint16_t s_nlnno; /* number of gp histogram entries */ 3262306a36Sopenharmony_ci int32_t s_flags; /* flags */ 3362306a36Sopenharmony_ci} SCNHDR; 3462306a36Sopenharmony_ci#define SCNHSZ sizeof(SCNHDR) 3562306a36Sopenharmony_ci#define SCNROUND ((int32_t)16) 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_citypedef struct aouthdr { 3862306a36Sopenharmony_ci int16_t magic; /* see above */ 3962306a36Sopenharmony_ci int16_t vstamp; /* version stamp */ 4062306a36Sopenharmony_ci int32_t tsize; /* text size in bytes, padded to DW bdry*/ 4162306a36Sopenharmony_ci int32_t dsize; /* initialized data " " */ 4262306a36Sopenharmony_ci int32_t bsize; /* uninitialized data " " */ 4362306a36Sopenharmony_ci int32_t entry; /* entry pt. */ 4462306a36Sopenharmony_ci int32_t text_start; /* base of text used for this file */ 4562306a36Sopenharmony_ci int32_t data_start; /* base of data used for this file */ 4662306a36Sopenharmony_ci int32_t bss_start; /* base of bss used for this file */ 4762306a36Sopenharmony_ci int32_t gprmask; /* general purpose register mask */ 4862306a36Sopenharmony_ci int32_t cprmask[4]; /* co-processor register masks */ 4962306a36Sopenharmony_ci int32_t gp_value; /* the gp value used for this object */ 5062306a36Sopenharmony_ci} AOUTHDR; 5162306a36Sopenharmony_ci#define AOUTHSZ sizeof(AOUTHDR) 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_ci#define OMAGIC 0407 5462306a36Sopenharmony_ci#define NMAGIC 0410 5562306a36Sopenharmony_ci#define ZMAGIC 0413 5662306a36Sopenharmony_ci#define SMAGIC 0411 5762306a36Sopenharmony_ci#define LIBMAGIC 0443 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci#define N_TXTOFF(f, a) \ 6062306a36Sopenharmony_ci ((a).magic == ZMAGIC || (a).magic == LIBMAGIC ? 0 : \ 6162306a36Sopenharmony_ci ((a).vstamp < 23 ? \ 6262306a36Sopenharmony_ci ((FILHSZ + AOUTHSZ + (f).f_nscns * SCNHSZ + 7) & 0xfffffff8) : \ 6362306a36Sopenharmony_ci ((FILHSZ + AOUTHSZ + (f).f_nscns * SCNHSZ + SCNROUND-1) & ~(SCNROUND-1)) ) ) 6462306a36Sopenharmony_ci#define N_DATOFF(f, a) \ 6562306a36Sopenharmony_ci N_TXTOFF(f, a) + (a).tsize; 66