Change rights 644 to 755
[nasm/github.git] / output / outelf.h
blob4d6db5d78054ea457d1917c9112d4ae2f11bb352
1 /* ----------------------------------------------------------------------- *
3 * Copyright 1996-2009 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
9 * conditions are met:
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
40 #include "output/elf.h"
41 #include "rbtree.h"
42 #include "saa.h"
44 /* symbol binding */
45 #define SYM_GLOBAL ELF32_ST_MKBIND(STB_GLOBAL)
46 #define SYM_LOCAL ELF32_ST_MKBIND(STB_LOCAL)
48 #define GLOBAL_TEMP_BASE 0x40000000 /* bigger than any sane symbol index */
50 /* alignment of sections in file */
51 #define SEC_FILEALIGN 16
53 /* this stuff is needed for the stabs debugging format */
54 #define TY_STABSSYMLIN 0x40 /* ouch */
56 /* this stuff is needed for the dwarf debugging format */
57 #define TY_DEBUGSYMLIN 0x40 /* internal call to debug_out */
59 /* Known sections with nonstandard defaults */
60 struct elf_known_section {
61 const char *name; /* Name of section */
62 int type; /* Section type (SHT_) */
63 uint32_t flags; /* Section flags (SHF_) */
64 uint32_t align; /* Section alignment */
66 extern const struct elf_known_section elf_known_sections[];
69 * Special ELF sections (after the real sections but before debugging ones)
71 #define sec_shstrtab (nsects + 1)
72 #define sec_symtab (nsects + 2)
73 #define sec_strtab (nsects + 3)
74 #define sec_numspecial 3
77 * Debugging ELF sections (last in the file)
80 /* stabs */
81 #define sec_stab (nsections-3)
82 #define sec_stabstr (nsections-2)
83 #define sec_rel_stab (nsections-1)
85 /* stabs symbol table format */
86 struct stabentry {
87 uint32_t n_strx;
88 uint8_t n_type;
89 uint8_t n_other;
90 uint16_t n_desc;
91 uint32_t n_value;
94 /* dwarf */
95 #define sec_debug_aranges (nsections-10)
96 #define sec_rela_debug_aranges (nsections-9)
97 #define sec_debug_pubnames (nsections-8)
98 #define sec_debug_info (nsections-7)
99 #define sec_rela_debug_info (nsections-6)
100 #define sec_debug_abbrev (nsections-5)
101 #define sec_debug_line (nsections-4)
102 #define sec_rela_debug_line (nsections-3)
103 #define sec_debug_frame (nsections-2)
104 #define sec_debug_loc (nsections-1)
106 extern uint8_t elf_osabi;
107 extern uint8_t elf_abiver;
109 int elf_directive(enum directives directive, char *value, int pass);
110 void elf_section_attrib(char *name, char *attr, int pass,
111 uint32_t *flags_and, uint32_t *flags_or,
112 uint64_t *align, int *type);
114 #define WRITE_STAB(p,n_strx,n_type,n_other,n_desc,n_value) \
115 do { \
116 WRITELONG(p, n_strx); \
117 WRITECHAR(p, n_type); \
118 WRITECHAR(p, n_other); \
119 WRITESHORT(p, n_desc); \
120 WRITELONG(p, n_value); \
121 } while (0)
123 struct elf_reloc {
124 struct elf_reloc *next;
125 int64_t address; /* relative to _start_ of section */
126 int64_t symbol; /* symbol index */
127 int64_t offset; /* symbol addend */
128 int type; /* type of relocation */
131 struct elf_symbol {
132 struct rbtree symv; /* symbol value and symbol rbtree */
133 int32_t strpos; /* string table position of name */
134 int32_t section; /* section ID of the symbol */
135 int type; /* symbol type */
136 int other; /* symbol visibility */
137 int32_t size; /* size of symbol */
138 int32_t globnum; /* symbol table offset if global */
139 struct elf_symbol *nextfwd; /* list of unresolved-size symbols */
140 char *name; /* used temporarily if in above list */
143 struct elf_section {
144 struct SAA *data;
145 uint64_t len;
146 uint64_t size;
147 uint64_t nrelocs;
148 int32_t index;
149 int type; /* SHT_PROGBITS or SHT_NOBITS */
150 uint64_t align; /* alignment: power of two */
151 uint64_t flags; /* section flags */
152 char *name;
153 struct SAA *rel;
154 uint64_t rellen;
155 struct elf_reloc *head;
156 struct elf_reloc **tail;
157 struct rbtree *gsyms; /* global symbols in section */
160 #endif /* OUTPUT_OUTELF_H */