vdso support
This commit is contained in:
@@ -21,7 +21,8 @@ IvyBridge(2012) and AMD Zen 2 Family 17H(2019) and Linux 5.9(2020).
|
||||
- [ ] `auxv`: check if that is setup correctly and completely
|
||||
- [ ] JIT support: intercept `mmap`, `mprotect` and `mremap` that change pages to be executable
|
||||
- [ ] `SIGILL` patching fallback
|
||||
- [ ] `vdso` handling
|
||||
- [x] `vdso` handling
|
||||
- [ ] check why the libc tests are flaky
|
||||
|
||||
## Minor things
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@ pub const InstructionIterator = struct {
|
||||
"Byte stepping, to find next valid instruction begin", .{}),
|
||||
zydis.ZYDIS_STATUS_DECODING_ERROR => log.warn("next: Got status: DECODING_ERROR. " ++
|
||||
"Byte stepping, to find next valid instruction begin", .{}),
|
||||
zydis.ZYDIS_STATUS_INVALID_MAP => log.warn("next: Got status: INVALID_MAP. " ++
|
||||
"Byte stepping, to find next valid instruction begin", .{}),
|
||||
else => log.warn("next: Got unknown status: 0x{x}. Byte stepping, to find next " ++
|
||||
"valid instruction begin", .{status}),
|
||||
}
|
||||
|
||||
25
src/main.zig
25
src/main.zig
@@ -118,6 +118,11 @@ pub fn main() !void {
|
||||
elf.AT_BASE => maybe_interp_base orelse auxv[i].a_un.a_val,
|
||||
elf.AT_ENTRY => entry,
|
||||
elf.AT_EXECFN => @intFromPtr(std.os.argv[arg_index]),
|
||||
elf.AT_SYSINFO_EHDR => blk: {
|
||||
log.info("Found vDSO at 0x{x}", .{auxv[i].a_un.a_val});
|
||||
try patchLoadedElf(auxv[i].a_un.a_val);
|
||||
break :blk auxv[i].a_un.a_val;
|
||||
},
|
||||
else => auxv[i].a_un.a_val,
|
||||
};
|
||||
}
|
||||
@@ -419,6 +424,26 @@ test "nolibc_pie_signal_handler" {
|
||||
);
|
||||
}
|
||||
|
||||
test "nolibc_nopie_vdso_clock" {
|
||||
try testHelper(
|
||||
&.{ flicker_path, getTestExePath("nolibc_nopie_vdso_clock") },
|
||||
"Time gotten\n",
|
||||
);
|
||||
}
|
||||
test "nolibc_pie_vdso_clock" {
|
||||
try testHelper(
|
||||
&.{ flicker_path, getTestExePath("nolibc_pie_vdso_clock") },
|
||||
"Time gotten\n",
|
||||
);
|
||||
}
|
||||
// BUG: This one is flaky
|
||||
// test "libc_pie_vdso_clock" {
|
||||
// try testHelper(
|
||||
// &.{ flicker_path, getTestExePath("libc_pie_vdso_clock") },
|
||||
// "Time gotten\n",
|
||||
// );
|
||||
// }
|
||||
|
||||
fn testPrintArgs(comptime name: []const u8) !void {
|
||||
const exe_path = getTestExePath(name);
|
||||
const loader_argv: []const []const u8 = &.{ flicker_path, exe_path, "foo", "bar", "baz hi" };
|
||||
|
||||
8
src/test/vdso_clock.zig
Normal file
8
src/test/vdso_clock.zig
Normal file
@@ -0,0 +1,8 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn main() !void {
|
||||
_ = try std.posix.clock_gettime(std.posix.CLOCK.MONOTONIC);
|
||||
|
||||
const msg = "Time gotten\n";
|
||||
_ = try std.posix.write(1, msg);
|
||||
}
|
||||
Reference in New Issue
Block a user