diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2021-01-17 11:26:02 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2021-01-17 14:57:53 +0100 |
| commit | b25cf7db0253f331f44b279fcbcdf71faa1afb92 (patch) | |
| tree | 7c579064f6b87be5642b6b85562b820ddea413b0 /test | |
| parent | e292f33de75fa00863a855161d6df9f6884df841 (diff) | |
| download | zig-b25cf7db0253f331f44b279fcbcdf71faa1afb92.tar.gz zig-b25cf7db0253f331f44b279fcbcdf71faa1afb92.zip | |
stage2 aarch64: add basic function pro/epilogue
Fix typo in `nop` implementation.
Simplify `aarch64` macOS tests.
Diffstat (limited to 'test')
| -rw-r--r-- | test/stage2/aarch64.zig | 101 |
1 files changed, 23 insertions, 78 deletions
diff --git a/test/stage2/aarch64.zig b/test/stage2/aarch64.zig index fb2b240c4d..6c283f8e9f 100644 --- a/test/stage2/aarch64.zig +++ b/test/stage2/aarch64.zig @@ -17,97 +17,60 @@ pub fn addCases(ctx: *TestContext) !void { // Regular old hello world case.addCompareOutput( + \\extern "c" fn write(usize, usize, usize) void; + \\extern "c" fn exit(usize) noreturn; + \\ \\export fn _start() noreturn { \\ print(); \\ - \\ exit(); + \\ exit(0); \\} \\ \\fn print() void { - \\ asm volatile ("svc #0x80" - \\ : - \\ : [number] "{x16}" (4), - \\ [arg1] "{x0}" (1), - \\ [arg2] "{x1}" (@ptrToInt("Hello, World!\n")), - \\ [arg3] "{x2}" (14) - \\ : "memory" - \\ ); - \\ return; - \\} - \\ - \\fn exit() noreturn { - \\ asm volatile ("svc #0x80" - \\ : - \\ : [number] "{x16}" (1), - \\ [arg1] "{x0}" (0) - \\ : "memory" - \\ ); - \\ unreachable; + \\ const msg = @ptrToInt("Hello, World!\n"); + \\ const len = 14; + \\ write(1, msg, len); \\} , "Hello, World!\n", ); + // Now change the message only case.addCompareOutput( + \\extern "c" fn write(usize, usize, usize) void; + \\extern "c" fn exit(usize) noreturn; + \\ \\export fn _start() noreturn { \\ print(); \\ - \\ exit(); + \\ exit(0); \\} \\ \\fn print() void { - \\ asm volatile ("svc #0x80" - \\ : - \\ : [number] "{x16}" (4), - \\ [arg1] "{x0}" (1), - \\ [arg2] "{x1}" (@ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n")), - \\ [arg3] "{x2}" (104) - \\ : "memory" - \\ ); - \\ return; - \\} - \\ - \\fn exit() noreturn { - \\ asm volatile ("svc #0x80" - \\ : - \\ : [number] "{x16}" (1), - \\ [arg1] "{x0}" (0) - \\ : "memory" - \\ ); - \\ unreachable; + \\ const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); + \\ const len = 104; + \\ write(1, msg, len); \\} , "What is up? This is a longer message that will force the data to be relocated in virtual address space.\n", ); + // Now we print it twice. case.addCompareOutput( + \\extern "c" fn write(usize, usize, usize) void; + \\extern "c" fn exit(usize) noreturn; + \\ \\export fn _start() noreturn { \\ print(); \\ print(); \\ - \\ exit(); + \\ exit(0); \\} \\ \\fn print() void { - \\ asm volatile ("svc #0x80" - \\ : - \\ : [number] "{x16}" (4), - \\ [arg1] "{x0}" (1), - \\ [arg2] "{x1}" (@ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n")), - \\ [arg3] "{x2}" (104) - \\ : "memory" - \\ ); - \\ return; - \\} - \\ - \\fn exit() noreturn { - \\ asm volatile ("svc #0x80" - \\ : - \\ : [number] "{x16}" (1), - \\ [arg1] "{x0}" (0) - \\ : "memory" - \\ ); - \\ unreachable; + \\ const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); + \\ const len = 104; + \\ write(1, msg, len); \\} , \\What is up? This is a longer message that will force the data to be relocated in virtual address space. @@ -201,24 +164,6 @@ pub fn addCases(ctx: *TestContext) !void { } { - var case = ctx.exe("hello world linked to libc", macos_aarch64); - - // TODO rewrite this test once we handle more int conversions and return args. - case.addCompareOutput( - \\extern "c" fn write(usize, usize, usize) void; - \\extern "c" fn exit(usize) noreturn; - \\ - \\export fn _start() noreturn { - \\ write(1, @ptrToInt("Hello,"), 6); - \\ write(1, @ptrToInt(" World!\n,"), 8); - \\ exit(0); - \\} - , - "Hello, World!\n", - ); - } - - { var case = ctx.exe("only libc exit", macos_aarch64); // This test case covers an infrequent scenarion where the string table *may* be relocated |
