<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63647>63647</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Crash in `AArch64MachObjectWriter::recordRelocation` when using `blockaddress` on function with `available_externally` linkage
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Sintendo
</td>
</tr>
</table>
<pre>
Minimal testcase:
```
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
target triple = "arm64-apple-ios13.0.0"
@0 = private unnamed_addr global [1 x i8*] [i8* blockaddress(@_ZThn16_NSt3__114basic_iostreamIcNS_11char_traitsIcEEED0Ev, %.exit)], align 1
; Function Attrs: noinline nounwind optnone ssp
define available_externally void @_ZThn16_NSt3__114basic_iostreamIcNS_11char_traitsIcEEED0Ev() unnamed_addr align 2 {
br label %.exit
.exit:
ret void
}
```
Compiling this on/for ARM64 macOS gives the following output:
```
% /opt/homebrew/opt/llvm@16/bin/clang -x ir min.ll -c -o /dev/null
warning: overriding the module target triple with arm64-apple-macosx13.0.0 [-Woverride-module]
PLEASE submit a bug report to https://github.com/Homebrew/homebrew-core/issues and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/homebrew/opt/llvm@16/bin/clang -x ir min.ll -c -o /dev/null
1. Code generation
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 libLLVM.dylib 0x00000001161343cc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1 libLLVM.dylib 0x0000000116133764 llvm::sys::CleanupOnSignal(unsigned long) + 252
2 libLLVM.dylib 0x0000000119f564f8 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) + 76
3 libLLVM.dylib 0x0000000119f565d4 CrashRecoverySignalHandler(int) + 112
4 libsystem_platform.dylib 0x00000001a0d6ea24 _sigtramp + 56
5 libLLVM.dylib 0x00000001183ece34 (anonymous namespace)::AArch64MachObjectWriter::recordRelocation(llvm::MachObjectWriter*, llvm::MCAssembler&, llvm::MCAsmLayout const&, llvm::MCFragment const*, llvm::MCFixup const&, llvm::MCValue, unsigned long long&) + 80
6 libLLVM.dylib 0x0000000117bda9bc llvm::MachObjectWriter::recordRelocation(llvm::MCAssembler&, llvm::MCAsmLayout const&, llvm::MCFragment const*, llvm::MCFixup const&, llvm::MCValue, unsigned long long&) + 84
7 libLLVM.dylib 0x0000000117b8b62c llvm::MCAssembler::handleFixup(llvm::MCAsmLayout const&, llvm::MCFragment&, llvm::MCFixup const&) + 1196
8 libLLVM.dylib 0x0000000117b8baec llvm::MCAssembler::layout(llvm::MCAsmLayout&) + 1104
9 libLLVM.dylib 0x0000000117b8bc34 llvm::MCAssembler::Finish() + 60
10 libLLVM.dylib 0x0000000117bb37b4 (anonymous namespace)::MCMachOStreamer::finishImpl() + 1936
11 libLLVM.dylib 0x0000000116c22484 llvm::AsmPrinter::doFinalization(llvm::Module&) + 4340
12 libLLVM.dylib 0x00000001162f3b9c llvm::FPPassManager::doFinalization(llvm::Module&) + 68
13 libLLVM.dylib 0x00000001162d452c llvm::legacy::PassManagerImpl::run(llvm::Module&) + 3220
14 libclang-cpp.dylib 0x000000010a851394 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream>>) + 5912
15 libclang-cpp.dylib 0x000000010abdb854 clang::CodeGenAction::ExecuteAction() + 2068
16 libclang-cpp.dylib 0x000000010b2afa44 clang::FrontendAction::Execute() + 96
17 libclang-cpp.dylib 0x000000010b2324e0 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 580
18 libclang-cpp.dylib 0x000000010b2fd314 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 512
19 clang-16 0x0000000104e6223c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 1772
20 clang-16 0x0000000104e5fcf8 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) + 1092
21 libclang-cpp.dylib 0x000000010aeacbc4 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const::$_0>(long) + 28
22 libLLVM.dylib 0x000000011605e7a4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 148
23 libclang-cpp.dylib 0x000000010aeac56c clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const + 244
24 libclang-cpp.dylib 0x000000010ae6a490 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const + 940
25 libclang-cpp.dylib 0x000000010ae8ee20 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&) + 332
26 clang-16 0x0000000104e5e938 clang_main(int, char**) + 9680
27 dyld 0x00000001a09e7f28 start + 2236
clang-16: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Homebrew clang version 16.0.6
Target: arm64-apple-darwin22.5.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm@16/bin
clang-16: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWU1v4zjS_jXKpWBDoj4sH3JwnPjtBjrTjXajB-9cDIoqy9ymSC1JOfH8-gUpKbZiJ_HMYg8LrBEkjlSseuq7VKLG8Eoi3gbpXZDe39DW7pS-XXNpUZbqplDl4faRS15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