link.Elf: fix merge sections namespacing

`link.Elf.merge_section.MergeSection` -> `link.Elf.Merge.Section`
This commit is contained in:
Andrew Kelley 2024-10-10 18:34:54 -07:00
parent 2c4e05eda7
commit 7b69738a06
5 changed files with 61 additions and 62 deletions

View File

@ -603,18 +603,18 @@ set(ZIG_STAGE2_SOURCES
src/link/Elf/AtomList.zig src/link/Elf/AtomList.zig
src/link/Elf/LdScript.zig src/link/Elf/LdScript.zig
src/link/Elf/LinkerDefined.zig src/link/Elf/LinkerDefined.zig
src/link/Elf/Merge.zig
src/link/Elf/Object.zig src/link/Elf/Object.zig
src/link/Elf/SharedObject.zig src/link/Elf/SharedObject.zig
src/link/Elf/Symbol.zig src/link/Elf/Symbol.zig
src/link/Elf/Thunk.zig
src/link/Elf/ZigObject.zig src/link/Elf/ZigObject.zig
src/link/Elf/eh_frame.zig src/link/Elf/eh_frame.zig
src/link/Elf/file.zig src/link/Elf/file.zig
src/link/Elf/gc.zig src/link/Elf/gc.zig
src/link/Elf/merge_section.zig
src/link/Elf/relocatable.zig src/link/Elf/relocatable.zig
src/link/Elf/relocation.zig src/link/Elf/relocation.zig
src/link/Elf/synthetic_sections.zig src/link/Elf/synthetic_sections.zig
src/link/Elf/Thunk.zig
src/link/MachO.zig src/link/MachO.zig
src/link/MachO/Archive.zig src/link/MachO/Archive.zig
src/link/MachO/Atom.zig src/link/MachO/Atom.zig

View File

@ -1,3 +1,5 @@
pub const Atom = @import("Elf/Atom.zig");
base: link.File, base: link.File,
rpath_table: std.StringArrayHashMapUnmanaged(void), rpath_table: std.StringArrayHashMapUnmanaged(void),
image_base: u64, image_base: u64,
@ -109,8 +111,8 @@ num_ifunc_dynrelocs: usize = 0,
thunks: std.ArrayListUnmanaged(Thunk) = .empty, thunks: std.ArrayListUnmanaged(Thunk) = .empty,
/// List of output merge sections with deduped contents. /// List of output merge sections with deduped contents.
merge_sections: std.ArrayListUnmanaged(MergeSection) = .empty, merge_sections: std.ArrayListUnmanaged(Merge.Section) = .empty,
comment_merge_section_index: ?MergeSection.Index = null, comment_merge_section_index: ?Merge.Section.Index = null,
first_eflags: ?elf.Elf64_Word = null, first_eflags: ?elf.Elf64_Word = null,
@ -4726,7 +4728,7 @@ pub fn linkerDefinedPtr(self: *Elf) ?*LinkerDefined {
return self.file(index).?.linker_defined; return self.file(index).?.linker_defined;
} }
pub fn getOrCreateMergeSection(self: *Elf, name: [:0]const u8, flags: u64, @"type": u32) !MergeSection.Index { pub fn getOrCreateMergeSection(self: *Elf, name: [:0]const u8, flags: u64, @"type": u32) !Merge.Section.Index {
const gpa = self.base.comp.gpa; const gpa = self.base.comp.gpa;
const out_name = name: { const out_name = name: {
if (self.base.isRelocatable()) break :name name; if (self.base.isRelocatable()) break :name name;
@ -4739,7 +4741,7 @@ pub fn getOrCreateMergeSection(self: *Elf, name: [:0]const u8, flags: u64, @"typ
} }
const out_off = try self.insertShString(out_name); const out_off = try self.insertShString(out_name);
const out_flags = flags & ~@as(u64, elf.SHF_COMPRESSED | elf.SHF_GROUP); const out_flags = flags & ~@as(u64, elf.SHF_COMPRESSED | elf.SHF_GROUP);
const index = @as(MergeSection.Index, @intCast(self.merge_sections.items.len)); const index: Merge.Section.Index = @intCast(self.merge_sections.items.len);
const msec = try self.merge_sections.addOne(gpa); const msec = try self.merge_sections.addOne(gpa);
msec.* = .{ msec.* = .{
.name_offset = out_off, .name_offset = out_off,
@ -4749,7 +4751,7 @@ pub fn getOrCreateMergeSection(self: *Elf, name: [:0]const u8, flags: u64, @"typ
return index; return index;
} }
pub fn mergeSection(self: *Elf, index: MergeSection.Index) *MergeSection { pub fn mergeSection(self: *Elf, index: Merge.Section.Index) *Merge.Section {
assert(index < self.merge_sections.items.len); assert(index < self.merge_sections.items.len);
return &self.merge_sections.items[index]; return &self.merge_sections.items[index];
} }
@ -5541,6 +5543,9 @@ const relocs_log = std.log.scoped(.link_relocs);
const state_log = std.log.scoped(.link_state); const state_log = std.log.scoped(.link_state);
const math = std.math; const math = std.math;
const mem = std.mem; const mem = std.mem;
const Allocator = std.mem.Allocator;
const Cache = std.Build.Cache;
const Hash = std.hash.Wyhash;
const codegen = @import("../codegen.zig"); const codegen = @import("../codegen.zig");
const dev = @import("../dev.zig"); const dev = @import("../dev.zig");
@ -5548,7 +5553,6 @@ const eh_frame = @import("Elf/eh_frame.zig");
const gc = @import("Elf/gc.zig"); const gc = @import("Elf/gc.zig");
const glibc = @import("../glibc.zig"); const glibc = @import("../glibc.zig");
const link = @import("../link.zig"); const link = @import("../link.zig");
const merge_section = @import("Elf/merge_section.zig");
const musl = @import("../musl.zig"); const musl = @import("../musl.zig");
const relocatable = @import("Elf/relocatable.zig"); const relocatable = @import("Elf/relocatable.zig");
const relocation = @import("Elf/relocation.zig"); const relocation = @import("Elf/relocation.zig");
@ -5556,12 +5560,10 @@ const target_util = @import("../target.zig");
const trace = @import("../tracy.zig").trace; const trace = @import("../tracy.zig").trace;
const synthetic_sections = @import("Elf/synthetic_sections.zig"); const synthetic_sections = @import("Elf/synthetic_sections.zig");
const Merge = @import("Elf/Merge.zig");
const Air = @import("../Air.zig"); const Air = @import("../Air.zig");
const Allocator = std.mem.Allocator;
const Archive = @import("Elf/Archive.zig"); const Archive = @import("Elf/Archive.zig");
pub const Atom = @import("Elf/Atom.zig");
const AtomList = @import("Elf/AtomList.zig"); const AtomList = @import("Elf/AtomList.zig");
const Cache = std.Build.Cache;
const Path = Cache.Path; const Path = Cache.Path;
const Compilation = @import("../Compilation.zig"); const Compilation = @import("../Compilation.zig");
const ComdatGroupSection = synthetic_sections.ComdatGroupSection; const ComdatGroupSection = synthetic_sections.ComdatGroupSection;
@ -5574,15 +5576,11 @@ const File = @import("Elf/file.zig").File;
const GnuHashSection = synthetic_sections.GnuHashSection; const GnuHashSection = synthetic_sections.GnuHashSection;
const GotSection = synthetic_sections.GotSection; const GotSection = synthetic_sections.GotSection;
const GotPltSection = synthetic_sections.GotPltSection; const GotPltSection = synthetic_sections.GotPltSection;
const Hash = std.hash.Wyhash;
const HashSection = synthetic_sections.HashSection; const HashSection = synthetic_sections.HashSection;
const InputMergeSection = merge_section.InputMergeSection;
const LdScript = @import("Elf/LdScript.zig"); const LdScript = @import("Elf/LdScript.zig");
const LinkerDefined = @import("Elf/LinkerDefined.zig"); const LinkerDefined = @import("Elf/LinkerDefined.zig");
const Liveness = @import("../Liveness.zig"); const Liveness = @import("../Liveness.zig");
const LlvmObject = @import("../codegen/llvm.zig").Object; const LlvmObject = @import("../codegen/llvm.zig").Object;
const MergeSection = merge_section.MergeSection;
const MergeSubsection = merge_section.MergeSubsection;
const Zcu = @import("../Zcu.zig"); const Zcu = @import("../Zcu.zig");
const Object = @import("Elf/Object.zig"); const Object = @import("Elf/Object.zig");
const InternPool = @import("../InternPool.zig"); const InternPool = @import("../InternPool.zig");

View File

@ -1,4 +1,4 @@
pub const MergeSection = struct { pub const Section = struct {
value: u64 = 0, value: u64 = 0,
size: u64 = 0, size: u64 = 0,
alignment: Atom.Alignment = .@"1", alignment: Atom.Alignment = .@"1",
@ -10,25 +10,25 @@ pub const MergeSection = struct {
bytes: std.ArrayListUnmanaged(u8) = .empty, bytes: std.ArrayListUnmanaged(u8) = .empty,
table: std.HashMapUnmanaged( table: std.HashMapUnmanaged(
String, String,
MergeSubsection.Index, Subsection.Index,
IndexContext, IndexContext,
std.hash_map.default_max_load_percentage, std.hash_map.default_max_load_percentage,
) = .{}, ) = .{},
subsections: std.ArrayListUnmanaged(MergeSubsection) = .empty, subsections: std.ArrayListUnmanaged(Subsection) = .empty,
finalized_subsections: std.ArrayListUnmanaged(MergeSubsection.Index) = .empty, finalized_subsections: std.ArrayListUnmanaged(Subsection.Index) = .empty,
pub fn deinit(msec: *MergeSection, allocator: Allocator) void { pub fn deinit(msec: *Section, allocator: Allocator) void {
msec.bytes.deinit(allocator); msec.bytes.deinit(allocator);
msec.table.deinit(allocator); msec.table.deinit(allocator);
msec.subsections.deinit(allocator); msec.subsections.deinit(allocator);
msec.finalized_subsections.deinit(allocator); msec.finalized_subsections.deinit(allocator);
} }
pub fn name(msec: MergeSection, elf_file: *Elf) [:0]const u8 { pub fn name(msec: Section, elf_file: *Elf) [:0]const u8 {
return elf_file.getShString(msec.name_offset); return elf_file.getShString(msec.name_offset);
} }
pub fn address(msec: MergeSection, elf_file: *Elf) i64 { pub fn address(msec: Section, elf_file: *Elf) i64 {
const shdr = elf_file.sections.items(.shdr)[msec.output_section_index]; const shdr = elf_file.sections.items(.shdr)[msec.output_section_index];
return @intCast(shdr.sh_addr + msec.value); return @intCast(shdr.sh_addr + msec.value);
} }
@ -36,10 +36,10 @@ pub const MergeSection = struct {
const InsertResult = struct { const InsertResult = struct {
found_existing: bool, found_existing: bool,
key: String, key: String,
sub: *MergeSubsection.Index, sub: *Subsection.Index,
}; };
pub fn insert(msec: *MergeSection, allocator: Allocator, string: []const u8) !InsertResult { pub fn insert(msec: *Section, allocator: Allocator, string: []const u8) !InsertResult {
const gop = try msec.table.getOrPutContextAdapted( const gop = try msec.table.getOrPutContextAdapted(
allocator, allocator,
string, string,
@ -54,7 +54,7 @@ pub const MergeSection = struct {
return .{ .found_existing = gop.found_existing, .key = gop.key_ptr.*, .sub = gop.value_ptr }; return .{ .found_existing = gop.found_existing, .key = gop.key_ptr.*, .sub = gop.value_ptr };
} }
pub fn insertZ(msec: *MergeSection, allocator: Allocator, string: []const u8) !InsertResult { pub fn insertZ(msec: *Section, allocator: Allocator, string: []const u8) !InsertResult {
const with_null = try allocator.alloc(u8, string.len + 1); const with_null = try allocator.alloc(u8, string.len + 1);
defer allocator.free(with_null); defer allocator.free(with_null);
@memcpy(with_null[0..string.len], string); @memcpy(with_null[0..string.len], string);
@ -64,7 +64,7 @@ pub const MergeSection = struct {
/// Finalizes the merge section and clears hash table. /// Finalizes the merge section and clears hash table.
/// Sorts all owned subsections. /// Sorts all owned subsections.
pub fn finalize(msec: *MergeSection, allocator: Allocator) !void { pub fn finalize(msec: *Section, allocator: Allocator) !void {
try msec.finalized_subsections.ensureTotalCapacityPrecise(allocator, msec.subsections.items.len); try msec.finalized_subsections.ensureTotalCapacityPrecise(allocator, msec.subsections.items.len);
var it = msec.table.iterator(); var it = msec.table.iterator();
@ -76,7 +76,7 @@ pub const MergeSection = struct {
msec.table.clearAndFree(allocator); msec.table.clearAndFree(allocator);
const sortFn = struct { const sortFn = struct {
pub fn sortFn(ctx: *MergeSection, lhs: MergeSubsection.Index, rhs: MergeSubsection.Index) bool { pub fn sortFn(ctx: *Section, lhs: Subsection.Index, rhs: Subsection.Index) bool {
const lhs_msub = ctx.mergeSubsection(lhs); const lhs_msub = ctx.mergeSubsection(lhs);
const rhs_msub = ctx.mergeSubsection(rhs); const rhs_msub = ctx.mergeSubsection(rhs);
if (lhs_msub.alignment.compareStrict(.eq, rhs_msub.alignment)) { if (lhs_msub.alignment.compareStrict(.eq, rhs_msub.alignment)) {
@ -91,10 +91,10 @@ pub const MergeSection = struct {
} }
}.sortFn; }.sortFn;
std.mem.sort(MergeSubsection.Index, msec.finalized_subsections.items, msec, sortFn); std.mem.sort(Subsection.Index, msec.finalized_subsections.items, msec, sortFn);
} }
pub fn updateSize(msec: *MergeSection) void { pub fn updateSize(msec: *Section) void {
// TODO a 'stale' flag would be better here perhaps? // TODO a 'stale' flag would be better here perhaps?
msec.size = 0; msec.size = 0;
msec.alignment = .@"1"; msec.alignment = .@"1";
@ -111,7 +111,7 @@ pub const MergeSection = struct {
} }
} }
pub fn initOutputSection(msec: *MergeSection, elf_file: *Elf) !void { pub fn initOutputSection(msec: *Section, elf_file: *Elf) !void {
msec.output_section_index = elf_file.sectionByName(msec.name(elf_file)) orelse try elf_file.addSection(.{ msec.output_section_index = elf_file.sectionByName(msec.name(elf_file)) orelse try elf_file.addSection(.{
.name = msec.name_offset, .name = msec.name_offset,
.type = msec.type, .type = msec.type,
@ -119,14 +119,14 @@ pub const MergeSection = struct {
}); });
} }
pub fn addMergeSubsection(msec: *MergeSection, allocator: Allocator) !MergeSubsection.Index { pub fn addMergeSubsection(msec: *Section, allocator: Allocator) !Subsection.Index {
const index: MergeSubsection.Index = @intCast(msec.subsections.items.len); const index: Subsection.Index = @intCast(msec.subsections.items.len);
const msub = try msec.subsections.addOne(allocator); const msub = try msec.subsections.addOne(allocator);
msub.* = .{}; msub.* = .{};
return index; return index;
} }
pub fn mergeSubsection(msec: *MergeSection, index: MergeSubsection.Index) *MergeSubsection { pub fn mergeSubsection(msec: *Section, index: Subsection.Index) *Subsection {
assert(index < msec.subsections.items.len); assert(index < msec.subsections.items.len);
return &msec.subsections.items[index]; return &msec.subsections.items[index];
} }
@ -158,7 +158,7 @@ pub const MergeSection = struct {
}; };
pub fn format( pub fn format(
msec: MergeSection, msec: Section,
comptime unused_fmt_string: []const u8, comptime unused_fmt_string: []const u8,
options: std.fmt.FormatOptions, options: std.fmt.FormatOptions,
writer: anytype, writer: anytype,
@ -167,10 +167,10 @@ pub const MergeSection = struct {
_ = unused_fmt_string; _ = unused_fmt_string;
_ = options; _ = options;
_ = writer; _ = writer;
@compileError("do not format MergeSection directly"); @compileError("do not format directly");
} }
pub fn fmt(msec: MergeSection, elf_file: *Elf) std.fmt.Formatter(format2) { pub fn fmt(msec: Section, elf_file: *Elf) std.fmt.Formatter(format2) {
return .{ .data = .{ return .{ .data = .{
.msec = msec, .msec = msec,
.elf_file = elf_file, .elf_file = elf_file,
@ -178,7 +178,7 @@ pub const MergeSection = struct {
} }
const FormatContext = struct { const FormatContext = struct {
msec: MergeSection, msec: Section,
elf_file: *Elf, elf_file: *Elf,
}; };
@ -209,30 +209,30 @@ pub const MergeSection = struct {
pub const Index = u32; pub const Index = u32;
}; };
pub const MergeSubsection = struct { pub const Subsection = struct {
value: i64 = 0, value: i64 = 0,
merge_section_index: MergeSection.Index = 0, merge_section_index: Section.Index = 0,
string_index: u32 = 0, string_index: u32 = 0,
size: u32 = 0, size: u32 = 0,
alignment: Atom.Alignment = .@"1", alignment: Atom.Alignment = .@"1",
entsize: u32 = 0, entsize: u32 = 0,
alive: bool = false, alive: bool = false,
pub fn address(msub: MergeSubsection, elf_file: *Elf) i64 { pub fn address(msub: Subsection, elf_file: *Elf) i64 {
return msub.mergeSection(elf_file).address(elf_file) + msub.value; return msub.mergeSection(elf_file).address(elf_file) + msub.value;
} }
pub fn mergeSection(msub: MergeSubsection, elf_file: *Elf) *MergeSection { pub fn mergeSection(msub: Subsection, elf_file: *Elf) *Section {
return elf_file.mergeSection(msub.merge_section_index); return elf_file.mergeSection(msub.merge_section_index);
} }
pub fn getString(msub: MergeSubsection, elf_file: *Elf) []const u8 { pub fn getString(msub: Subsection, elf_file: *Elf) []const u8 {
const msec = msub.mergeSection(elf_file); const msec = msub.mergeSection(elf_file);
return msec.bytes.items[msub.string_index..][0..msub.size]; return msec.bytes.items[msub.string_index..][0..msub.size];
} }
pub fn format( pub fn format(
msub: MergeSubsection, msub: Subsection,
comptime unused_fmt_string: []const u8, comptime unused_fmt_string: []const u8,
options: std.fmt.FormatOptions, options: std.fmt.FormatOptions,
writer: anytype, writer: anytype,
@ -241,10 +241,10 @@ pub const MergeSubsection = struct {
_ = unused_fmt_string; _ = unused_fmt_string;
_ = options; _ = options;
_ = writer; _ = writer;
@compileError("do not format MergeSubsection directly"); @compileError("do not format directly");
} }
pub fn fmt(msub: MergeSubsection, elf_file: *Elf) std.fmt.Formatter(format2) { pub fn fmt(msub: Subsection, elf_file: *Elf) std.fmt.Formatter(format2) {
return .{ .data = .{ return .{ .data = .{
.msub = msub, .msub = msub,
.elf_file = elf_file, .elf_file = elf_file,
@ -252,7 +252,7 @@ pub const MergeSubsection = struct {
} }
const FormatContext = struct { const FormatContext = struct {
msub: MergeSubsection, msub: Subsection,
elf_file: *Elf, elf_file: *Elf,
}; };
@ -277,32 +277,32 @@ pub const MergeSubsection = struct {
pub const Index = u32; pub const Index = u32;
}; };
pub const InputMergeSection = struct { pub const InputSection = struct {
merge_section_index: MergeSection.Index = 0, merge_section_index: Section.Index = 0,
atom_index: Atom.Index = 0, atom_index: Atom.Index = 0,
offsets: std.ArrayListUnmanaged(u32) = .empty, offsets: std.ArrayListUnmanaged(u32) = .empty,
subsections: std.ArrayListUnmanaged(MergeSubsection.Index) = .empty, subsections: std.ArrayListUnmanaged(Subsection.Index) = .empty,
bytes: std.ArrayListUnmanaged(u8) = .empty, bytes: std.ArrayListUnmanaged(u8) = .empty,
strings: std.ArrayListUnmanaged(String) = .empty, strings: std.ArrayListUnmanaged(String) = .empty,
pub fn deinit(imsec: *InputMergeSection, allocator: Allocator) void { pub fn deinit(imsec: *InputSection, allocator: Allocator) void {
imsec.offsets.deinit(allocator); imsec.offsets.deinit(allocator);
imsec.subsections.deinit(allocator); imsec.subsections.deinit(allocator);
imsec.bytes.deinit(allocator); imsec.bytes.deinit(allocator);
imsec.strings.deinit(allocator); imsec.strings.deinit(allocator);
} }
pub fn clearAndFree(imsec: *InputMergeSection, allocator: Allocator) void { pub fn clearAndFree(imsec: *InputSection, allocator: Allocator) void {
imsec.bytes.clearAndFree(allocator); imsec.bytes.clearAndFree(allocator);
// TODO: imsec.strings.clearAndFree(allocator); // TODO: imsec.strings.clearAndFree(allocator);
} }
const FindSubsectionResult = struct { const FindSubsectionResult = struct {
msub_index: MergeSubsection.Index, msub_index: Subsection.Index,
offset: u32, offset: u32,
}; };
pub fn findSubsection(imsec: InputMergeSection, offset: u32) ?FindSubsectionResult { pub fn findSubsection(imsec: InputSection, offset: u32) ?FindSubsectionResult {
// TODO: binary search // TODO: binary search
for (imsec.offsets.items, 0..) |off, index| { for (imsec.offsets.items, 0..) |off, index| {
if (offset < off) return .{ if (offset < off) return .{
@ -320,7 +320,7 @@ pub const InputMergeSection = struct {
return null; return null;
} }
pub fn insert(imsec: *InputMergeSection, allocator: Allocator, string: []const u8) !void { pub fn insert(imsec: *InputSection, allocator: Allocator, string: []const u8) !void {
const index: u32 = @intCast(imsec.bytes.items.len); const index: u32 = @intCast(imsec.bytes.items.len);
try imsec.bytes.appendSlice(allocator, string); try imsec.bytes.appendSlice(allocator, string);
try imsec.strings.append(allocator, .{ .pos = index, .len = @intCast(string.len) }); try imsec.strings.append(allocator, .{ .pos = index, .len = @intCast(string.len) });
@ -338,3 +338,4 @@ const std = @import("std");
const Allocator = mem.Allocator; const Allocator = mem.Allocator;
const Atom = @import("Atom.zig"); const Atom = @import("Atom.zig");
const Elf = @import("../Elf.zig"); const Elf = @import("../Elf.zig");
const Merge = @This();

View File

@ -23,8 +23,8 @@ atoms_extra: std.ArrayListUnmanaged(u32) = .empty,
comdat_groups: std.ArrayListUnmanaged(Elf.ComdatGroup) = .empty, comdat_groups: std.ArrayListUnmanaged(Elf.ComdatGroup) = .empty,
comdat_group_data: std.ArrayListUnmanaged(u32) = .empty, comdat_group_data: std.ArrayListUnmanaged(u32) = .empty,
input_merge_sections: std.ArrayListUnmanaged(InputMergeSection) = .empty, input_merge_sections: std.ArrayListUnmanaged(Merge.InputSection) = .empty,
input_merge_sections_indexes: std.ArrayListUnmanaged(InputMergeSection.Index) = .empty, input_merge_sections_indexes: std.ArrayListUnmanaged(Merge.InputSection.Index) = .empty,
fdes: std.ArrayListUnmanaged(Fde) = .empty, fdes: std.ArrayListUnmanaged(Fde) = .empty,
cies: std.ArrayListUnmanaged(Cie) = .empty, cies: std.ArrayListUnmanaged(Cie) = .empty,
@ -1305,14 +1305,14 @@ fn setAtomFields(o: *Object, atom_ptr: *Atom, opts: Atom.Extra.AsOptionals) void
o.setAtomExtra(atom_ptr.extra_index, extras); o.setAtomExtra(atom_ptr.extra_index, extras);
} }
fn addInputMergeSection(self: *Object, allocator: Allocator) !InputMergeSection.Index { fn addInputMergeSection(self: *Object, allocator: Allocator) !Merge.InputSection.Index {
const index: InputMergeSection.Index = @intCast(self.input_merge_sections.items.len); const index: Merge.InputSection.Index = @intCast(self.input_merge_sections.items.len);
const msec = try self.input_merge_sections.addOne(allocator); const msec = try self.input_merge_sections.addOne(allocator);
msec.* = .{}; msec.* = .{};
return index; return index;
} }
fn inputMergeSection(self: *Object, index: InputMergeSection.Index) ?*InputMergeSection { fn inputMergeSection(self: *Object, index: Merge.InputSection.Index) ?*Merge.InputSection {
if (index == 0) return null; if (index == 0) return null;
return &self.input_merge_sections.items[index]; return &self.input_merge_sections.items[index];
} }
@ -1522,6 +1522,6 @@ const Cie = eh_frame.Cie;
const Elf = @import("../Elf.zig"); const Elf = @import("../Elf.zig");
const Fde = eh_frame.Fde; const Fde = eh_frame.Fde;
const File = @import("file.zig").File; const File = @import("file.zig").File;
const InputMergeSection = @import("merge_section.zig").InputMergeSection; const Merge = @import("Merge.zig");
const Symbol = @import("Symbol.zig"); const Symbol = @import("Symbol.zig");
const Alignment = Atom.Alignment; const Alignment = Atom.Alignment;

View File

@ -74,7 +74,7 @@ pub fn atom(symbol: Symbol, elf_file: *Elf) ?*Atom {
return file_ptr.atom(symbol.ref.index); return file_ptr.atom(symbol.ref.index);
} }
pub fn mergeSubsection(symbol: Symbol, elf_file: *Elf) ?*MergeSubsection { pub fn mergeSubsection(symbol: Symbol, elf_file: *Elf) ?*Merge.Subsection {
if (!symbol.flags.merge_subsection) return null; if (!symbol.flags.merge_subsection) return null;
const msec = elf_file.mergeSection(symbol.ref.file); const msec = elf_file.mergeSection(symbol.ref.file);
return msec.mergeSubsection(symbol.ref.index); return msec.mergeSubsection(symbol.ref.index);
@ -493,7 +493,7 @@ const File = @import("file.zig").File;
const GotSection = synthetic_sections.GotSection; const GotSection = synthetic_sections.GotSection;
const GotPltSection = synthetic_sections.GotPltSection; const GotPltSection = synthetic_sections.GotPltSection;
const LinkerDefined = @import("LinkerDefined.zig"); const LinkerDefined = @import("LinkerDefined.zig");
const MergeSubsection = @import("merge_section.zig").MergeSubsection; const Merge = @import("Merge.zig");
const Object = @import("Object.zig"); const Object = @import("Object.zig");
const PltSection = synthetic_sections.PltSection; const PltSection = synthetic_sections.PltSection;
const PltGotSection = synthetic_sections.PltGotSection; const PltGotSection = synthetic_sections.PltGotSection;