diff options
author | fanquake <fanquake@gmail.com> | 2022-05-30 15:59:43 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2022-06-11 14:55:13 +0100 |
commit | fbae8c59a2c3f102828a91ee0dbd6017daa1f4fb (patch) | |
tree | d5dbd8b08555fda9830101b55fbfa70571bb13c9 /src/compat.h | |
parent | b71d37da2c8c8d2a9cef020731767a6929db54b4 (diff) |
compat: Consolidate mingw-w64 ASLR workaround for upstream libsecp changes
Achieve this by adding a MAIN_FUNCTION macro, consolidating the docs, and
introducing the macro across our distributed binaries.
Also update the docs to explain that anyone using binutils < 2.36 is
effected by this issue. Release builds are not, because they use binutils
2.37. Currently LTS Linux distros, like Ubuntu Focal, ship with 2.34.
https://packages.ubuntu.com/focal/binutils
Diffstat (limited to 'src/compat.h')
-rw-r--r-- | src/compat.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/compat.h b/src/compat.h index 3ec4ab53fd..f41c501c84 100644 --- a/src/compat.h +++ b/src/compat.h @@ -86,6 +86,17 @@ typedef void* sockopt_arg_type; typedef char* sockopt_arg_type; #endif +#ifdef WIN32 +// Export main() and ensure working ASLR when using mingw-w64. +// Exporting a symbol will prevent the linker from stripping +// the .reloc section from the binary, which is a requirement +// for ASLR. While release builds are not affected, anyone +// building with a binutils < 2.36 is subject to this ld bug. +#define MAIN_FUNCTION __declspec(dllexport) int main(int argc, char* argv[]) +#else +#define MAIN_FUNCTION int main(int argc, char* argv[]) +#endif + // Note these both should work with the current usage of poll, but best to be safe // WIN32 poll is broken https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/ // __APPLE__ poll is broke https://github.com/bitcoin/bitcoin/pull/14336#issuecomment-437384408 |