기본 콘텐츠로 건너뛰기

GCC -rdynamic 플래그

GNU C 라이브러리에서 backtrace 함수를 지원하는 것 관련해서 -rdynamic 플래그를 쓰는 것에 대해 다시 볼 기회가 생겼다. (몇 년 전에 잠깐 보고 말았더랬지)

-rdynamic
    Pass the flag -export-dynamic to the ELF linker, on targets that support it. This instructs the linker to add all symbols, not only used ones, to the dynamic symbol table. This option is needed for some uses of "dlopen" or to allow obtaining backtraces from within a program.

여러번 재사용할 수 있는 심볼테이블을 만들라는 것인데, 컴파일러용 옵션이 아니라 링커용 옵션이다. 보통 DLL(리눅스에선 SO) 같은 걸 만들 때, 다른 Process가 이름(심볼)로 접근하기 위해 테이블을 만드는 것이다.

-g는 디버깅용 심볼테이블을 만드는데, 이것은 그야말로 임시용이라 strip 유틸리티 같은 걸로 날려버릴 수 있다.

참조: http://stackoverflow.com/questions/8623884/gcc-debug-symbols-g-flag-vs-linkers-rdynamic-option

댓글

이 블로그의 인기 게시물

Winget 해시 무시하기

가끔씩 Winget 에서 패키지를 다운로드 했을 때, "설치 관리자 해시가 일치하지 않습니다." 오류가 뜰 때가 있다. 보안 이슈가 있지만, 그냥 무시하고 싶을 때, 아래 순서로 무시해준다. 관리자 권한 winget settings --enable InstallerHashOverride 설치 winget install --ignore-security-hash --id NirSoft.NirCmd