| ... | ... | @@ -3730,33 +3730,37 @@ fn addRelocAssumeCapacity( |
| 3730 | 3730 | break :sti .none; |
| 3731 | 3731 | } else .none; |
| 3732 | 3732 | |
| 3733 | | const section = loc_sn.section(coff); |
| 3734 | | const header = loc_sn.header(coff); |
| 3735 | | const old_num_relocations = coff.targetLoad(&header.number_of_relocations); |
| 3736 | | const new_num_relocations = old_num_relocations + 1; |
| 3737 | | const new_size = new_num_relocations * std.coff.Relocation.sizeOf(); |
| 3738 | | if (section.relocation_table_ni == .none) { |
| 3739 | | section.relocation_table_ni = try coff.mf.addLastChildNode( |
| 3740 | | gpa, |
| 3741 | | coff.sectionParent(), |
| 3742 | | .{ |
| 3743 | | .size = new_size, |
| 3744 | | .alignment = .@"2", |
| 3745 | | .moved = true, |
| 3746 | | .resized = true, |
| 3747 | | }, |
| 3748 | | ); |
| 3749 | | coff.nodes.appendAssumeCapacity(.{ .relocation_table = loc_sn }); |
| 3750 | | } else { |
| 3751 | | try section.relocation_table_ni.resize(&coff.mf, gpa, new_size); |
| 3752 | | } |
| 3733 | const sri: Section.RelocationIndex = blk: { |
| 3734 | const section = loc_sn.section(coff); |
| 3735 | const header = loc_sn.header(coff); |
| 3736 | const old_num_relocations = coff.targetLoad(&header.number_of_relocations); |
| 3737 | const new_num_relocations = old_num_relocations + 1; |
| 3738 | const new_size = new_num_relocations * std.coff.Relocation.sizeOf(); |
| 3739 | |
| 3740 | coff.targetStore(&header.number_of_relocations, new_num_relocations); |
| 3741 | if (coff.symbolTableSectionAuxEntryPtr(loc_sn.symbol(coff).sti(coff))) |aux_ptr| |
| 3742 | coff.targetStore(&aux_ptr.number_of_relocations, new_num_relocations); |
| 3743 | |
| 3744 | if (section.relocation_table_ni == .none) { |
| 3745 | section.relocation_table_ni = try coff.mf.addLastChildNode( |
| 3746 | gpa, |
| 3747 | coff.sectionParent(), |
| 3748 | .{ |
| 3749 | .size = new_size, |
| 3750 | .alignment = .@"2", |
| 3751 | .moved = true, |
| 3752 | .resized = true, |
| 3753 | }, |
| 3754 | ); |
| 3755 | coff.nodes.appendAssumeCapacity(.{ .relocation_table = loc_sn }); |
| 3756 | } else { |
| 3757 | try section.relocation_table_ni.resize(&coff.mf, gpa, new_size); |
| 3758 | } |
| 3753 | 3759 | |
| 3754 | | coff.targetStore(&header.number_of_relocations, new_num_relocations); |
| 3755 | | if (coff.symbolTableSectionAuxEntryPtr(loc_sn.symbol(coff).sti(coff))) |aux_ptr| |
| 3756 | | coff.targetStore(&aux_ptr.number_of_relocations, new_num_relocations); |
| 3760 | // TODO: These need to allocate from a free list, once deleting relocs from the table is supported |
| 3761 | break :blk .wrap(old_num_relocations); |
| 3762 | }; |
| 3757 | 3763 | |
| 3758 | | // TODO: These need to allocate from a free list, once deleting relocs is supported |
| 3759 | | const sri: Section.RelocationIndex = .wrap(old_num_relocations); |
| 3760 | 3764 | const entry = sri.entry(coff, loc_sn).?; |
| 3761 | 3765 | if (sti.unwrap()) |index| coff.targetStore(&entry.symbol_table_index, index); |
| 3762 | 3766 | |