diff options
author | Wladimir J. van der Laan <laanwj@protonmail.com> | 2021-01-17 18:11:33 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@protonmail.com> | 2021-01-17 18:12:08 +0100 |
commit | 7acda55c4fa611481979a41dfd5ca016bb535409 (patch) | |
tree | f442a12728da70e5c5817d0ba10a36a3107c7d9f | |
parent | 30e664dcce1a9adb9ba9a29e4f0cf809767870dd (diff) | |
parent | c061800bb17ce8005ac7b189135dd7e95155e7de (diff) |
Merge #20939: build: fix RELOC_SECTION security check for bitcoin-util
c061800bb17ce8005ac7b189135dd7e95155e7de build: fix RELOC_SECTION security check for bitcoin-util (fanquake)
Pull request description:
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
ACKs for top commit:
dongcarl:
ACK c061800bb17ce8005ac7b189135dd7e95155e7de
laanwj:
ACK c061800bb17ce8005ac7b189135dd7e95155e7de
Tree-SHA512: a1a4da0b2cddfc377190b9044a04f42a859ca79f11ce2c2ab4c3d066a2786c34d5446d75f8eec634f308d2d3349ebbd7c9f76dcaebeeb28e471c829851592367
-rw-r--r-- | src/bitcoin-util.cpp | 9 |
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(); |