]> git.ipfire.org Git - people/ric9/pakfire.git/commitdiff
ELF: Skip any invalid DWARF sections
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 9 Jan 2025 17:20:46 +0000 (17:20 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 9 Jan 2025 17:20:46 +0000 (17:20 +0000)
On some start files in glibc, this error is thrown and I think it is
safe to just ignore it.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/elf.c

index caf508a33420e48424ee23d9cd7f231177a4fe36..a713a7cf77f50427ed5ec835f1bc6e96ed92a859 100644 (file)
@@ -1132,6 +1132,10 @@ int pakfire_elf_requires(struct pakfire_elf* self, char*** requires) {
 #define DWARF_E_NO_DWARF 6
 #endif
 
+#ifndef DWARF_E_INVALID_DWARF
+#define DWARF_E_INVALID_DWARF 16
+#endif
+
 int pakfire_elf_foreach_source_file(struct pakfire_elf* self,
                pakfire_elf_foreach_source_file_callback callback, void* data) {
        const char* filename = NULL;
@@ -1177,9 +1181,17 @@ int pakfire_elf_foreach_source_file(struct pakfire_elf* self,
                // Fetch the source files
                r = dwarf_getsrcfiles(die, &files, &count);
                if (r < 0) {
-                       ERROR(self->ctx, "Could not fetch the source files: %s\n", dwarf_errmsg(-1));
-                       r = -errno;
-                       goto ERROR;
+                       switch (dwarf_errno()) {
+                               // Skip any invalid DWARF sections
+                               case DWARF_E_INVALID_DWARF:
+                                       goto NEXT;
+
+                               default:
+                                       ERROR(self->ctx, "Could not fetch the source files for %s: %s\n",
+                                               self->path, dwarf_errmsg(-1));
+                                       r = -ENOTSUP;
+                                       goto ERROR;
+                       }
                }
 
                // Iterate over all files...
@@ -1213,6 +1225,7 @@ int pakfire_elf_foreach_source_file(struct pakfire_elf* self,
                                goto ERROR;
                }
 
+NEXT:
                offset = next_offset;
        }