在固定gpu内存会调用到nvidia驱动源码nv-p2p.h里的:
int nvidia_p2p_get_pages(uint64_t p2p_token, uint32_t va_space_token,
uint64_t virtual_address,
uint64_t length,
struct nvidia_p2p_page_table **page_table,
void (*free_callback)(void *data),
void *data);
所以尝试把nv-p2p.o文件编译成动态库,nv-p2p.o文件是编译nvidia驱动源码得到的。
命令:
sudo gcc -shared -o libnvp2p.so nv-p2p.o和
sudo gcc -shared -fPIC -o libnvp2p.so nv-p2p.o
都输出
错误:
/usr/bin/ld: nv-p2p.o: relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status