aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2003-06-27 08:01:28 +0000
committerNick Clifton <nickc@redhat.com>2003-06-27 08:01:28 +0000
commite7c81c254c0efabd933b208c8702d98d81b2bffa (patch)
tree41c9020838a2113579244f6b503605c1d8f4b301
parent72b4917c07ca0e1e2610c32543a2662dd2048f91 (diff)
downloadgdb-e7c81c254c0efabd933b208c8702d98d81b2bffa.zip
gdb-e7c81c254c0efabd933b208c8702d98d81b2bffa.tar.gz
gdb-e7c81c254c0efabd933b208c8702d98d81b2bffa.tar.bz2
Fix --add-gnu-debuglink
-rw-r--r--bfd/ChangeLog9
-rw-r--r--bfd/bfd-in2.h5
-rw-r--r--bfd/opncls.c108
-rw-r--r--binutils/ChangeLog8
-rw-r--r--binutils/objcopy.c18
5 files changed, 114 insertions, 34 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 6930e04..44159e5 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -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.
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index bdd7a48..c6815cc 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -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. */
diff --git a/bfd/opncls.c b/bfd/opncls.c
index b6b4097..5237190 100644
--- a/bfd/opncls.c
+++ b/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)
{
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 5b01202..1cbaca6 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -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.
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index de77767..9b87a8a 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -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,8 +1250,13 @@ 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;