[v3,00/12] Add support for LoongArch32 in Binutils

Message ID 20251205064759.2102819-1-mengqinggang@loongson.cn
Headers
Series Add support for LoongArch32 in Binutils |

Message

mengqinggang Dec. 5, 2025, 6:47 a.m. UTC
  Add support for LoongArch32 (LA32) and LoongArch32 Reduced (LA32R).
Add some new relocations for LA32 and LA32R.

The discussion about relocations is here[1].
The gcc, glibc and kernel patches is here[2] [3] [4].
The binutils, gcc and glibc source code are also here[5] [6] [7].
A LA32 linux system based on qemu-user is here[8].

[1] https://github.com/loongson/la-abi-specs/pull/16
[2] https://sourceware.org/pipermail/gcc-patches/2025-November/702128.html
[3] https://sourceware.org/pipermail/libc-alpha/2025-December/173146.html
[4] https://lore.kernel.org/loongarch/20251127154832.137925-1-chenhuacai@loongson.cn/
[5] https://github.com/cloudspurs/binutils/tree/la32 
[6] https://github.com/cloudspurs/gcc/tree/la32 
[7] https://github.com/cloudspurs/glibc/tree/la32 
[8] https://github.com/sunhaiyong1978/CLFS-for-LoongArch32/blob/main/Qemu_For_LoongArch32-Simple.md

v2 -> v3:
- Add call/tail, call/tail can expand to call36/tail36 or call30/tail30 by
  -mabi option.
- Add tests about relocations, tls type transition, got relaxation and call30
  relaxation.
- Modify some comments based on Xuerui's suggestions.

v1 -> v2:
- Add some new relocations for LA32 and LA32R.
- Add tls type transition and got relaxation.

v2: https://sourceware.org/pipermail/binutils/2025-December/146091.html 
v1: https://sourceware.org/pipermail/binutils/2025-June/141697.html

Jiajie Chen (1):
  LoongArch: Change DWARF2_CIE_DATA_ALIGNMENT to -4 for loongarch32

Lulu Cai (1):
  LoongArch32: Fix and add testcases

mengqinggang (10):
  LoongArch: Enable loongarch_elf64_vec loongarch64_pei_vec on LA32
    target
  LoongArch: Add R_LARCH_TLS_LE_ADD_R relocation support for add.w
  LoongArch: Enable all instructions by default on LA32 like LA64
  LoongArch: Add LA32 and LA32R relocations
  LoongArch: Add processing for LA32/LA32R relocations
  LoongArch: LA32 macros support
  LoongArch: LA32R macros expand
  LoongArch: Add linker relaxation support for R_LARCH_CALL30
  LoongArch: Add support for tls type transition on LA32
  LoongArch: Add linker relaxation for got_pcadd_hi20 and got_pcadd_lo12

 bfd/bfd-in2.h                                 |  13 +
 bfd/config.bfd                                |   2 +-
 bfd/elfnn-loongarch.c                         | 553 +++++++++++++++---
 bfd/elfxx-loongarch.c                         | 229 ++++++++
 bfd/libbfd.h                                  |  13 +
 bfd/reloc.c                                   |  27 +
 gas/config/tc-loongarch.c                     | 174 ++++--
 gas/config/tc-loongarch.h                     |   3 +-
 gas/testsuite/gas/loongarch/macro_op_32.d     |  72 ++-
 gas/testsuite/gas/loongarch/relocs_32.d       |  49 ++
 gas/testsuite/gas/loongarch/relocs_32.s       |  37 ++
 include/elf/loongarch.h                       |  35 ++
 include/opcode/loongarch.h                    |   4 +
 ld/testsuite/ld-loongarch-elf/desc-ie.d       |   9 +-
 ld/testsuite/ld-loongarch-elf/disas-jirl-32.d |  14 +-
 ld/testsuite/ld-loongarch-elf/la32.d          |  15 +
 ld/testsuite/ld-loongarch-elf/la32.s          |  14 +
 .../ld-loongarch-elf/ld-loongarch-elf.exp     |   4 +
 ld/testsuite/ld-loongarch-elf/macro_op_32.d   |  72 ++-
 ld/testsuite/ld-loongarch-elf/pic.exp         |   4 +-
 opcodes/loongarch-opc.c                       |  78 ++-
 21 files changed, 1189 insertions(+), 232 deletions(-)
 create mode 100644 ld/testsuite/ld-loongarch-elf/la32.d
 create mode 100644 ld/testsuite/ld-loongarch-elf/la32.s