mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-11-16 12:34:43 +00:00
tidy coff-alpha.c
Remove K&R required casts. Formatting fixes. Localise vars in alpha_ecoff_get_elt_at_filepos and tidy decompression loop.
This commit is contained in:
@@ -97,7 +97,7 @@ static bfd_reloc_status_type
|
||||
reloc_nil (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
arelent *reloc ATTRIBUTE_UNUSED,
|
||||
asymbol *sym ATTRIBUTE_UNUSED,
|
||||
void * data ATTRIBUTE_UNUSED,
|
||||
void *data ATTRIBUTE_UNUSED,
|
||||
asection *sec ATTRIBUTE_UNUSED,
|
||||
bfd *output_bfd ATTRIBUTE_UNUSED,
|
||||
char **error_message ATTRIBUTE_UNUSED)
|
||||
@@ -419,7 +419,7 @@ alpha_ecoff_object_p (bfd *abfd)
|
||||
On output we will set the lnnoptr field and force the
|
||||
alignment. */
|
||||
sec = bfd_get_section_by_name (abfd, _PDATA);
|
||||
if (sec != (asection *) NULL)
|
||||
if (sec != NULL)
|
||||
{
|
||||
bfd_size_type size;
|
||||
|
||||
@@ -438,7 +438,7 @@ alpha_ecoff_object_p (bfd *abfd)
|
||||
|
||||
static bool
|
||||
alpha_ecoff_bad_format_hook (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
void * filehdr)
|
||||
void *filehdr)
|
||||
{
|
||||
struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
|
||||
|
||||
@@ -458,15 +458,15 @@ alpha_ecoff_bad_format_hook (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
specific information. */
|
||||
|
||||
static void *
|
||||
alpha_ecoff_mkobject_hook (bfd *abfd, void * filehdr, void * aouthdr)
|
||||
alpha_ecoff_mkobject_hook (bfd *abfd, void *filehdr, void *aouthdr)
|
||||
{
|
||||
void * ecoff;
|
||||
void *ecoff;
|
||||
|
||||
ecoff = _bfd_ecoff_mkobject_hook (abfd, filehdr, aouthdr);
|
||||
|
||||
if (ecoff != NULL)
|
||||
{
|
||||
struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
|
||||
struct internal_filehdr *internal_f = filehdr;
|
||||
|
||||
/* Set additional BFD flags according to the object type from the
|
||||
machine specific file header flags. */
|
||||
@@ -491,10 +491,10 @@ alpha_ecoff_mkobject_hook (bfd *abfd, void * filehdr, void * aouthdr)
|
||||
|
||||
static void
|
||||
alpha_ecoff_swap_reloc_in (bfd *abfd,
|
||||
void * ext_ptr,
|
||||
void *ext_ptr,
|
||||
struct internal_reloc *intern)
|
||||
{
|
||||
const RELOC *ext = (RELOC *) ext_ptr;
|
||||
const RELOC *ext = ext_ptr;
|
||||
|
||||
intern->r_vaddr = H_GET_64 (abfd, ext->r_vaddr);
|
||||
intern->r_symndx = H_GET_32 (abfd, ext->r_symndx);
|
||||
@@ -542,9 +542,9 @@ alpha_ecoff_swap_reloc_in (bfd *abfd,
|
||||
static void
|
||||
alpha_ecoff_swap_reloc_out (bfd *abfd,
|
||||
const struct internal_reloc *intern,
|
||||
void * dst)
|
||||
void *dst)
|
||||
{
|
||||
RELOC *ext = (RELOC *) dst;
|
||||
RELOC *ext = dst;
|
||||
long symndx;
|
||||
unsigned char size;
|
||||
|
||||
@@ -605,7 +605,7 @@ alpha_adjust_reloc_in (bfd *abfd,
|
||||
abfd, intern->r_type);
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
rptr->addend = 0;
|
||||
rptr->howto = NULL;
|
||||
rptr->howto = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -782,7 +782,7 @@ alpha_ecoff_get_relocated_section_contents (bfd *abfd,
|
||||
long reloc_size;
|
||||
arelent **reloc_vector;
|
||||
long reloc_count;
|
||||
bfd *output_bfd = relocatable ? abfd : (bfd *) NULL;
|
||||
bfd *output_bfd = relocatable ? abfd : NULL;
|
||||
bfd_vma gp;
|
||||
bool gp_undefined;
|
||||
bfd_vma stack[RELOC_STACKSIZE];
|
||||
@@ -802,7 +802,7 @@ alpha_ecoff_get_relocated_section_contents (bfd *abfd,
|
||||
if (reloc_size == 0)
|
||||
return data;
|
||||
|
||||
reloc_vector = (arelent **) bfd_malloc (reloc_size);
|
||||
reloc_vector = bfd_malloc (reloc_size);
|
||||
if (reloc_vector == NULL)
|
||||
goto error_return;
|
||||
|
||||
@@ -824,7 +824,7 @@ alpha_ecoff_get_relocated_section_contents (bfd *abfd,
|
||||
bfd_vma lo;
|
||||
|
||||
/* Make up a value. */
|
||||
lo = (bfd_vma) -1;
|
||||
lo = -1;
|
||||
for (sec = abfd->sections; sec != NULL; sec = sec->next)
|
||||
{
|
||||
if (sec->vma < lo
|
||||
@@ -844,7 +844,7 @@ alpha_ecoff_get_relocated_section_contents (bfd *abfd,
|
||||
|
||||
h = bfd_link_hash_lookup (link_info->hash, "_gp", false, false,
|
||||
true);
|
||||
if (h == (struct bfd_link_hash_entry *) NULL
|
||||
if (h == NULL
|
||||
|| h->type != bfd_link_hash_defined)
|
||||
gp_undefined = true;
|
||||
else
|
||||
@@ -1256,7 +1256,7 @@ alpha_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
alpha_type = ALPHA_R_SREL64;
|
||||
break;
|
||||
default:
|
||||
return (reloc_howto_type *) NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &alpha_howto_table[alpha_type];
|
||||
@@ -1310,7 +1310,7 @@ alpha_convert_external_reloc (bfd *output_bfd ATTRIBUTE_UNUSED,
|
||||
hsec = h->root.u.def.section;
|
||||
name = bfd_section_name (hsec->output_section);
|
||||
|
||||
r_symndx = (unsigned long) -1;
|
||||
r_symndx = -1ul;
|
||||
switch (name[1])
|
||||
{
|
||||
case 'A':
|
||||
@@ -1367,7 +1367,7 @@ alpha_convert_external_reloc (bfd *output_bfd ATTRIBUTE_UNUSED,
|
||||
break;
|
||||
}
|
||||
|
||||
if (r_symndx == (unsigned long) -1)
|
||||
if (r_symndx == -1ul)
|
||||
abort ();
|
||||
|
||||
/* Add the section VMA and the symbol value. */
|
||||
@@ -1380,7 +1380,7 @@ alpha_convert_external_reloc (bfd *output_bfd ATTRIBUTE_UNUSED,
|
||||
/* Change the symndx value to the right one for
|
||||
the output BFD. */
|
||||
r_symndx = h->indx;
|
||||
if (r_symndx == (unsigned long) -1)
|
||||
if (r_symndx == -1ul)
|
||||
{
|
||||
/* Caller must give an error. */
|
||||
r_symndx = 0;
|
||||
@@ -1404,7 +1404,7 @@ alpha_relocate_section (bfd *output_bfd,
|
||||
bfd *input_bfd,
|
||||
asection *input_section,
|
||||
bfd_byte *contents,
|
||||
void * external_relocs)
|
||||
void *external_relocs)
|
||||
{
|
||||
asection **symndx_to_section, *lita_sec;
|
||||
struct ecoff_link_hash_entry **sym_hashes;
|
||||
@@ -1421,10 +1421,10 @@ alpha_relocate_section (bfd *output_bfd,
|
||||
the appropriate section. This is faster than looking up the
|
||||
section by name each time. */
|
||||
symndx_to_section = ecoff_data (input_bfd)->symndx_to_section;
|
||||
if (symndx_to_section == (asection **) NULL)
|
||||
if (symndx_to_section == NULL)
|
||||
{
|
||||
amt = NUM_RELOC_SECTIONS * sizeof (asection *);
|
||||
symndx_to_section = (asection **) bfd_alloc (input_bfd, amt);
|
||||
symndx_to_section = bfd_alloc (input_bfd, amt);
|
||||
if (!symndx_to_section)
|
||||
return false;
|
||||
|
||||
@@ -1481,9 +1481,7 @@ alpha_relocate_section (bfd *output_bfd,
|
||||
lita_sec_data = ecoff_section_data (input_bfd, lita_sec);
|
||||
if (lita_sec_data == NULL)
|
||||
{
|
||||
amt = sizeof (struct ecoff_section_tdata);
|
||||
lita_sec_data = ((struct ecoff_section_tdata *)
|
||||
bfd_zalloc (input_bfd, amt));
|
||||
lita_sec_data = bfd_zalloc (input_bfd, sizeof (*lita_sec_data));
|
||||
lita_sec->used_by_bfd = lita_sec_data;
|
||||
}
|
||||
|
||||
@@ -1502,7 +1500,7 @@ alpha_relocate_section (bfd *output_bfd,
|
||||
lita_size = lita_sec->size;
|
||||
|
||||
if (gp == 0
|
||||
|| lita_vma < gp - 0x8000
|
||||
|| lita_vma < gp - 0x8000
|
||||
|| lita_vma + lita_size >= gp + 0x8000)
|
||||
{
|
||||
/* Either gp hasn't been set at all or the current gp
|
||||
@@ -1513,8 +1511,7 @@ alpha_relocate_section (bfd *output_bfd,
|
||||
{
|
||||
(*info->callbacks->warning) (info,
|
||||
_("using multiple gp values"),
|
||||
(char *) NULL, output_bfd,
|
||||
(asection *) NULL, (bfd_vma) 0);
|
||||
NULL, output_bfd, NULL, 0);
|
||||
ecoff_data (output_bfd)->issued_multiple_gp_warning = true;
|
||||
}
|
||||
if (lita_vma < gp - 0x8000)
|
||||
@@ -1535,7 +1532,7 @@ alpha_relocate_section (bfd *output_bfd,
|
||||
BFD_ASSERT (bfd_header_little_endian (output_bfd));
|
||||
BFD_ASSERT (bfd_header_little_endian (input_bfd));
|
||||
|
||||
ext_rel = (struct external_reloc *) external_relocs;
|
||||
ext_rel = external_relocs;
|
||||
ext_rel_end = ext_rel + input_section->reloc_count;
|
||||
for (; ext_rel < ext_rel_end; ext_rel++)
|
||||
{
|
||||
@@ -1732,7 +1729,7 @@ alpha_relocate_section (bfd *output_bfd,
|
||||
relocated. */
|
||||
(*info->callbacks->undefined_symbol)
|
||||
(info, h->root.root.string, input_bfd,
|
||||
input_section, (bfd_vma) 0, true);
|
||||
input_section, 0, true);
|
||||
addend = 0;
|
||||
}
|
||||
}
|
||||
@@ -1747,7 +1744,7 @@ alpha_relocate_section (bfd *output_bfd,
|
||||
above. */
|
||||
(*info->callbacks->unattached_reloc)
|
||||
(info, h->root.root.string,
|
||||
input_bfd, input_section, (bfd_vma) 0);
|
||||
input_bfd, input_section, 0);
|
||||
}
|
||||
|
||||
addend = alpha_convert_external_reloc (output_bfd, info,
|
||||
@@ -1982,8 +1979,7 @@ alpha_relocate_section (bfd *output_bfd,
|
||||
name = bfd_section_name (symndx_to_section[r_symndx]);
|
||||
(*info->callbacks->reloc_overflow)
|
||||
(info, NULL, name, alpha_howto_table[r_type].name,
|
||||
(bfd_vma) 0, input_bfd, input_section,
|
||||
r_vaddr - input_section->vma);
|
||||
0, input_bfd, input_section, r_vaddr - input_section->vma);
|
||||
}
|
||||
break;
|
||||
case bfd_reloc_outofrange:
|
||||
@@ -2066,7 +2062,7 @@ alpha_ecoff_read_ar_hdr (bfd *abfd)
|
||||
struct areltdata *ret;
|
||||
struct ar_hdr *h;
|
||||
|
||||
ret = (struct areltdata *) _bfd_generic_read_ar_hdr_mag (abfd, ARFZMAG);
|
||||
ret = _bfd_generic_read_ar_hdr_mag (abfd, ARFZMAG);
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -2103,7 +2099,7 @@ alpha_ecoff_get_elt_at_filepos (bfd *archive, file_ptr filepos,
|
||||
struct ar_hdr *hdr;
|
||||
bfd_byte ab[8];
|
||||
bfd_size_type size;
|
||||
bfd_byte *buf, *p;
|
||||
bfd_byte *buf;
|
||||
struct bfd_in_memory *bim;
|
||||
ufile_ptr filesize;
|
||||
|
||||
@@ -2118,7 +2114,7 @@ alpha_ecoff_get_elt_at_filepos (bfd *archive, file_ptr filepos,
|
||||
return nbfd;
|
||||
}
|
||||
|
||||
tdata = (struct areltdata *) nbfd->arelt_data;
|
||||
tdata = nbfd->arelt_data;
|
||||
hdr = (struct ar_hdr *) tdata->arch_header;
|
||||
if (strncmp (hdr->ar_fmag, ARFZMAG, 2) != 0)
|
||||
return nbfd;
|
||||
@@ -2149,12 +2145,12 @@ alpha_ecoff_get_elt_at_filepos (bfd *archive, file_ptr filepos,
|
||||
|
||||
if (size != 0)
|
||||
{
|
||||
bfd_byte *p;
|
||||
bfd_size_type left;
|
||||
bfd_byte dict[4096];
|
||||
unsigned int h;
|
||||
bfd_byte b;
|
||||
|
||||
buf = (bfd_byte *) bfd_malloc (size);
|
||||
buf = bfd_malloc (size);
|
||||
if (buf == NULL)
|
||||
goto error_return;
|
||||
p = buf;
|
||||
@@ -2173,11 +2169,13 @@ alpha_ecoff_get_elt_at_filepos (bfd *archive, file_ptr filepos,
|
||||
next eight bytes in the output stream. */
|
||||
memset (dict, 0, sizeof dict);
|
||||
h = 0;
|
||||
while (bfd_read (&b, 1, nbfd) == 1)
|
||||
do
|
||||
{
|
||||
unsigned int i;
|
||||
bfd_byte b;
|
||||
if (bfd_read (&b, 1, nbfd) != 1)
|
||||
goto error_return;
|
||||
|
||||
for (i = 0; i < 8; i++, b >>= 1)
|
||||
for (unsigned int i = 0; i < 8; i++, b >>= 1)
|
||||
{
|
||||
bfd_byte n;
|
||||
|
||||
@@ -2200,24 +2198,19 @@ alpha_ecoff_get_elt_at_filepos (bfd *archive, file_ptr filepos,
|
||||
h ^= n;
|
||||
h &= sizeof dict - 1;
|
||||
}
|
||||
|
||||
if (left == 0)
|
||||
break;
|
||||
}
|
||||
if (left != 0)
|
||||
goto error_return;
|
||||
while (left != 0);
|
||||
}
|
||||
|
||||
/* Now the uncompressed file contents are in buf. */
|
||||
bim = ((struct bfd_in_memory *)
|
||||
bfd_malloc ((bfd_size_type) sizeof (struct bfd_in_memory)));
|
||||
bim = bfd_malloc (sizeof (*bim));
|
||||
if (bim == NULL)
|
||||
goto error_return;
|
||||
bim->size = size;
|
||||
bim->buffer = buf;
|
||||
|
||||
nbfd->mtime_set = true;
|
||||
nbfd->mtime = strtol (hdr->ar_date, (char **) NULL, 10);
|
||||
nbfd->mtime = strtol (hdr->ar_date, NULL, 10);
|
||||
|
||||
nbfd->flags |= BFD_IN_MEMORY;
|
||||
nbfd->iostream = bim;
|
||||
@@ -2254,7 +2247,7 @@ alpha_ecoff_openr_next_archived_file (bfd *archive, bfd *last_file)
|
||||
which is the uncompressed size. We need the compressed size. */
|
||||
t = (struct areltdata *) last_file->arelt_data;
|
||||
h = (struct ar_hdr *) t->arch_header;
|
||||
size = strtol (h->ar_size, (char **) NULL, 10);
|
||||
size = strtol (h->ar_size, NULL, 10);
|
||||
|
||||
/* Pad to an even boundary...
|
||||
Note that last_file->origin can be odd in the case of
|
||||
@@ -2280,8 +2273,7 @@ alpha_ecoff_get_elt_at_index (bfd *abfd, symindex sym_index)
|
||||
carsym *entry;
|
||||
|
||||
entry = bfd_ardata (abfd)->symdefs + sym_index;
|
||||
return alpha_ecoff_get_elt_at_filepos (abfd, entry->file_offset,
|
||||
NULL);
|
||||
return alpha_ecoff_get_elt_at_filepos (abfd, entry->file_offset, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user