Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Some ECOFF definitions.
0004  */
0005 
0006 #include <stdint.h>
0007 
0008 typedef struct filehdr {
0009     uint16_t    f_magic;    /* magic number */
0010     uint16_t    f_nscns;    /* number of sections */
0011     int32_t     f_timdat;   /* time & date stamp */
0012     int32_t     f_symptr;   /* file pointer to symbolic header */
0013     int32_t     f_nsyms;    /* sizeof(symbolic hdr) */
0014     uint16_t    f_opthdr;   /* sizeof(optional hdr) */
0015     uint16_t    f_flags;    /* flags */
0016 } FILHDR;
0017 #define FILHSZ  sizeof(FILHDR)
0018 
0019 #define MIPSEBMAGIC 0x160
0020 #define MIPSELMAGIC 0x162
0021 
0022 typedef struct scnhdr {
0023     char        s_name[8];  /* section name */
0024     int32_t     s_paddr;    /* physical address, aliased s_nlib */
0025     int32_t     s_vaddr;    /* virtual address */
0026     int32_t     s_size;     /* section size */
0027     int32_t     s_scnptr;   /* file ptr to raw data for section */
0028     int32_t     s_relptr;   /* file ptr to relocation */
0029     int32_t     s_lnnoptr;  /* file ptr to gp histogram */
0030     uint16_t    s_nreloc;   /* number of relocation entries */
0031     uint16_t    s_nlnno;    /* number of gp histogram entries */
0032     int32_t     s_flags;    /* flags */
0033 } SCNHDR;
0034 #define SCNHSZ      sizeof(SCNHDR)
0035 #define SCNROUND    ((int32_t)16)
0036 
0037 typedef struct aouthdr {
0038     int16_t magic;      /* see above                */
0039     int16_t vstamp;     /* version stamp            */
0040     int32_t tsize;      /* text size in bytes, padded to DW bdry*/
0041     int32_t dsize;      /* initialized data "  "        */
0042     int32_t bsize;      /* uninitialized data "   "     */
0043     int32_t entry;      /* entry pt.                */
0044     int32_t text_start; /* base of text used for this file  */
0045     int32_t data_start; /* base of data used for this file  */
0046     int32_t bss_start;  /* base of bss used for this file   */
0047     int32_t gprmask;    /* general purpose register mask    */
0048     int32_t cprmask[4]; /* co-processor register masks      */
0049     int32_t gp_value;   /* the gp value used for this object    */
0050 } AOUTHDR;
0051 #define AOUTHSZ sizeof(AOUTHDR)
0052 
0053 #define OMAGIC      0407
0054 #define NMAGIC      0410
0055 #define ZMAGIC      0413
0056 #define SMAGIC      0411
0057 #define LIBMAGIC    0443
0058 
0059 #define N_TXTOFF(f, a) \
0060  ((a).magic == ZMAGIC || (a).magic == LIBMAGIC ? 0 : \
0061   ((a).vstamp < 23 ? \
0062    ((FILHSZ + AOUTHSZ + (f).f_nscns * SCNHSZ + 7) & 0xfffffff8) : \
0063    ((FILHSZ + AOUTHSZ + (f).f_nscns * SCNHSZ + SCNROUND-1) & ~(SCNROUND-1)) ) )
0064 #define N_DATOFF(f, a) \
0065   N_TXTOFF(f, a) + (a).tsize;