1 /* ----------------------------------------------------------------------- *
3 * Copyright 1996-2019 The NASM Authors - All Rights Reserved
4 * See the file AUTHORS included with the NASM distribution for
5 * the specific copyright holders.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * ----------------------------------------------------------------------- */
35 * Internal definitions common to outelf32 and outelf64
37 #ifndef OUTPUT_OUTELF_H
38 #define OUTPUT_OUTELF_H
44 #define GLOBAL_TEMP_BASE 0x40000000 /* bigger than any sane symbol index */
46 /* alignment of sections in file */
47 #define SEC_FILEALIGN 16
49 /* this stuff is needed for the dwarf/stabs debugging format */
50 #define TY_DEBUGSYMLIN 0x40 /* internal call to debug_out */
53 * Debugging ELF sections (section indicies starting with sec_debug)
57 #define sec_stab (sec_debug + 0)
58 #define sec_stabstr (sec_debug + 1)
59 #define sec_rel_stab (sec_debug + 2)
61 /* stabs symbol table format */
71 #define sec_debug_aranges (sec_debug + 0)
72 #define sec_rela_debug_aranges (sec_debug + 1)
73 #define sec_debug_pubnames (sec_debug + 2)
74 #define sec_debug_info (sec_debug + 3)
75 #define sec_rela_debug_info (sec_debug + 4)
76 #define sec_debug_abbrev (sec_debug + 5)
77 #define sec_debug_line (sec_debug + 6)
78 #define sec_rela_debug_line (sec_debug + 7)
79 #define sec_debug_frame (sec_debug + 8)
80 #define sec_debug_loc (sec_debug + 9)
82 extern uint8_t elf_osabi
;
83 extern uint8_t elf_abiver
;
85 #define WRITE_STAB(p,n_strx,n_type,n_other,n_desc,n_value) \
87 WRITELONG(p, n_strx); \
88 WRITECHAR(p, n_type); \
89 WRITECHAR(p, n_other); \
90 WRITESHORT(p, n_desc); \
91 WRITELONG(p, n_value); \
95 struct elf_reloc
*next
;
96 int64_t address
; /* relative to _start_ of section */
97 int64_t symbol
; /* symbol index */
98 int64_t offset
; /* symbol addend */
99 int type
; /* type of relocation */
103 struct rbtree symv
; /* symbol value and symbol rbtree */
104 int32_t strpos
; /* string table position of name */
105 int32_t section
; /* section ID of the symbol */
106 int type
; /* symbol type */
107 int other
; /* symbol visibility */
108 int32_t size
; /* size of symbol */
109 int32_t globnum
; /* symbol table offset if global */
110 struct elf_symbol
*nextfwd
; /* list of unresolved-size symbols */
111 char *name
; /* used temporarily if in above list */
119 int32_t index
; /* NASM index or NO_SEG if internal */
120 int shndx
; /* ELF index */
121 int type
; /* SHT_* */
122 uint64_t align
; /* alignment: power of two */
123 uint64_t flags
; /* section flags */
124 int64_t pass_last_seen
;
125 uint64_t entsize
; /* entry size */
128 struct elf_reloc
*head
;
129 struct elf_reloc
**tail
;
130 struct rbtree
*gsyms
; /* global symbols in section */
133 #endif /* OUTPUT_OUTELF_H */