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

    <tr>
        <th>Summary</th>
        <td>
            Assertion Failure in LLD after
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            lld:ELF,
            crash
      </td>
    </tr>

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

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

<pre>
    We're hitting an assertion after bbf7b9d when building Fuchsia. 

Bot: https://luci-milo.appspot.com/ui/p/fuchsia/builders/ci/clang_toolchain.ci.core.x64-release/b8766941698462381393/overview

Error Output
```
FAILED: kernel_x64/zircon.elf kernel_x64/zircon.elf.map kernel_x64/zircon.elf.build-id.stamp 
../../prebuilt/third_party/clang/custom/bin/clang++ -o kernel_x64/zircon.elf -Wl,-T,../../zircon/kernel/kernel.ld -Wl,--emit-relocs -g3 -gdwarf-4 -gz=zstd -fdata-sections -ffunction-sections -Wl,--gc-sections -O2 -fno-exceptions -fno-rtti -ffile-compilation-dir=. -no-canonical-prefixes -fuse-ld=lld -Wl,-z,relro --target=x86_64-fuchsia -fcolor-diagnostics -Wl,--color-diagnostics -fcrash-diagnostics-dir=clang-crashreports -fcrash-diagnostics=all -gen-reproducer=error -Wl,--icf=all -nostdlib -static -Wl,--no-pie -fno-exceptions -fdata-sections -fno-omit-frame-pointer -fno-omit-frame-pointer -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-defsym,KERNEL_BASE=0xffffffff80100000 -Wl,-defsym,SMP_MAX_CPUS=32 -Wl,-defsym,BOOT_HEADER_SIZE=0x50 -Wl,--dependency-file=kernel_x64/zircon.elf.d -Wl,-Map,kernel_x64/zircon.elf.map -Wl,--start-group '@kernel_x64/zircon.elf.rsp' ../../src/lib/elfldltl/self-base.ld -Wl,--end-group  && ../../prebuilt/tools/buildidtool/linux-x64/buildidtool -build-id-dir ".build-id" -stamp "kernel_x64/zircon.elf.build-id.stamp" -entry "=kernel_x64/zircon.elf" -entry ".debug=kernel_x64/zircon.elf"
ld.lld: lld/ELF/InputSection.cpp:438: void lld::elf::InputSection::copyRelocations(uint8_t *, llvm::iterator_range<RelIt>) [ELFT = llvm::object::ELFType<llvm::endianness::little, true>, RelTy = llvm::object::Elf_Rel_Impl<llvm::object::ELFType<llvm::endianness::little, true>, true>, RelIt = llvm::mapped_iterator<const llvm::object::Elf_Rel_Impl<llvm::object::ELFType<llvm::endianness::little, true>, true> *, MapRel>]: Assertion `section->isLive()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
ld.lld: lld/ELF/InputSection.cpp:438: void lld::elf::InputSection::copyRelocations(uint8_t *, llvm::iterator_range<RelIt>) [ELFT = llvm::object::ELFType<llvm::endianness::little, true>, RelTy = llvm::object::Elf_Rel_Impl<llvm::object::ELFType<llvm::endianness::little, true>, true>, RelIt = llvm::mapped_iterator<const llvm::object::Elf_Rel_Impl<llvm::object::ELFType<llvm::endianness::little, true>, true> *, MapRel>]: Assertion `section->isLive()' failed.
clang++: error: unable to execute command: Aborted
clang++: error: ld.lld command failed due to signal (use -v to see invocation)
Fuchsia clang version 18.0.0 (https://llvm.googlesource.com/llvm-project 6971081cefdc498ed474182cc06aec68b007955c)
Target: x86_64-unknown-fuchsia
Thread model: posix
InstalledDir: ../../prebuilt/third_party/clang/custom/bin
clang++: note: diagnostic msg: 
```


I had to split the reproducer w/ zip to work around github upload limitations. You should be able to recombine them in the following way:
```
mv linker-reproducer.z01.zip linker-reproducer.z01 # rename file to work around github upload limitations

zip -F linker-reproducer.zip --out combined-reproducer.zip
```
The following page has more details if needed: https://superuser.com/questions/336219/how-do-i-split-a-zip-file-into-multiple-segments

[linker-reproducer.zip](https://github.com/llvm/llvm-project/files/13030971/linker-reproducer.zip)

[linker-reproducer.z01.zip](https://github.com/llvm/llvm-project/files/13030980/linker-reproducer.z01.zip)

CC: @MaskRay 
</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