| 1 | /* `a.out' object-file definitions, including extensions to 64-bit fields | 
|---|
| 2 |  | 
|---|
| 3 | Copyright 2001, 2003 Free Software Foundation, Inc. | 
|---|
| 4 |  | 
|---|
| 5 | This program is free software; you can redistribute it and/or modify | 
|---|
| 6 | it under the terms of the GNU General Public License as published by | 
|---|
| 7 | the Free Software Foundation; either version 2 of the License, or | 
|---|
| 8 | (at your option) any later version. | 
|---|
| 9 |  | 
|---|
| 10 | This program is distributed in the hope that it will be useful, | 
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 13 | GNU General Public License for more details. | 
|---|
| 14 |  | 
|---|
| 15 | You should have received a copy of the GNU General Public License | 
|---|
| 16 | along with this program; if not, write to the Free Software | 
|---|
| 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */ | 
|---|
| 18 |  | 
|---|
| 19 | #ifndef __A_OUT_64_H__ | 
|---|
| 20 | #define __A_OUT_64_H__ | 
|---|
| 21 |  | 
|---|
| 22 | #ifndef BYTES_IN_WORD | 
|---|
| 23 | #define BYTES_IN_WORD 4 | 
|---|
| 24 | #endif | 
|---|
| 25 |  | 
|---|
| 26 | /* This is the layout on disk of the 32-bit or 64-bit exec header.  */ | 
|---|
| 27 |  | 
|---|
| 28 | #ifndef external_exec | 
|---|
| 29 | struct external_exec | 
|---|
| 30 | { | 
|---|
| 31 | bfd_byte e_info[4];               /* Magic number and stuff.  */ | 
|---|
| 32 | bfd_byte e_text[BYTES_IN_WORD];   /* Length of text section in bytes.  */ | 
|---|
| 33 | bfd_byte e_data[BYTES_IN_WORD];   /* Length of data section in bytes.  */ | 
|---|
| 34 | bfd_byte e_bss[BYTES_IN_WORD];    /* Length of bss area in bytes.  */ | 
|---|
| 35 | bfd_byte e_syms[BYTES_IN_WORD];   /* Length of symbol table in bytes.  */ | 
|---|
| 36 | bfd_byte e_entry[BYTES_IN_WORD];  /* Start address.  */ | 
|---|
| 37 | bfd_byte e_trsize[BYTES_IN_WORD]; /* Length of text relocation info.  */ | 
|---|
| 38 | bfd_byte e_drsize[BYTES_IN_WORD]; /* Length of data relocation info.  */ | 
|---|
| 39 | }; | 
|---|
| 40 |  | 
|---|
| 41 | #define EXEC_BYTES_SIZE (4 + BYTES_IN_WORD * 7) | 
|---|
| 42 |  | 
|---|
| 43 | /* Magic numbers for a.out files.  */ | 
|---|
| 44 |  | 
|---|
| 45 | #if ARCH_SIZE==64 | 
|---|
| 46 | #define OMAGIC 0x1001           /* Code indicating object file.  */ | 
|---|
| 47 | #define ZMAGIC 0x1002           /* Code indicating demand-paged executable.  */ | 
|---|
| 48 | #define NMAGIC 0x1003           /* Code indicating pure executable.  */ | 
|---|
| 49 |  | 
|---|
| 50 | /* There is no 64-bit QMAGIC as far as I know.  */ | 
|---|
| 51 |  | 
|---|
| 52 | #define N_BADMAG(x)       (N_MAGIC(x) != OMAGIC         \ | 
|---|
| 53 | && N_MAGIC(x) != NMAGIC         \ | 
|---|
| 54 | && N_MAGIC(x) != ZMAGIC) | 
|---|
| 55 | #else | 
|---|
| 56 | #define OMAGIC 0407             /* Object file or impure executable.  */ | 
|---|
| 57 | #define NMAGIC 0410             /* Code indicating pure executable.  */ | 
|---|
| 58 | #define ZMAGIC 0413             /* Code indicating demand-paged executable.  */ | 
|---|
| 59 | #define BMAGIC 0415             /* Used by a b.out object.  */ | 
|---|
| 60 |  | 
|---|
| 61 | /* This indicates a demand-paged executable with the header in the text. | 
|---|
| 62 | It is used by 386BSD (and variants) and Linux, at least.  */ | 
|---|
| 63 | #ifndef QMAGIC | 
|---|
| 64 | #define QMAGIC 0314 | 
|---|
| 65 | #endif | 
|---|
| 66 | # ifndef N_BADMAG | 
|---|
| 67 | #  define N_BADMAG(x)     (N_MAGIC(x) != OMAGIC         \ | 
|---|
| 68 | && N_MAGIC(x) != NMAGIC         \ | 
|---|
| 69 | && N_MAGIC(x) != ZMAGIC \ | 
|---|
| 70 | && N_MAGIC(x) != QMAGIC) | 
|---|
| 71 | # endif /* N_BADMAG */ | 
|---|
| 72 | #endif | 
|---|
| 73 |  | 
|---|
| 74 | #endif | 
|---|
| 75 |  | 
|---|
| 76 | #ifdef QMAGIC | 
|---|
| 77 | #define N_IS_QMAGIC(x) (N_MAGIC (x) == QMAGIC) | 
|---|
| 78 | #else | 
|---|
| 79 | #define N_IS_QMAGIC(x) (0) | 
|---|
| 80 | #endif | 
|---|
| 81 |  | 
|---|
| 82 | /* The difference between TARGET_PAGE_SIZE and N_SEGSIZE is that TARGET_PAGE_SIZE is | 
|---|
| 83 | the finest granularity at which you can page something, thus it | 
|---|
| 84 | controls the padding (if any) before the text segment of a ZMAGIC | 
|---|
| 85 | file.  N_SEGSIZE is the resolution at which things can be marked as | 
|---|
| 86 | read-only versus read/write, so it controls the padding between the | 
|---|
| 87 | text segment and the data segment (in memory; on disk the padding | 
|---|
| 88 | between them is TARGET_PAGE_SIZE).  TARGET_PAGE_SIZE and N_SEGSIZE are the same | 
|---|
| 89 | for most machines, but different for sun3.  */ | 
|---|
| 90 |  | 
|---|
| 91 | /* By default, segment size is constant.  But some machines override this | 
|---|
| 92 | to be a function of the a.out header (e.g. machine type).  */ | 
|---|
| 93 |  | 
|---|
| 94 | #ifndef N_SEGSIZE | 
|---|
| 95 | #define N_SEGSIZE(x)    SEGMENT_SIZE | 
|---|
| 96 | #endif | 
|---|
| 97 |  | 
|---|
| 98 |  | 
|---|
| 99 | /* Virtual memory address of the text section. | 
|---|
| 100 | This is getting very complicated.  A good reason to discard a.out format | 
|---|
| 101 | for something that specifies these fields explicitly.  But til then... | 
|---|
| 102 |  | 
|---|
| 103 | * OMAGIC and NMAGIC files: | 
|---|
| 104 | (object files: text for "relocatable addr 0" right after the header) | 
|---|
| 105 | start at 0, offset is EXEC_BYTES_SIZE, size as stated. | 
|---|
| 106 | * The text address, offset, and size of ZMAGIC files depend | 
|---|
| 107 | on the entry point of the file: | 
|---|
| 108 | * entry point below TEXT_START_ADDR: | 
|---|
| 109 | (hack for SunOS shared libraries) | 
|---|
| 110 | start at 0, offset is 0, size as stated. | 
|---|
| 111 | * If N_HEADER_IN_TEXT(x) is true (which defaults to being the | 
|---|
| 112 | case when the entry point is EXEC_BYTES_SIZE or further into a page): | 
|---|
| 113 | no padding is needed; text can start after exec header.  Sun | 
|---|
| 114 | considers the text segment of such files to include the exec header; | 
|---|
| 115 | for BFD's purposes, we don't, which makes more work for us. | 
|---|
| 116 | start at TEXT_START_ADDR + EXEC_BYTES_SIZE, offset is EXEC_BYTES_SIZE, | 
|---|
| 117 | size as stated minus EXEC_BYTES_SIZE. | 
|---|
| 118 | * If N_HEADER_IN_TEXT(x) is false (which defaults to being the case when | 
|---|
| 119 | the entry point is less than EXEC_BYTES_SIZE into a page (e.g. page | 
|---|
| 120 | aligned)): (padding is needed so that text can start at a page boundary) | 
|---|
| 121 | start at TEXT_START_ADDR, offset TARGET_PAGE_SIZE, size as stated. | 
|---|
| 122 |  | 
|---|
| 123 | Specific configurations may want to hardwire N_HEADER_IN_TEXT, | 
|---|
| 124 | for efficiency or to allow people to play games with the entry point. | 
|---|
| 125 | In that case, you would #define N_HEADER_IN_TEXT(x) as 1 for sunos, | 
|---|
| 126 | and as 0 for most other hosts (Sony News, Vax Ultrix, etc). | 
|---|
| 127 | (Do this in the appropriate bfd target file.) | 
|---|
| 128 | (The default is a heuristic that will break if people try changing | 
|---|
| 129 | the entry point, perhaps with the ld -e flag.) | 
|---|
| 130 |  | 
|---|
| 131 | * QMAGIC is always like a ZMAGIC for which N_HEADER_IN_TEXT is true, | 
|---|
| 132 | and for which the starting address is TARGET_PAGE_SIZE (or should this be | 
|---|
| 133 | SEGMENT_SIZE?) (TEXT_START_ADDR only applies to ZMAGIC, not to QMAGIC).  */ | 
|---|
| 134 |  | 
|---|
| 135 | /* This macro is only relevant for ZMAGIC files; QMAGIC always has the header | 
|---|
| 136 | in the text.  */ | 
|---|
| 137 | #ifndef N_HEADER_IN_TEXT | 
|---|
| 138 | #define N_HEADER_IN_TEXT(x) \ | 
|---|
| 139 | (((x).a_entry & (TARGET_PAGE_SIZE-1)) >= EXEC_BYTES_SIZE) | 
|---|
| 140 | #endif | 
|---|
| 141 |  | 
|---|
| 142 | /* Sun shared libraries, not linux.  This macro is only relevant for ZMAGIC | 
|---|
| 143 | files.  */ | 
|---|
| 144 | #ifndef N_SHARED_LIB | 
|---|
| 145 | #if defined (TEXT_START_ADDR) && TEXT_START_ADDR == 0 | 
|---|
| 146 | #define N_SHARED_LIB(x) (0) | 
|---|
| 147 | #else | 
|---|
| 148 | #define N_SHARED_LIB(x) ((x).a_entry < TEXT_START_ADDR) | 
|---|
| 149 | #endif | 
|---|
| 150 | #endif | 
|---|
| 151 |  | 
|---|
| 152 | /* Returning 0 not TEXT_START_ADDR for OMAGIC and NMAGIC is based on | 
|---|
| 153 | the assumption that we are dealing with a .o file, not an | 
|---|
| 154 | executable.  This is necessary for OMAGIC (but means we don't work | 
|---|
| 155 | right on the output from ld -N); more questionable for NMAGIC.  */ | 
|---|
| 156 |  | 
|---|
| 157 | #ifndef N_TXTADDR | 
|---|
| 158 | #define N_TXTADDR(x) \ | 
|---|
| 159 | (/* The address of a QMAGIC file is always one page in,             \ | 
|---|
| 160 | with the header in the text.  */                                \ | 
|---|
| 161 | N_IS_QMAGIC (x)                                                    \ | 
|---|
| 162 | ? (bfd_vma) TARGET_PAGE_SIZE + EXEC_BYTES_SIZE                     \ | 
|---|
| 163 | : (N_MAGIC (x) != ZMAGIC                                           \ | 
|---|
| 164 | ? (bfd_vma) 0   /* Object file or NMAGIC.  */                   \ | 
|---|
| 165 | : (N_SHARED_LIB (x)                                             \ | 
|---|
| 166 | ? (bfd_vma) 0                                                \ | 
|---|
| 167 | : (N_HEADER_IN_TEXT (x)                                      \ | 
|---|
| 168 | ? (bfd_vma) TEXT_START_ADDR + EXEC_BYTES_SIZE             \ | 
|---|
| 169 | : (bfd_vma) TEXT_START_ADDR)))) | 
|---|
| 170 | #endif | 
|---|
| 171 |  | 
|---|
| 172 | /* If N_HEADER_IN_TEXT is not true for ZMAGIC, there is some padding | 
|---|
| 173 | to make the text segment start at a certain boundary.  For most | 
|---|
| 174 | systems, this boundary is TARGET_PAGE_SIZE.  But for Linux, in the | 
|---|
| 175 | time-honored tradition of crazy ZMAGIC hacks, it is 1024 which is | 
|---|
| 176 | not what TARGET_PAGE_SIZE needs to be for QMAGIC.  */ | 
|---|
| 177 |  | 
|---|
| 178 | #ifndef ZMAGIC_DISK_BLOCK_SIZE | 
|---|
| 179 | #define ZMAGIC_DISK_BLOCK_SIZE TARGET_PAGE_SIZE | 
|---|
| 180 | #endif | 
|---|
| 181 |  | 
|---|
| 182 | #define N_DISK_BLOCK_SIZE(x) \ | 
|---|
| 183 | (N_MAGIC(x) == ZMAGIC ? ZMAGIC_DISK_BLOCK_SIZE : TARGET_PAGE_SIZE) | 
|---|
| 184 |  | 
|---|
| 185 | /* Offset in an a.out of the start of the text section. */ | 
|---|
| 186 | #ifndef N_TXTOFF | 
|---|
| 187 | #define N_TXTOFF(x)                                                     \ | 
|---|
| 188 | (/* For {O,N,Q}MAGIC, no padding.  */                               \ | 
|---|
| 189 | N_MAGIC (x) != ZMAGIC                                              \ | 
|---|
| 190 | ? EXEC_BYTES_SIZE                                                  \ | 
|---|
| 191 | : (N_SHARED_LIB (x)                                                \ | 
|---|
| 192 | ? 0                                                             \ | 
|---|
| 193 | : (N_HEADER_IN_TEXT (x)                                         \ | 
|---|
| 194 | ? EXEC_BYTES_SIZE            /* No padding.  */              \ | 
|---|
| 195 | : ZMAGIC_DISK_BLOCK_SIZE     /* A page of padding.  */))) | 
|---|
| 196 | #endif | 
|---|
| 197 | /* Size of the text section.  It's always as stated, except that we | 
|---|
| 198 | offset it to `undo' the adjustment to N_TXTADDR and N_TXTOFF | 
|---|
| 199 | for ZMAGIC files that nominally include the exec header | 
|---|
| 200 | as part of the first page of text.  (BFD doesn't consider the | 
|---|
| 201 | exec header to be part of the text segment.)  */ | 
|---|
| 202 | #ifndef N_TXTSIZE | 
|---|
| 203 | #define N_TXTSIZE(x) \ | 
|---|
| 204 | (/* For QMAGIC, we don't consider the header part of the text section.  */\ | 
|---|
| 205 | N_IS_QMAGIC (x)                                                      \ | 
|---|
| 206 | ? (x).a_text - EXEC_BYTES_SIZE                                       \ | 
|---|
| 207 | : ((N_MAGIC (x) != ZMAGIC || N_SHARED_LIB (x))                       \ | 
|---|
| 208 | ? (x).a_text                                                      \ | 
|---|
| 209 | : (N_HEADER_IN_TEXT (x)                                           \ | 
|---|
| 210 | ? (x).a_text - EXEC_BYTES_SIZE /* No padding.  */              \ | 
|---|
| 211 | : (x).a_text                   /* A page of padding.  */ ))) | 
|---|
| 212 | #endif | 
|---|
| 213 | /* The address of the data segment in virtual memory. | 
|---|
| 214 | It is the text segment address, plus text segment size, rounded | 
|---|
| 215 | up to a N_SEGSIZE boundary for pure or pageable files.  */ | 
|---|
| 216 | #ifndef N_DATADDR | 
|---|
| 217 | #define N_DATADDR(x) \ | 
|---|
| 218 | (N_MAGIC (x) == OMAGIC                                                \ | 
|---|
| 219 | ? (N_TXTADDR (x) + N_TXTSIZE (x))                                    \ | 
|---|
| 220 | : (N_SEGSIZE (x) + ((N_TXTADDR (x) + N_TXTSIZE (x) - 1)              \ | 
|---|
| 221 | & ~ (bfd_vma) (N_SEGSIZE (x) - 1)))) | 
|---|
| 222 | #endif | 
|---|
| 223 | /* The address of the BSS segment -- immediately after the data segment.  */ | 
|---|
| 224 |  | 
|---|
| 225 | #define N_BSSADDR(x)    (N_DATADDR (x) + (x).a_data) | 
|---|
| 226 |  | 
|---|
| 227 | /* Offsets of the various portions of the file after the text segment.  */ | 
|---|
| 228 |  | 
|---|
| 229 | /* For {Q,Z}MAGIC, there is padding to make the data segment start on | 
|---|
| 230 | a page boundary.  Most of the time the a_text field (and thus | 
|---|
| 231 | N_TXTSIZE) already contains this padding.  It is possible that for | 
|---|
| 232 | BSDI and/or 386BSD it sometimes doesn't contain the padding, and | 
|---|
| 233 | perhaps we should be adding it here.  But this seems kind of | 
|---|
| 234 | questionable and probably should be BSDI/386BSD-specific if we do | 
|---|
| 235 | do it. | 
|---|
| 236 |  | 
|---|
| 237 | For NMAGIC (at least for hp300 BSD, probably others), there is | 
|---|
| 238 | padding in memory only, not on disk, so we must *not* ever pad here | 
|---|
| 239 | for NMAGIC.  */ | 
|---|
| 240 |  | 
|---|
| 241 | #ifndef N_DATOFF | 
|---|
| 242 | #define N_DATOFF(x)     (N_TXTOFF (x) + N_TXTSIZE (x)) | 
|---|
| 243 | #endif | 
|---|
| 244 | #ifndef N_TRELOFF | 
|---|
| 245 | #define N_TRELOFF(x)    (N_DATOFF (x) + (x).a_data) | 
|---|
| 246 | #endif | 
|---|
| 247 | #ifndef N_DRELOFF | 
|---|
| 248 | #define N_DRELOFF(x)    (N_TRELOFF (x) + (x).a_trsize) | 
|---|
| 249 | #endif | 
|---|
| 250 | #ifndef N_SYMOFF | 
|---|
| 251 | #define N_SYMOFF(x)     (N_DRELOFF (x) + (x).a_drsize) | 
|---|
| 252 | #endif | 
|---|
| 253 | #ifndef N_STROFF | 
|---|
| 254 | #define N_STROFF(x)     (N_SYMOFF (x) + (x).a_syms) | 
|---|
| 255 | #endif | 
|---|
| 256 |  | 
|---|
| 257 |  | 
|---|
| 258 | /* Symbols */ | 
|---|
| 259 | #ifndef external_nlist | 
|---|
| 260 | struct external_nlist | 
|---|
| 261 | { | 
|---|
| 262 | bfd_byte e_strx[BYTES_IN_WORD];       /* Index into string table of name.  */ | 
|---|
| 263 | bfd_byte e_type[1];                   /* Type of symbol.  */ | 
|---|
| 264 | bfd_byte e_other[1];                  /* Misc info (usually empty).  */ | 
|---|
| 265 | bfd_byte e_desc[2];                   /* Description field.  */ | 
|---|
| 266 | bfd_byte e_value[BYTES_IN_WORD];      /* Value of symbol.  */ | 
|---|
| 267 | }; | 
|---|
| 268 | #define EXTERNAL_NLIST_SIZE (BYTES_IN_WORD+4+BYTES_IN_WORD) | 
|---|
| 269 | #endif | 
|---|
| 270 |  | 
|---|
| 271 | struct internal_nlist | 
|---|
| 272 | { | 
|---|
| 273 | unsigned long n_strx;                 /* Index into string table of name.  */ | 
|---|
| 274 | unsigned char n_type;                 /* Type of symbol.  */ | 
|---|
| 275 | unsigned char n_other;                /* Misc info (usually empty).  */ | 
|---|
| 276 | unsigned short n_desc;                /* Description field.  */ | 
|---|
| 277 | bfd_vma n_value;                      /* Value of symbol.  */ | 
|---|
| 278 | }; | 
|---|
| 279 |  | 
|---|
| 280 | /* The n_type field is the symbol type, containing:  */ | 
|---|
| 281 |  | 
|---|
| 282 | #define N_UNDF  0       /* Undefined symbol.  */ | 
|---|
| 283 | #define N_ABS   2       /* Absolute symbol -- defined at particular addr.  */ | 
|---|
| 284 | #define N_TEXT  4       /* Text sym -- defined at offset in text seg.  */ | 
|---|
| 285 | #define N_DATA  6       /* Data sym -- defined at offset in data seg.  */ | 
|---|
| 286 | #define N_BSS   8       /* BSS  sym -- defined at offset in zero'd seg.  */ | 
|---|
| 287 | #define N_COMM  0x12    /* Common symbol (visible after shared lib dynlink).  */ | 
|---|
| 288 | #define N_FN    0x1f    /* File name of .o file.  */ | 
|---|
| 289 | #define N_FN_SEQ 0x0C   /* N_FN from Sequent compilers (sigh).  */ | 
|---|
| 290 | /* Note: N_EXT can only be usefully OR-ed with N_UNDF, N_ABS, N_TEXT, | 
|---|
| 291 | N_DATA, or N_BSS.  When the low-order bit of other types is set, | 
|---|
| 292 | (e.g. N_WARNING versus N_FN), they are two different types.  */ | 
|---|
| 293 | #define N_EXT   1       /* External symbol (as opposed to local-to-this-file).  */ | 
|---|
| 294 | #define N_TYPE  0x1e | 
|---|
| 295 | #define N_STAB  0xe0    /* If any of these bits are on, it's a debug symbol.  */ | 
|---|
| 296 |  | 
|---|
| 297 | #define N_INDR 0x0a | 
|---|
| 298 |  | 
|---|
| 299 | /* The following symbols refer to set elements. | 
|---|
| 300 | All the N_SET[ATDB] symbols with the same name form one set. | 
|---|
| 301 | Space is allocated for the set in the text section, and each set | 
|---|
| 302 | elements value is stored into one word of the space. | 
|---|
| 303 | The first word of the space is the length of the set (number of elements). | 
|---|
| 304 |  | 
|---|
| 305 | The address of the set is made into an N_SETV symbol | 
|---|
| 306 | whose name is the same as the name of the set. | 
|---|
| 307 | This symbol acts like a N_DATA global symbol | 
|---|
| 308 | in that it can satisfy undefined external references.  */ | 
|---|
| 309 |  | 
|---|
| 310 | /* These appear as input to LD, in a .o file.  */ | 
|---|
| 311 | #define N_SETA  0x14            /* Absolute set element symbol.  */ | 
|---|
| 312 | #define N_SETT  0x16            /* Text set element symbol.  */ | 
|---|
| 313 | #define N_SETD  0x18            /* Data set element symbol.  */ | 
|---|
| 314 | #define N_SETB  0x1A            /* Bss set element symbol.  */ | 
|---|
| 315 |  | 
|---|
| 316 | /* This is output from LD.  */ | 
|---|
| 317 | #define N_SETV  0x1C            /* Pointer to set vector in data area.  */ | 
|---|
| 318 |  | 
|---|
| 319 | /* Warning symbol. The text gives a warning message, the next symbol | 
|---|
| 320 | in the table will be undefined. When the symbol is referenced, the | 
|---|
| 321 | message is printed.  */ | 
|---|
| 322 |  | 
|---|
| 323 | #define N_WARNING 0x1e | 
|---|
| 324 |  | 
|---|
| 325 | /* Weak symbols.  These are a GNU extension to the a.out format.  The | 
|---|
| 326 | semantics are those of ELF weak symbols.  Weak symbols are always | 
|---|
| 327 | externally visible.  The N_WEAK? values are squeezed into the | 
|---|
| 328 | available slots.  The value of a N_WEAKU symbol is 0.  The values | 
|---|
| 329 | of the other types are the definitions.  */ | 
|---|
| 330 | #define N_WEAKU 0x0d            /* Weak undefined symbol.  */ | 
|---|
| 331 | #define N_WEAKA 0x0e            /* Weak absolute symbol.  */ | 
|---|
| 332 | #define N_WEAKT 0x0f            /* Weak text symbol.  */ | 
|---|
| 333 | #define N_WEAKD 0x10            /* Weak data symbol.  */ | 
|---|
| 334 | #define N_WEAKB 0x11            /* Weak bss symbol.  */ | 
|---|
| 335 |  | 
|---|
| 336 | /* emx-specific symbols.  */ | 
|---|
| 337 | #define N_IMP1 0x68             /* Import reference (emx specific) */ | 
|---|
| 338 | #define N_IMP2 0x6a             /* Import definition (emx specific) */ | 
|---|
| 339 | #define N_EXP  0x6c             /* Export definition (emx specific) */ | 
|---|
| 340 |  | 
|---|
| 341 | /* Relocations | 
|---|
| 342 |  | 
|---|
| 343 | There are two types of relocation flavours for a.out systems, | 
|---|
| 344 | standard and extended. The standard form is used on systems where the | 
|---|
| 345 | instruction has room for all the bits of an offset to the operand, whilst | 
|---|
| 346 | the extended form is used when an address operand has to be split over n | 
|---|
| 347 | instructions. Eg, on the 68k, each move instruction can reference | 
|---|
| 348 | the target with a displacement of 16 or 32 bits. On the sparc, move | 
|---|
| 349 | instructions use an offset of 14 bits, so the offset is stored in | 
|---|
| 350 | the reloc field, and the data in the section is ignored.  */ | 
|---|
| 351 |  | 
|---|
| 352 | /* This structure describes a single relocation to be performed. | 
|---|
| 353 | The text-relocation section of the file is a vector of these structures, | 
|---|
| 354 | all of which apply to the text section. | 
|---|
| 355 | Likewise, the data-relocation section applies to the data section.  */ | 
|---|
| 356 |  | 
|---|
| 357 | struct reloc_std_external | 
|---|
| 358 | { | 
|---|
| 359 | bfd_byte r_address[BYTES_IN_WORD];    /* Offset of of data to relocate.  */ | 
|---|
| 360 | bfd_byte r_index[3];                  /* Symbol table index of symbol.  */ | 
|---|
| 361 | bfd_byte r_type[1];                   /* Relocation type.  */ | 
|---|
| 362 | }; | 
|---|
| 363 |  | 
|---|
| 364 | #define RELOC_STD_BITS_PCREL_BIG        ((unsigned int) 0x80) | 
|---|
| 365 | #define RELOC_STD_BITS_PCREL_LITTLE     ((unsigned int) 0x01) | 
|---|
| 366 |  | 
|---|
| 367 | #define RELOC_STD_BITS_LENGTH_BIG       ((unsigned int) 0x60) | 
|---|
| 368 | #define RELOC_STD_BITS_LENGTH_SH_BIG    5 | 
|---|
| 369 | #define RELOC_STD_BITS_LENGTH_LITTLE    ((unsigned int) 0x06) | 
|---|
| 370 | #define RELOC_STD_BITS_LENGTH_SH_LITTLE 1 | 
|---|
| 371 |  | 
|---|
| 372 | #define RELOC_STD_BITS_EXTERN_BIG       ((unsigned int) 0x10) | 
|---|
| 373 | #define RELOC_STD_BITS_EXTERN_LITTLE    ((unsigned int) 0x08) | 
|---|
| 374 |  | 
|---|
| 375 | #define RELOC_STD_BITS_BASEREL_BIG      ((unsigned int) 0x08) | 
|---|
| 376 | #define RELOC_STD_BITS_BASEREL_LITTLE   ((unsigned int) 0x10) | 
|---|
| 377 |  | 
|---|
| 378 | #define RELOC_STD_BITS_JMPTABLE_BIG     ((unsigned int) 0x04) | 
|---|
| 379 | #define RELOC_STD_BITS_JMPTABLE_LITTLE  ((unsigned int) 0x20) | 
|---|
| 380 |  | 
|---|
| 381 | #define RELOC_STD_BITS_RELATIVE_BIG     ((unsigned int) 0x02) | 
|---|
| 382 | #define RELOC_STD_BITS_RELATIVE_LITTLE  ((unsigned int) 0x40) | 
|---|
| 383 |  | 
|---|
| 384 | #define RELOC_STD_SIZE  (BYTES_IN_WORD + 3 + 1)         /* Bytes per relocation entry.  */ | 
|---|
| 385 |  | 
|---|
| 386 | struct reloc_std_internal | 
|---|
| 387 | { | 
|---|
| 388 | bfd_vma r_address;            /* Address (within segment) to be relocated.  */ | 
|---|
| 389 | /* The meaning of r_symbolnum depends on r_extern.  */ | 
|---|
| 390 | unsigned int r_symbolnum:24; | 
|---|
| 391 | /* Nonzero means value is a pc-relative offset | 
|---|
| 392 | and it should be relocated for changes in its own address | 
|---|
| 393 | as well as for changes in the symbol or section specified.  */ | 
|---|
| 394 | unsigned int r_pcrel:1; | 
|---|
| 395 | /* Length (as exponent of 2) of the field to be relocated. | 
|---|
| 396 | Thus, a value of 2 indicates 1<<2 bytes.  */ | 
|---|
| 397 | unsigned int r_length:2; | 
|---|
| 398 | /* 1 => relocate with value of symbol. | 
|---|
| 399 | r_symbolnum is the index of the symbol | 
|---|
| 400 | in files the symbol table. | 
|---|
| 401 | 0 => relocate with the address of a segment. | 
|---|
| 402 | r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS | 
|---|
| 403 | (the N_EXT bit may be set also, but signifies nothing).  */ | 
|---|
| 404 | unsigned int r_extern:1; | 
|---|
| 405 | /* The next three bits are for SunOS shared libraries, and seem to | 
|---|
| 406 | be undocumented.  */ | 
|---|
| 407 | unsigned int r_baserel:1;     /* Linkage table relative.  */ | 
|---|
| 408 | unsigned int r_jmptable:1;    /* pc-relative to jump table.  */ | 
|---|
| 409 | unsigned int r_relative:1;    /* "relative relocation".  */ | 
|---|
| 410 | /* unused */ | 
|---|
| 411 | unsigned int r_pad:1;         /* Padding -- set to zero.  */ | 
|---|
| 412 | }; | 
|---|
| 413 |  | 
|---|
| 414 |  | 
|---|
| 415 | /* EXTENDED RELOCS.   */ | 
|---|
| 416 |  | 
|---|
| 417 | struct reloc_ext_external | 
|---|
| 418 | { | 
|---|
| 419 | bfd_byte r_address[BYTES_IN_WORD];    /* Offset of of data to relocate.  */ | 
|---|
| 420 | bfd_byte r_index[3];                  /* Symbol table index of symbol.  */ | 
|---|
| 421 | bfd_byte r_type[1];                   /* Relocation type.  */ | 
|---|
| 422 | bfd_byte r_addend[BYTES_IN_WORD];     /* Datum addend.  */ | 
|---|
| 423 | }; | 
|---|
| 424 |  | 
|---|
| 425 | #ifndef RELOC_EXT_BITS_EXTERN_BIG | 
|---|
| 426 | #define RELOC_EXT_BITS_EXTERN_BIG       ((unsigned int) 0x80) | 
|---|
| 427 | #endif | 
|---|
| 428 |  | 
|---|
| 429 | #ifndef RELOC_EXT_BITS_EXTERN_LITTLE | 
|---|
| 430 | #define RELOC_EXT_BITS_EXTERN_LITTLE    ((unsigned int) 0x01) | 
|---|
| 431 | #endif | 
|---|
| 432 |  | 
|---|
| 433 | #ifndef RELOC_EXT_BITS_TYPE_BIG | 
|---|
| 434 | #define RELOC_EXT_BITS_TYPE_BIG         ((unsigned int) 0x1F) | 
|---|
| 435 | #endif | 
|---|
| 436 |  | 
|---|
| 437 | #ifndef RELOC_EXT_BITS_TYPE_SH_BIG | 
|---|
| 438 | #define RELOC_EXT_BITS_TYPE_SH_BIG      0 | 
|---|
| 439 | #endif | 
|---|
| 440 |  | 
|---|
| 441 | #ifndef RELOC_EXT_BITS_TYPE_LITTLE | 
|---|
| 442 | #define RELOC_EXT_BITS_TYPE_LITTLE      ((unsigned int) 0xF8) | 
|---|
| 443 | #endif | 
|---|
| 444 |  | 
|---|
| 445 | #ifndef RELOC_EXT_BITS_TYPE_SH_LITTLE | 
|---|
| 446 | #define RELOC_EXT_BITS_TYPE_SH_LITTLE   3 | 
|---|
| 447 | #endif | 
|---|
| 448 |  | 
|---|
| 449 | /* Bytes per relocation entry.  */ | 
|---|
| 450 | #define RELOC_EXT_SIZE  (BYTES_IN_WORD + 3 + 1 + BYTES_IN_WORD) | 
|---|
| 451 |  | 
|---|
| 452 | enum reloc_type | 
|---|
| 453 | { | 
|---|
| 454 | /* Simple relocations.  */ | 
|---|
| 455 | RELOC_8,                      /* data[0:7] = addend + sv              */ | 
|---|
| 456 | RELOC_16,                     /* data[0:15] = addend + sv             */ | 
|---|
| 457 | RELOC_32,                     /* data[0:31] = addend + sv             */ | 
|---|
| 458 | /* PC-rel displacement.  */ | 
|---|
| 459 | RELOC_DISP8,                  /* data[0:7] = addend - pc + sv         */ | 
|---|
| 460 | RELOC_DISP16,                 /* data[0:15] = addend - pc + sv        */ | 
|---|
| 461 | RELOC_DISP32,                 /* data[0:31] = addend - pc + sv        */ | 
|---|
| 462 | /* Special.  */ | 
|---|
| 463 | RELOC_WDISP30,                /* data[0:29] = (addend + sv - pc)>>2   */ | 
|---|
| 464 | RELOC_WDISP22,                /* data[0:21] = (addend + sv - pc)>>2   */ | 
|---|
| 465 | RELOC_HI22,                   /* data[0:21] = (addend + sv)>>10       */ | 
|---|
| 466 | RELOC_22,                     /* data[0:21] = (addend + sv)           */ | 
|---|
| 467 | RELOC_13,                     /* data[0:12] = (addend + sv)           */ | 
|---|
| 468 | RELOC_LO10,                   /* data[0:9] = (addend + sv)            */ | 
|---|
| 469 | RELOC_SFA_BASE, | 
|---|
| 470 | RELOC_SFA_OFF13, | 
|---|
| 471 | /* P.I.C. (base-relative).  */ | 
|---|
| 472 | RELOC_BASE10,                 /* Not sure - maybe we can do this the */ | 
|---|
| 473 | RELOC_BASE13,                 /* right way now */ | 
|---|
| 474 | RELOC_BASE22, | 
|---|
| 475 | /* For some sort of pc-rel P.I.C. (?)  */ | 
|---|
| 476 | RELOC_PC10, | 
|---|
| 477 | RELOC_PC22, | 
|---|
| 478 | /* P.I.C. jump table.  */ | 
|---|
| 479 | RELOC_JMP_TBL, | 
|---|
| 480 | /* Reputedly for shared libraries somehow.  */ | 
|---|
| 481 | RELOC_SEGOFF16, | 
|---|
| 482 | RELOC_GLOB_DAT, | 
|---|
| 483 | RELOC_JMP_SLOT, | 
|---|
| 484 | RELOC_RELATIVE, | 
|---|
| 485 |  | 
|---|
| 486 | RELOC_11, | 
|---|
| 487 | RELOC_WDISP2_14, | 
|---|
| 488 | RELOC_WDISP19, | 
|---|
| 489 | RELOC_HHI22,                  /* data[0:21] = (addend + sv) >> 42     */ | 
|---|
| 490 | RELOC_HLO10,                  /* data[0:9] = (addend + sv) >> 32      */ | 
|---|
| 491 |  | 
|---|
| 492 | /* 29K relocation types.  */ | 
|---|
| 493 | RELOC_JUMPTARG, | 
|---|
| 494 | RELOC_CONST, | 
|---|
| 495 | RELOC_CONSTH, | 
|---|
| 496 |  | 
|---|
| 497 | /* All the new ones I can think of, for sparc v9.  */ | 
|---|
| 498 | RELOC_64,                     /* data[0:63] = addend + sv             */ | 
|---|
| 499 | RELOC_DISP64,                 /* data[0:63] = addend - pc + sv        */ | 
|---|
| 500 | RELOC_WDISP21,                /* data[0:20] = (addend + sv - pc)>>2   */ | 
|---|
| 501 | RELOC_DISP21,                 /* data[0:20] = addend - pc + sv        */ | 
|---|
| 502 | RELOC_DISP14,                 /* data[0:13] = addend - pc + sv        */ | 
|---|
| 503 | /* Q . | 
|---|
| 504 | What are the other ones, | 
|---|
| 505 | Since this is a clean slate, can we throw away the ones we dont | 
|---|
| 506 | understand ? Should we sort the values ? What about using a | 
|---|
| 507 | microcode format like the 68k ?  */ | 
|---|
| 508 | NO_RELOC | 
|---|
| 509 | }; | 
|---|
| 510 |  | 
|---|
| 511 |  | 
|---|
| 512 | struct reloc_internal | 
|---|
| 513 | { | 
|---|
| 514 | bfd_vma r_address;            /* Offset of of data to relocate.  */ | 
|---|
| 515 | long  r_index;                /* Symbol table index of symbol.  */ | 
|---|
| 516 | enum reloc_type r_type;       /* Relocation type.  */ | 
|---|
| 517 | bfd_vma r_addend;             /* Datum addend.  */ | 
|---|
| 518 | }; | 
|---|
| 519 |  | 
|---|
| 520 | /* Q. | 
|---|
| 521 | Should the length of the string table be 4 bytes or 8 bytes ? | 
|---|
| 522 |  | 
|---|
| 523 | Q. | 
|---|
| 524 | What about archive indexes ?  */ | 
|---|
| 525 |  | 
|---|
| 526 | #endif                          /* __A_OUT_64_H__ */ | 
|---|