aboutsummaryrefslogtreecommitdiff
path: root/src/link
diff options
context:
space:
mode:
authorjoachimschmidt557 <joachim.schmidt557@outlook.com>2020-10-05 10:13:56 +0200
committerAndrew Kelley <andrew@ziglang.org>2020-10-05 04:48:58 -0400
commit7c5a24e08cd0bffd2a5cce6d1fd592a7d2bee678 (patch)
tree40b072ebb155f4c487f7c01b009a79d034e7df73 /src/link
parent9952a072cc120f5dc134bb1070ad02dfab59cefa (diff)
downloadzig-7c5a24e08cd0bffd2a5cce6d1fd592a7d2bee678.tar.gz
zig-7c5a24e08cd0bffd2a5cce6d1fd592a7d2bee678.zip
Turn zig fmt back on in various src/ files
Diffstat (limited to 'src/link')
-rw-r--r--src/link/Elf.zig100
1 files changed, 56 insertions, 44 deletions
diff --git a/src/link/Elf.zig b/src/link/Elf.zig
index 26f3c8e70d..4be47ccdf7 100644
--- a/src/link/Elf.zig
+++ b/src/link/Elf.zig
@@ -27,9 +27,6 @@ const Cache = @import("../Cache.zig");
const default_entry_addr = 0x8000000;
-// TODO Turn back on zig fmt when https://github.com/ziglang/zig/issues/5948 is implemented.
-// zig fmt: off
-
pub const base_tag: File.Tag = .elf;
base: File,
@@ -273,8 +270,8 @@ pub fn openPath(allocator: *Allocator, sub_path: []const u8, options: link.Optio
pub fn createEmpty(gpa: *Allocator, options: link.Options) !*Elf {
const ptr_width: PtrWidth = switch (options.target.cpu.arch.ptrBitWidth()) {
- 0 ... 32 => .p32,
- 33 ... 64 => .p64,
+ 0...32 => .p32,
+ 33...64 => .p64,
else => return error.UnsupportedELFArchitecture,
};
const self = try gpa.create(Elf);
@@ -752,40 +749,52 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {
// These are LEB encoded but since the values are all less than 127
// we can simply append these bytes.
const abbrev_buf = [_]u8{
- abbrev_compile_unit, DW.TAG_compile_unit, DW.CHILDREN_yes, // header
- DW.AT_stmt_list, DW.FORM_sec_offset, DW.AT_low_pc,
- DW.FORM_addr, DW.AT_high_pc, DW.FORM_addr,
- DW.AT_name, DW.FORM_strp, DW.AT_comp_dir,
- DW.FORM_strp, DW.AT_producer, DW.FORM_strp,
- DW.AT_language, DW.FORM_data2, 0,
+ abbrev_compile_unit, DW.TAG_compile_unit, DW.CHILDREN_yes, // header
+ DW.AT_stmt_list, DW.FORM_sec_offset, DW.AT_low_pc,
+ DW.FORM_addr, DW.AT_high_pc, DW.FORM_addr,
+ DW.AT_name, DW.FORM_strp, DW.AT_comp_dir,
+ DW.FORM_strp, DW.AT_producer, DW.FORM_strp,
+ DW.AT_language, DW.FORM_data2, 0,
0, // table sentinel
- abbrev_subprogram, DW.TAG_subprogram,
+ abbrev_subprogram,
+ DW.TAG_subprogram,
DW.CHILDREN_yes, // header
- DW.AT_low_pc, DW.FORM_addr,
- DW.AT_high_pc, DW.FORM_data4, DW.AT_type,
- DW.FORM_ref4, DW.AT_name, DW.FORM_string,
- 0, 0, // table sentinel
- abbrev_subprogram_retvoid,
- DW.TAG_subprogram, DW.CHILDREN_yes, // header
- DW.AT_low_pc,
- DW.FORM_addr, DW.AT_high_pc, DW.FORM_data4,
- DW.AT_name, DW.FORM_string, 0,
+ DW.AT_low_pc,
+ DW.FORM_addr,
+ DW.AT_high_pc,
+ DW.FORM_data4,
+ DW.AT_type,
+ DW.FORM_ref4,
+ DW.AT_name,
+ DW.FORM_string,
+ 0, 0, // table sentinel
+ abbrev_subprogram_retvoid,
+ DW.TAG_subprogram, DW.CHILDREN_yes, // header
+ DW.AT_low_pc, DW.FORM_addr,
+ DW.AT_high_pc, DW.FORM_data4,
+ DW.AT_name, DW.FORM_string,
+ 0,
0, // table sentinel
- abbrev_base_type, DW.TAG_base_type,
+ abbrev_base_type,
+ DW.TAG_base_type,
DW.CHILDREN_no, // header
- DW.AT_encoding, DW.FORM_data1,
- DW.AT_byte_size, DW.FORM_data1, DW.AT_name,
- DW.FORM_string, 0, 0, // table sentinel
-
- abbrev_pad1, DW.TAG_unspecified_type, DW.CHILDREN_no, // header
- 0, 0, // table sentinel
- abbrev_parameter,
+ DW.AT_encoding,
+ DW.FORM_data1,
+ DW.AT_byte_size,
+ DW.FORM_data1,
+ DW.AT_name,
+ DW.FORM_string, 0, 0, // table sentinel
+ abbrev_pad1, DW.TAG_unspecified_type, DW.CHILDREN_no, // header
+ 0, 0, // table sentinel
+ abbrev_parameter,
DW.TAG_formal_parameter, DW.CHILDREN_no, // header
- DW.AT_location,
- DW.FORM_exprloc, DW.AT_type, DW.FORM_ref4,
- DW.AT_name, DW.FORM_string, 0,
+ DW.AT_location, DW.FORM_exprloc,
+ DW.AT_type, DW.FORM_ref4,
+ DW.AT_name, DW.FORM_string,
+ 0,
0, // table sentinel
- 0, 0,
+ 0,
+ 0,
0, // section sentinel
};
@@ -1021,7 +1030,6 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {
0, // `DW.LNS_set_prologue_end`
0, // `DW.LNS_set_epilogue_begin`
1, // `DW.LNS_set_isa`
-
0, // include_directories (none except the compilation unit cwd)
});
// file_names[0]
@@ -1319,7 +1327,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
var prev_digest_buf: [digest.len]u8 = undefined;
const prev_digest: []u8 = directory.handle.readLink(id_symlink_basename, &prev_digest_buf) catch |err| blk: {
- log.debug("ELF LLD new_digest={} readlink error: {}", .{digest, @errorName(err)});
+ log.debug("ELF LLD new_digest={} readlink error: {}", .{ digest, @errorName(err) });
// Handle this as a cache miss.
break :blk prev_digest_buf[0..0];
};
@@ -1329,7 +1337,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
self.base.lock = man.toOwnedLock();
return;
}
- log.debug("ELF LLD prev_digest={} new_digest={}", .{prev_digest, digest});
+ log.debug("ELF LLD prev_digest={} new_digest={}", .{ prev_digest, digest });
// We are about to change the output file to be different, so we invalidate the build hash now.
directory.handle.deleteFile(id_symlink_basename) catch |err| switch (err) {
@@ -1370,7 +1378,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
if (self.base.options.eh_frame_hdr) {
try argv.append("--eh-frame-hdr");
}
-
+
if (self.base.options.emit_relocs) {
try argv.append("--emit-relocs");
}
@@ -1491,9 +1499,9 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
if (is_dyn_lib) {
const soname = self.base.options.override_soname orelse if (self.base.options.version) |ver|
- try std.fmt.allocPrint(arena, "lib{}.so.{}", .{self.base.options.root_name, ver.major})
- else
- try std.fmt.allocPrint(arena, "lib{}.so", .{self.base.options.root_name});
+ try std.fmt.allocPrint(arena, "lib{}.so.{}", .{ self.base.options.root_name, ver.major })
+ else
+ try std.fmt.allocPrint(arena, "lib{}.so", .{self.base.options.root_name});
try argv.append("-soname");
try argv.append(soname);
@@ -1616,7 +1624,11 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
};
defer stdout_context.data.deinit();
const llvm = @import("../llvm.zig");
- const ok = llvm.Link(.ELF, new_argv.ptr, new_argv.len, append_diagnostic,
+ const ok = llvm.Link(
+ .ELF,
+ new_argv.ptr,
+ new_argv.len,
+ append_diagnostic,
@ptrToInt(&stdout_context),
@ptrToInt(&stderr_context),
);
@@ -1642,7 +1654,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
};
// Again failure here only means an unnecessary cache miss.
man.writeManifest() catch |err| {
- std.log.warn("failed to write cache manifest when linking: {}", .{ @errorName(err) });
+ std.log.warn("failed to write cache manifest when linking: {}", .{@errorName(err)});
};
// We hang on to this lock so that the output file path can be used without
// other processes clobbering it.
@@ -2877,8 +2889,8 @@ fn dbgLineNeededHeaderBytes(self: Elf) u32 {
const root_src_dir_path_len = if (self.base.options.module.?.root_pkg.root_src_directory.path) |p| p.len else 1; // "."
return @intCast(u32, 53 + directory_entry_format_count * 2 + file_name_entry_format_count * 2 +
directory_count * 8 + file_name_count * 8 +
- // These are encoded as DW.FORM_string rather than DW.FORM_strp as we would like
- // because of a workaround for readelf and gdb failing to understand DWARFv5 correctly.
+ // These are encoded as DW.FORM_string rather than DW.FORM_strp as we would like
+ // because of a workaround for readelf and gdb failing to understand DWARFv5 correctly.
root_src_dir_path_len +
self.base.options.module.?.root_pkg.root_src_path.len);
}