Sorted out section classification.
[cl-elf.git] / elf-file-section.lisp
blobdb4f58f012a39efc2ec4fd8b59d6a6bb43e708cb
2 (in-package :cl-elf)
4 (defmethod section-type->description ((section elf-section))
5 (let
6 ((section-header (header-of section)))
7 (slot->flags section-header 'sh-type #'=
8 (+SHT_PROGBITS+ "Program Data")
9 (+SHT_SYMTAB+ "Symbol Table")
10 (+SHT_STRTAB+ "String Table")
11 (+SHT_RELA+ "Relocation entries")
12 (+SHT_HASH+ "Hash table")
13 (+SHT_DYNAMIC+ "Dynamic Linking info")
14 (+SHT_NOBITS+ "Program space with no data (bss)")
15 (+SHT_NOTE+ "Notes")
16 (+SHT_REL+ "Relocation entries, no addednd")
17 (+SHT_SHLIB+ "Reserved")
18 (+SHT_DYNSYM+ "Dynamic linker symbol table")
19 (+SHT_INIT_ARRAY+ "Constructor Array")
20 (+SHT_FINI_ARRAY+ "Destructor Array")
21 (+SHT_PREINIT_ARRAY+ "Pre-constructor array+")
22 (+SHT_GROUP+ "Section Group")
23 (+SHT_SYMTAB_SHNDX+ "Extended section indices"))))
26 (defmethod section-type->keyword ((section elf-section))
27 (let
28 ((section-header (header-of section)))
29 (car
30 (slot->flags section-header 'sh-type #'=
31 (+SHT_PROGBITS+ :program-data)
32 (+SHT_SYMTAB+ :symbol-table)
33 (+SHT_STRTAB+ :string-table)
34 (+SHT_RELA+ :relocation-entries)
35 (+SHT_HASH+ :hash-table)
36 (+SHT_DYNAMIC+ :dynamic-linking-info)
37 (+SHT_NOBITS+ :program-space)
38 (+SHT_NOTE+ :notes)
39 (+SHT_REL+ :relocation-entries-no-addend)
40 (+SHT_SHLIB+ :reserved)
41 (+SHT_DYNSYM+ :dynamic-linker-symbol-table)
42 (+SHT_INIT_ARRAY+ :constructor-array)
43 (+SHT_FINI_ARRAY+ :destructor-array)
44 (+SHT_PREINIT_ARRAY+ :pre-constructor-array)
45 (+SHT_GROUP+ :segment-group)
46 (+SHT_SYMTAB_SHNDX+ :extended-section-indices)))))
51 (defmethod section-flags->keywords ((section elf-section))
52 (let
53 ((section-header (header-of section)))
54 (slot->flags section-header 'sh-flags #'mask-predicate
55 (+SHF_WRITE+ :writeable)
56 (+SHF_ALLOC+ :allocate-memory)
57 (+SHF_EXECINSTR+ :executable)
58 (+SHF_MERGE+ :possibly-merged)
59 (+SHF_STRINGS+ :strings)
60 (+SHF_INFO_LINK+ :sht-index)
61 (+SHF_LINK_ORDER+ :preserve-link-order)
62 (+SHF_OS_NONCONFORMING+ :non-standard)
63 (+SHF_GROUP+ :group-member)
64 (+SHF_TLS+ :thread-local-storage))))
66 (defmethod section-flags->descriptions ((section elf-section))
67 (slot->flags section-header 'sh-flags #'mask-predicate
68 (+SHF_WRITE+ "writeable")
69 (+SHF_ALLOC+ "occupies memory")
70 (+SHF_EXECINSTR+ "executable")
71 (+SHF_MERGE+ "possibly merged")
72 (+SHF_STRINGS+ "strings")
73 (+SHF_INFO_LINK+ "index")
74 (+SHF_LINK_ORDER+ "preserve link order")
75 (+SHF_OS_NONCONFORMING+ "non standard")
76 (+SHF_GROUP+ "group member")
77 (+SHF_TLS+ "thread local storage")))