Repository: rust
Issue: Getting SIGSEGV with `-fp-armv8` features
Labels: I-crash,A-LLVM,P-medium,T-compiler,C-bug,requires-nightly,ICEBreaker-LLVM,O-AArch64

I'm getting `SIGSEGV: invalid memory reference` crashes when compiling projects with `-fp-armv8` features.

I got same results on macosx and linux.


I tried this code:

<details><summary>codes</summary>
<p>


`src/startup.rs`
```rust
#![no_std]
#![no_main]
#![feature(asm)]

#[no_mangle]
pub extern "C" fn startup() {
    loop {
        unsafe{ asm!("wfe") }
    };
}
```

`.cargo/config.toml`
```toml
[unstable]
build-std = ["core", "compiler_builtins"]
build-std-features = ["compiler-builtins-mem"]

[build]
target = "aarch64-unknown-none.json"
```

`aarch64-unknown-none.json`
```json
{
  "arch": "aarch64",
  "data-layout": "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
  "env": "",
  "executables": true,
  "features": "+strict-align,-fp-armv8",
  "is-builtin": true,
  "linker": "rust-lld",
  "linker-flavor": "ld.lld",
  "pre-link-args": {
    "ld.lld": ["-Tldscript.ld"]
  },
  "llvm-target": "aarch64-unknown-none",
  "max-atomic-width": 128,
  "os": "none",
  "panic-strategy": "abort",
  "relocation-model": "static",
  "target-c-int-width": "32",
  "target-endian": "little",
  "target-pointer-width": "64",
  "unsupported-abis": [
    "stdcall",
    "fastcall",
    "vectorcall",
    "thiscall",
    "win64",
    "sysv64"
  ],
  "vendor": ""
}
```

`Cargo.toml`
```toml
[package]
name = "kernel"
version = "0.1.0"
authors = ["tnishinaga <>"]
edition = "2018"

[[bin]]
name = "kernel"
path = "src/startup.rs"

[profile.dev]
panic = "abort"

[profile.release]
panic = "abort"

[dependencies]
```

`ldscript.ld`
```
OUTPUT_ARCH(aarch64)

ENTRY(_start)

MEMORY
{
	/* for qemu(256MiB) */
	/* entry point is 0x40000000 */
	RAM(xrw) : ORIGIN = 0x40080000 , LENGTH = 0x10000000 - 0x00080000
}

SECTIONS
{	
	.text : {
		__text_start = .;
		__start = .;
		KEEP(*(.text.start))
		KEEP(*(.text.exeption.el2))
		*(.text*)
		. = ALIGN(4096);
		__text_end = .;
	} > RAM

	.rodata : {
		__rodata_start = .;
		*(.rodata*)
		. = ALIGN(4096);
		__rodata_end = .;
	} > RAM

	.data : {
		__data_start = . ;
		*(.data*)
		. = ALIGN(4096);
		__data_end = . ;
	} > RAM

	.bss : {
		__bss_start = . ;
		*(.bss*)
		. = ALIGN(4096);
		__bss_end = . ;
	} > RAM

    /* 8MiB space for heap memory */
	. = . + (1024 * 1024) * 8;

    __stack_end = .;
    /* 8MiB space */ 
    __stack_start = __stack_end + (1024 * 1024) * 8;


	/* /DISCARD/ : { *(.debug*) } */
}
```

</p>
</details>


I expected to see this happen:
build sccuess

Instead, this happened:
`SIGSEGV: invalid memory reference`

### Meta

#### macosx
<!--
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.50.0-nightly (1f5bc176b 2020-12-19)
binary: rustc
commit-hash: 1f5bc176b0e54a8e464704adcd7e571700207fe9
commit-date: 2020-12-19
host: x86_64-apple-darwin
release: 1.50.0-nightly
```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary>Error log(on macos)</summary>
<p>

```
$ RUST_BACKTRACE=1 cargo +nightly build --target=aarch64-unknown-none.json
    Blocking waiting for file lock on build directory
   Compiling core v0.0.0 (/Users/tnishinaga/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core)
   Compiling rustc-std-workspace-core v1.99.0 (/Users/tnishinaga/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/rustc-std-workspace-core)
error: could not compile `core`

Caused by:
  process didn't exit successfully: `rustc --crate-name core --edition=2018 /Users/tnishinaga/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C panic=abort -C embed-bitcode=no -C debuginfo=2 -C metadata=0e695d8bdba0e0fe -C extra-filename=-0e695d8bdba0e0fe --out-dir /Users/tnishinaga/tmp/kernel/target/aarch64-unknown-none/debug/deps --target /Users/tnishinaga/tmp/kernel/aarch64-unknown-none.json -Z force-unstable-if-unmarked -L dependency=/Users/tnishinaga/tmp/kernel/target/aarch64-unknown-none/debug/deps -L dependency=/Users/tnishinaga/tmp/kernel/target/debug/deps --cap-lints allow` (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
error: build failed
```

</p>
</details>


#### linux
<!--
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 +nightly --version --verbose`:
```
rustc 1.50.0-nightly (c609b2eaf 2020-12-20)
binary: rustc
commit-hash: c609b2eaf323186a1167ec1a9ffa69a7d4a5b1b9
commit-date: 2020-12-20
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly
```

<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_ASSIGN_START -->

<!-- TRIAGEBOT_ASSIGN_DATA_START$${"user":"nasherm"}$$TRIAGEBOT_ASSIGN_DATA_END -->

<!-- TRIAGEBOT_ASSIGN_END -->
<!-- TRIAGEBOT_END -->