Skip to content

Commit

Permalink
added elf_interpreteR_path
Browse files Browse the repository at this point in the history
  • Loading branch information
elfmaster committed Mar 14, 2022
1 parent 90d3f49 commit fcbc501
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
7 changes: 4 additions & 3 deletions build/libelfmaster.pc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ prefix=/opt/elfmaster
includedir=/opt/elfmaster/include
libdir=/opt/elfmaster/lib

Name: Backtrace I/O pdb parsing library
Description: Library for the loading and parsing of pdb files
URL: http://backtrace.io/
Name: Advanced ELF binary parsing API
Description: Library for the loading, parsing, modifying and
forensic reconstruction of ELF binaries.
URL: https://github.com/elfmaster/libelfmaster
Version: 0.1.0
Cflags: -D__x86_64__ -I${includedir} -D_GNU_SOURCE

1 change: 1 addition & 0 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ all:
$(CC) -Wl,-z,separate-code test.c -o test_scop_pie
$(CC) -no-pie -Wl,-z,separate-code test.c -o test_scop_binary
$(CC) -O2 -g pltgot.c -o pltgot ../src/libelfmaster.a
$(CC) phoff.c -o phoff ../src/libelfmaster.a
./stripx test_stripped
./stripx test32_stripped
clean:
Expand Down
1 change: 1 addition & 0 deletions include/libelfmaster.h
Original file line number Diff line number Diff line change
Expand Up @@ -990,4 +990,5 @@ bool elf_section_commit(elfobj_t *);
bool elf_lxc_set_rootfs(elfobj_t *, const char *);
bool elf_lxc_get_rootfs(elfobj_t *, char *, const size_t);

char * elf_interpreter_path(elfobj_t *);
#endif
17 changes: 17 additions & 0 deletions src/libelfmaster.c
Original file line number Diff line number Diff line change
Expand Up @@ -3235,6 +3235,23 @@ elf_open_object(const char *path, struct elfobj *obj, uint64_t load_flags,
return false;
}

char *
elf_interpreter_path(elfobj_t *obj)
{
struct elf_segment segment;
elf_segment_iterator_t p_iter;
char *path;

elf_segment_iterator_init(obj, &p_iter);
while (elf_segment_iterator_next(&p_iter, &segment) == ELF_ITER_OK) {
if (segment.type == PT_INTERP) {
path = elf_offset_pointer(obj, segment.offset);
return path;
}
}
return NULL;
}

void
elf_close_object(elfobj_t *obj)
{
Expand Down

0 comments on commit fcbc501

Please sign in to comment.