/* Support for the generic parts of COFF, for BFD.
- Copyright (C) 1990-2014 Free Software Foundation, Inc.
+ Copyright (C) 1990-2015 Free Software Foundation, Inc.
Written by Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
/* Compress/decompress DWARF debug sections with names: .debug_* and
.zdebug_*, after the section flags is set. */
if ((flags & SEC_DEBUGGING)
+ && strlen (name) > 7
&& ((name[1] == 'd' && name[6] == '_')
- || (name[1] == 'z' && name[7] == '_')))
+ || (strlen (name) > 8 && name[1] == 'z' && name[7] == '_')))
{
enum { nothing, compress, decompress } action = nothing;
char *new_name = NULL;
abfd, name);
return FALSE;
}
- if (name[1] != 'z')
+ if (return_section->compress_status == COMPRESS_SECTION_DONE)
{
- unsigned int len = strlen (name);
+ if (name[1] != 'z')
+ {
+ unsigned int len = strlen (name);
- new_name = bfd_alloc (abfd, len + 2);
- if (new_name == NULL)
- return FALSE;
- new_name[0] = '.';
- new_name[1] = 'z';
- memcpy (new_name + 2, name + 1, len);
+ new_name = bfd_alloc (abfd, len + 2);
+ if (new_name == NULL)
+ return FALSE;
+ new_name[0] = '.';
+ new_name[1] = 'z';
+ memcpy (new_name + 2, name + 1, len);
+ }
}
- break;
+ break;
case decompress:
if (!bfd_init_section_decompress_status (abfd, return_section))
{
bfd_release (abfd, opthdr);
return NULL;
}
+ /* PR 17512: file: 11056-1136-0.004. */
+ if (internal_f.f_opthdr < aoutsz)
+ memset (((char *) opthdr) + internal_f.f_opthdr, 0, aoutsz - internal_f.f_opthdr);
+
bfd_coff_swap_aouthdr_in (abfd, opthdr, (void *) &internal_a);
bfd_release (abfd, opthdr);
}
if (strings == NULL)
return NULL;
}
- if (sym->_n._n_n._n_offset >= obj_coff_strings_len (abfd))
+ /* PR 17910: Only check for string overflow if the length has been set.
+ Some DLLs, eg those produced by Visual Studio, may not set the length field. */
+ if (obj_coff_strings_len (abfd) > 0
+ && sym->_n._n_n._n_offset >= obj_coff_strings_len (abfd))
return NULL;
return strings + sym->_n._n_n._n_offset;
}
return total;
}
-/* Takes a bfd and a symbol, returns a pointer to the coff specific
- area of the symbol if there is one. */
-
-coff_symbol_type *
-coff_symbol_from (bfd *ignore_abfd ATTRIBUTE_UNUSED,
- asymbol *symbol)
-{
- if (!bfd_family_coff (bfd_asymbol_bfd (symbol)))
- return (coff_symbol_type *) NULL;
-
- if (bfd_asymbol_bfd (symbol)->tdata.coff_obj_data == (coff_data_type *) NULL)
- return (coff_symbol_type *) NULL;
-
- return (coff_symbol_type *) symbol;
-}
-
static void
fixup_symbol_value (bfd *abfd,
coff_symbol_type *coff_symbol_ptr,
for (symbol_index = 0; symbol_index < symbol_count; symbol_index++)
{
- coff_symbol_type *coff_symbol_ptr = coff_symbol_from (bfd_ptr, symbol_ptr_ptr[symbol_index]);
+ coff_symbol_type *coff_symbol_ptr;
+ coff_symbol_ptr = coff_symbol_from (symbol_ptr_ptr[symbol_index]);
symbol_ptr_ptr[symbol_index]->udata.i = symbol_index;
if (coff_symbol_ptr && coff_symbol_ptr->native)
{
for (symbol_index = 0; symbol_index < symbol_count; symbol_index++)
{
- coff_symbol_type *coff_symbol_ptr =
- coff_symbol_from (bfd_ptr, symbol_ptr_ptr[symbol_index]);
+ coff_symbol_type *coff_symbol_ptr;
+ coff_symbol_ptr = coff_symbol_from (symbol_ptr_ptr[symbol_index]);
if (coff_symbol_ptr && coff_symbol_ptr->native)
{
int i;
/* Copy the any flags from the file header into the symbol.
FIXME: Why? */
{
- coff_symbol_type *c = coff_symbol_from (abfd, symbol);
+ coff_symbol_type *c = coff_symbol_from (symbol);
if (c != (coff_symbol_type *) NULL)
native->u.syment.n_flags = bfd_asymbol_bfd (&c->symbol)->flags;
}
for (p = abfd->outsymbols, i = 0; i < limit; i++, p++)
{
asymbol *symbol = *p;
- coff_symbol_type *c_symbol = coff_symbol_from (abfd, symbol);
+ coff_symbol_type *c_symbol = coff_symbol_from (symbol);
if (c_symbol == (coff_symbol_type *) NULL
|| c_symbol->native == (combined_entry_type *) NULL)
{
asymbol *q = *p;
size_t name_length = strlen (q->name);
- coff_symbol_type *c_symbol = coff_symbol_from (abfd, q);
+ coff_symbol_type *c_symbol = coff_symbol_from (q);
size_t maxlen;
/* Figure out whether the symbol name should go in the string
(bfd_hostptr_t) obj_raw_syments (abfd);
}
-/* Return the COFF syment for a symbol. */
-
-bfd_boolean
-bfd_coff_get_syment (bfd *abfd,
- asymbol *symbol,
- struct internal_syment *psyment)
-{
- coff_symbol_type *csym;
-
- csym = coff_symbol_from (abfd, symbol);
- if (csym == NULL || csym->native == NULL
- || ! csym->native->is_sym)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return FALSE;
- }
-
- *psyment = csym->native->u.syment;
-
- if (csym->native->fix_value)
- psyment->n_value = psyment->n_value -
- (bfd_hostptr_t) obj_raw_syments (abfd);
-
- /* FIXME: We should handle fix_line here. */
-
- return TRUE;
-}
-
-/* Return the COFF auxent for a symbol. */
-
-bfd_boolean
-bfd_coff_get_auxent (bfd *abfd,
- asymbol *symbol,
- int indx,
- union internal_auxent *pauxent)
-{
- coff_symbol_type *csym;
- combined_entry_type *ent;
-
- csym = coff_symbol_from (abfd, symbol);
-
- if (csym == NULL
- || csym->native == NULL
- || ! csym->native->is_sym
- || indx >= csym->native->u.syment.n_numaux)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return FALSE;
- }
-
- ent = csym->native + indx + 1;
-
- BFD_ASSERT (! ent->is_sym);
- *pauxent = ent->u.auxent;
-
- if (ent->fix_tag)
- pauxent->x_sym.x_tagndx.l =
- ((combined_entry_type *) pauxent->x_sym.x_tagndx.p
- - obj_raw_syments (abfd));
-
- if (ent->fix_end)
- pauxent->x_sym.x_fcnary.x_fcn.x_endndx.l =
- ((combined_entry_type *) pauxent->x_sym.x_fcnary.x_fcn.x_endndx.p
- - obj_raw_syments (abfd));
-
- if (ent->fix_scnlen)
- pauxent->x_csect.x_scnlen.l =
- ((combined_entry_type *) pauxent->x_csect.x_scnlen.p
- - obj_raw_syments (abfd));
-
- return TRUE;
-}
-
/* Print out information about COFF symbol. */
void
&coff_data(abfd)->dwarf2_find_line_info))
return TRUE;
+ /* If the DWARF lookup failed, but there is DWARF information available
+ then the problem might be that the file has been rebased. This tool
+ changes the VMAs of all the sections, but it does not update the DWARF
+ information. So try again, using a bias against the address sought. */
+ if (coff_data (abfd)->dwarf2_find_line_info != NULL)
+ {
+ bfd_signed_vma bias;
+
+ bias = _bfd_dwarf2_find_symbol_bias (symbols,
+ & coff_data (abfd)->dwarf2_find_line_info);
+
+ if (bias
+ && _bfd_dwarf2_find_nearest_line (abfd, symbols, NULL, section,
+ offset + bias,
+ filename_ptr, functionname_ptr,
+ line_ptr, NULL, debug_sections, 0,
+ &coff_data(abfd)->dwarf2_find_line_info))
+ return TRUE;
+ }
+
*filename_ptr = 0;
*functionname_ptr = 0;
*line_ptr = 0;
{
coff_symbol_type * csym;
- csym = coff_symbol_from (abfd, symbol);
+ csym = coff_symbol_from (symbol);
if (csym == NULL)
{
bfd_set_error (bfd_error_invalid_operation);
return TRUE;
}
-struct coff_comdat_info *
-bfd_coff_get_comdat_section (bfd *abfd, struct bfd_section *sec)
-{
- if (bfd_get_flavour (abfd) == bfd_target_coff_flavour
- && coff_section_data (abfd, sec) != NULL)
- return coff_section_data (abfd, sec)->comdat;
- else
- return NULL;
-}
-
bfd_boolean
_bfd_coff_section_already_linked (bfd *abfd,
asection *sec,