manywaypark's Blog
개발, 검색, 함수

'dladdr'에 해당되는 글 1건

  1. 2017.03.30 shared object (.so) 가 로딩된 위치

가끔은 자기 자신이 어디서 로딩되었는지를 알아야만 할 때가 있다.

static initialization 과정에서 함수의 주소로 알아내는 방법이 있다.

#define _GNU_SOURCE

#include <dlfcn.h>

#include <stdio.h>


__attribute__((constructor))

void on_load(void) {

  Dl_info dl_info;

  dladdr((void *)on_load, &dl_info);

  fprintf(stderr, "module %s loaded\n", dl_info.dli_fname);

}

좀더 자세한건 man 3 dladdr


refs: 

http://stackoverflow.com/questions/1681060/library-path-when-dynamically-loaded

https://cseweb.ucsd.edu/~gbournou/CSE131/the_inside_story_on_shared_libraries_and_dynamic_loading.pdf

the_inside_story_on_shared_libraries_and_dynamic_loading.pdf

happy hackin'

1 
분류 전체보기 (306)
잡담 (20)
함수형 언어 (65)
emacs (16)
java (18)
tips & tricks (154)
사랑 (1)
가사 (0)
독서 (4)
mobile (6)
비함수형 언어 (2)

공지사항

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

04-19 07:18