how to link dramsim2 library interface with a PINtool

帅比萌擦擦* 提交于 2019-12-13 12:22:39

问题


I want to use DRAMSim2 as library interface in a developing PINtool.

I try to be familiar with dramsim_test.cpp that includes dramsim_test.h, that includes DRAMSim.h (in a specific directory).

If i put these files in the directory of my PINtool an include them (except .cpp. for this i use the code in the PINtool) i get a linker (i suppose) error:

undefined symbol: _ZN7DRAMSim23getMemorySystemInstanceERKSsS1_S1_S1_jPSs

The PINtool has a config file that writes these:

## Libraries to link
ifeq ($(TARGET_OS),mac)
    APP_LIBS := -lm
else
    APP_LIBS := -Wl,--as-needed -lm
endif
DL_LIB :=
APP_LIB_ATOMIC := -latomic
APP_LIB_XED := -lxed
TOOL_LIBS := -lpin -lxed
SATOOL_LIBS := -lsapin -lxed
CXX_LIBS :=

The makefile of dramsim example has this:

$(CXX) -g -o dramsim_test dramsim_test.cpp -I../ -L../ -ldramsim -Wl,-rpath=../

I suppose that i have to add somewhere in the pintool config file the -ldramism option but i dont know how.

Im not familiar also with linker options, configuration files etc. How can i link them?

UPDATE: The problem solved. After changing the conf file by adding -ldramsim and didnt work, i tried to move the libdramsim.so into the folder of allcache_v7.cpp and is ok...


回答1:


Just add -ldramsim to the TOOL_LIBS variable. You will also need to add its path. So change the line:

TOOL_LIBS := -lpin -lxed

to

TOOL_LIBS := -lpin -lxed -L/path/to/dramsim/ -ldramsim

UPDATE: Now that you have successfully built your library, you're almost there. You just need to make sure it is found by the dynamic linker at load time. In theory, this is done as follows from your shell prompt:

> export LD_LIBRARY_PATH=/path/to/dramsim:${LD_LIBRARY_PATH}
> #command to invoke binary that uses your library allcache_v7.so

If this still gives you problems, check if the linker can resolve it:

> ldd allcache_v7.so | grep dramsim

This should tell you whether the linker can resolve libdramsin.so or not. Try it before and after the export ... command - see if the output changes from something like "Not found" to the true path of the library.



来源:https://stackoverflow.com/questions/37707344/how-to-link-dramsim2-library-interface-with-a-pintool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!