Commit 6f1cf45
committed
[lldb][MachO] Local structs for larger VA offsets
The Mach-O file format has several load commands which specify the
location of data in the file in UInt32 offsets. lldb uses these
same structures to track the offsets of the binary in virtual address
space when it is running. Normally a binary is loaded in memory
contiguously, so this is fine, but on Darwin systems there is a
"system shared cache" where all system libraries are combined into
one region of memory and pre-linked. The shared cache has the TEXT
segments for every binary loaded contiguously, then the DATA segments,
and finally a shared common LINKEDIT segment for all binaries. The
virtual address offset from the TEXT segment for a libray to the
LINKEDIT may exceed 4GB of virtual address space depending on the
structure of the shared cache, so this use of a UInt32 offset will
not work.
There was an initial instance of this issue that I fixed last November
in llvm#117832 where I
fixed this issue for the LC_SYMTAB / `symtab_command` structure. But
we have the same issue now with three additional structures;
`linkedit_data_command`, `dyld_info_command`, and `dysymtab_command`.
For all of these we can see the pattern of `dyld_info.export_off +=
linkedit_slide` applied to the offset fields in ObjectFileMachO.
This defines local structures that mirror the Mach-O structures,
except that it uses UInt64 offset fields so we can reuse the same
field for a large virtual address offset at runtime. I defined
ctor's from the genuine structures, as well as operator= methods
so the structures can be read from the Mach-O binary into the
standard object, then copied into our local expanded versions of
them. These structures are ABI in Mach-O and cannot change their
layout.
The alternative is to create local variables alongside these Mach-O
load command objects for the offsets that we care about, adjust
those by the correct VA offsets, and only use those local variables
instead of the fields in the objects. I took the approach of the
local enhanced structure in November and I think it is the cleaner
approach.
rdar://1603849681 parent b28d2ea commit 6f1cf45
File tree
2 files changed
+170
-43
lines changed- lldb/source/Plugins/ObjectFile/Mach-O
2 files changed
+170
-43
lines changedLines changed: 33 additions & 43 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2156 | 2156 | | |
2157 | 2157 | | |
2158 | 2158 | | |
2159 | | - | |
2160 | | - | |
2161 | | - | |
2162 | | - | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
2163 | 2163 | | |
2164 | 2164 | | |
2165 | 2165 | | |
| |||
2196 | 2196 | | |
2197 | 2197 | | |
2198 | 2198 | | |
2199 | | - | |
2200 | | - | |
2201 | | - | |
2202 | | - | |
2203 | | - | |
2204 | | - | |
2205 | | - | |
2206 | | - | |
2207 | | - | |
2208 | | - | |
2209 | | - | |
2210 | | - | |
2211 | | - | |
2212 | | - | |
2213 | | - | |
2214 | | - | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
| 2202 | + | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
2215 | 2207 | | |
2216 | 2208 | | |
2217 | | - | |
2218 | | - | |
2219 | | - | |
2220 | | - | |
2221 | | - | |
2222 | | - | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
2223 | 2215 | | |
2224 | | - | |
| 2216 | + | |
2225 | 2217 | | |
2226 | 2218 | | |
2227 | 2219 | | |
| |||
2245 | 2237 | | |
2246 | 2238 | | |
2247 | 2239 | | |
2248 | | - | |
2249 | | - | |
2250 | | - | |
2251 | | - | |
2252 | | - | |
2253 | | - | |
2254 | | - | |
2255 | | - | |
2256 | | - | |
2257 | | - | |
2258 | | - | |
2259 | | - | |
2260 | | - | |
2261 | | - | |
2262 | | - | |
2263 | | - | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
| 2249 | + | |
| 2250 | + | |
| 2251 | + | |
| 2252 | + | |
| 2253 | + | |
2264 | 2254 | | |
2265 | 2255 | | |
2266 | 2256 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
266 | 278 | | |
267 | 279 | | |
268 | 280 | | |
| |||
271 | 283 | | |
272 | 284 | | |
273 | 285 | | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
274 | 411 | | |
275 | 412 | | |
276 | 413 | | |
| |||
0 commit comments