Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lld/test/ELF/loongarch-relax-align.s
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# REQUIRES: loongarch

# RUN: llvm-mc --filetype=obj --triple=loongarch32 --mattr=+relax %s -o %t.32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch64 --mattr=+relax %s -o %t.64.o
# RUN: llvm-mc --filetype=obj --triple=loongarch32 --mattr=+32s,+relax %s -o %t.32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch64 --mattr=+32s,+relax %s -o %t.64.o
# RUN: ld.lld --section-start=.text=0x10000 --section-start=.text2=0x20000 -e 0 %t.32.o -o %t.32
# RUN: ld.lld --section-start=.text=0x10000 --section-start=.text2=0x20000 -e 0 %t.64.o -o %t.64
# RUN: ld.lld --section-start=.text=0x10000 --section-start=.text2=0x20000 -e 0 --no-relax %t.32.o -o %t.32n
Expand Down
2 changes: 1 addition & 1 deletion lld/test/ELF/loongarch-relax-emit-relocs.s
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# REQUIRES: loongarch
## Test that we can handle --emit-relocs while relaxing.

# RUN: llvm-mc --filetype=obj --triple=loongarch32 --mattr=+relax %s -o %t.32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch32 --mattr=+32s,+relax %s -o %t.32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch64 --mattr=+relax --defsym ELF64=1 %s -o %t.64.o
# RUN: ld.lld -Ttext=0x10000 -section-start=.got=0x20000 --emit-relocs %t.32.o -o %t.32
# RUN: ld.lld -Ttext=0x10000 -section-start=.got=0x20000 --emit-relocs %t.64.o -o %t.64
Expand Down
4 changes: 2 additions & 2 deletions lld/test/ELF/loongarch-relax-pc-hi20-lo12-got-symbols.s
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# REQUIRES: loongarch
# RUN: rm -rf %t && split-file %s %t && cd %t

# RUN: llvm-mc --filetype=obj --triple=loongarch32 -mattr=+relax symbols.s -o symbols.32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch32 -mattr=+32s,+relax symbols.s -o symbols.32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch64 -mattr=+relax symbols.s -o symbols.64.o
# RUN: llvm-mc --filetype=obj --triple=loongarch32 -mattr=+relax abs.s -o abs.32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch32 -mattr=+32s,+relax abs.s -o abs.32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch64 -mattr=+relax abs.s -o abs.64.o

# RUN: ld.lld --shared -Tlinker.t symbols.32.o abs.32.o -o symbols.32.so
Expand Down
4 changes: 2 additions & 2 deletions lld/test/ELF/loongarch-relax-pc-hi20-lo12.s
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# REQUIRES: loongarch
# RUN: rm -rf %t && split-file %s %t && cd %t

# RUN: llvm-mc --filetype=obj --triple=loongarch32 -mattr=+relax a.s -o a.32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch32 -mattr=+32s,+relax a.s -o a.32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch64 -mattr=+relax a.s -o a.64.o

# RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 a.32.o -o a.32
Expand Down Expand Up @@ -54,7 +54,7 @@


## GOT references with non-zero addends. No relaxation.
# RUN: llvm-mc --filetype=obj --triple=loongarch32 -mattr=+relax nonzero.s -o nonzero.32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch32 -mattr=+32s,+relax nonzero.s -o nonzero.32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch64 -mattr=+relax nonzero.s -o nonzero.64.o
# RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 nonzero.32.o -o nonzero.32
# RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 nonzero.64.o -o nonzero.64
Expand Down
4 changes: 2 additions & 2 deletions lld/test/ELF/loongarch-relocatable-align.s
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
# CHECK-REL: Relocation section '.rela.text1' at offset {{.*}} contains 5 entries:

## Test LA32.
# RUN: llvm-mc -filetype=obj -triple=loongarch32 -mattr=+relax a.s -o a.32.o
# RUN: llvm-mc -filetype=obj -triple=loongarch32 -mattr=+relax b.s -o b.32.o
# RUN: llvm-mc -filetype=obj -triple=loongarch32 -mattr=+32s,+relax a.s -o a.32.o
# RUN: llvm-mc -filetype=obj -triple=loongarch32 -mattr=+32s,+relax b.s -o b.32.o
# RUN: ld.lld -r a.32.o b.32.o -o out.32.ro
# RUN: ld.lld -Ttext=0x10000 out.32.ro -o out32
# RUN: llvm-objdump -dr --no-show-raw-insn out32 | FileCheck %s --check-prefix=CHECK32
Expand Down
2 changes: 1 addition & 1 deletion lld/test/ELF/loongarch-tls-gd-edge-case.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Edge case: when a TLS symbol is being accessed in both GD and IE manners,
## correct reloc behavior should be preserved for both kinds of accesses.

# RUN: llvm-mc --filetype=obj --triple=loongarch32 %s -o %t.la32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch32 --mattr=+32s %s -o %t.la32.o
# RUN: ld.lld %t.la32.o -shared -o %t.la32
# RUN: llvm-mc --filetype=obj --triple=loongarch64 %s -o %t.la64.o
# RUN: ld.lld %t.la64.o -shared -o %t.la64
Expand Down
8 changes: 4 additions & 4 deletions lld/test/ELF/loongarch-tls-gd.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
## (a) code sequence can be converted from `pcalau12i+addi.[wd]` to `pcaddi`.
## (b) dynamic relocations can be omitted for GD->LE relaxation.

# RUN: llvm-mc --filetype=obj --triple=loongarch32 %t/a.s -o %t/a.32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch32 -mattr=+relax %t/a.s -o %t/a.32.relax.o
# RUN: llvm-mc --filetype=obj --triple=loongarch32 %t/bc.s -o %t/bc.32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch32 -mattr=+32s %t/a.s -o %t/a.32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch32 -mattr=+32s,+relax %t/a.s -o %t/a.32.relax.o
# RUN: llvm-mc --filetype=obj --triple=loongarch32 -mattr=+32s %t/bc.s -o %t/bc.32.o
# RUN: ld.lld -shared -soname=bc.so %t/bc.32.o -o %t/bc.32.so
# RUN: llvm-mc --filetype=obj --triple=loongarch32 %t/tga.s -o %t/tga.32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch32 -mattr=+32s %t/tga.s -o %t/tga.32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch64 %t/a.s -o %t/a.64.o
# RUN: llvm-mc --filetype=obj --triple=loongarch64 %t/a.s -mattr=+relax -o %t/a.64.relax.o
# RUN: llvm-mc --filetype=obj --triple=loongarch64 %t/bc.s -o %t/bc.64.o
Expand Down
2 changes: 1 addition & 1 deletion lld/test/ELF/loongarch-tls-ie.s
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# REQUIRES: loongarch
# RUN: rm -rf %t && split-file %s %t

# RUN: llvm-mc --filetype=obj --triple=loongarch32 %t/32.s -o %t/32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch32 --mattr=+32s %t/32.s -o %t/32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch64 %t/64.s -o %t/64.o

## LA32 IE
Expand Down
6 changes: 3 additions & 3 deletions lld/test/ELF/loongarch-tls-ld.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
## (a) code sequence can be converted from `pcalau12i+addi.[wd]` to `pcaddi`.
## (b) dynamic relocations can be omitted for LD->LE relaxation.

# RUN: llvm-mc --filetype=obj --triple=loongarch32 --position-independent %t/a.s -o %t/a.32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch32 --position-independent -mattr=+relax %t/a.s -o %t/a.32.relax.o
# RUN: llvm-mc --filetype=obj --triple=loongarch32 %t/tga.s -o %t/tga.32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch32 --position-independent -mattr=+32s %t/a.s -o %t/a.32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch32 --position-independent -mattr=+32s,+relax %t/a.s -o %t/a.32.relax.o
# RUN: llvm-mc --filetype=obj --triple=loongarch32 -mattr=+32s %t/tga.s -o %t/tga.32.o
# RUN: llvm-mc --filetype=obj --triple=loongarch64 --position-independent %t/a.s -o %t/a.64.o
# RUN: llvm-mc --filetype=obj --triple=loongarch64 --position-independent -mattr=+relax %t/a.s -o %t/a.64.relax.o
# RUN: llvm-mc --filetype=obj --triple=loongarch64 %t/tga.s -o %t/tga.64.o
Expand Down
4 changes: 2 additions & 2 deletions lld/test/ELF/loongarch-tlsdesc.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# RUN: llvm-mc -filetype=obj -triple=loongarch64 a.s -o a.64.o
# RUN: llvm-mc -filetype=obj -triple=loongarch64 c.s -o c.64.o
# RUN: ld.lld -shared -soname=c.64.so c.64.o -o c.64.so
# RUN: llvm-mc -filetype=obj -triple=loongarch32 --defsym ELF32=1 a.s -o a.32.o
# RUN: llvm-mc -filetype=obj -triple=loongarch32 --defsym ELF32=1 c.s -o c.32.o
# RUN: llvm-mc -filetype=obj -triple=loongarch32 --mattr=+32s --defsym ELF32=1 a.s -o a.32.o
# RUN: llvm-mc -filetype=obj -triple=loongarch32 --mattr=+32s --defsym ELF32=1 c.s -o c.32.o
# RUN: ld.lld -shared -soname=c.32.so c.32.o -o c.32.so

# RUN: ld.lld -shared -z now a.64.o c.64.o -o a.64.so
Expand Down
13 changes: 13 additions & 0 deletions llvm/include/llvm/BinaryFormat/ELFRelocs/LoongArch.def
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,16 @@ ELF_RELOC(R_LARCH_TLS_LE_LO12_R, 123)
ELF_RELOC(R_LARCH_TLS_LD_PCREL20_S2, 124)
ELF_RELOC(R_LARCH_TLS_GD_PCREL20_S2, 125)
ELF_RELOC(R_LARCH_TLS_DESC_PCREL20_S2, 126)

// Relocs added in ELF for the LoongArch™ Architecture v2025????, part of the
// v2.40 LoongArch ABI specs.
//
// Spec addition: https://github.com/loongson/la-abi-specs/pull/16
ELF_RELOC(R_LARCH_CALL30, 127)
ELF_RELOC(R_LARCH_PCADD_HI20, 128)
ELF_RELOC(R_LARCH_GOT_PCADD_HI20, 129)
ELF_RELOC(R_LARCH_TLS_IE_PCADD_HI20, 130)
ELF_RELOC(R_LARCH_TLS_LD_PCADD_HI20, 131)
ELF_RELOC(R_LARCH_TLS_GD_PCADD_HI20, 132)
ELF_RELOC(R_LARCH_TLS_DESC_PCADD_HI20, 133)
ELF_RELOC(R_LARCH_PCADD_LO12, 134)
Loading
Loading