]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-130673: Gracefully handle missing sections in JIT build (GH-130906)
authorBojun Ren <bj.ren.coding@outlook.com>
Tue, 25 Mar 2025 23:35:39 +0000 (07:35 +0800)
committerGitHub <noreply@github.com>
Tue, 25 Mar 2025 23:35:39 +0000 (16:35 -0700)
Misc/NEWS.d/next/Build/2025-03-06-20-55-34.gh-issue-130673.T3RSCI.rst [new file with mode: 0644]
Tools/jit/_targets.py

diff --git a/Misc/NEWS.d/next/Build/2025-03-06-20-55-34.gh-issue-130673.T3RSCI.rst b/Misc/NEWS.d/next/Build/2025-03-06-20-55-34.gh-issue-130673.T3RSCI.rst
new file mode 100644 (file)
index 0000000..20c52c3
--- /dev/null
@@ -0,0 +1,2 @@
+Fix potential ``KeyError`` when handling object sections during JIT building
+process.
index b5a839e07d4dafb359d1fcaf8cca1bc3754d1a99..b3b065652e0bb0d6905319fa8f81e9b4a4a79344 100644 (file)
@@ -323,7 +323,11 @@ class _ELF(
         if section_type == "SHT_RELA":
             assert "SHF_INFO_LINK" in flags, flags
             assert not section["Symbols"]
-            value, base = group.symbols[section["Info"]]
+            maybe_symbol = group.symbols.get(section["Info"])
+            if maybe_symbol is None:
+                # These are relocations for a section we're not emitting. Skip:
+                return
+            value, base = maybe_symbol
             if value is _stencils.HoleValue.CODE:
                 stencil = group.code
             else: