mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 14:08:40 +01:00
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
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <chainparamsbase.h>
|
||||
#include <clientversion.h>
|
||||
#include <compat.h>
|
||||
#include <compat/stdin.h>
|
||||
#include <policy/feerate.h>
|
||||
#include <rpc/client.h>
|
||||
@@ -1212,19 +1213,11 @@ static int CommandLineRPC(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[])
|
||||
MAIN_FUNCTION
|
||||
{
|
||||
#ifdef WIN32
|
||||
util::WinCmdLineArgs winArgs;
|
||||
std::tie(argc, argv) = winArgs.get();
|
||||
#else
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#endif
|
||||
SetupEnvironment();
|
||||
if (!SetupNetworking()) {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <clientversion.h>
|
||||
#include <coins.h>
|
||||
#include <compat.h>
|
||||
#include <consensus/amount.h>
|
||||
#include <consensus/consensus.h>
|
||||
#include <core_io.h>
|
||||
@@ -854,7 +855,7 @@ static int CommandLineRawTx(int argc, char* argv[])
|
||||
return nRet;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
MAIN_FUNCTION
|
||||
{
|
||||
SetupEnvironment();
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <chainparams.h>
|
||||
#include <chainparamsbase.h>
|
||||
#include <clientversion.h>
|
||||
#include <compat.h>
|
||||
#include <core_io.h>
|
||||
#include <streams.h>
|
||||
#include <util/system.h>
|
||||
@@ -142,16 +143,7 @@ static int Grind(const std::vector<std::string>& args, std::string& strPrint)
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#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
|
||||
MAIN_FUNCTION
|
||||
{
|
||||
ArgsManager& args = gArgs;
|
||||
SetupEnvironment();
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <chainparams.h>
|
||||
#include <chainparamsbase.h>
|
||||
#include <clientversion.h>
|
||||
#include <compat.h>
|
||||
#include <interfaces/init.h>
|
||||
#include <key.h>
|
||||
#include <logging.h>
|
||||
@@ -88,7 +89,7 @@ static bool WalletAppInit(ArgsManager& args, int argc, char* argv[])
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
MAIN_FUNCTION
|
||||
{
|
||||
ArgsManager& args = gArgs;
|
||||
#ifdef WIN32
|
||||
|
||||
@@ -256,7 +256,7 @@ static bool AppInit(NodeContext& node, int argc, char* argv[])
|
||||
return fRet;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
MAIN_FUNCTION
|
||||
{
|
||||
#ifdef WIN32
|
||||
util::WinCmdLineArgs winArgs;
|
||||
|
||||
11
src/compat.h
11
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
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <qt/bitcoin.h>
|
||||
|
||||
#include <compat.h>
|
||||
#include <util/translation.h>
|
||||
#include <util/url.h>
|
||||
|
||||
@@ -18,4 +19,7 @@ extern const std::function<std::string(const char*)> G_TRANSLATION_FUN = [](cons
|
||||
};
|
||||
UrlDecodeFn* const URL_DECODE = urlDecode;
|
||||
|
||||
int main(int argc, char* argv[]) { return GuiMain(argc, argv); }
|
||||
MAIN_FUNCTION
|
||||
{
|
||||
return GuiMain(argc, argv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user