使用依赖项编译 PIN 工具

Compiling PIN tool with dependencies

如标题所述,我正在寻找一种方法来使用一些依赖项来编译我的 PIN 工具。因此,例如,如果我在我的 PIN 工具中 #include "somefile.h",并生成一些 object 文件 g++ -c somefile.cpp,我如何 link 我的 object 文件与我的 PIN 一起编译工具以便我可以在我的 PIN 工具中使用它的功能?

您需要在 "makefile.rules" 末尾添加一条新规则:

$(OBJDIR)YourPinToolMainFile$(PINTOOL_SUFFIX): $(OBJDIR)YourPinToolMainFile$(OBJ_SUFFIX) $(OBJDIR)somefile$(OBJ_SUFFIX)
$(LINKER) $(TOOL_LDFLAGS) $(LINK_EXE)$@ $^ $(TOOL_LPATHS) $(TOOL_LIBS)

所以我能够在 PIN 的网站 here 下找到一些关于更改 "makefile.rules" 的文档。对于我的情况,下面这 6 行将添加到 "makefile.rules".

的末尾
$(OBJDIR)"somefile"$(OBJ_SUFFIX): "somefile".cpp "somefile".h
    $(CXX) $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<

$(OBJDIR)"PinFile"$(OBJ_SUFFIX): "pin_tool".cpp
    $(CXX) $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<

$(OBJDIR)"pin_tool"$(PINTOOL_SUFFIX): $(OBJDIR)"somefile"$(OBJ_SUFFIX) $(OBJDIR)"PinFile"$(OBJ_SUFFIX) "somefile".h
    $(LINKER) $(TOOL_LDFLAGS_NOOPT) $(LINK_EXE)$@ $(^:%.h=) $(TOOL_LPATHS) $(TOOL_LIBS)

The only thing that would change from one make file to another would be the words I put in quotes. Note that the quoted words should not have quotes around them in the actual "makefile.rules"