00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 #include "bfd.h"
00127 #include "sysdep.h"
00128 #include "libbfd.h"
00129 #include "libiberty.h"
00130 #include "safe-ctype.h"
00131
00132 static void ihex_init
00133 PARAMS ((void));
00134 static bfd_boolean ihex_mkobject
00135 PARAMS ((bfd *));
00136 static INLINE int ihex_get_byte
00137 PARAMS ((bfd *, bfd_boolean *));
00138 static void ihex_bad_byte
00139 PARAMS ((bfd *, unsigned int, int, bfd_boolean));
00140 static bfd_boolean ihex_scan
00141 PARAMS ((bfd *));
00142 static const bfd_target *ihex_object_p
00143 PARAMS ((bfd *));
00144 static bfd_boolean ihex_read_section
00145 PARAMS ((bfd *, asection *, bfd_byte *));
00146 static bfd_boolean ihex_get_section_contents
00147 PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
00148 static bfd_boolean ihex_set_section_contents
00149 PARAMS ((bfd *, asection *, const PTR, file_ptr, bfd_size_type));
00150 static bfd_boolean ihex_write_record
00151 PARAMS ((bfd *, size_t, unsigned int, unsigned int, bfd_byte *));
00152 static bfd_boolean ihex_write_object_contents
00153 PARAMS ((bfd *));
00154 static bfd_boolean ihex_set_arch_mach
00155 PARAMS ((bfd *, enum bfd_architecture, unsigned long));
00156 static int ihex_sizeof_headers
00157 PARAMS ((bfd *, bfd_boolean));
00158
00159
00160
00161 #define CHUNK 16
00162
00163
00164
00165 #define NIBBLE(x) (hex_value (x))
00166 #define HEX2(buffer) ((NIBBLE ((buffer)[0]) << 4) + NIBBLE ((buffer)[1]))
00167 #define HEX4(buffer) ((HEX2 (buffer) << 8) + HEX2 ((buffer) + 2))
00168 #define ISHEX(x) (hex_p (x))
00169
00170
00171
00172
00173 struct ihex_data_list
00174 {
00175 struct ihex_data_list *next;
00176 bfd_byte *data;
00177 bfd_vma where;
00178 bfd_size_type size;
00179 };
00180
00181
00182
00183 struct ihex_data_struct
00184 {
00185 struct ihex_data_list *head;
00186 struct ihex_data_list *tail;
00187 };
00188
00189
00190
00191 static void
00192 ihex_init ()
00193 {
00194 static bfd_boolean inited;
00195
00196 if (! inited)
00197 {
00198 inited = TRUE;
00199 hex_init ();
00200 }
00201 }
00202
00203
00204
00205 static bfd_boolean
00206 ihex_mkobject (abfd)
00207 bfd *abfd;
00208 {
00209 struct ihex_data_struct *tdata;
00210 bfd_size_type amt = sizeof (struct ihex_data_struct);
00211
00212 tdata = (struct ihex_data_struct *) bfd_alloc (abfd, amt);
00213 if (tdata == NULL)
00214 return FALSE;
00215
00216 abfd->tdata.ihex_data = tdata;
00217 tdata->head = NULL;
00218 tdata->tail = NULL;
00219 return TRUE;
00220 }
00221
00222
00223
00224
00225 static INLINE int
00226 ihex_get_byte (abfd, errorptr)
00227 bfd *abfd;
00228 bfd_boolean *errorptr;
00229 {
00230 bfd_byte c;
00231
00232 if (bfd_bread (&c, (bfd_size_type) 1, abfd) != 1)
00233 {
00234 if (bfd_get_error () != bfd_error_file_truncated)
00235 *errorptr = TRUE;
00236 return EOF;
00237 }
00238
00239 return (int) (c & 0xff);
00240 }
00241
00242
00243
00244 static void
00245 ihex_bad_byte (abfd, lineno, c, error)
00246 bfd *abfd;
00247 unsigned int lineno;
00248 int c;
00249 bfd_boolean error;
00250 {
00251 if (c == EOF)
00252 {
00253 if (! error)
00254 bfd_set_error (bfd_error_file_truncated);
00255 }
00256 else
00257 {
00258 char buf[10];
00259
00260 if (! ISPRINT (c))
00261 sprintf (buf, "\\%03o", (unsigned int) c);
00262 else
00263 {
00264 buf[0] = c;
00265 buf[1] = '\0';
00266 }
00267 (*_bfd_error_handler)
00268 (_("%B:%d: unexpected character `%s' in Intel Hex file"),
00269 abfd, lineno, buf);
00270 bfd_set_error (bfd_error_bad_value);
00271 }
00272 }
00273
00274
00275
00276
00277 static bfd_boolean
00278 ihex_scan (abfd)
00279 bfd *abfd;
00280 {
00281 bfd_vma segbase;
00282 bfd_vma extbase;
00283 asection *sec;
00284 unsigned int lineno;
00285 bfd_boolean error;
00286 bfd_byte *buf = NULL;
00287 size_t bufsize;
00288 int c;
00289
00290 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
00291 goto error_return;
00292
00293 abfd->start_address = 0;
00294
00295 segbase = 0;
00296 extbase = 0;
00297 sec = NULL;
00298 lineno = 1;
00299 error = FALSE;
00300 bufsize = 0;
00301
00302 while ((c = ihex_get_byte (abfd, &error)) != EOF)
00303 {
00304 if (c == '\r')
00305 continue;
00306 else if (c == '\n')
00307 {
00308 ++lineno;
00309 continue;
00310 }
00311 else if (c != ':')
00312 {
00313 ihex_bad_byte (abfd, lineno, c, error);
00314 goto error_return;
00315 }
00316 else
00317 {
00318 file_ptr pos;
00319 char hdr[8];
00320 unsigned int i;
00321 unsigned int len;
00322 bfd_vma addr;
00323 unsigned int type;
00324 unsigned int chars;
00325 unsigned int chksum;
00326
00327
00328 pos = bfd_tell (abfd) - 1;
00329
00330
00331 if (bfd_bread (hdr, (bfd_size_type) 8, abfd) != 8)
00332 goto error_return;
00333
00334 for (i = 0; i < 8; i++)
00335 {
00336 if (! ISHEX (hdr[i]))
00337 {
00338 ihex_bad_byte (abfd, lineno, hdr[i], error);
00339 goto error_return;
00340 }
00341 }
00342
00343 len = HEX2 (hdr);
00344 addr = HEX4 (hdr + 2);
00345 type = HEX2 (hdr + 6);
00346
00347
00348 chars = len * 2 + 2;
00349 if (chars >= bufsize)
00350 {
00351 buf = (bfd_byte *) bfd_realloc (buf, (bfd_size_type) chars);
00352 if (buf == NULL)
00353 goto error_return;
00354 bufsize = chars;
00355 }
00356
00357 if (bfd_bread (buf, (bfd_size_type) chars, abfd) != chars)
00358 goto error_return;
00359
00360 for (i = 0; i < chars; i++)
00361 {
00362 if (! ISHEX (buf[i]))
00363 {
00364 ihex_bad_byte (abfd, lineno, hdr[i], error);
00365 goto error_return;
00366 }
00367 }
00368
00369
00370 chksum = len + addr + (addr >> 8) + type;
00371 for (i = 0; i < len; i++)
00372 chksum += HEX2 (buf + 2 * i);
00373 if (((- chksum) & 0xff) != (unsigned int) HEX2 (buf + 2 * i))
00374 {
00375 (*_bfd_error_handler)
00376 (_("%B:%u: bad checksum in Intel Hex file (expected %u, found %u)"),
00377 abfd, lineno,
00378 (- chksum) & 0xff, (unsigned int) HEX2 (buf + 2 * i));
00379 bfd_set_error (bfd_error_bad_value);
00380 goto error_return;
00381 }
00382
00383 switch (type)
00384 {
00385 case 0:
00386
00387 if (sec != NULL
00388 && sec->vma + sec->size == extbase + segbase + addr)
00389 {
00390
00391
00392 sec->size += len;
00393 }
00394 else if (len > 0)
00395 {
00396 char secbuf[20];
00397 char *secname;
00398 bfd_size_type amt;
00399
00400 sprintf (secbuf, ".sec%d", bfd_count_sections (abfd) + 1);
00401 amt = strlen (secbuf) + 1;
00402 secname = (char *) bfd_alloc (abfd, amt);
00403 if (secname == NULL)
00404 goto error_return;
00405 strcpy (secname, secbuf);
00406 sec = bfd_make_section (abfd, secname);
00407 if (sec == NULL)
00408 goto error_return;
00409 sec->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
00410 sec->vma = extbase + segbase + addr;
00411 sec->lma = extbase + segbase + addr;
00412 sec->size = len;
00413 sec->filepos = pos;
00414 }
00415 break;
00416
00417 case 1:
00418
00419 if (abfd->start_address == 0)
00420 abfd->start_address = addr;
00421 if (buf != NULL)
00422 free (buf);
00423 return TRUE;
00424
00425 case 2:
00426
00427 if (len != 2)
00428 {
00429 (*_bfd_error_handler)
00430 (_("%B:%u: bad extended address record length in Intel Hex file"),
00431 abfd, lineno);
00432 bfd_set_error (bfd_error_bad_value);
00433 goto error_return;
00434 }
00435
00436 segbase = HEX4 (buf) << 4;
00437
00438 sec = NULL;
00439
00440 break;
00441
00442 case 3:
00443
00444 if (len != 4)
00445 {
00446 (*_bfd_error_handler)
00447 (_("%B:%u: bad extended start address length in Intel Hex file"),
00448 abfd, lineno);
00449 bfd_set_error (bfd_error_bad_value);
00450 goto error_return;
00451 }
00452
00453 abfd->start_address += (HEX4 (buf) << 4) + HEX4 (buf + 4);
00454
00455 sec = NULL;
00456
00457 break;
00458
00459 case 4:
00460
00461 if (len != 2)
00462 {
00463 (*_bfd_error_handler)
00464 (_("%B:%u: bad extended linear address record length in Intel Hex file"),
00465 abfd, lineno);
00466 bfd_set_error (bfd_error_bad_value);
00467 goto error_return;
00468 }
00469
00470 extbase = HEX4 (buf) << 16;
00471
00472 sec = NULL;
00473
00474 break;
00475
00476 case 5:
00477
00478 if (len != 2 && len != 4)
00479 {
00480 (*_bfd_error_handler)
00481 (_("%B:%u: bad extended linear start address length in Intel Hex file"),
00482 abfd, lineno);
00483 bfd_set_error (bfd_error_bad_value);
00484 goto error_return;
00485 }
00486
00487 if (len == 2)
00488 abfd->start_address += HEX4 (buf) << 16;
00489 else
00490 abfd->start_address = (HEX4 (buf) << 16) + HEX4 (buf + 4);
00491
00492 sec = NULL;
00493
00494 break;
00495
00496 default:
00497 (*_bfd_error_handler)
00498 (_("%B:%u: unrecognized ihex type %u in Intel Hex file"),
00499 abfd, lineno, type);
00500 bfd_set_error (bfd_error_bad_value);
00501 goto error_return;
00502 }
00503 }
00504 }
00505
00506 if (error)
00507 goto error_return;
00508
00509 if (buf != NULL)
00510 free (buf);
00511
00512 return TRUE;
00513
00514 error_return:
00515 if (buf != NULL)
00516 free (buf);
00517 return FALSE;
00518 }
00519
00520
00521
00522 static const bfd_target *
00523 ihex_object_p (abfd)
00524 bfd *abfd;
00525 {
00526 PTR tdata_save;
00527 bfd_byte b[9];
00528 unsigned int i;
00529 unsigned int type;
00530
00531 ihex_init ();
00532
00533 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
00534 return NULL;
00535 if (bfd_bread (b, (bfd_size_type) 9, abfd) != 9)
00536 {
00537 if (bfd_get_error () == bfd_error_file_truncated)
00538 bfd_set_error (bfd_error_wrong_format);
00539 return NULL;
00540 }
00541
00542 if (b[0] != ':')
00543 {
00544 bfd_set_error (bfd_error_wrong_format);
00545 return NULL;
00546 }
00547
00548 for (i = 1; i < 9; i++)
00549 {
00550 if (! ISHEX (b[i]))
00551 {
00552 bfd_set_error (bfd_error_wrong_format);
00553 return NULL;
00554 }
00555 }
00556
00557 type = HEX2 (b + 7);
00558 if (type > 5)
00559 {
00560 bfd_set_error (bfd_error_wrong_format);
00561 return NULL;
00562 }
00563
00564
00565 tdata_save = abfd->tdata.any;
00566 if (! ihex_mkobject (abfd) || ! ihex_scan (abfd))
00567 {
00568 if (abfd->tdata.any != tdata_save && abfd->tdata.any != NULL)
00569 bfd_release (abfd, abfd->tdata.any);
00570 abfd->tdata.any = tdata_save;
00571 return NULL;
00572 }
00573
00574 return abfd->xvec;
00575 }
00576
00577
00578
00579 static bfd_boolean
00580 ihex_read_section (abfd, section, contents)
00581 bfd *abfd;
00582 asection *section;
00583 bfd_byte *contents;
00584 {
00585 int c;
00586 bfd_byte *p;
00587 bfd_byte *buf = NULL;
00588 size_t bufsize;
00589 bfd_boolean error;
00590
00591 if (bfd_seek (abfd, section->filepos, SEEK_SET) != 0)
00592 goto error_return;
00593
00594 p = contents;
00595 bufsize = 0;
00596 error = FALSE;
00597 while ((c = ihex_get_byte (abfd, &error)) != EOF)
00598 {
00599 char hdr[8];
00600 unsigned int len;
00601 bfd_vma addr;
00602 unsigned int type;
00603 unsigned int i;
00604
00605 if (c == '\r' || c == '\n')
00606 continue;
00607
00608
00609
00610 BFD_ASSERT (c == ':');
00611
00612 if (bfd_bread (hdr, (bfd_size_type) 8, abfd) != 8)
00613 goto error_return;
00614
00615 len = HEX2 (hdr);
00616 addr = HEX4 (hdr + 2);
00617 type = HEX2 (hdr + 6);
00618
00619
00620 if (type != 0)
00621 {
00622 (*_bfd_error_handler)
00623 (_("%B: internal error in ihex_read_section"), abfd);
00624 bfd_set_error (bfd_error_bad_value);
00625 goto error_return;
00626 }
00627
00628 if (len * 2 > bufsize)
00629 {
00630 buf = (bfd_byte *) bfd_realloc (buf, (bfd_size_type) len * 2);
00631 if (buf == NULL)
00632 goto error_return;
00633 bufsize = len * 2;
00634 }
00635
00636 if (bfd_bread (buf, (bfd_size_type) len * 2, abfd) != len * 2)
00637 goto error_return;
00638
00639 for (i = 0; i < len; i++)
00640 *p++ = HEX2 (buf + 2 * i);
00641 if ((bfd_size_type) (p - contents) >= section->size)
00642 {
00643
00644 if (buf != NULL)
00645 free (buf);
00646 return TRUE;
00647 }
00648
00649
00650 if (bfd_bread (buf, (bfd_size_type) 2, abfd) != 2)
00651 goto error_return;
00652 }
00653
00654 if ((bfd_size_type) (p - contents) < section->size)
00655 {
00656 (*_bfd_error_handler)
00657 (_("%B: bad section length in ihex_read_section"), abfd);
00658 bfd_set_error (bfd_error_bad_value);
00659 goto error_return;
00660 }
00661
00662 if (buf != NULL)
00663 free (buf);
00664
00665 return TRUE;
00666
00667 error_return:
00668 if (buf != NULL)
00669 free (buf);
00670 return FALSE;
00671 }
00672
00673
00674
00675 static bfd_boolean
00676 ihex_get_section_contents (abfd, section, location, offset, count)
00677 bfd *abfd;
00678 asection *section;
00679 PTR location;
00680 file_ptr offset;
00681 bfd_size_type count;
00682 {
00683 if (section->used_by_bfd == NULL)
00684 {
00685 section->used_by_bfd = bfd_alloc (abfd, section->size);
00686 if (section->used_by_bfd == NULL)
00687 return FALSE;
00688 if (! ihex_read_section (abfd, section, section->used_by_bfd))
00689 return FALSE;
00690 }
00691
00692 memcpy (location, (bfd_byte *) section->used_by_bfd + offset,
00693 (size_t) count);
00694
00695 return TRUE;
00696 }
00697
00698
00699
00700 static bfd_boolean
00701 ihex_set_section_contents (abfd, section, location, offset, count)
00702 bfd *abfd;
00703 asection *section;
00704 const PTR location;
00705 file_ptr offset;
00706 bfd_size_type count;
00707 {
00708 struct ihex_data_list *n;
00709 bfd_byte *data;
00710 struct ihex_data_struct *tdata;
00711 bfd_size_type amt;
00712
00713 if (count == 0
00714 || (section->flags & SEC_ALLOC) == 0
00715 || (section->flags & SEC_LOAD) == 0)
00716 return TRUE;
00717
00718 amt = sizeof (struct ihex_data_list);
00719 n = (struct ihex_data_list *) bfd_alloc (abfd, amt);
00720 if (n == NULL)
00721 return FALSE;
00722
00723 data = (bfd_byte *) bfd_alloc (abfd, count);
00724 if (data == NULL)
00725 return FALSE;
00726 memcpy (data, location, (size_t) count);
00727
00728 n->data = data;
00729 n->where = section->lma + offset;
00730 n->size = count;
00731
00732
00733
00734 tdata = abfd->tdata.ihex_data;
00735 if (tdata->tail != NULL
00736 && n->where >= tdata->tail->where)
00737 {
00738 tdata->tail->next = n;
00739 n->next = NULL;
00740 tdata->tail = n;
00741 }
00742 else
00743 {
00744 register struct ihex_data_list **pp;
00745
00746 for (pp = &tdata->head;
00747 *pp != NULL && (*pp)->where < n->where;
00748 pp = &(*pp)->next)
00749 ;
00750 n->next = *pp;
00751 *pp = n;
00752 if (n->next == NULL)
00753 tdata->tail = n;
00754 }
00755
00756 return TRUE;
00757 }
00758
00759
00760
00761 static bfd_boolean
00762 ihex_write_record (abfd, count, addr, type, data)
00763 bfd *abfd;
00764 size_t count;
00765 unsigned int addr;
00766 unsigned int type;
00767 bfd_byte *data;
00768 {
00769 static const char digs[] = "0123456789ABCDEF";
00770 char buf[9 + CHUNK * 2 + 4];
00771 char *p;
00772 unsigned int chksum;
00773 unsigned int i;
00774 size_t total;
00775
00776 #define TOHEX(buf, v) \
00777 ((buf)[0] = digs[((v) >> 4) & 0xf], (buf)[1] = digs[(v) & 0xf])
00778
00779 buf[0] = ':';
00780 TOHEX (buf + 1, count);
00781 TOHEX (buf + 3, (addr >> 8) & 0xff);
00782 TOHEX (buf + 5, addr & 0xff);
00783 TOHEX (buf + 7, type);
00784
00785 chksum = count + addr + (addr >> 8) + type;
00786
00787 for (i = 0, p = buf + 9; i < count; i++, p += 2, data++)
00788 {
00789 TOHEX (p, *data);
00790 chksum += *data;
00791 }
00792
00793 TOHEX (p, (- chksum) & 0xff);
00794 p[2] = '\r';
00795 p[3] = '\n';
00796
00797 total = 9 + count * 2 + 4;
00798 if (bfd_bwrite (buf, (bfd_size_type) total, abfd) != total)
00799 return FALSE;
00800
00801 return TRUE;
00802 }
00803
00804
00805
00806 static bfd_boolean
00807 ihex_write_object_contents (abfd)
00808 bfd *abfd;
00809 {
00810 bfd_vma segbase;
00811 bfd_vma extbase;
00812 struct ihex_data_list *l;
00813
00814 segbase = 0;
00815 extbase = 0;
00816 for (l = abfd->tdata.ihex_data->head; l != NULL; l = l->next)
00817 {
00818 bfd_vma where;
00819 bfd_byte *p;
00820 bfd_size_type count;
00821
00822 where = l->where;
00823 p = l->data;
00824 count = l->size;
00825 while (count > 0)
00826 {
00827 size_t now;
00828 unsigned int rec_addr;
00829
00830 now = count;
00831 if (count > CHUNK)
00832 now = CHUNK;
00833
00834 if (where > segbase + extbase + 0xffff)
00835 {
00836 bfd_byte addr[2];
00837
00838
00839 if (where <= 0xfffff)
00840 {
00841
00842 BFD_ASSERT (extbase == 0);
00843
00844 segbase = where & 0xf0000;
00845 addr[0] = (bfd_byte)(segbase >> 12) & 0xff;
00846 addr[1] = (bfd_byte)(segbase >> 4) & 0xff;
00847 if (! ihex_write_record (abfd, 2, 0, 2, addr))
00848 return FALSE;
00849 }
00850 else
00851 {
00852
00853
00854
00855
00856
00857
00858 if (segbase != 0)
00859 {
00860 addr[0] = 0;
00861 addr[1] = 0;
00862 if (! ihex_write_record (abfd, 2, 0, 2, addr))
00863 return FALSE;
00864 segbase = 0;
00865 }
00866
00867 extbase = where & 0xffff0000;
00868 if (where > extbase + 0xffff)
00869 {
00870 char buf[20];
00871
00872 sprintf_vma (buf, where);
00873 (*_bfd_error_handler)
00874 (_("%s: address 0x%s out of range for Intel Hex file"),
00875 bfd_get_filename (abfd), buf);
00876 bfd_set_error (bfd_error_bad_value);
00877 return FALSE;
00878 }
00879 addr[0] = (bfd_byte)(extbase >> 24) & 0xff;
00880 addr[1] = (bfd_byte)(extbase >> 16) & 0xff;
00881 if (! ihex_write_record (abfd, 2, 0, 4, addr))
00882 return FALSE;
00883 }
00884 }
00885
00886 rec_addr = where - (extbase + segbase);
00887
00888
00889 if (rec_addr + now > 0xffff)
00890 now = 0x10000 - rec_addr;
00891
00892 if (! ihex_write_record (abfd, now, rec_addr, 0, p))
00893 return FALSE;
00894
00895 where += now;
00896 p += now;
00897 count -= now;
00898 }
00899 }
00900
00901 if (abfd->start_address != 0)
00902 {
00903 bfd_vma start;
00904 bfd_byte startbuf[4];
00905
00906 start = abfd->start_address;
00907
00908 if (start <= 0xfffff)
00909 {
00910 startbuf[0] = (bfd_byte)((start & 0xf0000) >> 12) & 0xff;
00911 startbuf[1] = 0;
00912 startbuf[2] = (bfd_byte)(start >> 8) & 0xff;
00913 startbuf[3] = (bfd_byte)start & 0xff;
00914 if (! ihex_write_record (abfd, 4, 0, 3, startbuf))
00915 return FALSE;
00916 }
00917 else
00918 {
00919 startbuf[0] = (bfd_byte)(start >> 24) & 0xff;
00920 startbuf[1] = (bfd_byte)(start >> 16) & 0xff;
00921 startbuf[2] = (bfd_byte)(start >> 8) & 0xff;
00922 startbuf[3] = (bfd_byte)start & 0xff;
00923 if (! ihex_write_record (abfd, 4, 0, 5, startbuf))
00924 return FALSE;
00925 }
00926 }
00927
00928 if (! ihex_write_record (abfd, 0, 0, 1, NULL))
00929 return FALSE;
00930
00931 return TRUE;
00932 }
00933
00934
00935
00936
00937 static bfd_boolean
00938 ihex_set_arch_mach (abfd, arch, mach)
00939 bfd *abfd;
00940 enum bfd_architecture arch;
00941 unsigned long mach;
00942 {
00943 if (! bfd_default_set_arch_mach (abfd, arch, mach))
00944 {
00945 if (arch != bfd_arch_unknown)
00946 return FALSE;
00947 }
00948 return TRUE;
00949 }
00950
00951
00952
00953 static int
00954 ihex_sizeof_headers (abfd, exec)
00955 bfd *abfd ATTRIBUTE_UNUSED;
00956 bfd_boolean exec ATTRIBUTE_UNUSED;
00957 {
00958 return 0;
00959 }
00960
00961
00962
00963 #define ihex_close_and_cleanup _bfd_generic_close_and_cleanup
00964 #define ihex_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
00965 #define ihex_new_section_hook _bfd_generic_new_section_hook
00966 #define ihex_get_section_contents_in_window \
00967 _bfd_generic_get_section_contents_in_window
00968
00969 #define ihex_get_symtab_upper_bound bfd_0l
00970 #define ihex_canonicalize_symtab \
00971 ((long (*) PARAMS ((bfd *, asymbol **))) bfd_0l)
00972 #define ihex_make_empty_symbol _bfd_generic_make_empty_symbol
00973 #define ihex_print_symbol _bfd_nosymbols_print_symbol
00974 #define ihex_get_symbol_info _bfd_nosymbols_get_symbol_info
00975 #define ihex_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
00976 #define ihex_bfd_is_local_label_name _bfd_nosymbols_bfd_is_local_label_name
00977 #define ihex_get_lineno _bfd_nosymbols_get_lineno
00978 #define ihex_find_nearest_line _bfd_nosymbols_find_nearest_line
00979 #define ihex_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
00980 #define ihex_read_minisymbols _bfd_nosymbols_read_minisymbols
00981 #define ihex_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
00982
00983 #define ihex_get_reloc_upper_bound \
00984 ((long (*) PARAMS ((bfd *, asection *))) bfd_0l)
00985 #define ihex_canonicalize_reloc \
00986 ((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) bfd_0l)
00987 #define ihex_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
00988
00989 #define ihex_bfd_get_relocated_section_contents \
00990 bfd_generic_get_relocated_section_contents
00991 #define ihex_bfd_relax_section bfd_generic_relax_section
00992 #define ihex_bfd_gc_sections bfd_generic_gc_sections
00993 #define ihex_bfd_merge_sections bfd_generic_merge_sections
00994 #define ihex_bfd_is_group_section bfd_generic_is_group_section
00995 #define ihex_bfd_discard_group bfd_generic_discard_group
00996 #define ihex_section_already_linked \
00997 _bfd_generic_section_already_linked
00998 #define ihex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
00999 #define ihex_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
01000 #define ihex_bfd_link_add_symbols _bfd_generic_link_add_symbols
01001 #define ihex_bfd_link_just_syms _bfd_generic_link_just_syms
01002 #define ihex_bfd_final_link _bfd_generic_final_link
01003 #define ihex_bfd_link_split_section _bfd_generic_link_split_section
01004
01005
01006
01007 const bfd_target ihex_vec =
01008 {
01009 "ihex",
01010 bfd_target_ihex_flavour,
01011 BFD_ENDIAN_UNKNOWN,
01012 BFD_ENDIAN_UNKNOWN,
01013 0,
01014 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD),
01015 0,
01016 ' ',
01017 16,
01018 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
01019 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
01020 bfd_getb16, bfd_getb_signed_16, bfd_putb16,
01021 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
01022 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
01023 bfd_getb16, bfd_getb_signed_16, bfd_putb16,
01024
01025 {
01026 _bfd_dummy_target,
01027 ihex_object_p,
01028 _bfd_dummy_target,
01029 _bfd_dummy_target,
01030 },
01031 {
01032 bfd_false,
01033 ihex_mkobject,
01034 _bfd_generic_mkarchive,
01035 bfd_false,
01036 },
01037 {
01038 bfd_false,
01039 ihex_write_object_contents,
01040 _bfd_write_archive_contents,
01041 bfd_false,
01042 },
01043
01044 BFD_JUMP_TABLE_GENERIC (ihex),
01045 BFD_JUMP_TABLE_COPY (_bfd_generic),
01046 BFD_JUMP_TABLE_CORE (_bfd_nocore),
01047 BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
01048 BFD_JUMP_TABLE_SYMBOLS (ihex),
01049 BFD_JUMP_TABLE_RELOCS (ihex),
01050 BFD_JUMP_TABLE_WRITE (ihex),
01051 BFD_JUMP_TABLE_LINK (ihex),
01052 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
01053
01054 NULL,
01055
01056 (PTR) 0
01057 };