From c061800bb17ce8005ac7b189135dd7e95155e7de Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 15 Jan 2021 11:03:49 +0800 Subject: build: fix RELOC_SECTION security check for bitcoin-util The binutils we use for gitian builds strips the reloc section from Windows binaries, which breaks ASLR. As a temporary workaround, export main(). This is the same workaround as #18702 (bitcoin-cli), and will fix the currently failing security check: ```bash + make -j1 -C src check-security make: Entering directory '/home/ubuntu/build/bitcoin/distsrc-x86_64-w64-mingw32/src' Checking binary security... bitcoin-util.exe: failed RELOC_SECTION make: *** [check-security] Error 1 ``` Relevant upstream issue: https://sourceware.org/bugzilla/show_bug.cgi?id=19011 --- src/bitcoin-util.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/bitcoin-util.cpp b/src/bitcoin-util.cpp index b702a68bdf..30b8098716 100644 --- a/src/bitcoin-util.cpp +++ b/src/bitcoin-util.cpp @@ -181,7 +181,16 @@ static int CommandLineUtil(int argc, char* argv[]) return nRet; } +#ifdef WIN32 +// Export main() and ensure working ASLR on Windows. +// Exporting a symbol will prevent the linker from stripping +// the .reloc section from the binary, which is a requirement +// for ASLR. This is a temporary workaround until a fixed +// version of binutils is used for releases. +__declspec(dllexport) int main(int argc, char* argv[]) +#else int main(int argc, char* argv[]) +#endif { SetupEnvironment(); -- cgit v1.2.3