Changeset 609 for branches/GNU/src/binutils/bfd/i386os9k.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/i386os9k.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* BFD back-end for os9000 i386 binaries. 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2001, 2002 3 3 Free Software Foundation, Inc. 4 4 Written by Cygnus Support. … … 28 28 #include "os9k.h" 29 29 30 static const bfd_target *os9k_callback PARAMS ((bfd *)); 30 static const bfd_target * os9k_callback 31 PARAMS ((bfd *)); 32 static const bfd_target * os9k_object_p 33 PARAMS ((bfd *)); 34 static int os9k_sizeof_headers 35 PARAMS ((bfd *, bfd_boolean)); 36 bfd_boolean os9k_swap_exec_header_in 37 PARAMS ((bfd *, mh_com *, struct internal_exec *)); 31 38 32 39 /* Swaps the information in an executable header taken from a raw byte 33 40 stream memory image, into the internal exec_header structure. */ 34 b oolean41 bfd_boolean 35 42 os9k_swap_exec_header_in (abfd, raw_bytes, execp) 36 43 bfd *abfd; … … 42 49 43 50 /* Now fill in fields in the execp, from the bytes in the raw data. */ 44 execp->a_info = bfd_h_get_16 (abfd, bytes->m_sync);51 execp->a_info = H_GET_16 (abfd, bytes->m_sync); 45 52 execp->a_syms = 0; 46 execp->a_entry = bfd_h_get_32 (abfd, bytes->m_exec);53 execp->a_entry = H_GET_32 (abfd, bytes->m_exec); 47 54 execp->a_talign = 2; 48 55 execp->a_dalign = 2; 49 56 execp->a_balign = 2; 50 57 51 dload = bfd_h_get_32 (abfd, bytes->m_idata);58 dload = H_GET_32 (abfd, bytes->m_idata); 52 59 execp->a_data = dload + 8; 53 60 54 61 if (bfd_seek (abfd, (file_ptr) dload, SEEK_SET) != 0 55 || (bfd_ read (&dmemstart, sizeof (dmemstart), 1, abfd)62 || (bfd_bread (&dmemstart, (bfd_size_type) sizeof (dmemstart), abfd) 56 63 != sizeof (dmemstart)) 57 || (bfd_ read (&dmemsize, sizeof (dmemsize), 1, abfd)64 || (bfd_bread (&dmemsize, (bfd_size_type) sizeof (dmemsize), abfd) 58 65 != sizeof (dmemsize))) 59 return false;66 return FALSE; 60 67 61 68 execp->a_tload = 0; 62 execp->a_dload = bfd_h_get_32 (abfd, (unsigned char *) &dmemstart);69 execp->a_dload = H_GET_32 (abfd, (unsigned char *) &dmemstart); 63 70 execp->a_text = dload - execp->a_tload; 64 execp->a_data = bfd_h_get_32 (abfd, (unsigned char *) &dmemsize);65 execp->a_bss = bfd_h_get_32 (abfd, bytes->m_data) - execp->a_data;71 execp->a_data = H_GET_32 (abfd, (unsigned char *) &dmemsize); 72 execp->a_bss = H_GET_32 (abfd, bytes->m_data) - execp->a_data; 66 73 67 74 execp->a_trsize = 0; 68 75 execp->a_drsize = 0; 69 76 70 return true;77 return TRUE; 71 78 } 72 79 … … 75 82 supplied buffer ready for writing to disk. */ 76 83 77 PROTO (void, os9k_swap_exec_header_out, 78 (bfd * abfd, 79 struct internal_exec * execp, 80 struct mh_com * raw_bytes)); 84 void os9k_swap_exec_header_out 85 PARAMS ((bfd *, struct internal_exec *, struct mh_com *)); 86 81 87 void 82 88 os9k_swap_exec_header_out (abfd, execp, raw_bytes) … … 88 94 89 95 /* Now fill in fields in the raw data, from the fields in the exec struct. */ 90 bfd_h_put_32 (abfd, execp->a_info, bytes->e_info);91 bfd_h_put_32 (abfd, execp->a_text, bytes->e_text);92 bfd_h_put_32 (abfd, execp->a_data, bytes->e_data);93 bfd_h_put_32 (abfd, execp->a_bss, bytes->e_bss);94 bfd_h_put_32 (abfd, execp->a_syms, bytes->e_syms);95 bfd_h_put_32 (abfd, execp->a_entry, bytes->e_entry);96 bfd_h_put_32 (abfd, execp->a_trsize, bytes->e_trsize);97 bfd_h_put_32 (abfd, execp->a_drsize, bytes->e_drsize);98 bfd_h_put_32 (abfd, execp->a_tload, bytes->e_tload);99 bfd_h_put_32 (abfd, execp->a_dload, bytes->e_dload);96 H_PUT_32 (abfd, execp->a_info, bytes->e_info); 97 H_PUT_32 (abfd, execp->a_text, bytes->e_text); 98 H_PUT_32 (abfd, execp->a_data, bytes->e_data); 99 H_PUT_32 (abfd, execp->a_bss, bytes->e_bss); 100 H_PUT_32 (abfd, execp->a_syms, bytes->e_syms); 101 H_PUT_32 (abfd, execp->a_entry, bytes->e_entry); 102 H_PUT_32 (abfd, execp->a_trsize, bytes->e_trsize); 103 H_PUT_32 (abfd, execp->a_drsize, bytes->e_drsize); 104 H_PUT_32 (abfd, execp->a_tload, bytes->e_tload); 105 H_PUT_32 (abfd, execp->a_dload, bytes->e_dload); 100 106 bytes->e_talign[0] = execp->a_talign; 101 107 bytes->e_dalign[0] = execp->a_dalign; … … 113 119 mh_com exec_bytes; 114 120 115 if (bfd_ read ((PTR) & exec_bytes, MHCOM_BYTES_SIZE, 1, abfd)121 if (bfd_bread ((PTR) &exec_bytes, (bfd_size_type) MHCOM_BYTES_SIZE, abfd) 116 122 != MHCOM_BYTES_SIZE) 117 123 { … … 121 127 } 122 128 123 anexec.a_info = bfd_h_get_16 (abfd, exec_bytes.m_sync);129 anexec.a_info = H_GET_16 (abfd, exec_bytes.m_sync); 124 130 if (N_BADMAG (anexec)) 125 131 { … … 148 154 unsigned long bss_start; 149 155 150 /* Architecture and machine type */156 /* Architecture and machine type. */ 151 157 bfd_set_arch_mach (abfd, bfd_arch_i386, 0); 152 158 … … 155 161 obj_sym_filepos (abfd) = 0; 156 162 157 /* The alignments of the sections */163 /* The alignments of the sections. */ 158 164 obj_textsec (abfd)->alignment_power = execp->a_talign; 159 165 obj_datasec (abfd)->alignment_power = execp->a_dalign; … … 164 170 obj_datasec (abfd)->vma = execp->a_dload; 165 171 166 /* And reload the sizes, since the aout module zaps them */172 /* And reload the sizes, since the aout module zaps them. */ 167 173 obj_textsec (abfd)->_raw_size = execp->a_text; 168 174 169 bss_start = execp->a_dload + execp->a_data; /* BSS = end of data section */175 bss_start = execp->a_dload + execp->a_data; /* BSS = end of data section. */ 170 176 obj_bsssec (abfd)->vma = align_power (bss_start, execp->a_balign); 171 177 172 /* The file positions of the sections */178 /* The file positions of the sections. */ 173 179 obj_textsec (abfd)->filepos = execp->a_entry; 174 180 obj_datasec (abfd)->filepos = execp->a_dload; … … 176 182 /* The file positions of the relocation info *** 177 183 obj_textsec (abfd)->rel_filepos = N_TROFF(*execp); 178 obj_datasec (abfd)->rel_filepos = N_DROFF(*execp); 179 */ 180 181 adata (abfd).page_size = 1; /* Not applicable. */ 182 adata (abfd).segment_size = 1;/* Not applicable. */ 184 obj_datasec (abfd)->rel_filepos = N_DROFF(*execp); */ 185 186 adata (abfd).page_size = 1; /* Not applicable. */ 187 adata (abfd).segment_size = 1;/* Not applicable. */ 183 188 adata (abfd).exec_bytes_size = MHCOM_BYTES_SIZE; 184 189 … … 193 198 }; 194 199 195 static b oolean200 static bfd_boolean 196 201 os9k_mkobject (abfd) 197 202 bfd *abfd; 198 203 { 199 204 struct bout_data_struct *rawptr; 200 201 rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct)); 205 bfd_size_type amt = sizeof (struct bout_data_struct); 206 207 rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, amt); 202 208 if (rawptr == NULL) 203 return false;209 return FALSE; 204 210 205 211 abfd->tdata.bout_data = rawptr; … … 210 216 obj_bsssec (abfd) = (asection *) NULL; 211 217 212 return true;213 } 214 215 static b oolean218 return TRUE; 219 } 220 221 static bfd_boolean 216 222 os9k_write_object_contents (abfd) 217 223 bfd *abfd; … … 220 226 221 227 if (! aout_32_make_sections (abfd)) 222 return false;228 return FALSE; 223 229 224 230 exec_hdr (abfd)->a_info = BMAGIC; … … 244 250 245 251 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 246 || (bfd_write ((PTR) & swapped_hdr, 1, EXEC_BYTES_SIZE, abfd)247 != EXEC_BYTES_SIZE))248 return false;249 250 /* Now write out reloc info, followed by syms and strings */252 || bfd_bwrite ((PTR) & swapped_hdr, (bfd_size_type) EXEC_BYTES_SIZE, 253 abfd) != EXEC_BYTES_SIZE) 254 return FALSE; 255 256 /* Now write out reloc info, followed by syms and strings. */ 251 257 if (bfd_get_symcount (abfd) != 0) 252 258 { 253 259 if (bfd_seek (abfd, (file_ptr) (N_SYMOFF (*exec_hdr (abfd))), SEEK_SET) 254 260 != 0) 255 return false;261 return FALSE; 256 262 257 263 if (!aout_32_write_syms (abfd)) 258 return false;264 return FALSE; 259 265 260 266 if (bfd_seek (abfd, (file_ptr) (N_TROFF (*exec_hdr (abfd))), SEEK_SET) 261 267 != 0) 262 return false;268 return FALSE; 263 269 264 270 if (!b_out_squirt_out_relocs (abfd, obj_textsec (abfd))) 265 return false;271 return FALSE; 266 272 if (bfd_seek (abfd, (file_ptr) (N_DROFF (*exec_hdr (abfd))), SEEK_SET) 267 273 != 0) 268 return false;274 return FALSE; 269 275 270 276 if (!b_out_squirt_out_relocs (abfd, obj_datasec (abfd))) 271 return false;272 } 273 return true;274 } 275 276 277 static b oolean277 return FALSE; 278 } 279 return TRUE; 280 } 281 282 283 static bfd_boolean 278 284 os9k_set_section_contents (abfd, section, location, offset, count) 279 285 bfd *abfd; … … 284 290 { 285 291 286 if ( abfd->output_has_begun == false)292 if (! abfd->output_has_begun) 287 293 { /* set by bfd.c handler */ 288 294 if (! aout_32_make_sections (abfd)) 289 return false;295 return FALSE; 290 296 291 297 obj_textsec (abfd)->filepos = sizeof (struct internal_exec); … … 294 300 295 301 } 296 /* regardless, once we know what we're doing, we might as well get going*/302 /* Regardless, once we know what we're doing, we might as well get going. */ 297 303 if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0) 298 return false;304 return FALSE; 299 305 300 306 if (count != 0) 301 { 302 return (bfd_write ((PTR) location, 1, count, abfd) == count) ? true : false; 303 } 304 return true; 307 return bfd_bwrite ((PTR) location, (bfd_size_type) count, abfd) == count; 308 309 return TRUE; 305 310 } 306 311 #endif /* 0 */ … … 309 314 os9k_sizeof_headers (ignore_abfd, ignore) 310 315 bfd *ignore_abfd ATTRIBUTE_UNUSED; 311 b oolean ignore ATTRIBUTE_UNUSED;316 bfd_boolean ignore ATTRIBUTE_UNUSED; 312 317 { 313 318 return sizeof (struct internal_exec); … … 315 320 316 321 317 /***********************************************************************/ 322 318 323 319 324 #define aout_32_close_and_cleanup aout_32_bfd_free_cached_info … … 330 335 #define os9k_bfd_relax_section bfd_generic_relax_section 331 336 #define os9k_bfd_gc_sections bfd_generic_gc_sections 337 #define os9k_bfd_merge_sections bfd_generic_merge_sections 338 #define os9k_bfd_discard_group bfd_generic_discard_group 332 339 #define os9k_bfd_link_hash_table_create _bfd_generic_link_hash_table_create 340 #define os9k_bfd_link_hash_table_free _bfd_generic_link_hash_table_free 333 341 #define os9k_bfd_link_add_symbols _bfd_generic_link_add_symbols 342 #define os9k_bfd_link_just_syms _bfd_generic_link_just_syms 334 343 #define os9k_bfd_final_link _bfd_generic_final_link 335 344 #define os9k_bfd_link_split_section _bfd_generic_link_split_section 336 345 337 346 const bfd_target i386os9k_vec = 338 {339 "i386os9k", /* name */340 bfd_target_os9k_flavour,341 BFD_ENDIAN_LITTLE, /* data byte order is little */342 BFD_ENDIAN_LITTLE, /* hdr byte order is little */343 (HAS_RELOC | EXEC_P | WP_TEXT), /* object flags */344 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD), /* section flags */345 0, /* symbol leading char */346 ' ', /* ar_pad_char */347 16, /* ar_max_namelen */348 349 bfd_getl64, bfd_getl_signed_64, bfd_putl64,350 bfd_getl32, bfd_getl_signed_32, bfd_putl32,351 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */352 bfd_getl64, bfd_getl_signed_64, bfd_putl64,353 bfd_getl32, bfd_getl_signed_32, bfd_putl32,354 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */355 {_bfd_dummy_target, os9k_object_p, /* bfd_check_format */356 bfd_generic_archive_p, _bfd_dummy_target},357 {bfd_false, bfd_false, /* bfd_set_format */358 _bfd_generic_mkarchive, bfd_false},359 {bfd_false, bfd_false, /* bfd_write_contents */360 _bfd_write_archive_contents, bfd_false},361 362 363 364 365 366 367 368 369 370 371 372 NULL,373 374 (PTR) 0,375 };347 { 348 "i386os9k", /* name */ 349 bfd_target_os9k_flavour, 350 BFD_ENDIAN_LITTLE, /* data byte order is little */ 351 BFD_ENDIAN_LITTLE, /* hdr byte order is little */ 352 (HAS_RELOC | EXEC_P | WP_TEXT), /* object flags */ 353 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD), /* section flags */ 354 0, /* symbol leading char */ 355 ' ', /* ar_pad_char */ 356 16, /* ar_max_namelen */ 357 358 bfd_getl64, bfd_getl_signed_64, bfd_putl64, 359 bfd_getl32, bfd_getl_signed_32, bfd_putl32, 360 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */ 361 bfd_getl64, bfd_getl_signed_64, bfd_putl64, 362 bfd_getl32, bfd_getl_signed_32, bfd_putl32, 363 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ 364 {_bfd_dummy_target, os9k_object_p, /* bfd_check_format */ 365 bfd_generic_archive_p, _bfd_dummy_target}, 366 {bfd_false, bfd_false, /* bfd_set_format */ 367 _bfd_generic_mkarchive, bfd_false}, 368 {bfd_false, bfd_false, /* bfd_write_contents */ 369 _bfd_write_archive_contents, bfd_false}, 370 371 BFD_JUMP_TABLE_GENERIC (aout_32), 372 BFD_JUMP_TABLE_COPY (_bfd_generic), 373 BFD_JUMP_TABLE_CORE (_bfd_nocore), 374 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd), 375 BFD_JUMP_TABLE_SYMBOLS (aout_32), 376 BFD_JUMP_TABLE_RELOCS (aout_32), 377 BFD_JUMP_TABLE_WRITE (aout_32), 378 BFD_JUMP_TABLE_LINK (os9k), 379 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), 380 381 NULL, 382 383 (PTR) 0, 384 }; -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.