Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: chrome/installer/mini_installer/mini_installer.cc

Issue 2621223003: Fix building ASAN instrumented executables with custom entrypoints (Closed)
Patch Set: nits Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/installer/mini_installer/BUILD.gn ('k') | remoting/host/win/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // mini_installer.exe is the first exe that is run when chrome is being 5 // mini_installer.exe is the first exe that is run when chrome is being
6 // installed or upgraded. It is designed to be extremely small (~5KB with no 6 // installed or upgraded. It is designed to be extremely small (~5KB with no
7 // extra resources linked) and it has two main jobs: 7 // extra resources linked) and it has two main jobs:
8 // 1) unpack the resources (possibly decompressing some) 8 // 1) unpack the resources (possibly decompressing some)
9 // 2) run the real installer (setup.exe) with appropriate flags. 9 // 2) run the real installer (setup.exe) with appropriate flags.
10 // 10 //
11 // In order to be really small the app doesn't link against the CRT and 11 // In order to be really small the app doesn't link against the CRT and
12 // defines the following compiler/linker flags: 12 // defines the following compiler/linker flags:
13 // EnableIntrinsicFunctions="true" compiler: /Oi 13 // EnableIntrinsicFunctions="true" compiler: /Oi
14 // BasicRuntimeChecks="0" 14 // BasicRuntimeChecks="0"
15 // BufferSecurityCheck="false" compiler: /GS- 15 // BufferSecurityCheck="false" compiler: /GS-
16 // EntryPointSymbol="MainEntryPoint" linker: /ENTRY 16 // EntryPointSymbol="MainEntryPoint" linker: /ENTRY
17 // IgnoreAllDefaultLibraries="true" linker: /NODEFAULTLIB 17 // IgnoreAllDefaultLibraries="true" linker: /NODEFAULTLIB
18 // OptimizeForWindows98="1" liker: /OPT:NOWIN98 18 // OptimizeForWindows98="1" linker: /OPT:NOWIN98
19 // linker: /SAFESEH:NO 19 // linker: /SAFESEH:NO
20 20
21 // have the linker merge the sections, saving us ~500 bytes. 21 // have the linker merge the sections, saving us ~500 bytes.
22 #pragma comment(linker, "/MERGE:.rdata=.text") 22 #pragma comment(linker, "/MERGE:.rdata=.text")
23 23
24 #include <windows.h> 24 #include <windows.h>
25 25
26 // #define needed to link in RtlGenRandom(), a.k.a. SystemFunction036. See the 26 // #define needed to link in RtlGenRandom(), a.k.a. SystemFunction036. See the
27 // "Community Additions" comment on MSDN here: 27 // "Community Additions" comment on MSDN here:
28 // http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx 28 // http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 888
889 } // namespace mini_installer 889 } // namespace mini_installer
890 890
891 int MainEntryPoint() { 891 int MainEntryPoint() {
892 mini_installer::ProcessExitResult result = 892 mini_installer::ProcessExitResult result =
893 mini_installer::WMain(::GetModuleHandle(NULL)); 893 mini_installer::WMain(::GetModuleHandle(NULL));
894 894
895 ::ExitProcess(result.exit_code); 895 ::ExitProcess(result.exit_code);
896 } 896 }
897 897
898 #if defined(ADDRESS_SANITIZER)
899 // Executables instrumented with ASAN need CRT functions. We do not use
900 // the /ENTRY switch for ASAN instrumented executable and a "main" function
901 // is required.
902 int WINAPI WinMain(HINSTANCE hInstance,
903 HINSTANCE hPrevInstance,
904 LPSTR lpCmdLine,
905 int nCmdShow) {
906 MainEntryPoint();
907 return 0;
908 }
909 #endif
910
898 // VC Express editions don't come with the memset CRT obj file and linking to 911 // VC Express editions don't come with the memset CRT obj file and linking to
899 // the obj files between versions becomes a bit problematic. Therefore, 912 // the obj files between versions becomes a bit problematic. Therefore,
900 // simply implement memset. 913 // simply implement memset.
901 // 914 //
902 // This also avoids having to explicitly set the __sse2_available hack when 915 // This also avoids having to explicitly set the __sse2_available hack when
903 // linking with both the x64 and x86 obj files which is required when not 916 // linking with both the x64 and x86 obj files which is required when not
904 // linking with the std C lib in certain instances (including Chromium) with 917 // linking with the std C lib in certain instances (including Chromium) with
905 // MSVC. __sse2_available determines whether to use SSE2 intructions with 918 // MSVC. __sse2_available determines whether to use SSE2 intructions with
906 // std C lib routines, and is set by MSVC's std C lib implementation normally. 919 // std C lib routines, and is set by MSVC's std C lib implementation normally.
907 extern "C" { 920 extern "C" {
908 #pragma function(memset) 921 #pragma function(memset)
909 void* memset(void* dest, int c, size_t count) { 922 void* memset(void* dest, int c, size_t count) {
910 void* start = dest; 923 void* start = dest;
911 while (count--) { 924 while (count--) {
912 *reinterpret_cast<char*>(dest) = static_cast<char>(c); 925 *reinterpret_cast<char*>(dest) = static_cast<char>(c);
913 dest = reinterpret_cast<char*>(dest) + 1; 926 dest = reinterpret_cast<char*>(dest) + 1;
914 } 927 }
915 return start; 928 return start;
916 } 929 }
917 } // extern "C" 930 } // extern "C"
OLDNEW
« no previous file with comments | « chrome/installer/mini_installer/BUILD.gn ('k') | remoting/host/win/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698