flat.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2002-2003 David McCullough <davidm@snapgear.com>
  4. * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>
  5. * The Silver Hammer Group, Ltd.
  6. *
  7. * This file provides the definitions and structures needed to
  8. * support uClinux flat-format executables.
  9. */
  10. #ifndef _LINUX_FLAT_H
  11. #define _LINUX_FLAT_H
  12. #define FLAT_VERSION 0x00000004L
  13. /*
  14. * To make everything easier to port and manage cross platform
  15. * development, all fields are in network byte order.
  16. */
  17. struct flat_hdr {
  18. char magic[4];
  19. __be32 rev; /* version (as above) */
  20. __be32 entry; /* Offset of first executable instruction
  21. with text segment from beginning of file */
  22. __be32 data_start; /* Offset of data segment from beginning of
  23. file */
  24. __be32 data_end; /* Offset of end of data segment from beginning
  25. of file */
  26. __be32 bss_end; /* Offset of end of bss segment from beginning
  27. of file */
  28. /* (It is assumed that data_end through bss_end forms the bss segment.) */
  29. __be32 stack_size; /* Size of stack, in bytes */
  30. __be32 reloc_start; /* Offset of relocation records from beginning of
  31. file */
  32. __be32 reloc_count; /* Number of relocation records */
  33. __be32 flags;
  34. __be32 build_date; /* When the program/library was built */
  35. __u32 filler[5]; /* Reservered, set to zero */
  36. };
  37. #define FLAT_FLAG_RAM 0x0001 /* load program entirely into RAM */
  38. #define FLAT_FLAG_GOTPIC 0x0002 /* program is PIC with GOT */
  39. #define FLAT_FLAG_GZIP 0x0004 /* all but the header is compressed */
  40. #define FLAT_FLAG_GZDATA 0x0008 /* only data/relocs are compressed (for XIP) */
  41. #define FLAT_FLAG_KTRACE 0x0010 /* output useful kernel trace for debugging */
  42. /*
  43. * While it would be nice to keep this header clean, users of older
  44. * tools still need this support in the kernel. So this section is
  45. * purely for compatibility with old tool chains.
  46. *
  47. * DO NOT make changes or enhancements to the old format please, just work
  48. * with the format above, except to fix bugs with old format support.
  49. */
  50. #define OLD_FLAT_VERSION 0x00000002L
  51. #define OLD_FLAT_RELOC_TYPE_TEXT 0
  52. #define OLD_FLAT_RELOC_TYPE_DATA 1
  53. #define OLD_FLAT_RELOC_TYPE_BSS 2
  54. typedef union {
  55. u32 value;
  56. struct {
  57. #if defined(__LITTLE_ENDIAN_BITFIELD) || \
  58. (defined(mc68000) && !defined(CONFIG_COLDFIRE))
  59. s32 offset : 30;
  60. u32 type : 2;
  61. # elif defined(__BIG_ENDIAN_BITFIELD)
  62. u32 type : 2;
  63. s32 offset : 30;
  64. # else
  65. # error "Unknown bitfield order for flat files."
  66. # endif
  67. } reloc;
  68. } flat_v2_reloc_t;
  69. #endif /* _LINUX_FLAT_H */