aboutsummaryrefslogtreecommitdiff
path: root/src/bitcoin-util.cpp
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2021-01-15 11:03:49 +0800
committerfanquake <fanquake@gmail.com>2021-01-15 11:53:14 +0800
commitc061800bb17ce8005ac7b189135dd7e95155e7de (patch)
tree61c7c7cfed656a988479a28a639f98359329c494 /src/bitcoin-util.cpp
parentf91587f050d9dceb45fe10129a76a4a9a060a09c (diff)
downloadbitcoin-c061800bb17ce8005ac7b189135dd7e95155e7de.tar.xz
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
Diffstat (limited to 'src/bitcoin-util.cpp')
-rw-r--r--src/bitcoin-util.cpp9
1 files changed, 9 insertions, 0 deletions
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();