readelf.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * readelf.h
  3. * @(#)$Id: readelf.h,v 1.1 1996/06/22 22:04:22 christos Exp $
  4. *
  5. * Provide elf data structures for non-elf machines, allowing file
  6. * non-elf hosts to determine if an elf binary is stripped.
  7. * Note: cobbled from the linux header file, with modifications
  8. */
  9. #ifndef __fake_elf_h__
  10. #define __fake_elf_h__
  11. typedef unsigned int Elf32_Addr;
  12. typedef unsigned short Elf32_Half;
  13. typedef unsigned int Elf32_Off;
  14. typedef unsigned int Elf32_Word;
  15. typedef unsigned char Elf32_Char;
  16. #define EI_NIDENT 16
  17. typedef struct elfhdr{
  18. Elf32_Char e_ident[EI_NIDENT];
  19. Elf32_Half e_type;
  20. Elf32_Half e_machine;
  21. Elf32_Word e_version;
  22. Elf32_Addr e_entry; /* Entry point */
  23. Elf32_Off e_phoff;
  24. Elf32_Off e_shoff;
  25. Elf32_Word e_flags;
  26. Elf32_Half e_ehsize;
  27. Elf32_Half e_phentsize;
  28. Elf32_Half e_phnum;
  29. Elf32_Half e_shentsize;
  30. Elf32_Half e_shnum;
  31. Elf32_Half e_shstrndx;
  32. } Elf32_Ehdr;
  33. /* sh_type */
  34. #define SHT_SYMTAB 2
  35. /* elf type */
  36. #define ELFDATANONE 0 /* e_ident[EI_DATA] */
  37. #define ELFDATA2LSB 1
  38. #define ELFDATA2MSB 2
  39. /* magic number */
  40. #define EI_MAG0 0 /* e_ident[] indexes */
  41. #define EI_MAG1 1
  42. #define EI_MAG2 2
  43. #define EI_MAG3 3
  44. #define EI_CLASS 4
  45. #define EI_DATA 5
  46. #define EI_VERSION 6
  47. #define EI_PAD 7
  48. #define ELFMAG0 0x7f /* EI_MAG */
  49. #define ELFMAG1 'E'
  50. #define ELFMAG2 'L'
  51. #define ELFMAG3 'F'
  52. #define ELFMAG "\177ELF"
  53. typedef struct {
  54. Elf32_Word sh_name;
  55. Elf32_Word sh_type;
  56. Elf32_Word sh_flags;
  57. Elf32_Addr sh_addr;
  58. Elf32_Off sh_offset;
  59. Elf32_Word sh_size;
  60. Elf32_Word sh_link;
  61. Elf32_Word sh_info;
  62. Elf32_Word sh_addralign;
  63. Elf32_Word sh_entsize;
  64. } Elf32_Shdr;
  65. #endif