Skip to content

Commit 9e591c1

Browse files
author
Valeriy Khorunzhin
committed
pppatch
Signed-off-by: Valeriy Khorunzhin <valeriy.khorunzhin@flant.com>
1 parent 0ee1079 commit 9e591c1

3 files changed

Lines changed: 49 additions & 30 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
diff --git a/scripts/layoutrom.py b/scripts/layoutrom.py
2+
index dd2c9ef..f09ec55 100644
3+
--- a/scripts/layoutrom.py
4+
+++ b/scripts/layoutrom.py
5+
@@ -460,13 +460,18 @@ def findReachable(anchorsections, checkreloc, data):
6+
def findReachable(anchorsections, checkreloc, data):
7+
anchorsections = dict([(section, []) for section in anchorsections])
8+
pending = list(anchorsections)
9+
while pending:
10+
section = pending.pop()
11+
+ if section is None or section.relocs is None:
12+
+ continue
13+
for reloc in section.relocs:
14+
chain = anchorsections[section] + [section.name]
15+
if not checkreloc(reloc, section, data, chain):
16+
continue
17+
nextsection = reloc.symbol.section
18+
+ if nextsection is None:
19+
+ continue
20+
if nextsection not in anchorsections:
21+
anchorsections[nextsection] = chain
22+
pending.append(nextsection)
23+
return anchorsections
24+
@@ -555,7 +560,10 @@ def parseObjDump(file, fileid):
25+
state = None
26+
continue
27+
state = 'reloc'
28+
- relocsection = sectionmap[sectionname]
29+
+ relocsection = sectionmap.get(sectionname)
30+
+ if relocsection is None:
31+
+ state = None
32+
+ continue
33+
continue
34+
35+
if state == 'section':
36+
@@ -660,10 +668,11 @@ else:
37+
entrysym = symbols['16'].get('entry_csm')
38+
else:
39+
entrysym = symbols['16'].get('reset_vector')
40+
-anchorsections = [entrysym.section] + [
41+
+anchorsections = [entrysym.section] + [
42+
section for section in allsections
43+
if section.name.startswith('.fixedaddr.')]
44+
+anchorsections = [section for section in anchorsections if section is not None]
45+
keepsections = findReachable(anchorsections, checkKeep, symbols)
46+
sections = [section for section in allsections if section in keepsections]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
# 001-isa-debug-port-no-bootable-device-message.patch
22
If SeaBIOS cannot find a bootable device, output "No bootable device." to the debug device at address 0x403 in addition to the normal console message.
3+
4+
# 002-layoutrom-handle-missing-sections.patch
5+
Teach `layoutrom.py` to skip relocations and anchor sections that are absent in `objdump` output from newer toolchains so `make -C roms bios` can finish successfully.

images/qemu/werf.inc.yaml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -364,36 +364,6 @@ shell:
364364
echo "Building patched SeaBIOS..."
365365
ln -sf /usr/bin/python3 /usr/bin/python
366366
367-
python3 - <<'PY'
368-
from pathlib import Path
369-
370-
p = Path("roms/seabios/scripts/layoutrom.py")
371-
t = p.read_text()
372-
373-
replacements = {
374-
"relocsection = sectionmap[sectionname]": """relocsection = sectionmap.get(sectionname)
375-
if relocsection is None:
376-
state = None
377-
continue""",
378-
" pending = list(anchorsections)": " pending = [section for section in anchorsections if section is not None]",
379-
" for reloc in section.relocs:": """ if section is None or section.relocs is None:
380-
continue
381-
for reloc in section.relocs:""",
382-
" if nextsection not in anchorsections:": """ if nextsection is None:
383-
continue
384-
if nextsection not in anchorsections:""",
385-
" keepsections = findReachable(anchorsections, checkKeep, symbols)": """ anchorsections = [section for section in anchorsections if section is not None]
386-
keepsections = findReachable(anchorsections, checkKeep, symbols)""",
387-
}
388-
389-
for old, new in replacements.items():
390-
if old not in t:
391-
raise SystemExit(f"Expected snippet not found in {p}: {old!r}")
392-
t = t.replace(old, new, 1)
393-
394-
p.write_text(t)
395-
PY
396-
397367
make -C roms bios -j$(nproc)
398368
399369
/install-qemu.sh --version-num "{{ $version }}" \

0 commit comments

Comments
 (0)