mirror of
https://frontier.innolan.net/github/amigaos-binutils.git
synced 2025-11-19 19:40:19 +00:00
Add a helper function to read a 16-bit value.
* bfd/amigaos.c (get_word): New helper function. (amiga_handle_rest): Use new helper function. (read_raw_relocs): Likewise.
This commit is contained in:
@ -161,6 +161,7 @@ typedef struct amiga_ardata_struct {
|
|||||||
#define MAX_NAME_SIZE 124
|
#define MAX_NAME_SIZE 124
|
||||||
|
|
||||||
static bfd_boolean get_long PARAMS ((bfd *, unsigned long *));
|
static bfd_boolean get_long PARAMS ((bfd *, unsigned long *));
|
||||||
|
static bfd_boolean get_word PARAMS ((bfd *, unsigned long *));
|
||||||
static const struct bfd_target *amiga_object_p PARAMS ((bfd *));
|
static const struct bfd_target *amiga_object_p PARAMS ((bfd *));
|
||||||
static sec_ptr amiga_get_section_by_hunk_number PARAMS ((bfd *, long));
|
static sec_ptr amiga_get_section_by_hunk_number PARAMS ((bfd *, long));
|
||||||
static bfd_boolean amiga_add_reloc PARAMS ((bfd *, sec_ptr, bfd_size_type,
|
static bfd_boolean amiga_add_reloc PARAMS ((bfd *, sec_ptr, bfd_size_type,
|
||||||
@ -297,6 +298,17 @@ get_long (abfd, n)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bfd_boolean
|
||||||
|
get_word (abfd, n)
|
||||||
|
bfd *abfd;
|
||||||
|
unsigned long *n;
|
||||||
|
{
|
||||||
|
if (bfd_bread ((PTR)n, 2, abfd) != 2)
|
||||||
|
return FALSE;
|
||||||
|
*n = GW (n);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static const struct bfd_target *
|
static const struct bfd_target *
|
||||||
amiga_object_p (abfd)
|
amiga_object_p (abfd)
|
||||||
bfd *abfd;
|
bfd *abfd;
|
||||||
@ -1049,10 +1061,9 @@ amiga_handle_rest (abfd, current_section, isload)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
char buf[2];
|
if (!get_word (abfd, &no))
|
||||||
if (bfd_bread (buf, 2, abfd) != 2)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (no=GW(buf),!no)
|
if (!no)
|
||||||
break;
|
break;
|
||||||
relp->num += no;
|
relp->num += no;
|
||||||
if (bfd_seek (abfd, (no+1)<<1, SEEK_CUR))
|
if (bfd_seek (abfd, (no+1)<<1, SEEK_CUR))
|
||||||
@ -2513,21 +2524,18 @@ read_raw_relocs (abfd, section, d_offset, count)
|
|||||||
case HUNK_RELOC32SHORT:
|
case HUNK_RELOC32SHORT:
|
||||||
/* read reloc count, hunk number and offsets */
|
/* read reloc count, hunk number and offsets */
|
||||||
for (howto=&howto_table[R_ABS32SHORT];;) {
|
for (howto=&howto_table[R_ABS32SHORT];;) {
|
||||||
char buf[2];
|
/* read offsets and hunk number */
|
||||||
if (bfd_bread (buf, 2, abfd) != 2)
|
if (!get_word (abfd, &no))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (no=GW(buf),!no)
|
if (!no)
|
||||||
break;
|
break;
|
||||||
count -= no;
|
count -= no;
|
||||||
if (bfd_bread (buf, 2, abfd) != 2)
|
if (!get_word (abfd, &hunk_number))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
hunk_number = GW (buf);
|
|
||||||
/* add relocs */
|
/* add relocs */
|
||||||
for (j=0; j<no; j++) {
|
for (j=0; j<no; j++) {
|
||||||
if (bfd_bread (buf, 2, abfd) != 2)
|
if (!get_word (abfd, &offset) ||
|
||||||
return FALSE;
|
!amiga_add_reloc (abfd, section, offset, NULL, howto,
|
||||||
offset = GW (buf);
|
|
||||||
if (!amiga_add_reloc (abfd, section, offset, NULL, howto,
|
|
||||||
hunk_number))
|
hunk_number))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user