@@ -64,6 +64,7 @@ def test_module(self):
6464 foo_file_addr = TEXT_file_addr + 0x100
6565 bar_file_addr = DATA_file_addr + 0x10
6666 TEXT_size = 0x222
67+ text_size = 0x20
6768 DATA_size = 0x333
6869 foo_size = 0x11
6970 bar_size = 0x22
@@ -74,10 +75,22 @@ def test_module(self):
7475 "type" : "sharedlibrary" ,
7576 "sections" : [
7677 {
78+ "user_id" : 0x100 ,
79+ "name" : "__PAGEZERO" ,
80+ "type" : "container" ,
81+ "address" : 0 ,
82+ "size" : 0x100000000 ,
83+ "flags" : 0x101
84+ },
85+ {
86+ "user_id" : 0x200 ,
7787 "name" : "__TEXT" ,
7888 "type" : "container" ,
7989 "address" : TEXT_file_addr ,
8090 "size" : TEXT_size ,
91+ "flags" : 0x202 ,
92+ "file_offset" : 0 ,
93+ "file_size" : TEXT_size ,
8194 "read" : True ,
8295 "write" : False ,
8396 "execute" : True ,
@@ -86,10 +99,29 @@ def test_module(self):
8699 "name" : "__text" ,
87100 "type" : "code" ,
88101 "address" : TEXT_file_addr ,
89- "size" : TEXT_size ,
102+ "size" : text_size ,
103+ "alignment" : 2 ,
90104 "read" : True ,
91105 "write" : False ,
92106 "execute" : True ,
107+ },
108+ {
109+ "name" : "__fake" ,
110+ "address" : TEXT_file_addr + 1 * text_size ,
111+ "size" : text_size ,
112+ "fake" : True
113+ },
114+ {
115+ "name" : "__encrypted" ,
116+ "address" : TEXT_file_addr + 2 * text_size ,
117+ "size" : text_size ,
118+ "encrypted" : True
119+ },
120+ {
121+ "name" : "__tls" ,
122+ "address" : TEXT_file_addr + 2 * text_size ,
123+ "size" : text_size ,
124+ "thread_specific" : True
93125 }
94126 ],
95127 },
@@ -101,6 +133,9 @@ def test_module(self):
101133 "read" : True ,
102134 "write" : True ,
103135 "execute" : False ,
136+ "flags" : 0x303 ,
137+ "file_offset" : DATA_file_addr - TEXT_file_addr ,
138+ "file_size" : DATA_size ,
104139 },
105140 ],
106141 "symbols" : [
@@ -127,33 +162,48 @@ def test_module(self):
127162
128163 TEXT_section = module .GetSectionAtIndex (0 )
129164 self .assertTrue (TEXT_section .IsValid ())
165+ self .assertEqual (TEXT_section .GetName (), "__PAGEZERO" )
166+ self .assertEqual (TEXT_section .file_addr , 0 )
167+ self .assertEqual (TEXT_section .size , 0x100000000 )
168+ self .assertEqual (TEXT_section .GetSectionType (), lldb .eSectionTypeContainer )
169+ self .assertEqual (TEXT_section .GetNumSubSections (), 0 )
170+ text_permissions = TEXT_section .GetPermissions ()
171+ self .assertFalse ((text_permissions & lldb .ePermissionsReadable ) != 0 )
172+ self .assertFalse ((text_permissions & lldb .ePermissionsWritable ) != 0 )
173+ self .assertFalse ((text_permissions & lldb .ePermissionsExecutable ) != 0 )
174+
175+ TEXT_section = module .GetSectionAtIndex (1 )
176+ self .assertTrue (TEXT_section .IsValid ())
130177 self .assertEqual (TEXT_section .GetName (), "__TEXT" )
131178 self .assertEqual (TEXT_section .file_addr , TEXT_file_addr )
132179 self .assertEqual (TEXT_section .size , TEXT_size )
180+ self .assertEqual (TEXT_section .file_offset , 0 )
181+ self .assertEqual (TEXT_section .file_size , TEXT_size )
133182 self .assertEqual (TEXT_section .GetSectionType (), lldb .eSectionTypeContainer )
134- self .assertEqual (TEXT_section .GetNumSubSections (), 1 )
183+ self .assertEqual (TEXT_section .GetNumSubSections (), 4 )
135184 text_permissions = TEXT_section .GetPermissions ()
136185 self .assertTrue ((text_permissions & lldb .ePermissionsReadable ) != 0 )
137186 self .assertFalse ((text_permissions & lldb .ePermissionsWritable ) != 0 )
138187 self .assertTrue ((text_permissions & lldb .ePermissionsExecutable ) != 0 )
139188
140189 text_section = TEXT_section .GetSubSectionAtIndex (0 )
141- self .assertTrue (text_section .IsValid ())
142190 self .assertEqual (text_section .GetName (), "__text" )
143- self .assertEqual (text_section .file_addr , TEXT_file_addr )
144- self .assertEqual (text_section .size , TEXT_size )
191+ self .assertEqual (text_section .size , text_size )
192+ self .assertEqual (text_section .GetAlignment (), 4 )
145193 self .assertEqual (text_section .GetSectionType (), lldb .eSectionTypeCode )
146194 self .assertEqual (text_section .GetNumSubSections (), 0 )
147195 text_permissions = text_section .GetPermissions ()
148196 self .assertTrue ((text_permissions & lldb .ePermissionsReadable ) != 0 )
149197 self .assertFalse ((text_permissions & lldb .ePermissionsWritable ) != 0 )
150198 self .assertTrue ((text_permissions & lldb .ePermissionsExecutable ) != 0 )
151199
152- DATA_section = module .GetSectionAtIndex (1 )
200+ DATA_section = module .GetSectionAtIndex (2 )
153201 self .assertTrue (DATA_section .IsValid ())
154202 self .assertEqual (DATA_section .GetName (), "__DATA" )
155203 self .assertEqual (DATA_section .file_addr , DATA_file_addr )
156204 self .assertEqual (DATA_section .size , DATA_size )
205+ self .assertEqual (DATA_section .file_offset , DATA_file_addr - TEXT_file_addr )
206+ self .assertEqual (DATA_section .file_size , DATA_size )
157207 self .assertEqual (DATA_section .GetSectionType (), lldb .eSectionTypeData )
158208 data_permissions = DATA_section .GetPermissions ()
159209 self .assertTrue ((data_permissions & lldb .ePermissionsReadable ) != 0 )
@@ -170,6 +220,19 @@ def test_module(self):
170220 self .assertEqual (bar_symbol .addr .GetFileAddress (), bar_file_addr )
171221 self .assertEqual (bar_symbol .GetSize (), bar_size )
172222
223+ # Verify the user_ids and flags are set correctly since there is no API
224+ # for this on lldb.SBSection
225+ self .expect ("target modules dump sections c.json" ,
226+ substrs = [
227+ "0x0000000000000100 container [0x0000000000000000-0x0000000100000000) --- 0x00000000 0x00000000 0x00000101 c.json.__PAGEZERO" ,
228+ "0x0000000000000200 container [0x0000000100000000-0x0000000100000222) r-x 0x00000000 0x00000222 0x00000202 c.json.__TEXT" ,
229+ "0x0000000000000001 code [0x0000000100000000-0x0000000100000020) r-x 0x00000000 0x00000000 0x00000000 c.json.__TEXT.__text" ,
230+ "0x0000000000000002 code [0x0000000100000020-0x0000000100000040) --- 0x00000000 0x00000000 0x00000000 c.json.__TEXT.__fake" ,
231+ "0x0000000000000003 code [0x0000000100000040-0x0000000100000060) --- 0x00000000 0x00000000 0x00000000 c.json.__TEXT.__encrypted" ,
232+ "0x0000000000000004 code [0x0000000100000040-0x0000000100000060) --- 0x00000000 0x00000000 0x00000000 c.json.__TEXT.__tls" ,
233+ "0x0000000000000005 data [0x0000000100001000-0x0000000100001333) rw- 0x00001000 0x00000333 0x00000303 c.json.__DATA"
234+ ])
235+
173236 error = target .SetSectionLoadAddress (TEXT_section , TEXT_file_addr + slide )
174237 self .assertSuccess (error )
175238 error = target .SetSectionLoadAddress (DATA_section , DATA_file_addr + slide )
0 commit comments