VirtualBox

Changeset 95834 in vbox


Ignore:
Timestamp:
Jul 26, 2022 2:46:59 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
152557
Message:

IPRT/nocrt: Call C & C++ initializers and terminators. TLS directory (not used by VBoxControl). bugref:10261

Location:
trunk/src/VBox/Runtime
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/Makefile.kmk

    r95832 r95834  
    23052305 RuntimeGuestR3_SOURCES.win += \
    23062306        common/compiler/vcc/loadcfg-vcc.c \
     2307        common/compiler/vcc/tlsdir-vcc.c \
     2308        common/compiler/vcc/initializers-c-cpp-vcc.cpp \
    23072309        common/compiler/vcc/stacksup-vcc.cpp \
    23082310        r3/win/nocrt-startup-exe-win.cpp \
  • trunk/src/VBox/Runtime/common/compiler/vcc/loadcfg-vcc.c

    r95832 r95834  
    11/* $Id$ */
    22/** @file
    3  * IPRT - No-CRT - PE/Windows Load Configuration.
     3 * IPRT - Visual C++ Compiler - PE/Windows Load Configuration.
    44 *
    55 * @note This is a C file and not C++ because the compiler generates fixups
     
    3535#include <iprt/formats/pecoff.h>
    3636
     37#include "internal/compiler-vcc.h"
     38
    3739
    3840/*********************************************************************************************************************************
     
    6466#endif
    6567
    66 extern RT_CONCAT(IMAGE_LOAD_CONFIG_DIRECTORY, ARCH_BITS) const  _load_config_used;
    67 
    6868
    6969/**
     
    7777 *       the machinactions we include here for the 2019 (14.29.30139.0) linker.
    7878 */
    79 const IMAGE_LOAD_CONFIG_DIRECTORY64 _load_config_used =
     79RT_CONCAT(IMAGE_LOAD_CONFIG_DIRECTORY, ARCH_BITS) const _load_config_used =
    8080{
    8181    /* .Size                                = */    sizeof(_load_config_used),
  • trunk/src/VBox/Runtime/r3/win/nocrt-startup-exe-win.cpp

    r95818 r95834  
    4545# include <iprt/nocrt/stdlib.h>
    4646#endif
     47
     48#include "internal/compiler-vcc.h"
    4749
    4850
     
    158160            }
    159161        }
     162
     163        rtVccInitializersRunTerm();
    160164    }
    161165#else
     
    203207    initProcExecPath();
    204208
    205     /*
    206      * Get and convert the command line to argc/argv format.
    207      */
    208209    RTEXITCODE rcExit;
    209     UNICODE_STRING const *pCmdLine = pPeb->ProcessParameters ? &pPeb->ProcessParameters->CommandLine : NULL;
    210     if (pCmdLine)
    211     {
    212         char *pszCmdLine = NULL;
    213         int rc = RTUtf16ToUtf8Ex(pCmdLine->Buffer, pCmdLine->Length / sizeof(WCHAR), &pszCmdLine, 0, NULL);
    214         if (RT_SUCCESS(rc))
    215         {
    216             char **papszArgv;
    217             int    cArgs = 0;
    218             rc = RTGetOptArgvFromString(&papszArgv, &cArgs, pszCmdLine,
    219                                         RTGETOPTARGV_CNV_MODIFY_INPUT | RTGETOPTARGV_CNV_QUOTE_MS_CRT,  NULL);
     210#ifdef IPRT_NO_CRT
     211    AssertCompile(sizeof(rcExit) == sizeof(int));
     212    rcExit = (RTEXITCODE)rtVccInitializersRunInit();
     213    if (rcExit == RTEXITCODE_SUCCESS)
     214#endif
     215    {
     216        /*
     217         * Get and convert the command line to argc/argv format.
     218         */
     219        UNICODE_STRING const *pCmdLine = pPeb->ProcessParameters ? &pPeb->ProcessParameters->CommandLine : NULL;
     220        if (pCmdLine)
     221        {
     222            char *pszCmdLine = NULL;
     223            int rc = RTUtf16ToUtf8Ex(pCmdLine->Buffer, pCmdLine->Length / sizeof(WCHAR), &pszCmdLine, 0, NULL);
    220224            if (RT_SUCCESS(rc))
    221225            {
    222                 /*
    223                  * Call the main function.
    224                  */
    225                 AssertCompile(sizeof(rcExit) == sizeof(int));
    226                 rcExit = (RTEXITCODE)main(cArgs, papszArgv, NULL /*envp*/);
     226                char **papszArgv;
     227                int    cArgs = 0;
     228                rc = RTGetOptArgvFromString(&papszArgv, &cArgs, pszCmdLine,
     229                                            RTGETOPTARGV_CNV_MODIFY_INPUT | RTGETOPTARGV_CNV_QUOTE_MS_CRT,  NULL);
     230                if (RT_SUCCESS(rc))
     231                {
     232                    /*
     233                     * Call the main function.
     234                     */
     235                    AssertCompile(sizeof(rcExit) == sizeof(int));
     236                    rcExit = (RTEXITCODE)main(cArgs, papszArgv, NULL /*envp*/);
     237                }
     238                else
     239                    rcExit = RTMsgErrorExitFailure("Error parsing command line: %Rrc\n", rc);
    227240            }
    228241            else
    229                 rcExit = RTMsgErrorExitFailure("Error parsing command line: %Rrc\n", rc);
     242                rcExit = RTMsgErrorExitFailure("Failed to convert command line to UTF-8: %Rrc\n", rc);
    230243        }
    231244        else
    232             rcExit = RTMsgErrorExitFailure("Failed to convert command line to UTF-8: %Rrc\n", rc);
    233     }
     245            rcExit = RTMsgErrorExitFailure("No command line\n");
     246        rtTerminateProcess(rcExit, true /*fDoAtExit*/);
     247    }
     248#ifdef IPRT_NO_CRT
    234249    else
    235         rcExit = RTMsgErrorExitFailure("No command line\n");
    236 
    237     rtTerminateProcess(rcExit, true /*fDoAtExit*/);
    238 }
    239 
     250    {
     251        RTMsgError("A C static initializor failed (%d)\n", rcExit);
     252        rtTerminateProcess(rcExit, false /*fDoAtExit*/);
     253    }
     254#endif
     255}
     256
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette