<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/99008>99008</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [LLD][ARM] Assertion "If the source is ARM, we should not need Thumb PLTs"
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            lld,
            backend:ARM,
            crash-on-valid
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ostannard
      </td>
    </tr>
</table>

<pre>
    This reproducer tarball (found while building https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/) causes an assertion in lld:

[repro.tar.gz](https://github.com/user-attachments/files/16246302/repro.tar.gz)

```
$ /work/et/build/llvm/bin/ld.lld --chroot . -l crt0-semihost -l semihost -rpath work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi tmp/ucmpdi2_test-71ac06.o work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi/libclang_rt.builtins.a -l c -l m -Bstatic -EL --script picolibcpp.ld -L work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi -L work/et/build/llvm/lib/clang-runtimes/arm-none-eabi/armv7a_soft_nofp_exn_rtti/lib -L work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi -L work/et/build/llvm/lib/clang-runtimes/arm-none-eabi/armv7a_soft_nofp_exn_rtti/lib --target2 rel -o ucmpdi2_test.c.tmp
ld.lld: /work/et/repos/llvm-project/lld/ELF/Arch/ARM.cpp:396: virtual bool {anonymous}::ARM::needsThunk(lld::elf::RelExpr, lld::elf::RelType, const lld::elf::InputFile*, uint64_t, const lld::elf::Symbol&, int64_t) const: Assertion `!config->armThumbPLTs && "If the source is ARM, we should not need Thumb PLTs"' failed.
PLEASE submit a bug report to https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/issues and include the crash backtrace.
Stack dump:
0.      Program arguments: /work/et/build/llvm/bin/ld.lld --chroot . -l crt0-semihost -l semihost -rpath work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi tmp/ucmpdi2_test-71ac06.o work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi/libclang_rt.builtins.a -l c -l m -Bstatic -EL --script picolibcpp.ld -L work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi -L work/et/build/llvm/lib/clang-runtimes/arm-none-eabi/armv7a_soft_nofp_exn_rtti/lib -L work/et/build/compiler-rt/armv7a_soft_nofp_exn_rtti/src/compiler_rt_armv7a_soft_nofp_exn_rtti-build/lib/arm-unknown-none-eabi -L work/et/build/llvm/lib/clang-runtimes/arm-none-eabi/armv7a_soft_nofp_exn_rtti/lib --target2 rel -o ucmpdi2_test.c.tmp
 #0 0x0000561187063f00 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/work/et/build/llvm/bin/ld.lld+0x1c25f00)
 #1 0x000056118706131f llvm::sys::RunSignalHandlers() (/work/et/build/llvm/bin/ld.lld+0x1c2331f)
 #2 0x0000561187061475 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f1c1a242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f1c1a2969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007f1c1a2969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007f1c1a2969fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007f1c1a242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007f1c1a2287f3 abort ./stdlib/abort.c:81:7
 #9 0x00007f1c1a22871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007f1c1a239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x00005611871dfce6 (anonymous namespace)::ARM::needsThunk(lld::elf::RelExpr, unsigned int, lld::elf::InputFile const*, unsigned long, lld::elf::Symbol const&, long) const ARM.cpp:0:0
#12 0x00005611872f6103 lld::elf::ThunkCreator::createThunks(unsigned int, llvm::ArrayRef<lld::elf::OutputSection*>) (/work/et/build/llvm/bin/ld.lld+0x1eb8103)
#13 0x00005611873df80d (anonymous namespace)::Writer<llvm::object::ELFType<(llvm::endianness)1, false>>::finalizeAddressDependentContent() Writer.cpp:0:0
#14 0x00005611873e0d33 (anonymous namespace)::Writer<llvm::object::ELFType<(llvm::endianness)1, false>>::finalizeSections() Writer.cpp:0:0
#15 0x00005611873e2a2c (anonymous namespace)::Writer<llvm::object::ELFType<(llvm::endianness)1, false>>::run() Writer.cpp:0:0
#16 0x00005611873e3abd void lld::elf::writeResult<llvm::object::ELFType<(llvm::endianness)1, false>>() (/work/et/build/llvm/bin/ld.lld+0x1fa5abd)
#17 0x00005611871c9a75 void lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::endianness)1, false>>(llvm::opt::InputArgList&) (/work/et/build/llvm/bin/ld.lld+0x1d8ba75)
#18 0x00005611871d344b lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) (/work/et/build/llvm/bin/ld.lld+0x1d9544b)
#19 0x00005611871d54c0 lld::elf::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) (/work/et/build/llvm/bin/ld.lld+0x1d974c0)
#20 0x0000561187065f70 lld::unsafeLldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>, bool) (/work/et/build/llvm/bin/ld.lld+0x1c27f70)
#21 0x0000561186fa02a6 lld_main(int, char**, llvm::ToolContext const&) (/work/et/build/llvm/bin/ld.lld+0x1b622a6)
#22 0x0000561186fa064b main (/work/et/build/llvm/bin/ld.lld+0x1b6264b)
#23 0x00007f1c1a229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#24 0x00007f1c1a229e40 call_init ./csu/../csu/libc-start.c:128:20
#25 0x00007f1c1a229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#26 0x0000561186f9fae5 _start (/work/et/build/llvm/bin/ld.lld+0x1b61ae5)
fish: Job 1, '/work/et/build/llvm/bin/ld.lld…' terminated by signal SIGABRT (Abort)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWVtv47gZ_TXMCyGBou4PeVAubrfwoIMkaB8FiqRsNhQpkFQu--sLUk5sOd40624xC3QGGVuiyMNzeDnfJ5pYKzaK80uQX4H85oJMbqvNpbaOKEUMu-g0e7182AoLDR-NZhPlBjpiOiIlBLjq9aQYfN4KyWE3CcmE2sCtc6MFaQPwCuDVRrjt1MVUDwCvmrtvkdW9eyaGA7xar__xLeJDxxnjLHJaS7olQkW9NlFjhgBQQ0omyy0kChJruXFCKygUlJL5TtANQG-f-VWgGTti4s2vIL8BuPqEzWS5iYhzhG4HrpwFeNULyf13UuCsSBEGeLWAxPWiwwLt_uZbnEGAV8_aPAK84g7gVRgUgFdSPvkeO6H8DYulZDCK6NZo7WAMIwmpcSiyfBBbbZ0v2F-bkbgtPAVL9TAKyU1kfCkxw1NJWj_ArdL92PIX1RrnBMAra-hB_da49jdrR--kRTejRpN6VPpZRUorHnHSCeiG0Y8gHUYmcOu4dVGZEIqKWP-5mM5PqSRq0xoX-xZOKBuTMOj-Y4DRlXXECQqj2zWMIkuNGB0cBdW-6TjGfrbWfy5dv0Vot9LmlkF2ZCblxBDWtYc6HJ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