Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for static dl_iterate_phdr #6

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion link.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,44 @@
#include <uk/essentials.h>
#include <stddef.h>
#include <link.h>
#include <elf.h>

#include <stdlib.h>

#ifdef DRUNTIME
struct DG {
void * addr;
struct dl_phdr_info* result;
};

extern char __bss_start[];
extern char _end[];
#endif

int dl_iterate_phdr(
int (*callback)(struct dl_phdr_info *info,
size_t size, void *data),
void *data)
{
return 0;
#ifdef DRUNTIME
struct DG* temp = (struct DG *)data;

temp->result->dlpi_addr = (ElfW(Addr))__bss_start;
temp->result->dlpi_phnum = 1;
temp->result->dlpi_adds = 0;
temp->result->dlpi_subs = 0;
temp->result->dlpi_name = "";

ElfW(Phdr) *segment_data = (ElfW(Phdr) *)malloc(sizeof(ElfW(Phdr)));
segment_data->p_type = PT_LOAD;
segment_data->p_flags = PF_W;
segment_data->p_vaddr = 0;
segment_data->p_memsz = _end - __bss_start;

temp->result->dlpi_phdr = segment_data;

return 1;
#else
return 0;
#endif
}