mirror of
https://github.com/ziglang/zig.git
synced 2026-01-14 03:15:14 +00:00
fix more compilation errors introduced by this branch
This commit is contained in:
parent
638db680f4
commit
48d5861f92
@ -893,6 +893,12 @@ const CacheUse = union(CacheMode) {
|
||||
whole.lock = null;
|
||||
}
|
||||
}
|
||||
|
||||
fn moveLock(whole: *Whole) Cache.Lock {
|
||||
const result = whole.lock.?;
|
||||
whole.lock = null;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
const Incremental = struct {
|
||||
@ -939,7 +945,9 @@ pub const InitOptions = struct {
|
||||
main_mod: ?*Package.Module = null,
|
||||
/// This is provided so that the API user has a chance to tweak the
|
||||
/// per-module settings of the standard library.
|
||||
std_mod: *Package.Module,
|
||||
/// When this is null, a default configuration of the std lib is created
|
||||
/// based on the settings of root_mod.
|
||||
std_mod: ?*Package.Module = null,
|
||||
root_name: []const u8,
|
||||
sysroot: ?[]const u8 = null,
|
||||
/// `null` means to not emit a binary file.
|
||||
@ -1381,13 +1389,30 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
|
||||
break :eh eh;
|
||||
} else null;
|
||||
|
||||
const std_mod = options.std_mod orelse try Package.Module.create(arena, .{
|
||||
.global_cache_directory = options.global_cache_directory,
|
||||
.paths = .{
|
||||
.root = .{
|
||||
.root_dir = options.zig_lib_directory,
|
||||
.sub_path = "std",
|
||||
},
|
||||
.root_src_path = "std.zig",
|
||||
},
|
||||
.fully_qualified_name = "std",
|
||||
.cc_argv = &.{},
|
||||
.inherited = .{},
|
||||
.global = options.config,
|
||||
.parent = options.root_mod,
|
||||
.builtin_mod = options.root_mod.deps.get("builtin").?,
|
||||
});
|
||||
|
||||
const zcu = try arena.create(Module);
|
||||
zcu.* = .{
|
||||
.gpa = gpa,
|
||||
.comp = comp,
|
||||
.main_mod = options.main_mod orelse options.root_mod,
|
||||
.root_mod = options.root_mod,
|
||||
.std_mod = options.std_mod,
|
||||
.std_mod = std_mod,
|
||||
.global_zir_cache = global_zir_cache,
|
||||
.local_zir_cache = local_zir_cache,
|
||||
.emit_h = emit_h,
|
||||
@ -6215,7 +6240,7 @@ fn buildOutputFromZig(
|
||||
.full_object_path = try sub_compilation.bin_file.?.emit.directory.join(gpa, &.{
|
||||
sub_compilation.bin_file.?.emit.sub_path,
|
||||
}),
|
||||
.lock = sub_compilation.bin_file.toOwnedLock(),
|
||||
.lock = sub_compilation.bin_file.?.toOwnedLock(),
|
||||
};
|
||||
}
|
||||
|
||||
@ -6317,13 +6342,16 @@ pub fn build_crt_file(
|
||||
try comp.updateSubCompilation(sub_compilation, misc_task_tag, prog_node);
|
||||
|
||||
try comp.crt_files.ensureUnusedCapacity(gpa, 1);
|
||||
comp.crt_files.putAssumeCapacityNoClobber(basename, try sub_compilation.toCrtFile());
|
||||
}
|
||||
|
||||
comp.crt_files.putAssumeCapacityNoClobber(basename, .{
|
||||
.full_object_path = try sub_compilation.bin_file.?.emit.directory.join(gpa, &.{
|
||||
sub_compilation.bin_file.?.emit.sub_path,
|
||||
pub fn toCrtFile(comp: *Compilation) Allocator.Error!CRTFile {
|
||||
return .{
|
||||
.full_object_path = try comp.local_cache_directory.join(comp.gpa, &.{
|
||||
comp.cache_use.whole.bin_sub_path.?,
|
||||
}),
|
||||
.lock = sub_compilation.bin_file.toOwnedLock(),
|
||||
});
|
||||
.lock = comp.cache_use.whole.moveLock(),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn addLinkLib(comp: *Compilation, lib_name: []const u8) !void {
|
||||
|
||||
@ -6332,7 +6332,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {
|
||||
|
||||
/// TODO support scope overrides. Also note this logic is duplicated with `Module.wantSafety`.
|
||||
fn wantSafety(self: *Self) bool {
|
||||
return switch (self.bin_file.options.optimize_mode) {
|
||||
return switch (self.bin_file.comp.root_mod.optimize_mode) {
|
||||
.Debug => true,
|
||||
.ReleaseSafe => true,
|
||||
.ReleaseFast => false,
|
||||
|
||||
@ -6281,7 +6281,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {
|
||||
|
||||
/// TODO support scope overrides. Also note this logic is duplicated with `Module.wantSafety`.
|
||||
fn wantSafety(self: *Self) bool {
|
||||
return switch (self.bin_file.options.optimize_mode) {
|
||||
return switch (self.bin_file.comp.root_mod.optimize_mode) {
|
||||
.Debug => true,
|
||||
.ReleaseSafe => true,
|
||||
.ReleaseFast => false,
|
||||
|
||||
@ -2708,7 +2708,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {
|
||||
|
||||
/// TODO support scope overrides. Also note this logic is duplicated with `Module.wantSafety`.
|
||||
fn wantSafety(self: *Self) bool {
|
||||
return switch (self.bin_file.options.optimize_mode) {
|
||||
return switch (self.bin_file.comp.root_mod.optimize_mode) {
|
||||
.Debug => true,
|
||||
.ReleaseSafe => true,
|
||||
.ReleaseFast => false,
|
||||
|
||||
@ -4857,7 +4857,7 @@ fn truncRegister(
|
||||
|
||||
/// TODO support scope overrides. Also note this logic is duplicated with `Module.wantSafety`.
|
||||
fn wantSafety(self: *Self) bool {
|
||||
return switch (self.bin_file.options.optimize_mode) {
|
||||
return switch (self.bin_file.comp.root_mod.optimize_mode) {
|
||||
.Debug => true,
|
||||
.ReleaseSafe => true,
|
||||
.ReleaseFast => false,
|
||||
|
||||
@ -25,7 +25,9 @@ const Emit = @import("Emit.zig");
|
||||
const Liveness = @import("../../Liveness.zig");
|
||||
const Lower = @import("Lower.zig");
|
||||
const Mir = @import("Mir.zig");
|
||||
const Package = @import("../../Package.zig");
|
||||
const Module = @import("../../Module.zig");
|
||||
const Zcu = Module;
|
||||
const InternPool = @import("../../InternPool.zig");
|
||||
const Alignment = InternPool.Alignment;
|
||||
const Target = std.Target;
|
||||
@ -56,6 +58,7 @@ bin_file: *link.File,
|
||||
debug_output: DebugInfoOutput,
|
||||
target: *const std.Target,
|
||||
owner: Owner,
|
||||
mod: *Package.Module,
|
||||
err_msg: ?*ErrorMsg,
|
||||
args: []MCValue,
|
||||
va_info: union {
|
||||
@ -10906,7 +10909,7 @@ fn genCall(self: *Self, info: union(enum) {
|
||||
if (self.bin_file.cast(link.File.Elf)) |elf_file| {
|
||||
const sym_index = try elf_file.zigObjectPtr().?.getOrCreateMetadataForDecl(elf_file, func.owner_decl);
|
||||
const sym = elf_file.symbol(sym_index);
|
||||
if (self.bin_file.options.pic) {
|
||||
if (self.mod.pic) {
|
||||
const callee_reg: Register = switch (resolved_cc) {
|
||||
.SysV => callee: {
|
||||
if (!fn_info.is_var_args) break :callee .rax;
|
||||
@ -13819,7 +13822,7 @@ fn genLazySymbolRef(
|
||||
const sym_index = elf_file.zigObjectPtr().?.getOrCreateMetadataForLazySymbol(elf_file, lazy_sym) catch |err|
|
||||
return self.fail("{s} creating lazy symbol", .{@errorName(err)});
|
||||
const sym = elf_file.symbol(sym_index);
|
||||
if (self.bin_file.options.pic) {
|
||||
if (self.mod.pic) {
|
||||
switch (tag) {
|
||||
.lea, .call => try self.genSetReg(reg, Type.usize, .{
|
||||
.load_symbol = .{ .sym = sym.esym_index },
|
||||
@ -16062,7 +16065,7 @@ fn resolveInst(self: *Self, ref: Air.Inst.Ref) InnerError!MCValue {
|
||||
const const_mcv = try self.genTypedValue(.{ .ty = ty, .val = Value.fromInterned(ip_index) });
|
||||
switch (const_mcv) {
|
||||
.lea_tlv => |tlv_sym| if (self.bin_file.cast(link.File.Elf)) |_| {
|
||||
if (self.bin_file.options.pic) {
|
||||
if (self.mod.pic) {
|
||||
try self.spillRegisters(&.{ .rdi, .rax });
|
||||
} else {
|
||||
try self.spillRegisters(&.{.rax});
|
||||
|
||||
@ -103,10 +103,10 @@ pub fn emitMir(emit: *Emit) Error!void {
|
||||
});
|
||||
},
|
||||
.linker_reloc => |data| if (emit.lower.bin_file.cast(link.File.Elf)) |elf_file| {
|
||||
const is_obj_or_static_lib = switch (emit.lower.bin_file.options.output_mode) {
|
||||
const is_obj_or_static_lib = switch (emit.lower.output_mode) {
|
||||
.Exe => false,
|
||||
.Obj => true,
|
||||
.Lib => emit.lower.bin_file.options.link_mode == .Static,
|
||||
.Lib => emit.lower.link_mode == .Static,
|
||||
};
|
||||
const atom = elf_file.symbol(data.atom_index).atom(elf_file).?;
|
||||
const sym_index = elf_file.zigObjectPtr().?.symbol(data.sym_index);
|
||||
@ -114,7 +114,7 @@ pub fn emitMir(emit: *Emit) Error!void {
|
||||
if (sym.flags.needs_zig_got and !is_obj_or_static_lib) {
|
||||
_ = try sym.getOrCreateZigGotEntry(sym_index, elf_file);
|
||||
}
|
||||
if (emit.lower.bin_file.options.pic) {
|
||||
if (emit.lower.pic) {
|
||||
const r_type: u32 = if (sym.flags.needs_zig_got and !is_obj_or_static_lib)
|
||||
link.File.Elf.R_X86_64_ZIG_GOTPCREL
|
||||
else if (sym.flags.needs_got)
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
//! This file contains the functionality for lowering x86_64 MIR to Instructions
|
||||
|
||||
bin_file: *link.File,
|
||||
output_mode: std.builtin.OutputMode,
|
||||
link_mode: std.builtin.LinkMode,
|
||||
pic: bool,
|
||||
allocator: Allocator,
|
||||
mir: Mir,
|
||||
cc: std.builtin.CallingConvention,
|
||||
@ -336,10 +339,10 @@ fn isTls(sym: bits.Symbol, ctx: *link.File) bool {
|
||||
}
|
||||
|
||||
fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand) Error!void {
|
||||
const is_obj_or_static_lib = switch (lower.bin_file.options.output_mode) {
|
||||
const is_obj_or_static_lib = switch (lower.output_mode) {
|
||||
.Exe => false,
|
||||
.Obj => true,
|
||||
.Lib => lower.bin_file.options.link_mode == .Static,
|
||||
.Lib => lower.link_mode == .Static,
|
||||
};
|
||||
|
||||
const emit_prefix = prefix;
|
||||
@ -358,7 +361,7 @@ fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand)
|
||||
|
||||
if (isTls(sym, lower.bin_file)) {
|
||||
// TODO handle extern TLS vars, i.e., emit GD model
|
||||
if (lower.bin_file.options.pic) {
|
||||
if (lower.pic) {
|
||||
// Here, we currently assume local dynamic TLS vars, and so
|
||||
// we emit LD model.
|
||||
_ = lower.reloc(.{ .linker_tlsld = sym });
|
||||
@ -403,7 +406,7 @@ fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand)
|
||||
}
|
||||
|
||||
_ = lower.reloc(.{ .linker_reloc = sym });
|
||||
break :op if (lower.bin_file.options.pic) switch (mnemonic) {
|
||||
break :op if (lower.pic) switch (mnemonic) {
|
||||
.lea => {
|
||||
break :op .{ .mem = Memory.rip(mem_op.sib.ptr_size, 0) };
|
||||
},
|
||||
|
||||
@ -299,12 +299,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void {
|
||||
try comp.updateSubCompilation(sub_compilation, .libcxx, prog_node);
|
||||
|
||||
assert(comp.libcxx_static_lib == null);
|
||||
comp.libcxx_static_lib = Compilation.CRTFile{
|
||||
.full_object_path = try sub_compilation.bin_file.?.emit.directory.join(comp.gpa, &.{
|
||||
sub_compilation.bin_file.?.emit.sub_path,
|
||||
}),
|
||||
.lock = sub_compilation.bin_file.toOwnedLock(),
|
||||
};
|
||||
comp.libcxx_static_lib = try sub_compilation.toCrtFile();
|
||||
}
|
||||
|
||||
pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void {
|
||||
@ -489,10 +484,5 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void {
|
||||
try comp.updateSubCompilation(sub_compilation, .libcxxabi, prog_node);
|
||||
|
||||
assert(comp.libcxxabi_static_lib == null);
|
||||
comp.libcxxabi_static_lib = Compilation.CRTFile{
|
||||
.full_object_path = try sub_compilation.bin_file.?.emit.directory.join(comp.gpa, &[_][]const u8{
|
||||
sub_compilation.bin_file.?.emit.sub_path,
|
||||
}),
|
||||
.lock = sub_compilation.bin_file.toOwnedLock(),
|
||||
};
|
||||
comp.libcxxabi_static_lib = try sub_compilation.toCrtFile();
|
||||
}
|
||||
|
||||
@ -268,12 +268,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) !void {
|
||||
try comp.updateSubCompilation(sub_compilation, .libtsan, prog_node);
|
||||
|
||||
assert(comp.tsan_static_lib == null);
|
||||
comp.tsan_static_lib = Compilation.CRTFile{
|
||||
.full_object_path = try sub_compilation.bin_file.?.emit.directory.join(comp.gpa, &[_][]const u8{
|
||||
sub_compilation.bin_file.?.emit.sub_path,
|
||||
}),
|
||||
.lock = sub_compilation.bin_file.toOwnedLock(),
|
||||
};
|
||||
comp.tsan_static_lib = try sub_compilation.toCrtFile();
|
||||
}
|
||||
|
||||
const tsan_sources = [_][]const u8{
|
||||
|
||||
@ -151,12 +151,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void {
|
||||
|
||||
assert(comp.libunwind_static_lib == null);
|
||||
|
||||
comp.libunwind_static_lib = Compilation.CRTFile{
|
||||
.full_object_path = try sub_compilation.bin_file.?.emit.directory.join(comp.gpa, &[_][]const u8{
|
||||
sub_compilation.bin_file.?.emit.sub_path,
|
||||
}),
|
||||
.lock = sub_compilation.bin_file.toOwnedLock(),
|
||||
};
|
||||
comp.libunwind_static_lib = try sub_compilation.toOwnedLock();
|
||||
}
|
||||
|
||||
const unwind_src_list = [_][]const u8{
|
||||
|
||||
@ -8,14 +8,16 @@ pub const DynamicSection = struct {
|
||||
}
|
||||
|
||||
pub fn addNeeded(dt: *DynamicSection, shared: *SharedObject, elf_file: *Elf) !void {
|
||||
const gpa = elf_file.base.allocator;
|
||||
const comp = elf_file.base.comp;
|
||||
const gpa = comp.gpa;
|
||||
const off = try elf_file.insertDynString(shared.soname());
|
||||
try dt.needed.append(gpa, off);
|
||||
}
|
||||
|
||||
pub fn setRpath(dt: *DynamicSection, rpath_list: []const []const u8, elf_file: *Elf) !void {
|
||||
if (rpath_list.len == 0) return;
|
||||
const gpa = elf_file.base.allocator;
|
||||
const comp = elf_file.base.comp;
|
||||
const gpa = comp.gpa;
|
||||
var rpath = std.ArrayList(u8).init(gpa);
|
||||
defer rpath.deinit();
|
||||
for (rpath_list, 0..) |path, i| {
|
||||
@ -248,7 +250,8 @@ pub const ZigGotSection = struct {
|
||||
|
||||
pub fn addSymbol(zig_got: *ZigGotSection, sym_index: Symbol.Index, elf_file: *Elf) !Index {
|
||||
const comp = elf_file.base.comp;
|
||||
const index = try zig_got.allocateEntry(elf_file.base.allocator);
|
||||
const gpa = comp.gpa;
|
||||
const index = try zig_got.allocateEntry(gpa);
|
||||
const entry = &zig_got.entries.items[index];
|
||||
entry.* = sym_index;
|
||||
const symbol = elf_file.symbol(sym_index);
|
||||
@ -349,7 +352,9 @@ pub const ZigGotSection = struct {
|
||||
}
|
||||
|
||||
pub fn addRela(zig_got: ZigGotSection, elf_file: *Elf) !void {
|
||||
try elf_file.rela_dyn.ensureUnusedCapacity(elf_file.base.allocator, zig_got.numRela());
|
||||
const comp = elf_file.base.comp;
|
||||
const gpa = comp.gpa;
|
||||
try elf_file.rela_dyn.ensureUnusedCapacity(gpa, zig_got.numRela());
|
||||
for (zig_got.entries.items) |entry| {
|
||||
const symbol = elf_file.symbol(entry);
|
||||
const offset = symbol.zigGotAddress(elf_file);
|
||||
@ -481,7 +486,8 @@ pub const GotSection = struct {
|
||||
|
||||
pub fn addGotSymbol(got: *GotSection, sym_index: Symbol.Index, elf_file: *Elf) !Index {
|
||||
const comp = elf_file.base.comp;
|
||||
const index = try got.allocateEntry(elf_file.base.allocator);
|
||||
const gpa = comp.gpa;
|
||||
const index = try got.allocateEntry(gpa);
|
||||
const entry = &got.entries.items[index];
|
||||
entry.tag = .got;
|
||||
entry.symbol_index = sym_index;
|
||||
@ -501,8 +507,10 @@ pub const GotSection = struct {
|
||||
}
|
||||
|
||||
pub fn addTlsLdSymbol(got: *GotSection, elf_file: *Elf) !void {
|
||||
const comp = elf_file.base.comp;
|
||||
const gpa = comp.gpa;
|
||||
assert(got.flags.needs_tlsld);
|
||||
const index = try got.allocateEntry(elf_file.base.allocator);
|
||||
const index = try got.allocateEntry(gpa);
|
||||
const entry = &got.entries.items[index];
|
||||
entry.tag = .tlsld;
|
||||
entry.symbol_index = undefined; // unused
|
||||
@ -511,7 +519,9 @@ pub const GotSection = struct {
|
||||
}
|
||||
|
||||
pub fn addTlsGdSymbol(got: *GotSection, sym_index: Symbol.Index, elf_file: *Elf) !void {
|
||||
const index = try got.allocateEntry(elf_file.base.allocator);
|
||||
const comp = elf_file.base.comp;
|
||||
const gpa = comp.gpa;
|
||||
const index = try got.allocateEntry(gpa);
|
||||
const entry = &got.entries.items[index];
|
||||
entry.tag = .tlsgd;
|
||||
entry.symbol_index = sym_index;
|
||||
@ -526,7 +536,9 @@ pub const GotSection = struct {
|
||||
}
|
||||
|
||||
pub fn addGotTpSymbol(got: *GotSection, sym_index: Symbol.Index, elf_file: *Elf) !void {
|
||||
const index = try got.allocateEntry(elf_file.base.allocator);
|
||||
const comp = elf_file.base.comp;
|
||||
const gpa = comp.gpa;
|
||||
const index = try got.allocateEntry(gpa);
|
||||
const entry = &got.entries.items[index];
|
||||
entry.tag = .gottp;
|
||||
entry.symbol_index = sym_index;
|
||||
@ -541,7 +553,9 @@ pub const GotSection = struct {
|
||||
}
|
||||
|
||||
pub fn addTlsDescSymbol(got: *GotSection, sym_index: Symbol.Index, elf_file: *Elf) !void {
|
||||
const index = try got.allocateEntry(elf_file.base.allocator);
|
||||
const comp = elf_file.base.comp;
|
||||
const gpa = comp.gpa;
|
||||
const index = try got.allocateEntry(gpa);
|
||||
const entry = &got.entries.items[index];
|
||||
entry.tag = .tlsdesc;
|
||||
entry.symbol_index = sym_index;
|
||||
@ -628,8 +642,9 @@ pub const GotSection = struct {
|
||||
|
||||
pub fn addRela(got: GotSection, elf_file: *Elf) !void {
|
||||
const comp = elf_file.base.comp;
|
||||
const gpa = comp.gpa;
|
||||
const is_dyn_lib = elf_file.isDynLib();
|
||||
try elf_file.rela_dyn.ensureUnusedCapacity(elf_file.base.allocator, got.numRela(elf_file));
|
||||
try elf_file.rela_dyn.ensureUnusedCapacity(gpa, got.numRela(elf_file));
|
||||
|
||||
for (got.entries.items) |entry| {
|
||||
const symbol = switch (entry.tag) {
|
||||
@ -847,6 +862,8 @@ pub const PltSection = struct {
|
||||
}
|
||||
|
||||
pub fn addSymbol(plt: *PltSection, sym_index: Symbol.Index, elf_file: *Elf) !void {
|
||||
const comp = elf_file.base.comp;
|
||||
const gpa = comp.gpa;
|
||||
const index = @as(u32, @intCast(plt.symbols.items.len));
|
||||
const symbol = elf_file.symbol(sym_index);
|
||||
symbol.flags.has_plt = true;
|
||||
@ -855,7 +872,7 @@ pub const PltSection = struct {
|
||||
new_extra.plt = index;
|
||||
symbol.setExtra(new_extra, elf_file);
|
||||
} else try symbol.addExtra(.{ .plt = index }, elf_file);
|
||||
try plt.symbols.append(elf_file.base.allocator, sym_index);
|
||||
try plt.symbols.append(gpa, sym_index);
|
||||
}
|
||||
|
||||
pub fn size(plt: PltSection) usize {
|
||||
@ -895,7 +912,9 @@ pub const PltSection = struct {
|
||||
}
|
||||
|
||||
pub fn addRela(plt: PltSection, elf_file: *Elf) !void {
|
||||
try elf_file.rela_plt.ensureUnusedCapacity(elf_file.base.allocator, plt.numRela());
|
||||
const comp = elf_file.base.comp;
|
||||
const gpa = comp.gpa;
|
||||
try elf_file.rela_plt.ensureUnusedCapacity(gpa, plt.numRela());
|
||||
for (plt.symbols.items) |sym_index| {
|
||||
const sym = elf_file.symbol(sym_index);
|
||||
assert(sym.flags.import);
|
||||
@ -1010,6 +1029,8 @@ pub const PltGotSection = struct {
|
||||
}
|
||||
|
||||
pub fn addSymbol(plt_got: *PltGotSection, sym_index: Symbol.Index, elf_file: *Elf) !void {
|
||||
const comp = elf_file.base.comp;
|
||||
const gpa = comp.gpa;
|
||||
const index = @as(u32, @intCast(plt_got.symbols.items.len));
|
||||
const symbol = elf_file.symbol(sym_index);
|
||||
symbol.flags.has_plt = true;
|
||||
@ -1019,7 +1040,7 @@ pub const PltGotSection = struct {
|
||||
new_extra.plt_got = index;
|
||||
symbol.setExtra(new_extra, elf_file);
|
||||
} else try symbol.addExtra(.{ .plt_got = index }, elf_file);
|
||||
try plt_got.symbols.append(elf_file.base.allocator, sym_index);
|
||||
try plt_got.symbols.append(gpa, sym_index);
|
||||
}
|
||||
|
||||
pub fn size(plt_got: PltGotSection) usize {
|
||||
@ -1077,6 +1098,8 @@ pub const CopyRelSection = struct {
|
||||
}
|
||||
|
||||
pub fn addSymbol(copy_rel: *CopyRelSection, sym_index: Symbol.Index, elf_file: *Elf) !void {
|
||||
const comp = elf_file.base.comp;
|
||||
const gpa = comp.gpa;
|
||||
const index = @as(u32, @intCast(copy_rel.symbols.items.len));
|
||||
const symbol = elf_file.symbol(sym_index);
|
||||
symbol.flags.import = true;
|
||||
@ -1089,7 +1112,7 @@ pub const CopyRelSection = struct {
|
||||
new_extra.copy_rel = index;
|
||||
symbol.setExtra(new_extra, elf_file);
|
||||
} else try symbol.addExtra(.{ .copy_rel = index }, elf_file);
|
||||
try copy_rel.symbols.append(elf_file.base.allocator, sym_index);
|
||||
try copy_rel.symbols.append(gpa, sym_index);
|
||||
|
||||
const shared_object = symbol.file(elf_file).?.shared_object;
|
||||
if (shared_object.aliases == null) {
|
||||
@ -1129,7 +1152,9 @@ pub const CopyRelSection = struct {
|
||||
}
|
||||
|
||||
pub fn addRela(copy_rel: CopyRelSection, elf_file: *Elf) !void {
|
||||
try elf_file.rela_dyn.ensureUnusedCapacity(elf_file.base.allocator, copy_rel.numRela());
|
||||
const comp = elf_file.base.comp;
|
||||
const gpa = comp.gpa;
|
||||
try elf_file.rela_dyn.ensureUnusedCapacity(gpa, copy_rel.numRela());
|
||||
for (copy_rel.symbols.items) |sym_index| {
|
||||
const sym = elf_file.symbol(sym_index);
|
||||
assert(sym.flags.import and sym.flags.has_copy_rel);
|
||||
@ -1162,7 +1187,8 @@ pub const DynsymSection = struct {
|
||||
}
|
||||
|
||||
pub fn addSymbol(dynsym: *DynsymSection, sym_index: Symbol.Index, elf_file: *Elf) !void {
|
||||
const gpa = elf_file.base.allocator;
|
||||
const comp = elf_file.base.comp;
|
||||
const gpa = comp.gpa;
|
||||
const index = @as(u32, @intCast(dynsym.entries.items.len + 1));
|
||||
const sym = elf_file.symbol(sym_index);
|
||||
sym.flags.has_dynamic = true;
|
||||
@ -1244,7 +1270,8 @@ pub const HashSection = struct {
|
||||
pub fn generate(hs: *HashSection, elf_file: *Elf) !void {
|
||||
if (elf_file.dynsym.count() == 1) return;
|
||||
|
||||
const gpa = elf_file.base.allocator;
|
||||
const comp = elf_file.base.comp;
|
||||
const gpa = comp.gpa;
|
||||
const nsyms = elf_file.dynsym.count();
|
||||
|
||||
var buckets = try gpa.alloc(u32, nsyms);
|
||||
@ -1332,7 +1359,8 @@ pub const GnuHashSection = struct {
|
||||
try cwriter.writeInt(u32, hash.num_bloom, .little);
|
||||
try cwriter.writeInt(u32, bloom_shift, .little);
|
||||
|
||||
const gpa = elf_file.base.allocator;
|
||||
const comp = elf_file.base.comp;
|
||||
const gpa = comp.gpa;
|
||||
const hashes = try gpa.alloc(u32, exports.len);
|
||||
defer gpa.free(hashes);
|
||||
const indices = try gpa.alloc(u32, exports.len);
|
||||
@ -1434,7 +1462,8 @@ pub const VerneedSection = struct {
|
||||
}
|
||||
};
|
||||
|
||||
const gpa = elf_file.base.allocator;
|
||||
const comp = elf_file.base.comp;
|
||||
const gpa = comp.gpa;
|
||||
var verneed = std.ArrayList(VersionedSymbol).init(gpa);
|
||||
defer verneed.deinit();
|
||||
try verneed.ensureTotalCapacity(dynsyms.len);
|
||||
@ -1490,7 +1519,8 @@ pub const VerneedSection = struct {
|
||||
}
|
||||
|
||||
fn addVerneed(vern: *VerneedSection, soname: []const u8, elf_file: *Elf) !*elf.Elf64_Verneed {
|
||||
const gpa = elf_file.base.allocator;
|
||||
const comp = elf_file.base.comp;
|
||||
const gpa = comp.gpa;
|
||||
const sym = try vern.verneed.addOne(gpa);
|
||||
sym.* = .{
|
||||
.vn_version = 1,
|
||||
@ -1508,7 +1538,8 @@ pub const VerneedSection = struct {
|
||||
version: [:0]const u8,
|
||||
elf_file: *Elf,
|
||||
) !elf.Elf64_Vernaux {
|
||||
const gpa = elf_file.base.allocator;
|
||||
const comp = elf_file.base.comp;
|
||||
const gpa = comp.gpa;
|
||||
const sym = try vern.vernaux.addOne(gpa);
|
||||
sym.* = .{
|
||||
.vna_hash = HashSection.hasher(version),
|
||||
|
||||
17
src/main.zig
17
src/main.zig
@ -5242,22 +5242,6 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
|
||||
});
|
||||
|
||||
const builtin_mod = root_mod.getBuiltinDependency();
|
||||
const std_mod = try Package.Module.create(arena, .{
|
||||
.global_cache_directory = global_cache_directory,
|
||||
.paths = .{
|
||||
.root = .{
|
||||
.root_dir = zig_lib_directory,
|
||||
.sub_path = "std",
|
||||
},
|
||||
.root_src_path = "std.zig",
|
||||
},
|
||||
.fully_qualified_name = "std",
|
||||
.cc_argv = &.{},
|
||||
.inherited = .{},
|
||||
.global = config,
|
||||
.parent = root_mod,
|
||||
.builtin_mod = builtin_mod,
|
||||
});
|
||||
|
||||
const build_mod = try Package.Module.create(arena, .{
|
||||
.global_cache_directory = global_cache_directory,
|
||||
@ -5425,7 +5409,6 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
|
||||
.config = config,
|
||||
.root_mod = root_mod,
|
||||
.main_mod = build_mod,
|
||||
.std_mod = std_mod,
|
||||
.emit_bin = emit_bin,
|
||||
.emit_h = null,
|
||||
.self_exe_path = self_exe_path,
|
||||
|
||||
@ -280,7 +280,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr
|
||||
.full_object_path = try sub_compilation.bin_file.?.emit.directory.join(comp.gpa, &.{
|
||||
sub_compilation.bin_file.?.emit.sub_path,
|
||||
}),
|
||||
.lock = sub_compilation.bin_file.toOwnedLock(),
|
||||
.lock = sub_compilation.bin_file.?.toOwnedLock(),
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user