Created
December 14, 2019 03:39
-
-
Save travisstaloch/b2a5edb5bd003b85214a9e6e2fe615f0 to your computer and use it in GitHub Desktop.
stripped down template for viewing assembly produced by zig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// zig build-obj --emit asm --strip --release-small view_asm.zig && cat view_asm.s | |
const std = @import("std"); | |
pub fn panic(msg: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { | |
while (true) {} | |
} | |
export nakedcc fn _start() noreturn { | |
// code here will appear in _start section | |
// unless it isn't used | |
aeou() catch unreachable; | |
std.os.exit(0); | |
// while (true) {} | |
} | |
fn aeou() !void { | |
_ = try std.os.write(1, "hello world\n"); | |
} | |
// to build exe. first create view_asm.o then create exe | |
// zig build-obj --strip --release-small view_asm.zig | |
// zig build-exe --object view_asm.o --name view_asm | |
// one liner | |
// zig build-obj --strip --release-small view_asm.zig && zig build-exe --object view_asm.o --name view_asm && ./view_asm | |
// disassemble with objdump | |
// objdump -d view_asm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment