// Strings
size_t shstrndx;
+ // Interpreter
+ const char* interpreter;
+
// GNU Build ID
char* build_id;
return 0;
}
+static int pakfire_elf_fetch_interpreter(
+ struct pakfire_elf* self, const GElf_Phdr* phdr, void* data) {
+ Elf_Data* chunk = NULL;
+
+ switch (phdr->p_type) {
+ case PT_INTERP:
+ chunk = elf_getdata_rawchunk(self->elf, phdr->p_offset, phdr->p_filesz, ELF_T_BYTE);
+ if (!chunk || !chunk->d_buf) {
+ ERROR(self->ctx, "Failed to fetch the interpreter\n");
+ return -EINVAL;
+ }
+
+ // Store the interpreter
+ self->interpreter = (const char*)chunk->d_buf;
+ break;
+
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+const char* pakfire_elf_interpreter(struct pakfire_elf* self) {
+ int r;
+
+ // Fetch the interpreter if not available
+ if (!self->interpreter) {
+ r = pakfire_elf_foreach_program_header(self, pakfire_elf_fetch_interpreter, NULL);
+ if (r < 0)
+ return NULL;
+ }
+
+ return self->interpreter;
+}
+
int pakfire_elf_is_pie(struct pakfire_elf* self) {
switch (pakfire_elf_type(self)) {
// Shared Object files are good
int pakfire_elf_endianess(struct pakfire_elf* self);
const char* pakfire_elf_build_id(struct pakfire_elf* self);
const char* pakfire_elf_debuglink(struct pakfire_elf* self);
+const char* pakfire_elf_interpreter(struct pakfire_elf* elf);
int pakfire_elf_is_pie(struct pakfire_elf* self);
int pakfire_elf_has_ssp(struct pakfire_elf* self);