static bfd_reloc_status_type hppa_som_reloc
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
static bfd_reloc_status_type hppa_som_reloc
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
- HOWTO(TYPE, 0, 0, 32, FALSE, 0, 0, hppa_som_reloc, NAME, FALSE, 0, 0, FALSE)
+ HOWTO(TYPE, 0, 0, 32, false, 0, 0, hppa_som_reloc, NAME, false, 0, 0, false)
/* If we have short and long pcrel modes, then generate the proper
mode selector, then the pcrel relocation. Redundant selectors
will be eliminated as the relocs are sized and emitted. */
/* If we have short and long pcrel modes, then generate the proper
mode selector, then the pcrel relocation. Redundant selectors
will be eliminated as the relocs are sized and emitted. */
som_object_setup (bfd *abfd,
struct som_header *file_hdrp,
struct som_exec_auxhdr *aux_hdrp,
som_object_setup (bfd *abfd,
struct som_header *file_hdrp,
struct som_exec_auxhdr *aux_hdrp,
setup_sections (bfd *abfd,
struct som_header *file_hdr,
unsigned long current_offset)
{
setup_sections (bfd *abfd,
struct som_header *file_hdr,
unsigned long current_offset)
{
unsigned int space_index, i;
unsigned int total_subspaces = 0;
asection **subspace_sections = NULL;
asection *section;
unsigned int space_index, i;
unsigned int total_subspaces = 0;
asection **subspace_sections = NULL;
asection *section;
/* Read in the next subspace. */
amt = sizeof ext_subspace;
if (bfd_bread (&ext_subspace, amt, abfd) != amt)
goto error_return;
/* Read in the next subspace. */
amt = sizeof ext_subspace;
if (bfd_bread (&ext_subspace, amt, abfd) != amt)
goto error_return;
som_mkobject (bfd *abfd)
{
/* Allocate memory to hold backend information. */
abfd->tdata.som_data = bfd_zalloc (abfd, (bfd_size_type) sizeof (struct som_data_struct));
if (abfd->tdata.som_data == NULL)
som_mkobject (bfd *abfd)
{
/* Allocate memory to hold backend information. */
abfd->tdata.som_data = bfd_zalloc (abfd, (bfd_size_type) sizeof (struct som_data_struct));
if (abfd->tdata.som_data == NULL)
}
/* Initialize some information in the file header. This routine makes
not attempt at doing the right thing for a full executable; it
is only meant to handle relocatable objects. */
}
/* Initialize some information in the file header. This routine makes
not attempt at doing the right thing for a full executable; it
is only meant to handle relocatable objects. */
amt = sizeof (struct som_exec_auxhdr);
obj_som_exec_hdr (abfd) = bfd_zalloc (abfd, amt);
if (obj_som_exec_hdr (abfd) == NULL)
amt = sizeof (struct som_exec_auxhdr);
obj_som_exec_hdr (abfd) = bfd_zalloc (abfd, amt);
if (obj_som_exec_hdr (abfd) == NULL)
amt = sizeof (struct som_space_dictionary_record);
som_section_data (section)->space_dict = bfd_zalloc (abfd, amt);
if (som_section_data (section)->space_dict == NULL)
amt = sizeof (struct som_space_dictionary_record);
som_section_data (section)->space_dict = bfd_zalloc (abfd, amt);
if (som_section_data (section)->space_dict == NULL)
/* Set space attributes. Note most attributes of SOM spaces
are set based on the subspaces it contains. */
som_section_data (section)->space_dict->loader_fix_index = -1;
/* Set space attributes. Note most attributes of SOM spaces
are set based on the subspaces it contains. */
som_section_data (section)->space_dict->loader_fix_index = -1;
amt = sizeof (struct som_subspace_dictionary_record);
som_section_data (section)->subspace_dict = bfd_zalloc (abfd, amt);
if (som_section_data (section)->subspace_dict == NULL)
amt = sizeof (struct som_subspace_dictionary_record);
som_section_data (section)->subspace_dict = bfd_zalloc (abfd, amt);
if (som_section_data (section)->subspace_dict == NULL)
som_is_space (asection *section)
{
/* If no copy data is available, then it's neither a space nor a
subspace. */
if (som_section_data (section)->copy_data == NULL)
som_is_space (asection *section)
{
/* If no copy data is available, then it's neither a space nor a
subspace. */
if (som_section_data (section)->copy_data == NULL)
/* If the containing space isn't the same as the given section,
then this isn't a space. */
if (som_section_data (section)->copy_data->container != section
&& (som_section_data (section)->copy_data->container->output_section
!= section))
/* If the containing space isn't the same as the given section,
then this isn't a space. */
if (som_section_data (section)->copy_data->container != section
&& (som_section_data (section)->copy_data->container->output_section
!= section))
som_is_subspace (asection *section)
{
/* If no copy data is available, then it's neither a space nor a
subspace. */
if (som_section_data (section)->copy_data == NULL)
som_is_subspace (asection *section)
{
/* If no copy data is available, then it's neither a space nor a
subspace. */
if (som_section_data (section)->copy_data == NULL)
/* If the containing space is the same as the given section,
then this isn't a subspace. */
if (som_section_data (section)->copy_data->container == section
|| (som_section_data (section)->copy_data->container->output_section
== section))
/* If the containing space is the same as the given section,
then this isn't a subspace. */
if (som_section_data (section)->copy_data->container == section
|| (som_section_data (section)->copy_data->container->output_section
== section))
memcpy (sorted_syms, syms, num_syms * sizeof (asymbol *));
qsort (sorted_syms, num_syms, sizeof (asymbol *), compare_syms);
obj_som_sorted_syms (abfd) = sorted_syms;
memcpy (sorted_syms, syms, num_syms * sizeof (asymbol *));
qsort (sorted_syms, num_syms, sizeof (asymbol *), compare_syms);
obj_som_sorted_syms (abfd) = sorted_syms;
som_write_fixups (bfd *abfd,
unsigned long current_offset,
unsigned int *total_reloc_sizep)
som_write_fixups (bfd *abfd,
unsigned long current_offset,
unsigned int *total_reloc_sizep)
som_write_space_strings (bfd *abfd,
unsigned long current_offset,
unsigned int *string_sizep)
som_write_space_strings (bfd *abfd,
unsigned long current_offset,
unsigned int *string_sizep)
/* This gets a bit gruesome because of the compilation unit. The
strings within the compilation unit are part of the symbol
strings, but don't have symbol_dictionary entries. So, manually
/* This gets a bit gruesome because of the compilation unit. The
strings within the compilation unit are part of the symbol
strings, but don't have symbol_dictionary entries. So, manually
}
/* Compute variable information to be placed in the SOM headers,
space/subspace dictionaries, relocation streams, etc. Begin
writing parts of the object file. */
}
/* Compute variable information to be placed in the SOM headers,
space/subspace dictionaries, relocation streams, etc. Begin
writing parts of the object file. */
/* Write the aux_id structure and the string length. */
len = sizeof (struct som_external_string_auxhdr);
obj_som_file_hdr (abfd)->aux_header_size += len;
current_offset += len;
som_swap_string_auxhdr_out
/* Write the aux_id structure and the string length. */
len = sizeof (struct som_external_string_auxhdr);
obj_som_file_hdr (abfd)->aux_header_size += len;
current_offset += len;
som_swap_string_auxhdr_out
/* Write the aux_id structure and the string length. */
len = sizeof (struct som_external_string_auxhdr);
obj_som_file_hdr (abfd)->aux_header_size += len;
current_offset += len;
som_swap_string_auxhdr_out
/* Write the aux_id structure and the string length. */
len = sizeof (struct som_external_string_auxhdr);
obj_som_file_hdr (abfd)->aux_header_size += len;
current_offset += len;
som_swap_string_auxhdr_out
if (abfd->flags & (EXEC_P | DYNAMIC))
current_offset = SOM_ALIGN (current_offset, PA_PAGESIZE);
if (bfd_seek (abfd, (file_ptr) current_offset - 1, SEEK_SET) != 0)
if (abfd->flags & (EXEC_P | DYNAMIC))
current_offset = SOM_ALIGN (current_offset, PA_PAGESIZE);
if (bfd_seek (abfd, (file_ptr) current_offset - 1, SEEK_SET) != 0)
if (! som_write_symbol_strings (abfd, current_offset, syms,
num_syms, &strings_size,
obj_som_compilation_unit (abfd)))
if (! som_write_symbol_strings (abfd, current_offset, syms,
num_syms, &strings_size,
obj_som_compilation_unit (abfd)))
- som_prep_for_fixups (abfd,
- bfd_get_outsymbols (abfd),
- bfd_get_symcount (abfd));
+ if (!som_prep_for_fixups (abfd,
+ bfd_get_outsymbols (abfd),
+ bfd_get_symcount (abfd)))
+ return false;
/* Write the fixups and update fields in subspace headers which
relate to the fixup stream. */
if (! som_write_fixups (abfd, current_offset, &total_reloc_size))
/* Write the fixups and update fields in subspace headers which
relate to the fixup stream. */
if (! som_write_fixups (abfd, current_offset, &total_reloc_size))
/* Now that the symbol table information is complete, build and
write the symbol table. */
if (! som_build_and_write_symbol_table (abfd))
/* Now that the symbol table information is complete, build and
write the symbol table. */
if (! som_build_and_write_symbol_table (abfd))
/* Seek to the start of the subspace dictionary records. */
location = obj_som_file_hdr (abfd)->subspace_location;
if (bfd_seek (abfd, location, SEEK_SET) != 0)
/* Seek to the start of the subspace dictionary records. */
location = obj_som_file_hdr (abfd)->subspace_location;
if (bfd_seek (abfd, location, SEEK_SET) != 0)
/* Only thing left to do is write out the file header. It is always
at location zero. Seek there and write it. */
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
/* Only thing left to do is write out the file header. It is always
at location zero. Seek there and write it. */
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
}
som_swap_exec_auxhdr_out (exec_header, &ext_exec_header);
if (bfd_seek (abfd, obj_som_file_hdr (abfd)->aux_header_location,
SEEK_SET) != 0)
}
som_swap_exec_auxhdr_out (exec_header, &ext_exec_header);
if (bfd_seek (abfd, obj_som_file_hdr (abfd)->aux_header_location,
SEEK_SET) != 0)
- symtab_size = num_syms;
- symtab_size *= sizeof (struct som_external_symbol_dictionary_record);
- som_symtab = bfd_zmalloc (symtab_size);
- if (som_symtab == NULL && symtab_size != 0)
+ if (_bfd_mul_overflow (num_syms,
+ sizeof (struct som_external_symbol_dictionary_record),
+ &amt))
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return false;
+ }
+ som_symtab = bfd_zmalloc (amt);
+ if (som_symtab == NULL && num_syms != 0)
By the time we get here, the index has already been
computed and stored into the name field in the BFD symbol. */
bfd_putb32 (som_symbol_data (bfd_syms[i])->stringtab_offset,
By the time we get here, the index has already been
computed and stored into the name field in the BFD symbol. */
bfd_putb32 (som_symbol_data (bfd_syms[i])->stringtab_offset,
/* Derive SOM information from the BFD symbol. */
som_bfd_derive_misc_symbol_info (abfd, bfd_syms[i], &info);
/* Now use it. */
flags = (info.symbol_type << SOM_SYMBOL_TYPE_SH)
/* Derive SOM information from the BFD symbol. */
som_bfd_derive_misc_symbol_info (abfd, bfd_syms[i], &info);
/* Now use it. */
flags = (info.symbol_type << SOM_SYMBOL_TYPE_SH)
- | (info.symbol_scope << SOM_SYMBOL_SCOPE_SH)
- | (info.arg_reloc << SOM_SYMBOL_ARG_RELOC_SH)
- | (3 << SOM_SYMBOL_XLEAST_SH)
- | (info.secondary_def ? SOM_SYMBOL_SECONDARY_DEF : 0)
- | (info.is_common ? SOM_SYMBOL_IS_COMMON : 0)
- | (info.dup_common ? SOM_SYMBOL_DUP_COMMON : 0);
+ | (info.symbol_scope << SOM_SYMBOL_SCOPE_SH)
+ | (info.arg_reloc << SOM_SYMBOL_ARG_RELOC_SH)
+ | (3 << SOM_SYMBOL_XLEAST_SH)
+ | (info.secondary_def ? SOM_SYMBOL_SECONDARY_DEF : 0)
+ | (info.is_common ? SOM_SYMBOL_IS_COMMON : 0)
+ | (info.dup_common ? SOM_SYMBOL_DUP_COMMON : 0);
}
/* Everything is ready, seek to the right location and
scribble out the symbol table. */
if (bfd_seek (abfd, symtab_location, SEEK_SET) != 0)
}
/* Everything is ready, seek to the right location and
scribble out the symbol table. */
if (bfd_seek (abfd, symtab_location, SEEK_SET) != 0)
/* Start writing the object file. This include all the string
tables, fixup streams, and other portions of the object file. */
som_begin_writing (abfd);
/* Start writing the object file. This include all the string
tables, fixup streams, and other portions of the object file. */
som_begin_writing (abfd);
- if (bfd_bread (buf, amt, abfd) != amt)
+ buf = (struct som_external_symbol_dictionary_record *)
+ _bfd_malloc_and_read (abfd, amt, amt);
+ if (buf == NULL)
+ goto error_return;
+
+ if (_bfd_mul_overflow (symbol_count, sizeof (som_symbol_type), &amt))
+ {
+ bfd_set_error (bfd_error_file_too_big);
+ goto error_return;
+ }
+ symbase = bfd_zmalloc (amt);
+ if (symbase == NULL)
/* Mark section symbols and symbols used by the debugger.
Note $START$ is a magic code symbol, NOT a section symbol. */
if (sym->symbol.name[0] == '$'
&& sym->symbol.name[strlen (sym->symbol.name) - 1] == '$'
&& !strcmp (sym->symbol.name, sym->symbol.section->name))
sym->symbol.flags |= BSF_SECTION_SYM;
/* Mark section symbols and symbols used by the debugger.
Note $START$ is a magic code symbol, NOT a section symbol. */
if (sym->symbol.name[0] == '$'
&& sym->symbol.name[strlen (sym->symbol.name) - 1] == '$'
&& !strcmp (sym->symbol.name, sym->symbol.section->name))
sym->symbol.flags |= BSF_SECTION_SYM;
fixup_stream_size = som_section_data (section)->reloc_size;
/* If there were no relocations, then there is nothing to do. */
if (section->reloc_count == 0)
fixup_stream_size = som_section_data (section)->reloc_size;
/* If there were no relocations, then there is nothing to do. */
if (section->reloc_count == 0)
/* If reloc_count is -1, then the relocation stream has not been
parsed. We must do so now to know how many relocations exist. */
if (section->reloc_count == (unsigned) -1)
{
/* If reloc_count is -1, then the relocation stream has not been
parsed. We must do so now to know how many relocations exist. */
if (section->reloc_count == (unsigned) -1)
{
/* Let callers know how many relocations found.
also save the relocation stream as we will
need it again. */
section->reloc_count = som_set_reloc_info (external_relocs,
fixup_stream_size,
/* Let callers know how many relocations found.
also save the relocation stream as we will
need it again. */
section->reloc_count = som_set_reloc_info (external_relocs,
fixup_stream_size,
num_relocs = section->reloc_count;
external_relocs = som_section_data (section)->reloc_stream;
/* Return saved information about the relocations if it is available. */
if (section->relocation != NULL)
num_relocs = section->reloc_count;
external_relocs = som_section_data (section)->reloc_stream;
/* Return saved information about the relocations if it is available. */
if (section->relocation != NULL)
- amt = num_relocs;
- amt *= sizeof (arelent);
- internal_relocs = bfd_zalloc (abfd, (amt));
+ if (_bfd_mul_overflow (num_relocs, sizeof (arelent), &amt))
+ {
+ bfd_set_error (bfd_error_file_too_big);
+ return false;
+ }
+ internal_relocs = bfd_zalloc (abfd, amt);
/* One day we may try to grok other private data. */
if (ibfd->xvec->flavour != bfd_target_som_flavour
|| obfd->xvec->flavour != bfd_target_som_flavour
|| (!som_is_space (isection) && !som_is_subspace (isection)))
/* One day we may try to grok other private data. */
if (ibfd->xvec->flavour != bfd_target_som_flavour
|| obfd->xvec->flavour != bfd_target_som_flavour
|| (!som_is_space (isection) && !som_is_subspace (isection)))
amt = sizeof (struct som_copyable_section_data_struct);
som_section_data (osection)->copy_data = bfd_zalloc (obfd, amt);
if (som_section_data (osection)->copy_data == NULL)
amt = sizeof (struct som_copyable_section_data_struct);
som_section_data (osection)->copy_data = bfd_zalloc (obfd, amt);
if (som_section_data (osection)->copy_data == NULL)
- som_section_data (osection)->copy_data->container =
- som_section_data (osection)->copy_data->container->output_section;
+ {
+ if (som_section_data (osection)->copy_data->container->output_section)
+ som_section_data (osection)->copy_data->container =
+ som_section_data (osection)->copy_data->container->output_section;
+ else
+ {
+ /* User has specified a subspace without its containing space. */
+ _bfd_error_handler (_("%pB[%pA]: no output section for space %pA"),
+ obfd, osection, som_section_data (osection)->copy_data->container);
+ return false;
+ }
+ }
som_bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
{
/* One day we may try to grok other private data. */
if (ibfd->xvec->flavour != bfd_target_som_flavour
|| obfd->xvec->flavour != bfd_target_som_flavour)
som_bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
{
/* One day we may try to grok other private data. */
if (ibfd->xvec->flavour != bfd_target_som_flavour
|| obfd->xvec->flavour != bfd_target_som_flavour)
/* Allocate some memory to hold the data we need. */
obj_som_exec_data (obfd) = bfd_zalloc (obfd, (bfd_size_type) sizeof (struct som_exec_data));
if (obj_som_exec_data (obfd) == NULL)
/* Allocate some memory to hold the data we need. */
obj_som_exec_data (obfd) = bfd_zalloc (obfd, (bfd_size_type) sizeof (struct som_exec_data));
if (obj_som_exec_data (obfd) == NULL)
fprintf (f, " length %#x\n", auxhdr->length);
/* Note that, depending on the HP-UX version, the following fields can be
fprintf (f, " length %#x\n", auxhdr->length);
/* Note that, depending on the HP-UX version, the following fields can be
fprintf (f, " text size %#lx\n", (long) exec_header->exec_tsize);
fprintf (f, " text memory offset %#lx\n", (long) exec_header->exec_tmem);
fprintf (f, " text size %#lx\n", (long) exec_header->exec_tsize);
fprintf (f, " text memory offset %#lx\n", (long) exec_header->exec_tmem);
}
som_section_data (section)->copy_data->sort_key = sort_key;
som_section_data (section)->copy_data->is_defined = defined;
som_section_data (section)->copy_data->is_private = private;
som_section_data (section)->copy_data->container = section;
som_section_data (section)->copy_data->space_number = spnum;
}
som_section_data (section)->copy_data->sort_key = sort_key;
som_section_data (section)->copy_data->is_defined = defined;
som_section_data (section)->copy_data->is_private = private;
som_section_data (section)->copy_data->container = section;
som_section_data (section)->copy_data->space_number = spnum;
som_section_data (section)->copy_data->is_comdat = comdat;
som_section_data (section)->copy_data->is_common = common;
som_section_data (section)->copy_data->dup_common = dup_common;
som_section_data (section)->copy_data->is_comdat = comdat;
som_section_data (section)->copy_data->is_common = common;
som_section_data (section)->copy_data->dup_common = dup_common;
amt = sizeof (struct som_string_auxhdr) + len + pad;
obj_som_version_hdr (abfd) = bfd_zalloc (abfd, amt);
if (!obj_som_version_hdr (abfd))
amt = sizeof (struct som_string_auxhdr) + len + pad;
obj_som_version_hdr (abfd) = bfd_zalloc (abfd, amt);
if (!obj_som_version_hdr (abfd))
obj_som_version_hdr (abfd)->header_id.type = VERSION_AUX_ID;
obj_som_version_hdr (abfd)->header_id.length = 4 + len + pad;
obj_som_version_hdr (abfd)->string_length = len;
obj_som_version_hdr (abfd)->header_id.type = VERSION_AUX_ID;
obj_som_version_hdr (abfd)->header_id.length = 4 + len + pad;
obj_som_version_hdr (abfd)->string_length = len;
amt = sizeof (struct som_string_auxhdr) + len + pad;
obj_som_copyright_hdr (abfd) = bfd_zalloc (abfd, amt);
if (!obj_som_copyright_hdr (abfd))
amt = sizeof (struct som_string_auxhdr) + len + pad;
obj_som_copyright_hdr (abfd) = bfd_zalloc (abfd, amt);
if (!obj_som_copyright_hdr (abfd))
obj_som_copyright_hdr (abfd)->header_id.type = COPYRIGHT_AUX_ID;
obj_som_copyright_hdr (abfd)->header_id.length = len + pad + 4;
obj_som_copyright_hdr (abfd)->string_length = len;
memcpy (obj_som_copyright_hdr (abfd)->string, string, len);
memset (obj_som_copyright_hdr (abfd)->string + len, 0, pad);
}
obj_som_copyright_hdr (abfd)->header_id.type = COPYRIGHT_AUX_ID;
obj_som_copyright_hdr (abfd)->header_id.length = len + pad + 4;
obj_som_copyright_hdr (abfd)->string_length = len;
memcpy (obj_som_copyright_hdr (abfd)->string, string, len);
memset (obj_som_copyright_hdr (abfd)->string + len, 0, pad);
}
if ((bfd_size_type) (offset+count) > section->size
|| bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0
|| bfd_bread (location, count, abfd) != count)
if ((bfd_size_type) (offset+count) > section->size
|| bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0
|| bfd_bread (location, count, abfd) != count)
/* Start writing the object file. This include all the string
tables, fixup streams, and other portions of the object file. */
som_begin_writing (abfd);
/* Start writing the object file. This include all the string
tables, fixup streams, and other portions of the object file. */
som_begin_writing (abfd);
/* Seek to the proper offset within the object file and write the
data. */
offset += som_section_data (section)->subspace_dict->file_loc_init_value;
if (bfd_seek (abfd, offset, SEEK_SET) != 0)
/* Seek to the proper offset within the object file and write the
data. */
offset += som_section_data (section)->subspace_dict->file_loc_init_value;
if (bfd_seek (abfd, offset, SEEK_SET) != 0)
som_bfd_count_ar_symbols (bfd *abfd,
struct som_lst_header *lst_header,
symindex *count)
{
unsigned int i;
unsigned char *hash_table;
som_bfd_count_ar_symbols (bfd *abfd,
struct som_lst_header *lst_header,
symindex *count)
{
unsigned int i;
unsigned char *hash_table;
- amt = lst_header->hash_size * 4;
- hash_table = bfd_malloc (amt);
- if (hash_table == NULL && amt != 0)
+ /* Read in the hash table. The hash table is an array of 32-bit
+ file offsets which point to the hash chains. */
+ if (_bfd_mul_overflow (lst_header->hash_size, 4, &amt))
+ {
+ bfd_set_error (bfd_error_file_too_big);
+ return false;
+ }
+ hash_table = _bfd_malloc_and_read (abfd, amt, amt);
+ if (hash_table == NULL && lst_header->hash_size != 0)
- if (bfd_bread ((void *) hash_table, amt, abfd) != amt)
+ if (_bfd_mul_overflow (lst_header->hash_size, 4, &amt))
+ {
+ bfd_set_error (bfd_error_file_too_big);
+ return false;
+ }
+ hash_table = _bfd_malloc_and_read (abfd, amt, amt);
+ if (hash_table == NULL && lst_header->hash_size != 0)
- amt = lst_header->module_count * sizeof (struct som_external_som_entry);
- som_dict = bfd_malloc (amt);
- if (som_dict == NULL && amt != 0)
- goto error_return;
-
- if (bfd_bread ((void *) som_dict, amt, abfd) != amt)
+ if (_bfd_mul_overflow (lst_header->module_count,
+ sizeof (struct som_external_som_entry), &amt))
+ {
+ bfd_set_error (bfd_error_file_too_big);
+ goto error_return;
+ }
+ som_dict = (struct som_external_som_entry *)
+ _bfd_malloc_and_read (abfd, amt, amt);
+ if (som_dict == NULL && lst_header->module_count != 0)
index can point *anywhere* in the archive to save space, so just
using the string table would not be safe. */
if (bfd_seek (abfd, (lst_filepos + string_loc
index can point *anywhere* in the archive to save space, so just
using the string table would not be safe. */
if (bfd_seek (abfd, (lst_filepos + string_loc
- set->name = bfd_zalloc (abfd, (bfd_size_type) len + 1);
- if (!set->name)
- goto error_return;
- if (bfd_bread (set->name, (bfd_size_type) len, abfd) != len)
+ if (len == (size_t) -1)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ goto error_return;
+ }
+ name = (char *) _bfd_alloc_and_read (abfd, len + 1, len);
+ if (!name)
- set->name = bfd_zalloc (abfd, (bfd_size_type) len + 1);
- if (!set->name)
- goto error_return;
-
- if (bfd_bread (set->name, (bfd_size_type) len, abfd) != len)
+ if (len == (size_t) -1)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ goto error_return;
+ }
+ name = (char *) _bfd_alloc_and_read (abfd, len + 1, len);
+ if (!name)
}
/* Read in and sanity check the archive header. */
amt = sizeof (struct ar_hdr);
if (bfd_bread ((void *) &ar_header, amt, abfd) != amt)
}
/* Read in and sanity check the archive header. */
amt = sizeof (struct ar_hdr);
if (bfd_bread ((void *) &ar_header, amt, abfd) != amt)
/* Get back to the start of the library symbol table. */
if (bfd_seek (abfd, (ardata->first_file_filepos - parsed_size
+ sizeof (struct som_external_lst_header)),
/* Get back to the start of the library symbol table. */
if (bfd_seek (abfd, (ardata->first_file_filepos - parsed_size
+ sizeof (struct som_external_lst_header)),
/* Seek back to the "first" file in the archive. Note the "first"
file may be the extended name table. */
if (bfd_seek (abfd, ardata->first_file_filepos, SEEK_SET) != 0)
/* Seek back to the "first" file in the archive. Note the "first"
file may be the extended name table. */
if (bfd_seek (abfd, ardata->first_file_filepos, SEEK_SET) != 0)
to it. It's a little slimey to grab the symbols via obj_som_symtab,
but doing so avoids allocating lots of extra memory. */
if (! som_slurp_symbol_table (curr_bfd))
to it. It's a little slimey to grab the symbols via obj_som_symtab,
but doing so avoids allocating lots of extra memory. */
if (! som_slurp_symbol_table (curr_bfd))
struct som_external_som_entry *som_dict = NULL;
struct som_external_lst_symbol_record **last_hash_entry = NULL;
unsigned int curr_som_offset, som_index = 0;
struct som_external_som_entry *som_dict = NULL;
struct som_external_lst_symbol_record **last_hash_entry = NULL;
unsigned int curr_som_offset, som_index = 0;
- flags = 0;
- if (info.secondary_def)
- flags |= LST_SYMBOL_SECONDARY_DEF;
- flags |= info.symbol_type << LST_SYMBOL_SYMBOL_TYPE_SH;
- flags |= info.symbol_scope << LST_SYMBOL_SYMBOL_SCOPE_SH;
- if (bfd_is_com_section (sym->symbol.section))
- flags |= LST_SYMBOL_IS_COMMON;
- if (info.dup_common)
- flags |= LST_SYMBOL_DUP_COMMON;
- flags |= 3 << LST_SYMBOL_XLEAST_SH;
- flags |= info.arg_reloc << LST_SYMBOL_ARG_RELOC_SH;
- bfd_putb32 (flags, curr_lst_sym->flags);
- bfd_putb32 (p - strings + 4, curr_lst_sym->name);
- bfd_putb32 (0, curr_lst_sym->qualifier_name);
- bfd_putb32 (info.symbol_info, curr_lst_sym->symbol_info);
- bfd_putb32 (info.symbol_value | info.priv_level,
- curr_lst_sym->symbol_value);
- bfd_putb32 (0, curr_lst_sym->symbol_descriptor);
- curr_lst_sym->reserved = 0;
- bfd_putb32 (som_index, curr_lst_sym->som_index);
- bfd_putb32 (symbol_key, curr_lst_sym->symbol_key);
- bfd_putb32 (0, curr_lst_sym->next_entry);
+ flags = 0;
+ if (info.secondary_def)
+ flags |= LST_SYMBOL_SECONDARY_DEF;
+ flags |= info.symbol_type << LST_SYMBOL_SYMBOL_TYPE_SH;
+ flags |= info.symbol_scope << LST_SYMBOL_SYMBOL_SCOPE_SH;
+ if (bfd_is_com_section (sym->symbol.section))
+ flags |= LST_SYMBOL_IS_COMMON;
+ if (info.dup_common)
+ flags |= LST_SYMBOL_DUP_COMMON;
+ flags |= 3 << LST_SYMBOL_XLEAST_SH;
+ flags |= info.arg_reloc << LST_SYMBOL_ARG_RELOC_SH;
+ bfd_putb32 (flags, curr_lst_sym->flags);
+ bfd_putb32 (p - strings + 4, curr_lst_sym->name);
+ bfd_putb32 (0, curr_lst_sym->qualifier_name);
+ bfd_putb32 (info.symbol_info, curr_lst_sym->symbol_info);
+ bfd_putb32 (info.symbol_value | info.priv_level,
+ curr_lst_sym->symbol_value);
+ bfd_putb32 (0, curr_lst_sym->symbol_descriptor);
+ curr_lst_sym->reserved = 0;
+ bfd_putb32 (som_index, curr_lst_sym->som_index);
+ bfd_putb32 (symbol_key, curr_lst_sym->symbol_key);
+ bfd_putb32 (0, curr_lst_sym->next_entry);
- symbol_pos =
- (curr_lst_sym - lst_syms)
- * sizeof (struct som_external_lst_symbol_record)
- + hash_size * 4
- + module_count * sizeof (struct som_external_som_entry)
- + sizeof (struct som_external_lst_header);
- last = last_hash_entry[symbol_key % hash_size];
+ symbol_pos =
+ (curr_lst_sym - lst_syms)
+ * sizeof (struct som_external_lst_symbol_record)
+ + hash_size * 4
+ + module_count * sizeof (struct som_external_som_entry)
+ + sizeof (struct som_external_lst_header);
+ last = last_hash_entry[symbol_key % hash_size];
/* Count how many symbols we will have on the hash chains and the
size of the associated string table. */
if (! som_bfd_prep_for_ar_write (abfd, &nsyms, &stringsize))
/* Count how many symbols we will have on the hash chains and the
size of the associated string table. */
if (! som_bfd_prep_for_ar_write (abfd, &nsyms, &stringsize))
sprintf (hdr.ar_name, "/ ");
_bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%-12ld",
sprintf (hdr.ar_name, "/ ");
_bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%-12ld",
/* Scribble out the ar header. */
amt = sizeof (struct ar_hdr);
if (bfd_bwrite ((void *) &hdr, amt, abfd) != amt)
/* Scribble out the ar header. */
amt = sizeof (struct ar_hdr);
if (bfd_bwrite ((void *) &hdr, amt, abfd) != amt)
/* Now scribble out the lst header. */
amt = sizeof (struct som_external_lst_header);
if (bfd_bwrite ((void *) &lst, amt, abfd) != amt)
/* Now scribble out the lst header. */
amt = sizeof (struct som_external_lst_header);
if (bfd_bwrite ((void *) &lst, amt, abfd) != amt)
/* Build and write the armap. */
if (!som_bfd_ar_write_symbol_stuff (abfd, nsyms, stringsize, lst, elength))
/* Build and write the armap. */
if (!som_bfd_ar_write_symbol_stuff (abfd, nsyms, stringsize, lst, elength))
- asection *o;
-
- if (bfd_get_format (abfd) != bfd_object)
- return TRUE;
-
-#define FREE(x) if (x != NULL) { free (x); x = NULL; }
- /* Free the native string and symbol tables. */
- FREE (obj_som_symtab (abfd));
- FREE (obj_som_stringtab (abfd));
- for (o = abfd->sections; o != NULL; o = o->next)
+ if (bfd_get_format (abfd) == bfd_object)
- /* Free the native relocations. */
- o->reloc_count = (unsigned) -1;
- FREE (som_section_data (o)->reloc_stream);
- /* Do not free the generic relocations as they are objalloc'ed. */
- }
+ asection *o;
+
+#define FREE(x) do { free (x); x = NULL; } while (0)
+ /* Free the native string and symbol tables. */
+ FREE (obj_som_symtab (abfd));
+ FREE (obj_som_stringtab (abfd));
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ /* Free the native relocations. */
+ o->reloc_count = (unsigned) -1;
+ FREE (som_section_data (o)->reloc_stream);
+ /* Do not free the generic relocations as they are objalloc'ed. */
+ }
-#define som_close_and_cleanup som_bfd_free_cached_info
-#define som_read_ar_hdr _bfd_generic_read_ar_hdr
-#define som_write_ar_hdr _bfd_generic_write_ar_hdr
-#define som_openr_next_archived_file bfd_generic_openr_next_archived_file
-#define som_get_elt_at_index _bfd_generic_get_elt_at_index
-#define som_generic_stat_arch_elt bfd_generic_stat_arch_elt
-#define som_truncate_arname bfd_bsd_truncate_arname
-#define som_slurp_extended_name_table _bfd_slurp_extended_name_table
-#define som_construct_extended_name_table _bfd_archive_coff_construct_extended_name_table
-#define som_update_armap_timestamp bfd_true
-#define som_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
-#define som_get_lineno _bfd_nosymbols_get_lineno
-#define som_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define som_read_minisymbols _bfd_generic_read_minisymbols
-#define som_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
-#define som_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
-#define som_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
-#define som_bfd_relax_section bfd_generic_relax_section
-#define som_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define som_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define som_bfd_link_just_syms _bfd_generic_link_just_syms
+#define som_close_and_cleanup som_bfd_free_cached_info
+#define som_read_ar_hdr _bfd_generic_read_ar_hdr
+#define som_write_ar_hdr _bfd_generic_write_ar_hdr
+#define som_openr_next_archived_file bfd_generic_openr_next_archived_file
+#define som_get_elt_at_index _bfd_generic_get_elt_at_index
+#define som_generic_stat_arch_elt bfd_generic_stat_arch_elt
+#define som_truncate_arname bfd_bsd_truncate_arname
+#define som_slurp_extended_name_table _bfd_slurp_extended_name_table
+#define som_construct_extended_name_table _bfd_archive_coff_construct_extended_name_table
+#define som_update_armap_timestamp _bfd_bool_bfd_true
+#define som_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
+#define som_get_lineno _bfd_nosymbols_get_lineno
+#define som_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define som_read_minisymbols _bfd_generic_read_minisymbols
+#define som_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
+#define som_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
+#define som_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
+#define som_bfd_relax_section bfd_generic_relax_section
+#define som_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define som_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define som_bfd_link_just_syms _bfd_generic_link_just_syms
-#define som_bfd_final_link _bfd_generic_final_link
-#define som_bfd_gc_sections bfd_generic_gc_sections
-#define som_bfd_lookup_section_flags bfd_generic_lookup_section_flags
-#define som_bfd_merge_sections bfd_generic_merge_sections
-#define som_bfd_is_group_section bfd_generic_is_group_section
-#define som_bfd_discard_group bfd_generic_discard_group
-#define som_section_already_linked _bfd_generic_section_already_linked
-#define som_bfd_define_common_symbol bfd_generic_define_common_symbol
-#define som_bfd_define_start_stop bfd_generic_define_start_stop
+#define som_bfd_final_link _bfd_generic_final_link
+#define som_bfd_gc_sections bfd_generic_gc_sections
+#define som_bfd_lookup_section_flags bfd_generic_lookup_section_flags
+#define som_bfd_merge_sections bfd_generic_merge_sections
+#define som_bfd_is_group_section bfd_generic_is_group_section
+#define som_bfd_group_name bfd_generic_group_name
+#define som_bfd_discard_group bfd_generic_discard_group
+#define som_section_already_linked _bfd_generic_section_already_linked
+#define som_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define som_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
+#define som_bfd_define_start_stop bfd_generic_define_start_stop
#define som_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
#define som_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
#define som_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
#define som_find_inliner_info _bfd_nosymbols_find_inliner_info
#define som_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
#define som_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
#define som_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
#define som_find_inliner_info _bfd_nosymbols_find_inliner_info
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Data. */
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Data. */