Repository: rust
Issue: error: undefined symbol: __chkstk on aarch64-unknown-uefi
Labels: E-needs-test,C-bug,O-AArch64

<!--
Thank you for filing a bug report! 🐛 Please provide a short summary of the bug,
along with any information you feel relevant to replicating the bug.
-->

I tried this code:

```rust
// in #[entry] fn main()
let memory_map = get_mem_map(bt);

// in library
pub fn get_mem_map(bt: &BootServices) -> AlignToMemoryDescriptor {
    let mut memory_map = AlignToMemoryDescriptor {
        0: [0 as u8; MAX_MEMORY_MAP_SIZE],
    };
    {
        let res = bt.memory_map(&mut memory_map.0);

        match res {
            Ok(r) => {
                info!("Retrieved Memory Map!");
                info!("Memory Map Key = {:?}", &r.0);
                let iterator_item = r.1;
                iterator_item.for_each(|i| info!("Memory Descriptor = {i:?}"));
            }
            Err(err) => panic!("Could not get memory map. Error: {err:?}"),
        }
    }

    memory_map
}
```

I expected to see this happen: No link error cause it is sound code.

Instead, this happened: I got an undefined symbol error, which seems to be a problem with the compiler/linker being unable to know if Im going to overflow the stack

### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```
rustc 1.62.0-nightly (60e50fc1c 2022-04-04)
binary: rustc
commit-hash: 60e50fc1cfe0bb693a5f4f93eb83ef70854531e3
commit-date: 2022-04-04
host: aarch64-apple-darwin
release: 1.62.0-nightly
LLVM version: 14.0.0
```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary>Backtrace</summary>
<p>

```
error: linking with `rust-lld` failed: exit status: 1
  |
  = note: "rust-lld" "-flavor" "link" "/NOLOGO" "/entry:efi_main" "/subsystem:efi_application" "/machine:arm64" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.10860la7lg9m5zn1.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.12gi8jn8zywdxv6h.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.12mds7eapchfjvfh.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.1ikw55eou1bf3eg1.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.1mx424kmmbsalcic.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.1t9doq35s6sx7lcj.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.237grgsvhid7fpts.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.23hlvne6yrypuu9l.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.2ek71ldjh4fw9mnr.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.2p1np39se4rg1en1.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.35qfhcfezhjjhjq8.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.3bki6fhvzt8tce2g.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.3hssll7pzpq4wngd.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.3iq51mcpjmgqqxcp.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.474t401uuawr9pjp.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.4f2py4q0c58oopcl.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.4l0fy6cj8w3oiywi.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.4r9nhovccm037jyi.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.51j5lxe7enjgraji.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.5a7llcm4ivz0mg9m.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.ap4qa7cl5w7xkk4.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.hj8i0u6yntu4dkf.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.hnpm1zs9s81xv4g.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.jy7nxdsjlj6pv75.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.qh1nrbt29xb0vkn.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.zs6cy23jktqio5w.rcgu.o" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.4lgs7981ret5znjw.rcgu.o" "/LIBPATH:/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps" "/LIBPATH:/Users/jasonq/Documents/GitHub/Arcboot/target/debug/deps" "/LIBPATH:/Users/jasonq/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-unknown-uefi/lib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/libarcboot-3b698ac8d3c398e2.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/liblinked_list_allocator-75bb8ba81fc768db.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/libspinning_top-2aa0acbdfe0c659c.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/libaarch64-705062cb4f6b687d.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/libcortex_a-39e702517f9b69f2.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/libtock_registers-57c8d8f19f0b66ee.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/libqemu_exit-c7972f030686e4ec.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/liblazy_static-6ca79388e5285dbe.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/libspin-1d4a8bf93c0fa00f.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/libspin-60f5af8ab53b5555.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/liblock_api-9f9389295b3faafd.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/libscopeguard-2bd0414a3c1a160c.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/libacpi-e04bf978a602b9e2.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/librsdp-3ca0eea8681ddda1.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/libuefi-668ad71a18d6f50e.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/libbitflags-39e5d6ea55f39b47.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/libucs2-ffe6747d48dde65d.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/libbit_field-6814482675aaa2e6.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/liballoc-ec155d3e116d2a14.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/liblog-bbb3b5c8bc5d1d68.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/libcfg_if-8866ce721cb8a40e.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/librustc_std_workspace_core-dc84e73fe987a0ca.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/libcore-a8ff4b8ed128c50e.rlib" "/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/libcompiler_builtins-42e14f5c94945cb2.rlib" "/NXCOMPAT" "/LIBPATH:/Users/jasonq/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-unknown-uefi/lib" "/OUT:/Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.efi" "/OPT:REF,NOICF" "/DEBUG" "/NODEFAULTLIB"
  = note: rust-lld: error: undefined symbol: __chkstk
          >>> referenced by /Users/jasonq/Documents/GitHub/Arcboot/src/main.rs:56
          >>>               /Users/jasonq/Documents/GitHub/Arcboot/target/aarch64-unknown-uefi/debug/deps/arcboot_main-3791f8b9a1c81533.3iq51mcpjmgqqxcp.rcgu.o:(efi_main)
          

warning: `arcboot_main` (bin "arcboot_main") generated 12 warnings
error: could not compile `arcboot_main` due to previous error; 12 warnings emitted
```

</p>
</details>