]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/gdb_bfd.c
* coffread.c (cs_to_section): Use gdb_bfd_section_index.
[thirdparty/binutils-gdb.git] / gdb / gdb_bfd.c
index 53c3a1244e075e117e6fa1d696fbd4d73a44062b..e7cd5237943c6899e299f7030394bc197de92631 100644 (file)
@@ -605,6 +605,36 @@ gdb_bfd_fdopenr (const char *filename, const char *target, int fd)
 
 \f
 
+gdb_static_assert (ARRAY_SIZE (_bfd_std_section) == 4);
+
+/* See gdb_bfd.h.  */
+
+int
+gdb_bfd_section_index (bfd *abfd, asection *section)
+{
+  if (section == NULL)
+    return -1;
+  else if (section == bfd_com_section_ptr)
+    return bfd_count_sections (abfd) + 1;
+  else if (section == bfd_und_section_ptr)
+    return bfd_count_sections (abfd) + 2;
+  else if (section == bfd_abs_section_ptr)
+    return bfd_count_sections (abfd) + 3;
+  else if (section == bfd_ind_section_ptr)
+    return bfd_count_sections (abfd) + 4;
+  return section->index;
+}
+
+/* See gdb_bfd.h.  */
+
+int
+gdb_bfd_count_sections (bfd *abfd)
+{
+  return bfd_count_sections (abfd) + 4;
+}
+
+\f
+
 /* A callback for htab_traverse that prints a single BFD.  */
 
 static int