15
15
import subprocess
16
16
import sys
17
17
import textwrap
18
+ import traceback
18
19
19
20
20
21
def epilog ():
@@ -81,6 +82,7 @@ def get_linker_script_data(script):
81
82
text = re .sub (r"/\*.*?\*/" , " " , text )
82
83
83
84
close_brace = re .compile (r"\s}(\s*>\s*\w+)?" )
85
+ uwnknown_cmd = re .compile (r"\sPHDRS\s*{" ) # only this pattern for now, more might follow!
84
86
memory_cmd = re .compile (r"\sMEMORY\s*{" )
85
87
sections_cmd = re .compile (r"\sSECTIONS\s*{" )
86
88
assign_current = re .compile (r"\s(?P<sym>\w+)\s*=\s*\.\s*;" )
@@ -102,6 +104,7 @@ def get_linker_script_data(script):
102
104
# with the info gleaned from the matched string.
103
105
jump_table = {
104
106
close_brace : close_brace_fun ,
107
+ uwnknown_cmd : unknown_cmd_fun ,
105
108
memory_cmd : memory_cmd_fun ,
106
109
sections_cmd : sections_cmd_fun ,
107
110
assign_current : assign_current_fun ,
@@ -146,6 +149,7 @@ def get_linker_script_data(script):
146
149
state ["MEM" ] = False
147
150
state ["SEC" ] = False
148
151
state ["DEF" ] = False
152
+ state ["UNKNOWN" ] = False
149
153
150
154
i = 0
151
155
while i < len (text ):
@@ -274,8 +278,12 @@ def close_brace_fun(state, _, buf):
274
278
elif state ["MEM" ]:
275
279
info ("Closing memory command" )
276
280
state ["MEM" ] = False
281
+ elif state ["UNKNOWN" ]:
282
+ info ("Closing unknown command" )
283
+ state ["UNKNOWN" ] = False
277
284
else :
278
285
error ("Not in block\n %s" , buf )
286
+ traceback .print_stack ()
279
287
exit (1 )
280
288
281
289
@@ -306,6 +314,9 @@ def memory_cmd_fun(state, _, buf):
306
314
asrt (not state ["MEM" ], "encountered MEMORY twice" , buf )
307
315
state ["MEM" ] = True
308
316
317
+ def unknown_cmd_fun (state , _ , buf ):
318
+ asrt (not state ["MEM" ], "encountered UNKNOWN twice" , buf )
319
+ state ["UNKNOWN" ] = True
309
320
310
321
def match_up_expr_assigns (state ):
311
322
blocks = set ([data ["origin" ] for data in state ["expr-assigns" ]])
0 commit comments