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

Cannot relocate on OCaml 4.13.1 [Windows] #100

Open
EmmaJaneBonestell opened this issue Feb 28, 2022 · 1 comment · May be fixed by #52
Open

Cannot relocate on OCaml 4.13.1 [Windows] #100

EmmaJaneBonestell opened this issue Feb 28, 2022 · 1 comment · May be fixed by #52

Comments

@EmmaJaneBonestell
Copy link

I'm working on porting the Binary Analysis Platform / BAP to Windows.

Unless I am misunderstanding, the mingw64 chain , >=OCaml 4.12.1, and >=Binutils 2.36 should no longer be experiencing runtime plugin/dll relocation failures with RELOC_REL32.

Using MSYS2's UCRT shell/toolchain (I have this same issue in Cygwin, too.), MinGW GCC 11.2, OCaml 4.13.1 + flambda, and the latest git source of flexdll.

However, the LLVM-backend plugin for BAP is erroring out here. If I get flexlink to pass --default-image-base-low when linking the main executable and the breaking plugin, it's fine. Decorating the symbol as a dllimport, in the plugin code, didn't appear to make a difference.

No other plugins seem to have this issue, even when they are left with a high base address & the executable is low.

Failed to load plugin "bap-plugin-llvm": Failed to load bap_llvm: error loading shared library: Dynlink.Error (Dynlink.Cannot_open_dll "(Failure\n \"flexdll error: cannot relocate _ZN3bap21register_disassemblerENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10shared_ptrINS_14disasm_factoryEE RELOC_REL32, target is too far: FFFFFFFCCE4E7D5B FFFFFFFFCE4E7D5B\")")

bap::register_disassembler(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::shared_ptr<bap::disasm_factory>)

These are the instantiation of the register_disassembler function in the main executable:
https://github.com/BinaryAnalysisPlatform/bap/blob/master/lib/bap_disasm/disasm.hpp
https://github.com/BinaryAnalysisPlatform/bap/blob/master/lib/bap_disasm/disasm.cpp

And this is the plugin's usage of it:
https://github.com/BinaryAnalysisPlatform/bap/blob/master/lib/bap_llvm/llvm_disasm.cpp

I'll be honest and say that I'm only guessing that this problem lies with FlexDLL, but it could be in OCaml itself, BAP's source code, MinGW, etc.

If needed, I can provide a way to reproduce this; however, it's unfortunately not a quick process, and will require manual steps in the build process. At that, I could also provide the virtual machine image or the msys64 folder.

@dra27
Copy link
Member

dra27 commented Sep 29, 2022

Sorry for ignoring this one too! The problem is definitely reported by flexdll - I presume that was with declspec(dllimport) in the .hpp, rather than the .cpp file? Do any of the other plugins have to call that precise function?

@dra27 dra27 linked a pull request Dec 29, 2024 that will close this issue
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 a pull request may close this issue.

2 participants