@@ -75,16 +75,33 @@ def test_module(self):
75
75
"sections" : [
76
76
{
77
77
"name" : "__TEXT" ,
78
- "type" : "code " ,
78
+ "type" : "container " ,
79
79
"address" : TEXT_file_addr ,
80
80
"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
+ ],
81
95
},
82
96
{
83
97
"name" : "__DATA" ,
84
- "type" : "code " ,
98
+ "type" : "data " ,
85
99
"address" : DATA_file_addr ,
86
100
"size" : DATA_size ,
87
- }
101
+ "read" : True ,
102
+ "write" : True ,
103
+ "execute" : False ,
104
+ },
88
105
],
89
106
"symbols" : [
90
107
{
@@ -108,17 +125,40 @@ def test_module(self):
108
125
module = target .AddModule (self .toModuleSpec (json_object_file_c ))
109
126
self .assertTrue (module .IsValid ())
110
127
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 )
112
141
self .assertTrue (text_section .IsValid ())
113
- self .assertEqual (text_section .GetName (), "__TEXT " )
142
+ self .assertEqual (text_section .GetName (), "__text " )
114
143
self .assertEqual (text_section .file_addr , TEXT_file_addr )
115
144
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 )
122
162
123
163
foo_symbol = module .FindSymbol ("foo" )
124
164
self .assertTrue (foo_symbol .IsValid ())
@@ -130,9 +170,9 @@ def test_module(self):
130
170
self .assertEqual (bar_symbol .addr .GetFileAddress (), bar_file_addr )
131
171
self .assertEqual (bar_symbol .GetSize (), bar_size )
132
172
133
- error = target .SetSectionLoadAddress (text_section , TEXT_file_addr + slide )
173
+ error = target .SetSectionLoadAddress (TEXT_section , TEXT_file_addr + slide )
134
174
self .assertSuccess (error )
135
- error = target .SetSectionLoadAddress (data_section , DATA_file_addr + slide )
175
+ error = target .SetSectionLoadAddress (DATA_section , DATA_file_addr + slide )
136
176
self .assertSuccess (error )
137
177
self .assertEqual (foo_symbol .addr .GetLoadAddress (target ), foo_file_addr + slide )
138
178
self .assertEqual (bar_symbol .addr .GetLoadAddress (target ), bar_file_addr + slide )
0 commit comments