[llvm] 5bbf01f - MC,test: Improve section symbol test
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 23 22:28:33 PDT 2025
Author: Fangrui Song
Date: 2025-07-23T22:28:28-07:00
New Revision: 5bbf01f7cbd98f9bf79eeaeecd43c28e38cb94fa
URL: https://github.com/llvm/llvm-project/commit/5bbf01f7cbd98f9bf79eeaeecd43c28e38cb94fa
DIFF: https://github.com/llvm/llvm-project/commit/5bbf01f7cbd98f9bf79eeaeecd43c28e38cb94fa.diff
LOG: MC,test: Improve section symbol test
Added:
Modified:
llvm/test/MC/ELF/section-sym-err.s
llvm/test/MC/ELF/section-sym2.s
Removed:
llvm/test/MC/ELF/section-sym-err2.s
################################################################################
diff --git a/llvm/test/MC/ELF/section-sym-err.s b/llvm/test/MC/ELF/section-sym-err.s
index afed21dbe7237..2f7ab6907aa5d 100644
--- a/llvm/test/MC/ELF/section-sym-err.s
+++ b/llvm/test/MC/ELF/section-sym-err.s
@@ -1,6 +1,9 @@
-// RUN: not llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o %t.o 2>&1 | FileCheck %s
+# RUN: not llvm-mc -filetype=obj -triple x86_64 %s -o %t 2>&1 | FileCheck %s
.section foo
foo:
+# CHECK: [[#@LINE-1]]:1: error: symbol 'foo' is already defined
-// CHECK: error: symbol 'foo' is already defined
+x1:
+.section x1
+# CHECK: <unknown>:0: error: invalid symbol redefinition
diff --git a/llvm/test/MC/ELF/section-sym-err2.s b/llvm/test/MC/ELF/section-sym-err2.s
deleted file mode 100644
index 27d8e9a9ac249..0000000000000
--- a/llvm/test/MC/ELF/section-sym-err2.s
+++ /dev/null
@@ -1,6 +0,0 @@
-// RUN: not llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o %t.o 2>&1 | FileCheck %s
-
-foo:
-.section foo
-
-// CHECK: error: invalid symbol redefinition
diff --git a/llvm/test/MC/ELF/section-sym2.s b/llvm/test/MC/ELF/section-sym2.s
index b404ef79414df..167fc8c938ea4 100644
--- a/llvm/test/MC/ELF/section-sym2.s
+++ b/llvm/test/MC/ELF/section-sym2.s
@@ -1,24 +1,27 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj --symbols -r --expand-relocs - | FileCheck %s
+# RUN: llvm-mc -filetype=obj -triple x86_64 %s -o %t
+# RUN: llvm-readelf -Srs %t | FileCheck %s
-// Test that we can forward reference a section.
+## Test that we can forward reference a section.
mov .rodata, %rsi
-.section .rodata
+mov .debug_info, %rsi
-// CHECK:Relocations [
-// CHECK: Section {{.*}} .rela.text {
-// CHECK: Relocation {
-// CHECK: Offset: 0x4
-// CHECK: Type: R_X86_64_32S (11)
-// CHECK: Symbol: .rodata
-// CHECK: Addend: 0x0
-// CHECK: }
-// CHECK: }
-// CHECK:]
+.section .rodata,"a"
+.section .debug_info,"G", at progbits,11,comdat; .long x1
+.section .debug_info,"G", at progbits,22,comdat; .long x2
+.section .debug_info,"", at progbits; .long x0
-// There is only one .rodata symbol
+# CHECK: Relocation section '.rela.debug_info' at offset {{.*}} contains 1
+# CHECK: Relocation section '.rela.debug_info' at offset {{.*}} contains 1
+# CHECK: Relocation section '.rela.debug_info' at offset {{.*}} contains 1
-// CHECK:Symbols [
-// CHECK: Type: Section (0x3)
-// CHECK: Section: .rodata
-// CHECK-NOT: Section: .rodata
+# CHECK: Symbol table '.symtab' contains 8 entries:
+# CHECK-NEXT: Num: Value Size Type Bind Vis Ndx Name
+# CHECK-NEXT: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
+# CHECK-NEXT: 0000000000000000 0 SECTION LOCAL DEFAULT 4 .rodata
+# CHECK-NEXT: 0000000000000000 0 SECTION LOCAL DEFAULT 11 .debug_info
+# CHECK-NEXT: 0000000000000000 0 NOTYPE LOCAL DEFAULT 5 11
+# CHECK-NEXT: 0000000000000000 0 NOTYPE LOCAL DEFAULT 8 22
+# CHECK-NEXT: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND x1
+# CHECK-NEXT: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND x2
+# CHECK-NEXT: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND x0
More information about the llvm-commits
mailing list