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.
This commit is contained in:
parent
2af84339f3
commit
17bc726360
|
@ -81,6 +81,7 @@ def get_linker_script_data(script):
|
|||
text = re.sub(r"/\*.*?\*/", " ", text)
|
||||
|
||||
close_brace = re.compile(r"\s}(\s*>\s*\w+)?")
|
||||
uwnknown_cmd = re.compile(r"\sPHDRS\s*{") # only this pattern for now, more might follow!
|
||||
memory_cmd = re.compile(r"\sMEMORY\s*{")
|
||||
sections_cmd = re.compile(r"\sSECTIONS\s*{")
|
||||
assign_current = re.compile(r"\s(?P<sym>\w+)\s*=\s*\.\s*;")
|
||||
|
@ -102,6 +103,7 @@ def get_linker_script_data(script):
|
|||
# with the info gleaned from the matched string.
|
||||
jump_table = {
|
||||
close_brace : close_brace_fun,
|
||||
uwnknown_cmd : unknown_cmd_fun,
|
||||
memory_cmd : memory_cmd_fun,
|
||||
sections_cmd : sections_cmd_fun,
|
||||
assign_current : assign_current_fun,
|
||||
|
@ -146,6 +148,7 @@ def get_linker_script_data(script):
|
|||
state["MEM"] = False
|
||||
state["SEC"] = False
|
||||
state["DEF"] = False
|
||||
state["UNKNOWN"] = False
|
||||
|
||||
i = 0
|
||||
while i < len(text):
|
||||
|
@ -274,6 +277,9 @@ def close_brace_fun(state, _, buf):
|
|||
elif state["MEM"]:
|
||||
info("Closing memory command")
|
||||
state["MEM"] = False
|
||||
elif state["UNKNOWN"]:
|
||||
info("Closing unknown command")
|
||||
state["UNKNOWN"] = False
|
||||
else:
|
||||
error("Not in block\n%s", buf)
|
||||
exit(1)
|
||||
|
@ -306,6 +312,9 @@ def memory_cmd_fun(state, _, buf):
|
|||
asrt(not state["MEM"], "encountered MEMORY twice", buf)
|
||||
state["MEM"] = True
|
||||
|
||||
def unknown_cmd_fun(state, _, buf):
|
||||
asrt(not state["MEM"], "encountered UNKNOWN twice", buf)
|
||||
state["UNKNOWN"] = True
|
||||
|
||||
def match_up_expr_assigns(state):
|
||||
blocks = set([data["origin"] for data in state["expr-assigns"]])
|
||||
|
|
Loading…
Reference in New Issue