VirtualBox

Ignore:
Timestamp:
Mar 31, 2025 11:31:09 AM (2 weeks ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
168237
Message:

Devices/EFI/FirmwareNew: Merge edk2-stable202502 from the vendor branch and make it build for the important platforms, bugref:4643

Location:
trunk/src/VBox/Devices/EFI/FirmwareNew
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/FirmwareNew

  • trunk/src/VBox/Devices/EFI/FirmwareNew/BaseTools/Source/Python/AutoGen/GenC.py

    r105670 r108794  
    2121from .GenPcdDb import CreatePcdDatabaseCode
    2222from .IdfClassObject import *
     23
     24import json
     25import secrets
    2326
    2427## PCD type string
     
    20402043    CreateHeaderCode(Info, AutoGenC, AutoGenH)
    20412044
     2045    # The only 32 bit archs we have are IA32 and ARM, everything else is 64 bit
     2046    Bitwidth = 32 if Info.Arch == 'IA32' or Info.Arch == 'ARM' else 64
     2047
     2048    if GlobalData.gStackCookieValues64 == [] and os.path.exists(os.path.join(Info.PlatformInfo.BuildDir, "StackCookieValues64.json")):
     2049        with open (os.path.join(Info.PlatformInfo.BuildDir, "StackCookieValues64.json"), "r") as file:
     2050            GlobalData.gStackCookieValues64 = json.load(file)
     2051    if GlobalData.gStackCookieValues32 == [] and os.path.exists(os.path.join(Info.PlatformInfo.BuildDir, "StackCookieValues32.json")):
     2052        with open (os.path.join(Info.PlatformInfo.BuildDir, "StackCookieValues32.json"), "r") as file:
     2053            GlobalData.gStackCookieValues32 = json.load(file)
     2054
     2055    try:
     2056        if Bitwidth == 32:
     2057            CookieValue = int(GlobalData.gStackCookieValues32[hash(Info.Guid) % len(GlobalData.gStackCookieValues32)])
     2058        else:
     2059            CookieValue = int(GlobalData.gStackCookieValues64[hash(Info.Guid) % len(GlobalData.gStackCookieValues64)])
     2060    except:
     2061        EdkLogger.warn("build", "Failed to get Stack Cookie Value List! Generating random value.", ExtraData="[%s]" % str(Info))
     2062        if Bitwidth == 32:
     2063            CookieValue = secrets.randbelow (0xFFFFFFFF)
     2064        else:
     2065            CookieValue = secrets.randbelow (0xFFFFFFFFFFFFFFFF)
     2066
     2067    AutoGenH.Append((
     2068        '#define STACK_COOKIE_VALUE 0x%XULL\n' % CookieValue
     2069        if Bitwidth == 64 else
     2070        '#define STACK_COOKIE_VALUE 0x%X\n' % CookieValue
     2071    ))
     2072
    20422073    CreateGuidDefinitionCode(Info, AutoGenC, AutoGenH)
    20432074    CreateProtocolDefinitionCode(Info, AutoGenC, AutoGenH)
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