Changeset 609 for branches/GNU/src/binutils/bfd/aout-encap.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/aout-encap.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* BFD back-end for a.out files encapsulated with COFF headers. 2 Copyright 1990, 1991, 1994, 1995, 2000 Free Software Foundation, Inc. 2 Copyright 1990, 1991, 1994, 1995, 2000, 2001, 2002, 2003 3 Free Software Foundation, Inc. 3 4 4 5 This file is part of BFD, the Binary File Descriptor library. … … 24 25 #define SEGMENT_SIZE TARGET_PAGE_SIZE 25 26 #define TEXT_START_ADDR 0 26 #define BYTES_IN_WORD 427 27 #endif 28 28 29 29 #include "bfd.h" 30 #include <sysdep.h>30 #include "sysdep.h" 31 31 #include "libbfd.h" 32 #include <aout/aout64.h>32 #include "aout/aout64.h" 33 33 #include "aout/stab_gnu.h" 34 34 #include "aout/ar.h" … … 46 46 struct external_exec exec_bytes; 47 47 struct internal_exec exec; 48 49 if (bfd_read ((PTR)magicbuf, 1, sizeof (magicbuf), abfd) != 50 sizeof (magicbuf))48 bfd_size_type amt = sizeof (magicbuf); 49 50 if (bfd_bread ((PTR) magicbuf, amt, abfd) != amt) 51 51 { 52 52 if (bfd_get_error () != bfd_error_system_call) … … 55 55 } 56 56 57 coff_magic = bfd_h_get_16 (abfd, magicbuf);57 coff_magic = H_GET_16 (abfd, magicbuf); 58 58 if (coff_magic != COFF_MAGIC) 59 59 return 0; /* Not an encap coff file */ 60 60 61 __header_offset_temp==COFF_MAGIC ? sizeof (struct coffheader) : 0) 62 (fseek ((f), HEADER_OFFSET((f)), 1)) 63 64 magic = bfd_h_get_32 (abfd, magicbuf); 65 66 if (N_BADMAG (*((struct internal_exec *) &magic))) return 0; 67 68 struct external_exec exec_bytes; 69 if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) 70 != EXEC_BYTES_SIZE) { 71 if (bfd_get_error () != bfd_error_system_call) 72 bfd_set_error (bfd_error_wrong_format); 61 magic = H_GET_32 (abfd, magicbuf); 62 63 if (N_BADMAG (*((struct internal_exec *) &magic))) 73 64 return 0; 74 } 65 66 if (bfd_seek (abfd, (file_ptr) sizeof (struct coffheader), SEEK_SET) != 0) 67 return 0; 68 69 amt = EXEC_BYTES_SIZE; 70 if (bfd_bread ((PTR) &exec_bytes, amt, abfd) != amt) 71 { 72 if (bfd_get_error () != bfd_error_system_call) 73 bfd_set_error (bfd_error_wrong_format); 74 return 0; 75 } 75 76 NAME(aout,swap_exec_header_in) (abfd, &exec_bytes, &exec); 76 77 … … 78 79 } 79 80 80 /* Finish up the reading of a encapsulated-coff a.out file header*/81 /* Finish up the reading of an encapsulated-coff a.out file header. */ 81 82 const bfd_target * 82 83 encap_real_callback (abfd) … … 91 92 for remote debugging of embedded systems. */ 92 93 if (N_FLAGS(exec_aouthdr) & N_FLAGS_COFF_ENCAPSULATE) 93 { 94 struct coffheader ch; 95 int val; 96 val = lseek (execchan, -(sizeof (AOUTHDR) + sizeof (ch)), 1); 97 if (val == -1) 98 perror_with_name (filename); 99 val = myread (execchan, &ch, sizeof (ch)); 100 if (val < 0) 101 perror_with_name (filename); 102 text_start = ch.text_start; 103 exec_data_start = ch.data_start; 104 } else 105 { 106 text_start = 107 IS_OBJECT_FILE (exec_aouthdr) ? 0 : N_TXTADDR (exec_aouthdr); 108 exec_data_start = IS_OBJECT_FILE (exec_aouthdr) 109 ? exec_aouthdr.a_text : N_DATADDR (exec_aouthdr); 110 } 94 { 95 struct coffheader ch; 96 int val; 97 val = lseek (execchan, -(sizeof (AOUTHDR) + sizeof (ch)), 1); 98 if (val == -1) 99 perror_with_name (filename); 100 val = myread (execchan, &ch, sizeof (ch)); 101 if (val < 0) 102 perror_with_name (filename); 103 text_start = ch.text_start; 104 exec_data_start = ch.data_start; 105 } 106 else 107 { 108 text_start = 109 IS_OBJECT_FILE (exec_aouthdr) ? 0 : N_TXTADDR (exec_aouthdr); 110 exec_data_start = (IS_OBJECT_FILE (exec_aouthdr) 111 ? exec_aouthdr.a_text 112 : N_DATADDR (exec_aouthdr)); 113 } 111 114 112 115 /* Determine the architecture and machine type of the object file. */ … … 120 123 file header, symbols, and relocation. */ 121 124 122 b oolean125 bfd_boolean 123 126 encap_write_object_contents (abfd) 124 127 bfd *abfd; … … 128 131 struct internal_exec *execp = exec_hdr (abfd); 129 132 130 /****** FIXME: Fragments from the old GNU LD program for dealing with131 132 struct coffheader coffheader;133 int need_coff_header;133 /* FIXME: Fragments from the old GNU LD program for dealing with 134 encap coff. */ 135 struct coffheader coffheader; 136 int need_coff_header; 134 137 135 138 /* Determine whether to count the header as part of … … 227 230 text_size -= N_TXTOFF (outheader); 228 231 WRITE_HEADERS(abfd, execp); 229 return true;232 return TRUE; 230 233 } 231 234 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.