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
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 * ----------------------------------------------------------------------- */
34 #ifndef OUTPUT_ELF64_H
35 #define OUTPUT_ELF64_H
37 #include "output/elfcommon.h"
39 /* ELF standard typedefs (yet more proof that <stdint.h> was way overdue) */
40 typedef uint16_t Elf64_Half
;
41 typedef int16_t Elf64_SHalf
;
42 typedef uint32_t Elf64_Word
;
43 typedef int32_t Elf64_Sword
;
44 typedef uint64_t Elf64_Xword
;
45 typedef int64_t Elf64_Sxword
;
47 typedef uint64_t Elf64_Off
;
48 typedef uint64_t Elf64_Addr
;
49 typedef uint16_t Elf64_Section
;
53 typedef struct elf64_dyn
{
63 #define ELF64_R_SYM(x) ((x) >> 32)
64 #define ELF64_R_TYPE(x) ((x) & 0xffffffff)
66 typedef struct elf64_rel
{
71 typedef struct elf64_rela
{
74 Elf64_Sxword r_addend
;
78 R_X86_64_NONE
= 0, /* No reloc */
79 R_X86_64_64
= 1, /* Direct 64 bit */
80 R_X86_64_PC32
= 2, /* PC relative 32 bit signed */
81 R_X86_64_GOT32
= 3, /* 32 bit GOT entry */
82 R_X86_64_PLT32
= 4, /* 32 bit PLT address */
83 R_X86_64_COPY
= 5, /* Copy symbol at runtime */
84 R_X86_64_GLOB_DAT
= 6, /* Create GOT entry */
85 R_X86_64_JUMP_SLOT
= 7, /* Create PLT entry */
86 R_X86_64_RELATIVE
= 8, /* Adjust by program base */
87 R_X86_64_GOTPCREL
= 9, /* 32 bit signed PC relative offset to GOT */
88 R_X86_64_32
= 10, /* Direct 32 bit zero extended */
89 R_X86_64_32S
= 11, /* Direct 32 bit sign extended */
90 R_X86_64_16
= 12, /* Direct 16 bit zero extended */
91 R_X86_64_PC16
= 13, /* 16 bit sign extended pc relative */
92 R_X86_64_8
= 14, /* Direct 8 bit sign extended */
93 R_X86_64_PC8
= 15, /* 8 bit sign extended pc relative */
94 R_X86_64_DTPMOD64
= 16, /* ID of module containing symbol */
95 R_X86_64_DTPOFF64
= 17, /* Offset in module's TLS block */
96 R_X86_64_TPOFF64
= 18, /* Offset in initial TLS block */
97 R_X86_64_TLSGD
= 19, /* 32 bit signed PC relative offset
98 to two GOT entries for GD symbol */
99 R_X86_64_TLSLD
= 20, /* 32 bit signed PC relative offset
100 to two GOT entries for LD symbol */
101 R_X86_64_DTPOFF32
= 21, /* Offset in TLS block */
102 R_X86_64_GOTTPOFF
= 22, /* 32 bit signed PC relative offset
103 to GOT entry for IE symbol */
104 R_X86_64_TPOFF32
= 23, /* Offset in initial TLS block */
105 R_X86_64_PC64
= 24, /* word64 S + A - P */
106 R_X86_64_GOTOFF64
= 25, /* word64 S + A - GOT */
107 R_X86_64_GOTPC32
= 26, /* word32 GOT + A - P */
108 R_X86_64_GOT64
= 27, /* word64 G + A */
109 R_X86_64_GOTPCREL64
= 28, /* word64 G + GOT - P + A */
110 R_X86_64_GOTPC64
= 29, /* word64 GOT - P + A */
111 R_X86_64_GOTPLT64
= 30, /* word64 G + A */
112 R_X86_64_PLTOFF64
= 31, /* word64 L - GOT + A */
113 R_X86_64_SIZE32
= 32, /* word32 Z + A */
114 R_X86_64_SIZE64
= 33, /* word64 Z + A */
115 R_X86_64_GOTPC32_TLSDESC
= 34, /* word32 */
116 R_X86_64_TLSDESC_CALL
= 35, /* none */
117 R_X86_64_TLSDESC
= 36 /* word64×2 */
122 typedef struct elf64_sym
{
124 unsigned char st_info
;
125 unsigned char st_other
;
131 /* Main file header */
133 typedef struct elf64_hdr
{
134 unsigned char e_ident
[EI_NIDENT
];
136 Elf64_Half e_machine
;
137 Elf64_Word e_version
;
143 Elf64_Half e_phentsize
;
145 Elf64_Half e_shentsize
;
147 Elf64_Half e_shstrndx
;
152 typedef struct elf64_phdr
{
158 Elf64_Xword p_filesz
;
165 typedef struct elf64_shdr
{
168 Elf64_Xword sh_flags
;
174 Elf64_Xword sh_addralign
;
175 Elf64_Xword sh_entsize
;
179 typedef struct elf64_note
{
180 Elf64_Word n_namesz
; /* Name size */
181 Elf64_Word n_descsz
; /* Content size */
182 Elf64_Word n_type
; /* Content type */
185 /* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */
186 #define ELF64_ST_BIND(val) ELF32_ST_BIND (val)
187 #define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val)
189 #endif /* OUTPUT_ELF64_H */