| ... | ... | @@ -8421,24 +8421,27 @@ fn prelinkInner(elf: *Elf) Error!void { |
| 8421 | 8421 | if (comp.zcu) |_| self_hosted_codegen: { |
| 8422 | 8422 | if (comp.config.use_llvm) break :self_hosted_codegen; |
| 8423 | 8423 | |
| 8424 | | // We're using self-hosted codegen---add an input representing the Zig "object". |
| 8425 | | try elf.inputs.ensureUnusedCapacity(gpa, 1); |
| 8426 | | const zcu_name = try std.fmt.allocPrint(gpa, "{s}_zcu", .{comp.root_name}); |
| 8427 | | defer gpa.free(zcu_name); |
| 8428 | | const zcu_file_symbol = try elf.addLocalSymbol(.{ |
| 8429 | | .node = .none, |
| 8430 | | .name = zcu_name, |
| 8431 | | .value = 0, |
| 8432 | | .size = 0, |
| 8433 | | .type = .FILE, |
| 8434 | | .shndx = .ABS, |
| 8435 | | }); |
| 8436 | | elf.inputs.addOneAssumeCapacity().* = .{ |
| 8437 | | .path = elf.base.emit, |
| 8438 | | .member = null, |
| 8439 | | .extra = .{ .file_symbol = zcu_file_symbol }, |
| 8440 | | }; |
| 8441 | | elf.input_pending_index += 1; |
| 8424 | if (elf.archive == null) { |
| 8425 | // Self-hosted codegen is logically emitting a relocatable which is then immediately |
| 8426 | // being linked into the output file, so add that fictional Zig object file input. |
| 8427 | try elf.inputs.ensureUnusedCapacity(gpa, 1); |
| 8428 | const zcu_name = try std.fmt.allocPrint(gpa, "{s}_zcu", .{comp.root_name}); |
| 8429 | defer gpa.free(zcu_name); |
| 8430 | const zcu_file_symbol = try elf.addLocalSymbol(.{ |
| 8431 | .node = .none, |
| 8432 | .name = zcu_name, |
| 8433 | .value = 0, |
| 8434 | .size = 0, |
| 8435 | .type = .FILE, |
| 8436 | .shndx = .ABS, |
| 8437 | }); |
| 8438 | elf.inputs.addOneAssumeCapacity().* = .{ |
| 8439 | .path = elf.base.emit, |
| 8440 | .member = null, |
| 8441 | .extra = .{ .file_symbol = zcu_file_symbol }, |
| 8442 | }; |
| 8443 | elf.input_pending_index += 1; |
| 8444 | } |
| 8442 | 8445 | |
| 8443 | 8446 | switch (elf.shndx.debug_addr) { |
| 8444 | 8447 | .UNDEF => {}, |