Debian Codegraph @

output/outelf.h

raw
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /* Copyright 1996-2019 The NASM Authors - All Rights Reserved */
3
4 /*
5 * Internal definitions common to outelf32 and outelf64
6 */
7 #ifndef OUTPUT_OUTELF_H
8 #define OUTPUT_OUTELF_H
9
10 #include "elf.h"
11 #include "rbtree.h"
12 #include "saa.h"
13
14 #define GLOBAL_TEMP_BASE 0x40000000 /* bigger than any sane symbol index */
15
16 /* alignment of sections in file */
17 #define SEC_FILEALIGN 16
18
19 /* this stuff is needed for the dwarf/stabs debugging format */
20 #define TY_DEBUGSYMLIN 0x40 /* internal call to debug_out */
21
22 /*
23 * Debugging ELF sections (section indices starting with sec_debug)
24 */
25
26 /* stabs */
27 #define sec_stab (sec_debug + 0)
28 #define sec_stabstr (sec_debug + 1)
29 #define sec_rel_stab (sec_debug + 2)
30
31 /* stabs symbol table format */
32 struct stabentry {
33 uint32_t n_strx;
34 uint8_t n_type;
35 uint8_t n_other;
36 uint16_t n_desc;
37 uint32_t n_value;
38 };
39
40 /* dwarf */
41 #define sec_debug_aranges (sec_debug + 0)
42 #define sec_rela_debug_aranges (sec_debug + 1)
43 #define sec_debug_pubnames (sec_debug + 2)
44 #define sec_debug_info (sec_debug + 3)
45 #define sec_rela_debug_info (sec_debug + 4)
46 #define sec_debug_abbrev (sec_debug + 5)
47 #define sec_debug_line (sec_debug + 6)
48 #define sec_rela_debug_line (sec_debug + 7)
49 #define sec_debug_frame (sec_debug + 8)
50 #define sec_debug_loc (sec_debug + 9)
51
52 extern uint8_t elf_osabi;
53 extern uint8_t elf_abiver;
54
55 #define WRITE_STAB(p,n_strx,n_type,n_other,n_desc,n_value) \
56 do { \
57 WRITELONG(p, n_strx); \
58 WRITECHAR(p, n_type); \
59 WRITECHAR(p, n_other); \
60 WRITESHORT(p, n_desc); \
61 WRITELONG(p, n_value); \
62 } while (0)
63
64 struct elf_reloc {
65 struct elf_reloc *next;
66 int64_t address; /* relative to _start_ of section */
67 int64_t symbol; /* symbol index */
68 int64_t offset; /* symbol addend */
69 int type; /* type of relocation */
70 };
71
72 struct elf_symbol {
73 struct rbtree symv; /* symbol value and symbol rbtree */
74 int32_t strpos; /* string table position of name */
75 int32_t section; /* section ID of the symbol */
76 int type; /* symbol type */
77 int other; /* symbol visibility */
78 int32_t size; /* size of symbol */
79 int32_t globnum; /* symbol table offset if global */
80 struct elf_symbol *nextfwd; /* list of unresolved-size symbols */
81 char *name; /* used temporarily if in above list */
82 };
83
84 struct elf_section {
85 struct SAA *data;
86 uint64_t len;
87 uint64_t size;
88 uint64_t nrelocs;
89 int32_t index; /* NASM index or NO_SEG if internal */
90 int shndx; /* ELF index */
91 int type; /* SHT_* */
92 uint64_t align; /* alignment: power of two */
93 uint64_t flags; /* section flags */
94 int64_t pass_last_seen;
95 uint64_t entsize; /* entry size */
96 char *name;
97 struct SAA *rel;
98 struct elf_reloc *head;
99 struct elf_reloc **tail;
100 struct rbtree *gsyms; /* global symbols in section */
101 };
102
103 #endif /* OUTPUT_OUTELF_H */