1ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/*
2ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown *  TCC - Tiny C Compiler
3ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown *
4ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown *  Copyright (c) 2001-2004 Fabrice Bellard
5ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown *
6ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown * This library is free software; you can redistribute it and/or
7ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown * modify it under the terms of the GNU Lesser General Public
8ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown * License as published by the Free Software Foundation; either
9ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown * version 2 of the License, or (at your option) any later version.
10ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown *
11ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown * This library is distributed in the hope that it will be useful,
12ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown * but WITHOUT ANY WARRANTY; without even the implied warranty of
13ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown * Lesser General Public License for more details.
15ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown *
16ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown * You should have received a copy of the GNU Lesser General Public
17ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown * License along with this library; if not, write to the Free Software
18ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown */
20ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define _GNU_SOURCE
21ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
22ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown// njn: inlined config.h
23ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//#include "config.h"
24ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//---------------------------------------------------------------------------
25ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Automatically generated by configure - do not modify */
26ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define CONFIG_TCCDIR "tinycc-extras"
27ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define GCC_MAJOR 3
28ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define HOST_I386 1
29ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define TCC_VERSION "0.9.23"
30ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//---------------------------------------------------------------------------
31ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
32ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown// njn: comment out CONFIG_TCCBOOT branch
33ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//#ifdef CONFIG_TCCBOOT
34ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//
35ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//#include "tccboot.h"
36ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//#define CONFIG_TCC_STATIC
37ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//
38ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//#else
39ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
40ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#include <assert.h>
41ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#include <stdlib.h>
42ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#include <stdio.h>
43ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#include <stdarg.h>
44ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#include <string.h>
45ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#include <errno.h>
46ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#include <math.h>
47ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#include <unistd.h>
48ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#include <signal.h>
49ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#include <fcntl.h>
50ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#include <setjmp.h>
51ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#include <time.h>
52ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#ifdef WIN32
53ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#include <sys/timeb.h>
54ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#endif
55ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#ifndef WIN32
56ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#include <sys/time.h>
57ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#include <sys/ucontext.h>
58ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#endif
59ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
60ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//#endif /* !CONFIG_TCCBOOT */
61ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
62ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown// Dummy variables used to avoid warnings like these:
63ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown// warning: ignoring return value of ‘fwrite’, declared with attribute
64ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//    warn_unused_result
65ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownchar* dummy_char_star;
66ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownsize_t dummy_size_t;
67ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
68ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown// njn: inlined elf.h
69ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//#include "elf.h"
70ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//---------------------------------------------------------------------------
71ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* This file defines standard ELF types, structures, and macros.
72ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
73ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   This file is part of the GNU C Library.
74ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   Contributed by Ian Lance Taylor <ian@cygnus.com>.
75ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
76ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   The GNU C Library is free software; you can redistribute it and/or
77ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   modify it under the terms of the GNU Library General Public License as
78ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   published by the Free Software Foundation; either version 2 of the
79ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   License, or (at your option) any later version.
80ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
81ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   The GNU C Library is distributed in the hope that it will be useful,
82ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   but WITHOUT ANY WARRANTY; without even the implied warranty of
83ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
84ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   Library General Public License for more details.
85ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
86ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   You should have received a copy of the GNU Library General Public
87ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   License along with the GNU C Library; see the file COPYING.LIB.  If not,
88ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
89ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   Boston, MA 02111-1307, USA.  */
90ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
91ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#ifndef _ELF_H
92ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define	_ELF_H 1
93ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
94ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#ifndef WIN32
95ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#include <inttypes.h>
96ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#else
97ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#ifndef __int8_t_defined
98ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define __int8_t_defined
99ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef signed char int8_t;
100ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef	short int int16_t;
101ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef	int int32_t;
102ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef long long int int64_t;
103ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#endif
104ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
105ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef unsigned char		uint8_t;
106ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef unsigned short int	uint16_t;
107ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef unsigned int		uint32_t;
108ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef unsigned long long int	uint64_t;
109ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#endif
110ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
111ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Standard ELF types.  */
112ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
113ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Type for a 16-bit quantity.  */
114ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef uint16_t Elf32_Half;
115ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef uint16_t Elf64_Half;
116ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
117ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Types for signed and unsigned 32-bit quantities.  */
118ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef uint32_t Elf32_Word;
119ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef	int32_t  Elf32_Sword;
120ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef uint32_t Elf64_Word;
121ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef	int32_t  Elf64_Sword;
122ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
123ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Types for signed and unsigned 64-bit quantities.  */
124ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef uint64_t Elf32_Xword;
125ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef	int64_t  Elf32_Sxword;
126ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef uint64_t Elf64_Xword;
127ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef	int64_t  Elf64_Sxword;
128ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
129ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Type of addresses.  */
130ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef uint32_t Elf32_Addr;
131ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef uint64_t Elf64_Addr;
132ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
133ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Type of file offsets.  */
134ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef uint32_t Elf32_Off;
135ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef uint64_t Elf64_Off;
136ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
137ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Type for section indices, which are 16-bit quantities.  */
138ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef uint16_t Elf32_Section;
139ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef uint16_t Elf64_Section;
140ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
141ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Type of symbol indices.  */
142ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef uint32_t Elf32_Symndx;
143ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef uint64_t Elf64_Symndx;
144ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
145ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
146ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* The ELF file header.  This appears at the start of every ELF file.  */
147ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
148ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EI_NIDENT (16)
149ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
150ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
151ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
152ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  unsigned char	e_ident[EI_NIDENT];	/* Magic number and other info */
153ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Half	e_type;			/* Object file type */
154ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Half	e_machine;		/* Architecture */
155ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	e_version;		/* Object file version */
156ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Addr	e_entry;		/* Entry point virtual address */
157ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Off	e_phoff;		/* Program header table file offset */
158ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Off	e_shoff;		/* Section header table file offset */
159ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	e_flags;		/* Processor-specific flags */
160ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Half	e_ehsize;		/* ELF header size in bytes */
161ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Half	e_phentsize;		/* Program header table entry size */
162ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Half	e_phnum;		/* Program header table entry count */
163ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Half	e_shentsize;		/* Section header table entry size */
164ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Half	e_shnum;		/* Section header table entry count */
165ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Half	e_shstrndx;		/* Section header string table index */
166ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf32_Ehdr;
167ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
168ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
169ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
170ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  unsigned char	e_ident[EI_NIDENT];	/* Magic number and other info */
171ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Half	e_type;			/* Object file type */
172ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Half	e_machine;		/* Architecture */
173ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word	e_version;		/* Object file version */
174ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Addr	e_entry;		/* Entry point virtual address */
175ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Off	e_phoff;		/* Program header table file offset */
176ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Off	e_shoff;		/* Section header table file offset */
177ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word	e_flags;		/* Processor-specific flags */
178ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Half	e_ehsize;		/* ELF header size in bytes */
179ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Half	e_phentsize;		/* Program header table entry size */
180ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Half	e_phnum;		/* Program header table entry count */
181ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Half	e_shentsize;		/* Section header table entry size */
182ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Half	e_shnum;		/* Section header table entry count */
183ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Half	e_shstrndx;		/* Section header string table index */
184ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf64_Ehdr;
185ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
186ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Fields in the e_ident array.  The EI_* macros are indices into the
187ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   array.  The macros under each EI_* macro are the values the byte
188ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   may have.  */
189ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
190ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EI_MAG0		0		/* File identification byte 0 index */
191ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELFMAG0		0x7f		/* Magic number byte 0 */
192ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
193ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EI_MAG1		1		/* File identification byte 1 index */
194ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELFMAG1		'E'		/* Magic number byte 1 */
195ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
196ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EI_MAG2		2		/* File identification byte 2 index */
197ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELFMAG2		'L'		/* Magic number byte 2 */
198ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
199ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EI_MAG3		3		/* File identification byte 3 index */
200ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELFMAG3		'F'		/* Magic number byte 3 */
201ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
202ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Conglomeration of the identification bytes, for easy testing as a word.  */
203ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define	ELFMAG		"\177ELF"
204ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define	SELFMAG		4
205ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
206ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EI_CLASS	4		/* File class byte index */
207ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELFCLASSNONE	0		/* Invalid class */
208ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELFCLASS32	1		/* 32-bit objects */
209ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELFCLASS64	2		/* 64-bit objects */
210ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELFCLASSNUM	3
211ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
212ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EI_DATA		5		/* Data encoding byte index */
213ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELFDATANONE	0		/* Invalid data encoding */
214ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELFDATA2LSB	1		/* 2's complement, little endian */
215ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELFDATA2MSB	2		/* 2's complement, big endian */
216ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELFDATANUM	3
217ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
218ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EI_VERSION	6		/* File version byte index */
219ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					/* Value must be EV_CURRENT */
220ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
221ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EI_OSABI	7		/* OS ABI identification */
222ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELFOSABI_SYSV		0	/* UNIX System V ABI */
223ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELFOSABI_HPUX		1	/* HP-UX */
224ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELFOSABI_FREEBSD        9       /* Free BSD */
225ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELFOSABI_ARM		97	/* ARM */
226ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELFOSABI_STANDALONE	255	/* Standalone (embedded) application */
227ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
228ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EI_ABIVERSION	8		/* ABI version */
229ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
230ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EI_PAD		9		/* Byte index of padding bytes */
231ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
232ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for e_type (object file type).  */
233ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
234ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ET_NONE		0		/* No file type */
235ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ET_REL		1		/* Relocatable file */
236ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ET_EXEC		2		/* Executable file */
237ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ET_DYN		3		/* Shared object file */
238ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ET_CORE		4		/* Core file */
239ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define	ET_NUM		5		/* Number of defined types */
240ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ET_LOPROC	0xff00		/* Processor-specific */
241ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ET_HIPROC	0xffff		/* Processor-specific */
242ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
243ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for e_machine (architecture).  */
244ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
245ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_NONE		 0		/* No machine */
246ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_M32		 1		/* AT&T WE 32100 */
247ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_SPARC	 2		/* SUN SPARC */
248ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_386		 3		/* Intel 80386 */
249ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_68K		 4		/* Motorola m68k family */
250ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_88K		 5		/* Motorola m88k family */
251ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_486		 6		/* Intel 80486 */
252ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_860		 7		/* Intel 80860 */
253ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_MIPS		 8		/* MIPS R3000 big-endian */
254ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_S370		 9		/* Amdahl */
255ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_MIPS_RS4_BE	10		/* MIPS R4000 big-endian */
256ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_RS6000	11		/* RS6000 */
257ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
258ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_PARISC	15		/* HPPA */
259ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_nCUBE	16		/* nCUBE */
260ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_VPP500	17		/* Fujitsu VPP500 */
261ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_SPARC32PLUS	18		/* Sun's "v8plus" */
262ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_960		19		/* Intel 80960 */
263ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_PPC		20		/* PowerPC */
264ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
265ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_V800		36		/* NEC V800 series */
266ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_FR20		37		/* Fujitsu FR20 */
267ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_RH32		38		/* TRW RH32 */
268ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_MMA		39		/* Fujitsu MMA */
269ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_ARM		40		/* ARM */
270ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_FAKE_ALPHA	41		/* Digital Alpha */
271ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_SH		42		/* Hitachi SH */
272ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_SPARCV9	43		/* SPARC v9 64-bit */
273ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_TRICORE	44		/* Siemens Tricore */
274ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_ARC		45		/* Argonaut RISC Core */
275ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_H8_300	46		/* Hitachi H8/300 */
276ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_H8_300H	47		/* Hitachi H8/300H */
277ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_H8S		48		/* Hitachi H8S */
278ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_H8_500	49		/* Hitachi H8/500 */
279ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_IA_64	50		/* Intel Merced */
280ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_MIPS_X	51		/* Stanford MIPS-X */
281ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_COLDFIRE	52		/* Motorola Coldfire */
282ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_68HC12	53		/* Motorola M68HC12 */
283ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_NUM		54
284ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
285ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* If it is necessary to assign new unofficial EM_* values, please
286ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
287ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   chances of collision with official or non-GNU unofficial values.  */
288ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
289ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_ALPHA	0x9026
290ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EM_C60          0x9c60
291ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
292ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for e_version (version).  */
293ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
294ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EV_NONE		0		/* Invalid ELF version */
295ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EV_CURRENT	1		/* Current version */
296ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EV_NUM		2
297ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
298ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Section header.  */
299ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
300ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
301ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
302ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	sh_name;		/* Section name (string tbl index) */
303ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	sh_type;		/* Section type */
304ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	sh_flags;		/* Section flags */
305ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Addr	sh_addr;		/* Section virtual addr at execution */
306ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Off	sh_offset;		/* Section file offset */
307ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	sh_size;		/* Section size in bytes */
308ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	sh_link;		/* Link to another section */
309ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	sh_info;		/* Additional section information */
310ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	sh_addralign;		/* Section alignment */
311ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	sh_entsize;		/* Entry size if section holds table */
312ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf32_Shdr;
313ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
314ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
315ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
316ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word	sh_name;		/* Section name (string tbl index) */
317ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word	sh_type;		/* Section type */
318ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Xword	sh_flags;		/* Section flags */
319ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Addr	sh_addr;		/* Section virtual addr at execution */
320ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Off	sh_offset;		/* Section file offset */
321ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Xword	sh_size;		/* Section size in bytes */
322ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word	sh_link;		/* Link to another section */
323ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word	sh_info;		/* Additional section information */
324ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Xword	sh_addralign;		/* Section alignment */
325ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Xword	sh_entsize;		/* Entry size if section holds table */
326ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf64_Shdr;
327ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
328ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Special section indices.  */
329ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
330ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHN_UNDEF	0		/* Undefined section */
331ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHN_LORESERVE	0xff00		/* Start of reserved indices */
332ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHN_LOPROC	0xff00		/* Start of processor-specific */
333ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHN_HIPROC	0xff1f		/* End of processor-specific */
334ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHN_ABS		0xfff1		/* Associated symbol is absolute */
335ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHN_COMMON	0xfff2		/* Associated symbol is common */
336ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHN_HIRESERVE	0xffff		/* End of reserved indices */
337ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
338ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for sh_type (section type).  */
339ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
340ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_NULL	 0		/* Section header table entry unused */
341ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_PROGBITS	 1		/* Program data */
342ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_SYMTAB	 2		/* Symbol table */
343ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_STRTAB	 3		/* String table */
344ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_RELA	 4		/* Relocation entries with addends */
345ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_HASH	 5		/* Symbol hash table */
346ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_DYNAMIC	 6		/* Dynamic linking information */
347ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_NOTE	 7		/* Notes */
348ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_NOBITS	 8		/* Program space with no data (bss) */
349ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_REL		 9		/* Relocation entries, no addends */
350ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_SHLIB	 10		/* Reserved */
351ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_DYNSYM	 11		/* Dynamic linker symbol table */
352ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define	SHT_NUM		 12		/* Number of defined types.  */
353ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_LOOS	 0x60000000	/* Start OS-specific */
354ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_LOSUNW	 0x6ffffffb	/* Sun-specific low bound.  */
355ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_SUNW_COMDAT  0x6ffffffb
356ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_SUNW_syminfo 0x6ffffffc
357ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_GNU_verdef	 0x6ffffffd	/* Version definition section.  */
358ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_GNU_verneed	 0x6ffffffe	/* Version needs section.  */
359ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_GNU_versym	 0x6fffffff	/* Version symbol table.  */
360ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_HISUNW	 0x6fffffff	/* Sun-specific high bound.  */
361ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_HIOS	 0x6fffffff	/* End OS-specific type */
362ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_LOPROC	 0x70000000	/* Start of processor-specific */
363ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_HIPROC	 0x7fffffff	/* End of processor-specific */
364ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_LOUSER	 0x80000000	/* Start of application-specific */
365ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_HIUSER	 0x8fffffff	/* End of application-specific */
366ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
367ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for sh_flags (section flags).  */
368ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
369ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHF_WRITE	(1 << 0)	/* Writable */
370ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHF_ALLOC	(1 << 1)	/* Occupies memory during execution */
371ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHF_EXECINSTR	(1 << 2)	/* Executable */
372ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHF_MASKPROC	0xf0000000	/* Processor-specific */
373ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
374ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Symbol table entry.  */
375ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
376ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
377ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
378ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	st_name;		/* Symbol name (string tbl index) */
379ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Addr	st_value;		/* Symbol value */
380ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	st_size;		/* Symbol size */
381ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  unsigned char	st_info;		/* Symbol type and binding */
382ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  unsigned char	st_other;		/* No defined meaning, 0 */
383ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Section	st_shndx;		/* Section index */
384ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf32_Sym;
385ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
386ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
387ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
388ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word	st_name;		/* Symbol name (string tbl index) */
389ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  unsigned char	st_info;		/* Symbol type and binding */
390ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  unsigned char st_other;		/* No defined meaning, 0 */
391ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Section	st_shndx;		/* Section index */
392ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Addr	st_value;		/* Symbol value */
393ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Xword	st_size;		/* Symbol size */
394ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf64_Sym;
395ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
396ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* The syminfo section if available contains additional information about
397ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   every dynamic symbol.  */
398ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
399ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
400ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
401ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Half si_boundto;		/* Direct bindings, symbol bound to */
402ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Half si_flags;			/* Per symbol flags */
403ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf32_Syminfo;
404ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
405ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
406ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
407ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Half si_boundto;		/* Direct bindings, symbol bound to */
408ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Half si_flags;			/* Per symbol flags */
409ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf64_Syminfo;
410ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
411ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Possible values for si_boundto.  */
412ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SYMINFO_BT_SELF		0xffff	/* Symbol bound to self */
413ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SYMINFO_BT_PARENT	0xfffe	/* Symbol bound to parent */
414ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SYMINFO_BT_LOWRESERVE	0xff00	/* Beginning of reserved entries */
415ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
416ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Possible bitmasks for si_flags.  */
417ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SYMINFO_FLG_DIRECT	0x0001	/* Direct bound symbol */
418ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SYMINFO_FLG_PASSTHRU	0x0002	/* Pass-thru symbol for translator */
419ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SYMINFO_FLG_COPY	0x0004	/* Symbol is a copy-reloc */
420ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SYMINFO_FLG_LAZYLOAD	0x0008	/* Symbol bound to object to be lazy
421ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   loaded */
422ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Syminfo version values.  */
423ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SYMINFO_NONE		0
424ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SYMINFO_CURRENT		1
425ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SYMINFO_NUM		2
426ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
427ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
428ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Special section index.  */
429ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
430ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHN_UNDEF	0		/* No section, undefined symbol.  */
431ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
432ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* How to extract and insert information held in the st_info field.  */
433ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
434ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELF32_ST_BIND(val)		(((unsigned char) (val)) >> 4)
435ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELF32_ST_TYPE(val)		((val) & 0xf)
436ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELF32_ST_INFO(bind, type)	(((bind) << 4) + ((type) & 0xf))
437ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
438ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field.  */
439ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELF64_ST_BIND(val)		ELF32_ST_BIND (val)
440ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELF64_ST_TYPE(val)		ELF32_ST_TYPE (val)
441ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELF64_ST_INFO(bind, type)	ELF32_ST_INFO ((bind), (type))
442ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
443ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for ST_BIND subfield of st_info (symbol binding).  */
444ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
445ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STB_LOCAL	0		/* Local symbol */
446ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STB_GLOBAL	1		/* Global symbol */
447ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STB_WEAK	2		/* Weak symbol */
448ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define	STB_NUM		3		/* Number of defined types.  */
449ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STB_LOOS	10		/* Start of OS-specific */
450ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STB_HIOS	12		/* End of OS-specific */
451ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STB_LOPROC	13		/* Start of processor-specific */
452ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STB_HIPROC	15		/* End of processor-specific */
453ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
454ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for ST_TYPE subfield of st_info (symbol type).  */
455ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
456ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STT_NOTYPE	0		/* Symbol type is unspecified */
457ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STT_OBJECT	1		/* Symbol is a data object */
458ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STT_FUNC	2		/* Symbol is a code object */
459ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STT_SECTION	3		/* Symbol associated with a section */
460ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STT_FILE	4		/* Symbol's name is file name */
461ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define	STT_NUM		5		/* Number of defined types.  */
462ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STT_LOOS	11		/* Start of OS-specific */
463ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STT_HIOS	12		/* End of OS-specific */
464ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STT_LOPROC	13		/* Start of processor-specific */
465ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STT_HIPROC	15		/* End of processor-specific */
466ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
467ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
468ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Symbol table indices are found in the hash buckets and chain table
469ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   of a symbol hash table section.  This special index value indicates
470ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   the end of a chain, meaning no further symbols are found in that bucket.  */
471ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
472ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STN_UNDEF	0		/* End of a chain.  */
473ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
474ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
475ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* How to extract and insert information held in the st_other field.  */
476ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
477ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELF32_ST_VISIBILITY(o)	((o) & 0x03)
478ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
479ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* For ELF64 the definitions are the same.  */
480ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELF64_ST_VISIBILITY(o)	ELF32_ST_VISIBILITY (o)
481ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
482ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Symbol visibility specification encoded in the st_other field.  */
483ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STV_DEFAULT	0		/* Default symbol visibility rules */
484ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STV_INTERNAL	1		/* Processor specific hidden class */
485ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STV_HIDDEN	2		/* Sym unavailable in other modules */
486ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STV_PROTECTED	3		/* Not preemptible, not exported */
487ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
488ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
489ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Relocation table entry without addend (in section of type SHT_REL).  */
490ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
491ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
492ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
493ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Addr	r_offset;		/* Address */
494ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	r_info;			/* Relocation type and symbol index */
495ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf32_Rel;
496ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
497ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* I have seen two different definitions of the Elf64_Rel and
498ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   Elf64_Rela structures, so we'll leave them out until Novell (or
499ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   whoever) gets their act together.  */
500ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* The following, at least, is used on Sparc v9, MIPS, and Alpha.  */
501ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
502ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
503ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
504ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Addr	r_offset;		/* Address */
505ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Xword	r_info;			/* Relocation type and symbol index */
506ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf64_Rel;
507ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
508ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Relocation table entry with addend (in section of type SHT_RELA).  */
509ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
510ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
511ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
512ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Addr	r_offset;		/* Address */
513ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	r_info;			/* Relocation type and symbol index */
514ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Sword	r_addend;		/* Addend */
515ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf32_Rela;
516ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
517ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
518ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
519ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Addr	r_offset;		/* Address */
520ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Xword	r_info;			/* Relocation type and symbol index */
521ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Sxword	r_addend;		/* Addend */
522ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf64_Rela;
523ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
524ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* How to extract and insert information held in the r_info field.  */
525ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
526ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELF32_R_SYM(val)		((val) >> 8)
527ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELF32_R_TYPE(val)		((val) & 0xff)
528ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELF32_R_INFO(sym, type)		(((sym) << 8) + ((type) & 0xff))
529ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
530ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELF64_R_SYM(i)			((i) >> 32)
531ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELF64_R_TYPE(i)			((i) & 0xffffffff)
532ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELF64_R_INFO(sym,type)		(((sym) << 32) + (type))
533ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
534ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Program segment header.  */
535ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
536ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
537ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
538ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	p_type;			/* Segment type */
539ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Off	p_offset;		/* Segment file offset */
540ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Addr	p_vaddr;		/* Segment virtual address */
541ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Addr	p_paddr;		/* Segment physical address */
542ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	p_filesz;		/* Segment size in file */
543ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	p_memsz;		/* Segment size in memory */
544ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	p_flags;		/* Segment flags */
545ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	p_align;		/* Segment alignment */
546ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf32_Phdr;
547ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
548ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
549ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
550ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word	p_type;			/* Segment type */
551ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word	p_flags;		/* Segment flags */
552ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Off	p_offset;		/* Segment file offset */
553ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Addr	p_vaddr;		/* Segment virtual address */
554ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Addr	p_paddr;		/* Segment physical address */
555ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Xword	p_filesz;		/* Segment size in file */
556ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Xword	p_memsz;		/* Segment size in memory */
557ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Xword	p_align;		/* Segment alignment */
558ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf64_Phdr;
559ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
560ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for p_type (segment type).  */
561ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
562ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define	PT_NULL		0		/* Program header table entry unused */
563ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PT_LOAD		1		/* Loadable program segment */
564ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PT_DYNAMIC	2		/* Dynamic linking information */
565ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PT_INTERP	3		/* Program interpreter */
566ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PT_NOTE		4		/* Auxiliary information */
567ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PT_SHLIB	5		/* Reserved */
568ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PT_PHDR		6		/* Entry for header table itself */
569ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define	PT_NUM		7		/* Number of defined types.  */
570ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PT_LOOS		0x60000000	/* Start of OS-specific */
571ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PT_HIOS		0x6fffffff	/* End of OS-specific */
572ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PT_LOPROC	0x70000000	/* Start of processor-specific */
573ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PT_HIPROC	0x7fffffff	/* End of processor-specific */
574ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
575ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for p_flags (segment flags).  */
576ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
577ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PF_X		(1 << 0)	/* Segment is executable */
578ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PF_W		(1 << 1)	/* Segment is writable */
579ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PF_R		(1 << 2)	/* Segment is readable */
580ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PF_MASKPROC	0xf0000000	/* Processor-specific */
581ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
582ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for note segment descriptor types for core files. */
583ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
584ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define NT_PRSTATUS	1		/* Contains copy of prstatus struct */
585ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define NT_FPREGSET	2		/* Contains copy of fpregset struct */
586ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define NT_PRPSINFO	3		/* Contains copy of prpsinfo struct */
587ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define NT_PRXREG	4		/* Contains copy of prxregset struct */
588ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define NT_PLATFORM	5		/* String from sysinfo(SI_PLATFORM) */
589ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define NT_AUXV		6		/* Contains copy of auxv array */
590ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define NT_GWINDOWS	7		/* Contains copy of gwindows struct */
591ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define NT_PSTATUS	10		/* Contains copy of pstatus struct */
592ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define NT_PSINFO	13		/* Contains copy of psinfo struct */
593ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define NT_PRCRED	14		/* Contains copy of prcred struct */
594ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define NT_UTSNAME	15		/* Contains copy of utsname struct */
595ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define NT_LWPSTATUS	16		/* Contains copy of lwpstatus struct */
596ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define NT_LWPSINFO	17		/* Contains copy of lwpinfo struct */
597ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
598ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for the  note segment descriptor types for object files.  */
599ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
600ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define NT_VERSION	1		/* Contains a version string.  */
601ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
602ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
603ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Dynamic section entry.  */
604ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
605ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
606ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
607ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Sword	d_tag;			/* Dynamic entry type */
608ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  union
609ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    {
610ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown      Elf32_Word d_val;			/* Integer value */
611ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown      Elf32_Addr d_ptr;			/* Address value */
612ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    } d_un;
613ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf32_Dyn;
614ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
615ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
616ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
617ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Sxword	d_tag;			/* Dynamic entry type */
618ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  union
619ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    {
620ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown      Elf64_Xword d_val;		/* Integer value */
621ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown      Elf64_Addr d_ptr;			/* Address value */
622ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    } d_un;
623ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf64_Dyn;
624ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
625ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for d_tag (dynamic entry type).  */
626ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
627ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_NULL		0		/* Marks end of dynamic section */
628ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_NEEDED	1		/* Name of needed library */
629ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_PLTRELSZ	2		/* Size in bytes of PLT relocs */
630ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_PLTGOT	3		/* Processor defined value */
631ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_HASH		4		/* Address of symbol hash table */
632ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_STRTAB	5		/* Address of string table */
633ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_SYMTAB	6		/* Address of symbol table */
634ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_RELA		7		/* Address of Rela relocs */
635ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_RELASZ	8		/* Total size of Rela relocs */
636ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_RELAENT	9		/* Size of one Rela reloc */
637ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_STRSZ	10		/* Size of string table */
638ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_SYMENT	11		/* Size of one symbol table entry */
639ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_INIT		12		/* Address of init function */
640ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_FINI		13		/* Address of termination function */
641ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_SONAME	14		/* Name of shared object */
642ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_RPATH	15		/* Library search path */
643ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_SYMBOLIC	16		/* Start symbol search here */
644ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_REL		17		/* Address of Rel relocs */
645ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_RELSZ	18		/* Total size of Rel relocs */
646ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_RELENT	19		/* Size of one Rel reloc */
647ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_PLTREL	20		/* Type of reloc in PLT */
648ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_DEBUG	21		/* For debugging; unspecified */
649ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_TEXTREL	22		/* Reloc might modify .text */
650ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_JMPREL	23		/* Address of PLT relocs */
651ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define	DT_BIND_NOW	24		/* Process relocations of object */
652ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define	DT_INIT_ARRAY	25		/* Array with addresses of init fct */
653ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define	DT_FINI_ARRAY	26		/* Array with addresses of fini fct */
654ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define	DT_INIT_ARRAYSZ	27		/* Size in bytes of DT_INIT_ARRAY */
655ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define	DT_FINI_ARRAYSZ	28		/* Size in bytes of DT_FINI_ARRAY */
656ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define	DT_NUM		29		/* Number used */
657ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_LOOS		0x60000000	/* Start of OS-specific */
658ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_HIOS		0x6fffffff	/* End of OS-specific */
659ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_LOPROC	0x70000000	/* Start of processor-specific */
660ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_HIPROC	0x7fffffff	/* End of processor-specific */
661ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define	DT_PROCNUM	DT_MIPS_NUM	/* Most used by any processor */
662ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
663ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the
664ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   Dyn.d_un.d_val field of the Elf*_Dyn structure.  This follows Sun's
665ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   approach.  */
666ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_VALRNGLO	0x6ffffd00
667ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_POSFLAG_1	0x6ffffdfd	/* Flags for DT_* entries, effecting
668ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   the following DT_* entry.  */
669ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_SYMINSZ	0x6ffffdfe	/* Size of syminfo table (in bytes) */
670ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_SYMINENT	0x6ffffdff	/* Entry size of syminfo */
671ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_VALRNGHI	0x6ffffdff
672ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
673ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the
674ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   Dyn.d_un.d_ptr field of the Elf*_Dyn structure.
675ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
676ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   If any adjustment is made to the ELF object after it has been
677ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   built these entries will need to be adjusted.  */
678ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_ADDRRNGLO	0x6ffffe00
679ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_SYMINFO	0x6ffffeff	/* syminfo table */
680ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_ADDRRNGHI	0x6ffffeff
681ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
682ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* The versioning entry types.  The next are defined as part of the
683ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   GNU extension.  */
684ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_VERSYM	0x6ffffff0
685ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
686ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* These were chosen by Sun.  */
687ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_FLAGS_1	0x6ffffffb	/* State flags, see DF_1_* below.  */
688ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define	DT_VERDEF	0x6ffffffc	/* Address of version definition
689ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   table */
690ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define	DT_VERDEFNUM	0x6ffffffd	/* Number of version definitions */
691ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define	DT_VERNEED	0x6ffffffe	/* Address of table with needed
692ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   versions */
693ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define	DT_VERNEEDNUM	0x6fffffff	/* Number of needed versions */
694ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_VERSIONTAGIDX(tag)	(DT_VERNEEDNUM - (tag))	/* Reverse order! */
695ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_VERSIONTAGNUM 16
696ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
697ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Sun added these machine-independent extensions in the "processor-specific"
698ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   range.  Be compatible.  */
699ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_AUXILIARY    0x7ffffffd      /* Shared object to load before self */
700ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_FILTER       0x7fffffff      /* Shared object to get values from */
701ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_EXTRATAGIDX(tag)	((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)
702ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_EXTRANUM	3
703ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
704ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1
705ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   entry in the dynamic section.  */
706ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DF_1_NOW	0x00000001	/* Set RTLD_NOW for this object.  */
707ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DF_1_GLOBAL	0x00000002	/* Set RTLD_GLOBAL for this object.  */
708ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DF_1_GROUP	0x00000004	/* Set RTLD_GROUP for this object.  */
709ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DF_1_NODELETE	0x00000008	/* Set RTLD_NODELETE for this object.*/
710ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DF_1_LOADFLTR	0x00000010	/* Trigger filtee loading at runtime.*/
711ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DF_1_INITFIRST	0x00000020	/* Set RTLD_INITFIRST for this object*/
712ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DF_1_NOOPEN	0x00000040	/* Set RTLD_NOOPEN for this object.  */
713ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
714ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Version definition sections.  */
715ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
716ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
717ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
718ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Half	vd_version;		/* Version revision */
719ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Half	vd_flags;		/* Version information */
720ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Half	vd_ndx;			/* Version Index */
721ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Half	vd_cnt;			/* Number of associated aux entries */
722ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	vd_hash;		/* Version name hash value */
723ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	vd_aux;			/* Offset in bytes to verdaux array */
724ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	vd_next;		/* Offset in bytes to next verdef
725ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   entry */
726ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf32_Verdef;
727ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
728ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
729ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
730ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Half	vd_version;		/* Version revision */
731ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Half	vd_flags;		/* Version information */
732ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Half	vd_ndx;			/* Version Index */
733ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Half	vd_cnt;			/* Number of associated aux entries */
734ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word	vd_hash;		/* Version name hash value */
735ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word	vd_aux;			/* Offset in bytes to verdaux array */
736ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word	vd_next;		/* Offset in bytes to next verdef
737ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   entry */
738ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf64_Verdef;
739ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
740ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
741ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for vd_version (version revision).  */
742ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define VER_DEF_NONE	0		/* No version */
743ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define VER_DEF_CURRENT	1		/* Current version */
744ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define VER_DEF_NUM	2		/* Given version number */
745ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
746ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for vd_flags (version information flags).  */
747ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define VER_FLG_BASE	0x1		/* Version definition of file itself */
748ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define VER_FLG_WEAK	0x2		/* Weak version identifier */
749ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
750ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Auxialiary version information.  */
751ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
752ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
753ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
754ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	vda_name;		/* Version or dependency names */
755ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	vda_next;		/* Offset in bytes to next verdaux
756ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   entry */
757ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf32_Verdaux;
758ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
759ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
760ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
761ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word	vda_name;		/* Version or dependency names */
762ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word	vda_next;		/* Offset in bytes to next verdaux
763ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   entry */
764ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf64_Verdaux;
765ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
766ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
767ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Version dependency section.  */
768ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
769ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
770ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
771ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Half	vn_version;		/* Version of structure */
772ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Half	vn_cnt;			/* Number of associated aux entries */
773ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	vn_file;		/* Offset of filename for this
774ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   dependency */
775ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	vn_aux;			/* Offset in bytes to vernaux array */
776ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	vn_next;		/* Offset in bytes to next verneed
777ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   entry */
778ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf32_Verneed;
779ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
780ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
781ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
782ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Half	vn_version;		/* Version of structure */
783ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Half	vn_cnt;			/* Number of associated aux entries */
784ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word	vn_file;		/* Offset of filename for this
785ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   dependency */
786ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word	vn_aux;			/* Offset in bytes to vernaux array */
787ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word	vn_next;		/* Offset in bytes to next verneed
788ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   entry */
789ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf64_Verneed;
790ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
791ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
792ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for vn_version (version revision).  */
793ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define VER_NEED_NONE	 0		/* No version */
794ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define VER_NEED_CURRENT 1		/* Current version */
795ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define VER_NEED_NUM	 2		/* Given version number */
796ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
797ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Auxiliary needed version information.  */
798ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
799ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
800ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
801ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	vna_hash;		/* Hash value of dependency name */
802ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Half	vna_flags;		/* Dependency specific information */
803ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Half	vna_other;		/* Unused */
804ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	vna_name;		/* Dependency name string offset */
805ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	vna_next;		/* Offset in bytes to next vernaux
806ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   entry */
807ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf32_Vernaux;
808ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
809ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
810ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
811ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word	vna_hash;		/* Hash value of dependency name */
812ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Half	vna_flags;		/* Dependency specific information */
813ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Half	vna_other;		/* Unused */
814ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word	vna_name;		/* Dependency name string offset */
815ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word	vna_next;		/* Offset in bytes to next vernaux
816ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   entry */
817ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf64_Vernaux;
818ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
819ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
820ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for vna_flags.  */
821ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define VER_FLG_WEAK	0x2		/* Weak version identifier */
822ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
823ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
824ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Auxiliary vector.  */
825ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
826ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* This vector is normally only used by the program interpreter.  The
827ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   usual definition in an ABI supplement uses the name auxv_t.  The
828ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   vector is not usually defined in a standard <elf.h> file, but it
829ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   can't hurt.  We rename it to avoid conflicts.  The sizes of these
830ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   types are an arrangement between the exec server and the program
831ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   interpreter, so we don't fully specify them here.  */
832ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
833ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
834ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
835ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  int a_type;			/* Entry type */
836ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  union
837ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    {
838ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown      long int a_val;		/* Integer value */
839ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown      void *a_ptr;		/* Pointer value */
840ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown      void (*a_fcn) (void);	/* Function pointer value */
841ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    } a_un;
842ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf32_auxv_t;
843ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
844ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
845ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
846ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  long int a_type;		/* Entry type */
847ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  union
848ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    {
849ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown      long int a_val;		/* Integer value */
850ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown      void *a_ptr;		/* Pointer value */
851ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown      void (*a_fcn) (void);	/* Function pointer value */
852ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    } a_un;
853ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf64_auxv_t;
854ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
855ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for a_type (entry type).  */
856ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
857ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define AT_NULL		0		/* End of vector */
858ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define AT_IGNORE	1		/* Entry should be ignored */
859ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define AT_EXECFD	2		/* File descriptor of program */
860ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define AT_PHDR		3		/* Program headers for program */
861ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define AT_PHENT	4		/* Size of program header entry */
862ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define AT_PHNUM	5		/* Number of program headers */
863ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define AT_PAGESZ	6		/* System page size */
864ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define AT_BASE		7		/* Base address of interpreter */
865ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define AT_FLAGS	8		/* Flags */
866ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define AT_ENTRY	9		/* Entry point of program */
867ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define AT_NOTELF	10		/* Program is not ELF */
868ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define AT_UID		11		/* Real uid */
869ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define AT_EUID		12		/* Effective uid */
870ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define AT_GID		13		/* Real gid */
871ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define AT_EGID		14		/* Effective gid */
872ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
873ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Some more special a_type values describing the hardware.  */
874ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define AT_PLATFORM	15		/* String identifying platform.  */
875ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define AT_HWCAP	16		/* Machine dependent hints about
876ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   processor capabilities.  */
877ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
878ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* This entry gives some information about the FPU initialization
879ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   performed by the kernel.  */
880ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define AT_FPUCW	17		/* Used FPU control word.  */
881ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
882ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
883ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Note section contents.  Each entry in the note section begins with
884ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   a header of a fixed form.  */
885ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
886ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
887ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
888ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word n_namesz;			/* Length of the note's name.  */
889ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word n_descsz;			/* Length of the note's descriptor.  */
890ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word n_type;			/* Type of the note.  */
891ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf32_Nhdr;
892ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
893ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
894ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
895ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word n_namesz;			/* Length of the note's name.  */
896ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word n_descsz;			/* Length of the note's descriptor.  */
897ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word n_type;			/* Type of the note.  */
898ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf64_Nhdr;
899ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
900ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Known names of notes.  */
901ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
902ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Solaris entries in the note section have this name.  */
903ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELF_NOTE_SOLARIS	"SUNW Solaris"
904ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
905ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Note entries for GNU systems have this name.  */
906ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELF_NOTE_GNU		"GNU"
907ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
908ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
909ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Defined types of notes for Solaris.  */
910ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
911ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Value of descriptor (one word) is desired pagesize for the binary.  */
912ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELF_NOTE_PAGESIZE_HINT	1
913ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
914ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
915ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Defined note types for GNU systems.  */
916ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
917ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ABI information.  The descriptor consists of words:
918ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   word 0: OS descriptor
919ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   word 1: major version of the ABI
920ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   word 2: minor version of the ABI
921ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   word 3: subminor version of the ABI
922ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown*/
923ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELF_NOTE_ABI		1
924ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
925ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Known OSes.  These value can appear in word 0 of an ELF_NOTE_ABI
926ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   note section entry.  */
927ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELF_NOTE_OS_LINUX	0
928ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELF_NOTE_OS_GNU		1
929ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ELF_NOTE_OS_SOLARIS2	2
930ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
931ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
932ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Motorola 68k specific definitions.  */
933ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
934ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* m68k relocs.  */
935ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
936ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_NONE	0		/* No reloc */
937ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_32	1		/* Direct 32 bit  */
938ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_16	2		/* Direct 16 bit  */
939ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_8		3		/* Direct 8 bit  */
940ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_PC32	4		/* PC relative 32 bit */
941ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_PC16	5		/* PC relative 16 bit */
942ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_PC8	6		/* PC relative 8 bit */
943ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_GOT32	7		/* 32 bit PC relative GOT entry */
944ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_GOT16	8		/* 16 bit PC relative GOT entry */
945ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_GOT8	9		/* 8 bit PC relative GOT entry */
946ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_GOT32O	10		/* 32 bit GOT offset */
947ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_GOT16O	11		/* 16 bit GOT offset */
948ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_GOT8O	12		/* 8 bit GOT offset */
949ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_PLT32	13		/* 32 bit PC relative PLT address */
950ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_PLT16	14		/* 16 bit PC relative PLT address */
951ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_PLT8	15		/* 8 bit PC relative PLT address */
952ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_PLT32O	16		/* 32 bit PLT offset */
953ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_PLT16O	17		/* 16 bit PLT offset */
954ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_PLT8O	18		/* 8 bit PLT offset */
955ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_COPY	19		/* Copy symbol at runtime */
956ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_GLOB_DAT	20		/* Create GOT entry */
957ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_JMP_SLOT	21		/* Create PLT entry */
958ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_RELATIVE	22		/* Adjust by program base */
959ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Keep this the last entry.  */
960ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_68K_NUM	23
961ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
962ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Intel 80386 specific definitions.  */
963ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
964ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* i386 relocs.  */
965ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
966ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_386_NONE	0		/* No reloc */
967ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_386_32	1		/* Direct 32 bit  */
968ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_386_PC32	2		/* PC relative 32 bit */
969ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_386_GOT32	3		/* 32 bit GOT entry */
970ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_386_PLT32	4		/* 32 bit PLT address */
971ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_386_COPY	5		/* Copy symbol at runtime */
972ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_386_GLOB_DAT	6		/* Create GOT entry */
973ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_386_JMP_SLOT	7		/* Create PLT entry */
974ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_386_RELATIVE	8		/* Adjust by program base */
975ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_386_GOTOFF	9		/* 32 bit offset to GOT */
976ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_386_GOTPC	10		/* 32 bit PC relative offset to GOT */
977ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Keep this the last entry.  */
978ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_386_NUM	11
979ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
980ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* SUN SPARC specific definitions.  */
981ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
982ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Values for Elf64_Ehdr.e_flags.  */
983ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
984ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_SPARCV9_MM		3
985ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_SPARCV9_TSO		0
986ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_SPARCV9_PSO		1
987ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_SPARCV9_RMO		2
988ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_SPARC_EXT_MASK	0xFFFF00
989ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_SPARC_SUN_US1	0x000200
990ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_SPARC_HAL_R1		0x000400
991ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
992ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* SPARC relocs.  */
993ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
994ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_NONE	0		/* No reloc */
995ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_8	1		/* Direct 8 bit */
996ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_16	2		/* Direct 16 bit */
997ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_32	3		/* Direct 32 bit */
998ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_DISP8	4		/* PC relative 8 bit */
999ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_DISP16	5		/* PC relative 16 bit */
1000ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_DISP32	6		/* PC relative 32 bit */
1001ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_WDISP30	7		/* PC relative 30 bit shifted */
1002ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_WDISP22	8		/* PC relative 22 bit shifted */
1003ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_HI22	9		/* High 22 bit */
1004ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_22	10		/* Direct 22 bit */
1005ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_13	11		/* Direct 13 bit */
1006ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_LO10	12		/* Truncated 10 bit */
1007ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_GOT10	13		/* Truncated 10 bit GOT entry */
1008ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_GOT13	14		/* 13 bit GOT entry */
1009ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_GOT22	15		/* 22 bit GOT entry shifted */
1010ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_PC10	16		/* PC relative 10 bit truncated */
1011ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_PC22	17		/* PC relative 22 bit shifted */
1012ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_WPLT30	18		/* 30 bit PC relative PLT address */
1013ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_COPY	19		/* Copy symbol at runtime */
1014ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_GLOB_DAT 20		/* Create GOT entry */
1015ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_JMP_SLOT 21		/* Create PLT entry */
1016ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_RELATIVE 22		/* Adjust by program base */
1017ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_UA32	23		/* Direct 32 bit unaligned */
1018ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1019ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Additional Sparc64 relocs.  */
1020ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1021ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_PLT32	24		/* Direct 32 bit ref to PLT entry */
1022ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_HIPLT22	25		/* High 22 bit PLT entry */
1023ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_LOPLT10	26		/* Truncated 10 bit PLT entry */
1024ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_PCPLT32	27		/* PC rel 32 bit ref to PLT entry */
1025ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_PCPLT22	28		/* PC rel high 22 bit PLT entry */
1026ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_PCPLT10	29		/* PC rel trunc 10 bit PLT entry */
1027ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_10	30		/* Direct 10 bit */
1028ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_11	31		/* Direct 11 bit */
1029ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_64	32		/* Direct 64 bit */
1030ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_OLO10	33		/* ?? */
1031ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_HH22	34		/* Top 22 bits of direct 64 bit */
1032ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_HM10	35		/* High middle 10 bits of ... */
1033ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_LM22	36		/* Low middle 22 bits of ... */
1034ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_PC_HH22	37		/* Top 22 bits of pc rel 64 bit */
1035ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_PC_HM10	38		/* High middle 10 bit of ... */
1036ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_PC_LM22	39		/* Low miggle 22 bits of ... */
1037ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_WDISP16	40		/* PC relative 16 bit shifted */
1038ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_WDISP19	41		/* PC relative 19 bit shifted */
1039ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_7	43		/* Direct 7 bit */
1040ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_5	44		/* Direct 5 bit */
1041ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_6	45		/* Direct 6 bit */
1042ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_DISP64	46		/* PC relative 64 bit */
1043ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_PLT64	47		/* Direct 64 bit ref to PLT entry */
1044ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_HIX22	48		/* High 22 bit complemented */
1045ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_LOX10	49		/* Truncated 11 bit complemented */
1046ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_H44	50		/* Direct high 12 of 44 bit */
1047ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_M44	51		/* Direct mid 22 of 44 bit */
1048ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_L44	52		/* Direct low 10 of 44 bit */
1049ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_REGISTER 53		/* Global register usage */
1050ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_UA64	54		/* Direct 64 bit unaligned */
1051ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_UA16	55		/* Direct 16 bit unaligned */
1052ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Keep this the last entry.  */
1053ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_SPARC_NUM	56
1054ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1055ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* For Sparc64, legal values for d_tag of Elf64_Dyn.  */
1056ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1057ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_SPARC_REGISTER 0x70000001
1058ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_SPARC_NUM	2
1059ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1060ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Bits present in AT_HWCAP, primarily for Sparc32.  */
1061ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1062ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define HWCAP_SPARC_FLUSH	1	/* The cpu supports flush insn.  */
1063ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define HWCAP_SPARC_STBAR	2
1064ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define HWCAP_SPARC_SWAP	4
1065ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define HWCAP_SPARC_MULDIV	8
1066ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define HWCAP_SPARC_V9		16	/* The cpu is v9, so v8plus is ok.  */
1067ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1068ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* MIPS R3000 specific definitions.  */
1069ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1070ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for e_flags field of Elf32_Ehdr.  */
1071ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1072ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_MIPS_NOREORDER   1		/* A .noreorder directive was used */
1073ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_MIPS_PIC	    2		/* Contains PIC code */
1074ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_MIPS_CPIC	    4		/* Uses PIC calling sequence */
1075ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_MIPS_XGOT	    8
1076ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_MIPS_64BIT_WHIRL 16
1077ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_MIPS_ABI2	    32
1078ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_MIPS_ABI_ON32    64
1079ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_MIPS_ARCH	    0xf0000000	/* MIPS architecture level */
1080ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1081ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for MIPS architecture level.  */
1082ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1083ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_MIPS_ARCH_1	    0x00000000	/* -mips1 code.  */
1084ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_MIPS_ARCH_2	    0x10000000	/* -mips2 code.  */
1085ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_MIPS_ARCH_3	    0x20000000	/* -mips3 code.  */
1086ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_MIPS_ARCH_4	    0x30000000	/* -mips4 code.  */
1087ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_MIPS_ARCH_5	    0x40000000	/* -mips5 code.  */
1088ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1089ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* The following are non-official names and should not be used.  */
1090ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1091ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define E_MIPS_ARCH_1	  0x00000000	/* -mips1 code.  */
1092ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define E_MIPS_ARCH_2	  0x10000000	/* -mips2 code.  */
1093ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define E_MIPS_ARCH_3	  0x20000000	/* -mips3 code.  */
1094ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define E_MIPS_ARCH_4	  0x30000000	/* -mips4 code.  */
1095ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define E_MIPS_ARCH_5	  0x40000000	/* -mips5 code.  */
1096ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1097ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Special section indices.  */
1098ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1099ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHN_MIPS_ACOMMON 0xff00		/* Allocated common symbols */
1100ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHN_MIPS_TEXT	 0xff01		/* Allocated test symbols.  */
1101ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHN_MIPS_DATA	 0xff02		/* Allocated data symbols.  */
1102ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHN_MIPS_SCOMMON 0xff03		/* Small common symbols */
1103ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHN_MIPS_SUNDEFINED 0xff04	/* Small undefined symbols */
1104ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1105ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for sh_type field of Elf32_Shdr.  */
1106ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1107ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_LIBLIST       0x70000000 /* Shared objects used in link */
1108ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_MSYM	       0x70000001
1109ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_CONFLICT      0x70000002 /* Conflicting symbols */
1110ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_GPTAB	       0x70000003 /* Global data area sizes */
1111ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_UCODE	       0x70000004 /* Reserved for SGI/MIPS compilers */
1112ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_DEBUG	       0x70000005 /* MIPS ECOFF debugging information*/
1113ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_REGINFO       0x70000006 /* Register usage information */
1114ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_PACKAGE       0x70000007
1115ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_PACKSYM       0x70000008
1116ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_RELD	       0x70000009
1117ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_IFACE         0x7000000b
1118ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_CONTENT       0x7000000c
1119ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_OPTIONS       0x7000000d /* Miscellaneous options.  */
1120ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_SHDR	       0x70000010
1121ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_FDESC	       0x70000011
1122ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_EXTSYM	       0x70000012
1123ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_DENSE	       0x70000013
1124ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_PDESC	       0x70000014
1125ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_LOCSYM	       0x70000015
1126ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_AUXSYM	       0x70000016
1127ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_OPTSYM	       0x70000017
1128ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_LOCSTR	       0x70000018
1129ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_LINE	       0x70000019
1130ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_RFDESC	       0x7000001a
1131ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_DELTASYM      0x7000001b
1132ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_DELTAINST     0x7000001c
1133ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_DELTACLASS    0x7000001d
1134ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_DWARF         0x7000001e /* DWARF debugging information.  */
1135ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_DELTADECL     0x7000001f
1136ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_SYMBOL_LIB    0x70000020
1137ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_EVENTS	       0x70000021 /* Event section.  */
1138ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_TRANSLATE     0x70000022
1139ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_PIXIE	       0x70000023
1140ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_XLATE	       0x70000024
1141ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_XLATE_DEBUG   0x70000025
1142ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_WHIRL	       0x70000026
1143ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_EH_REGION     0x70000027
1144ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_XLATE_OLD     0x70000028
1145ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_MIPS_PDR_EXCEPTION 0x70000029
1146ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1147ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for sh_flags field of Elf32_Shdr.  */
1148ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1149ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHF_MIPS_GPREL	 0x10000000	/* Must be part of global data area */
1150ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHF_MIPS_MERGE	 0x20000000
1151ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHF_MIPS_ADDR	 0x40000000
1152ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHF_MIPS_STRINGS 0x80000000
1153ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHF_MIPS_NOSTRIP 0x08000000
1154ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHF_MIPS_LOCAL	 0x04000000
1155ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHF_MIPS_NAMES	 0x02000000
1156ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHF_MIPS_NODUPE	 0x01000000
1157ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1158ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1159ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Symbol tables.  */
1160ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1161ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* MIPS specific values for `st_other'.  */
1162ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STO_MIPS_DEFAULT		0x0
1163ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STO_MIPS_INTERNAL		0x1
1164ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STO_MIPS_HIDDEN			0x2
1165ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STO_MIPS_PROTECTED		0x3
1166ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STO_MIPS_SC_ALIGN_UNUSED	0xff
1167ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1168ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* MIPS specific values for `st_info'.  */
1169ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STB_MIPS_SPLIT_COMMON		13
1170ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1171ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Entries found in sections of type SHT_MIPS_GPTAB.  */
1172ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1173ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef union
1174ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
1175ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  struct
1176ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    {
1177ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown      Elf32_Word gt_current_g_value;	/* -G value used for compilation */
1178ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown      Elf32_Word gt_unused;		/* Not used */
1179ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    } gt_header;			/* First entry in section */
1180ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  struct
1181ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    {
1182ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown      Elf32_Word gt_g_value;		/* If this value were used for -G */
1183ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown      Elf32_Word gt_bytes;		/* This many bytes would be used */
1184ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    } gt_entry;				/* Subsequent entries in section */
1185ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf32_gptab;
1186ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1187ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Entry found in sections of type SHT_MIPS_REGINFO.  */
1188ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1189ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
1190ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
1191ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	ri_gprmask;		/* General registers used */
1192ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word	ri_cprmask[4];		/* Coprocessor registers used */
1193ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Sword	ri_gp_value;		/* $gp register value */
1194ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf32_RegInfo;
1195ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1196ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Entries found in sections of type SHT_MIPS_OPTIONS.  */
1197ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1198ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
1199ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
1200ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  unsigned char kind;		/* Determines interpretation of the
1201ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown				   variable part of descriptor.  */
1202ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  unsigned char size;		/* Size of descriptor, including header.  */
1203ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Section section;	/* Section header index of section affected,
1204ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown				   0 for global options.  */
1205ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word info;		/* Kind-specific information.  */
1206ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf_Options;
1207ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1208ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Values for `kind' field in Elf_Options.  */
1209ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1210ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ODK_NULL	0	/* Undefined.  */
1211ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ODK_REGINFO	1	/* Register usage information.  */
1212ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ODK_EXCEPTIONS	2	/* Exception processing options.  */
1213ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ODK_PAD		3	/* Section padding options.  */
1214ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ODK_HWPATCH	4	/* Hardware workarounds performed */
1215ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ODK_FILL	5	/* record the fill value used by the linker. */
1216ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ODK_TAGS	6	/* reserve space for desktop tools to write. */
1217ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ODK_HWAND	7	/* HW workarounds.  'AND' bits when merging. */
1218ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define ODK_HWOR	8	/* HW workarounds.  'OR' bits when merging.  */
1219ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1220ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries.  */
1221ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1222ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define OEX_FPU_MIN	0x1f	/* FPE's which MUST be enabled.  */
1223ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define OEX_FPU_MAX	0x1f00	/* FPE's which MAY be enabled.  */
1224ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define OEX_PAGE0	0x10000	/* page zero must be mapped.  */
1225ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define OEX_SMM		0x20000	/* Force sequential memory mode?  */
1226ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define OEX_FPDBUG	0x40000	/* Force floating point debug mode?  */
1227ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define OEX_PRECISEFP	OEX_FPDBUG
1228ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define OEX_DISMISS	0x80000	/* Dismiss invalid address faults?  */
1229ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1230ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define OEX_FPU_INVAL	0x10
1231ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define OEX_FPU_DIV0	0x08
1232ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define OEX_FPU_OFLO	0x04
1233ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define OEX_FPU_UFLO	0x02
1234ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define OEX_FPU_INEX	0x01
1235ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1236ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry.  */
1237ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1238ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define OHW_R4KEOP	0x1	/* R4000 end-of-page patch.  */
1239ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define OHW_R8KPFETCH	0x2	/* may need R8000 prefetch patch.  */
1240ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define OHW_R5KEOP	0x4	/* R5000 end-of-page patch.  */
1241ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define OHW_R5KCVTL	0x8	/* R5000 cvt.[ds].l bug.  clean=1.  */
1242ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1243ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define OPAD_PREFIX	0x1
1244ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define OPAD_POSTFIX	0x2
1245ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define OPAD_SYMBOL	0x4
1246ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1247ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Entry found in `.options' section.  */
1248ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1249ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
1250ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
1251ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word hwp_flags1;	/* Extra flags.  */
1252ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word hwp_flags2;	/* Extra flags.  */
1253ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf_Options_Hw;
1254ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1255ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries.  */
1256ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1257ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define OHWA0_R4KEOP_CHECKED	0x00000001
1258ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define OHWA1_R4KEOP_CLEAN	0x00000002
1259ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1260ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* MIPS relocs.  */
1261ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1262ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_NONE		0	/* No reloc */
1263ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_16		1	/* Direct 16 bit */
1264ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_32		2	/* Direct 32 bit */
1265ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_REL32		3	/* PC relative 32 bit */
1266ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_26		4	/* Direct 26 bit shifted */
1267ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_HI16		5	/* High 16 bit */
1268ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_LO16		6	/* Low 16 bit */
1269ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_GPREL16		7	/* GP relative 16 bit */
1270ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_LITERAL		8	/* 16 bit literal entry */
1271ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_GOT16		9	/* 16 bit GOT entry */
1272ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_PC16		10	/* PC relative 16 bit */
1273ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_CALL16		11	/* 16 bit GOT entry for function */
1274ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_GPREL32		12	/* GP relative 32 bit */
1275ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1276ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_SHIFT5		16
1277ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_SHIFT6		17
1278ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_64		18
1279ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_GOT_DISP		19
1280ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_GOT_PAGE		20
1281ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_GOT_OFST		21
1282ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_GOT_HI16		22
1283ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_GOT_LO16		23
1284ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_SUB		24
1285ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_INSERT_A		25
1286ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_INSERT_B		26
1287ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_DELETE		27
1288ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_HIGHER		28
1289ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_HIGHEST		29
1290ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_CALL_HI16	30
1291ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_CALL_LO16	31
1292ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_SCN_DISP		32
1293ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_REL16		33
1294ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_ADD_IMMEDIATE	34
1295ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_PJUMP		35
1296ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_RELGOT		36
1297ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_JALR		37
1298ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Keep this the last entry.  */
1299ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_MIPS_NUM		38
1300ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1301ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for p_type field of Elf32_Phdr.  */
1302ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1303ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PT_MIPS_REGINFO	0x70000000	/* Register usage information */
1304ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PT_MIPS_RTPROC  0x70000001	/* Runtime procedure table. */
1305ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PT_MIPS_OPTIONS 0x70000002
1306ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1307ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Special program header types.  */
1308ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1309ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PF_MIPS_LOCAL	0x10000000
1310ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1311ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for d_tag field of Elf32_Dyn.  */
1312ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1313ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_RLD_VERSION  0x70000001	/* Runtime linker interface version */
1314ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_TIME_STAMP   0x70000002	/* Timestamp */
1315ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_ICHECKSUM    0x70000003	/* Checksum */
1316ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_IVERSION     0x70000004	/* Version string (string tbl index) */
1317ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_FLAGS	     0x70000005	/* Flags */
1318ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_BASE_ADDRESS 0x70000006	/* Base address */
1319ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_MSYM	     0x70000007
1320ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_CONFLICT     0x70000008	/* Address of CONFLICT section */
1321ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_LIBLIST	     0x70000009	/* Address of LIBLIST section */
1322ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_LOCAL_GOTNO  0x7000000a	/* Number of local GOT entries */
1323ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_CONFLICTNO   0x7000000b	/* Number of CONFLICT entries */
1324ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_LIBLISTNO    0x70000010	/* Number of LIBLIST entries */
1325ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_SYMTABNO     0x70000011	/* Number of DYNSYM entries */
1326ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_UNREFEXTNO   0x70000012	/* First external DYNSYM */
1327ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_GOTSYM	     0x70000013	/* First GOT entry in DYNSYM */
1328ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_HIPAGENO     0x70000014	/* Number of GOT page table entries */
1329ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_RLD_MAP	     0x70000016	/* Address of run time loader map.  */
1330ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_DELTA_CLASS  0x70000017	/* Delta C++ class definition.  */
1331ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_DELTA_CLASS_NO    0x70000018 /* Number of entries in
1332ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown						DT_MIPS_DELTA_CLASS.  */
1333ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_DELTA_INSTANCE    0x70000019 /* Delta C++ class instances.  */
1334ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in
1335ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown						DT_MIPS_DELTA_INSTANCE.  */
1336ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_DELTA_RELOC  0x7000001b /* Delta relocations.  */
1337ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in
1338ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					     DT_MIPS_DELTA_RELOC.  */
1339ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_DELTA_SYM    0x7000001d /* Delta symbols that Delta
1340ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   relocations refer to.  */
1341ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in
1342ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   DT_MIPS_DELTA_SYM.  */
1343ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the
1344ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					     class declaration.  */
1345ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in
1346ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown						DT_MIPS_DELTA_CLASSSYM.  */
1347ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_CXX_FLAGS    0x70000022 /* Flags indicating for C++ flavor.  */
1348ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_PIXIE_INIT   0x70000023
1349ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_SYMBOL_LIB   0x70000024
1350ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025
1351ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_LOCAL_GOTIDX 0x70000026
1352ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_HIDDEN_GOTIDX 0x70000027
1353ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_PROTECTED_GOTIDX 0x70000028
1354ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_OPTIONS	     0x70000029 /* Address of .options.  */
1355ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_INTERFACE    0x7000002a /* Address of .interface.  */
1356ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_DYNSTR_ALIGN 0x7000002b
1357ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */
1358ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve
1359ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown						    function stored in GOT.  */
1360ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_PERF_SUFFIX  0x7000002e /* Default suffix of dso to be added
1361ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   by rld on dlopen() calls.  */
1362ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */
1363ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_GP_VALUE     0x70000030 /* GP value for aux GOTs.  */
1364ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_AUX_DYNAMIC  0x70000031 /* Address of aux .dynamic.  */
1365ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define DT_MIPS_NUM	     0x32
1366ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1367ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry.  */
1368ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1369ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define RHF_NONE		   0		/* No flags */
1370ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define RHF_QUICKSTART		   (1 << 0)	/* Use quickstart */
1371ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define RHF_NOTPOT		   (1 << 1)	/* Hash size not power of 2 */
1372ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2)	/* Ignore LD_LIBRARY_PATH */
1373ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define RHF_NO_MOVE		   (1 << 3)
1374ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define RHF_SGI_ONLY		   (1 << 4)
1375ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define RHF_GUARANTEE_INIT	   (1 << 5)
1376ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define RHF_DELTA_C_PLUS_PLUS	   (1 << 6)
1377ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define RHF_GUARANTEE_START_INIT   (1 << 7)
1378ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define RHF_PIXIE		   (1 << 8)
1379ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define RHF_DEFAULT_DELAY_LOAD	   (1 << 9)
1380ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define RHF_REQUICKSTART	   (1 << 10)
1381ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define RHF_REQUICKSTARTED	   (1 << 11)
1382ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define RHF_CORD		   (1 << 12)
1383ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define RHF_NO_UNRES_UNDEF	   (1 << 13)
1384ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define RHF_RLD_ORDER_SAFE	   (1 << 14)
1385ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1386ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Entries found in sections of type SHT_MIPS_LIBLIST.  */
1387ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1388ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
1389ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
1390ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word l_name;		/* Name (string table index) */
1391ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word l_time_stamp;	/* Timestamp */
1392ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word l_checksum;	/* Checksum */
1393ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word l_version;		/* Interface version */
1394ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf32_Word l_flags;		/* Flags */
1395ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf32_Lib;
1396ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1397ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct
1398ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
1399ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word l_name;		/* Name (string table index) */
1400ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word l_time_stamp;	/* Timestamp */
1401ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word l_checksum;	/* Checksum */
1402ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word l_version;		/* Interface version */
1403ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown  Elf64_Word l_flags;		/* Flags */
1404ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Elf64_Lib;
1405ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1406ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1407ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for l_flags.  */
1408ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1409ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define LL_NONE		  0
1410ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define LL_EXACT_MATCH	  (1 << 0)	/* Require exact match */
1411ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define LL_IGNORE_INT_VER (1 << 1)	/* Ignore interface version */
1412ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define LL_REQUIRE_MINOR  (1 << 2)
1413ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define LL_EXPORTS	  (1 << 3)
1414ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define LL_DELAY_LOAD	  (1 << 4)
1415ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define LL_DELTA	  (1 << 5)
1416ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1417ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Entries found in sections of type SHT_MIPS_CONFLICT.  */
1418ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1419ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef Elf32_Addr Elf32_Conflict;
1420ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1421ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1422ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* HPPA specific definitions.  */
1423ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1424ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for e_flags field of Elf32_Ehdr.  */
1425ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1426ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_PARISC_TRAPNL	1	/* Trap nil pointer dereference.  */
1427ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_PARISC_EXT		2	/* Program uses arch. extensions.  */
1428ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_PARISC_ARCH		0xffff0000 /* Architecture version.  */
1429ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Defined values are:
1430ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown				0x020b	PA-RISC 1.0 big-endian
1431ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown				0x0210	PA-RISC 1.1 big-endian
1432ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown				0x028b	PA-RISC 1.0 little-endian
1433ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown				0x0290	PA-RISC 1.1 little-endian
1434ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown*/
1435ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1436ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for sh_type field of Elf32_Shdr.  */
1437ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1438ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_PARISC_GOT		0x70000000 /* GOT for external data.  */
1439ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_PARISC_ARCH		0x70000001 /* Architecture extensions.  */
1440ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_PARISC_GLOBAL	0x70000002 /* Definition of $global$.  */
1441ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_PARISC_MILLI	0x70000003 /* Millicode routines.  */
1442ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_PARISC_UNWIND	0x70000004 /* Unwind information.  */
1443ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_PARISC_PLT		0x70000005 /* Procedure linkage table.  */
1444ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_PARISC_SDATA	0x70000006 /* Short initialized data.  */
1445ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_PARISC_SBSS		0x70000007 /* Short uninitialized data.  */
1446ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_PARISC_SYMEXTN	0x70000008 /* Argument/relocation info.  */
1447ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_PARISC_STUBS	0x70000009 /* Linker stubs.  */
1448ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1449ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for sh_flags field of Elf32_Shdr.  */
1450ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1451ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHF_PARISC_GLOBAL	0x10000000 /* Section defines dp.  */
1452ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHF_PARISC_SHORT	0x20000000 /* Section with short addressing. */
1453ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1454ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for ST_TYPE subfield of st_info (symbol type).  */
1455ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1456ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STT_PARISC_MILLICODE	13	/* Millicode function entry point.  */
1457ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1458ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* HPPA relocs.  */
1459ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1460ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PARISC_NONE		0	/* No reloc.  */
1461ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PARISC_DIR32		1	/* Direct 32-bit reference.  */
1462ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PARISC_DIR21L		2	/* Left 21 bits of eff. address.  */
1463ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PARISC_DIR17R		3	/* Right 17 bits of eff. address.  */
1464ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PARISC_DIR14R		4	/* Right 14 bits of eff. address.  */
1465ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PARISC_PCREL21L	5	/* PC-relative, left 21 bits.  */
1466ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PARISC_PCREL14R	6	/* PC-relative, right 14 bits.  */
1467ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PARISC_PCREL17C	7	/* Conditional PC-relative, ignore
1468ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   if displacement > 17bits.  */
1469ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PARISC_PCREL17F	8	/* Conditional PC-relative, must
1470ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   fit in 17bits.  */
1471ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PARISC_DPREL21L	9	/* DP-relative, left 21 bits.  */
1472ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PARISC_DPREL14R	10	/* DP-relative, right 14 bits.  */
1473ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PARISC_DPREL14F	11	/* DP-relative, must bit in 14 bits. */
1474ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PARISC_DLTREL21L	12	/* DLT-relative, left 21 bits.  */
1475ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PARISC_DLTREL14R	13	/* DLT-relative, right 14 bits.  */
1476ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PARISC_DLTREL14F	14	/* DLT-relative, must fit in 14 bits.*/
1477ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PARISC_DLTIND21L	15	/* DLT-relative indirect, left
1478ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   21 bits.  */
1479ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PARISC_DLTIND14R	16	/* DLT-relative indirect, right
1480ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   14 bits.  */
1481ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PARISC_DLTIND14F	17	/* DLT-relative indirect, must fit
1482ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   int 14 bits.  */
1483ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PARISC_PLABEL32	18	/* Direct 32-bit reference to proc.  */
1484ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1485ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Alpha specific definitions.  */
1486ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1487ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for e_flags field of Elf64_Ehdr.  */
1488ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1489ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_ALPHA_32BIT		1	/* All addresses must be < 2GB.  */
1490ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_ALPHA_CANRELAX	2	/* Relocations for relaxing exist.  */
1491ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1492ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for sh_type field of Elf64_Shdr.  */
1493ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1494ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* These two are primerily concerned with ECOFF debugging info.  */
1495ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_ALPHA_DEBUG		0x70000001
1496ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHT_ALPHA_REGINFO	0x70000002
1497ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1498ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for sh_flags field of Elf64_Shdr.  */
1499ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1500ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHF_ALPHA_GPREL		0x10000000
1501ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1502ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Legal values for st_other field of Elf64_Sym.  */
1503ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STO_ALPHA_NOPV		0x80	/* No PV required.  */
1504ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STO_ALPHA_STD_GPLOAD	0x88	/* PV only used for initial ldgp.  */
1505ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1506ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Alpha relocs.  */
1507ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1508ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_NONE		0	/* No reloc */
1509ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_REFLONG		1	/* Direct 32 bit */
1510ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_REFQUAD		2	/* Direct 64 bit */
1511ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_GPREL32		3	/* GP relative 32 bit */
1512ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_LITERAL		4	/* GP relative 16 bit w/optimization */
1513ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_LITUSE		5	/* Optimization hint for LITERAL */
1514ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_GPDISP		6	/* Add displacement to GP */
1515ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_BRADDR		7	/* PC+4 relative 23 bit shifted */
1516ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_HINT		8	/* PC+4 relative 16 bit shifted */
1517ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_SREL16		9	/* PC relative 16 bit */
1518ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_SREL32		10	/* PC relative 32 bit */
1519ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_SREL64		11	/* PC relative 64 bit */
1520ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_OP_PUSH		12	/* OP stack push */
1521ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_OP_STORE	13	/* OP stack pop and store */
1522ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_OP_PSUB		14	/* OP stack subtract */
1523ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_OP_PRSHIFT	15	/* OP stack right shift */
1524ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_GPVALUE		16
1525ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_GPRELHIGH	17
1526ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_GPRELLOW	18
1527ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_IMMED_GP_16	19
1528ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_IMMED_GP_HI32	20
1529ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_IMMED_SCN_HI32	21
1530ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_IMMED_BR_HI32	22
1531ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_IMMED_LO32	23
1532ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_COPY		24	/* Copy symbol at runtime */
1533ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_GLOB_DAT	25	/* Create GOT entry */
1534ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_JMP_SLOT	26	/* Create PLT entry */
1535ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_RELATIVE	27	/* Adjust by program base */
1536ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Keep this the last entry.  */
1537ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ALPHA_NUM		28
1538ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1539ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1540ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* PowerPC specific declarations */
1541ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1542ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* PowerPC relocations defined by the ABIs */
1543ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_NONE		0
1544ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_ADDR32		1	/* 32bit absolute address */
1545ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_ADDR24		2	/* 26bit address, 2 bits ignored.  */
1546ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_ADDR16		3	/* 16bit absolute address */
1547ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_ADDR16_LO		4	/* lower 16bit of absolute address */
1548ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_ADDR16_HI		5	/* high 16bit of absolute address */
1549ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_ADDR16_HA		6	/* adjusted high 16bit */
1550ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_ADDR14		7	/* 16bit address, 2 bits ignored */
1551ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_ADDR14_BRTAKEN	8
1552ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_ADDR14_BRNTAKEN	9
1553ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_REL24		10	/* PC relative 26 bit */
1554ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_REL14		11	/* PC relative 16 bit */
1555ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_REL14_BRTAKEN	12
1556ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_REL14_BRNTAKEN	13
1557ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_GOT16		14
1558ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_GOT16_LO		15
1559ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_GOT16_HI		16
1560ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_GOT16_HA		17
1561ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_PLTREL24		18
1562ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_COPY		19
1563ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_GLOB_DAT		20
1564ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_JMP_SLOT		21
1565ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_RELATIVE		22
1566ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_LOCAL24PC		23
1567ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_UADDR32		24
1568ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_UADDR16		25
1569ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_REL32		26
1570ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_PLT32		27
1571ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_PLTREL32		28
1572ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_PLT16_LO		29
1573ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_PLT16_HI		30
1574ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_PLT16_HA		31
1575ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_SDAREL16		32
1576ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_SECTOFF		33
1577ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_SECTOFF_LO	34
1578ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_SECTOFF_HI	35
1579ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_SECTOFF_HA	36
1580ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Keep this the last entry.  */
1581ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_NUMm		37
1582ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1583ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* The remaining relocs are from the Embedded ELF ABI, and are not
1584ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   in the SVR4 ELF ABI.  */
1585ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_EMB_NADDR32	101
1586ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_EMB_NADDR16	102
1587ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_EMB_NADDR16_LO	103
1588ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_EMB_NADDR16_HI	104
1589ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_EMB_NADDR16_HA	105
1590ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_EMB_SDAI16	106
1591ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_EMB_SDA2I16	107
1592ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_EMB_SDA2REL	108
1593ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_EMB_SDA21		109	/* 16 bit offset in SDA */
1594ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_EMB_MRKREF	110
1595ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_EMB_RELSEC16	111
1596ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_EMB_RELST_LO	112
1597ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_EMB_RELST_HI	113
1598ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_EMB_RELST_HA	114
1599ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_EMB_BIT_FLD	115
1600ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_EMB_RELSDA	116	/* 16 bit relative offset in SDA */
1601ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1602ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Diab tool relocations.  */
1603ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_DIAB_SDA21_LO	180	/* like EMB_SDA21, but lower 16 bit */
1604ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_DIAB_SDA21_HI	181	/* like EMB_SDA21, but high 16 bit */
1605ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_DIAB_SDA21_HA	182	/* like EMB_SDA21, adjusted high 16 */
1606ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_DIAB_RELSDA_LO	183	/* like EMB_RELSDA, but lower 16 bit */
1607ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_DIAB_RELSDA_HI	184	/* like EMB_RELSDA, but high 16 bit */
1608ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_DIAB_RELSDA_HA	185	/* like EMB_RELSDA, adjusted high 16 */
1609ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1610ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* This is a phony reloc to handle any old fashioned TOC16 references
1611ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   that may still be in object files.  */
1612ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_PPC_TOC16		255
1613ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1614ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1615ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ARM specific declarations */
1616ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1617ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Processor specific flags for the ELF header e_flags field.  */
1618ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_ARM_RELEXEC     0x01
1619ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_ARM_HASENTRY    0x02
1620ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_ARM_INTERWORK   0x04
1621ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_ARM_APCS_26     0x08
1622ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_ARM_APCS_FLOAT  0x10
1623ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_ARM_PIC         0x20
1624ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_ALIGN8          0x40		/* 8-bit structure alignment is in use */
1625ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_NEW_ABI         0x80
1626ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define EF_OLD_ABI         0x100
1627ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1628ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Additional symbol types for Thumb */
1629ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STT_ARM_TFUNC      0xd
1630ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1631ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ARM-specific values for sh_flags */
1632ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHF_ARM_ENTRYSECT  0x10000000   /* Section contains an entry point */
1633ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHF_ARM_COMDEF     0x80000000   /* Section may be multiply defined
1634ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   in the input to a link step */
1635ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1636ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ARM-specific program header flags */
1637ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PF_ARM_SB          0x10000000   /* Segment contains the location
1638ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown					   addressed by the static base */
1639ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1640ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ARM relocs.  */
1641ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_NONE		0	/* No reloc */
1642ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_PC24		1	/* PC relative 26 bit branch */
1643ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_ABS32		2	/* Direct 32 bit  */
1644ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_REL32		3	/* PC relative 32 bit */
1645ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_PC13		4
1646ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_ABS16		5	/* Direct 16 bit */
1647ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_ABS12		6	/* Direct 12 bit */
1648ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_THM_ABS5		7
1649ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_ABS8		8	/* Direct 8 bit */
1650ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_SBREL32		9
1651ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_THM_PC22		10
1652ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_THM_PC8		11
1653ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_AMP_VCALL9	12
1654ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_SWI24		13
1655ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_THM_SWI8		14
1656ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_XPC25		15
1657ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_THM_XPC22		16
1658ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_COPY		20	/* Copy symbol at runtime */
1659ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_GLOB_DAT		21	/* Create GOT entry */
1660ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_JUMP_SLOT		22	/* Create PLT entry */
1661ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_RELATIVE		23	/* Adjust by program base */
1662ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_GOTOFF		24	/* 32 bit offset to GOT */
1663ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_GOTPC		25	/* 32 bit PC relative offset to GOT */
1664ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_GOT32		26	/* 32 bit GOT entry */
1665ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_PLT32		27	/* 32 bit PLT address */
1666ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_GNU_VTENTRY	100
1667ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_GNU_VTINHERIT	101
1668ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_THM_PC11		102	/* thumb unconditional branch */
1669ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_THM_PC9		103	/* thumb conditional branch */
1670ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_RXPC25		249
1671ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_RSBREL32		250
1672ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_THM_RPC22		251
1673ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_RREL32		252
1674ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_RABS22		253
1675ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_RPC24		254
1676ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_RBASE		255
1677ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Keep this the last entry.  */
1678ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_ARM_NUM		256
1679ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1680ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* TMS320C67xx specific declarations */
1681ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* XXX: no ELF standard yet */
1682ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1683ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* TMS320C67xx relocs. */
1684ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_C60_32       1
1685ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_C60_GOT32	3		/* 32 bit GOT entry */
1686ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_C60_PLT32	4		/* 32 bit PLT address */
1687ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_C60_COPY	5		/* Copy symbol at runtime */
1688ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_C60_GLOB_DAT	6		/* Create GOT entry */
1689ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_C60_JMP_SLOT	7		/* Create PLT entry */
1690ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_C60_RELATIVE	8		/* Adjust by program base */
1691ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_C60_GOTOFF	9		/* 32 bit offset to GOT */
1692ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_C60_GOTPC	10		/* 32 bit PC relative offset to GOT */
1693ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1694ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_C60HI16      0x55       // high 16 bit MVKH embedded
1695ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define R_C60LO16      0x54       // low 16 bit MVKL embedded
1696ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1697ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#endif	/* elf.h */
1698ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//---------------------------------------------------------------------------
1699ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1700ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1701ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown// njn: inlined stab.h
1702ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//#include "stab.h"
1703ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//---------------------------------------------------------------------------
1704ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#ifndef __GNU_STAB__
1705ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1706ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Indicate the GNU stab.h is in use.  */
1707ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1708ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define __GNU_STAB__
1709ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1710ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define __define_stab(NAME, CODE, STRING) NAME=CODE,
1711ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1712ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownenum __stab_debug_code
1713ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{
1714ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown// njn: inlined stab.def
1715ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//#include "stab.def"
1716ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//---------------------------------------------------------------------------
1717ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Table of DBX symbol codes for the GNU system.
1718ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   Copyright (C) 1988, 1997 Free Software Foundation, Inc.
1719ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   This file is part of the GNU C Library.
1720ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1721ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   The GNU C Library is free software; you can redistribute it and/or
1722ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   modify it under the terms of the GNU Library General Public License as
1723ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   published by the Free Software Foundation; either version 2 of the
1724ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   License, or (at your option) any later version.
1725ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1726ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   The GNU C Library is distributed in the hope that it will be useful,
1727ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   but WITHOUT ANY WARRANTY; without even the implied warranty of
1728ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1729ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   Library General Public License for more details.
1730ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1731ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   You should have received a copy of the GNU Library General Public
1732ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   License along with the GNU C Library; see the file COPYING.LIB.  If not,
1733ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1734ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   Boston, MA 02111-1307, USA.  */
1735ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1736ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* This contains contribution from Cygnus Support.  */
1737ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1738ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Global variable.  Only the name is significant.
1739ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   To find the address, look in the corresponding external symbol.  */
1740ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_GSYM, 0x20, "GSYM")
1741ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1742ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Function name for BSD Fortran.  Only the name is significant.
1743ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   To find the address, look in the corresponding external symbol.  */
1744ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_FNAME, 0x22, "FNAME")
1745ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1746ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Function name or text-segment variable for C.  Value is its address.
1747ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   Desc is supposedly starting line number, but GCC doesn't set it
1748ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   and DBX seems not to miss it.  */
1749ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_FUN, 0x24, "FUN")
1750ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1751ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Data-segment variable with internal linkage.  Value is its address.
1752ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   "Static Sym".  */
1753ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_STSYM, 0x26, "STSYM")
1754ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1755ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* BSS-segment variable with internal linkage.  Value is its address.  */
1756ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_LCSYM, 0x28, "LCSYM")
1757ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1758ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Name of main routine.  Only the name is significant.
1759ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   This is not used in C.  */
1760ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_MAIN, 0x2a, "MAIN")
1761ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1762ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Global symbol in Pascal.
1763ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   Supposedly the value is its line number; I'm skeptical.  */
1764ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_PC, 0x30, "PC")
1765ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1766ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Number of symbols:  0, files,,funcs,lines according to Ultrix V4.0. */
1767ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_NSYMS, 0x32, "NSYMS")
1768ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1769ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* "No DST map for sym: name, ,0,type,ignored"  according to Ultrix V4.0. */
1770ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_NOMAP, 0x34, "NOMAP")
1771ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1772ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* New stab from Solaris.  I don't know what it means, but it
1773ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   don't seem to contain useful information.  */
1774ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_OBJ, 0x38, "OBJ")
1775ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1776ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* New stab from Solaris.  I don't know what it means, but it
1777ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   don't seem to contain useful information.  Possibly related to the
1778ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   optimization flags used in this module.  */
1779ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_OPT, 0x3c, "OPT")
1780ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1781ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Register variable.  Value is number of register.  */
1782ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_RSYM, 0x40, "RSYM")
1783ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1784ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Modula-2 compilation unit.  Can someone say what info it contains?  */
1785ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_M2C, 0x42, "M2C")
1786ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1787ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Line number in text segment.  Desc is the line number;
1788ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   value is corresponding address.  */
1789ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_SLINE, 0x44, "SLINE")
1790ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1791ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Similar, for data segment.  */
1792ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_DSLINE, 0x46, "DSLINE")
1793ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1794ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Similar, for bss segment.  */
1795ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_BSLINE, 0x48, "BSLINE")
1796ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1797ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Sun's source-code browser stabs.  ?? Don't know what the fields are.
1798ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   Supposedly the field is "path to associated .cb file".  THIS VALUE
1799ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   OVERLAPS WITH N_BSLINE!  */
1800ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_BROWS, 0x48, "BROWS")
1801ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1802ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* GNU Modula-2 definition module dependency.  Value is the modification time
1803ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   of the definition file.  Other is non-zero if it is imported with the
1804ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   GNU M2 keyword %INITIALIZE.  Perhaps N_M2C can be used if there
1805ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   are enough empty fields? */
1806ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab(N_DEFD, 0x4a, "DEFD")
1807ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1808ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* THE FOLLOWING TWO STAB VALUES CONFLICT.  Happily, one is for Modula-2
1809ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   and one is for C++.   Still,... */
1810ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* GNU C++ exception variable.  Name is variable name.  */
1811ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_EHDECL, 0x50, "EHDECL")
1812ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Modula2 info "for imc":  name,,0,0,0  according to Ultrix V4.0.  */
1813ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_MOD2, 0x50, "MOD2")
1814ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1815ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* GNU C++ `catch' clause.  Value is its address.  Desc is nonzero if
1816ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   this entry is immediately followed by a CAUGHT stab saying what exception
1817ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   was caught.  Multiple CAUGHT stabs means that multiple exceptions
1818ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   can be caught here.  If Desc is 0, it means all exceptions are caught
1819ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   here.  */
1820ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_CATCH, 0x54, "CATCH")
1821ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1822ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Structure or union element.  Value is offset in the structure.  */
1823ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_SSYM, 0x60, "SSYM")
1824ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1825ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Name of main source file.
1826ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   Value is starting text address of the compilation.  */
1827ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_SO, 0x64, "SO")
1828ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1829ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Automatic variable in the stack.  Value is offset from frame pointer.
1830ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   Also used for type descriptions.  */
1831ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_LSYM, 0x80, "LSYM")
1832ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1833ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Beginning of an include file.  Only Sun uses this.
1834ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   In an object file, only the name is significant.
1835ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   The Sun linker puts data into some of the other fields.  */
1836ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_BINCL, 0x82, "BINCL")
1837ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1838ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Name of sub-source file (#include file).
1839ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   Value is starting text address of the compilation.  */
1840ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_SOL, 0x84, "SOL")
1841ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1842ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Parameter variable.  Value is offset from argument pointer.
1843ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   (On most machines the argument pointer is the same as the frame pointer.  */
1844ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_PSYM, 0xa0, "PSYM")
1845ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1846ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* End of an include file.  No name.
1847ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   This and N_BINCL act as brackets around the file's output.
1848ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   In an object file, there is no significant data in this entry.
1849ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   The Sun linker puts data into some of the fields.  */
1850ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_EINCL, 0xa2, "EINCL")
1851ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1852ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Alternate entry point.  Value is its address.  */
1853ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_ENTRY, 0xa4, "ENTRY")
1854ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1855ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Beginning of lexical block.
1856ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   The desc is the nesting level in lexical blocks.
1857ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   The value is the address of the start of the text for the block.
1858ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   The variables declared inside the block *precede* the N_LBRAC symbol.  */
1859ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_LBRAC, 0xc0, "LBRAC")
1860ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1861ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Place holder for deleted include file.  Replaces a N_BINCL and everything
1862ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   up to the corresponding N_EINCL.  The Sun linker generates these when
1863ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   it finds multiple identical copies of the symbols from an include file.
1864ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   This appears only in output from the Sun linker.  */
1865ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_EXCL, 0xc2, "EXCL")
1866ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1867ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Modula-2 scope information.  Can someone say what info it contains?  */
1868ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_SCOPE, 0xc4, "SCOPE")
1869ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1870ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* End of a lexical block.  Desc matches the N_LBRAC's desc.
1871ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   The value is the address of the end of the text for the block.  */
1872ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_RBRAC, 0xe0, "RBRAC")
1873ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1874ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Begin named common block.  Only the name is significant.  */
1875ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_BCOMM, 0xe2, "BCOMM")
1876ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1877ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* End named common block.  Only the name is significant
1878ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   (and it should match the N_BCOMM).  */
1879ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_ECOMM, 0xe4, "ECOMM")
1880ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1881ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* End common (local name): value is address.
1882ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   I'm not sure how this is used.  */
1883ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_ECOML, 0xe8, "ECOML")
1884ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1885ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* These STAB's are used on Gould systems for Non-Base register symbols
1886ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   or something like that.  FIXME.  I have assigned the values at random
1887ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   since I don't have a Gould here.  Fixups from Gould folk welcome... */
1888ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_NBTEXT, 0xF0, "NBTEXT")
1889ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_NBDATA, 0xF2, "NBDATA")
1890ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_NBBSS,  0xF4, "NBBSS")
1891ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_NBSTS,  0xF6, "NBSTS")
1892ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_NBLCS,  0xF8, "NBLCS")
1893ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1894ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Second symbol entry containing a length-value for the preceding entry.
1895ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   The value is the length.  */
1896ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown__define_stab (N_LENG, 0xfe, "LENG")
1897ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1898ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* The above information, in matrix format.
1899ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1900ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown			STAB MATRIX
1901ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	_________________________________________________
1902ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 00 - 1F are not dbx stab symbols		|
1903ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| In most cases, the low bit is the EXTernal bit|
1904ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1905ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 00 UNDEF  | 02 ABS	| 04 TEXT   | 06 DATA	|
1906ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 01  |EXT  | 03  |EXT	| 05  |EXT  | 07  |EXT	|
1907ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1908ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 08 BSS    | 0A INDR	| 0C FN_SEQ | 0E   	|
1909ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 09  |EXT  | 0B 	| 0D	    | 0F	|
1910ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1911ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 10 	    | 12 COMM	| 14 SETA   | 16 SETT	|
1912ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 11	    | 13	| 15 	    | 17	|
1913ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1914ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 18 SETD   | 1A SETB	| 1C SETV   | 1E WARNING|
1915ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 19	    | 1B	| 1D 	    | 1F FN	|
1916ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1917ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	|_______________________________________________|
1918ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| Debug entries with bit 01 set are unused.	|
1919ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 20 GSYM   | 22 FNAME	| 24 FUN    | 26 STSYM	|
1920ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 28 LCSYM  | 2A MAIN	| 2C	    | 2E	|
1921ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 30 PC	    | 32 NSYMS	| 34 NOMAP  | 36	|
1922ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 38 OBJ    | 3A	| 3C OPT    | 3E	|
1923ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 40 RSYM   | 42 M2C	| 44 SLINE  | 46 DSLINE |
1924ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 48 BSLINE*| 4A DEFD	| 4C        | 4E	|
1925ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 50 EHDECL*| 52	| 54 CATCH  | 56        |
1926ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 58        | 5A        | 5C        | 5E	|
1927ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 60 SSYM   | 62	| 64 SO	    | 66 	|
1928ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 68 	    | 6A	| 6C	    | 6E	|
1929ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 70	    | 72	| 74	    | 76	|
1930ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 78	    | 7A	| 7C	    | 7E	|
1931ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 80 LSYM   | 82 BINCL	| 84 SOL    | 86	|
1932ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 88	    | 8A	| 8C	    | 8E	|
1933ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 90	    | 92	| 94	    | 96	|
1934ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| 98	    | 9A	| 9C	    | 9E	|
1935ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| A0 PSYM   | A2 EINCL	| A4 ENTRY  | A6	|
1936ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| A8	    | AA	| AC	    | AE	|
1937ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| B0	    | B2	| B4	    | B6	|
1938ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| B8	    | BA	| BC	    | BE	|
1939ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| C0 LBRAC  | C2 EXCL	| C4 SCOPE  | C6	|
1940ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| C8	    | CA	| CC	    | CE	|
1941ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| D0	    | D2	| D4	    | D6	|
1942ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| D8	    | DA	| DC	    | DE	|
1943ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| E0 RBRAC  | E2 BCOMM	| E4 ECOMM  | E6	|
1944ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| E8 ECOML  | EA	| EC	    | EE	|
1945ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| F0	    | F2	| F4	    | F6	|
1946ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	| F8	    | FA	| FC	    | FE LENG	|
1947ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown	+-----------------------------------------------+
1948ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown * 50 EHDECL is also MOD2.
1949ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown * 48 BSLINE is also BROWS.
1950ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown */
1951ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//---------------------------------------------------------------------------
1952ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownLAST_UNUSED_STAB_CODE
1953ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown};
1954ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1955ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#undef __define_stab
1956ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1957ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#endif /* __GNU_STAB_ */
1958ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//---------------------------------------------------------------------------
1959ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1960ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#ifndef O_BINARY
1961ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define O_BINARY 0
1962ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#endif
1963ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1964ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown// njn: inlined libtcc.h
1965ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//#include "libtcc.h"
1966ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//---------------------------------------------------------------------------
1967ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#ifndef LIBTCC_H
1968ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define LIBTCC_H
1969ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1970ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#ifdef __cplusplus
1971ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownextern "C" {
1972ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#endif
1973ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1974ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstruct TCCState;
1975ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1976ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct TCCState TCCState;
1977ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1978ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* create a new TCC compilation context */
1979ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownTCCState *tcc_new(void);
1980ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1981ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* free a TCC compilation context */
1982ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownvoid tcc_delete(TCCState *s);
1983ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1984ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* add debug information in the generated code */
1985ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownvoid tcc_enable_debug(TCCState *s);
1986ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1987ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* set error/warning display callback */
1988ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownvoid tcc_set_error_func(TCCState *s, void *error_opaque,
1989ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown                        void (*error_func)(void *opaque, const char *msg));
1990ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1991ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* set/reset a warning */
1992ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownint tcc_set_warning(TCCState *s, const char *warning_name, int value);
1993ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1994ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/*****************************/
1995ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* preprocessor */
1996ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
1997ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* add include path */
1998ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownint tcc_add_include_path(TCCState *s, const char *pathname);
1999ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2000ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* add in system include path */
2001ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownint tcc_add_sysinclude_path(TCCState *s, const char *pathname);
2002ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2003ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* define preprocessor symbol 'sym'. Can put optional value */
2004ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownvoid tcc_define_symbol(TCCState *s, const char *sym, const char *value);
2005ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2006ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* undefine preprocess symbol 'sym' */
2007ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownvoid tcc_undefine_symbol(TCCState *s, const char *sym);
2008ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2009ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/*****************************/
2010ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* compiling */
2011ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2012ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* add a file (either a C file, dll, an object, a library or an ld
2013ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   script). Return -1 if error. */
2014ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownint tcc_add_file(TCCState *s, const char *filename);
2015ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2016ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* compile a string containing a C source. Return non zero if
2017ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   error. */
2018ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownint tcc_compile_string(TCCState *s, const char *buf);
2019ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2020ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/*****************************/
2021ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* linking commands */
2022ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2023ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* set output type. MUST BE CALLED before any compilation */
2024ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define TCC_OUTPUT_MEMORY   0 /* output will be ran in memory (no
2025ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown                                 output file) (default) */
2026ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define TCC_OUTPUT_EXE      1 /* executable file */
2027ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define TCC_OUTPUT_DLL      2 /* dynamic library */
2028ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define TCC_OUTPUT_OBJ      3 /* object file */
2029ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownint tcc_set_output_type(TCCState *s, int output_type);
2030ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2031ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define TCC_OUTPUT_FORMAT_ELF    0 /* default output format: ELF */
2032ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define TCC_OUTPUT_FORMAT_BINARY 1 /* binary image output */
2033ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define TCC_OUTPUT_FORMAT_COFF   2 /* COFF */
2034ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2035ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* equivalent to -Lpath option */
2036ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownint tcc_add_library_path(TCCState *s, const char *pathname);
2037ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2038ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* the library name is the same as the argument of the '-l' option */
2039ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownint tcc_add_library(TCCState *s, const char *libraryname);
2040ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2041ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* add a symbol to the compiled program */
2042ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownint tcc_add_symbol(TCCState *s, const char *name, unsigned long val);
2043ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2044ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* output an executable, library or object file. DO NOT call
2045ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   tcc_relocate() before. */
2046ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownint tcc_output_file(TCCState *s, const char *filename);
2047ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2048ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* link and run main() function and return its value. DO NOT call
2049ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   tcc_relocate() before. */
2050ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownint tcc_run(TCCState *s, int argc, char **argv);
2051ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2052ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* do all relocations (needed before using tcc_get_symbol()). Return
2053ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   non zero if link error. */
2054ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownint tcc_relocate(TCCState *s);
2055ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2056ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* return symbol value. return 0 if OK, -1 if symbol not found */
2057ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownint tcc_get_symbol(TCCState *s, unsigned long *pval, const char *name);
2058ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2059ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#ifdef __cplusplus
2060ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown}
2061ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#endif
2062ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2063ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#endif
2064ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//---------------------------------------------------------------------------
2065ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2066ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* parser debug */
2067ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//#define PARSE_DEBUG
2068ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* preprocessor debug */
2069ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//#define PP_DEBUG
2070ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* include file debug */
2071ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//#define INC_DEBUG
2072ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2073ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//#define MEM_DEBUG
2074ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2075ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* assembler debug */
2076ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//#define ASM_DEBUG
2077ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2078ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* target selection */
2079ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//#define TCC_TARGET_I386   /* i386 code generator */
2080ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//#define TCC_TARGET_ARM    /* ARMv4 code generator */
2081ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown//#define TCC_TARGET_C67    /* TMS320C67xx code generator */
2082ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2083ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* default target is I386 */
2084ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#if !defined(TCC_TARGET_I386) && !defined(TCC_TARGET_ARM) && \
2085ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    !defined(TCC_TARGET_C67)
2086ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define TCC_TARGET_I386
2087ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#endif
2088ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2089ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#if !defined(WIN32) && !defined(TCC_UCLIBC) && !defined(TCC_TARGET_ARM) && \
2090ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    !defined(TCC_TARGET_C67)
2091ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define CONFIG_TCC_BCHECK /* enable bound checking code */
2092ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#endif
2093ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2094ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#if defined(WIN32) && !defined(TCC_TARGET_PE)
2095ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define CONFIG_TCC_STATIC
2096ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#endif
2097ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2098ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* define it to include assembler support */
2099ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#if !defined(TCC_TARGET_ARM) && !defined(TCC_TARGET_C67)
2100ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define CONFIG_TCC_ASM
2101ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#endif
2102ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2103ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* object format selection */
2104ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#if defined(TCC_TARGET_C67)
2105ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define TCC_TARGET_COFF
2106ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#endif
2107ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2108ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define FALSE 0
2109ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define false 0
2110ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define TRUE 1
2111ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define true 1
2112ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef int BOOL;
2113ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2114ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* path to find crt1.o, crti.o and crtn.o. Only needed when generating
2115ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   executables or dlls */
2116ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define CONFIG_TCC_CRT_PREFIX "/usr/lib"
2117ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2118ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define INCLUDE_STACK_SIZE  32
2119ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define IFDEF_STACK_SIZE    64
2120ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define VSTACK_SIZE         256
2121ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define STRING_MAX_SIZE     1024
2122ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PACK_STACK_SIZE     8
2123ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2124ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define TOK_HASH_SIZE       8192 /* must be a power of two */
2125ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define TOK_ALLOC_INCR      512  /* must be a power of two */
2126ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define TOK_MAX_SIZE        4 /* token max size in int unit when stored in string */
2127ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2128ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* token symbol management */
2129ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct TokenSym {
2130ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    struct TokenSym *hash_next;
2131ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    struct Sym *sym_define; /* direct pointer to define */
2132ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    struct Sym *sym_label; /* direct pointer to label */
2133ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    struct Sym *sym_struct; /* direct pointer to structure */
2134ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    struct Sym *sym_identifier; /* direct pointer to identifier */
2135ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int tok; /* token number */
2136ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int len;
2137ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    char str[1];
2138ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} TokenSym;
2139ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2140ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct CString {
2141ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int size; /* size in bytes */
2142ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    void *data; /* either 'char *' or 'int *' */
2143ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int size_allocated;
2144ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    void *data_allocated; /* if non NULL, data has been malloced */
2145ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} CString;
2146ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2147ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* type definition */
2148ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct CType {
2149ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int t;
2150ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    struct Sym *ref;
2151ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} CType;
2152ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2153ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* constant value */
2154ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef union CValue {
2155ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    long double ld;
2156ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    double d;
2157ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    float f;
2158ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int i;
2159ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    unsigned int ui;
2160ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    unsigned int ul; /* address (should be unsigned long on 64 bit cpu) */
2161ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    long long ll;
2162ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    unsigned long long ull;
2163ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    struct CString *cstr;
2164ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    void *ptr;
2165b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov    int tab[sizeof(long double) / sizeof(int)];
2166ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} CValue;
2167ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2168ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* value on stack */
2169ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct SValue {
2170ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    CType type;      /* type */
2171ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    unsigned short r;      /* register + flags */
2172ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    unsigned short r2;     /* second register, used for 'long long'
2173ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown                              type. If not used, set to VT_CONST */
2174ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    CValue c;              /* constant, if VT_CONST */
2175ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    struct Sym *sym;       /* symbol, if (VT_SYM | VT_CONST) */
2176ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} SValue;
2177ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2178ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* symbol management */
2179ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct Sym {
2180ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    long v;    /* symbol token */
2181ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    long r;    /* associated register */
2182ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    long c;    /* associated number */
2183ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    CType type;    /* associated type */
2184ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    struct Sym *next; /* next related symbol */
2185ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    struct Sym *prev; /* prev symbol in stack */
2186ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    struct Sym *prev_tok; /* previous symbol for this token */
2187ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Sym;
2188ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2189ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* section definition */
2190ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* XXX: use directly ELF structure for parameters ? */
2191ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* special flag to indicate that the section should not be linked to
2192ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   the other ones */
2193ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SHF_PRIVATE 0x80000000
2194ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2195ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct Section {
2196ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    unsigned long data_offset; /* current data offset */
2197ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    unsigned char *data;       /* section data */
2198ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    unsigned long data_allocated; /* used for realloc() handling */
2199ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int sh_name;             /* elf section name (only used during output) */
2200ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int sh_num;              /* elf section number */
2201ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int sh_type;             /* elf section type */
2202ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int sh_flags;            /* elf section flags */
2203ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int sh_info;             /* elf section info */
2204ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int sh_addralign;        /* elf section alignment */
2205ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int sh_entsize;          /* elf entry size */
2206ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    unsigned long sh_size;   /* section size (only used during output) */
2207ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    unsigned long sh_addr;      /* address at which the section is relocated */
2208ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    unsigned long sh_offset;      /* address at which the section is relocated */
2209ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int nb_hashed_syms;      /* used to resize the hash table */
2210ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    struct Section *link;    /* link to another section */
2211ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    struct Section *reloc;   /* corresponding section for relocation, if any */
2212ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    struct Section *hash;     /* hash table for symbols */
2213ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    struct Section *next;
2214ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    char name[1];           /* section name */
2215ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} Section;
2216ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2217ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct DLLReference {
2218ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int level;
2219ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    char name[1];
2220ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} DLLReference;
2221ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2222ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* GNUC attribute definition */
2223ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct AttributeDef {
2224ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int aligned;
2225ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int packed;
2226ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    Section *section;
2227ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    unsigned char func_call; /* FUNC_CDECL, FUNC_STDCALL, FUNC_FASTCALLx */
2228ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    unsigned char dllexport;
2229ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} AttributeDef;
2230ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2231ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SYM_STRUCT     0x40000000 /* struct/union/enum symbol space */
2232ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SYM_FIELD      0x20000000 /* struct/union field symbol space */
2233ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define SYM_FIRST_ANOM 0x10000000 /* first anonymous sym */
2234ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2235ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* stored in 'Sym.c' field */
2236ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define FUNC_NEW       1 /* ansi function prototype */
2237ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define FUNC_OLD       2 /* old function prototype */
2238ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define FUNC_ELLIPSIS  3 /* ansi function prototype with ... */
2239ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2240ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* stored in 'Sym.r' field */
2241ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define FUNC_CDECL     0 /* standard c call */
2242ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define FUNC_STDCALL   1 /* pascal c call */
2243ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define FUNC_FASTCALL1 2 /* first param in %eax */
2244ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define FUNC_FASTCALL2 3 /* first parameters in %eax, %edx */
2245ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define FUNC_FASTCALL3 4 /* first parameter in %eax, %edx, %ecx */
2246ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2247ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* field 'Sym.t' for macros */
2248ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define MACRO_OBJ      0 /* object like macro */
2249ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define MACRO_FUNC     1 /* function like macro */
2250ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2251ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* field 'Sym.r' for C labels */
2252ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define LABEL_DEFINED  0 /* label is defined */
2253ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define LABEL_FORWARD  1 /* label is forward defined */
2254ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define LABEL_DECLARED 2 /* label is declared but never used */
2255ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2256ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* type_decl() types */
2257ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define TYPE_ABSTRACT  1 /* type without variable */
2258ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define TYPE_DIRECT    2 /* type with variable */
2259ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2260ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define IO_BUF_SIZE 8192
2261ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2262ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct BufferedFile {
2263ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    uint8_t *buf_ptr;
2264ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    uint8_t *buf_end;
2265ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int fd;
2266ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int line_num;    /* current line number - here to simplify code */
2267ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int ifndef_macro;  /* #ifndef macro / #endif search */
2268ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int ifndef_macro_saved; /* saved ifndef_macro */
2269ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int *ifdef_stack_ptr; /* ifdef_stack value at the start of the file */
2270ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    char inc_type;          /* type of include */
2271ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    char inc_filename[512]; /* filename specified by the user */
2272ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    char filename[1024];    /* current filename - here to simplify code */
2273ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    unsigned char buffer[IO_BUF_SIZE + 1]; /* extra size for CH_EOB char */
2274ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} BufferedFile;
2275ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2276ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define CH_EOB   '\\'       /* end of buffer or '\0' char in file */
2277ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define CH_EOF   (-1)   /* end of file */
2278ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2279ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* parsing state (used to save parser state to reparse part of the
2280ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   source several times) */
2281ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct ParseState {
2282ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int *macro_ptr;
2283ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int line_num;
2284ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int tok;
2285ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    CValue tokc;
2286ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} ParseState;
2287ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2288ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* used to record tokens */
2289ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct TokenString {
2290ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int *str;
2291ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int len;
2292ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int allocated_len;
2293ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int last_line_num;
2294ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} TokenString;
2295ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2296ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* include file cache, used to find files faster and also to eliminate
2297ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   inclusion if the include file is protected by #ifndef ... #endif */
2298ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Browntypedef struct CachedInclude {
2299ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int ifndef_macro;
2300ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    int hash_next; /* -1 if none */
2301ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    char type; /* '"' or '>' to give include type */
2302ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown    char filename[1]; /* path specified in #include */
2303ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} CachedInclude;
2304ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2305ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define CACHED_INCLUDES_HASH_SIZE 512
2306ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2307ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* parser */
2308ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic struct BufferedFile *file;
2309ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic int ch, tok;
2310ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic CValue tokc;
2311ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic CString tokcstr; /* current parsed string, if any */
2312ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* additional informations about token */
2313ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic int tok_flags;
2314ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define TOK_FLAG_BOL   0x0001 /* beginning of line before */
2315ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define TOK_FLAG_BOF   0x0002 /* beginning of file before */
2316ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define TOK_FLAG_ENDIF 0x0004 /* a endif was found matching starting #ifdef */
2317ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2318ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic int *macro_ptr, *macro_ptr_allocated;
2319ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic int *unget_saved_macro_ptr;
2320ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic int unget_saved_buffer[TOK_MAX_SIZE + 1];
2321ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic int unget_buffer_enabled;
2322ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic int parse_flags;
2323ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PARSE_FLAG_PREPROCESS 0x0001 /* activate preprocessing */
2324ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PARSE_FLAG_TOK_NUM    0x0002 /* return numbers instead of TOK_PPNUM */
2325ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PARSE_FLAG_LINEFEED   0x0004 /* line feed is returned as a
2326ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown                                        token. line feed is also
2327ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown                                        returned at eof */
2328ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#define PARSE_FLAG_ASM_COMMENTS 0x0008 /* '#' can be used for line comment */
2329ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2330ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic Section *text_section, *data_section, *bss_section; /* predefined sections */
2331ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic Section *cur_text_section; /* current section where function code is
2332ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown                              generated */
2333ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#ifdef CONFIG_TCC_ASM
2334ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic Section *last_text_section; /* to handle .previous asm directive */
2335ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#endif
2336ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* bound check related sections */
2337ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic Section *bounds_section; /* contains global data bound description */
2338ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic Section *lbounds_section; /* contains local data bound description */
2339ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* symbol sections */
2340ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic Section *symtab_section, *strtab_section;
2341ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2342ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* debug sections */
2343ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic Section *stab_section, *stabstr_section;
2344ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown
2345ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* loc : local variable index
2346ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   ind : output code index
2347ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   rsym: return symbol
2348ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown   anon_sym: anonymous symbol index
2349ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown*/
2350ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic long rsym, anon_sym, ind, loc;
2351ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* expression generation modifiers */
2352ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic int const_wanted; /* true if constant wanted */
2353ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic int nocode_wanted; /* true if no code generation wanted for an expression */
2354ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic int global_expr;  /* true if compound literals must be allocated
2355ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown                            globally (used during initializers parsing */
2356ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic CType func_vt; /* current function return type (used by return
2357ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown                         instruction) */
2358ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic int func_vc;
2359ed07e00d438c74b7a23c01bfffde77e3968305e4</