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

Subversion Repositories or1k

[/] [or1k/] [tags/] [start/] [insight/] [bfd/] [rs6000-core.c] - Blame information for rev 1782

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

Line No. Rev Author Line
1 578 markom
/* IBM RS/6000 "XCOFF" back-end for BFD.
2
   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
3
   2001
4
   Free Software Foundation, Inc.
5
   FIXME: Can someone provide a transliteration of this name into ASCII?
6
   Using the following chars caused a compiler warning on HIUX (so I replaced
7
   them with octal escapes), and isn't useful without an understanding of what
8
   character set it is.
9
   Written by Metin G. Ozisik, Mimi Ph\373\364ng-Th\345o V\365,
10
     and John Gilmore.
11
   Archive support from Damon A. Permezel.
12
   Contributed by IBM Corporation and Cygnus Support.
13
 
14
This file is part of BFD, the Binary File Descriptor library.
15
 
16
This program is free software; you can redistribute it and/or modify
17
it under the terms of the GNU General Public License as published by
18
the Free Software Foundation; either version 2 of the License, or
19
(at your option) any later version.
20
 
21
This program is distributed in the hope that it will be useful,
22
but WITHOUT ANY WARRANTY; without even the implied warranty of
23
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
GNU General Public License for more details.
25
 
26
You should have received a copy of the GNU General Public License
27
along with this program; if not, write to the Free Software
28
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
29
 
30
/* This port currently only handles reading object files, except when
31
   compiled on an RS/6000 host.  -- no archive support, no core files.
32
   In all cases, it does not support writing.
33
 
34
   This is in a separate file from coff-rs6000.c, because it includes
35
   system include files that conflict with coff/rs6000.h.  */
36
 
37
/* Internalcoff.h and coffcode.h modify themselves based on this flag.  */
38
#define RS6000COFF_C 1
39
 
40
/* The AIX 4.1 kernel is obviously compiled with -D_LONG_LONG, so
41
   we have to define _LONG_LONG for older versions of gcc to get the
42
   proper alignments in the user structure.  */
43
#if defined(_AIX41) && !defined(_LONG_LONG)
44
#define _LONG_LONG
45
#endif
46
 
47
#include "bfd.h"
48
#include "sysdep.h"
49
#include "libbfd.h"
50
 
51
#ifdef AIX_CORE
52
 
53
/* AOUTHDR is defined by the above.  We need another defn of it, from the
54
   system include files.  Punt the old one and get us a new name for the
55
   typedef in the system include files.  */
56
#ifdef AOUTHDR
57
#undef AOUTHDR
58
#endif
59
#define AOUTHDR second_AOUTHDR
60
 
61
#undef  SCNHDR
62
 
63
/* ------------------------------------------------------------------------ */
64
/*      Support for core file stuff..                                       */
65
/* ------------------------------------------------------------------------ */
66
 
67
#include <sys/user.h>
68
#define __LDINFO_PTRACE32__     /* for __ld_info32 */
69
#define __LDINFO_PTRACE64__     /* for __ld_info64 */
70
#include <sys/ldr.h>
71
#include <sys/core.h>
72
#include <sys/systemcfg.h>
73
 
74
#define core_hdr(bfd)           ((CoreHdr *) bfd->tdata.any)
75
 
76
/* AIX 4.1 changed the names and locations of a few items in the core file.
77
   AIX 4.3 defined an entirely new structure, core_dumpx, but kept support for
78
   the previous 4.1 structure, core_dump.
79
 
80
   AIX_CORE_DUMPX_CORE is defined (by configure) on AIX 4.3+, and
81
   CORE_VERSION_1 is defined (by AIX core.h) as 2 on AIX 4.3+ and as 1 on AIX
82
   4.1 and 4.2.  AIX pre-4.1 (aka 3.x) either doesn't define CORE_VERSION_1
83
   or else defines it as 0.  */
84
 
85
#if defined(CORE_VERSION_1) && !CORE_VERSION_1
86
# undef CORE_VERSION_1
87
#endif
88
 
89
/* The following union and macros allow this module to compile on all AIX
90
   versions and to handle both core_dumpx and core_dump on 4.3+.  CNEW_*()
91
   and COLD_*() macros respectively retrieve core_dumpx and core_dump
92
   values.  */
93
 
94
/* Union of 32-bit and 64-bit versions of ld_info.  */
95
 
96
typedef union {
97
#ifdef __ld_info32
98
  struct __ld_info32 l32;
99
  struct __ld_info64 l64;
100
#else
101
  struct ld_info l32;
102
  struct ld_info l64;
103
#endif
104
} LdInfo;
105
 
106
/* Union of old and new core dump structures.  */
107
 
108
typedef union {
109
#ifdef AIX_CORE_DUMPX_CORE
110
  struct core_dumpx new;        /* new AIX 4.3+ core dump */
111
#else
112
  struct core_dump new;         /* for simpler coding */
113
#endif
114
  struct core_dump old;         /* old AIX 4.2- core dump, still used on
115
                                   4.3+ with appropriate SMIT config */
116
} CoreHdr;
117
 
118
/* Union of old and new vm_info structures.  */
119
 
120
#ifdef CORE_VERSION_1
121
typedef union {
122
#ifdef AIX_CORE_DUMPX_CORE
123
  struct vm_infox new;
124
#else
125
  struct vm_info new;
126
#endif
127
  struct vm_info old;
128
} VmInfo;
129
#endif
130
 
131
/* Return whether CoreHdr C is in new or old format.  */
132
 
133
#ifdef AIX_CORE_DUMPX_CORE
134
# define CORE_NEW(c)    (!(c).old.c_entries)
135
#else
136
# define CORE_NEW(c)    0
137
#endif
138
 
139
/* Return the c_stackorg field from struct core_dumpx C.  */
140
 
141
#ifdef AIX_CORE_DUMPX_CORE
142
# define CNEW_STACKORG(c)       (c).c_stackorg
143
#else
144
# define CNEW_STACKORG(c)       0
145
#endif
146
 
147
/* Return the offset to the loader region from struct core_dump C.  */
148
 
149
#ifdef AIX_CORE_DUMPX_CORE
150
# define CNEW_LOADER(c) (c).c_loader
151
#else
152
# define CNEW_LOADER(c) 0
153
#endif
154
 
155
/* Return the offset to the loader region from struct core_dump C.  */
156
 
157
#define COLD_LOADER(c)  (c).c_tab
158
 
159
/* Return the c_lsize field from struct core_dumpx C.  */
160
 
161
#ifdef AIX_CORE_DUMPX_CORE
162
# define CNEW_LSIZE(c)  (c).c_lsize
163
#else
164
# define CNEW_LSIZE(c)  0
165
#endif
166
 
167
/* Return the c_dataorg field from struct core_dumpx C.  */
168
 
169
#ifdef AIX_CORE_DUMPX_CORE
170
# define CNEW_DATAORG(c)        (c).c_dataorg
171
#else
172
# define CNEW_DATAORG(c)        0
173
#endif
174
 
175
/* Return the c_datasize field from struct core_dumpx C.  */
176
 
177
#ifdef AIX_CORE_DUMPX_CORE
178
# define CNEW_DATASIZE(c)       (c).c_datasize
179
#else
180
# define CNEW_DATASIZE(c)       0
181
#endif
182
 
183
/* Return the c_impl field from struct core_dumpx C.  */
184
 
185
#ifdef AIX_CORE_DUMPX_CORE
186
# define CNEW_IMPL(c)   (c).c_impl
187
#else
188
# define CNEW_IMPL(c)   0
189
#endif
190
 
191
/* Return the command string from struct core_dumpx C.  */
192
 
193
#ifdef AIX_CORE_DUMPX_CORE
194
# define CNEW_COMM(c)   (c).c_u.U_proc.pi_comm
195
#else
196
# define CNEW_COMM(c)   0
197
#endif
198
 
199
/* Return the command string from struct core_dump C.  */
200
 
201
#ifdef CORE_VERSION_1
202
# define COLD_COMM(c)   (c).c_u.U_comm
203
#else
204
# define COLD_COMM(c)   (c).c_u.u_comm
205
#endif
206
 
207
/* Return the struct __context64 pointer from struct core_dumpx C.  */
208
 
209
#ifdef AIX_CORE_DUMPX_CORE
210
# define CNEW_CONTEXT64(c)      (c).c_flt.hctx.r64
211
#else
212
# define CNEW_CONTEXT64(c)      c
213
#endif
214
 
215
/* Return the struct mstsave pointer from struct core_dumpx C.  */
216
 
217
#ifdef AIX_CORE_DUMPX_CORE
218
# define CNEW_MSTSAVE(c)        (c).c_flt.hctx.r32
219
#else
220
# define CNEW_MSTSAVE(c)        c
221
#endif
222
 
223
/* Return the struct mstsave pointer from struct core_dump C.  */
224
 
225
#ifdef CORE_VERSION_1
226
# define COLD_MSTSAVE(c)        (c).c_mst
227
#else
228
# define COLD_MSTSAVE(c)        (c).c_u.u_save
229
#endif
230
 
231
/* Return whether struct core_dumpx is from a 64-bit process.  */
232
 
233
#ifdef AIX_CORE_DUMPX_CORE
234
# define CNEW_PROC64(c)         IS_PROC64(&(c).c_u.U_proc)
235
#else
236
# define CNEW_PROC64(c)         0
237
#endif
238
 
239
/* Magic end-of-stack addresses for old core dumps.  This is _very_ fragile,
240
   but I don't see any easy way to get that info right now.  */
241
 
242
#ifdef CORE_VERSION_1
243
# define COLD_STACKEND  0x2ff23000
244
#else
245
# define COLD_STACKEND  0x2ff80000
246
#endif
247
 
248
/* Size of the leading portion that old and new core dump structures have in
249
   common.  */
250
#define CORE_COMMONSZ   ((int) &((struct core_dump *) 0)->c_entries \
251
                         + sizeof (((struct core_dump *) 0)->c_entries))
252
 
253
/* Try to read into CORE the header from the core file associated with ABFD.
254
   Return success.  */
255
 
256
static boolean
257
read_hdr (bfd *abfd, CoreHdr *core)
258
{
259
  bfd_size_type size;
260
 
261
  if (bfd_seek (abfd, 0, SEEK_SET) != 0)
262
    return false;
263
 
264
  /* Read the leading portion that old and new core dump structures have in
265
     common.  */
266
  if (bfd_read (core, CORE_COMMONSZ, 1, abfd) != CORE_COMMONSZ)
267
    return false;
268
 
269
  /* Read the trailing portion of the structure.  */
270
  size = CORE_NEW (*core) ? sizeof (core->new) : sizeof (core->old)
271
    - CORE_COMMONSZ;
272
  return bfd_read ((char *) core + CORE_COMMONSZ, size, 1, abfd) == size;
273
}
274
 
275
static asection *
276
make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos)
277
     bfd *abfd;
278
     CONST char *name;
279
     flagword flags;
280
     bfd_size_type _raw_size;
281
     bfd_vma vma;
282
     file_ptr filepos;
283
{
284
  asection *asect;
285
 
286
  asect = bfd_make_section_anyway (abfd, name);
287
  if (!asect)
288
    return NULL;
289
 
290
  asect->flags = flags;
291
  asect->_raw_size = _raw_size;
292
  asect->vma = vma;
293
  asect->filepos = filepos;
294
  asect->alignment_power = 8;
295
 
296
  return asect;
297
}
298
 
299
/* Decide if a given bfd represents a `core' file or not. There really is no
300
   magic number or anything like, in rs6000coff.  */
301
 
302
const bfd_target *
303
rs6000coff_core_p (abfd)
304
     bfd *abfd;
305
{
306
  CoreHdr core;
307
  struct stat statbuf;
308
  bfd_size_type size;
309
  char *tmpptr;
310
 
311
  /* Values from new and old core structures.  */
312
  int c_flag;
313
  file_ptr c_stack, c_regoff, c_loader;
314
  bfd_size_type c_size, c_regsize, c_lsize;
315
  bfd_vma c_stackend;
316
  void *c_regptr;
317
  int proc64;
318
 
319
  if (!read_hdr (abfd, &core))
320
    {
321
      if (bfd_get_error () != bfd_error_system_call)
322
        bfd_set_error (bfd_error_wrong_format);
323
      return NULL;
324
    }
325
 
326
  /* Copy fields from new or old core structure.  */
327
  if (CORE_NEW (core))
328
    {
329
      c_flag = core.new.c_flag;
330
      c_stack = (file_ptr) core.new.c_stack;
331
      c_size = core.new.c_size;
332
      c_stackend = CNEW_STACKORG (core.new) + c_size;
333
      c_lsize = CNEW_LSIZE (core.new);
334
      c_loader = CNEW_LOADER (core.new);
335
      proc64 = CNEW_PROC64 (core.new);
336
    }
337
  else
338
    {
339
      c_flag = core.old.c_flag;
340
      c_stack = (file_ptr) core.old.c_stack;
341
      c_size = core.old.c_size;
342
      c_stackend = COLD_STACKEND;
343
      c_lsize = 0x7ffffff;
344
      c_loader = (file_ptr) COLD_LOADER (core.old);
345
      proc64 = 0;
346
    }
347
 
348
  if (proc64)
349
    {
350
      c_regsize = sizeof (CNEW_CONTEXT64 (core.new));
351
      c_regptr = &CNEW_CONTEXT64 (core.new);
352
    }
353
  else if (CORE_NEW (core))
354
    {
355
      c_regsize = sizeof (CNEW_MSTSAVE (core.new));
356
      c_regptr = &CNEW_MSTSAVE (core.new);
357
    }
358
  else
359
    {
360
      c_regsize = sizeof (COLD_MSTSAVE (core.old));
361
      c_regptr = &COLD_MSTSAVE (core.old);
362
    }
363
  c_regoff = (char *) c_regptr - (char *) &core;
364
 
365
  if (bfd_stat (abfd, &statbuf) < 0)
366
    {
367
      bfd_set_error (bfd_error_system_call);
368
      return NULL;
369
    }
370
 
371
  /* If the core file ulimit is too small, the system will first
372
     omit the data segment, then omit the stack, then decline to
373
     dump core altogether (as far as I know UBLOCK_VALID and LE_VALID
374
     are always set) (this is based on experimentation on AIX 3.2).
375
     Now, the thing is that GDB users will be surprised
376
     if segments just silently don't appear (well, maybe they would
377
     think to check "info files", I don't know).
378
 
379
     For the data segment, we have no choice but to keep going if it's
380
     not there, since the default behavior is not to dump it (regardless
381
     of the ulimit, it's based on SA_FULLDUMP).  But for the stack segment,
382
     if it's not there, we refuse to have anything to do with this core
383
     file.  The usefulness of a core dump without a stack segment is pretty
384
     limited anyway.  */
385
 
386
  if (!(c_flag & UBLOCK_VALID)
387
      || !(c_flag & LE_VALID))
388
    {
389
      bfd_set_error (bfd_error_wrong_format);
390
      return NULL;
391
    }
392
 
393
  if (!(c_flag & USTACK_VALID))
394
    {
395
      bfd_set_error (bfd_error_file_truncated);
396
      return NULL;
397
    }
398
 
399
  /* Don't check the core file size for a full core, AIX 4.1 includes
400
     additional shared library sections in a full core.  */
401
  if (!(c_flag & (FULL_CORE | CORE_TRUNC)))
402
    {
403
      /* If the size is wrong, it means we're misinterpreting something.  */
404
      if (c_stack + (file_ptr) c_size != statbuf.st_size)
405
        {
406
          bfd_set_error (bfd_error_wrong_format);
407
          return NULL;
408
        }
409
    }
410
 
411
  /* Sanity check on the c_tab field.  */
412
  if (!CORE_NEW (core) && (c_loader < (file_ptr) sizeof core.old ||
413
                           c_loader >= statbuf.st_size ||
414
                           c_loader >= c_stack))
415
    {
416
      bfd_set_error (bfd_error_wrong_format);
417
      return NULL;
418
    }
419
 
420
  /* Issue warning if the core file was truncated during writing.  */
421
  if (c_flag & CORE_TRUNC)
422
    (*_bfd_error_handler) (_("%s: warning core file truncated"),
423
                           bfd_get_filename (abfd));
424
 
425
  /* Allocate core file header.  */
426
  size = CORE_NEW (core) ? sizeof (core.new) : sizeof (core.old);
427
  tmpptr = (char *) bfd_zalloc (abfd, size);
428
  if (!tmpptr)
429
    return NULL;
430
 
431
  /* Copy core file header.  */
432
  memcpy (tmpptr, &core, size);
433
  set_tdata (abfd, tmpptr);
434
 
435
  /* Set architecture.  */
436
  if (CORE_NEW (core))
437
    {
438
      enum bfd_architecture arch;
439
      unsigned long mach;
440
 
441
      switch (CNEW_IMPL (core.new))
442
        {
443
        case POWER_RS1:
444
        case POWER_RSC:
445
        case POWER_RS2:
446
          arch = bfd_arch_rs6000;
447
          mach = bfd_mach_rs6k;
448
          break;
449
        default:
450
          arch = bfd_arch_powerpc;
451
          mach = bfd_mach_ppc;
452
          break;
453
        }
454
      bfd_default_set_arch_mach (abfd, arch, mach);
455
    }
456
 
457
  /* .stack section.  */
458
  if (!make_bfd_asection (abfd, ".stack",
459
                          SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS,
460
                          c_size, c_stackend - c_size, c_stack))
461
    return NULL;
462
 
463
  /* .reg section for all registers.  */
464
  if (!make_bfd_asection (abfd, ".reg",
465
                          SEC_HAS_CONTENTS,
466
                          c_regsize, (bfd_vma) 0, c_regoff))
467
    return NULL;
468
 
469
  /* .ldinfo section.
470
     To actually find out how long this section is in this particular
471
     core dump would require going down the whole list of struct ld_info's.
472
     See if we can just fake it.  */
473
  if (!make_bfd_asection (abfd, ".ldinfo",
474
                          SEC_HAS_CONTENTS,
475
                          c_lsize, (bfd_vma) 0, c_loader))
476
    return NULL;
477
 
478
#ifndef CORE_VERSION_1
479
  /* .data section if present.
480
     AIX 3 dumps the complete data section and sets FULL_CORE if the
481
     ulimit is large enough, otherwise the data section is omitted.
482
     AIX 4 sets FULL_CORE even if the core file is truncated, we have
483
     to examine core.c_datasize below to find out the actual size of
484
     the .data section.  */
485
  if (c_flag & FULL_CORE)
486
    {
487
      if (!make_bfd_asection (abfd, ".data",
488
                              SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS,
489
                              (bfd_size_type) core.old.c_u.u_dsize,
490
                              (bfd_vma)
491
                                CDATA_ADDR (core.old.c_u.u_dsize),
492
                              c_stack + c_size))
493
        return NULL;
494
    }
495
#endif
496
 
497
#ifdef CORE_VERSION_1
498
  /* AIX 4 adds data sections from loaded objects to the core file,
499
     which can be found by examining ldinfo, and anonymously mmapped
500
     regions.  */
501
  {
502
    LdInfo ldinfo;
503
    bfd_size_type ldi_datasize;
504
    file_ptr ldi_core;
505
    uint ldi_next;
506
    bfd_vma ldi_dataorg;
507
 
508
    /* Fields from new and old core structures.  */
509
    bfd_size_type c_datasize, c_vmregions;
510
    file_ptr c_data, c_vmm;
511
 
512
    if (CORE_NEW (core))
513
      {
514
        c_datasize = CNEW_DATASIZE (core.new);
515
        c_data = (file_ptr) core.new.c_data;
516
        c_vmregions = core.new.c_vmregions;
517
        c_vmm = (file_ptr) core.new.c_vmm;
518
      }
519
    else
520
      {
521
        c_datasize = core.old.c_datasize;
522
        c_data = (file_ptr) core.old.c_data;
523
        c_vmregions = core.old.c_vmregions;
524
        c_vmm = (file_ptr) core.old.c_vmm;
525
      }
526
 
527
    /* .data section from executable.  */
528
    if (c_datasize)
529
      {
530
        if (!make_bfd_asection (abfd, ".data",
531
                                SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS,
532
                                c_datasize,
533
                                (bfd_vma) CDATA_ADDR (c_datasize),
534
                                c_data))
535
          return NULL;
536
      }
537
 
538
    /* .data sections from loaded objects.  */
539
    if (proc64)
540
      size = (int) ((LdInfo *) 0)->l64.ldinfo_filename;
541
    else
542
      size = (int) ((LdInfo *) 0)->l32.ldinfo_filename;
543
 
544
    while (1)
545
      {
546
        if (bfd_seek (abfd, c_loader, SEEK_SET) != 0)
547
          return NULL;
548
        if (bfd_read (&ldinfo, size, 1, abfd) != size)
549
          return NULL;
550
 
551
        if (proc64)
552
          {
553
            ldi_core = ldinfo.l64.ldinfo_core;
554
            ldi_datasize = ldinfo.l64.ldinfo_datasize;
555
            ldi_dataorg = (bfd_vma) ldinfo.l64.ldinfo_dataorg;
556
            ldi_next = ldinfo.l64.ldinfo_next;
557
          }
558
        else
559
          {
560
            ldi_core = ldinfo.l32.ldinfo_core;
561
            ldi_datasize = ldinfo.l32.ldinfo_datasize;
562
            ldi_dataorg = (bfd_vma) (long) ldinfo.l32.ldinfo_dataorg;
563
            ldi_next = ldinfo.l32.ldinfo_next;
564
          }
565
 
566
        if (ldi_core)
567
          if (!make_bfd_asection (abfd, ".data",
568
                                  SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS,
569
                                  ldi_datasize, ldi_dataorg, ldi_core))
570
            return NULL;
571
 
572
        if (ldi_next == 0)
573
          break;
574
        c_loader += ldi_next;
575
      }
576
 
577
    /* .vmdata sections from anonymously mmapped regions.  */
578
    if (c_vmregions)
579
      {
580
        bfd_size_type i;
581
 
582
        if (bfd_seek (abfd, c_vmm, SEEK_SET) != 0)
583
          return NULL;
584
 
585
        for (i = 0; i < c_vmregions; i++)
586
          {
587
            VmInfo vminfo;
588
            bfd_size_type vminfo_size;
589
            file_ptr vminfo_offset;
590
            bfd_vma vminfo_addr;
591
 
592
            size = CORE_NEW (core) ? sizeof (vminfo.new) : sizeof (vminfo.old);
593
            if (bfd_read (&vminfo, size, 1, abfd) != size)
594
              return NULL;
595
 
596
            if (CORE_NEW (core))
597
              {
598
                vminfo_addr = (bfd_vma) vminfo.new.vminfo_addr;
599
                vminfo_size = vminfo.new.vminfo_size;
600
                vminfo_offset = vminfo.new.vminfo_offset;
601
              }
602
            else
603
              {
604
                vminfo_addr = (bfd_vma) (long) vminfo.old.vminfo_addr;
605
                vminfo_size = vminfo.old.vminfo_size;
606
                vminfo_offset = vminfo.old.vminfo_offset;
607
              }
608
 
609
            if (vminfo_offset)
610
              if (!make_bfd_asection (abfd, ".vmdata",
611
                                      SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS,
612
                                      vminfo_size, vminfo_addr,
613
                                      vminfo_offset))
614
                return NULL;
615
          }
616
      }
617
  }
618
#endif
619
 
620
  return abfd->xvec;            /* This is garbage for now.  */
621
}
622
 
623
/* Return `true' if given core is from the given executable.  */
624
 
625
boolean
626
rs6000coff_core_file_matches_executable_p (core_bfd, exec_bfd)
627
     bfd *core_bfd;
628
     bfd *exec_bfd;
629
{
630
  CoreHdr core;
631
  bfd_size_type size;
632
  char *path, *s;
633
  size_t alloc;
634
  const char *str1, *str2;
635
  boolean ret;
636
  file_ptr c_loader;
637
 
638
  if (!read_hdr (core_bfd, &core))
639
    return false;
640
 
641
  if (CORE_NEW (core))
642
    c_loader = CNEW_LOADER (core.new);
643
  else
644
    c_loader = (file_ptr) COLD_LOADER (core.old);
645
 
646
  if (CORE_NEW (core) && CNEW_PROC64 (core.new))
647
    size = (int) ((LdInfo *) 0)->l64.ldinfo_filename;
648
  else
649
    size = (int) ((LdInfo *) 0)->l32.ldinfo_filename;
650
 
651
  if (bfd_seek (core_bfd, c_loader + size, SEEK_SET) != 0)
652
    return false;
653
 
654
  alloc = 100;
655
  path = bfd_malloc (alloc);
656
  if (path == NULL)
657
    return false;
658
  s = path;
659
 
660
  while (1)
661
    {
662
      if (bfd_read (s, 1, 1, core_bfd) != 1)
663
        {
664
          free (path);
665
          return false;
666
        }
667
      if (*s == '\0')
668
        break;
669
      ++s;
670
      if (s == path + alloc)
671
        {
672
          char *n;
673
 
674
          alloc *= 2;
675
          n = bfd_realloc (path, alloc);
676
          if (n == NULL)
677
            {
678
              free (path);
679
              return false;
680
            }
681
          s = n + (path - s);
682
          path = n;
683
        }
684
    }
685
 
686
  str1 = strrchr (path, '/');
687
  str2 = strrchr (exec_bfd->filename, '/');
688
 
689
  /* step over character '/' */
690
  str1 = str1 != NULL ? str1 + 1 : path;
691
  str2 = str2 != NULL ? str2 + 1 : exec_bfd->filename;
692
 
693
  if (strcmp (str1, str2) == 0)
694
    ret = true;
695
  else
696
    ret = false;
697
 
698
  free (path);
699
 
700
  return ret;
701
}
702
 
703
char *
704
rs6000coff_core_file_failing_command (abfd)
705
     bfd *abfd;
706
{
707
  CoreHdr *core = core_hdr (abfd);
708
  char *com = CORE_NEW (*core) ?
709
    CNEW_COMM (core->new) : COLD_COMM (core->old);
710
 
711
  if (*com)
712
    return com;
713
  else
714
    return 0;
715
}
716
 
717
int
718
rs6000coff_core_file_failing_signal (abfd)
719
     bfd *abfd;
720
{
721
  CoreHdr *core = core_hdr (abfd);
722
  return CORE_NEW (*core) ? core->new.c_signo : core->old.c_signo;
723
}
724
 
725
#endif /* AIX_CORE */

powered by: WebSVN 2.1.0

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