| 1 | /* A.out "format 1" file handling code for BFD. | 
|---|
| 2 | Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, | 
|---|
| 3 | 2001, 2002 | 
|---|
| 4 | Free Software Foundation, Inc. | 
|---|
| 5 | Written by Cygnus Support. | 
|---|
| 6 |  | 
|---|
| 7 | This file is part of BFD, the Binary File Descriptor library. | 
|---|
| 8 |  | 
|---|
| 9 | This program is free software; you can redistribute it and/or modify | 
|---|
| 10 | it under the terms of the GNU General Public License as published by | 
|---|
| 11 | the Free Software Foundation; either version 2 of the License, or | 
|---|
| 12 | (at your option) any later version. | 
|---|
| 13 |  | 
|---|
| 14 | This program is distributed in the hope that it will be useful, | 
|---|
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 17 | GNU General Public License for more details. | 
|---|
| 18 |  | 
|---|
| 19 | You should have received a copy of the GNU General Public License | 
|---|
| 20 | along with this program; if not, write to the Free Software | 
|---|
| 21 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */ | 
|---|
| 22 |  | 
|---|
| 23 | #include "bfd.h" | 
|---|
| 24 | #include "sysdep.h" | 
|---|
| 25 | #include "libbfd.h" | 
|---|
| 26 |  | 
|---|
| 27 | #include "aout/sun4.h" | 
|---|
| 28 | #include "libaout.h"            /* BFD a.out internal data structures */ | 
|---|
| 29 |  | 
|---|
| 30 | #include "aout/aout64.h" | 
|---|
| 31 | #include "aout/stab_gnu.h" | 
|---|
| 32 | #include "aout/ar.h" | 
|---|
| 33 |  | 
|---|
| 34 | /* This is needed to reject a NewsOS file, e.g. in | 
|---|
| 35 | gdb/testsuite/gdb.t10/crossload.exp. <kingdon@cygnus.com> | 
|---|
| 36 | I needed to add M_UNKNOWN to recognize a 68000 object, so this will | 
|---|
| 37 | probably no longer reject a NewsOS object.  <ian@cygnus.com>.  */ | 
|---|
| 38 | #ifndef MACHTYPE_OK | 
|---|
| 39 | #define MACHTYPE_OK(mtype) \ | 
|---|
| 40 | (((mtype) == M_SPARC && bfd_lookup_arch (bfd_arch_sparc, 0) != NULL) \ | 
|---|
| 41 | || (((mtype) == M_UNKNOWN || (mtype) == M_68010 || (mtype) == M_68020) \ | 
|---|
| 42 | && bfd_lookup_arch (bfd_arch_m68k, 0) != NULL)) | 
|---|
| 43 | #endif | 
|---|
| 44 |  | 
|---|
| 45 | /* | 
|---|
| 46 | The file @code{aoutf1.h} contains the code for BFD's | 
|---|
| 47 | a.out back end. Control over the generated back end is given by these | 
|---|
| 48 | two preprocessor names: | 
|---|
| 49 | @table @code | 
|---|
| 50 | @item ARCH_SIZE | 
|---|
| 51 | This value should be either 32 or 64, depending upon the size of an | 
|---|
| 52 | int in the target format. It changes the sizes of the structs which | 
|---|
| 53 | perform the memory/disk mapping of structures. | 
|---|
| 54 |  | 
|---|
| 55 | The 64 bit backend may only be used if the host compiler supports 64 | 
|---|
| 56 | ints (eg long long with gcc), by defining the name @code{BFD_HOST_64_BIT} in @code{bfd.h}. | 
|---|
| 57 | With this name defined, @emph{all} bfd operations are performed with 64bit | 
|---|
| 58 | arithmetic, not just those to a 64bit target. | 
|---|
| 59 |  | 
|---|
| 60 | @item TARGETNAME | 
|---|
| 61 | The name put into the target vector. | 
|---|
| 62 | @item | 
|---|
| 63 | @end table | 
|---|
| 64 |  | 
|---|
| 65 | */ | 
|---|
| 66 |  | 
|---|
| 67 | /*SUPPRESS558*/ | 
|---|
| 68 | /*SUPPRESS529*/ | 
|---|
| 69 |  | 
|---|
| 70 | #if ARCH_SIZE == 64 | 
|---|
| 71 | #define sunos_set_arch_mach sunos_64_set_arch_mach | 
|---|
| 72 | #define sunos_write_object_contents aout_64_sunos4_write_object_contents | 
|---|
| 73 | #else | 
|---|
| 74 | #define sunos_set_arch_mach sunos_32_set_arch_mach | 
|---|
| 75 | #define sunos_write_object_contents aout_32_sunos4_write_object_contents | 
|---|
| 76 | #endif | 
|---|
| 77 |  | 
|---|
| 78 | static bfd_boolean sunos_merge_private_bfd_data | 
|---|
| 79 | PARAMS ((bfd *, bfd *)); | 
|---|
| 80 | static void sunos_set_arch_mach | 
|---|
| 81 | PARAMS ((bfd *, enum machine_type)); | 
|---|
| 82 | static void choose_reloc_size | 
|---|
| 83 | PARAMS ((bfd *)); | 
|---|
| 84 | static bfd_boolean sunos_write_object_contents | 
|---|
| 85 | PARAMS ((bfd *)); | 
|---|
| 86 | static const bfd_target *sunos4_core_file_p | 
|---|
| 87 | PARAMS ((bfd *)); | 
|---|
| 88 | static char *sunos4_core_file_failing_command | 
|---|
| 89 | PARAMS ((bfd *)); | 
|---|
| 90 | static int sunos4_core_file_failing_signal | 
|---|
| 91 | PARAMS ((bfd *)); | 
|---|
| 92 | static bfd_boolean sunos4_core_file_matches_executable_p | 
|---|
| 93 | PARAMS ((bfd *, bfd *)); | 
|---|
| 94 | static bfd_boolean sunos4_set_sizes | 
|---|
| 95 | PARAMS ((bfd *)); | 
|---|
| 96 |  | 
|---|
| 97 | /* Merge backend data into the output file. | 
|---|
| 98 | This is necessary on sparclet-aout where we want the resultant machine | 
|---|
| 99 | number to be M_SPARCLET if any input file is M_SPARCLET.  */ | 
|---|
| 100 |  | 
|---|
| 101 | #define MY_bfd_merge_private_bfd_data sunos_merge_private_bfd_data | 
|---|
| 102 |  | 
|---|
| 103 | static bfd_boolean | 
|---|
| 104 | sunos_merge_private_bfd_data (ibfd, obfd) | 
|---|
| 105 | bfd *ibfd, *obfd; | 
|---|
| 106 | { | 
|---|
| 107 | if (bfd_get_flavour (ibfd) != bfd_target_aout_flavour | 
|---|
| 108 | || bfd_get_flavour (obfd) != bfd_target_aout_flavour) | 
|---|
| 109 | return TRUE; | 
|---|
| 110 |  | 
|---|
| 111 | if (bfd_get_arch (obfd) == bfd_arch_sparc) | 
|---|
| 112 | { | 
|---|
| 113 | if (bfd_get_mach (obfd) < bfd_get_mach (ibfd)) | 
|---|
| 114 | bfd_set_arch_mach (obfd, bfd_arch_sparc, bfd_get_mach (ibfd)); | 
|---|
| 115 | } | 
|---|
| 116 |  | 
|---|
| 117 | return TRUE; | 
|---|
| 118 | } | 
|---|
| 119 |  | 
|---|
| 120 | /* This is either sunos_32_set_arch_mach or sunos_64_set_arch_mach, | 
|---|
| 121 | depending upon ARCH_SIZE.  */ | 
|---|
| 122 |  | 
|---|
| 123 | static void | 
|---|
| 124 | sunos_set_arch_mach (abfd, machtype) | 
|---|
| 125 | bfd *abfd; | 
|---|
| 126 | enum machine_type machtype; | 
|---|
| 127 | { | 
|---|
| 128 | /* Determine the architecture and machine type of the object file.  */ | 
|---|
| 129 | enum bfd_architecture arch; | 
|---|
| 130 | unsigned long machine; | 
|---|
| 131 | switch (machtype) | 
|---|
| 132 | { | 
|---|
| 133 |  | 
|---|
| 134 | case M_UNKNOWN: | 
|---|
| 135 | /* Some Sun3s make magic numbers without cpu types in them, so | 
|---|
| 136 | we'll default to the 68000.  */ | 
|---|
| 137 | arch = bfd_arch_m68k; | 
|---|
| 138 | machine = bfd_mach_m68000; | 
|---|
| 139 | break; | 
|---|
| 140 |  | 
|---|
| 141 | case M_68010: | 
|---|
| 142 | case M_HP200: | 
|---|
| 143 | arch = bfd_arch_m68k; | 
|---|
| 144 | machine = bfd_mach_m68010; | 
|---|
| 145 | break; | 
|---|
| 146 |  | 
|---|
| 147 | case M_68020: | 
|---|
| 148 | case M_HP300: | 
|---|
| 149 | arch = bfd_arch_m68k; | 
|---|
| 150 | machine = bfd_mach_m68020; | 
|---|
| 151 | break; | 
|---|
| 152 |  | 
|---|
| 153 | case M_SPARC: | 
|---|
| 154 | arch = bfd_arch_sparc; | 
|---|
| 155 | machine = 0; | 
|---|
| 156 | break; | 
|---|
| 157 |  | 
|---|
| 158 | case M_SPARCLET: | 
|---|
| 159 | arch = bfd_arch_sparc; | 
|---|
| 160 | machine = bfd_mach_sparc_sparclet; | 
|---|
| 161 | break; | 
|---|
| 162 |  | 
|---|
| 163 | case M_SPARCLITE_LE: | 
|---|
| 164 | arch = bfd_arch_sparc; | 
|---|
| 165 | machine = bfd_mach_sparc_sparclite_le; | 
|---|
| 166 | break; | 
|---|
| 167 |  | 
|---|
| 168 | case M_386: | 
|---|
| 169 | case M_386_DYNIX: | 
|---|
| 170 | arch = bfd_arch_i386; | 
|---|
| 171 | machine = 0; | 
|---|
| 172 | break; | 
|---|
| 173 |  | 
|---|
| 174 | case M_29K: | 
|---|
| 175 | arch = bfd_arch_a29k; | 
|---|
| 176 | machine = 0; | 
|---|
| 177 | break; | 
|---|
| 178 |  | 
|---|
| 179 | case M_HPUX: | 
|---|
| 180 | arch = bfd_arch_m68k; | 
|---|
| 181 | machine = 0; | 
|---|
| 182 | break; | 
|---|
| 183 |  | 
|---|
| 184 | default: | 
|---|
| 185 | arch = bfd_arch_obscure; | 
|---|
| 186 | machine = 0; | 
|---|
| 187 | break; | 
|---|
| 188 | } | 
|---|
| 189 | bfd_set_arch_mach (abfd, arch, machine); | 
|---|
| 190 | } | 
|---|
| 191 |  | 
|---|
| 192 | #define SET_ARCH_MACH(ABFD, EXEC) \ | 
|---|
| 193 | NAME(sunos,set_arch_mach) (ABFD, N_MACHTYPE (EXEC)); \ | 
|---|
| 194 | choose_reloc_size(ABFD); | 
|---|
| 195 |  | 
|---|
| 196 | /* Determine the size of a relocation entry, based on the architecture */ | 
|---|
| 197 | static void | 
|---|
| 198 | choose_reloc_size (abfd) | 
|---|
| 199 | bfd *abfd; | 
|---|
| 200 | { | 
|---|
| 201 | switch (bfd_get_arch (abfd)) | 
|---|
| 202 | { | 
|---|
| 203 | case bfd_arch_sparc: | 
|---|
| 204 | case bfd_arch_a29k: | 
|---|
| 205 | obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE; | 
|---|
| 206 | break; | 
|---|
| 207 | default: | 
|---|
| 208 | obj_reloc_entry_size (abfd) = RELOC_STD_SIZE; | 
|---|
| 209 | break; | 
|---|
| 210 | } | 
|---|
| 211 | } | 
|---|
| 212 |  | 
|---|
| 213 | /* Write an object file in SunOS format.  Section contents have | 
|---|
| 214 | already been written.  We write the file header, symbols, and | 
|---|
| 215 | relocation.  The real name of this function is either | 
|---|
| 216 | aout_64_sunos4_write_object_contents or | 
|---|
| 217 | aout_32_sunos4_write_object_contents, depending upon ARCH_SIZE.  */ | 
|---|
| 218 |  | 
|---|
| 219 | static bfd_boolean | 
|---|
| 220 | sunos_write_object_contents (abfd) | 
|---|
| 221 | bfd *abfd; | 
|---|
| 222 | { | 
|---|
| 223 | struct external_exec exec_bytes; | 
|---|
| 224 | struct internal_exec *execp = exec_hdr (abfd); | 
|---|
| 225 |  | 
|---|
| 226 | /* Magic number, maestro, please!  */ | 
|---|
| 227 | switch (bfd_get_arch (abfd)) | 
|---|
| 228 | { | 
|---|
| 229 | case bfd_arch_m68k: | 
|---|
| 230 | switch (bfd_get_mach (abfd)) | 
|---|
| 231 | { | 
|---|
| 232 | case bfd_mach_m68000: | 
|---|
| 233 | N_SET_MACHTYPE (*execp, M_UNKNOWN); | 
|---|
| 234 | break; | 
|---|
| 235 | case bfd_mach_m68010: | 
|---|
| 236 | N_SET_MACHTYPE (*execp, M_68010); | 
|---|
| 237 | break; | 
|---|
| 238 | default: | 
|---|
| 239 | case bfd_mach_m68020: | 
|---|
| 240 | N_SET_MACHTYPE (*execp, M_68020); | 
|---|
| 241 | break; | 
|---|
| 242 | } | 
|---|
| 243 | break; | 
|---|
| 244 | case bfd_arch_sparc: | 
|---|
| 245 | switch (bfd_get_mach (abfd)) | 
|---|
| 246 | { | 
|---|
| 247 | case bfd_mach_sparc_sparclet: | 
|---|
| 248 | N_SET_MACHTYPE (*execp, M_SPARCLET); | 
|---|
| 249 | break; | 
|---|
| 250 | case bfd_mach_sparc_sparclite_le: | 
|---|
| 251 | N_SET_MACHTYPE (*execp, M_SPARCLITE_LE); | 
|---|
| 252 | break; | 
|---|
| 253 | default: | 
|---|
| 254 | N_SET_MACHTYPE (*execp, M_SPARC); | 
|---|
| 255 | break; | 
|---|
| 256 | } | 
|---|
| 257 | break; | 
|---|
| 258 | case bfd_arch_i386: | 
|---|
| 259 | N_SET_MACHTYPE (*execp, M_386); | 
|---|
| 260 | break; | 
|---|
| 261 | case bfd_arch_a29k: | 
|---|
| 262 | N_SET_MACHTYPE (*execp, M_29K); | 
|---|
| 263 | break; | 
|---|
| 264 | default: | 
|---|
| 265 | N_SET_MACHTYPE (*execp, M_UNKNOWN); | 
|---|
| 266 | } | 
|---|
| 267 |  | 
|---|
| 268 | choose_reloc_size (abfd); | 
|---|
| 269 |  | 
|---|
| 270 | N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags); | 
|---|
| 271 |  | 
|---|
| 272 | N_SET_DYNAMIC (*execp, (long)(bfd_get_file_flags (abfd) & DYNAMIC)); | 
|---|
| 273 |  | 
|---|
| 274 | WRITE_HEADERS (abfd, execp); | 
|---|
| 275 |  | 
|---|
| 276 | return TRUE; | 
|---|
| 277 | } | 
|---|
| 278 |  | 
|---|
| 279 |  | 
|---|
| 280 | /* core files */ | 
|---|
| 281 |  | 
|---|
| 282 | #define CORE_MAGIC 0x080456 | 
|---|
| 283 | #define CORE_NAMELEN 16 | 
|---|
| 284 |  | 
|---|
| 285 | /* The core structure is taken from the Sun documentation. | 
|---|
| 286 | Unfortunately, they don't document the FPA structure, or at least I | 
|---|
| 287 | can't find it easily.  Fortunately the core header contains its own | 
|---|
| 288 | length.  So this shouldn't cause problems, except for c_ucode, which | 
|---|
| 289 | so far we don't use but is easy to find with a little arithmetic.  */ | 
|---|
| 290 |  | 
|---|
| 291 | /* But the reg structure can be gotten from the SPARC processor handbook. | 
|---|
| 292 | This really should be in a GNU include file though so that gdb can use | 
|---|
| 293 | the same info.  */ | 
|---|
| 294 | struct regs | 
|---|
| 295 | { | 
|---|
| 296 | int r_psr; | 
|---|
| 297 | int r_pc; | 
|---|
| 298 | int r_npc; | 
|---|
| 299 | int r_y; | 
|---|
| 300 | int r_g1; | 
|---|
| 301 | int r_g2; | 
|---|
| 302 | int r_g3; | 
|---|
| 303 | int r_g4; | 
|---|
| 304 | int r_g5; | 
|---|
| 305 | int r_g6; | 
|---|
| 306 | int r_g7; | 
|---|
| 307 | int r_o0; | 
|---|
| 308 | int r_o1; | 
|---|
| 309 | int r_o2; | 
|---|
| 310 | int r_o3; | 
|---|
| 311 | int r_o4; | 
|---|
| 312 | int r_o5; | 
|---|
| 313 | int r_o6; | 
|---|
| 314 | int r_o7; | 
|---|
| 315 | }; | 
|---|
| 316 |  | 
|---|
| 317 | /* Taken from Sun documentation: */ | 
|---|
| 318 |  | 
|---|
| 319 | /* FIXME:  It's worse than we expect.  This struct contains TWO substructs | 
|---|
| 320 | neither of whose size we know, WITH STUFF IN BETWEEN THEM!  We can't | 
|---|
| 321 | even portably access the stuff in between!  */ | 
|---|
| 322 |  | 
|---|
| 323 | struct external_sparc_core | 
|---|
| 324 | { | 
|---|
| 325 | int c_magic;                /* Corefile magic number */ | 
|---|
| 326 | int c_len;                  /* Sizeof (struct core) */ | 
|---|
| 327 | #define SPARC_CORE_LEN  432 | 
|---|
| 328 | int c_regs[19];             /* General purpose registers -- MACHDEP SIZE */ | 
|---|
| 329 | struct external_exec c_aouthdr;     /* A.out header */ | 
|---|
| 330 | int c_signo;                /* Killing signal, if any */ | 
|---|
| 331 | int c_tsize;                /* Text size (bytes) */ | 
|---|
| 332 | int c_dsize;                /* Data size (bytes) */ | 
|---|
| 333 | int c_ssize;                /* Stack size (bytes) */ | 
|---|
| 334 | char c_cmdname[CORE_NAMELEN + 1];   /* Command name */ | 
|---|
| 335 | double fp_stuff[1];         /* external FPU state (size unknown by us) */ | 
|---|
| 336 | /* The type "double" is critical here, for alignment. | 
|---|
| 337 | SunOS declares a struct here, but the struct's alignment | 
|---|
| 338 | is double since it contains doubles.  */ | 
|---|
| 339 | int c_ucode;                /* Exception no. from u_code */ | 
|---|
| 340 | /* (this member is not accessible by name since we don't | 
|---|
| 341 | portably know the size of fp_stuff.) */ | 
|---|
| 342 | }; | 
|---|
| 343 |  | 
|---|
| 344 | /* Core files generated by the BCP (the part of Solaris which allows | 
|---|
| 345 | it to run SunOS4 a.out files).  */ | 
|---|
| 346 | struct external_solaris_bcp_core | 
|---|
| 347 | { | 
|---|
| 348 | int c_magic;                /* Corefile magic number */ | 
|---|
| 349 | int c_len;                  /* Sizeof (struct core) */ | 
|---|
| 350 | #define SOLARIS_BCP_CORE_LEN    456 | 
|---|
| 351 | int c_regs[19];             /* General purpose registers -- MACHDEP SIZE */ | 
|---|
| 352 | int c_exdata_vp;            /* exdata structure */ | 
|---|
| 353 | int c_exdata_tsize; | 
|---|
| 354 | int c_exdata_dsize; | 
|---|
| 355 | int c_exdata_bsize; | 
|---|
| 356 | int c_exdata_lsize; | 
|---|
| 357 | int c_exdata_nshlibs; | 
|---|
| 358 | short c_exdata_mach; | 
|---|
| 359 | short c_exdata_mag; | 
|---|
| 360 | int c_exdata_toffset; | 
|---|
| 361 | int c_exdata_doffset; | 
|---|
| 362 | int c_exdata_loffset; | 
|---|
| 363 | int c_exdata_txtorg; | 
|---|
| 364 | int c_exdata_datorg; | 
|---|
| 365 | int c_exdata_entloc; | 
|---|
| 366 | int c_signo;                /* Killing signal, if any */ | 
|---|
| 367 | int c_tsize;                /* Text size (bytes) */ | 
|---|
| 368 | int c_dsize;                /* Data size (bytes) */ | 
|---|
| 369 | int c_ssize;                /* Stack size (bytes) */ | 
|---|
| 370 | char c_cmdname[CORE_NAMELEN + 1];   /* Command name */ | 
|---|
| 371 | double fp_stuff[1];         /* external FPU state (size unknown by us) */ | 
|---|
| 372 | /* The type "double" is critical here, for alignment. | 
|---|
| 373 | SunOS declares a struct here, but the struct's alignment | 
|---|
| 374 | is double since it contains doubles.  */ | 
|---|
| 375 | int c_ucode;                /* Exception no. from u_code */ | 
|---|
| 376 | /* (this member is not accessible by name since we don't | 
|---|
| 377 | portably know the size of fp_stuff.) */ | 
|---|
| 378 | }; | 
|---|
| 379 |  | 
|---|
| 380 | struct external_sun3_core | 
|---|
| 381 | { | 
|---|
| 382 | int c_magic;                /* Corefile magic number */ | 
|---|
| 383 | int c_len;                  /* Sizeof (struct core) */ | 
|---|
| 384 | #define SUN3_CORE_LEN   826     /* As of SunOS 4.1.1 */ | 
|---|
| 385 | int c_regs[18];             /* General purpose registers -- MACHDEP SIZE */ | 
|---|
| 386 | struct external_exec c_aouthdr;     /* A.out header */ | 
|---|
| 387 | int c_signo;                /* Killing signal, if any */ | 
|---|
| 388 | int c_tsize;                /* Text size (bytes) */ | 
|---|
| 389 | int c_dsize;                /* Data size (bytes) */ | 
|---|
| 390 | int c_ssize;                /* Stack size (bytes) */ | 
|---|
| 391 | char c_cmdname[CORE_NAMELEN + 1];   /* Command name */ | 
|---|
| 392 | double fp_stuff[1];         /* external FPU state (size unknown by us) */ | 
|---|
| 393 | /* The type "double" is critical here, for alignment. | 
|---|
| 394 | SunOS declares a struct here, but the struct's alignment | 
|---|
| 395 | is double since it contains doubles.  */ | 
|---|
| 396 | int c_ucode;                /* Exception no. from u_code */ | 
|---|
| 397 | /* (this member is not accessible by name since we don't | 
|---|
| 398 | portably know the size of fp_stuff.) */ | 
|---|
| 399 | }; | 
|---|
| 400 |  | 
|---|
| 401 | struct internal_sunos_core | 
|---|
| 402 | { | 
|---|
| 403 | int c_magic;                /* Corefile magic number */ | 
|---|
| 404 | int c_len;                  /* Sizeof (struct core) */ | 
|---|
| 405 | long c_regs_pos;            /* file offset of General purpose registers */ | 
|---|
| 406 | int c_regs_size;            /* size of General purpose registers */ | 
|---|
| 407 | struct internal_exec c_aouthdr;     /* A.out header */ | 
|---|
| 408 | int c_signo;                /* Killing signal, if any */ | 
|---|
| 409 | int c_tsize;                /* Text size (bytes) */ | 
|---|
| 410 | int c_dsize;                /* Data size (bytes) */ | 
|---|
| 411 | bfd_vma c_data_addr;        /* Data start (address) */ | 
|---|
| 412 | int c_ssize;                /* Stack size (bytes) */ | 
|---|
| 413 | bfd_vma c_stacktop;         /* Stack top (address) */ | 
|---|
| 414 | char c_cmdname[CORE_NAMELEN + 1];   /* Command name */ | 
|---|
| 415 | long fp_stuff_pos;          /* file offset of external FPU state (regs) */ | 
|---|
| 416 | int fp_stuff_size;          /* Size of it */ | 
|---|
| 417 | int c_ucode;                /* Exception no. from u_code */ | 
|---|
| 418 | }; | 
|---|
| 419 |  | 
|---|
| 420 | static void swapcore_sun3 | 
|---|
| 421 | PARAMS ((bfd *, char *, struct internal_sunos_core *)); | 
|---|
| 422 | static void swapcore_sparc | 
|---|
| 423 | PARAMS ((bfd *, char *, struct internal_sunos_core *)); | 
|---|
| 424 | static void swapcore_solaris_bcp | 
|---|
| 425 | PARAMS ((bfd *, char *, struct internal_sunos_core *)); | 
|---|
| 426 |  | 
|---|
| 427 | /* byte-swap in the Sun-3 core structure */ | 
|---|
| 428 | static void | 
|---|
| 429 | swapcore_sun3 (abfd, ext, intcore) | 
|---|
| 430 | bfd *abfd; | 
|---|
| 431 | char *ext; | 
|---|
| 432 | struct internal_sunos_core *intcore; | 
|---|
| 433 | { | 
|---|
| 434 | struct external_sun3_core *extcore = (struct external_sun3_core *) ext; | 
|---|
| 435 |  | 
|---|
| 436 | intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic); | 
|---|
| 437 | intcore->c_len = H_GET_32 (abfd, &extcore->c_len); | 
|---|
| 438 | intcore->c_regs_pos = (long) (((struct external_sun3_core *) 0)->c_regs); | 
|---|
| 439 | intcore->c_regs_size = sizeof (extcore->c_regs); | 
|---|
| 440 | #if ARCH_SIZE == 64 | 
|---|
| 441 | aout_64_swap_exec_header_in | 
|---|
| 442 | #else | 
|---|
| 443 | aout_32_swap_exec_header_in | 
|---|
| 444 | #endif | 
|---|
| 445 | (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr); | 
|---|
| 446 | intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo); | 
|---|
| 447 | intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize); | 
|---|
| 448 | intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize); | 
|---|
| 449 | intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr); | 
|---|
| 450 | intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize); | 
|---|
| 451 | memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname)); | 
|---|
| 452 | intcore->fp_stuff_pos = (long) (((struct external_sun3_core *) 0)->fp_stuff); | 
|---|
| 453 | /* FP stuff takes up whole rest of struct, except c_ucode.  */ | 
|---|
| 454 | intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) - | 
|---|
| 455 | (file_ptr) (((struct external_sun3_core *) 0)->fp_stuff); | 
|---|
| 456 | /* Ucode is the last thing in the struct -- just before the end */ | 
|---|
| 457 | intcore->c_ucode = H_GET_32 (abfd, | 
|---|
| 458 | (intcore->c_len | 
|---|
| 459 | - sizeof (extcore->c_ucode) | 
|---|
| 460 | + (unsigned char *) extcore)); | 
|---|
| 461 | intcore->c_stacktop = 0x0E000000;     /* By experimentation */ | 
|---|
| 462 | } | 
|---|
| 463 |  | 
|---|
| 464 | /* byte-swap in the Sparc core structure */ | 
|---|
| 465 | static void | 
|---|
| 466 | swapcore_sparc (abfd, ext, intcore) | 
|---|
| 467 | bfd *abfd; | 
|---|
| 468 | char *ext; | 
|---|
| 469 | struct internal_sunos_core *intcore; | 
|---|
| 470 | { | 
|---|
| 471 | struct external_sparc_core *extcore = (struct external_sparc_core *) ext; | 
|---|
| 472 |  | 
|---|
| 473 | intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic); | 
|---|
| 474 | intcore->c_len = H_GET_32 (abfd, &extcore->c_len); | 
|---|
| 475 | intcore->c_regs_pos = (long) (((struct external_sparc_core *) 0)->c_regs); | 
|---|
| 476 | intcore->c_regs_size = sizeof (extcore->c_regs); | 
|---|
| 477 | #if ARCH_SIZE == 64 | 
|---|
| 478 | aout_64_swap_exec_header_in | 
|---|
| 479 | #else | 
|---|
| 480 | aout_32_swap_exec_header_in | 
|---|
| 481 | #endif | 
|---|
| 482 | (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr); | 
|---|
| 483 | intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo); | 
|---|
| 484 | intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize); | 
|---|
| 485 | intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize); | 
|---|
| 486 | intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr); | 
|---|
| 487 | intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize); | 
|---|
| 488 | memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname)); | 
|---|
| 489 | intcore->fp_stuff_pos = (long) (((struct external_sparc_core *) 0)->fp_stuff); | 
|---|
| 490 | /* FP stuff takes up whole rest of struct, except c_ucode.  */ | 
|---|
| 491 | intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) - | 
|---|
| 492 | (file_ptr) (((struct external_sparc_core *) 0)->fp_stuff); | 
|---|
| 493 | /* Ucode is the last thing in the struct -- just before the end */ | 
|---|
| 494 | intcore->c_ucode = H_GET_32 (abfd, | 
|---|
| 495 | (intcore->c_len | 
|---|
| 496 | - sizeof (extcore->c_ucode) | 
|---|
| 497 | + (unsigned char *) extcore)); | 
|---|
| 498 |  | 
|---|
| 499 | /* Supposedly the user stack grows downward from the bottom of kernel memory. | 
|---|
| 500 | Presuming that this remains true, this definition will work.  */ | 
|---|
| 501 | /* Now sun has provided us with another challenge.  The value is different | 
|---|
| 502 | for sparc2 and sparc10 (both running SunOS 4.1.3).  We pick one or | 
|---|
| 503 | the other based on the current value of the stack pointer.  This | 
|---|
| 504 | loses (a) if the stack pointer has been clobbered, or (b) if the stack | 
|---|
| 505 | is larger than 128 megabytes. | 
|---|
| 506 |  | 
|---|
| 507 | It's times like these you're glad they're switching to ELF. | 
|---|
| 508 |  | 
|---|
| 509 | Note that using include files or nlist on /vmunix would be wrong, | 
|---|
| 510 | because we want the value for this core file, no matter what kind of | 
|---|
| 511 | machine we were compiled on or are running on.  */ | 
|---|
| 512 | #define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000) | 
|---|
| 513 | #define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000) | 
|---|
| 514 | { | 
|---|
| 515 | bfd_vma sp = H_GET_32 (abfd, &((struct regs *) &extcore->c_regs[0])->r_o6); | 
|---|
| 516 | if (sp < SPARC_USRSTACK_SPARC10) | 
|---|
| 517 | intcore->c_stacktop = SPARC_USRSTACK_SPARC10; | 
|---|
| 518 | else | 
|---|
| 519 | intcore->c_stacktop = SPARC_USRSTACK_SPARC2; | 
|---|
| 520 | } | 
|---|
| 521 | } | 
|---|
| 522 |  | 
|---|
| 523 | /* byte-swap in the Solaris BCP core structure */ | 
|---|
| 524 | static void | 
|---|
| 525 | swapcore_solaris_bcp (abfd, ext, intcore) | 
|---|
| 526 | bfd *abfd; | 
|---|
| 527 | char *ext; | 
|---|
| 528 | struct internal_sunos_core *intcore; | 
|---|
| 529 | { | 
|---|
| 530 | struct external_solaris_bcp_core *extcore = | 
|---|
| 531 | (struct external_solaris_bcp_core *) ext; | 
|---|
| 532 |  | 
|---|
| 533 | intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic); | 
|---|
| 534 | intcore->c_len = H_GET_32 (abfd, &extcore->c_len); | 
|---|
| 535 | intcore->c_regs_pos = (long) (((struct external_solaris_bcp_core *) 0)->c_regs); | 
|---|
| 536 | intcore->c_regs_size = sizeof (extcore->c_regs); | 
|---|
| 537 |  | 
|---|
| 538 | /* The Solaris BCP exdata structure does not contain an a_syms field, | 
|---|
| 539 | so we are unable to synthesize an internal exec header. | 
|---|
| 540 | Luckily we are able to figure out the start address of the data section, | 
|---|
| 541 | which is the only thing needed from the internal exec header, | 
|---|
| 542 | from the exdata structure. | 
|---|
| 543 |  | 
|---|
| 544 | As of Solaris 2.3, BCP core files for statically linked executables | 
|---|
| 545 | are buggy. The exdata structure is not properly filled in, and | 
|---|
| 546 | the data section is written from address zero instead of the data | 
|---|
| 547 | start address.  */ | 
|---|
| 548 | memset ((PTR) &intcore->c_aouthdr, 0, sizeof (struct internal_exec)); | 
|---|
| 549 | intcore->c_data_addr = H_GET_32 (abfd, &extcore->c_exdata_datorg); | 
|---|
| 550 | intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo); | 
|---|
| 551 | intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize); | 
|---|
| 552 | intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize); | 
|---|
| 553 | intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize); | 
|---|
| 554 | memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname)); | 
|---|
| 555 | intcore->fp_stuff_pos = | 
|---|
| 556 | (long) (((struct external_solaris_bcp_core *) 0)->fp_stuff); | 
|---|
| 557 | /* FP stuff takes up whole rest of struct, except c_ucode.  */ | 
|---|
| 558 | intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) - | 
|---|
| 559 | (file_ptr) (((struct external_solaris_bcp_core *) 0)->fp_stuff); | 
|---|
| 560 | /* Ucode is the last thing in the struct -- just before the end */ | 
|---|
| 561 | intcore->c_ucode = H_GET_32 (abfd, | 
|---|
| 562 | (intcore->c_len | 
|---|
| 563 | - sizeof (extcore->c_ucode) | 
|---|
| 564 | + (unsigned char *) extcore)); | 
|---|
| 565 |  | 
|---|
| 566 | /* Supposedly the user stack grows downward from the bottom of kernel memory. | 
|---|
| 567 | Presuming that this remains true, this definition will work.  */ | 
|---|
| 568 | /* Now sun has provided us with another challenge.  The value is different | 
|---|
| 569 | for sparc2 and sparc10 (both running SunOS 4.1.3).  We pick one or | 
|---|
| 570 | the other based on the current value of the stack pointer.  This | 
|---|
| 571 | loses (a) if the stack pointer has been clobbered, or (b) if the stack | 
|---|
| 572 | is larger than 128 megabytes. | 
|---|
| 573 |  | 
|---|
| 574 | It's times like these you're glad they're switching to ELF. | 
|---|
| 575 |  | 
|---|
| 576 | Note that using include files or nlist on /vmunix would be wrong, | 
|---|
| 577 | because we want the value for this core file, no matter what kind of | 
|---|
| 578 | machine we were compiled on or are running on.  */ | 
|---|
| 579 | #define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000) | 
|---|
| 580 | #define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000) | 
|---|
| 581 | { | 
|---|
| 582 | bfd_vma sp = H_GET_32 (abfd, &((struct regs *) &extcore->c_regs[0])->r_o6); | 
|---|
| 583 | if (sp < SPARC_USRSTACK_SPARC10) | 
|---|
| 584 | intcore->c_stacktop = SPARC_USRSTACK_SPARC10; | 
|---|
| 585 | else | 
|---|
| 586 | intcore->c_stacktop = SPARC_USRSTACK_SPARC2; | 
|---|
| 587 | } | 
|---|
| 588 | } | 
|---|
| 589 |  | 
|---|
| 590 | /* need this cast because ptr is really void * */ | 
|---|
| 591 | #define core_hdr(bfd) ((bfd)->tdata.sun_core_data) | 
|---|
| 592 | #define core_datasec(bfd) (core_hdr(bfd)->data_section) | 
|---|
| 593 | #define core_stacksec(bfd) (core_hdr(bfd)->stack_section) | 
|---|
| 594 | #define core_regsec(bfd) (core_hdr(bfd)->reg_section) | 
|---|
| 595 | #define core_reg2sec(bfd) (core_hdr(bfd)->reg2_section) | 
|---|
| 596 |  | 
|---|
| 597 | /* These are stored in the bfd's tdata */ | 
|---|
| 598 | struct sun_core_struct | 
|---|
| 599 | { | 
|---|
| 600 | struct internal_sunos_core *hdr;      /* core file header */ | 
|---|
| 601 | asection *data_section; | 
|---|
| 602 | asection *stack_section; | 
|---|
| 603 | asection *reg_section; | 
|---|
| 604 | asection *reg2_section; | 
|---|
| 605 | }; | 
|---|
| 606 |  | 
|---|
| 607 | static const bfd_target * | 
|---|
| 608 | sunos4_core_file_p (abfd) | 
|---|
| 609 | bfd *abfd; | 
|---|
| 610 | { | 
|---|
| 611 | unsigned char longbuf[4];     /* Raw bytes of various header fields */ | 
|---|
| 612 | bfd_size_type core_size, amt; | 
|---|
| 613 | unsigned long core_mag; | 
|---|
| 614 | struct internal_sunos_core *core; | 
|---|
| 615 | char *extcore; | 
|---|
| 616 | struct mergem | 
|---|
| 617 | { | 
|---|
| 618 | struct sun_core_struct suncoredata; | 
|---|
| 619 | struct internal_sunos_core internal_sunos_core; | 
|---|
| 620 | char external_core[1]; | 
|---|
| 621 | } *mergem; | 
|---|
| 622 |  | 
|---|
| 623 | if (bfd_bread ((PTR) longbuf, (bfd_size_type) sizeof (longbuf), abfd) | 
|---|
| 624 | != sizeof (longbuf)) | 
|---|
| 625 | return 0; | 
|---|
| 626 | core_mag = H_GET_32 (abfd, longbuf); | 
|---|
| 627 |  | 
|---|
| 628 | if (core_mag != CORE_MAGIC) | 
|---|
| 629 | return 0; | 
|---|
| 630 |  | 
|---|
| 631 | /* SunOS core headers can vary in length; second word is size; */ | 
|---|
| 632 | if (bfd_bread ((PTR) longbuf, (bfd_size_type) sizeof (longbuf), abfd) | 
|---|
| 633 | != sizeof (longbuf)) | 
|---|
| 634 | return 0; | 
|---|
| 635 | core_size = H_GET_32 (abfd, longbuf); | 
|---|
| 636 | /* Sanity check */ | 
|---|
| 637 | if (core_size > 20000) | 
|---|
| 638 | return 0; | 
|---|
| 639 |  | 
|---|
| 640 | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) | 
|---|
| 641 | return 0; | 
|---|
| 642 |  | 
|---|
| 643 | amt = core_size + sizeof (struct mergem); | 
|---|
| 644 | mergem = (struct mergem *) bfd_zalloc (abfd, amt); | 
|---|
| 645 | if (mergem == NULL) | 
|---|
| 646 | return 0; | 
|---|
| 647 |  | 
|---|
| 648 | extcore = mergem->external_core; | 
|---|
| 649 |  | 
|---|
| 650 | if ((bfd_bread ((PTR) extcore, core_size, abfd)) != core_size) | 
|---|
| 651 | { | 
|---|
| 652 | loser: | 
|---|
| 653 | bfd_release (abfd, (char *) mergem); | 
|---|
| 654 | abfd->tdata.any = NULL; | 
|---|
| 655 | bfd_section_list_clear (abfd); | 
|---|
| 656 | return 0; | 
|---|
| 657 | } | 
|---|
| 658 |  | 
|---|
| 659 | /* Validate that it's a core file we know how to handle, due to sun | 
|---|
| 660 | botching the positioning of registers and other fields in a machine | 
|---|
| 661 | dependent way.  */ | 
|---|
| 662 | core = &mergem->internal_sunos_core; | 
|---|
| 663 | switch (core_size) | 
|---|
| 664 | { | 
|---|
| 665 | case SPARC_CORE_LEN: | 
|---|
| 666 | swapcore_sparc (abfd, extcore, core); | 
|---|
| 667 | break; | 
|---|
| 668 | case SUN3_CORE_LEN: | 
|---|
| 669 | swapcore_sun3 (abfd, extcore, core); | 
|---|
| 670 | break; | 
|---|
| 671 | case SOLARIS_BCP_CORE_LEN: | 
|---|
| 672 | swapcore_solaris_bcp (abfd, extcore, core); | 
|---|
| 673 | break; | 
|---|
| 674 | default: | 
|---|
| 675 | bfd_set_error (bfd_error_system_call);    /* FIXME */ | 
|---|
| 676 | goto loser; | 
|---|
| 677 | } | 
|---|
| 678 |  | 
|---|
| 679 | abfd->tdata.sun_core_data = &mergem->suncoredata; | 
|---|
| 680 | abfd->tdata.sun_core_data->hdr = core; | 
|---|
| 681 |  | 
|---|
| 682 | /* Create the sections.  */ | 
|---|
| 683 | core_stacksec (abfd) = bfd_make_section_anyway (abfd, ".stack"); | 
|---|
| 684 | if (core_stacksec (abfd) == NULL) | 
|---|
| 685 | /* bfd_release frees everything allocated after it's arg.  */ | 
|---|
| 686 | goto loser; | 
|---|
| 687 |  | 
|---|
| 688 | core_datasec (abfd) = bfd_make_section_anyway (abfd, ".data"); | 
|---|
| 689 | if (core_datasec (abfd) == NULL) | 
|---|
| 690 | goto loser; | 
|---|
| 691 |  | 
|---|
| 692 | core_regsec (abfd) = bfd_make_section_anyway (abfd, ".reg"); | 
|---|
| 693 | if (core_regsec (abfd) == NULL) | 
|---|
| 694 | goto loser; | 
|---|
| 695 |  | 
|---|
| 696 | core_reg2sec (abfd) = bfd_make_section_anyway (abfd, ".reg2"); | 
|---|
| 697 | if (core_reg2sec (abfd) == NULL) | 
|---|
| 698 | goto loser; | 
|---|
| 699 |  | 
|---|
| 700 | core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS; | 
|---|
| 701 | core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS; | 
|---|
| 702 | core_regsec (abfd)->flags = SEC_HAS_CONTENTS; | 
|---|
| 703 | core_reg2sec (abfd)->flags = SEC_HAS_CONTENTS; | 
|---|
| 704 |  | 
|---|
| 705 | core_stacksec (abfd)->_raw_size = core->c_ssize; | 
|---|
| 706 | core_datasec (abfd)->_raw_size = core->c_dsize; | 
|---|
| 707 | core_regsec (abfd)->_raw_size = core->c_regs_size; | 
|---|
| 708 | core_reg2sec (abfd)->_raw_size = core->fp_stuff_size; | 
|---|
| 709 |  | 
|---|
| 710 | core_stacksec (abfd)->vma = (core->c_stacktop - core->c_ssize); | 
|---|
| 711 | core_datasec (abfd)->vma = core->c_data_addr; | 
|---|
| 712 | core_regsec (abfd)->vma = 0; | 
|---|
| 713 | core_reg2sec (abfd)->vma = 0; | 
|---|
| 714 |  | 
|---|
| 715 | core_stacksec (abfd)->filepos = core->c_len + core->c_dsize; | 
|---|
| 716 | core_datasec (abfd)->filepos = core->c_len; | 
|---|
| 717 | /* We'll access the regs afresh in the core file, like any section: */ | 
|---|
| 718 | core_regsec (abfd)->filepos = (file_ptr) core->c_regs_pos; | 
|---|
| 719 | core_reg2sec (abfd)->filepos = (file_ptr) core->fp_stuff_pos; | 
|---|
| 720 |  | 
|---|
| 721 | /* Align to word at least */ | 
|---|
| 722 | core_stacksec (abfd)->alignment_power = 2; | 
|---|
| 723 | core_datasec (abfd)->alignment_power = 2; | 
|---|
| 724 | core_regsec (abfd)->alignment_power = 2; | 
|---|
| 725 | core_reg2sec (abfd)->alignment_power = 2; | 
|---|
| 726 |  | 
|---|
| 727 | return abfd->xvec; | 
|---|
| 728 | } | 
|---|
| 729 |  | 
|---|
| 730 | static char * | 
|---|
| 731 | sunos4_core_file_failing_command (abfd) | 
|---|
| 732 | bfd *abfd; | 
|---|
| 733 | { | 
|---|
| 734 | return core_hdr (abfd)->hdr->c_cmdname; | 
|---|
| 735 | } | 
|---|
| 736 |  | 
|---|
| 737 | static int | 
|---|
| 738 | sunos4_core_file_failing_signal (abfd) | 
|---|
| 739 | bfd *abfd; | 
|---|
| 740 | { | 
|---|
| 741 | return core_hdr (abfd)->hdr->c_signo; | 
|---|
| 742 | } | 
|---|
| 743 |  | 
|---|
| 744 | static bfd_boolean | 
|---|
| 745 | sunos4_core_file_matches_executable_p (core_bfd, exec_bfd) | 
|---|
| 746 | bfd *core_bfd; | 
|---|
| 747 | bfd *exec_bfd; | 
|---|
| 748 | { | 
|---|
| 749 | if (core_bfd->xvec != exec_bfd->xvec) | 
|---|
| 750 | { | 
|---|
| 751 | bfd_set_error (bfd_error_system_call); | 
|---|
| 752 | return FALSE; | 
|---|
| 753 | } | 
|---|
| 754 |  | 
|---|
| 755 | /* Solaris core files do not include an aouthdr.  */ | 
|---|
| 756 | if ((core_hdr (core_bfd)->hdr)->c_len == SOLARIS_BCP_CORE_LEN) | 
|---|
| 757 | return TRUE; | 
|---|
| 758 |  | 
|---|
| 759 | return (memcmp ((char *) &((core_hdr (core_bfd)->hdr)->c_aouthdr), | 
|---|
| 760 | (char *) exec_hdr (exec_bfd), | 
|---|
| 761 | sizeof (struct internal_exec)) == 0); | 
|---|
| 762 | } | 
|---|
| 763 |  | 
|---|
| 764 | #define MY_set_sizes sunos4_set_sizes | 
|---|
| 765 | static bfd_boolean | 
|---|
| 766 | sunos4_set_sizes (abfd) | 
|---|
| 767 | bfd *abfd; | 
|---|
| 768 | { | 
|---|
| 769 | switch (bfd_get_arch (abfd)) | 
|---|
| 770 | { | 
|---|
| 771 | default: | 
|---|
| 772 | return FALSE; | 
|---|
| 773 | case bfd_arch_sparc: | 
|---|
| 774 | adata (abfd).page_size = 0x2000; | 
|---|
| 775 | adata (abfd).segment_size = 0x2000; | 
|---|
| 776 | adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE; | 
|---|
| 777 | return TRUE; | 
|---|
| 778 | case bfd_arch_m68k: | 
|---|
| 779 | adata (abfd).page_size = 0x2000; | 
|---|
| 780 | adata (abfd).segment_size = 0x20000; | 
|---|
| 781 | adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE; | 
|---|
| 782 | return TRUE; | 
|---|
| 783 | } | 
|---|
| 784 | } | 
|---|
| 785 |  | 
|---|
| 786 | /* We default to setting the toolversion field to 1, as is required by | 
|---|
| 787 | SunOS.  */ | 
|---|
| 788 | #ifndef MY_exec_hdr_flags | 
|---|
| 789 | #define MY_exec_hdr_flags 1 | 
|---|
| 790 | #endif | 
|---|
| 791 |  | 
|---|
| 792 | #ifndef MY_entry_is_text_address | 
|---|
| 793 | #define MY_entry_is_text_address 0 | 
|---|
| 794 | #endif | 
|---|
| 795 | #ifndef MY_add_dynamic_symbols | 
|---|
| 796 | #define MY_add_dynamic_symbols 0 | 
|---|
| 797 | #endif | 
|---|
| 798 | #ifndef MY_add_one_symbol | 
|---|
| 799 | #define MY_add_one_symbol 0 | 
|---|
| 800 | #endif | 
|---|
| 801 | #ifndef MY_link_dynamic_object | 
|---|
| 802 | #define MY_link_dynamic_object 0 | 
|---|
| 803 | #endif | 
|---|
| 804 | #ifndef MY_write_dynamic_symbol | 
|---|
| 805 | #define MY_write_dynamic_symbol 0 | 
|---|
| 806 | #endif | 
|---|
| 807 | #ifndef MY_check_dynamic_reloc | 
|---|
| 808 | #define MY_check_dynamic_reloc 0 | 
|---|
| 809 | #endif | 
|---|
| 810 | #ifndef MY_finish_dynamic_link | 
|---|
| 811 | #define MY_finish_dynamic_link 0 | 
|---|
| 812 | #endif | 
|---|
| 813 |  | 
|---|
| 814 | static const struct aout_backend_data sunos4_aout_backend = | 
|---|
| 815 | { | 
|---|
| 816 | 0,                            /* zmagic files are not contiguous */ | 
|---|
| 817 | 1,                            /* text includes header */ | 
|---|
| 818 | MY_entry_is_text_address, | 
|---|
| 819 | MY_exec_hdr_flags, | 
|---|
| 820 | 0,                            /* default text vma */ | 
|---|
| 821 | sunos4_set_sizes, | 
|---|
| 822 | 0,                            /* header is counted in zmagic text */ | 
|---|
| 823 | MY_add_dynamic_symbols, | 
|---|
| 824 | MY_add_one_symbol, | 
|---|
| 825 | MY_link_dynamic_object, | 
|---|
| 826 | MY_write_dynamic_symbol, | 
|---|
| 827 | MY_check_dynamic_reloc, | 
|---|
| 828 | MY_finish_dynamic_link | 
|---|
| 829 | }; | 
|---|
| 830 |  | 
|---|
| 831 |  | 
|---|
| 832 | #define MY_core_file_failing_command    sunos4_core_file_failing_command | 
|---|
| 833 | #define MY_core_file_failing_signal     sunos4_core_file_failing_signal | 
|---|
| 834 | #define MY_core_file_matches_executable_p sunos4_core_file_matches_executable_p | 
|---|
| 835 |  | 
|---|
| 836 | #define MY_bfd_debug_info_start         bfd_void | 
|---|
| 837 | #define MY_bfd_debug_info_end           bfd_void | 
|---|
| 838 | #define MY_bfd_debug_info_accumulate    \ | 
|---|
| 839 | (void (*) PARAMS ((bfd *, struct sec *))) bfd_void | 
|---|
| 840 | #define MY_core_file_p                  sunos4_core_file_p | 
|---|
| 841 | #define MY_write_object_contents        NAME(aout,sunos4_write_object_contents) | 
|---|
| 842 | #define MY_backend_data                 &sunos4_aout_backend | 
|---|
| 843 |  | 
|---|
| 844 | #ifndef TARGET_IS_LITTLE_ENDIAN_P | 
|---|
| 845 | #define TARGET_IS_BIG_ENDIAN_P | 
|---|
| 846 | #endif | 
|---|
| 847 |  | 
|---|
| 848 | #include "aout-target.h" | 
|---|