| ... | ... | @@ -28,7 +28,6 @@ name: ?[]const u8 = null, |
| 28 | 28 | mtime: ?u64 = null, |
| 29 | 29 | |
| 30 | 30 | load_commands: std.ArrayListUnmanaged(LoadCommand) = .{}, |
| 31 | | sections: std.ArrayListUnmanaged(Section) = .{}, |
| 32 | 31 | |
| 33 | 32 | segment_cmd_index: ?u16 = null, |
| 34 | 33 | symtab_cmd_index: ?u16 = null, |
| ... | ... | @@ -49,32 +48,10 @@ dwarf_debug_ranges_index: ?u16 = null, |
| 49 | 48 | symtab: std.ArrayListUnmanaged(macho.nlist_64) = .{}, |
| 50 | 49 | strtab: std.ArrayListUnmanaged(u8) = .{}, |
| 51 | 50 | |
| 52 | | symbols: std.ArrayListUnmanaged(*Symbol) = .{}, |
| 53 | | stabs: std.ArrayListUnmanaged(*Symbol) = .{}, |
| 54 | 51 | initializers: std.ArrayListUnmanaged(u32) = .{}, |
| 55 | 52 | data_in_code_entries: std.ArrayListUnmanaged(macho.data_in_code_entry) = .{}, |
| 56 | 53 | |
| 57 | | pub const Section = struct { |
| 58 | | inner: macho.section_64, |
| 59 | | code: []u8, |
| 60 | | relocs: ?[]*Relocation, |
| 61 | | target_map: ?struct { |
| 62 | | segment_id: u16, |
| 63 | | section_id: u16, |
| 64 | | offset: u32, |
| 65 | | } = null, |
| 66 | | |
| 67 | | pub fn deinit(self: *Section, allocator: *Allocator) void { |
| 68 | | allocator.free(self.code); |
| 69 | | |
| 70 | | if (self.relocs) |relocs| { |
| 71 | | for (relocs) |rel| { |
| 72 | | allocator.destroy(rel); |
| 73 | | } |
| 74 | | allocator.free(relocs); |
| 75 | | } |
| 76 | | } |
| 77 | | }; |
| 54 | symbols: std.ArrayListUnmanaged(*Symbol) = .{}, |
| 78 | 55 | |
| 79 | 56 | const DebugInfo = struct { |
| 80 | 57 | inner: dwarf.DwarfInfo, |
| ... | ... | @@ -177,19 +154,11 @@ pub fn deinit(self: *Object) void { |
| 177 | 154 | lc.deinit(self.allocator); |
| 178 | 155 | } |
| 179 | 156 | self.load_commands.deinit(self.allocator); |
| 180 | | |
| 181 | | for (self.sections.items) |*sect| { |
| 182 | | sect.deinit(self.allocator); |
| 183 | | } |
| 184 | | self.sections.deinit(self.allocator); |
| 185 | | |
| 186 | | self.symbols.deinit(self.allocator); |
| 187 | | self.stabs.deinit(self.allocator); |
| 188 | | |
| 189 | 157 | self.data_in_code_entries.deinit(self.allocator); |
| 190 | 158 | self.initializers.deinit(self.allocator); |
| 191 | 159 | self.symtab.deinit(self.allocator); |
| 192 | 160 | self.strtab.deinit(self.allocator); |
| 161 | self.symbols.deinit(self.allocator); |
| 193 | 162 | |
| 194 | 163 | if (self.name) |n| { |
| 195 | 164 | self.allocator.free(n); |
| ... | ... | @@ -231,10 +200,8 @@ pub fn parse(self: *Object) !void { |
| 231 | 200 | self.header = header; |
| 232 | 201 | |
| 233 | 202 | try self.readLoadCommands(reader); |
| 234 | | try self.parseSections(); |
| 235 | 203 | try self.parseSymtab(); |
| 236 | 204 | try self.parseDataInCode(); |
| 237 | | try self.parseInitializers(); |
| 238 | 205 | } |
| 239 | 206 | |
| 240 | 207 | pub fn readLoadCommands(self: *Object, reader: anytype) !void { |
| ... | ... | @@ -305,250 +272,253 @@ pub fn readLoadCommands(self: *Object, reader: anytype) !void { |
| 305 | 272 | } |
| 306 | 273 | } |
| 307 | 274 | |
| 308 | | pub fn parseSections(self: *Object) !void { |
| 309 | | const seg = self.load_commands.items[self.segment_cmd_index.?].Segment; |
| 310 | | |
| 311 | | log.debug("parsing sections in {s}", .{self.name.?}); |
| 312 | | |
| 313 | | try self.sections.ensureCapacity(self.allocator, seg.sections.items.len); |
| 275 | const NlistWithIndex = struct { |
| 276 | nlist: macho.nlist_64, |
| 277 | index: u32, |
| 314 | 278 | |
| 315 | | for (seg.sections.items) |sect| { |
| 316 | | log.debug("parsing section '{s},{s}'", .{ segmentName(sect), sectionName(sect) }); |
| 317 | | // Read sections' code |
| 318 | | var code = try self.allocator.alloc(u8, @intCast(usize, sect.size)); |
| 319 | | _ = try self.file.?.preadAll(code, sect.offset); |
| 320 | | |
| 321 | | var section = Section{ |
| 322 | | .inner = sect, |
| 323 | | .code = code, |
| 324 | | .relocs = null, |
| 325 | | }; |
| 279 | pub fn cmp(_: void, lhs: @This(), rhs: @This()) bool { |
| 280 | return lhs.nlist.n_value < rhs.nlist.n_value; |
| 281 | } |
| 326 | 282 | |
| 327 | | // Parse relocations |
| 328 | | if (sect.nreloc > 0) { |
| 329 | | var raw_relocs = try self.allocator.alloc(u8, @sizeOf(macho.relocation_info) * sect.nreloc); |
| 330 | | defer self.allocator.free(raw_relocs); |
| 283 | fn filterNlistsInSection(symbols: []@This(), sect_id: u8) []@This() { |
| 284 | var start: usize = 0; |
| 285 | var end: usize = symbols.len; |
| 331 | 286 | |
| 332 | | _ = try self.file.?.preadAll(raw_relocs, sect.reloff); |
| 287 | while (true) { |
| 288 | var change = false; |
| 289 | if (symbols[start].nlist.n_sect != sect_id) { |
| 290 | start += 1; |
| 291 | change = true; |
| 292 | } |
| 293 | if (symbols[end - 1].nlist.n_sect != sect_id) { |
| 294 | end -= 1; |
| 295 | change = true; |
| 296 | } |
| 333 | 297 | |
| 334 | | section.relocs = try reloc.parse( |
| 335 | | self.allocator, |
| 336 | | self.arch.?, |
| 337 | | section.code, |
| 338 | | mem.bytesAsSlice(macho.relocation_info, raw_relocs), |
| 339 | | ); |
| 298 | if (start == end) break; |
| 299 | if (!change) break; |
| 340 | 300 | } |
| 341 | 301 | |
| 342 | | self.sections.appendAssumeCapacity(section); |
| 302 | return symbols[start..end]; |
| 343 | 303 | } |
| 344 | | } |
| 345 | | |
| 346 | | pub fn parseTextBlocks(self: *Object, zld: *Zld) !*TextBlock { |
| 347 | | const seg = self.load_commands.items[self.segment_cmd_index.?].Segment; |
| 304 | }; |
| 348 | 305 | |
| 349 | | log.warn("analysing {s}", .{self.name.?}); |
| 306 | fn filterRelocs(relocs: []macho.relocation_info, start: u64, end: u64) []macho.relocation_info { |
| 307 | if (relocs.len == 0) return relocs; |
| 350 | 308 | |
| 351 | | const dysymtab = self.load_commands.items[self.dysymtab_cmd_index.?].Dysymtab; |
| 309 | var start_id: usize = 0; |
| 310 | var end_id: usize = relocs.len; |
| 352 | 311 | |
| 353 | | const SymWithIndex = struct { |
| 354 | | nlist: macho.nlist_64, |
| 355 | | index: u32, |
| 356 | | |
| 357 | | pub fn cmp(_: void, lhs: @This(), rhs: @This()) bool { |
| 358 | | return lhs.nlist.n_value < rhs.nlist.n_value; |
| 312 | while (true) { |
| 313 | var change = false; |
| 314 | if (relocs[start_id].r_address > end) { |
| 315 | start_id += 1; |
| 316 | change = true; |
| 359 | 317 | } |
| 360 | | |
| 361 | | fn filterSymsInSection(symbols: []@This(), sect_id: u8) []@This() { |
| 362 | | var start: usize = 0; |
| 363 | | var end: usize = symbols.len; |
| 364 | | |
| 365 | | while (true) { |
| 366 | | var change = false; |
| 367 | | if (symbols[start].nlist.n_sect != sect_id) { |
| 368 | | start += 1; |
| 369 | | change = true; |
| 370 | | } |
| 371 | | if (symbols[end - 1].nlist.n_sect != sect_id) { |
| 372 | | end -= 1; |
| 373 | | change = true; |
| 374 | | } |
| 375 | | |
| 376 | | if (start == end) break; |
| 377 | | if (!change) break; |
| 378 | | } |
| 379 | | |
| 380 | | return symbols[start..end]; |
| 318 | if (relocs[end_id - 1].r_address < start) { |
| 319 | end_id -= 1; |
| 320 | change = true; |
| 381 | 321 | } |
| 382 | 322 | |
| 383 | | fn filterRelocs(relocs: []macho.relocation_info, start: u64, end: u64) []macho.relocation_info { |
| 384 | | if (relocs.len == 0) return relocs; |
| 323 | if (start_id == end_id) break; |
| 324 | if (!change) break; |
| 325 | } |
| 385 | 326 | |
| 386 | | var start_id: usize = 0; |
| 387 | | var end_id: usize = relocs.len; |
| 327 | return relocs[start_id..end_id]; |
| 328 | } |
| 388 | 329 | |
| 389 | | while (true) { |
| 390 | | var change = false; |
| 391 | | if (relocs[start_id].r_address > end) { |
| 392 | | start_id += 1; |
| 393 | | change = true; |
| 394 | | } |
| 395 | | if (relocs[end_id - 1].r_address < start) { |
| 396 | | end_id -= 1; |
| 397 | | change = true; |
| 398 | | } |
| 330 | const SeniorityContext = struct { |
| 331 | zld: *Zld, |
| 332 | }; |
| 333 | fn cmpSymBySeniority(context: SeniorityContext, lhs: u32, rhs: u32) bool { |
| 334 | const lreg = context.zld.locals.items[lhs].payload.regular; |
| 335 | const rreg = context.zld.locals.items[rhs].payload.regular; |
| 336 | |
| 337 | return switch (rreg.linkage) { |
| 338 | .global => true, |
| 339 | .linkage_unit => lreg.linkage == .translation_unit, |
| 340 | else => false, |
| 341 | }; |
| 342 | } |
| 399 | 343 | |
| 400 | | if (start_id == end_id) break; |
| 401 | | if (!change) break; |
| 402 | | } |
| 344 | pub fn parseTextBlocks(self: *Object, zld: *Zld) !?*TextBlock { |
| 345 | const seg = self.load_commands.items[self.segment_cmd_index.?].Segment; |
| 403 | 346 | |
| 404 | | return relocs[start_id..end_id]; |
| 405 | | } |
| 406 | | }; |
| 347 | log.warn("analysing {s}", .{self.name.?}); |
| 407 | 348 | |
| 349 | const dysymtab = self.load_commands.items[self.dysymtab_cmd_index.?].Dysymtab; |
| 350 | // We only care about defined symbols, so filter every other out. |
| 408 | 351 | const nlists = self.symtab.items[dysymtab.ilocalsym..dysymtab.iundefsym]; |
| 409 | 352 | |
| 410 | | var sorted_syms = std.ArrayList(SymWithIndex).init(self.allocator); |
| 411 | | defer sorted_syms.deinit(); |
| 412 | | try sorted_syms.ensureTotalCapacity(nlists.len); |
| 353 | var sorted_nlists = std.ArrayList(NlistWithIndex).init(self.allocator); |
| 354 | defer sorted_nlists.deinit(); |
| 355 | try sorted_nlists.ensureTotalCapacity(nlists.len); |
| 413 | 356 | |
| 414 | 357 | for (nlists) |nlist, index| { |
| 415 | | sorted_syms.appendAssumeCapacity(.{ |
| 358 | sorted_nlists.appendAssumeCapacity(.{ |
| 416 | 359 | .nlist = nlist, |
| 417 | 360 | .index = @intCast(u32, index + dysymtab.ilocalsym), |
| 418 | 361 | }); |
| 419 | 362 | } |
| 420 | 363 | |
| 421 | | std.sort.sort(SymWithIndex, sorted_syms.items, {}, SymWithIndex.cmp); |
| 364 | std.sort.sort(NlistWithIndex, sorted_nlists.items, {}, NlistWithIndex.cmp); |
| 365 | |
| 366 | var last_block: ?*TextBlock = null; |
| 422 | 367 | |
| 423 | 368 | for (seg.sections.items) |sect, sect_id| { |
| 424 | | log.warn("section {s},{s}", .{ segmentName(sect), sectionName(sect) }); |
| 369 | log.warn("putting section '{s},{s}' as a TextBlock", .{ |
| 370 | segmentName(sect), |
| 371 | sectionName(sect), |
| 372 | }); |
| 425 | 373 | |
| 374 | // Get matching segment/section in the final artifact. |
| 426 | 375 | const match = (try zld.getMatchingSection(sect)) orelse { |
| 427 | 376 | log.warn("unhandled section", .{}); |
| 428 | 377 | continue; |
| 429 | 378 | }; |
| 430 | 379 | |
| 431 | | // Read code |
| 380 | // Read section's code |
| 432 | 381 | var code = try self.allocator.alloc(u8, @intCast(usize, sect.size)); |
| 433 | 382 | defer self.allocator.free(code); |
| 434 | 383 | _ = try self.file.?.preadAll(code, sect.offset); |
| 435 | 384 | |
| 436 | | // Read and parse relocs |
| 437 | | const raw_relocs = try self.allocator.alloc(u8, @sizeOf(macho.relocation_info) * sect.nreloc); |
| 438 | | defer self.allocator.free(raw_relocs); |
| 439 | | _ = try self.file.?.preadAll(raw_relocs, sect.reloff); |
| 440 | | const relocs = mem.bytesAsSlice(macho.relocation_info, raw_relocs); |
| 385 | // Is there any padding between symbols within the section? |
| 386 | const is_padded = self.header.?.flags & macho.MH_SUBSECTIONS_VIA_SYMBOLS != 0; |
| 441 | 387 | |
| 388 | // Section alignment will be the assumed alignment per symbol. |
| 442 | 389 | const alignment = sect.@"align"; |
| 443 | 390 | |
| 444 | | if (self.header.?.flags & macho.MH_SUBSECTIONS_VIA_SYMBOLS != 0) { |
| 445 | | const syms = SymWithIndex.filterSymsInSection(sorted_syms.items, @intCast(u8, sect_id + 1)); |
| 446 | | |
| 447 | | if (syms.len == 0) { |
| 448 | | // One large text block referenced by section offsets only |
| 449 | | log.warn("TextBlock", .{}); |
| 450 | | log.warn(" | referenced by section offsets", .{}); |
| 451 | | log.warn(" | start_addr = {}", .{sect.addr}); |
| 452 | | log.warn(" | end_addr = {}", .{sect.size}); |
| 453 | | log.warn(" | size = {}", .{sect.size}); |
| 454 | | log.warn(" | alignment = 0x{x}", .{alignment}); |
| 455 | | log.warn(" | segment_id = {}", .{match.seg}); |
| 456 | | log.warn(" | section_id = {}", .{match.sect}); |
| 457 | | log.warn(" | relocs: {any}", .{relocs}); |
| 458 | | } |
| 391 | next: { |
| 392 | if (is_padded) blocks: { |
| 393 | const filtered_nlists = NlistWithIndex.filterNlistsInSection( |
| 394 | sorted_nlists.items, |
| 395 | @intCast(u8, sect_id + 1), |
| 396 | ); |
| 397 | |
| 398 | if (filtered_nlists.len == 0) break :blocks; |
| 459 | 399 | |
| 460 | | var indices = std.ArrayList(u32).init(self.allocator); |
| 461 | | defer indices.deinit(); |
| 400 | var nlist_indices = std.ArrayList(u32).init(self.allocator); |
| 401 | defer nlist_indices.deinit(); |
| 462 | 402 | |
| 463 | | var i: u32 = 0; |
| 464 | | while (i < syms.len) : (i += 1) { |
| 465 | | const curr = syms[i]; |
| 466 | | try indices.append(i); |
| 403 | var i: u32 = 0; |
| 404 | while (i < filtered_nlists.len) : (i += 1) { |
| 405 | const curr = filtered_nlists[i]; |
| 406 | try nlist_indices.append(curr.index); |
| 467 | 407 | |
| 468 | | const next: ?SymWithIndex = if (i + 1 < syms.len) |
| 469 | | syms[i + 1] |
| 470 | | else |
| 471 | | null; |
| 408 | const next: ?NlistWithIndex = if (i + 1 < filtered_nlists.len) |
| 409 | filtered_nlists[i + 1] |
| 410 | else |
| 411 | null; |
| 472 | 412 | |
| 473 | | if (next) |n| { |
| 474 | | if (curr.nlist.n_value == n.nlist.n_value) { |
| 475 | | continue; |
| 413 | if (next) |n| { |
| 414 | if (curr.nlist.n_value == n.nlist.n_value) { |
| 415 | continue; |
| 416 | } |
| 476 | 417 | } |
| 477 | | } |
| 478 | 418 | |
| 479 | | const start_addr = curr.nlist.n_value - sect.addr; |
| 480 | | const end_addr = if (next) |n| n.nlist.n_value - sect.addr else sect.size; |
| 419 | // Bubble-up senior symbol as the main link to the text block. |
| 420 | for (nlist_indices.items) |*index| { |
| 421 | const sym = self.symbols.items[index.*]; |
| 422 | if (sym.payload != .regular) { |
| 423 | log.err("expected a regular symbol, found {s}", .{sym.payload}); |
| 424 | log.err(" when remapping {s}", .{sym.name}); |
| 425 | return error.SymbolIsNotRegular; |
| 426 | } |
| 427 | assert(sym.payload.regular.local_sym_index != 0); // This means the symbol has not been properly resolved. |
| 428 | index.* = sym.payload.regular.local_sym_index; |
| 429 | } |
| 481 | 430 | |
| 482 | | const tb_code = code[start_addr..end_addr]; |
| 483 | | const size = tb_code.len; |
| 431 | std.sort.sort(u32, nlist_indices.items, SeniorityContext{ .zld = zld }, cmpSymBySeniority); |
| 484 | 432 | |
| 485 | | log.warn("TextBlock", .{}); |
| 486 | | for (indices.items) |id| { |
| 487 | | const sym = self.symbols.items[syms[id].index]; |
| 488 | | log.warn(" | symbol = {s}", .{sym.name}); |
| 489 | | } |
| 490 | | log.warn(" | start_addr = {}", .{start_addr}); |
| 491 | | log.warn(" | end_addr = {}", .{end_addr}); |
| 492 | | log.warn(" | size = {}", .{size}); |
| 493 | | log.warn(" | alignment = 0x{x}", .{alignment}); |
| 494 | | log.warn(" | segment_id = {}", .{match.seg}); |
| 495 | | log.warn(" | section_id = {}", .{match.sect}); |
| 496 | | log.warn(" | relocs: {any}", .{SymWithIndex.filterRelocs(relocs, start_addr, end_addr)}); |
| 497 | | |
| 498 | | indices.clearRetainingCapacity(); |
| 499 | | } |
| 500 | | } else { |
| 501 | | return error.TODOOneLargeTextBlock; |
| 502 | | } |
| 503 | | } |
| 504 | | } |
| 433 | const local_sym_index = nlist_indices.pop(); |
| 434 | const sym = zld.locals.items[local_sym_index]; |
| 435 | if (sym.payload.regular.file) |file| { |
| 436 | if (file != self) { |
| 437 | log.warn("deduping definition of {s} in {s}", .{ sym.name, self.name.? }); |
| 438 | continue; |
| 439 | } |
| 440 | } |
| 505 | 441 | |
| 506 | | const SectionAsTextBlocksArgs = struct { |
| 507 | | sect: macho.section_64, |
| 508 | | code: []u8, |
| 509 | | subsections_via_symbols: bool = false, |
| 510 | | relocs: ?[]macho.relocation_info = null, |
| 511 | | segment_id: u16 = 0, |
| 512 | | section_id: u16 = 0, |
| 513 | | }; |
| 442 | const start_addr = curr.nlist.n_value - sect.addr; |
| 443 | const end_addr = if (next) |n| n.nlist.n_value - sect.addr else sect.size; |
| 444 | |
| 445 | const tb_code = code[start_addr..end_addr]; |
| 446 | const size = tb_code.len; |
| 447 | |
| 448 | const block = try self.allocator.create(TextBlock); |
| 449 | errdefer self.allocator.destroy(block); |
| 450 | |
| 451 | block.* = .{ |
| 452 | .local_sym_index = local_sym_index, |
| 453 | .aliases = std.ArrayList(u32).init(self.allocator), |
| 454 | .references = std.ArrayList(u32).init(self.allocator), |
| 455 | .code = tb_code, |
| 456 | .relocs = std.ArrayList(*Relocation).init(self.allocator), |
| 457 | .size = size, |
| 458 | .alignment = alignment, |
| 459 | .segment_id = match.seg, |
| 460 | .section_id = match.sect, |
| 461 | }; |
| 462 | try block.aliases.appendSlice(nlist_indices.items); |
| 463 | |
| 464 | // TODO parse relocs |
| 465 | |
| 466 | if (last_block) |last| { |
| 467 | last.next = block; |
| 468 | block.prev = last; |
| 469 | } |
| 470 | last_block = block; |
| 514 | 471 | |
| 515 | | fn sectionAsTextBlocks(self: *Object, args: SectionAsTextBlocksArgs) !*TextBlock { |
| 516 | | const sect = args.sect; |
| 472 | nlist_indices.clearRetainingCapacity(); |
| 473 | } |
| 517 | 474 | |
| 518 | | log.warn("putting section '{s},{s}' as a TextBlock", .{ segmentName(sect), sectionName(sect) }); |
| 475 | break :next; |
| 476 | } |
| 519 | 477 | |
| 520 | | // Section alignment will be the assumed alignment per symbol. |
| 521 | | const alignment = sect.@"align"; |
| 478 | // Since there is no symbol to refer to this block, we create |
| 479 | // a temp one. |
| 480 | const name = try std.fmt.allocPrint(self.allocator, "l_{s}_{s}_{s}", .{ |
| 481 | self.name.?, |
| 482 | segmentName(sect), |
| 483 | sectionName(sect), |
| 484 | }); |
| 485 | defer self.allocator.free(name); |
| 486 | const symbol = try Symbol.new(self.allocator, name); |
| 487 | symbol.payload = .{ |
| 488 | .regular = .{ |
| 489 | .linkage = .translation_unit, |
| 490 | .file = self, |
| 491 | }, |
| 492 | }; |
| 493 | const local_sym_index = @intCast(u32, zld.locals.items.len); |
| 494 | try zld.locals.append(zld.allocator, symbol); |
| 522 | 495 | |
| 523 | | const first_block: *TextBlock = blk: { |
| 524 | | if (args.subsections_via_symbols) { |
| 525 | | return error.TODO; |
| 526 | | } else { |
| 527 | 496 | const block = try self.allocator.create(TextBlock); |
| 528 | 497 | errdefer self.allocator.destroy(block); |
| 529 | 498 | |
| 530 | 499 | block.* = .{ |
| 531 | | .ref = .{ |
| 532 | | .section = undefined, // Will be populated when we allocated final sections. |
| 533 | | }, |
| 534 | | .code = args.code, |
| 535 | | .relocs = null, |
| 500 | .local_sym_index = local_sym_index, |
| 501 | .aliases = std.ArrayList(u32).init(self.allocator), |
| 502 | .references = std.ArrayList(u32).init(self.allocator), |
| 503 | .code = code, |
| 504 | .relocs = std.ArrayList(*Relocation).init(self.allocator), |
| 536 | 505 | .size = sect.size, |
| 537 | 506 | .alignment = alignment, |
| 538 | | .segment_id = args.segment_id, |
| 539 | | .section_id = args.section_id, |
| 507 | .segment_id = match.seg, |
| 508 | .section_id = match.sect, |
| 540 | 509 | }; |
| 541 | 510 | |
| 542 | 511 | // TODO parse relocs |
| 543 | | if (args.relocs) |relocs| { |
| 544 | | block.relocs = try reloc.parse(self.allocator, self.arch.?, args.code, relocs, symbols); |
| 545 | | } |
| 546 | 512 | |
| 547 | | break :blk block; |
| 513 | if (last_block) |last| { |
| 514 | last.next = block; |
| 515 | block.prev = last; |
| 516 | } |
| 517 | last_block = block; |
| 548 | 518 | } |
| 549 | | }; |
| 519 | } |
| 550 | 520 | |
| 551 | | return first_block; |
| 521 | return last_block; |
| 552 | 522 | } |
| 553 | 523 | |
| 554 | 524 | pub fn parseInitializers(self: *Object) !void { |