Fix --add-gnu-debuglink
This commit is contained in:
parent
72b4917c07
commit
e7c81c254c
5 changed files with 114 additions and 34 deletions
|
@ -1,3 +1,12 @@
|
|||
2003-06-27 Nick Clifton <nickc@redhat.com>
|
||||
|
||||
* opncls.c (bfd_add_gnu_debuglink_section): Rename to
|
||||
bfd_add_gnu_debuglink_section and only create the section, do not
|
||||
fill in its contents.
|
||||
(bfd_fill_in_gnu_debuglink_section): New function. Fill in the
|
||||
contents of a .gnu-debuglink section.
|
||||
* bfd-in2.h: Regenerate.
|
||||
|
||||
2003-06-27 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
|
||||
|
||||
* elfxx-mips.c: Revert .got alignment to 2**4.
|
||||
|
|
|
@ -911,8 +911,11 @@ bfd_calc_gnu_debuglink_crc32 PARAMS ((unsigned long crc, const unsigned char *bu
|
|||
char *
|
||||
bfd_follow_gnu_debuglink PARAMS ((bfd *abfd, const char *dir));
|
||||
|
||||
struct sec *
|
||||
bfd_create_gnu_debuglink_section PARAMS ((bfd * abfd, const char * filename));
|
||||
|
||||
bfd_boolean
|
||||
bfd_add_gnu_debuglink PARAMS ((bfd * abfd, const char * filename));
|
||||
bfd_fill_in_gnu_debuglink_section PARAMS ((bfd * abfd, struct sec * sect, const char * filename));
|
||||
|
||||
/* Extracted from libbfd.c. */
|
||||
|
||||
|
|
108
bfd/opncls.c
108
bfd/opncls.c
|
@ -1058,16 +1058,82 @@ bfd_follow_gnu_debuglink (abfd, dir)
|
|||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_add_gnu_debuglink
|
||||
bfd_create_gnu_debuglink_section
|
||||
|
||||
SYNOPSIS
|
||||
bfd_boolean bfd_add_gnu_debuglink (bfd * abfd, const char * filename);
|
||||
struct sec * bfd_create_gnu_debuglink_section (bfd * abfd, const char * filename);
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
Takes a @var{BFD} and adds a .gnu_debuglink section containing a link
|
||||
to the specified @var{filename}. The filename should be relative to
|
||||
the current directory.
|
||||
Takes a @var{BFD} and adds a .gnu_debuglink section to it. The section is sized
|
||||
to be big enough to contain a link to the specified @var{filename}.
|
||||
|
||||
RETURNS
|
||||
A pointer to the new section is returned if all is ok. Otherwise <<NULL>> is
|
||||
returned and bfd_error is set.
|
||||
*/
|
||||
|
||||
asection *
|
||||
bfd_create_gnu_debuglink_section
|
||||
(bfd * abfd,
|
||||
const char * filename)
|
||||
{
|
||||
asection * sect;
|
||||
bfd_size_type debuglink_size;
|
||||
|
||||
if (abfd == NULL || filename == NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_invalid_operation);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Strip off any path components in filename. */
|
||||
filename = lbasename (filename);
|
||||
|
||||
sect = bfd_get_section_by_name (abfd, GNU_DEBUGLINK);
|
||||
if (sect)
|
||||
{
|
||||
/* Section already exists. */
|
||||
bfd_set_error (bfd_error_invalid_operation);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sect = bfd_make_section (abfd, GNU_DEBUGLINK);
|
||||
if (sect == NULL)
|
||||
return NULL;
|
||||
|
||||
if (! bfd_set_section_flags (abfd, sect,
|
||||
SEC_HAS_CONTENTS | SEC_READONLY | SEC_DEBUGGING))
|
||||
/* XXX Should we delete the section from the bfd ? */
|
||||
return NULL;
|
||||
|
||||
|
||||
debuglink_size = strlen (filename) + 1;
|
||||
debuglink_size += 3;
|
||||
debuglink_size &= ~3;
|
||||
debuglink_size += 4;
|
||||
|
||||
if (! bfd_set_section_size (abfd, sect, debuglink_size))
|
||||
/* XXX Should we delete the section from the bfd ? */
|
||||
return NULL;
|
||||
|
||||
return sect;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_fill_in_gnu_debuglink_section
|
||||
|
||||
SYNOPSIS
|
||||
bfd_boolean bfd_fill_in_gnu_debuglink_section (bfd * abfd, struct sec * sect, const char * filename);
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
Takes a @var{BFD} and containing a .gnu_debuglink section @var{SECT}
|
||||
and fills in the contents of the section to contain a link to the
|
||||
specified @var{filename}. The filename should be relative to the
|
||||
current directory.
|
||||
|
||||
RETURNS
|
||||
<<TRUE>> is returned if all is ok. Otherwise <<FALSE>> is returned
|
||||
|
@ -1075,11 +1141,11 @@ RETURNS
|
|||
*/
|
||||
|
||||
bfd_boolean
|
||||
bfd_add_gnu_debuglink (abfd, filename)
|
||||
bfd *abfd;
|
||||
const char * filename;
|
||||
bfd_fill_in_gnu_debuglink_section
|
||||
(bfd * abfd,
|
||||
struct sec * sect,
|
||||
const char * filename)
|
||||
{
|
||||
asection * sect;
|
||||
bfd_size_type debuglink_size;
|
||||
unsigned long crc32;
|
||||
char * contents;
|
||||
|
@ -1088,7 +1154,7 @@ bfd_add_gnu_debuglink (abfd, filename)
|
|||
static char buffer[8 * 1024];
|
||||
size_t count;
|
||||
|
||||
if (abfd == NULL || filename == NULL)
|
||||
if (abfd == NULL || sect == NULL || filename == NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_invalid_operation);
|
||||
return FALSE;
|
||||
|
@ -1116,33 +1182,11 @@ bfd_add_gnu_debuglink (abfd, filename)
|
|||
now that we no longer need them. */
|
||||
filename = lbasename (filename);
|
||||
|
||||
sect = bfd_get_section_by_name (abfd, GNU_DEBUGLINK);
|
||||
if (sect)
|
||||
{
|
||||
/* Section already exists. */
|
||||
bfd_set_error (bfd_error_invalid_operation);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
sect = bfd_make_section (abfd, GNU_DEBUGLINK);
|
||||
if (sect == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (! bfd_set_section_flags (abfd, sect,
|
||||
SEC_HAS_CONTENTS | SEC_DEBUGGING))
|
||||
/* XXX Should we delete the section from the bfd ? */
|
||||
return FALSE;
|
||||
|
||||
|
||||
debuglink_size = strlen (filename) + 1;
|
||||
debuglink_size += 3;
|
||||
debuglink_size &= ~3;
|
||||
debuglink_size += 4;
|
||||
|
||||
if (! bfd_set_section_size (abfd, sect, debuglink_size))
|
||||
/* XXX Should we delete the section from the bfd ? */
|
||||
return FALSE;
|
||||
|
||||
contents = malloc (debuglink_size);
|
||||
if (contents == NULL)
|
||||
{
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
2003-06-27 Nick Clifton <nickc@redhat.com>
|
||||
|
||||
* objcopy.c (copy_object): Replace call to
|
||||
bfd_create_gnu_debuglink_section with seperate calls to
|
||||
bfd_add_gnu_debuglink_section and
|
||||
bfd_fill_in_gnu_debuglink_section, seperated by a walk over the
|
||||
symbol tables.
|
||||
|
||||
2003-06-26 Roland McGrath <roland@redhat.com>
|
||||
|
||||
* readelf.c (loadaddr): Variable removed.
|
||||
|
|
|
@ -1132,6 +1132,7 @@ copy_object (ibfd, obfd)
|
|||
bfd_vma start;
|
||||
long symcount;
|
||||
asection **osections = NULL;
|
||||
asection * gnu_debuglink_section = NULL;
|
||||
bfd_size_type *gaps = NULL;
|
||||
bfd_size_type max_gap = 0;
|
||||
long symsize;
|
||||
|
@ -1249,9 +1250,14 @@ copy_object (ibfd, obfd)
|
|||
|
||||
if (gnu_debuglink_filename != NULL)
|
||||
{
|
||||
if (! bfd_add_gnu_debuglink (obfd, gnu_debuglink_filename))
|
||||
gnu_debuglink_section = bfd_create_gnu_debuglink_section (obfd, gnu_debuglink_filename);
|
||||
|
||||
if (gnu_debuglink_section == NULL)
|
||||
{
|
||||
fprintf (stderr, "UGG\n");
|
||||
RETURN_NONFATAL (gnu_debuglink_filename);
|
||||
}
|
||||
}
|
||||
|
||||
if (gap_fill_set || pad_to_set)
|
||||
{
|
||||
|
@ -1413,6 +1419,16 @@ copy_object (ibfd, obfd)
|
|||
}
|
||||
}
|
||||
|
||||
if (gnu_debuglink_filename != NULL)
|
||||
{
|
||||
if (! bfd_fill_in_gnu_debuglink_section
|
||||
(obfd, gnu_debuglink_section, gnu_debuglink_filename))
|
||||
{
|
||||
fprintf (stderr, "UGG 2\n");
|
||||
RETURN_NONFATAL (gnu_debuglink_filename);
|
||||
}
|
||||
}
|
||||
|
||||
if (gap_fill_set || pad_to_set)
|
||||
{
|
||||
bfd_byte *buf;
|
||||
|
|
Loading…
Reference in a new issue