반응형
Linux에서 현재 rpath를 검사하는 방법이 있습니까?
readelf -d <elf> | grep RPATH
쉘에서 주어진 바이너리를 검사하는 데 사용할 수 있다는 것을 알고 있지만 프로세스 내에서이 작업을 수행 할 수 있습니까?
(내가 완전히 구성한 시스템 호출) :
/* get a copy of current rpath into buffer */
sys_get_current_rpath(&buffer);
코드베이스에서 의심스러운 SO 링크 문제를 진단하려고 시도하고 있으며 가능하면 RPATH를 검사하고 싶습니다 (차라리 외부 스크립트를 생성 할 필요가 없습니다).
#include <stdio.h>
#include <elf.h>
#include <link.h>
int main()
{
const ElfW(Dyn) *dyn = _DYNAMIC;
const ElfW(Dyn) *rpath = NULL;
const char *strtab = NULL;
for (; dyn->d_tag != DT_NULL; ++dyn) {
if (dyn->d_tag == DT_RPATH) {
rpath = dyn;
} else if (dyn->d_tag == DT_STRTAB) {
strtab = (const char *)dyn->d_un.d_val;
}
}
if (strtab != NULL && rpath != NULL) {
printf("RPATH: %s\n", strtab + rpath->d_un.d_val);
}
return 0;
}
기록을 위해 rpath
헤더 를 표시하는 몇 가지 명령이 있습니다.
objdump -x binary-or-library |grep RPATH
더 나은 방법은 다음과 같습니다.
readelf -d binary-or-library |head -20
두 번째 명령은 다른 라이브러리에 대한 직접적인 종속성과 rpath
.
다음을 사용할 수도 있습니다.
chrpath -l binary-or-library
참고 URL : https://stackoverflow.com/questions/2836330/is-there-a-way-to-inspect-the-current-rpath-on-linux
반응형
'Program Tip' 카테고리의 다른 글
iPhone에서 TableView 구분 기호를 사용자 지정하는 방법 (0) | 2020.11.19 |
---|---|
StreamReader를 처음으로 반환 (0) | 2020.11.19 |
Android에서 수직 SeekBar를 만드는 방법은 무엇입니까? (0) | 2020.11.19 |
Internet Explorer의 addEventListener (0) | 2020.11.19 |
iOS 앱이 처음 실행되는시기를 감지 하시겠습니까? (0) | 2020.11.19 |