trad-core.c (78828) | trad-core.c (89857) |
---|---|
1/* BFD back end for traditional Unix core files (U-area and raw sections) 2 Copyright 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, | 1/* BFD back end for traditional Unix core files (U-area and raw sections) 2 Copyright 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, |
3 2000 | 3 2000, 2001, 2002 |
4 Free Software Foundation, Inc. 5 Written by John Gilmore of Cygnus Support. 6 7This file is part of BFD, the Binary File Descriptor library. 8 9This program is free software; you can redistribute it and/or modify 10it under the terms of the GNU General Public License as published by 11the Free Software Foundation; either version 2 of the License, or --- 63 unchanged lines hidden (view full) --- 75const bfd_target * 76trad_unix_core_file_p (abfd) 77 bfd *abfd; 78 79{ 80 int val; 81 struct user u; 82 struct trad_core_struct *rawptr; | 4 Free Software Foundation, Inc. 5 Written by John Gilmore of Cygnus Support. 6 7This file is part of BFD, the Binary File Descriptor library. 8 9This program is free software; you can redistribute it and/or modify 10it under the terms of the GNU General Public License as published by 11the Free Software Foundation; either version 2 of the License, or --- 63 unchanged lines hidden (view full) --- 75const bfd_target * 76trad_unix_core_file_p (abfd) 77 bfd *abfd; 78 79{ 80 int val; 81 struct user u; 82 struct trad_core_struct *rawptr; |
83 bfd_size_type amt; |
|
83 84#ifdef TRAD_CORE_USER_OFFSET 85 /* If defined, this macro is the file position of the user struct. */ | 84 85#ifdef TRAD_CORE_USER_OFFSET 86 /* If defined, this macro is the file position of the user struct. */ |
86 if (bfd_seek (abfd, TRAD_CORE_USER_OFFSET, SEEK_SET) != 0) | 87 if (bfd_seek (abfd, (file_ptr) TRAD_CORE_USER_OFFSET, SEEK_SET) != 0) |
87 return 0; 88#endif 89 | 88 return 0; 89#endif 90 |
90 val = bfd_read ((void *)&u, 1, sizeof u, abfd); | 91 val = bfd_bread ((void *) &u, (bfd_size_type) sizeof u, abfd); |
91 if (val != sizeof u) 92 { 93 /* Too small to be a core file */ 94 bfd_set_error (bfd_error_wrong_format); 95 return 0; 96 } 97 98 /* Sanity check perhaps??? */ --- 45 unchanged lines hidden (view full) --- 144 } 145#endif 146 } 147 148 /* OK, we believe you. You're a core file (sure, sure). */ 149 150 /* Allocate both the upage and the struct core_data at once, so 151 a single free() will free them both. */ | 92 if (val != sizeof u) 93 { 94 /* Too small to be a core file */ 95 bfd_set_error (bfd_error_wrong_format); 96 return 0; 97 } 98 99 /* Sanity check perhaps??? */ --- 45 unchanged lines hidden (view full) --- 145 } 146#endif 147 } 148 149 /* OK, we believe you. You're a core file (sure, sure). */ 150 151 /* Allocate both the upage and the struct core_data at once, so 152 a single free() will free them both. */ |
152 rawptr = (struct trad_core_struct *) 153 bfd_zmalloc (sizeof (struct trad_core_struct)); | 153 amt = sizeof (struct trad_core_struct); 154 rawptr = (struct trad_core_struct *) bfd_zmalloc (amt); |
154 if (rawptr == NULL) 155 return 0; 156 157 abfd->tdata.trad_core_data = rawptr; 158 159 rawptr->u = u; /*Copy the uarea into the tdata part of the bfd */ 160 | 155 if (rawptr == NULL) 156 return 0; 157 158 abfd->tdata.trad_core_data = rawptr; 159 160 rawptr->u = u; /*Copy the uarea into the tdata part of the bfd */ 161 |
161 /* Create the sections. This is raunchy, but bfd_close wants to free 162 them separately. */ | 162 /* Create the sections. */ |
163 | 163 |
164 core_stacksec(abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); | 164 core_stacksec(abfd) = bfd_make_section_anyway (abfd, ".stack"); |
165 if (core_stacksec (abfd) == NULL) | 165 if (core_stacksec (abfd) == NULL) |
166 return NULL; 167 core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); | 166 goto fail; 167 core_datasec (abfd) = bfd_make_section_anyway (abfd, ".data"); |
168 if (core_datasec (abfd) == NULL) | 168 if (core_datasec (abfd) == NULL) |
169 return NULL; 170 core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); | 169 goto fail; 170 core_regsec (abfd) = bfd_make_section_anyway (abfd, ".reg"); |
171 if (core_regsec (abfd) == NULL) | 171 if (core_regsec (abfd) == NULL) |
172 return NULL; | 172 goto fail; |
173 | 173 |
174 core_stacksec (abfd)->name = ".stack"; 175 core_datasec (abfd)->name = ".data"; 176 core_regsec (abfd)->name = ".reg"; 177 | |
178 core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS; 179 core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS; 180 core_regsec (abfd)->flags = SEC_HAS_CONTENTS; 181 182 core_datasec (abfd)->_raw_size = NBPG * u.u_dsize 183#ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE 184 - NBPG * u.u_tsize 185#endif --- 39 unchanged lines hidden (view full) --- 225 ; 226 core_regsec (abfd)->filepos = 0; /* Register segment is the upage */ 227 228 /* Align to word at least */ 229 core_stacksec (abfd)->alignment_power = 2; 230 core_datasec (abfd)->alignment_power = 2; 231 core_regsec (abfd)->alignment_power = 2; 232 | 174 core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS; 175 core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS; 176 core_regsec (abfd)->flags = SEC_HAS_CONTENTS; 177 178 core_datasec (abfd)->_raw_size = NBPG * u.u_dsize 179#ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE 180 - NBPG * u.u_tsize 181#endif --- 39 unchanged lines hidden (view full) --- 221 ; 222 core_regsec (abfd)->filepos = 0; /* Register segment is the upage */ 223 224 /* Align to word at least */ 225 core_stacksec (abfd)->alignment_power = 2; 226 core_datasec (abfd)->alignment_power = 2; 227 core_regsec (abfd)->alignment_power = 2; 228 |
233 abfd->sections = core_stacksec (abfd); 234 core_stacksec (abfd)->next = core_datasec (abfd); 235 core_datasec (abfd)->next = core_regsec (abfd); 236 abfd->section_count = 3; 237 | |
238 return abfd->xvec; | 229 return abfd->xvec; |
230 231 fail: 232 bfd_release (abfd, abfd->tdata.any); 233 abfd->tdata.any = NULL; 234 bfd_section_list_clear (abfd); 235 return NULL; |
|
239} 240 241char * 242trad_unix_core_file_failing_command (abfd) 243 bfd *abfd; 244{ 245#ifndef NO_CORE_COMMAND 246 char *com = abfd->tdata.trad_core_data->u.u_comm; --- 88 unchanged lines hidden --- | 236} 237 238char * 239trad_unix_core_file_failing_command (abfd) 240 bfd *abfd; 241{ 242#ifndef NO_CORE_COMMAND 243 char *com = abfd->tdata.trad_core_data->u.u_comm; --- 88 unchanged lines hidden --- |