Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright (C) 2002-2003  David McCullough <davidm@snapgear.com>
0004  * Copyright (C) 1998       Kenneth Albanowski <kjahds@kjahds.com>
0005  *                          The Silver Hammer Group, Ltd.
0006  *
0007  * This file provides the definitions and structures needed to
0008  * support uClinux flat-format executables.
0009  */
0010 #ifndef _LINUX_FLAT_H
0011 #define _LINUX_FLAT_H
0012 
0013 #define FLAT_VERSION            0x00000004L
0014 
0015 /*
0016  * To make everything easier to port and manage cross platform
0017  * development,  all fields are in network byte order.
0018  */
0019 
0020 struct flat_hdr {
0021     char    magic[4];
0022     __be32  rev;          /* version (as above) */
0023     __be32  entry;        /* Offset of first executable instruction
0024                  with text segment from beginning of file */
0025     __be32  data_start;   /* Offset of data segment from beginning of
0026                  file */
0027     __be32  data_end;     /* Offset of end of data segment from beginning
0028                  of file */
0029     __be32  bss_end;      /* Offset of end of bss segment from beginning
0030                  of file */
0031 
0032     /* (It is assumed that data_end through bss_end forms the bss segment.) */
0033 
0034     __be32  stack_size;   /* Size of stack, in bytes */
0035     __be32  reloc_start;  /* Offset of relocation records from beginning of
0036                  file */
0037     __be32  reloc_count;  /* Number of relocation records */
0038     __be32  flags;
0039     __be32  build_date;   /* When the program/library was built */
0040     __u32   filler[5];    /* Reservered, set to zero */
0041 };
0042 
0043 #define FLAT_FLAG_RAM    0x0001 /* load program entirely into RAM */
0044 #define FLAT_FLAG_GOTPIC 0x0002 /* program is PIC with GOT */
0045 #define FLAT_FLAG_GZIP   0x0004 /* all but the header is compressed */
0046 #define FLAT_FLAG_GZDATA 0x0008 /* only data/relocs are compressed (for XIP) */
0047 #define FLAT_FLAG_KTRACE 0x0010 /* output useful kernel trace for debugging */
0048 
0049 /*
0050  * While it would be nice to keep this header clean,  users of older
0051  * tools still need this support in the kernel.  So this section is
0052  * purely for compatibility with old tool chains.
0053  *
0054  * DO NOT make changes or enhancements to the old format please,  just work
0055  *        with the format above,  except to fix bugs with old format support.
0056  */
0057 
0058 #define OLD_FLAT_VERSION            0x00000002L
0059 #define OLD_FLAT_RELOC_TYPE_TEXT    0
0060 #define OLD_FLAT_RELOC_TYPE_DATA    1
0061 #define OLD_FLAT_RELOC_TYPE_BSS     2
0062 
0063 typedef union {
0064     u32     value;
0065     struct {
0066 #if defined(__LITTLE_ENDIAN_BITFIELD) || \
0067     (defined(mc68000) && !defined(CONFIG_COLDFIRE))
0068         s32 offset : 30;
0069         u32 type : 2;
0070 # elif defined(__BIG_ENDIAN_BITFIELD)
0071         u32 type : 2;
0072         s32 offset : 30;
0073 # else
0074 #       error "Unknown bitfield order for flat files."
0075 # endif
0076     } reloc;
0077 } flat_v2_reloc_t;
0078 
0079 #endif /* _LINUX_FLAT_H */