[llvm] [LoongArch] Insert nops and emit align reloc when handle alignment directive (PR #72962)

Jinyang He via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 16 18:01:58 PST 2024


================
@@ -0,0 +1,53 @@
+# RUN: llvm-mc --filetype=obj --triple=loongarch64 --mattr=-relax %s \
+# RUN:     | llvm-readelf -rs - | FileCheck %s --check-prefix=NORELAX
+# RUN: llvm-mc --filetype=obj --triple=loongarch64 --mattr=+relax %s \
+# RUN:     | llvm-readelf -rs - | FileCheck %s --check-prefix=RELAX
+# RUN: llvm-mc --filetype=obj --triple=loongarch64 --mattr=+relax %s \
+# RUN:     | llvm-objdump -d - | FileCheck -check-prefix=RELAX-INST %s
+
+# NORELAX: There are no relocations in this file.
+# NORELAX: Symbol table '.symtab' contains 1 entries:
+
+# RELAX:       0000000000000000  0000000100000066 R_LARCH_ALIGN          0000000000000000 {{.*}} + 4
+# RELAX-NEXT:  0000000000000010  0000000100000066 R_LARCH_ALIGN          0000000000000000 {{.*}} + 5
+# RELAX-NEXT:  000000000000002c  0000000100000066 R_LARCH_ALIGN          0000000000000000 {{.*}} + 4
+# RELAX-NEXT:  000000000000003c  0000000100000066 R_LARCH_ALIGN          0000000000000000 {{.*}} + b04
+# RELAX-NEXT:  0000000000000048  0000000100000066 R_LARCH_ALIGN          0000000000000000 {{.*}} + 4
+# RELAX-EMPTY:
+# RELAX:       0000000000000000  0000000200000066 R_LARCH_ALIGN          0000000000000000 <null> + 4
+# RELAX-EMPTY:
+# RELAX:       Symbol table '.symtab' contains 3 entries:
----------------
MQ-mengqing wrote:

As I mentioned earlier, we need to create the symbol for R_LARCH_ALIGN. It seems that this symbol needs to be kept in the same section as the alignment directive (see [1]). So this test case wants to check that two symbols are created and that they are in different sections in the relocation table. The `llvm-objdump -dr` cannot check that case, is there any other suitable method?

[1] https://sourceware.org/pipermail/binutils/2024-January/131615.html

https://github.com/llvm/llvm-project/pull/72962


More information about the llvm-commits mailing list