Skip to content

Commit 7acda55

Browse files
committed
Merge #20939: build: fix RELOC_SECTION security check for bitcoin-util
c061800 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 c061800 laanwj: ACK c061800 Tree-SHA512: a1a4da0b2cddfc377190b9044a04f42a859ca79f11ce2c2ab4c3d066a2786c34d5446d75f8eec634f308d2d3349ebbd7c9f76dcaebeeb28e471c829851592367
2 parents 30e664d + c061800 commit 7acda55

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/bitcoin-util.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,16 @@ static int CommandLineUtil(int argc, char* argv[])
181181
return nRet;
182182
}
183183

184+
#ifdef WIN32
185+
// Export main() and ensure working ASLR on Windows.
186+
// Exporting a symbol will prevent the linker from stripping
187+
// the .reloc section from the binary, which is a requirement
188+
// for ASLR. This is a temporary workaround until a fixed
189+
// version of binutils is used for releases.
190+
__declspec(dllexport) int main(int argc, char* argv[])
191+
#else
184192
int main(int argc, char* argv[])
193+
#endif
185194
{
186195
SetupEnvironment();
187196

0 commit comments

Comments
 (0)