Sorted out section classification.
[cl-elf.git] / elf-section-types.lisp
blobb23402c08e281bc73ec7263af97d37e4906124e9
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 (let
68 ((section-header (header-of section)))
69 (slot->flags section-header 'sh-flags #'mask-predicate
70 (+SHF_WRITE+ "writeable")
71 (+SHF_ALLOC+ "occupies memory")
72 (+SHF_EXECINSTR+ "executable")
73 (+SHF_MERGE+ "possibly merged")
74 (+SHF_STRINGS+ "strings")
75 (+SHF_INFO_LINK+ "index")
76 (+SHF_LINK_ORDER+ "preserve link order")
77 (+SHF_OS_NONCONFORMING+ "non standard")
78 (+SHF_GROUP+ "group member")
79 (+SHF_TLS+ "thread local storage"))))
82 ;; to do -- hashtable of section type keywords that map to
83 ;; class names which represent section types, so
84 ;; specialised methods can be used for each type
87 ;; entry type should be computed whithin read-elf-file
88 ;; and computed within the fill-section-header-slots label
89 ;; a specialised
90 ;; (defmethod read-value ((type (eql 'section-entry-type) (self elf-file-data) &key)
91 ;; can be used on the entry type
93 ;; so, for each section type we need to know entry type specialiser kw
94 ;; eg for string section it's simply asciiz