2011-12-12 16 views
11

ben şöyleHATA: ld.so: LD_PRELOAD nesne 'getpid.so' önceden yüklenmiş edilemez: göz ardı

LD_PRELOAD=getpid.so ./testpid 

aşağıdaki hatayı ...

ERROR: ld.so: object 'getpid.so' from LD_PRELOAD cannot be preloaded: ignored. 
LD_PRELOAD kullanmaya çalıştığınızda

...

Ben

gcc -Wall -fPIC -shared -o getpid.so getpid.c 

kullanarak getpid.so derlemek ve aşağıdaki kodu içeren Burada sorun olabilir ne

gcc testpid -o testpid.c 

yaparak derlenmektedir aşağıda gösterildiği gibi getpid kullanır
// getpid.c 
#include <sys/syscall.h> 
#include <sys/types.h> 
#include <unistd.h> 
#include <stdio.h> 

pid_t getpid(void) 
{ 
    printf("Hello, world!\n"); 
    return syscall(SYS_getpid); 
} 

tespid.c constains kodu? LD_PRELOAD neden çalışmıyor? yükleyici kütüphanede yolunu belirtilmeyen ettik getpid.so bulamadığını gibi

// testpid.c 
#include <sys/syscall.h> 
#include <sys/types.h> 
#include <unistd.h> 
#include <stdio.h> 

int main() 
{ 
    printf("pid = %d!\n", getpid()); 

    return 0; 
} 

cevap

18

görünüyor.

Dene:

LD_PRELOAD=/full/path/to/getpid.so ./testpid 
+3

Çok doğru! LD_PRELOAD = getpid.so ./testpid yerine, LD_PRELOAD =./Getpid.so ./testpid olmalıdır. Şimdi çalışıyor. – MetallicPriest

+2

Benim durumumda da 'LD_LIBRARY_PATH' ayarını yapmak ve kütüphanenin 64-bit versiyonunu almak zorunda kaldım. –

İlgili konular