OpenCores
URL https://opencores.org/ocsvn/open8_urisc/open8_urisc/trunk

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [gas/] [config/] [aout_gnu.h] - Blame information for rev 128

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 khays
/* This file is aout_gnu.h
2
 
3
   Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 2000, 2002,
4
   2005, 2007 Free Software Foundation, Inc.
5
 
6
   This file is part of GAS, the GNU Assembler.
7
 
8
   GAS is free software; you can redistribute it and/or modify
9
   it under the terms of the GNU General Public License as published by
10
   the Free Software Foundation; either version 3, or (at your option)
11
   any later version.
12
 
13
   GAS is distributed in the hope that it will be useful,
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
   GNU General Public License for more details.
17
 
18
   You should have received a copy of the GNU General Public License
19
   along with GAS; see the file COPYING.  If not, write to
20
   the Free Software Foundation, 51 Franklin Street - Fifth Floor,
21
   Boston, MA 02110-1301, USA.  */
22
 
23
#ifndef __A_OUT_GNU_H__
24
#define __A_OUT_GNU_H__
25
 
26
/* There are two main flavours of a.out, one which uses the standard
27
   relocations, and one which uses extended relocations.
28
 
29
   Today, the extended reloc uses are
30
   TC_SPARC
31
 
32
   each must define the enum reloc_type
33
 
34
*/
35
 
36
#define USE_EXTENDED_RELOC defined(TC_SPARC)
37
 
38
#if defined(TC_SPARC)
39
enum reloc_type
40
  {
41
    RELOC_8, RELOC_16, RELOC_32,/* simple relocations */
42
    RELOC_DISP8, RELOC_DISP16, RELOC_DISP32,    /* pc-rel displacement */
43
    RELOC_WDISP30, RELOC_WDISP22,
44
    RELOC_HI22, RELOC_22,
45
    RELOC_13, RELOC_LO10,
46
    RELOC_SFA_BASE, RELOC_SFA_OFF13,
47
    RELOC_BASE10, RELOC_BASE13, RELOC_BASE22,   /* P.I.C. (base-relative) */
48
    RELOC_PC10, RELOC_PC22,     /* for some sort of pc-rel P.I.C. (?) */
49
    RELOC_JMP_TBL,              /* P.I.C. jump table */
50
    RELOC_SEGOFF16,             /* reputedly for shared libraries somehow */
51
    RELOC_GLOB_DAT, RELOC_JMP_SLOT, RELOC_RELATIVE,
52
    RELOC_10, RELOC_11,
53
    RELOC_WDISP2_14,
54
    RELOC_WDISP19,
55
    RELOC_HHI22,
56
    RELOC_HLO10,
57
 
58
    /* 29K relocation types */
59
    RELOC_JUMPTARG, RELOC_CONST, RELOC_CONSTH,
60
 
61
    RELOC_WDISP14, RELOC_WDISP21,
62
 
63
    NO_RELOC
64
  };
65
 
66
#endif /* TC_SPARC */
67
 
68
#define __GNU_EXEC_MACROS__
69
 
70
#ifndef __STRUCT_EXEC_OVERRIDE__
71
 
72
/* This is the layout on disk of a Unix V7, Berkeley, SunOS, Vax Ultrix
73
   "struct exec".  Don't assume that on this machine, the "struct exec"
74
   will lay out the same sizes or alignments.  */
75
 
76
struct exec_bytes
77
  {
78
    unsigned char a_info[4];
79
    unsigned char a_text[4];
80
    unsigned char a_data[4];
81
    unsigned char a_bss[4];
82
    unsigned char a_syms[4];
83
    unsigned char a_entry[4];
84
    unsigned char a_trsize[4];
85
    unsigned char a_drsize[4];
86
  };
87
 
88
/* How big the "struct exec" is on disk */
89
#define EXEC_BYTES_SIZE (8 * 4)
90
 
91
/* This is the layout in memory of a "struct exec" while we process it.  */
92
 
93
struct exec
94
{
95
  unsigned long a_info;         /* Use macros N_MAGIC, etc for access */
96
  unsigned a_text;              /* length of text, in bytes */
97
  unsigned a_data;              /* length of data, in bytes */
98
  unsigned a_bss;               /* length of uninitialized data area for file, in bytes */
99
  unsigned a_syms;              /* length of symbol table data in file, in bytes */
100
  unsigned a_entry;             /* start address */
101
  unsigned a_trsize;            /* length of relocation info for text, in bytes */
102
  unsigned a_drsize;            /* length of relocation info for data, in bytes */
103
};
104
 
105
#endif /* __STRUCT_EXEC_OVERRIDE__ */
106
 
107
/* these go in the N_MACHTYPE field */
108
/* These symbols could be defined by code from Suns...punt 'em */
109
#undef M_UNKNOWN
110
#undef M_68010
111
#undef M_68020
112
#undef M_SPARC
113
enum machine_type
114
  {
115
    M_UNKNOWN = 0,
116
    M_68010 = 1,
117
    M_68020 = 2,
118
    M_SPARC = 3,
119
    /* skip a bunch so we don't run into any of sun's numbers */
120
    M_386 = 100,
121
    M_29K = 101,
122
    M_RS6000 = 102,             /* IBM RS/6000 */
123
    M_VAX4K_NETBSD = 150,
124
    /* HP/BSD formats */
125
    M_HP200 = 200,              /* hp200 (68010) BSD binary */
126
    M_HP300 = 300,              /* hp300 (68020+68881) BSD binary */
127
    M_HPUX23 = 0x020C           /* hp200/300 HPUX binary */
128
  };
129
 
130
#define N_MAGIC(exec) ((exec).a_info & 0xffff)
131
#define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
132
#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
133
#define N_SET_INFO(exec, magic, type, flags) \
134
    ((exec).a_info = ((magic) & 0xffff) \
135
     | (((int)(type) & 0xff) << 16) \
136
     | (((flags) & 0xff) << 24))
137
#define N_SET_MAGIC(exec, magic) \
138
    ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
139
 
140
#define N_SET_MACHTYPE(exec, machtype) \
141
    ((exec).a_info = \
142
     ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
143
 
144
#define N_SET_FLAGS(exec, flags) \
145
    ((exec).a_info = \
146
     ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
147
 
148
/* Code indicating object file or impure executable.  */
149
#ifndef OMAGIC
150
#define OMAGIC 0407
151
#endif
152
/* Code indicating pure executable.  */
153
#define NMAGIC 0410
154
/* Code indicating demand-paged executable.  */
155
#define ZMAGIC 0413
156
 
157
/* Virtual Address of text segment from the a.out file.  For OMAGIC,
158
   (almost always "unlinked .o's" these days), should be zero.
159
   For linked files, should reflect reality if we know it.  */
160
 
161
#ifndef N_TXTADDR
162
#define N_TXTADDR(x)    (N_MAGIC(x)==OMAGIC? 0 : TEXT_START_ADDR)
163
#endif
164
 
165
#ifndef N_BADMAG
166
#define N_BADMAG(x)       (N_MAGIC(x) != OMAGIC         \
167
                           && N_MAGIC(x) != NMAGIC              \
168
                           && N_MAGIC(x) != ZMAGIC)
169
#endif
170
 
171
/* By default, segment size is constant.  But on some machines, it can
172
   be a function of the a.out header (e.g. machine type).  */
173
#ifndef N_SEGSIZE
174
#define N_SEGSIZE(x)    SEGMENT_SIZE
175
#endif
176
 
177
/* This complexity is for encapsulated COFF support */
178
#ifndef _N_HDROFF
179
#define _N_HDROFF(x)    (N_SEGSIZE(x) - sizeof (struct exec))
180
#endif
181
 
182
#ifndef N_TXTOFF
183
#define N_TXTOFF(x)     (N_MAGIC(x) == ZMAGIC ? \
184
                         _N_HDROFF((x)) + sizeof (struct exec) :        \
185
                         sizeof (struct exec))
186
#endif
187
 
188
#ifndef N_DATOFF
189
#define N_DATOFF(x)     ( N_TXTOFF(x) + (x).a_text )
190
#endif
191
 
192
#ifndef N_TRELOFF
193
#define N_TRELOFF(x)    ( N_DATOFF(x) + (x).a_data )
194
#endif
195
 
196
#ifndef N_DRELOFF
197
#define N_DRELOFF(x)    ( N_TRELOFF(x) + (x).a_trsize )
198
#endif
199
 
200
#ifndef N_SYMOFF
201
#define N_SYMOFF(x)     ( N_DRELOFF(x) + (x).a_drsize )
202
#endif
203
 
204
#ifndef N_STROFF
205
#define N_STROFF(x)     ( N_SYMOFF(x) + (x).a_syms )
206
#endif
207
 
208
/* Address of text segment in memory after it is loaded.  */
209
#ifndef N_TXTADDR
210
#define N_TXTADDR(x)    0
211
#endif
212
 
213
#ifndef N_DATADDR
214
#define N_DATADDR(x) \
215
    (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) \
216
     :  (N_SEGSIZE(x) + ((N_TXTADDR(x)+(x).a_text-1) & ~(N_SEGSIZE(x)-1))))
217
#endif
218
 
219
/* Address of bss segment in memory after it is loaded.  */
220
#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
221
 
222
struct nlist
223
  {
224
    union
225
      {
226
        char *n_name;
227
        struct nlist *n_next;
228
        long n_strx;
229
      }
230
    n_un;
231
    unsigned char n_type;
232
    char n_other;
233
    short n_desc;
234
    unsigned long n_value;
235
  };
236
 
237
#define N_UNDF 0
238
#define N_ABS 2
239
#define N_TEXT 4
240
#define N_DATA 6
241
#define N_BSS 8
242
#define N_COMM  0x12            /* common (visible in shared lib commons) */
243
#define N_FN 0x1F               /* File name of a .o file */
244
 
245
/* Note: N_EXT can only usefully be OR-ed with N_UNDF, N_ABS, N_TEXT,
246
   N_DATA, or N_BSS.  When the low-order bit of other types is set,
247
   (e.g. N_WARNING versus N_FN), they are two different types.  */
248
#define N_EXT 1
249
#define N_TYPE 036
250
#define N_STAB 0340
251
 
252
/* The following type indicates the definition of a symbol as being
253
   an indirect reference to another symbol.  The other symbol
254
   appears as an undefined reference, immediately following this symbol.
255
 
256
   Indirection is asymmetrical.  The other symbol's value will be used
257
   to satisfy requests for the indirect symbol, but not vice versa.
258
   If the other symbol does not have a definition, libraries will
259
   be searched to find a definition.  */
260
 
261
#define N_INDR 0xa
262
 
263
/* The following symbols refer to set elements.
264
   All the N_SET[ATDB] symbols with the same name form one set.
265
   Space is allocated for the set in the text section, and each set
266
   element's value is stored into one word of the space.
267
   The first word of the space is the length of the set (number of elements).
268
 
269
   The address of the set is made into an N_SETV symbol
270
   whose name is the same as the name of the set.
271
   This symbol acts like a N_DATA global symbol
272
   in that it can satisfy undefined external references.  */
273
 
274
/* These appear as input to LD, in a .o file.  */
275
#define N_SETA  0x14            /* Absolute set element symbol */
276
#define N_SETT  0x16            /* Text set element symbol */
277
#define N_SETD  0x18            /* Data set element symbol */
278
#define N_SETB  0x1A            /* Bss set element symbol */
279
 
280
/* This is output from LD.  */
281
#define N_SETV  0x1C            /* Pointer to set vector in data area.  */
282
 
283
/* Warning symbol. The text gives a warning message, the next symbol
284
   in the table will be undefined. When the symbol is referenced, the
285
   message is printed.  */
286
 
287
#define N_WARNING 0x1e
288
 
289
/* Weak symbols.  These are a GNU extension to the a.out format.  The
290
   semantics are those of ELF weak symbols.  Weak symbols are always
291
   externally visible.  The N_WEAK? values are squeezed into the
292
   available slots.  The value of a N_WEAKU symbol is 0.  The values
293
   of the other types are the definitions.  */
294
#define N_WEAKU 0x0d            /* Weak undefined symbol.  */
295
#define N_WEAKA 0x0e            /* Weak absolute symbol.  */
296
#define N_WEAKT 0x0f            /* Weak text symbol.  */
297
#define N_WEAKD 0x10            /* Weak data symbol.  */
298
#define N_WEAKB 0x11            /* Weak bss symbol.  */
299
 
300
/* This structure describes a single relocation to be performed.
301
   The text-relocation section of the file is a vector of these structures,
302
   all of which apply to the text section.
303
   Likewise, the data-relocation section applies to the data section.  */
304
 
305
/* The following enum and struct were borrowed from SunOS's
306
   /usr/include/sun4/a.out.h  and extended to handle
307
   other machines.  It is currently used on SPARC and AMD 29000.
308
 
309
   reloc_ext_bytes is how it looks on disk.  reloc_info_extended is
310
   how we might process it on a native host.  */
311
#if USE_EXTENDED_RELOC
312
 
313
struct reloc_ext_bytes
314
  {
315
    unsigned char r_address[4];
316
    unsigned char r_index[3];
317
    unsigned char r_bits[1];
318
    unsigned char r_addend[4];
319
  };
320
 
321
#define RELOC_EXT_BITS_EXTERN_BIG       0x80
322
#define RELOC_EXT_BITS_EXTERN_LITTLE    0x01
323
 
324
#define RELOC_EXT_BITS_TYPE_BIG         0x1F
325
#define RELOC_EXT_BITS_TYPE_SH_BIG      0
326
#define RELOC_EXT_BITS_TYPE_LITTLE      0xF8
327
#define RELOC_EXT_BITS_TYPE_SH_LITTLE   3
328
 
329
#define RELOC_EXT_SIZE  12      /* Bytes per relocation entry */
330
 
331
struct reloc_info_extended
332
{
333
  unsigned long r_address;
334
  unsigned int r_index:24;
335
# define        r_symbolnum  r_index
336
  unsigned r_extern:1;
337
  unsigned:2;
338
  /*  RS/6000 compiler does not support enum bitfield
339
            enum reloc_type r_type:5; */
340
  enum reloc_type r_type;
341
  long int r_addend;
342
};
343
 
344
#else
345
 
346
/* The standard, old-fashioned, Berkeley compatible relocation struct */
347
 
348
#ifdef TC_I860
349
/* NOTE: three bits max, see struct reloc_info_i860.r_type */
350
enum i860_reloc_type
351
  {
352
    NO_RELOC = 0, BRADDR, LOW0, LOW1, LOW2, LOW3, LOW4, SPLIT0, SPLIT1, SPLIT2, RELOC_32,
353
  };
354
 
355
typedef enum i860_reloc_type reloc_type;
356
 
357
/* NOTE: two bits max, see reloc_info_i860.r_type */
358
enum highlow_type
359
  {
360
    NO_SPEC = 0, PAIR, HIGH, HIGHADJ,
361
  };
362
 
363
struct reloc_info_i860
364
{
365
  unsigned long r_address;
366
  /*
367
         * Using bit fields here is a bad idea because the order is not portable. :-(
368
         */
369
  unsigned int r_symbolnum:24;
370
  unsigned int r_pcrel:1;
371
  unsigned int r_extern:1;
372
  /* combining the two field simplifies the argument passing in "new_fix()" */
373
  /* and is compatible with the existing Sparc #ifdef's */
374
  /* r_type:  highlow_type - bits 5,4; reloc_type - bits 3-0 */
375
  unsigned int r_type:6;
376
  long r_addend;
377
};
378
 
379
#endif /* TC_I860 */
380
 
381
struct reloc_std_bytes
382
  {
383
    unsigned char r_address[4];
384
    unsigned char r_index[3];
385
    unsigned char r_bits[1];
386
  };
387
 
388
#define RELOC_STD_BITS_PCREL_BIG        0x80
389
#define RELOC_STD_BITS_PCREL_LITTLE     0x01
390
 
391
#define RELOC_STD_BITS_LENGTH_BIG       0x60
392
#define RELOC_STD_BITS_LENGTH_SH_BIG    5       /* To shift to units place */
393
#define RELOC_STD_BITS_LENGTH_LITTLE    0x06
394
#define RELOC_STD_BITS_LENGTH_SH_LITTLE 1
395
 
396
#define RELOC_STD_BITS_EXTERN_BIG       0x10
397
#define RELOC_STD_BITS_EXTERN_LITTLE    0x08
398
 
399
#define RELOC_STD_BITS_BASEREL_BIG      0x08
400
#define RELOC_STD_BITS_BASEREL_LITTLE   0x08
401
 
402
#define RELOC_STD_BITS_JMPTABLE_BIG     0x04
403
#define RELOC_STD_BITS_JMPTABLE_LITTLE  0x04
404
 
405
#define RELOC_STD_BITS_RELATIVE_BIG     0x02
406
#define RELOC_STD_BITS_RELATIVE_LITTLE  0x02
407
 
408
#define RELOC_STD_SIZE  8       /* Bytes per relocation entry */
409
 
410
#endif /* USE_EXTENDED_RELOC */
411
 
412
#ifndef CUSTOM_RELOC_FORMAT
413
struct relocation_info
414
{
415
  /* Address (within segment) to be relocated.  */
416
  int r_address;
417
  /* The meaning of r_symbolnum depends on r_extern.  */
418
  unsigned int r_symbolnum:24;
419
  /* Nonzero means value is a pc-relative offset
420
           and it should be relocated for changes in its own address
421
           as well as for changes in the symbol or section specified.  */
422
  unsigned int r_pcrel:1;
423
  /* Length (as exponent of 2) of the field to be relocated.
424
           Thus, a value of 2 indicates 1<<2 bytes.  */
425
  unsigned int r_length:2;
426
  /* 1 => relocate with value of symbol.
427
           r_symbolnum is the index of the symbol
428
           in file's the symbol table.
429
 
430
           r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
431
           (the N_EXT bit may be set also, but signifies nothing).  */
432
  unsigned int r_extern:1;
433
  /* The next three bits are for SunOS shared libraries, and seem to
434
           be undocumented.  */
435
#ifdef TC_NS32K
436
  unsigned int r_bsr:1;
437
  unsigned int r_disp:2;
438
#else
439
  unsigned int r_baserel:1;     /* Linkage table relative */
440
  unsigned int r_jmptable:1;    /* pc-relative to jump table */
441
  unsigned int r_relative:1;    /* "relative relocation" */
442
#endif /* TC_NS32K */
443
  /* unused */
444
  unsigned int r_pad:1;         /* Padding -- set to zero */
445
};
446
 
447
#endif /* CUSTOM_RELOC_FORMAT */
448
 
449
#endif /* __A_OUT_GNU_H__ */
450
 
451
/* end of aout_gnu.h */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.