《操作系统》的实验代码。
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

48 rindas
1.9 KiB

pirms 10 gadiem
  1. #ifndef __LIBS_ELF_H__
  2. #define __LIBS_ELF_H__
  3. #include <defs.h>
  4. #define ELF_MAGIC 0x464C457FU // "\x7FELF" in little endian
  5. /* file header */
  6. struct elfhdr {
  7. uint32_t e_magic; // must equal ELF_MAGIC
  8. uint8_t e_elf[12];
  9. uint16_t e_type; // 1=relocatable, 2=executable, 3=shared object, 4=core image
  10. uint16_t e_machine; // 3=x86, 4=68K, etc.
  11. uint32_t e_version; // file version, always 1
  12. uint32_t e_entry; // entry point if executable
  13. uint32_t e_phoff; // file position of program header or 0
  14. uint32_t e_shoff; // file position of section header or 0
  15. uint32_t e_flags; // architecture-specific flags, usually 0
  16. uint16_t e_ehsize; // size of this elf header
  17. uint16_t e_phentsize; // size of an entry in program header
  18. uint16_t e_phnum; // number of entries in program header or 0
  19. uint16_t e_shentsize; // size of an entry in section header
  20. uint16_t e_shnum; // number of entries in section header or 0
  21. uint16_t e_shstrndx; // section number that contains section name strings
  22. };
  23. /* program section header */
  24. struct proghdr {
  25. uint32_t p_type; // loadable code or data, dynamic linking info,etc.
  26. uint32_t p_offset; // file offset of segment
  27. uint32_t p_va; // virtual address to map segment
  28. uint32_t p_pa; // physical address, not used
  29. uint32_t p_filesz; // size of segment in file
  30. uint32_t p_memsz; // size of segment in memory (bigger if contains bss)
  31. uint32_t p_flags; // read/write/execute bits
  32. uint32_t p_align; // required alignment, invariably hardware page size
  33. };
  34. /* values for Proghdr::p_type */
  35. #define ELF_PT_LOAD 1
  36. /* flag bits for Proghdr::p_flags */
  37. #define ELF_PF_X 1
  38. #define ELF_PF_W 2
  39. #define ELF_PF_R 4
  40. #endif /* !__LIBS_ELF_H__ */