@@ -75,15 +75,32 @@ 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 ,
101+ "read" : True ,
102+ "write" : True ,
103+ "execute" : False
87104 }
88105 ],
89106 "symbols" : [
@@ -108,17 +125,43 @@ 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 (),
134+ lldb .eSectionTypeContainer )
135+ self .assertEqual (TEXT_section .GetNumSubSections (), 1 )
136+ text_permissions = TEXT_section .GetPermissions ()
137+ self .assertTrue ((text_permissions & lldb .ePermissionsReadable ) != 0 )
138+ self .assertFalse ((text_permissions & lldb .ePermissionsWritable ) != 0 )
139+ self .assertTrue ((text_permissions & lldb .ePermissionsExecutable ) != 0 )
140+
141+ text_section = TEXT_section .GetSubSectionAtIndex (0 )
112142 self .assertTrue (text_section .IsValid ())
113- self .assertEqual (text_section .GetName (), "__TEXT " )
143+ self .assertEqual (text_section .GetName (), "__text " )
114144 self .assertEqual (text_section .file_addr , TEXT_file_addr )
115145 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 )
146+ self .assertEqual (text_section .GetSectionType (),
147+ lldb .eSectionTypeCode )
148+ self .assertEqual (text_section .GetNumSubSections (), 0 )
149+ text_permissions = text_section .GetPermissions ()
150+ self .assertTrue ((text_permissions & lldb .ePermissionsReadable ) != 0 )
151+ self .assertFalse ((text_permissions & lldb .ePermissionsWritable ) != 0 )
152+ self .assertTrue ((text_permissions & lldb .ePermissionsExecutable ) != 0 )
153+
154+ DATA_section = module .GetSectionAtIndex (1 )
155+ self .assertTrue (DATA_section .IsValid ())
156+ self .assertEqual (DATA_section .GetName (), "__DATA" )
157+ self .assertEqual (DATA_section .file_addr , DATA_file_addr )
158+ self .assertEqual (DATA_section .size , DATA_size )
159+ self .assertEqual (DATA_section .GetSectionType (),
160+ lldb .eSectionTypeData )
161+ data_permissions = DATA_section .GetPermissions ()
162+ self .assertTrue ((data_permissions & lldb .ePermissionsReadable ) != 0 )
163+ self .assertTrue ((data_permissions & lldb .ePermissionsWritable ) != 0 )
164+ self .assertFalse ((data_permissions & lldb .ePermissionsExecutable ) != 0 )
122165
123166 foo_symbol = module .FindSymbol ("foo" )
124167 self .assertTrue (foo_symbol .IsValid ())
@@ -130,9 +173,9 @@ def test_module(self):
130173 self .assertEqual (bar_symbol .addr .GetFileAddress (), bar_file_addr )
131174 self .assertEqual (bar_symbol .GetSize (), bar_size )
132175
133- error = target .SetSectionLoadAddress (text_section , TEXT_file_addr + slide )
176+ error = target .SetSectionLoadAddress (TEXT_section , TEXT_file_addr + slide )
134177 self .assertSuccess (error )
135- error = target .SetSectionLoadAddress (data_section , DATA_file_addr + slide )
178+ error = target .SetSectionLoadAddress (DATA_section , DATA_file_addr + slide )
136179 self .assertSuccess (error )
137180 self .assertEqual (foo_symbol .addr .GetLoadAddress (target ), foo_file_addr + slide )
138181 self .assertEqual (bar_symbol .addr .GetLoadAddress (target ), bar_file_addr + slide )
0 commit comments