PR binutils/15125
* objcopy.c (copy_object): Provide a helpful warning message when adding a gnu_debuglink section to an object which already contains one.
This commit is contained in:
parent
1773c82c92
commit
d99b05a32e
|
@ -1,3 +1,10 @@
|
||||||
|
2013-02-14 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
|
PR binutils/15125
|
||||||
|
* objcopy.c (copy_object): Provide a helpful warning message when
|
||||||
|
adding a gnu_debuglink section to an object which already contains
|
||||||
|
one.
|
||||||
|
|
||||||
2013-02-07 Nick Clifton <nickc@redhat.com>
|
2013-02-07 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
* elfcomm.c (get_archive_member_name): Prevent seg-fault if a
|
* elfcomm.c (get_archive_member_name): Prevent seg-fault if a
|
||||||
|
|
|
@ -1763,58 +1763,70 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
|
||||||
|
|
||||||
if (gnu_debuglink_filename != NULL)
|
if (gnu_debuglink_filename != NULL)
|
||||||
{
|
{
|
||||||
gnu_debuglink_section = bfd_create_gnu_debuglink_section
|
/* PR 15125: Give a helpful warning message if
|
||||||
(obfd, gnu_debuglink_filename);
|
the debuglink section already exists, and
|
||||||
|
allow the rest of the copy to complete. */
|
||||||
if (gnu_debuglink_section == NULL)
|
if (bfd_get_section_by_name (obfd, ".gnu_debuglink"))
|
||||||
{
|
{
|
||||||
bfd_nonfatal_message (NULL, obfd, NULL,
|
non_fatal (_("%s: debuglink section already exists"),
|
||||||
_("cannot create debug link section `%s'"),
|
bfd_get_filename (obfd));
|
||||||
gnu_debuglink_filename);
|
gnu_debuglink_filename = NULL;
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
/* Special processing for PE format files. We
|
|
||||||
have no way to distinguish PE from COFF here. */
|
|
||||||
if (bfd_get_flavour (obfd) == bfd_target_coff_flavour)
|
|
||||||
{
|
{
|
||||||
bfd_vma debuglink_vma;
|
gnu_debuglink_section = bfd_create_gnu_debuglink_section
|
||||||
asection * highest_section;
|
(obfd, gnu_debuglink_filename);
|
||||||
asection * sec;
|
|
||||||
|
|
||||||
/* The PE spec requires that all sections be adjacent and sorted
|
if (gnu_debuglink_section == NULL)
|
||||||
in ascending order of VMA. It also specifies that debug
|
{
|
||||||
sections should be last. This is despite the fact that debug
|
bfd_nonfatal_message (NULL, obfd, NULL,
|
||||||
sections are not loaded into memory and so in theory have no
|
_("cannot create debug link section `%s'"),
|
||||||
use for a VMA.
|
gnu_debuglink_filename);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
This means that the debuglink section must be given a non-zero
|
/* Special processing for PE format files. We
|
||||||
VMA which makes it contiguous with other debug sections. So
|
have no way to distinguish PE from COFF here. */
|
||||||
walk the current section list, find the section with the
|
if (bfd_get_flavour (obfd) == bfd_target_coff_flavour)
|
||||||
highest VMA and start the debuglink section after that one. */
|
{
|
||||||
for (sec = obfd->sections, highest_section = NULL;
|
bfd_vma debuglink_vma;
|
||||||
sec != NULL;
|
asection * highest_section;
|
||||||
sec = sec->next)
|
asection * sec;
|
||||||
if (sec->vma > 0
|
|
||||||
&& (highest_section == NULL
|
|
||||||
|| sec->vma > highest_section->vma))
|
|
||||||
highest_section = sec;
|
|
||||||
|
|
||||||
if (highest_section)
|
/* The PE spec requires that all sections be adjacent and sorted
|
||||||
debuglink_vma = BFD_ALIGN (highest_section->vma
|
in ascending order of VMA. It also specifies that debug
|
||||||
+ highest_section->size,
|
sections should be last. This is despite the fact that debug
|
||||||
/* FIXME: We ought to be using
|
sections are not loaded into memory and so in theory have no
|
||||||
COFF_PAGE_SIZE here or maybe
|
use for a VMA.
|
||||||
bfd_get_section_alignment() (if it
|
|
||||||
was set) but since this is for PE
|
|
||||||
and we know the required alignment
|
|
||||||
it is easier just to hard code it. */
|
|
||||||
0x1000);
|
|
||||||
else
|
|
||||||
/* Umm, not sure what to do in this case. */
|
|
||||||
debuglink_vma = 0x1000;
|
|
||||||
|
|
||||||
bfd_set_section_vma (obfd, gnu_debuglink_section, debuglink_vma);
|
This means that the debuglink section must be given a non-zero
|
||||||
|
VMA which makes it contiguous with other debug sections. So
|
||||||
|
walk the current section list, find the section with the
|
||||||
|
highest VMA and start the debuglink section after that one. */
|
||||||
|
for (sec = obfd->sections, highest_section = NULL;
|
||||||
|
sec != NULL;
|
||||||
|
sec = sec->next)
|
||||||
|
if (sec->vma > 0
|
||||||
|
&& (highest_section == NULL
|
||||||
|
|| sec->vma > highest_section->vma))
|
||||||
|
highest_section = sec;
|
||||||
|
|
||||||
|
if (highest_section)
|
||||||
|
debuglink_vma = BFD_ALIGN (highest_section->vma
|
||||||
|
+ highest_section->size,
|
||||||
|
/* FIXME: We ought to be using
|
||||||
|
COFF_PAGE_SIZE here or maybe
|
||||||
|
bfd_get_section_alignment() (if it
|
||||||
|
was set) but since this is for PE
|
||||||
|
and we know the required alignment
|
||||||
|
it is easier just to hard code it. */
|
||||||
|
0x1000);
|
||||||
|
else
|
||||||
|
/* Umm, not sure what to do in this case. */
|
||||||
|
debuglink_vma = 0x1000;
|
||||||
|
|
||||||
|
bfd_set_section_vma (obfd, gnu_debuglink_section, debuglink_vma);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue