VirtualBox

Changeset 96589 in vbox


Ignore:
Timestamp:
Sep 3, 2022 2:54:22 AM (2 years ago)
Author:
vboxsync
Message:

IPRT/nocrt: Split the as much read-only data out of the .rdata segment and put it in a .rodata section when there's a posibility that we're targeting NT 3.x, as these older NT versions cannot deal with a read-only import table. The linker insists on putting the import table in the .rdata section. There are a couple of other structures it generates/manages that goes there too that and seems impossible to move out of it. bugref:10261

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Config.kmk

    r96585 r96589  
    63316331 endif
    63326332 ifdef VBOX_WITH_NOCRT_STATIC
    6333   TEMPLATE_VBOXR3STATIC_CFLAGS          = $(filter-out -MD$(VBOX_VCC_CRT_TYPE) -EHsc -GR, $(TEMPLATE_VBOXR3EXE_CFLAGS))   -Zl -EHc-s- -Gy -GR-
    6334   TEMPLATE_VBOXR3STATIC_CXXFLAGS        = $(filter-out -MD$(VBOX_VCC_CRT_TYPE) -EHsc -GR, $(TEMPLATE_VBOXR3EXE_CXXFLAGS)) -Zl -EHc-s- -Gy -GR-
    6335   TEMPLATE_VBOXR3STATIC_PCHFLAGS        = $(filter-out -MD$(VBOX_VCC_CRT_TYPE) -EHsc -GR, $(TEMPLATE_VBOXR3EXE_PCHFLAGS)) -Zl -EHc-s- -Gy -GR-
     6333  TEMPLATE_VBOXR3STATIC_CFLAGS          = $(filter-out -MD$(VBOX_VCC_CRT_TYPE) -EHsc -GR, $(TEMPLATE_VBOXR3EXE_CFLAGS)) \
     6334        -Zl -EHc-s- -Gy -GR-
     6335  TEMPLATE_VBOXR3STATIC_CXXFLAGS        = $(filter-out -MD$(VBOX_VCC_CRT_TYPE) -EHsc -GR, $(TEMPLATE_VBOXR3EXE_CXXFLAGS)) \
     6336        -Zl -EHc-s- -Gy -GR-
     6337  TEMPLATE_VBOXR3STATIC_PCHFLAGS        = $(filter-out -MD$(VBOX_VCC_CRT_TYPE) -EHsc -GR, $(TEMPLATE_VBOXR3EXE_PCHFLAGS)) \
     6338        -Zl -EHc-s- -Gy -GR-
    63366339 else
    6337   TEMPLATE_VBOXR3STATIC_CFLAGS          = $(filter-out -MD$(VBOX_VCC_CRT_TYPE), $(TEMPLATE_VBOXR3EXE_CFLAGS))   -MT$(VBOX_VCC_CRT_TYPE) -Gy
    6338   TEMPLATE_VBOXR3STATIC_CXXFLAGS        = $(filter-out -MD$(VBOX_VCC_CRT_TYPE), $(TEMPLATE_VBOXR3EXE_CXXFLAGS)) -MT$(VBOX_VCC_CRT_TYPE) -Gy
    6339   TEMPLATE_VBOXR3STATIC_PCHFLAGS        = $(filter-out -MD$(VBOX_VCC_CRT_TYPE), $(TEMPLATE_VBOXR3EXE_PCHFLAGS)) -MT$(VBOX_VCC_CRT_TYPE) -Gy
    6340  endif
     6340  TEMPLATE_VBOXR3STATIC_CFLAGS          = $(filter-out -MD$(VBOX_VCC_CRT_TYPE), $(TEMPLATE_VBOXR3EXE_CFLAGS)) \
     6341        -MT$(VBOX_VCC_CRT_TYPE) -Gy
     6342  TEMPLATE_VBOXR3STATIC_CXXFLAGS        = $(filter-out -MD$(VBOX_VCC_CRT_TYPE), $(TEMPLATE_VBOXR3EXE_CXXFLAGS)) \
     6343        -MT$(VBOX_VCC_CRT_TYPE) -Gy
     6344  TEMPLATE_VBOXR3STATIC_PCHFLAGS        = $(filter-out -MD$(VBOX_VCC_CRT_TYPE), $(TEMPLATE_VBOXR3EXE_PCHFLAGS)) \
     6345        -MT$(VBOX_VCC_CRT_TYPE) -Gy
     6346 endif
     6347
    63416348 if "$(VBOX_VCC_TOOL_STEM)" >= "VCC120" # Do not use SSE so valkit stuff can run on NT4 w/o needing a separate runtime library.
    6342   TEMPLATE_VBOXR3STATIC_CFLAGS.win.x86     = $(TEMPLATE_VBOXR3EXE_CFLAGS.win.86) /arch:IA32
    6343   TEMPLATE_VBOXR3STATIC_CXXFLAGS.win.x86   = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.win.86) /arch:IA32
    6344   TEMPLATE_VBOXR3STATIC_PCHFLAGS.win.x86   = $(TEMPLATE_VBOXR3EXE_PCHFLAGS.win.86) /arch:IA32
     6349  TEMPLATE_VBOXR3STATIC_CFLAGS.win.x86     = $(TEMPLATE_VBOXR3EXE_CFLAGS.win.86) \
     6350        /arch:IA32 -FI$(PATH_ROOT)/include/iprt/vcc-use-rodata.h # The -FI is explained down in VBOXGUESTR3EXE.
     6351  TEMPLATE_VBOXR3STATIC_CXXFLAGS.win.x86   = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.win.86) \
     6352        /arch:IA32 -FI$(PATH_ROOT)/include/iprt/vcc-use-rodata.h
     6353  TEMPLATE_VBOXR3STATIC_PCHFLAGS.win.x86   = $(TEMPLATE_VBOXR3EXE_PCHFLAGS.win.86) \
     6354        /arch:IA32 -FI$(PATH_ROOT)/include/iprt/vcc-use-rodata.h
    63456355  TEMPLATE_VBOXR3STATIC_CFLAGS            += -Gw
    63466356  TEMPLATE_VBOXR3STATIC_CXXFLAGS          += -Gw
     
    83938403  TEMPLATE_VBOXGUESTR3EXE_SDKS     = ReorderCompilerIncs $(VBOX_WINPSDK_GST) VBOX_NTDLL
    83948404 endif
    8395  # Hack for running on NT3x, NT4, W2K and XP w/o SP: Change OS and subsystem version in the image.
    8396  # The .bss section trick is for NT 3.1 which doesn't support merging initialized and uninitialized
    8397  # section because it doesn't recognize Misc.VirtualSize.  VBOX_PE_SET_VERSION will unset the !K flag.
     8405 # Hack for running on NT3x, NT4, W2K and XP w/o SP:
     8406 #  1. Change OS and subsystem version in the image.
     8407 #  2. NT 3.1 requires the IAT to be writable, so we end up marking .rdata as writable.
     8408 #  3. A follow up to (2) is to split as much out of .rdata as we can by compiling the
     8409 #     code with a different .rdata section name. This is done in VBOXR3STATIC because
     8410 #     of the validation kit. (Currently VBOX_WITH_NOCRT_STATIC only, for no particular
     8411 #     reason.)
     8412 #  4. NT 3.1 doesn't support merging initialized and uninitialized section because it
     8413 #     doesn't recognize Misc.VirtualSize.  So, we set the uncached flag (!K) on the
     8414 #     .bss section make it incompatible with .data.  VBOX_PE_SET_VERSION will clear the !K flag.
    83988415 # HACK ALERT! Double expansion of $$(NLTAB).
    83998416 TEMPLATE_VBOXGUESTR3EXE_POST_CMDS.win.x86  = $(if $(eq $(tool_do),LINK_LIBRARY),,$(VBOX_PE_SET_VERSION) $(out)$$(NLTAB)$(TEMPLATE_$(TEMPLATE_VBOXGUESTR3EXE_EXTENDS)_POST_CMDS))
    84008417 TEMPLATE_VBOXGUESTR3EXE_LNK_DEPS.win.x86   = $(if $(eq $(tool_do),LINK_LIBRARY),,$(VBOX_PE_SET_VERSION))
    8401  TEMPLATE_VBOXGUESTR3EXE_LDFLAGS.win.x86    = -Section:.bss,RW!K $(TEMPLATE_$(TEMPLATE_VBOXGUESTR3EXE_EXTENDS)_LDFLAGS.win.x86)
     8418 ifndef VBOX_WITH_NOCRT_STATIC
     8419  TEMPLATE_VBOXGUESTR3EXE_LDFLAGS.win.x86    = -Section:.bss,RW!K $(TEMPLATE_$(TEMPLATE_VBOXGUESTR3EXE_EXTENDS)_LDFLAGS.win.x86)
     8420 endif
    84028421
    84038422 if defined(VBOX_WITH_MORE_NT4_COMPAT_BINARIES) && "$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)" == "win.x86"
     
    85538572TEMPLATE_VBoxGuestR3DllMinW2K_EXTENDS  = VBoxGuestR3Dll
    85548573ifeq ($(KBUILD_TARGET),win)
    8555  TEMPLATE_VBoxGuestR3DllMinW2K_LDFLAGS.win.x86 = $(filter-out -Section:.bss$(COMMA)RW!K,$(TEMPLATE_VBoxGuestR3Dll_LDFLAGS.win.x86))
     8574 ifndef VBOX_WITH_NOCRT_STATIC # Not present here
     8575  TEMPLATE_VBoxGuestR3DllMinW2K_LDFLAGS.win.x86 = $(filter-out -Section:.bss$(COMMA)RW!K,$(TEMPLATE_VBoxGuestR3Dll_LDFLAGS.win.x86))
     8576 endif
    85568577 TEMPLATE_VBoxGuestR3DllMinW2K_POST_CMDS.win.x86 = $(subst $(VBOX_PE_SET_VERSION), $(VBOX_PE_SET_VERSION) --w2k,$(TEMPLATE_VBoxGuestR3Dll_POST_CMDS.win.x86))
    85578578 TEMPLATE_VBoxGuestR3DllMinW2K_POST_CMDS.win.amd64 = $(if $(eq $(tool_do),LINK_LIBRARY),,$(VBOX_PE_SET_VERSION) --w2k3 $(out)$$(NLTAB)$(TEMPLATE_VBoxGuestR3Dll_POST_CMDS.win.amd64))
     
    85658586TEMPLATE_VBoxGuestR3DllMinVista_EXTENDS  = VBoxGuestR3Dll
    85668587ifeq ($(KBUILD_TARGET),win)
    8567  TEMPLATE_VBoxGuestR3DllMinVista_LDFLAGS.win.x86 = $(filter-out -Section:.bss$(COMMA)RW!K,$(TEMPLATE_VBoxGuestR3Dll_LDFLAGS.win.x86))
     8588 ifndef VBOX_WITH_NOCRT_STATIC # Not present here
     8589  TEMPLATE_VBoxGuestR3DllMinVista_LDFLAGS.win.x86 = $(filter-out -Section:.bss$(COMMA)RW!K,$(TEMPLATE_VBoxGuestR3Dll_LDFLAGS.win.x86))
     8590 endif
    85688591 TEMPLATE_VBoxGuestR3DllMinVista_POST_CMDS.win.x86 = $(subst $(VBOX_PE_SET_VERSION), $(VBOX_PE_SET_VERSION) --vista,$(TEMPLATE_VBoxGuestR3Dll_POST_CMDS.win.x86))
    85698592 TEMPLATE_VBoxGuestR3DllMinVista_POST_CMDS.win.amd64 = $(if $(eq $(tool_do),LINK_LIBRARY),,$(VBOX_PE_SET_VERSION) --vista $(out)$$(NLTAB)$(TEMPLATE_VBoxGuestR3Dll_POST_CMDS.win.amd64))
     
    86098632TEMPLATE_NewerVccVBoxGuestR3DllMinVista_EXTENDS  = NewerVccVBoxGuestR3Dll
    86108633ifeq ($(KBUILD_TARGET),win)
    8611  TEMPLATE_NewerVccVBoxGuestR3DllMinVista_LDFLAGS.win.x86 = $(filter-out -Section:.bss$(COMMA)RW!K,$(TEMPLATE_NewerVccVBoxGuestR3Dll_LDFLAGS.win.x86))
     8634 ifndef VBOX_WITH_NOCRT_STATIC # Not present here
     8635  TEMPLATE_NewerVccVBoxGuestR3DllMinVista_LDFLAGS.win.x86 = $(filter-out -Section:.bss$(COMMA)RW!K,$(TEMPLATE_NewerVccVBoxGuestR3Dll_LDFLAGS.win.x86))
     8636 endif
    86128637 TEMPLATE_NewerVccVBoxGuestR3DllMinVista_POST_CMDS.win.x86 = $(subst $(VBOX_PE_SET_VERSION), $(VBOX_PE_SET_VERSION) --vista,$(TEMPLATE_NewerVccVBoxGuestR3Dll_POST_CMDS.win.x86))
    86138638 TEMPLATE_NewerVccVBoxGuestR3DllMinVista_POST_CMDS.win.amd64 = $(if $(eq $(tool_do),LINK_LIBRARY),,$(VBOX_PE_SET_VERSION) --vista $(out)$$(NLTAB)$(TEMPLATE_NewerVccVBoxGuestR3Dll_POST_CMDS.win.amd64))
  • trunk/src/VBox/Runtime/common/compiler/vcc/initializers-c-cpp-vcc.cpp

    r96407 r96589  
    8181
    8282/* Tell the linker to merge the .CRT* sections into .rdata */
    83 #pragma comment(linker, "/merge:.CRT=.rdata ")
     83#ifdef IPRT_VCC_USING_RODATA_AS_CONST_SEG
     84# pragma comment(linker, "/merge:.CRT=.rodata ")
     85#else
     86# pragma comment(linker, "/merge:.CRT=.rdata ")
     87#endif
    8488/** @} */
    8589
  • trunk/src/VBox/Runtime/common/compiler/vcc/tlsdir-vcc.c

    r96407 r96589  
    6565
    6666/* Tell the linker to merge the .CRT* sections into .rdata */
    67 #pragma comment(linker, "/merge:.CRT=.rdata ")
     67#ifdef IPRT_VCC_USING_RODATA_AS_CONST_SEG
     68# pragma comment(linker, "/merge:.CRT=.rodata ")
     69#else
     70# pragma comment(linker, "/merge:.CRT=.rdata ")
     71#endif
    6872/** @} */
    6973
Note: See TracChangeset for help on using the changeset viewer.

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