Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i#5879: Added an example analyzer #5916

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

prasun3
Copy link
Contributor

@prasun3 prasun3 commented Mar 16, 2023

Issue: #5879

@prasun3 prasun3 linked an issue Mar 16, 2023 that may be closed by this pull request
@prasun3
Copy link
Contributor Author

prasun3 commented Mar 16, 2023

I am seeing linking errors when I try to use these functions. It works if I extract the linker cmd line and manually add libdynamorio.so, but I wasn't able to figure out what I needed to add in my cmake script.

undefined reference to `instr_init'
undefined reference to `decode_from_copy'

@prasun3
Copy link
Contributor Author

prasun3 commented Mar 16, 2023

Nevermind, I was missing drdecode

@prasun3
Copy link
Contributor Author

prasun3 commented Mar 16, 2023

Seeing this error. Works if I point LD_LIBRARY_PATH to the lib64/release dir

./analyzer_separate: error while loading shared libraries: libdynamorio.so: cannot open shared object file: No such file or directory

@prasun3
Copy link
Contributor Author

prasun3 commented Mar 16, 2023

Windows build is failing due to symbols being defined in both libucrtd.lib and dynamorio.dll

2023-03-16T09:12:36.5993415Z 13: Run Build Command(s):C:/projects/install/ninja/ninja.exe && [1/2] Building CXX object CMakeFiles\analyzer_separate.dir\analyzer_separate.cpp.obj
2023-03-16T09:12:36.5997515Z 13: cl : Command line warning D9025 : overriding '/MDd' with '/MTd'
2023-03-16T09:12:36.6002084Z 13: [2/2] Linking CXX executable analyzer_separate.exe
2023-03-16T09:12:36.6048136Z 13: FAILED: analyzer_separate.exe 
2023-03-16T09:12:36.6391981Z 13: cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\analyzer_separate.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x86\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x86\mt.exe --manifests  -- C:\PROGRA~2\MICROS~2\2019\ENTERP~1\VC\Tools\MSVC\1429~1.301\bin\Hostx86\x86\link.exe /nologo CMakeFiles\analyzer_separate.dir\analyzer_separate.cpp.obj  /out:analyzer_separate.exe /implib:analyzer_separate.lib /pdb:analyzer_separate.pdb /version:0.0 /machine:X86 /debug /INCREMENTAL /subsystem:console  D:\a\dynamorio\dynamorio\build_debug-internal-32\lib32\drdecode.lib  D:\a\dynamorio\dynamorio\build_debug-internal-32\ext\lib32\debug\drutil.lib  D:\a\dynamorio\dynamorio\build_debug-internal-32\clients\lib32\debug\drmemtrace_analyzer.lib  D:\a\dynamorio\dynamorio\build_debug-internal-32\clients\lib32\debug\drmemtrace_histogram.lib  D:\a\dynamorio\dynamorio\build_debug-internal-32\lib32\drfrontendlib.lib  D:\a\dynamorio\dynamorio\build_debug-internal-32\lib32\drlibc.lib  D:\a\dynamorio\dynamorio\build_debug-internal-32\ext\lib32\debug\drmgr.lib  D:\a\dynamorio\dynamorio\build_debug-internal-32\ext\lib32\debug\drcontainers.lib  D:\a\dynamorio\dynamorio\build_debug-internal-32\lib32\debug\dynamorio.lib  D:\a\dynamorio\dynamorio\build_debug-internal-32\clients\lib32\debug\directory_iterator.lib  D:\a\dynamorio\dynamorio\build_debug-internal-32\lib32\drfrontendlib.lib  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
2023-03-16T09:12:36.6597649Z 13: LINK Pass 1: command "C:\PROGRA~2\MICROS~2\2019\ENTERP~1\VC\Tools\MSVC\1429~1.301\bin\Hostx86\x86\link.exe /nologo CMakeFiles\analyzer_separate.dir\analyzer_separate.cpp.obj /out:analyzer_separate.exe /implib:analyzer_separate.lib /pdb:analyzer_separate.pdb /version:0.0 /machine:X86 /debug /INCREMENTAL /subsystem:console D:\a\dynamorio\dynamorio\build_debug-internal-32\lib32\drdecode.lib D:\a\dynamorio\dynamorio\build_debug-internal-32\ext\lib32\debug\drutil.lib D:\a\dynamorio\dynamorio\build_debug-internal-32\clients\lib32\debug\drmemtrace_analyzer.lib D:\a\dynamorio\dynamorio\build_debug-internal-32\clients\lib32\debug\drmemtrace_histogram.lib D:\a\dynamorio\dynamorio\build_debug-internal-32\lib32\drfrontendlib.lib D:\a\dynamorio\dynamorio\build_debug-internal-32\lib32\drlibc.lib D:\a\dynamorio\dynamorio\build_debug-internal-32\ext\lib32\debug\drmgr.lib D:\a\dynamorio\dynamorio\build_debug-internal-32\ext\lib32\debug\drcontainers.lib D:\a\dynamorio\dynamorio\build_debug-internal-32\lib32\debug\dynamorio.lib D:\a\dynamorio\dynamorio\build_debug-internal-32\clients\lib32\debug\directory_iterator.lib D:\a\dynamorio\dynamorio\build_debug-internal-32\lib32\drfrontendlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\analyzer_separate.dir/intermediate.manifest CMakeFiles\analyzer_separate.dir/manifest.res" failed (exit code 1169) with the following output:
2023-03-16T09:12:36.6620222Z 13: libucrtd.lib(strnlen.obj) : error LNK2005: _wcslen already defined in dynamorio.lib(dynamorio.dll)
2023-03-16T09:12:36.6754743Z 13: libucrtd.lib(strtox.obj) : error LNK2005: _strtol already defined in dynamorio.lib(dynamorio.dll)
2023-03-16T09:12:36.6822657Z 13: libucrtd.lib(strnicmp.obj) : error LNK2005: __strnicmp already defined in dynamorio.lib(dynamorio.dll)
2023-03-16T09:12:36.6825184Z 13:    Creating library analyzer_separate.lib and object analyzer_separate.exp
2023-03-16T09:12:36.6868706Z 13: analyzer_separate.exe : fatal error LNK1169: one or more multiply defined symbols found
2023-03-16T09:12:36.6902550Z 13: ninja: build stopped: subcommand failed.

@derekbruening
Copy link
Contributor

Windows build is failing due to symbols being defined in both libucrtd.lib and dynamorio.dll

I remember various problems like this going away with the right ordering of libraries on the link line: probably there are mentions of ordering in the cmake code like:

  # We hit dup symbol errors on Windows so we need libc earlier before DR:
  _DR_get_static_libc_list(static_libc)

I thought that static libc list included libucrt? And adds the d for debug build?

@prasun3
Copy link
Contributor Author

prasun3 commented Mar 17, 2023

Seeing this error. Works if I point LD_LIBRARY_PATH to the lib64/release dir

./analyzer_separate: error while loading shared libraries: libdynamorio.so: cannot open shared object file: No such file or directory

Any idea how to fix this?

@prasun3
Copy link
Contributor Author

prasun3 commented Mar 17, 2023

x86-32 failure looks like #5908

@derekbruening
Copy link
Contributor

Seeing this error. Works if I point LD_LIBRARY_PATH to the lib64/release dir

./analyzer_separate: error while loading shared libraries: libdynamorio.so: cannot open shared object file: No such file or directory

Any idea how to fix this?

Missing the cmake call which adds the lib path to the ELF file? If legacy traces don't need support drdecode is probably all that's needed and not full libdynamorio in an analyzer.

@prasun3
Copy link
Contributor Author

prasun3 commented Mar 17, 2023

I added these statements so the cmake script is not explicitly adding libdynamorio. Should I explicitly add lib64/release to RPATH?

use_DynamoRIO_extension(analyzer_separate drdecode)
use_DynamoRIO_extension(analyzer_separate drutil)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a standalone example showing how to create new analysis tools
2 participants