Created
July 27, 2021 21:07
-
-
Save ayosec/eedf9301cc9bc0934a44640979825b98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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