Skip to content

Instantly share code, notes, and snippets.

@ayosec
Created July 27, 2021 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayosec/eedf9301cc9bc0934a44640979825b98 to your computer and use it in GitHub Desktop.
Save ayosec/eedf9301cc9bc0934a44640979825b98 to your computer and use it in GitHub Desktop.
#define _GNU_SOURCE
#include <link.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
struct link_map *m;
ElfW(Dyn) *dynsec;
ElfW(Addr) pltgot = 0;
for(m = _r_debug.r_map; m != NULL; m = m->l_next) {
printf("name = %s, l_addr = %p\n", m->l_name, m->l_addr);
for(dynsec = m->l_ld; dynsec->d_tag != DT_NULL; dynsec++) {
if (dynsec->d_tag == DT_PLTGOT) {
pltgot = dynsec->d_un.d_ptr;
break;
}
}
printf("pltgot = %p\n", pltgot);
/*
for(ds = m->l_ld; ds->d_tag != DT_NULL; ds++) {
printf("d_tag = %d\tptr = %p\tval = %u\n", ds->d_tag, ds->d_un.d_ptr, ds->d_un.d_val);
}
*/
}
sleep(100);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment