upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/pe_loader.cpp
diff options
context:
space:
mode:
authorJan Trencansky <jan.trencansky@protonmail.com>2026-11-24 19:38:04 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-24 19:38:04 -0500
commit39879ce0fdcaea23ce3919c1e845dd360b17b0f8 (patch)
tree894ddf50be120cdfbd80b28e895876c518cc2199 /runtime/src/pe_loader.cpp
parent273b3bdf9d6e736442ad584ad464df6e86ee928b (diff)
parent1154976d49acca28ad436b90861e9f9aea28eba9 (diff)
Merge main into RT-PROTON-STORY-LOAD (#984)
Merges main at 1154976d4 into the integration branch at 273b3bdf9 (merge base ece4ba5b3). 42 files conflicted; this commit is the resolution only. Build and test repairs follow in their own commits. Rule of resolution: where both sides added different things, both stay; where both made the same change in two forms, main's reviewed form stays and whatever #984's form did in addition is carried into it; where the two changed the same code for different purposes, both purposes are kept. Xbox proxy code (runtime/shims/d3d12_xs_device.cpp, d3d12_xs_device.h, d3d12_xs.cpp, d3d12_xs_alloc_size.h, d3d12_xs_desc_clean.h, registry.cpp): - d3d12_xs_device.cpp is #984's file with main's differing pieces ported in: env_slot and the configurable device routes, XboxQueueSlotRoutes, PresentationHandler / set_presentation_handler, the console caller rule for device slots 61 and 74 (#383, #385), route_xbox_device_slot, slot 81 as GetFrameStatisticsX, create_host_device, the console-form rule for slots 25 and 56, the console list IID of #359, and the forms of queue slot 18 (#403) and list slot 139 (#396). - Kept from #984: the list proxy with handle translation, queue slots 16/17 as Signal/Wait, the fence's completed-value mirror, the shared FrameTokenSource, PresentX through queue_present_x when no handler is attached (slot 30, or 32 on a queue detected as the newer layout), slots 27/53/55/57/70/71/133, the wider pc_resource_desc, S_OK for queue slots past the PC table. - Dropped: #984's GetFrameEventsX and LEONIDA_XS_FRAME_EVENTS_SLOT, its second-word rule for slot 61, its undetected-layout rule for queue slot 18, its list IID mapping to GraphicsCommandList6; main's copy of the base list proxy, its null-view slot 70 and its refusing slot 133. Proxy tests (runtime/test/xs_proxy_mock_test.cpp, device_proxy_test.cpp, queue_proxy_test.cpp): - Checks of both sides, each run once; main's forms of the render-target size and layout checks with #984's extra cases added; main's --env-slots-74 and #984's --env-slots-70. - Adapted to the merged code: the queue tail answers S_OK, slot 73 answers an unknown IID with the list proxy, the queue slot 18 case installs a console caller. Dropped: #984's slot 81 GetFrameEventsX cases. D3D12/Vulkan layer (runtime/shims/d3d12_com.cpp, d3d12_vulkan_device.cpp, runtime/src/command_list.h, frame_pacer.h, shader_library.h, vulkan_backend.h, vulkan_replay.h, runtime/test/command_list_test.cpp, d3d12_close_parity_test.cpp, d3d12_execute_indirect_validation_test.cpp, replay_texture_barrier_test.cpp, vk_pipeline_check.cpp, vk_test_device.h): - Resource::create_texture: #984's title images (deferred placed, pending streamed, title pool) and main's ordinary textures (#1413 shared blocks, #1364 staging fallback) are exclusive branches chosen by the texture's origin, so both pools run on disjoint sets of textures. - frame_pacer.h is main's pacer (#402) with #984's FrameTokenSource as the token counter. - main's forms kept for ExecuteIndirect (#1066, #377), the barrier into LAYOUT_UNDEFINED (#1055), the B4G4R4A4 stand-in, per-face stencil masks, the unaligned tile staging (#528) and the device-lost flag (#980). - shader_library.h: main's block inflate; #984's `bulk` parameter now defaults to true so main's callers keep it. - Dropped: #984's B8G8R8A8 stand-in for B4G4R4A4 targets, its refusal of separate stencil masks, its zero-count refusal in ExecuteIndirect, its wider UNDEFINED -> UNDEFINED release and the test case for it. Other shims (runtime/shims/dstorage.cpp, file_system.cpp, gameinput.cpp, xgameruntime_offline.cpp, runtime/test/xgameruntime_offline_test.cpp, xmem_test.cpp): - ReadFile and DirectStorage reads: #984's pinned kernel_writes read, then main's touch_pages retry on ERROR_NOACCESS. main's rt::fs::read_file is folded into #984's read_file. - gameinput: main's strict LEONIDA_INPUT_SCRIPT parser with #984's rsup/rsdown entries. - Speech synthesis: main's one silent voice and handle checks; #984's accept-anything form dropped. Build, tools, docs (runtime/CMakeLists.txt, runtime/cmake/translator_deps.cmake, scripts/build_runtime.ps1, make_game.py, tools/rdna2spirv.py, shader_disasm.py, shader_ir.py, shader_library.py, runtime/test/shaders/cs_imgload_tfe.asm, cs_imgload_d16_tfe.asm, docs/README.md, boot.md, d3d12_vulkan.md, runtime/README.md): - Unions of the test, target and source lists; spirv_loop_guard.py added to translator_deps.cmake. - rdna2spirv.py: main's DPP compare rule (#957), SMEM vcc base (#647) and widen_wave64_masks (#1021); #984's restore_skipped_instructions and restore_dot4_inline_sel. #984's duplicate widen_wave64_valu_masks dropped. - shader_disasm.py and shader_ir.py: main's structure with #984's one-line-per-dword llvm-mc input and wave flags. - shader_library.py: main's structure with #984's --compute-hashes and per-state compute variants. One file that did not conflict is changed here: tools/rdna2_decode.py. Git kept both sides' decoders for a VOPC compare with a DPP operand, and #984's narrower one shadowed main's; it is main's file again. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/pe_loader.cpp')
-rw-r--r--runtime/src/pe_loader.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/runtime/src/pe_loader.cpp b/runtime/src/pe_loader.cpp
index 9c12733c6..3558cffb5 100644
--- a/runtime/src/pe_loader.cpp
+++ b/runtime/src/pe_loader.cpp
@@ -1829,6 +1829,11 @@ void Loader::initialize_tls(Module& m) {
1829 if (tls->AddressOfIndex) { 1829 if (tls->AddressOfIndex) {
1830 index_rva = rva_in(m, tls->AddressOfIndex, "the TLS index"); 1830 index_rva = rva_in(m, tls->AddressOfIndex, "the TLS index");
1831 require_range(m.name, index_rva, sizeof(uint32_t), m.size, "the TLS index"); 1831 require_range(m.name, index_rva, sizeof(uint32_t), m.size, "the TLS index");
1832 // The index is written below, and every later step reads the headers back from the mapping. An index at
1833 // RVA 0 would not be written at all (index_rva doubles as "no index").
1834 const auto* nt = at<IMAGE_NT_HEADERS64>(m.base, reinterpret_cast<IMAGE_DOS_HEADER*>(m.base)->e_lfanew);
1835 if (index_rva < nt->OptionalHeader.SizeOfHeaders)
1836 throw std::runtime_error(m.name + ": the TLS index lands in the headers");
1832 } 1837 }
1833 1838
1834 if (!module_tls_slots()) throw std::runtime_error(m.name + ": this thread has no TLS array"); 1839 if (!module_tls_slots()) throw std::runtime_error(m.name + ": this thread has no TLS array");
@@ -2113,6 +2118,9 @@ void* Loader::resolve(Module& m, const std::string& dll, const std::string& name
2113 2118
2114void Loader::bind_imports(Module& m) { 2119void Loader::bind_imports(Module& m) {
2115 auto* nt = at<IMAGE_NT_HEADERS64>(m.base, reinterpret_cast<IMAGE_DOS_HEADER*>(m.base)->e_lfanew); 2120 auto* nt = at<IMAGE_NT_HEADERS64>(m.base, reinterpret_cast<IMAGE_DOS_HEADER*>(m.base)->e_lfanew);
2121 // Read before the first address is written: an entry in the headers would replace what the steps after this
2122 // one read back from the mapping (e_lfanew, the section table), so it is refused like a section there.
2123 const uint64_t headers_end = nt->OptionalHeader.SizeOfHeaders;
2116 2124
2117 // Thunk tables have no length field: they end at a zero entry, so each step is checked against the image. 2125 // Thunk tables have no length field: they end at a zero entry, so each step is checked against the image.
2118 auto bind_thunks = [&](const std::string& dll, uint64_t lookup_rva, uint64_t iat_rva) { 2126 auto bind_thunks = [&](const std::string& dll, uint64_t lookup_rva, uint64_t iat_rva) {
@@ -2129,6 +2137,8 @@ void Loader::bind_imports(Module& m) {
2129 uint32_t hint = static_cast<uint32_t>(lookup->u1.AddressOfData); 2137 uint32_t hint = static_cast<uint32_t>(lookup->u1.AddressOfData);
2130 name = read_string(m.name, m.base, m.size, hint + sizeof(uint16_t), "an import name"); 2138 name = read_string(m.name, m.base, m.size, hint + sizeof(uint16_t), "an import name");
2131 } 2139 }
2140 if (iat_rva < headers_end)
2141 throw std::runtime_error(m.name + ": an import address table lands in the headers");
2132 at<IMAGE_THUNK_DATA64>(m.base, static_cast<uint32_t>(iat_rva))->u1.Function = 2142 at<IMAGE_THUNK_DATA64>(m.base, static_cast<uint32_t>(iat_rva))->u1.Function =
2133 reinterpret_cast<uint64_t>(resolve(m, dll, name, ord, by_ord)); 2143 reinterpret_cast<uint64_t>(resolve(m, dll, name, ord, by_ord));
2134 } 2144 }