return pakfire_elf_dyn_walk(self, pakfire_elf_check_runpath, runpaths);
}
+static int __pakfire_elf_is_stripped(struct pakfire_elf* self,
+ const Elf_Scn* section, const Elf64_Shdr* shdr, Elf_Data* data) {
+ // Fetch the section name
+ const char* name = elf_strptr(self->elf, self->shstrndx, shdr->sh_name);
+ if (!name)
+ return -EINVAL;
+
+ switch (shdr->sh_type) {
+ // We should not have .symtab
+ case SHT_SYMTAB:
+ return 1;
+
+ // We should not have .symstr
+ case SHT_STRTAB:
+ if (pakfire_string_equals(name, ".symstr"))
+ return 1;
+
+ break;
+
+ // Sometimes we need to check by name...
+ default:
+ // There should be nothing here starting with .debug_* or .zdebug_*
+ if (pakfire_string_startswith(name, ".debug_"))
+ return 1;
+
+ else if (pakfire_string_startswith(name, ".zdebug_*"))
+ return 1;
+
+ // GDB symbol lookup
+ else if (pakfire_string_equals(name, ".gdb_index"))
+ return 1;
+
+ break;
+ }
+
+ return 0;
+}
+
int pakfire_elf_is_stripped(struct pakfire_elf* self) {
- Elf_Scn* symtab = NULL;
+ int r;
switch (pakfire_elf_type(self)) {
// Do not check Relocatable Objects
break;
}
- // Fetch the symbol table
- return pakfire_elf_get_section(self, SHT_SYMTAB, NULL, &symtab, NULL, NULL);
+ // Run through all sections
+ r = pakfire_elf_foreach_section(self, SHT_NULL, __pakfire_elf_is_stripped);
+ if (r < 0)
+ return r;
+
+ // If the callback found something, the binary is not stripped
+ else if (r == 1)
+ return 0;
+
+ // Otherwise we assume the binary being stripped
+ return 1;
}