Skip to content

feat: LoongArch64 support#1409

Merged
marxin merged 69 commits intowild-linker:mainfrom
marxin:loongarch64-support
Jan 3, 2026
Merged

feat: LoongArch64 support#1409
marxin merged 69 commits intowild-linker:mainfrom
marxin:loongarch64-support

Conversation

@marxin
Copy link
Copy Markdown
Collaborator

@marxin marxin commented Dec 29, 2025

The LoongArch64 port is looking good based on the integration tests (and the capability to bootstrap Wild itself!). I would like to list a couple of significant changes/needs for the port:

  1. The port needs a couple of High/Low part relocations where the former needs a bias (typically 0x800), so I decided to make it a first class citizen in the RelocationKindInfo type (plus I noticed a couple of relocations need to first apply addend before masking -> that's why I touched so many relocation expression calculations).
  2. LoongArch64 does not use a specific TLSGD Low part relocations for GOT and so we need to special-case it a bit.
  3. The target also uses the page masking, so I decided to make it an explicit parameter, rather than the currently used AArch64 constants.
  4. There's one super-complex relocation calculation that I decided to move to a separate function highest_relocation_with_bias.
  5. Just recently, there was a new addition of relocation in the latest spec release (v2.50) - for now I haven't implemented them.
  6. PairSubtractionULEB128 has been factored out as it's something used by both AArch64 and the newly added LoongArch64 port.

Some early benchmarks for linking the Mold project on Loongson-3A6000 8 core CPU:

| Linker | With debug info (s) | Without debug info (s) |
|--------|----------------------|-------------------------|
| bfd    | 65.0                 | 24.0                    |
| mold   | 4.4                  | 1.82                    |
| lld    | 10.4                 | 8.0                     |
| wild   | 11.8                 | 0.953                   |

I would like to thank @Gelbpunkt for the SSH access to the Alpine LoongArch64 machine! Really helped me.

Resolves: #1381

@marxin marxin force-pushed the loongarch64-support branch from 3f7ec38 to 6005fcc Compare December 29, 2025 21:31
@marxin marxin force-pushed the loongarch64-support branch from 7c8f626 to 76764fb Compare December 29, 2025 23:00
@marxin marxin force-pushed the loongarch64-support branch from 7f5080c to dbdec61 Compare December 30, 2025 21:35
@marxin marxin changed the title LoongArch64 support feat: LoongArch64 support Dec 31, 2025
@marxin marxin marked this pull request as ready for review December 31, 2025 12:42
@marxin marxin force-pushed the loongarch64-support branch from 55bf282 to 5cadd11 Compare December 31, 2025 13:13
Copy link
Copy Markdown
Member

@davidlattimore davidlattimore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

Comment thread wild/tests/sources/section-start.c
Comment thread linker-utils/src/elf.rs Outdated
@marxin marxin merged commit fa8703d into wild-linker:main Jan 3, 2026
20 of 21 checks passed
@marxin marxin deleted the loongarch64-support branch January 3, 2026 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LoongArch64 support

2 participants