Make bfd_byte an int8_t, flagword a uint32_t
[binutils-gdb.git] / bfd / dwarf1.c
index 21849ce837262e4f8f78139977d60f9bdd3d1311..d7c50eaa06866e8fd8b8b6b9ef1490dfb18c159d 100644 (file)
@@ -1,5 +1,5 @@
 /* DWARF 1 find nearest line (_bfd_dwarf1_find_nearest_line).
-   Copyright (C) 1998-2022 Free Software Foundation, Inc.
+   Copyright (C) 1998-2023 Free Software Foundation, Inc.
 
    Written by Gavin Romig-Koch of Cygnus Solutions (gavin@cygnus.com).
 
@@ -301,13 +301,13 @@ parse_line_table (struct dwarf1_debug* stash, struct dwarf1_unit* aUnit)
       bfd_size_type size;
 
       msec = bfd_get_section_by_name (stash->abfd, ".line");
-      if (! msec)
+      if (! msec || (msec->flags & SEC_HAS_CONTENTS) == 0)
        return false;
 
       size = msec->rawsize ? msec->rawsize : msec->size;
       stash->line_section
-       = bfd_simple_get_relocated_section_contents
-       (stash->abfd, msec, NULL, stash->syms);
+       = bfd_simple_get_relocated_section_contents (stash->abfd, msec, NULL,
+                                                    stash->syms);
 
       if (! stash->line_section)
        return false;
@@ -510,7 +510,8 @@ _bfd_dwarf1_find_nearest_line (bfd *abfd,
        return false;
 
       msec = bfd_get_section_by_name (abfd, ".debug");
-      if (! msec)
+      if (! msec
+         || (msec->flags & SEC_HAS_CONTENTS) == 0)
        /* No dwarf1 info.  Note that at this point the stash
           has been allocated, but contains zeros, this lets
           future calls to this function fail quicker.  */
@@ -592,3 +593,15 @@ _bfd_dwarf1_find_nearest_line (bfd *abfd,
 
   return false;
 }
+
+void
+_bfd_dwarf1_cleanup_debug_info (bfd *abfd ATTRIBUTE_UNUSED, void **pinfo)
+{
+  struct dwarf1_debug* stash = *pinfo;
+
+  if (stash == NULL)
+    return;
+
+  free (stash->debug_section);
+  free (stash->line_section);
+}