From 0352f927e1dfbdb2e137bce55a288910554de3fc Mon Sep 17 00:00:00 2001 From: Zhuowei Zhang Date: Sat, 4 Jul 2020 13:53:51 -0400 Subject: [PATCH] AsMain/main.s: align to 4 byte boundary ARM instructions must be aligned to 4 bytes. Without this directive, ld complains: ``` ld: warning: arm64 function not 4-byte aligned: _main from HelloWorld.o ld: warning: arm64 function not 4-byte aligned: helloworld from HelloWorld.o ``` Clang uses the .p2align directive to ensure this; you can see it if you run: ``` clang -S -Os -c -target arm64-apple-macos test.c ``` --- AsMain/main.s | 1 + 1 file changed, 1 insertion(+) diff --git a/AsMain/main.s b/AsMain/main.s index 3cb480c..39b7fb0 100644 --- a/AsMain/main.s +++ b/AsMain/main.s @@ -7,6 +7,7 @@ // .global _main // Provide program starting address to linker +.p2align 2 // align _main to 4 byte boundary // Setup the parameters to print hello world // and then call Linux to do it.