Move GDB/MI commands related to support-query to their own @node.
[deliverable/binutils-gdb.git] / bfd / opncls.c
index cd9c826dd4bcf9989dc040d143d5c2feed8a7b76..3f09420bf735db821a88bc6395702b6f26c7e06d 100644 (file)
@@ -80,27 +80,12 @@ _bfd_new_bfd (void)
 
   nbfd->arch_info = &bfd_default_arch_struct;
 
-  nbfd->direction = no_direction;
-  nbfd->iostream = NULL;
-  nbfd->where = 0;
   if (!bfd_hash_table_init_n (& nbfd->section_htab, bfd_section_hash_newfunc,
                              sizeof (struct section_hash_entry), 13))
     {
       free (nbfd);
       return NULL;
     }
-  nbfd->sections = NULL;
-  nbfd->section_last = NULL;
-  nbfd->format = bfd_unknown;
-  nbfd->my_archive = NULL;
-  nbfd->origin = 0;
-  nbfd->opened_once = FALSE;
-  nbfd->output_has_begun = FALSE;
-  nbfd->section_count = 0;
-  nbfd->usrdata = NULL;
-  nbfd->cacheable = FALSE;
-  nbfd->flags = BFD_NO_FLAGS;
-  nbfd->mtime_set = FALSE;
 
   return nbfd;
 }
@@ -1194,18 +1179,22 @@ FUNCTION
        bfd_get_alt_debug_link_info
 
 SYNOPSIS
-       char *bfd_get_alt_debug_link_info (bfd *abfd, unsigned long *crc32_out);
+       char *bfd_get_alt_debug_link_info (bfd * abfd,
+                                          bfd_size_type *buildid_len,
+                                          bfd_byte **buildid_out);
 
 DESCRIPTION
        Fetch the filename and BuildID value for any alternate debuginfo
        associated with @var{abfd}.  Return NULL if no such info found,
-       otherwise return filename and update @var{buildid_out}.  The
-       returned filename is allocated with @code{malloc}; freeing it
-       is the responsibility of the caller.
+       otherwise return filename and update @var{buildid_len} and
+       @var{buildid_out}.  The returned filename and build_id are
+       allocated with @code{malloc}; freeing them is the
+       responsibility of the caller.
 */
 
 char *
-bfd_get_alt_debug_link_info (bfd * abfd, unsigned long * buildid_out)
+bfd_get_alt_debug_link_info (bfd * abfd, bfd_size_type *buildid_len,
+                            bfd_byte **buildid_out)
 {
   asection *sect;
   bfd_byte *contents;
@@ -1213,6 +1202,7 @@ bfd_get_alt_debug_link_info (bfd * abfd, unsigned long * buildid_out)
   char *name;
 
   BFD_ASSERT (abfd);
+  BFD_ASSERT (buildid_len);
   BFD_ASSERT (buildid_out);
 
   sect = bfd_get_section_by_name (abfd, GNU_DEBUGALTLINK);
@@ -1227,12 +1217,13 @@ bfd_get_alt_debug_link_info (bfd * abfd, unsigned long * buildid_out)
       return NULL;
     }
 
-  /* BuildID value is stored after the filename, aligned up to 4 bytes.  */
+  /* BuildID value is stored after the filename.  */
   name = (char *) contents;
   buildid_offset = strlen (name) + 1;
-  buildid_offset = (buildid_offset + 3) & ~3;
 
-  * buildid_out = bfd_get_32 (abfd, contents + buildid_offset);
+  *buildid_len = bfd_get_section_size (sect) - buildid_offset;
+  *buildid_out = bfd_malloc (*buildid_len);
+  memcpy (*buildid_out, contents + buildid_offset, *buildid_len);
 
   return name;
 }
@@ -1466,6 +1457,24 @@ bfd_follow_gnu_debuglink (bfd *abfd, const char *dir)
                                   separate_debug_file_exists);
 }
 
+/* Helper for bfd_follow_gnu_debugaltlink.  It just pretends to return
+   a CRC.  .gnu_debugaltlink supplies a build-id, which is different,
+   but this is ok because separate_alt_debug_file_exists ignores the
+   CRC anyway.  */
+
+static char *
+get_alt_debug_link_info_shim (bfd * abfd, unsigned long *crc32_out)
+{
+  bfd_size_type len;
+  bfd_byte *buildid = NULL;
+  char *result = bfd_get_alt_debug_link_info (abfd, &len, &buildid);
+
+  *crc32_out = 0;
+  free (buildid);
+
+  return result;
+}
+
 /*
 FUNCTION
        bfd_follow_gnu_debugaltlink
@@ -1496,7 +1505,7 @@ char *
 bfd_follow_gnu_debugaltlink (bfd *abfd, const char *dir)
 {
   return find_separate_debug_file (abfd, dir,
-                                  bfd_get_alt_debug_link_info,
+                                  get_alt_debug_link_info_shim,
                                   separate_alt_debug_file_exists);
 }
 
This page took 0.024486 seconds and 4 git commands to generate.