3
3
"""Validate compact unwind info by cross checking the llvm-objdump
4
4
reports of the input object file vs final linked output.
5
5
"""
6
+ from __future__ import print_function
6
7
import sys
7
8
import argparse
8
9
import re
@@ -25,11 +26,11 @@ def main():
25
26
26
27
object_encodings_list = [(symbol , encoding , personality , lsda )
27
28
for symbol , encoding , personality , lsda in
28
- re .findall (rf "start:\s+0x{ hex } +\s+(\w+)\s+" +
29
- rf "length:\s+0x{ hex } +\s+" +
30
- rf "compact encoding:\s+0x({ hex } +)(?:\s+" +
31
- rf "personality function:\s+0x({ hex } +)\s+\w+\s+" +
32
- rf "LSDA:\s+0x({ hex } +)\s+\w+(?: \+ 0x{ hex } +)?)?" ,
29
+ re .findall (r "start:\s+0x%s +\s+(\w+)\s+" % hex +
30
+ r "length:\s+0x%s +\s+" % hex +
31
+ r "compact encoding:\s+0x(%s +)(?:\s+" % hex +
32
+ r "personality function:\s+0x(%s +)\s+\w+\s+" % hex +
33
+ r "LSDA:\s+0x(%s +)\s+\w+(?: \+ 0x%s +)?)?" % ( hex , hex ) ,
33
34
objdump_string , re .DOTALL )]
34
35
object_encodings_map = {symbol :encoding
35
36
for symbol , encoding , _ , _ in object_encodings_list }
@@ -38,21 +39,21 @@ def main():
38
39
39
40
program_symbols_map = {address :symbol
40
41
for address , symbol in
41
- re .findall (rf"^ { hex8 } ( { hex8 } ) g\s+F __TEXT,__text (x\1)$" ,
42
+ re .findall (r"^%s(%s ) g\s+F __TEXT,__text (x\1)$" % ( hex8 , hex8 ) ,
42
43
objdump_string , re .MULTILINE )}
43
44
if not program_symbols_map :
44
45
sys .exit ("no program symbols found in input" )
45
46
46
47
program_common_encodings = (
47
- re .findall (rf "^\s+encoding\[\d+\]: 0x({ hex } +)$" ,
48
+ re .findall (r "^\s+encoding\[\d+\]: 0x(%s +)$" % hex ,
48
49
objdump_string , re .MULTILINE ))
49
50
if not program_common_encodings :
50
51
sys .exit ("no common encodings found in input" )
51
52
52
53
program_encodings_map = {program_symbols_map [address ]:encoding
53
54
for address , encoding in
54
- re .findall (rf "^\s+\[\d+\]: function offset=0x({ hex } +), " +
55
- rf "encoding\[\d+\]=0x({ hex } +)$" ,
55
+ re .findall (r "^\s+\[\d+\]: function offset=0x(%s +), " % hex +
56
+ r "encoding\[\d+\]=0x(%s +)$" % hex ,
56
57
objdump_string , re .MULTILINE )}
57
58
if not object_encodings_map :
58
59
sys .exit ("no program encodings found in input" )
@@ -66,13 +67,14 @@ def main():
66
67
if fold :
67
68
del object_encodings_map [symbol ]
68
69
if args .debug :
69
- print (f"{ 'delete' if fold else 'retain' } { symbol } with { encoding } " )
70
+ print ("%s %s with %s" % (
71
+ 'delete' if fold else 'retain' , symbol , encoding ))
70
72
encoding0 = encoding
71
73
72
74
if program_encodings_map != object_encodings_map :
73
75
if args .debug :
74
- pprint (f "program encodings map:\n { program_encodings_map } " )
75
- pprint (f "object encodings map:\n { object_encodings_map } " )
76
+ pprint ("program encodings map:\n " + program_encodings_map )
77
+ pprint ("object encodings map:\n " + object_encodings_map )
76
78
sys .exit ("encoding maps differ" )
77
79
78
80
# Count frequency of object-file folded encodings
@@ -87,8 +89,8 @@ def main():
87
89
88
90
if program_common_encodings != encoding_frequencies :
89
91
if args .debug :
90
- pprint (f "program common encodings:\n { program_common_encodings } " )
91
- pprint (f "object encoding frequencies:\n { encoding_frequencies } " )
92
+ pprint ("program common encodings:\n " + program_common_encodings )
93
+ pprint ("object encoding frequencies:\n " + encoding_frequencies )
92
94
sys .exit ("encoding frequencies differ" )
93
95
94
96
0 commit comments