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_ELF32_H
35 #define OUTPUT_ELF32_H
37 #include "output/elfcommon.h"
39 /* ELF standard typedefs (yet more proof that <stdint.h> was way overdue) */
40 typedef uint16_t Elf32_Half
;
41 typedef int16_t Elf32_SHalf
;
42 typedef uint32_t Elf32_Word
;
43 typedef int32_t Elf32_Sword
;
44 typedef uint64_t Elf32_Xword
;
45 typedef int64_t Elf32_Sxword
;
47 typedef uint32_t Elf32_Off
;
48 typedef uint32_t Elf32_Addr
;
49 typedef uint16_t Elf32_Section
;
53 typedef struct elf32_dyn
{
63 #define ELF32_R_SYM(x) ((x) >> 8)
64 #define ELF32_R_TYPE(x) ((x) & 0xff)
66 typedef struct elf32_rel
{
71 typedef struct elf32_rela
{
78 R_386_32
= 1, /* ordinary absolute relocation */
79 R_386_PC32
= 2, /* PC-relative relocation */
80 R_386_GOT32
= 3, /* an offset into GOT */
81 R_386_PLT32
= 4, /* a PC-relative offset into PLT */
82 R_386_COPY
= 5, /* ??? */
83 R_386_GLOB_DAT
= 6, /* ??? */
84 R_386_JUMP_SLOT
= 7, /* ??? */
85 R_386_RELATIVE
= 8, /* ??? */
86 R_386_GOTOFF
= 9, /* an offset from GOT base */
87 R_386_GOTPC
= 10, /* a PC-relative offset _to_ GOT */
88 R_386_TLS_TPOFF
= 14, /* Offset in static TLS block */
89 R_386_TLS_IE
= 15, /* Address of GOT entry for static TLS
91 /* These are GNU extensions, but useful */
92 R_386_16
= 20, /* A 16-bit absolute relocation */
93 R_386_PC16
= 21, /* A 16-bit PC-relative relocation */
94 R_386_8
= 22, /* An 8-bit absolute relocation */
95 R_386_PC8
= 23 /* An 8-bit PC-relative relocation */
100 typedef struct elf32_sym
{
104 unsigned char st_info
;
105 unsigned char st_other
;
109 /* Main file header */
111 typedef struct elf32_hdr
{
112 unsigned char e_ident
[EI_NIDENT
];
114 Elf32_Half e_machine
;
115 Elf32_Word e_version
;
121 Elf32_Half e_phentsize
;
123 Elf32_Half e_shentsize
;
125 Elf32_Half e_shstrndx
;
130 typedef struct elf32_phdr
{
143 typedef struct elf32_shdr
{
152 Elf32_Word sh_addralign
;
153 Elf32_Word sh_entsize
;
157 typedef struct elf32_note
{
158 Elf32_Word n_namesz
; /* Name size */
159 Elf32_Word n_descsz
; /* Content size */
160 Elf32_Word n_type
; /* Content type */
163 /* How to extract and insert information held in the st_info field. */
164 #define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4)
165 #define ELF32_ST_TYPE(val) ((val) & 0xf)
167 #endif /* OUTPUT_ELF32_H */