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

'SO'에 해당되는 글 2건

  1. 2017.03.30 shared object (.so) 가 로딩된 위치
  2. 2014.05.19 lists exported symbols

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

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'

lists exported symbols

tips & tricks/Linux/Unix 2014. 5. 19. 16:05 by manywaypark

shared object 파일에서 어떤 symbol들이 export되는지 궁금해지는 경우가 있다.

(특히 unsolved external symbol 따위 linker error가 발생할 경우)

다음과 같이 하면 symbol들을 human-readable한 형태로 뽑아준다.

$ (find . -name '*.a'|xargs nm -f posix; find . -name '*.so' | xargs nm -f posix -D)|cut -f1 -d' '|LANG=C sort -u > all_symbols

$ grep '^_Z' all_symbols | c++filt|sort > demangled_c++_symbols


refs:

http://gcc.gnu.org/wiki/Cxx11AbiCompatibility

http://stackoverflow.com/questions/1237575/how-do-i-find-out-what-all-symbols-are-exported-from-a-shared-object


happy hackin'

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

공지사항

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

04-30 17:18