常见的问题:
- crt 相关的头文件的使用
- USIZE不再被定义
主要原因是头文件的include的使用不同,还有一些接口的改变。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| $ make obj-intel64/inscount0.so g++
-Wall -Werror -Wno-unknown-pragmas -Wno-dangling-pointer
-fno-stack-protector
-fno-exceptions -funwind-tables -fasynchronous-unwind-tables -fPIC
-fabi-version=2 -faligned-new -fno-rtti
-DPIN_CRT=1 -DTARGET_IA32E -DHOST_IA32E -DTARGET_LINUX
-I../../../source/include/pin -I../../../source/include/pin/gen -isystem /staff/shaojiemike/Download/pin-3.28-98749-g6643ecee5-gcc-linux/extras/cxx/include -isystem /staff/shaojiemike/Download/pin-3.28-98749-g6643ecee5-gcc-linux/extras/crt/include -isystem /staff/shaojiemike/Download/pin-3.28-98749-g6643ecee5-gcc-linux/extras/crt/include/arch-x86_64 -isystem /staff/shaojiemike/Download/pin-3.28-98749-g6643ecee5-gcc-linux/extras/crt/include/kernel/uapi -isystem /staff/shaojiemike/Download/pin-3.28-98749-g6643ecee5-gcc-linux/extras/crt/include/kernel/uapi/asm-x86 -I../../../extras/components/include -I../../../extras/xed-intel64/include/xed -I../../../source/tools/Utils -I../../../source/tools/InstLib
-O3 -fomit-frame-pointer -fno-strict-aliasing -c -o obj-intel64/inscount0.o inscount0.cpp
g++ -shared -Wl,--hash-style=sysv ../../../intel64/runtime/pincrt/crtbeginS.o -Wl,-Bsymbolic -Wl,--version-script=../../../source/include/pin/pintool.ver -fabi-version=2 -o obj-intel64/inscount0.so obj-intel64/inscount0.o -L../../../intel64/runtime/pincrt -L../../../intel64/lib -L../../../intel64/lib-ext -L../../../extras/xed-intel64/lib -lpin -lxed ../../../intel64/runtime/pincrt/crtendS.o -lpindwarf -ldl-dynamic -nostdlib -lc++ -lc++abi -lm-dynamic -lc-dynamic -lunwind-dynamic
|
对应的makefile规则在source/tools/Config/makefile.default.rules
1 2 3 4 5 6
| $(OBJDIR)%$(OBJ_SUFFIX): %.cpp $(CXX) $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $<
$(OBJDIR)%$(PINTOOL_SUFFIX): $(OBJDIR)%$(OBJ_SUFFIX) $(LINKER) $(TOOL_LDFLAGS) $(LINK_EXE)$@ $< $(TOOL_LPATHS) $(TOOL_LIBS)
|
- how to solve the
UINT64
undefined bug: inscount0.cpp
include pin.H
which includes types_foundation.PH
与基于 scons的编译流程的对比
由于old pintool 基于 pin2.14。作为对比也分析inscount0.so
的编译过程
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| g++
-Wall -Werror -Wno-unknown-pragmas
-fno-stack-protector
-fPIC
-DBIGARRAY_MULTIPLIER=1 -DTARGET_IA32E -DHOST_IA32E -DTARGET_LINUX -I../../../source/include/pin -I../../../source/include/pin/gen -I../../../extras/components/include -I../../../extras/xed-intel64/include -I../../../source/tools/InstLib
-O3 -fomit-frame-pointer -fno-strict-aliasing -c -o obj-intel64/inscount0.o inscount0.cpp
|
同时multipim 的scons的编译细节如下,去除与pin无关的参数:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| g++
-Wall -Wno-unknown-pragmas
-std=c++0x
-fPIC
-g
-fno-stack-protector
-MMD
-march=core2
-D_GLIBCXX_USE_CXX11_ABI=0 -fabi-version=2
-DBIGARRAY_MULTIPLIER=1 -DUSING_XED -DTARGET_IA32E -DHOST_IA32E -DTARGET_LINUX -DPIN_PATH="/staff/shaojiemike/github/MultiPIM_icarus0/pin/intel64/bin/pinbin" -DZSIM_PATH="/staff/shaojiemike/github/MultiPIM_icarus0/build/opt/libzsim.so" -DMT_SAFE_LOG -Ipin/extras/xed-intel64/include -Ipin/source/include/pin -Ipin/source/include/pin/gen -Ipin/extras/components/include
-O3 -funroll-loops -fomit-frame-pointer -c -o build/opt/simple_core.os build/opt/simple_core.cpp
|
STEP1: update define and include path order
对比后,pin3.28 相对 pin2.14 编译时,
- 加入了新定义
-DPIN_CRT=1
- include path and order changed a lot
- 编译选项也有改变(low influence)
STEP2: code change for include
1 2 3 4 5
| > typedef uint16_t Elf32_Section; > typedef uint16_t Elf64_Section;
remove __THROW
|
STEP3: ld errors
First apply the two change to old pintool
需要进一步的研究学习
暂无
遇到的问题
暂无
开题缘由、总结、反思、吐槽~~
参考文献
上面回答部分来自ChatGPT-3.5,没有进行正确性的交叉校验。
无