From 17bc7263606c6ec3ba20a67f5d57d8040090cbd5 Mon Sep 17 00:00:00 2001 From: Norbert Manthey Date: Tue, 10 Jul 2018 13:23:10 +0200 Subject: [PATCH] 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. --- scripts/ls_parse.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/ls_parse.py b/scripts/ls_parse.py index 5cbaee6831..16b39897d4 100755 --- a/scripts/ls_parse.py +++ b/scripts/ls_parse.py @@ -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\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"]])