@@ -75,16 +75,33 @@ def test_module(self):
7575 "sections" : [
7676 {
7777 "name" : "__TEXT" ,
78- "type" : "code " ,
78+ "type" : "container " ,
7979 "address" : TEXT_file_addr ,
8080 "size" : TEXT_size ,
81+ "read" : True ,
82+ "write" : False ,
83+ "execute" : True ,
84+ "subsections" : [
85+ {
86+ "name" : "__text" ,
87+ "type" : "code" ,
88+ "address" : TEXT_file_addr ,
89+ "size" : TEXT_size ,
90+ "read" : True ,
91+ "write" : False ,
92+ "execute" : True ,
93+ }
94+ ],
8195 },
8296 {
8397 "name" : "__DATA" ,
84- "type" : "code " ,
98+ "type" : "data " ,
8599 "address" : DATA_file_addr ,
86100 "size" : DATA_size ,
87- }
101+ "read" : True ,
102+ "write" : True ,
103+ "execute" : False ,
104+ },
88105 ],
89106 "symbols" : [
90107 {
@@ -108,17 +125,40 @@ def test_module(self):
108125 module = target .AddModule (self .toModuleSpec (json_object_file_c ))
109126 self .assertTrue (module .IsValid ())
110127
111- text_section = module .GetSectionAtIndex (0 )
128+ TEXT_section = module .GetSectionAtIndex (0 )
129+ self .assertTrue (TEXT_section .IsValid ())
130+ self .assertEqual (TEXT_section .GetName (), "__TEXT" )
131+ self .assertEqual (TEXT_section .file_addr , TEXT_file_addr )
132+ self .assertEqual (TEXT_section .size , TEXT_size )
133+ self .assertEqual (TEXT_section .GetSectionType (), lldb .eSectionTypeContainer )
134+ self .assertEqual (TEXT_section .GetNumSubSections (), 1 )
135+ text_permissions = TEXT_section .GetPermissions ()
136+ self .assertTrue ((text_permissions & lldb .ePermissionsReadable ) != 0 )
137+ self .assertFalse ((text_permissions & lldb .ePermissionsWritable ) != 0 )
138+ self .assertTrue ((text_permissions & lldb .ePermissionsExecutable ) != 0 )
139+
140+ text_section = TEXT_section .GetSubSectionAtIndex (0 )
112141 self .assertTrue (text_section .IsValid ())
113- self .assertEqual (text_section .GetName (), "__TEXT " )
142+ self .assertEqual (text_section .GetName (), "__text " )
114143 self .assertEqual (text_section .file_addr , TEXT_file_addr )
115144 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 )
145+ self .assertEqual (text_section .GetSectionType (), lldb .eSectionTypeCode )
146+ self .assertEqual (text_section .GetNumSubSections (), 0 )
147+ text_permissions = text_section .GetPermissions ()
148+ self .assertTrue ((text_permissions & lldb .ePermissionsReadable ) != 0 )
149+ self .assertFalse ((text_permissions & lldb .ePermissionsWritable ) != 0 )
150+ self .assertTrue ((text_permissions & lldb .ePermissionsExecutable ) != 0 )
151+
152+ DATA_section = module .GetSectionAtIndex (1 )
153+ self .assertTrue (DATA_section .IsValid ())
154+ self .assertEqual (DATA_section .GetName (), "__DATA" )
155+ self .assertEqual (DATA_section .file_addr , DATA_file_addr )
156+ self .assertEqual (DATA_section .size , DATA_size )
157+ self .assertEqual (DATA_section .GetSectionType (), lldb .eSectionTypeData )
158+ data_permissions = DATA_section .GetPermissions ()
159+ self .assertTrue ((data_permissions & lldb .ePermissionsReadable ) != 0 )
160+ self .assertTrue ((data_permissions & lldb .ePermissionsWritable ) != 0 )
161+ self .assertFalse ((data_permissions & lldb .ePermissionsExecutable ) != 0 )
122162
123163 foo_symbol = module .FindSymbol ("foo" )
124164 self .assertTrue (foo_symbol .IsValid ())
@@ -130,9 +170,9 @@ def test_module(self):
130170 self .assertEqual (bar_symbol .addr .GetFileAddress (), bar_file_addr )
131171 self .assertEqual (bar_symbol .GetSize (), bar_size )
132172
133- error = target .SetSectionLoadAddress (text_section , TEXT_file_addr + slide )
173+ error = target .SetSectionLoadAddress (TEXT_section , TEXT_file_addr + slide )
134174 self .assertSuccess (error )
135- error = target .SetSectionLoadAddress (data_section , DATA_file_addr + slide )
175+ error = target .SetSectionLoadAddress (DATA_section , DATA_file_addr + slide )
136176 self .assertSuccess (error )
137177 self .assertEqual (foo_symbol .addr .GetLoadAddress (target ), foo_file_addr + slide )
138178 self .assertEqual (bar_symbol .addr .GetLoadAddress (target ), bar_file_addr + slide )
0 commit comments