| author | |
| committer | |
| log | 662303d7e74b93c0169c84dcd64b9f7da51ece3a |
| tree | 18362931d00f8817a62a67a041ec3522ea984601 |
| parent | dd4e25cf4410017cb113c0cb1c85c6e5c75729e3 |
| parent | 20486c4a8155499db8a26651bb2b1d2886003c33 |
| signature |
7 files changed, 76 insertions(+), 28 deletions(-)
lib/libtsan/sanitizer_common/sanitizer_common_interceptors_ioctl.inc-8| ... | ... | @@ -338,17 +338,9 @@ static void ioctl_table_fill() { |
| 338 | 338 | _(SOUND_PCM_WRITE_CHANNELS, WRITE, sizeof(int)); |
| 339 | 339 | _(SOUND_PCM_WRITE_FILTER, WRITE, sizeof(int)); |
| 340 | 340 | _(TCFLSH, NONE, 0); |
| 341 | #if SANITIZER_GLIBC | |
| 342 | _(TCGETA, WRITE, struct_termio_sz); | |
| 343 | #endif | |
| 344 | 341 | _(TCGETS, WRITE, struct_termios_sz); |
| 345 | 342 | _(TCSBRK, NONE, 0); |
| 346 | 343 | _(TCSBRKP, NONE, 0); |
| 347 | #if SANITIZER_GLIBC | |
| 348 | _(TCSETA, READ, struct_termio_sz); | |
| 349 | _(TCSETAF, READ, struct_termio_sz); | |
| 350 | _(TCSETAW, READ, struct_termio_sz); | |
| 351 | #endif | |
| 352 | 344 | _(TCSETS, READ, struct_termios_sz); |
| 353 | 345 | _(TCSETSF, READ, struct_termios_sz); |
| 354 | 346 | _(TCSETSW, READ, struct_termios_sz); |
lib/libtsan/sanitizer_common/sanitizer_platform_limits_posix.cpp-3| ... | ... | @@ -485,9 +485,6 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); |
| 485 | 485 | unsigned struct_input_id_sz = sizeof(struct input_id); |
| 486 | 486 | unsigned struct_mtpos_sz = sizeof(struct mtpos); |
| 487 | 487 | unsigned struct_rtentry_sz = sizeof(struct rtentry); |
| 488 | #if SANITIZER_GLIBC || SANITIZER_ANDROID | |
| 489 | unsigned struct_termio_sz = sizeof(struct termio); | |
| 490 | #endif | |
| 491 | 488 | unsigned struct_vt_consize_sz = sizeof(struct vt_consize); |
| 492 | 489 | unsigned struct_vt_sizes_sz = sizeof(struct vt_sizes); |
| 493 | 490 | unsigned struct_vt_stat_sz = sizeof(struct vt_stat); |
lib/libtsan/sanitizer_common/sanitizer_platform_limits_posix.h-1| ... | ... | @@ -1043,7 +1043,6 @@ extern unsigned struct_hd_geometry_sz; |
| 1043 | 1043 | extern unsigned struct_input_absinfo_sz; |
| 1044 | 1044 | extern unsigned struct_input_id_sz; |
| 1045 | 1045 | extern unsigned struct_mtpos_sz; |
| 1046 | extern unsigned struct_termio_sz; | |
| 1047 | 1046 | extern unsigned struct_vt_consize_sz; |
| 1048 | 1047 | extern unsigned struct_vt_sizes_sz; |
| 1049 | 1048 | extern unsigned struct_vt_stat_sz; |
src/link/Elf/synthetic_sections.zig+11-16| ... | ... | @@ -384,7 +384,7 @@ pub const GotSection = struct { |
| 384 | 384 | try writeInt(value, elf_file, writer); |
| 385 | 385 | }, |
| 386 | 386 | .tlsld => { |
| 387 | try writeInt(if (is_dyn_lib) @as(u64, 0) else 1, elf_file, writer); | |
| 387 | try writeInt(if (is_dyn_lib) @as(i64, 0) else 1, elf_file, writer); | |
| 388 | 388 | try writeInt(0, elf_file, writer); |
| 389 | 389 | }, |
| 390 | 390 | .tlsgd => { |
| ... | ... | @@ -392,7 +392,7 @@ pub const GotSection = struct { |
| 392 | 392 | try writeInt(0, elf_file, writer); |
| 393 | 393 | try writeInt(0, elf_file, writer); |
| 394 | 394 | } else { |
| 395 | try writeInt(if (is_dyn_lib) @as(u64, 0) else 1, elf_file, writer); | |
| 395 | try writeInt(if (is_dyn_lib) @as(i64, 0) else 1, elf_file, writer); | |
| 396 | 396 | const offset = symbol.?.address(.{}, elf_file) - elf_file.dtpAddress(); |
| 397 | 397 | try writeInt(offset, elf_file, writer); |
| 398 | 398 | } |
| ... | ... | @@ -412,17 +412,12 @@ pub const GotSection = struct { |
| 412 | 412 | } |
| 413 | 413 | }, |
| 414 | 414 | .tlsdesc => { |
| 415 | if (symbol.?.flags.import) { | |
| 416 | try writeInt(0, elf_file, writer); | |
| 417 | try writeInt(0, elf_file, writer); | |
| 418 | } else { | |
| 419 | try writeInt(0, elf_file, writer); | |
| 420 | const offset = if (apply_relocs) | |
| 421 | symbol.?.address(.{}, elf_file) - elf_file.tlsAddress() | |
| 422 | else | |
| 423 | 0; | |
| 424 | try writeInt(offset, elf_file, writer); | |
| 425 | } | |
| 415 | try writeInt(0, elf_file, writer); | |
| 416 | const offset: i64 = if (apply_relocs and !symbol.?.flags.import) | |
| 417 | symbol.?.address(.{}, elf_file) - elf_file.tlsAddress() | |
| 418 | else | |
| 419 | 0; | |
| 420 | try writeInt(offset, elf_file, writer); | |
| 426 | 421 | }, |
| 427 | 422 | } |
| 428 | 423 | } |
| ... | ... | @@ -1505,9 +1500,9 @@ fn writeInt(value: anytype, elf_file: *Elf, writer: anytype) !void { |
| 1505 | 1500 | const target = elf_file.getTarget(); |
| 1506 | 1501 | const endian = target.cpu.arch.endian(); |
| 1507 | 1502 | switch (entry_size) { |
| 1508 | 2 => try writer.writeInt(u16, @intCast(value), endian), | |
| 1509 | 4 => try writer.writeInt(u32, @intCast(value), endian), | |
| 1510 | 8 => try writer.writeInt(u64, @intCast(value), endian), | |
| 1503 | 2 => try writer.writeInt(i16, @intCast(value), endian), | |
| 1504 | 4 => try writer.writeInt(i32, @intCast(value), endian), | |
| 1505 | 8 => try writer.writeInt(i64, value, endian), | |
| 1511 | 1506 | else => unreachable, |
| 1512 | 1507 | } |
| 1513 | 1508 | } |
test/standalone/build.zig.zon+3| ... | ... | @@ -208,6 +208,9 @@ |
| 208 | 208 | .run_cwd = .{ |
| 209 | 209 | .path = "run_cwd", |
| 210 | 210 | }, |
| 211 | .tsan = .{ | |
| 212 | .path = "tsan", | |
| 213 | }, | |
| 211 | 214 | }, |
| 212 | 215 | .paths = .{ |
| 213 | 216 | "build.zig", |
test/standalone/tsan/build.zig created+59| ... | ... | @@ -0,0 +1,59 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | pub fn build(b: *std.Build) !void { | |
| 4 | const test_step = b.step("test", "Test the program"); | |
| 5 | b.default_step = test_step; | |
| 6 | ||
| 7 | const is_macos = b.graph.host.result.os.tag == .macos; | |
| 8 | ||
| 9 | for ([_]struct { std.Target.Os.Tag, []const std.Target.Cpu.Arch }{ | |
| 10 | // .s390x and mips64(el) fail to build | |
| 11 | .{ .linux, &.{ .aarch64, .aarch64_be, .loongarch64, .powerpc64, .powerpc64le, .riscv64, .x86_64 } }, | |
| 12 | .{ .macos, &.{ .x86_64, .aarch64 } }, | |
| 13 | ||
| 14 | // Missing system headers | |
| 15 | // https://github.com/ziglang/zig/issues/24736 | |
| 16 | // .{ .freebsd, &.{ .aarch64, .powerpc64, .powerpc64le, .riscv64, .x86_64 } }, | |
| 17 | // https://github.com/ziglang/zig/issues/24737 | |
| 18 | // .{ .netbsd, &.{ .aarch64, .aarch64_be, .x86_64 } }, | |
| 19 | ||
| 20 | // TSan doesn't have full support for windows yet. | |
| 21 | // .{ .windows, &.{ .aarch64, .x86_64 } }, | |
| 22 | }) |entry| { | |
| 23 | switch (entry[0]) { | |
| 24 | // compiling tsan on macos requires system headers that aren't present during cross-compilation | |
| 25 | .macos => { | |
| 26 | if (!is_macos) continue; | |
| 27 | const target = b.resolveTargetQuery(.{}); | |
| 28 | const exe = b.addExecutable(.{ | |
| 29 | .name = b.fmt("tsan_{s}_{s}", .{ @tagName(entry[0]), @tagName(target.result.cpu.arch) }), | |
| 30 | .root_module = b.createModule(.{ | |
| 31 | .root_source_file = b.path("main.zig"), | |
| 32 | .target = target, | |
| 33 | .optimize = .Debug, | |
| 34 | .sanitize_thread = true, | |
| 35 | }), | |
| 36 | }); | |
| 37 | const install_exe = b.addInstallArtifact(exe, .{}); | |
| 38 | test_step.dependOn(&install_exe.step); | |
| 39 | }, | |
| 40 | else => for (entry[1]) |arch| { | |
| 41 | const target = b.resolveTargetQuery(.{ | |
| 42 | .os_tag = entry[0], | |
| 43 | .cpu_arch = arch, | |
| 44 | }); | |
| 45 | const exe = b.addExecutable(.{ | |
| 46 | .name = b.fmt("tsan_{s}_{s}", .{ @tagName(entry[0]), @tagName(arch) }), | |
| 47 | .root_module = b.createModule(.{ | |
| 48 | .root_source_file = b.path("main.zig"), | |
| 49 | .target = target, | |
| 50 | .optimize = .Debug, | |
| 51 | .sanitize_thread = true, | |
| 52 | }), | |
| 53 | }); | |
| 54 | const install_exe = b.addInstallArtifact(exe, .{}); | |
| 55 | test_step.dependOn(&install_exe.step); | |
| 56 | }, | |
| 57 | } | |
| 58 | } | |
| 59 | } |
test/standalone/tsan/main.zig created+3| ... | ... | @@ -0,0 +1,3 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | pub fn main() !void {} |