mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-23 03:29:47 +08:00
Made sure that every call to bfd_read, bfd_write, and bfd_seek
checks the return value and handled bfd_error correctly. These changes are not itemised. Also: * aoutx.h (emit_strtab): Change return type to boolean, and return errors. (NAME(aout,write_syms)): Check emit_strtab return value. (NAME(aout,final_link)): Likewise.
This commit is contained in:
24
bfd/aoutx.h
24
bfd/aoutx.h
@ -1038,7 +1038,8 @@ NAME(aout,set_section_contents) (abfd, section, location, offset, count)
|
|||||||
/* regardless, once we know what we're doing, we might as well get going */
|
/* regardless, once we know what we're doing, we might as well get going */
|
||||||
if (section != obj_bsssec(abfd))
|
if (section != obj_bsssec(abfd))
|
||||||
{
|
{
|
||||||
bfd_seek (abfd, section->filepos + offset, SEEK_SET);
|
if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (count) {
|
if (count) {
|
||||||
return (bfd_write ((PTR)location, 1, count, abfd) == count) ?
|
return (bfd_write ((PTR)location, 1, count, abfd) == count) ?
|
||||||
@ -1945,7 +1946,7 @@ add_to_stringtab (abfd, str, tab)
|
|||||||
return entry->index;
|
return entry->index;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static boolean
|
||||||
emit_strtab (abfd, tab)
|
emit_strtab (abfd, tab)
|
||||||
bfd *abfd;
|
bfd *abfd;
|
||||||
struct stringtab_data *tab;
|
struct stringtab_data *tab;
|
||||||
@ -1960,11 +1961,16 @@ emit_strtab (abfd, tab)
|
|||||||
char buffer[BYTES_IN_WORD];
|
char buffer[BYTES_IN_WORD];
|
||||||
|
|
||||||
PUT_WORD (abfd, tab->index, (unsigned char *) buffer);
|
PUT_WORD (abfd, tab->index, (unsigned char *) buffer);
|
||||||
bfd_write ((PTR) buffer, 1, BYTES_IN_WORD, abfd);
|
if (bfd_write ((PTR) buffer, 1, BYTES_IN_WORD, abfd) != BYTES_IN_WORD)
|
||||||
|
return false;
|
||||||
|
|
||||||
for (entry = tab->output_order; entry; entry = entry->next_to_output)
|
for (entry = tab->output_order; entry; entry = entry->next_to_output)
|
||||||
{
|
{
|
||||||
bfd_write ((PTR) entry->string, 1, strlen (entry->string) + 1, abfd);
|
size_t len = strlen (entry->string) + 1;
|
||||||
|
|
||||||
|
if (bfd_write ((PTR) entry->string, 1, len, abfd) != len)
|
||||||
|
return false;
|
||||||
|
|
||||||
#ifdef GATHER_STATISTICS
|
#ifdef GATHER_STATISTICS
|
||||||
count++;
|
count++;
|
||||||
#endif
|
#endif
|
||||||
@ -2012,6 +2018,8 @@ emit_strtab (abfd, tab)
|
|||||||
}
|
}
|
||||||
g->KEEPIT = (KEEPITTYPE) count;
|
g->KEEPIT = (KEEPITTYPE) count;
|
||||||
} */
|
} */
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean
|
boolean
|
||||||
@ -2060,9 +2068,7 @@ NAME(aout,write_syms) (abfd)
|
|||||||
g->KEEPIT = count;
|
g->KEEPIT = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit_strtab (abfd, &strtab);
|
return emit_strtab (abfd, &strtab);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3600,9 +3606,7 @@ NAME(aout,final_link) (abfd, info, callback)
|
|||||||
/* Write out the string table. */
|
/* Write out the string table. */
|
||||||
if (bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET) != 0)
|
if (bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET) != 0)
|
||||||
return false;
|
return false;
|
||||||
emit_strtab (abfd, &aout_info.strtab);
|
return emit_strtab (abfd, &aout_info.strtab);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Link an a.out input BFD into the output file. */
|
/* Link an a.out input BFD into the output file. */
|
||||||
|
Reference in New Issue
Block a user