@@ -59,7 +59,15 @@ def test_module(self):
5959
6060 module = target .AddModule (self .toModuleSpec (json_object_file_b ))
6161 self .assertFalse (module .IsValid ())
62-
62+ TEXT_file_addr = 0x100000000
63+ DATA_file_addr = 0x100001000
64+ foo_file_addr = TEXT_file_addr + 0x100
65+ bar_file_addr = DATA_file_addr + 0x10
66+ TEXT_size = 0x222
67+ DATA_size = 0x333
68+ foo_size = 0x11
69+ bar_size = 0x22
70+ slide = 0x100000000
6371 data = {
6472 "triple" : target .GetTriple (),
6573 "uuid" : str (uuid .uuid4 ()),
@@ -68,16 +76,29 @@ def test_module(self):
6876 {
6977 "name" : "__TEXT" ,
7078 "type" : "code" ,
71- "address" : 0 ,
72- "size" : 0x222 ,
79+ "address" : TEXT_file_addr ,
80+ "size" : TEXT_size ,
81+ },
82+ {
83+ "name" : "__DATA" ,
84+ "type" : "code" ,
85+ "address" : DATA_file_addr ,
86+ "size" : DATA_size ,
7387 }
7488 ],
7589 "symbols" : [
7690 {
7791 "name" : "foo" ,
78- "address" : 0x100 ,
79- "size" : 0x11 ,
80- }
92+ "type" : "code" ,
93+ "address" : foo_file_addr ,
94+ "size" : foo_size ,
95+ },
96+ {
97+ "name" : "bar" ,
98+ "type" : "data" ,
99+ "address" : bar_file_addr ,
100+ "size" : bar_size ,
101+ },
81102 ],
82103 }
83104
@@ -87,17 +108,31 @@ def test_module(self):
87108 module = target .AddModule (self .toModuleSpec (json_object_file_c ))
88109 self .assertTrue (module .IsValid ())
89110
90- section = module .GetSectionAtIndex (0 )
91- self .assertTrue (section .IsValid ())
92- self .assertEqual (section .GetName (), "__TEXT" )
93- self .assertEqual (section .file_addr , 0x0 )
94- self .assertEqual (section .size , 0x222 )
95-
96- symbol = module .FindSymbol ("foo" )
97- self .assertTrue (symbol .IsValid ())
98- self .assertEqual (symbol .addr .GetFileAddress (), 0x100 )
99- self .assertEqual (symbol .GetSize (), 0x11 )
100-
101- error = target .SetSectionLoadAddress (section , 0x1000 )
111+ text_section = module .GetSectionAtIndex (0 )
112+ self .assertTrue (text_section .IsValid ())
113+ self .assertEqual (text_section .GetName (), "__TEXT" )
114+ self .assertEqual (text_section .file_addr , TEXT_file_addr )
115+ self .assertEqual (text_section .size , TEXT_size )
116+
117+ data_section = module .GetSectionAtIndex (1 )
118+ self .assertTrue (data_section .IsValid ())
119+ self .assertEqual (data_section .GetName (), "__DATA" )
120+ self .assertEqual (data_section .file_addr , DATA_file_addr )
121+ self .assertEqual (data_section .size , DATA_size )
122+
123+ foo_symbol = module .FindSymbol ("foo" )
124+ self .assertTrue (foo_symbol .IsValid ())
125+ self .assertEqual (foo_symbol .addr .GetFileAddress (), foo_file_addr )
126+ self .assertEqual (foo_symbol .GetSize (), foo_size )
127+
128+ bar_symbol = module .FindSymbol ("bar" )
129+ self .assertTrue (bar_symbol .IsValid ())
130+ self .assertEqual (bar_symbol .addr .GetFileAddress (), bar_file_addr )
131+ self .assertEqual (bar_symbol .GetSize (), bar_size )
132+
133+ error = target .SetSectionLoadAddress (text_section , TEXT_file_addr + slide )
134+ self .assertSuccess (error )
135+ error = target .SetSectionLoadAddress (data_section , DATA_file_addr + slide )
102136 self .assertSuccess (error )
103- self .assertEqual (symbol .addr .GetLoadAddress (target ), 0x1100 )
137+ self .assertEqual (foo_symbol .addr .GetLoadAddress (target ), foo_file_addr + slide )
138+ self .assertEqual (bar_symbol .addr .GetLoadAddress (target ), bar_file_addr + slide )
0 commit comments