Skip to content

Commit 17bc726

Browse files
committed
ls_parse: Allow handling unknown blocks
The Xen linker script has a block "PHDRS" that results in a failure of the ls_parse.py script. As there is nothing to be done in that script for that block, this commit adds an empty handler for this block name. In case more blocks should be added, only the regular expression to match the blocks has to be modified.
1 parent 2af8433 commit 17bc726

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

scripts/ls_parse.py

+9
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def get_linker_script_data(script):
8181
text = re.sub(r"/\*.*?\*/", " ", text)
8282

8383
close_brace = re.compile(r"\s}(\s*>\s*\w+)?")
84+
uwnknown_cmd = re.compile(r"\sPHDRS\s*{") # only this pattern for now, more might follow!
8485
memory_cmd = re.compile(r"\sMEMORY\s*{")
8586
sections_cmd = re.compile(r"\sSECTIONS\s*{")
8687
assign_current = re.compile(r"\s(?P<sym>\w+)\s*=\s*\.\s*;")
@@ -102,6 +103,7 @@ def get_linker_script_data(script):
102103
# with the info gleaned from the matched string.
103104
jump_table = {
104105
close_brace : close_brace_fun,
106+
uwnknown_cmd : unknown_cmd_fun,
105107
memory_cmd : memory_cmd_fun,
106108
sections_cmd : sections_cmd_fun,
107109
assign_current : assign_current_fun,
@@ -146,6 +148,7 @@ def get_linker_script_data(script):
146148
state["MEM"] = False
147149
state["SEC"] = False
148150
state["DEF"] = False
151+
state["UNKNOWN"] = False
149152

150153
i = 0
151154
while i < len(text):
@@ -274,6 +277,9 @@ def close_brace_fun(state, _, buf):
274277
elif state["MEM"]:
275278
info("Closing memory command")
276279
state["MEM"] = False
280+
elif state["UNKNOWN"]:
281+
info("Closing unknown command")
282+
state["UNKNOWN"] = False
277283
else:
278284
error("Not in block\n%s", buf)
279285
exit(1)
@@ -306,6 +312,9 @@ def memory_cmd_fun(state, _, buf):
306312
asrt(not state["MEM"], "encountered MEMORY twice", buf)
307313
state["MEM"] = True
308314

315+
def unknown_cmd_fun(state, _, buf):
316+
asrt(not state["MEM"], "encountered UNKNOWN twice", buf)
317+
state["UNKNOWN"] = True
309318

310319
def match_up_expr_assigns(state):
311320
blocks = set([data["origin"] for data in state["expr-assigns"]])

0 commit comments

Comments
 (0)