]> git.ipfire.org Git - pakfire.git/commitdiff
linter: Use the new ELF object
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Jan 2025 17:14:54 +0000 (17:14 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Jan 2025 17:14:54 +0000 (17:14 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/linter-file.c

index 1782c77b8f2b49010222aefa55875dff94aee664..7c5af01ad0daad56d0c147b753967d9c4d635b1e 100644 (file)
@@ -27,6 +27,7 @@
 #include <elfutils/libdwelf.h>
 
 #include <pakfire/ctx.h>
+#include <pakfire/elf.h>
 #include <pakfire/file.h>
 #include <pakfire/linter.h>
 #include <pakfire/linter-file.h>
@@ -43,6 +44,9 @@ struct pakfire_linter_file {
        // File
        struct pakfire_file* file;
 
+       // ELF Object
+       struct pakfire_elf* _elf;
+
        // File Descriptor
        int fd;
 
@@ -157,6 +161,20 @@ int pakfire_linter_file_create(struct pakfire_linter_file** lfile,
                goto ERROR;
        }
 
+       // Open an ELF object
+       r = pakfire_elf_open(&l->_elf, l->ctx, l->path, l->fd);
+       if (r < 0) {
+               switch (-r) {
+                       // This does not seem to be an ELF file
+                       case ENOTSUP:
+                               break;
+
+                       // Something else happened
+                       default:
+                               goto ERROR;
+               }
+       }
+
        // Initialize libelf
        r = pakfire_linter_file_open_elf(l);
        if (r < 0) {
@@ -177,6 +195,9 @@ ERROR:
 static void pakfire_linter_file_free(struct pakfire_linter_file* lfile) {
        int r;
 
+       if (lfile->_elf)
+               pakfire_elf_unref(lfile->_elf);
+
        if (lfile->elf)
                elf_end(lfile->elf);