如何使用PINtool链接dramsim2库接口 [英] how to link dramsim2 library interface with a PINtool

查看:85
本文介绍了如何使用PINtool链接dramsim2库接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在开发中的PINtool中使用DRAMSim2作为库接口.

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

我尝试熟悉包含dramsim_test.h的dramsim_test.cpp,其中包括DRAMSim.h(在特定目录中).

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

如果我将这些文件放在PINtool的目录中并包括它们(.cpp.为此,我使用PINtool中的代码),则出现链接器错误(我想):

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

PINtool有一个配置文件,可写入以下内容:

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 :=

dramsim示例的makefile具有以下内容:

The makefile of dramsim example has this:

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

我想我必须在pintool配置文件中的-ldramism选项中添加一个位置,但是我不知道怎么做.

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?

更新:问题已解决.通过添加-ldramsim更改conf文件后,它没有起作用,我尝试将libdramsim.so移到allcache_v7.cpp文件夹中,并且可以...

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...

推荐答案

只需将-ldramsim添加到TOOL_LIBS变量中即可.您还需要添加其路径.因此,更改行:

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

TOOL_LIBS := -lpin -lxed

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

更新:既然您已经成功构建了库,那么您就快要准备好了.您只需要确保在加载时由动态链接器找到它即可.从理论上讲,这是在您的shell提示符下完成的:

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

这应该告诉您链接程序是否可以解析libdramsin.so.在export ...命令之前和之后进行尝试-查看输出是否从未找到"之类的内容变为库的真实路径.

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.

这篇关于如何使用PINtool链接dramsim2库接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆