[lld][ELF] Support LoongArch
authorWANG Xuerui <git@xen0n.name>
Tue, 25 Jul 2023 09:03:28 +0000 (17:03 +0800)
committerWeining Lu <luweining@loongson.cn>
Tue, 25 Jul 2023 09:06:07 +0000 (17:06 +0800)
commit6084ee742064cf8121444febee342133b0cb7abd
treec1411cf1e4795a5fd6149c087e068d4eaac6234d
parent4cf11d8a65dfded59761ec52804a86277b9c0036
[lld][ELF] Support LoongArch

This adds support for the LoongArch ELF psABI v2.00 [1] relocation
model to LLD. The deprecated stack-machine-based psABI v1 relocs are not
supported.

The code is tested by successfully bootstrapping a Gentoo/LoongArch
stage3, complete with common GNU userland tools and both the LLVM and
GNU toolchains (GNU toolchain is present only for building glibc,
LLVM+Clang+LLD are used for the rest). Large programs like QEMU are
tested to work as well.

[1]: https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html

Reviewed By: MaskRay, SixWeining

Differential Revision: https://reviews.llvm.org/D138135
29 files changed:
lld/ELF/Arch/LoongArch.cpp [new file with mode: 0644]
lld/ELF/CMakeLists.txt
lld/ELF/Driver.cpp
lld/ELF/InputFiles.cpp
lld/ELF/InputSection.cpp
lld/ELF/Relocations.cpp
lld/ELF/Relocations.h
lld/ELF/ScriptParser.cpp
lld/ELF/Target.cpp
lld/ELF/Target.h
lld/docs/ReleaseNotes.rst
lld/docs/index.rst
lld/docs/ld.lld.1
lld/test/ELF/emulation-loongarch.s [new file with mode: 0644]
lld/test/ELF/loongarch-abs64.s [new file with mode: 0644]
lld/test/ELF/loongarch-add-sub.s [new file with mode: 0644]
lld/test/ELF/loongarch-branch.s [new file with mode: 0644]
lld/test/ELF/loongarch-interlink.test [new file with mode: 0644]
lld/test/ELF/loongarch-pc-aligned.s [new file with mode: 0644]
lld/test/ELF/loongarch-pcala-lo12-jirl-shared.s [new file with mode: 0644]
lld/test/ELF/loongarch-pcala-lo12-jirl.s [new file with mode: 0644]
lld/test/ELF/loongarch-plt.s [new file with mode: 0644]
lld/test/ELF/loongarch-reloc-pic.s [new file with mode: 0644]
lld/test/ELF/loongarch-tls-gd-edge-case.s [new file with mode: 0644]
lld/test/ELF/loongarch-tls-gd.s [new file with mode: 0644]
lld/test/ELF/loongarch-tls-ie.s [new file with mode: 0644]
lld/test/ELF/loongarch-tls-ld.s [new file with mode: 0644]
lld/test/ELF/loongarch-tls-le.s [new file with mode: 0644]
lld/test/lit.cfg.py