flat.h 3.3 KB

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