]> git.ipfire.org Git - people/stevee/pakfire.git/blobdiff - src/libpakfire/file.c
file: Pass Dyn tag to the callback function
[people/stevee/pakfire.git] / src / libpakfire / file.c
index d8034b6abbbc1df398068e7b6732b1cf7c38f9bb..10cd8439a808d24f66602f3165ead10de2cd78d8 100644 (file)
@@ -1745,11 +1745,13 @@ static int pakfire_file_get_elf_type(struct pakfire_file* file) {
 }
 
 static int pakfire_file_elf_dyn_walk(struct pakfire_file* file, Elf* elf,
-               int (*callback)(struct pakfire_file* file, Elf64_Word key, const char* value, void* data),
+               int (*callback)(struct pakfire_file* file,
+                       Elf* elf, const GElf_Shdr* shdr, const GElf_Dyn* dyn, void* data),
                void* data) {
        Elf_Scn* dynamic = NULL;
        GElf_Shdr shdr;
        Elf_Data* elf_data = NULL;
+       GElf_Dyn dyn;
        int r;
 
        // Find the dynamic linking information
@@ -1759,20 +1761,14 @@ static int pakfire_file_elf_dyn_walk(struct pakfire_file* file, Elf* elf,
                return 1;
        }
 
-       GElf_Dyn dyn;
-       const char* value = NULL;
-
        // Walk through all entries...
        for (unsigned int i = 0; ; i++)  {
                // Fetch the next entry
                if (!gelf_getdyn(elf_data, i, &dyn))
                        break;
 
-               // Fetch the value
-               value = elf_strptr(elf, shdr.sh_link, dyn.d_un.d_val);
-
                // Call the callback
-               r = callback(file, dyn.d_tag, value, data);
+               r = callback(file, elf, &shdr, &dyn, data);
                if (r)
                        return r;
        }
@@ -1975,28 +1971,34 @@ static int __pakfire_file_check_partially_relro(
        }
 
        // This file does not seem to have PT_GNU_RELRO set
-       file->issues |= PAKFIRE_FILE_NO_PARTIALLY_RELRO;
+       file->issues |= PAKFIRE_FILE_NO_RELRO;
 
        return 0;
 }
 
 static int pakfire_file_check_relro(struct pakfire_file* file) {
-       return pakfire_file_open_elf(file, __pakfire_file_check_partially_relro, NULL);
+       return pakfire_file_open_elf(file, __pakfire_file_check_relro, NULL);
 }
 
 /*
        RPATH/RUNPATH
 */
 static int __pakfire_file_process_runpath(struct pakfire_file* file,
-               Elf64_Word key, const char* value, void* data) {
+               Elf* elf, const GElf_Shdr* shdr, const GElf_Dyn* dyn, void* data) {
+       const char* value = NULL;
        const char* runpath = NULL;
        char buffer[PATH_MAX];
        char* p = NULL;
        int r;
 
-       switch (key) {
+       switch (dyn->d_tag) {
                case DT_RUNPATH:
                case DT_RPATH:
+                       // Fetch the value
+                       value = elf_strptr(elf, shdr->sh_link, dyn->d_un.d_val);
+                       if (!value)
+                               return 1;
+
                        DEBUG(file->pakfire, "%s has a RUNPATH: %s\n", file->path, value);
 
                        // Copy the value into a buffer we can modify