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

Unsupported relocation kind 0003 for __GSHandlerCheck in libcamlrun.lib(intern.obj) #29

Open
whitequark opened this issue Oct 8, 2016 · 9 comments · May be fixed by #141
Open

Unsupported relocation kind 0003 for __GSHandlerCheck in libcamlrun.lib(intern.obj) #29

whitequark opened this issue Oct 8, 2016 · 9 comments · May be fixed by #141

Comments

@whitequark
Copy link
Member

whitequark commented Oct 8, 2016

I'm getting this when building OCaml 4.03.0 for x64 with bootstrapped flexlink and Visual Studio 2015. The relocation kind is IMAGE_REL_AMD64_ADDR32NB. I have not yet investigated exactly what that means.

@whitequark
Copy link
Member Author

This is a SEH relocation. It appears because the /GS switch uses SEH to indicate the failure of stack cookie validation. The error can be fixed by adding -GS- to BYTECC and NATIVECC in config/Makefile.

I decided to not implement this relocation because it is not clear to me how exactly that works, and given the high effort required for verifying a code path that in all likelihood will never be invoked, I opt to not risk including a broken implementation in flexdll.

@whitequark
Copy link
Member Author

whitequark commented Oct 8, 2016

The workaround does not work if one wishes to link with the libucrt.lib (the static C runtime library from Visual Studio 2015, as explained here), since that is built with /GS also. The workaround is to link the dynamic runtime library ucrt.lib.

@dra27
Copy link
Member

dra27 commented Dec 17, 2016

I've not seen this - is it still the case and is there an easy repro case?

@whitequark
Copy link
Member Author

@dra27 I don't see any reason this would be fixed. As for the repro case--sure, as described in the first comment, building OCaml using VS2015 and the default Makefile.config is enough IIRC.

@dra27
Copy link
Member

dra27 commented Dec 17, 2016

I've been building x64 4.03.0 and 4.04.0 with VS2015 with no problems for ages - including all the work I'm presently doing. Do you see the same thing with trunk?

@whitequark
Copy link
Member Author

OK, I will try again soon.

@bschommer
Copy link
Contributor

bschommer commented Jun 7, 2017

I encountered a similar issue when compiling zarith with the VS2015 and used /z7 for generating debug information.

@jonahbeckford
Copy link
Contributor

Just capturing for myself that I am getting this problem; don't have the time to investigate this properly. Much more time-consuming since this only appears on GitLab CI/CD.

But it does seem clear that we shouldn't be ignoring valid relocations, regardless of how they are triggered.

Problem

I recently switched to ucrt in https://github.com/jonahbeckford/flexdll/commits/0.43%2Bucrt, but haven't compiled the code that triggers this error before. There is a horrid mitigation for this issue which I will neither mention nor confirm.

Errors:

LINK: command "C:/GitLab-Runner/builds/diskuv/distributions/1.0/dksdk-ffi-ocaml/build/DkSDKFiles/cfg-Release/o/bin/flexlink.exe -noentry -o src\Std\DkSDKFFIOCaml_StdShared.dll -U /out:src\Std\DkSDKFFIOCaml_StdShared.dll -implib -L C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\lib\x64 -L C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64 -L C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64 -L C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64 -L C:\GitLab-Runner\builds\diskuv\distributions\1.0\dksdk-ffi-ocaml\build\DkSDKFiles\cfg-Release\o\lib\ocaml _deps\dksdk-ffi-c-build\src\dksdk_ffi_c-StaticExports.lib vcruntime.lib kernel32.lib advapi32.lib ws2_32.lib version.lib advapi32.lib ws2_32.lib version.lib _deps\c-capnproto-build\CapnC_Runtime-StaticExports.lib Rpcrt4.lib -custom-crt ucrt.lib -chain msvc64 -stack 33554432 -L C:\GitLab-Runner\builds\diskuv\distributions\1.0\dksdk-ffi-ocaml\build\DkSDKFiles\cfg-Release\o\lib\ocaml _deps\dksdk-ffi-c-build\src\dksdk_ffi_c-StaticExports.lib vcruntime.lib kernel32.lib advapi32.lib ws2_32.lib version.lib advapi32.lib ws2_32.lib version.lib _deps\c-capnproto-build\CapnC_Runtime-StaticExports.lib Rpcrt4.lib libasmrun.lib src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\stdexport-entry.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\ffi_bytes.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\dksdk_ffi_ocaml_callback.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\dksdk_ffi_ocaml_cls_builder.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\dksdk_ffi_ocaml_generic.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\dksdk_ffi_ocaml_instance.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\dksdk_ffi_ocaml_keyedvalue.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\dksdk_ffi_ocaml_retval.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\ffi_host_segment.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\ffi_uuids.c.obj -- /nologo /pdb:src\Std\DkSDKFFIOCaml_StdShared.pdb /dll /version:0.0 /machine:x64 /INCREMENTAL:NO /MANIFEST /MANIFESTFILE:src\Std\DkSDKFFIOCaml_StdShared.dll.manifest" failed (exit code 2) with the following output:
** Fatal error: Unsupported relocation kind 0003 for __GSHandlerCheck in _deps\dksdk-ffi-c-build\src\dksdk_ffi_c-StaticExports.lib(_deps\dksdk-ffi-c-build\src\CMakeFiles\dksdk_ffi_c-StaticExports.dir\sha256.c.obj)

and

Visual Studio Non-Incremental Link
LINK:
C:/GitLab-Runner/builds/diskuv/distributions/1.0/dksdk-ffi-ocaml/build/DkSDKFiles/cfg-Release/o/bin/flexlink.exe -noentry -o src\Std\DkSDKFFIOCaml_StdShared.dll -U /out:src\Std\DkSDKFFIOCaml_StdShared.dll -implib -L C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\lib\x64 -L C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64 -L C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64 -L C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64 -L C:\GitLab-Runner\builds\diskuv\distributions\1.0\dksdk-ffi-ocaml\build\DkSDKFiles\cfg-Release\o\lib\ocaml _deps\dksdk-ffi-c-build\src\dksdk_ffi_c-StaticExports.lib vcruntime.lib kernel32.lib advapi32.lib ws2_32.lib version.lib advapi32.lib ws2_32.lib version.lib _deps\c-capnproto-build\CapnC_Runtime-StaticExports.lib Rpcrt4.lib -custom-crt ucrt.lib -chain msvc64 -stack 33554432 -L C:\GitLab-Runner\builds\diskuv\distributions\1.0\dksdk-ffi-ocaml\build\DkSDKFiles\cfg-Release\o\lib\ocaml _deps\dksdk-ffi-c-build\src\dksdk_ffi_c-StaticExports.lib vcruntime.lib kernel32.lib advapi32.lib ws2_32.lib version.lib advapi32.lib ws2_32.lib version.lib _deps\c-capnproto-build\CapnC_Runtime-StaticExports.lib Rpcrt4.lib libasmrun.lib src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\stdexport-entry.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\ffi_bytes.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\dksdk_ffi_ocaml_callback.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\dksdk_ffi_ocaml_cls_builder.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\dksdk_ffi_ocaml_generic.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\dksdk_ffi_ocaml_instance.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\dksdk_ffi_ocaml_keyedvalue.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\dksdk_ffi_ocaml_retval.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\ffi_host_segment.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\ffi_uuids.c.obj -- /nologo /pdb:src\Std\DkSDKFFIOCaml_StdShared.pdb /dll /version:0.0 /machine:x64 /INCREMENTAL:NO /MANIFEST /MANIFESTFILE:src\Std\DkSDKFFIOCaml_StdShared.dll.manifest
LINK: command "C:/GitLab-Runner/builds/diskuv/distributions/1.0/dksdk-ffi-ocaml/build/DkSDKFiles/cfg-Release/o/bin/flexlink.exe -noentry -o src\Std\DkSDKFFIOCaml_StdShared.dll -U /out:src\Std\DkSDKFFIOCaml_StdShared.dll -implib -L C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\lib\x64 -L C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64 -L C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64 -L C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64 -L C:\GitLab-Runner\builds\diskuv\distributions\1.0\dksdk-ffi-ocaml\build\DkSDKFiles\cfg-Release\o\lib\ocaml _deps\dksdk-ffi-c-build\src\dksdk_ffi_c-StaticExports.lib vcruntime.lib kernel32.lib advapi32.lib ws2_32.lib version.lib advapi32.lib ws2_32.lib version.lib _deps\c-capnproto-build\CapnC_Runtime-StaticExports.lib Rpcrt4.lib -custom-crt ucrt.lib -chain msvc64 -stack 33554432 -L C:\GitLab-Runner\builds\diskuv\distributions\1.0\dksdk-ffi-ocaml\build\DkSDKFiles\cfg-Release\o\lib\ocaml _deps\dksdk-ffi-c-build\src\dksdk_ffi_c-StaticExports.lib vcruntime.lib kernel32.lib advapi32.lib ws2_32.lib version.lib advapi32.lib ws2_32.lib version.lib _deps\c-capnproto-build\CapnC_Runtime-StaticExports.lib Rpcrt4.lib libasmrun.lib src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\stdexport-entry.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\ffi_bytes.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\dksdk_ffi_ocaml_callback.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\dksdk_ffi_ocaml_cls_builder.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\dksdk_ffi_ocaml_generic.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\dksdk_ffi_ocaml_instance.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\dksdk_ffi_ocaml_keyedvalue.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\dksdk_ffi_ocaml_retval.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\ffi_host_segment.c.obj src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\ffi_uuids.c.obj -- /nologo /pdb:src\Std\DkSDKFFIOCaml_StdShared.pdb /dll /version:0.0 /machine:x64 /INCREMENTAL:NO /MANIFEST /MANIFESTFILE:src\Std\DkSDKFFIOCaml_StdShared.dll.manifest" failed (exit code 2) with the following output:
** Fatal error: Unsupported relocation kind 0003 for __GSHandlerCheck in src\Std\CMakeFiles\DkSDKFFIOCaml_StdShared.dir\core\ffi_uuids.c.obj                

@jonahbeckford
Copy link
Contributor

PR #141 has the fix.

mefyl pushed a commit to mefyl/timmy that referenced this issue Aug 1, 2024
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.

4 participants