title: How to fix "ld: warning: arm64 function not 4-byte aligned" warning?
body: <p>I start writing arm64 assembly code on M1 mac.<br />
  This is very simple sample code.</p>
  <pre><code>.global _main
  _main:
      mov x0, #1
      ret
  </code></pre>
  <p>When I compile this code by clang, titled linker warning will displayed.</p>
  <pre><code>$ clang test.s
  ld: warning: arm64 function not 4-byte aligned: _main from /var/folders/st/df0gjt9x5tl0cv7fw0xg5s9m0000gn/T/test-3c883c.o
  
  $ ./a.out
  $ echo $?
  1
  </code></pre>
  <p>Generated binary is works well but how to resolve this linker warning?</p>
  <p>Toolchain version (Xcode 12.3)</p>
  <pre><code>$ clang --version
  Apple clang version 12.0.0 (clang-1200.0.32.28)
  Target: arm64-apple-darwin20.2.0
  Thread model: posix
  InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
  </code></pre>
  <hr />
  <p>After writing up this question.
  write same behavior C file like this.</p>
  <pre><code>int main() { return 1; }
  </code></pre>
  <p>then output assembly code by clang</p>
  <pre><code>$ clang -S -O test.c
  </code></pre>
  <p>generated test.s file contains <code>.p2align 2</code>
  If that is contained, warning will not displayed.</p>
  <pre><code>    .section    __TEXT,__text,regular,pure_instructions
      .build_version macos, 11, 0 sdk_version 11, 1
      .globl  _main                   ; -- Begin function main
      .p2align    2
  _main:                                  ; @main
      .cfi_startproc
  ; %bb.0:
      mov w0, #1
      ret
      .cfi_endproc
                                          ; -- End function
  .subsections_via_symbols
  </code></pre>