Skip to content

[Object] Handle SHT_CREL relocation sections when resolving relocation data #141843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 29, 2025

Conversation

ZequanWu
Copy link
Contributor

Fixes #141680

@llvmbot
Copy link
Member

llvmbot commented May 28, 2025

@llvm/pr-subscribers-llvm-binary-utilities

@llvm/pr-subscribers-debuginfo

Author: Zequan Wu (ZequanWu)

Changes

Fixes #141680


Full diff: https://github.com/llvm/llvm-project/pull/141843.diff

2 Files Affected:

  • (modified) llvm/lib/Object/RelocationResolver.cpp (+2-1)
  • (added) llvm/test/tools/llvm-dwarfdump/X86/debug_info_crel.s (+288)
diff --git a/llvm/lib/Object/RelocationResolver.cpp b/llvm/lib/Object/RelocationResolver.cpp
index a28f5943c320d..8cf748aa5681c 100644
--- a/llvm/lib/Object/RelocationResolver.cpp
+++ b/llvm/lib/Object/RelocationResolver.cpp
@@ -888,7 +888,8 @@ uint64_t resolveRelocation(RelocationResolver Resolver, const RelocationRef &R,
         return Elf64BEObj->getRelSection(R.getRawDataRefImpl())->sh_type;
       };
 
-      if (GetRelSectionType() == ELF::SHT_RELA) {
+      if (GetRelSectionType() == ELF::SHT_RELA ||
+          GetRelSectionType() == ELF::SHT_CREL) {
         Addend = getELFAddend(R);
         // LoongArch and RISCV relocations use both LocData and Addend.
         if (Obj->getArch() != Triple::loongarch32 &&
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_info_crel.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_info_crel.s
new file mode 100644
index 0000000000000..b21018d10361f
--- /dev/null
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_info_crel.s
@@ -0,0 +1,288 @@
+# Test llvm-dwarfdump handles CREL relocation sections correctly.
+# Generated from the following code and command:
+# $ clang++ -O1 -Wa,--crel,--allow-experimental-crel -g -S foo.cpp -o foo.s
+# int foo(bool b, int x) {
+#   if (b)
+#     return x;
+#   else
+#     return x + 1;
+# }
+
+# RUN: llvm-mc %s -filetype=obj -triple=x86_64-pc-linux -o %t
+# RUN: llvm-dwarfdump --debug-info %t | FileCheck %s
+# CHECK:      DW_AT_producer    ("clang version
+# CHECK-NEXT: DW_AT_language    (DW_LANG_C_plus_plus_14)
+# CHECK-NEXT: DW_AT_name        ("foo.cpp")
+# CHECK-NEXT: DW_AT_str_offsets_base    (0x00000008)
+# CHECK-NEXT: DW_AT_stmt_list   (0x00000000)
+# CHECK-NEXT: DW_AT_comp_dir    ("/tmp")
+# CHECK-NEXT: DW_AT_low_pc      (0x0000000000000000)
+# CHECK-NEXT: DW_AT_high_pc     (0x000000000000000b)
+# CHECK-NEXT: DW_AT_addr_base   (0x00000008)
+# CHECK-NEXT: DW_AT_loclists_base       (0x0000000c)
+
+	.file	"foo.cpp"
+	.text
+	.globl	_Z3foobi                        # -- Begin function _Z3foobi
+	.p2align	4
+	.type	_Z3foobi,@function
+_Z3foobi:                               # @_Z3foobi
+.Lfunc_begin0:
+	.file	0 "/tmp" "foo.cpp" md5 0x33d1d90807761bceb53376a52dc68c38
+	.cfi_startproc
+# %bb.0:                                # %entry
+	#DEBUG_VALUE: foo:b <- [DW_OP_LLVM_convert 1 7, DW_OP_LLVM_convert 8 7, DW_OP_stack_value] $edi
+	#DEBUG_VALUE: foo:x <- $esi
+	.loc	0 2 7 prologue_end              # foo.cpp:2:7
+	xorb	$1, %dil
+.Ltmp0:
+	movzbl	%dil, %eax
+	addl	%esi, %eax
+.Ltmp1:
+	.loc	0 6 1                           # foo.cpp:6:1
+	retq
+.Ltmp2:
+.Lfunc_end0:
+	.size	_Z3foobi, .Lfunc_end0-_Z3foobi
+	.cfi_endproc
+                                        # -- End function
+	.section	.debug_loclists,"",@progbits
+	.long	.Ldebug_list_header_end0-.Ldebug_list_header_start0 # Length
+.Ldebug_list_header_start0:
+	.short	5                               # Version
+	.byte	8                               # Address size
+	.byte	0                               # Segment selector size
+	.long	1                               # Offset entry count
+.Lloclists_table_base0:
+	.long	.Ldebug_loc0-.Lloclists_table_base0
+.Ldebug_loc0:
+	.byte	4                               # DW_LLE_offset_pair
+	.uleb128 .Lfunc_begin0-.Lfunc_begin0    #   starting offset
+	.uleb128 .Ltmp0-.Lfunc_begin0           #   ending offset
+	.byte	20                              # Loc expr size
+	.byte	117                             # DW_OP_breg5
+	.byte	0                               # 0
+	.byte	16                              # DW_OP_constu
+	.byte	255                             # 4294967295
+	.byte	255                             # 
+	.byte	255                             # 
+	.byte	255                             # 
+	.byte	15                              # 
+	.byte	26                              # DW_OP_and
+	.byte	168                             # DW_OP_convert
+	.asciz	"\247\200\200"                  # 
+	.byte	168                             # DW_OP_convert
+	.asciz	"\253\200\200"                  # 
+	.byte	159                             # DW_OP_stack_value
+	.byte	0                               # DW_LLE_end_of_list
+.Ldebug_list_header_end0:
+	.section	.debug_abbrev,"",@progbits
+	.byte	1                               # Abbreviation Code
+	.byte	17                              # DW_TAG_compile_unit
+	.byte	1                               # DW_CHILDREN_yes
+	.byte	37                              # DW_AT_producer
+	.byte	37                              # DW_FORM_strx1
+	.byte	19                              # DW_AT_language
+	.byte	5                               # DW_FORM_data2
+	.byte	3                               # DW_AT_name
+	.byte	37                              # DW_FORM_strx1
+	.byte	114                             # DW_AT_str_offsets_base
+	.byte	23                              # DW_FORM_sec_offset
+	.byte	16                              # DW_AT_stmt_list
+	.byte	23                              # DW_FORM_sec_offset
+	.byte	27                              # DW_AT_comp_dir
+	.byte	37                              # DW_FORM_strx1
+	.byte	17                              # DW_AT_low_pc
+	.byte	27                              # DW_FORM_addrx
+	.byte	18                              # DW_AT_high_pc
+	.byte	6                               # DW_FORM_data4
+	.byte	115                             # DW_AT_addr_base
+	.byte	23                              # DW_FORM_sec_offset
+	.ascii	"\214\001"                      # DW_AT_loclists_base
+	.byte	23                              # DW_FORM_sec_offset
+	.byte	0                               # EOM(1)
+	.byte	0                               # EOM(2)
+	.byte	2                               # Abbreviation Code
+	.byte	36                              # DW_TAG_base_type
+	.byte	0                               # DW_CHILDREN_no
+	.byte	3                               # DW_AT_name
+	.byte	37                              # DW_FORM_strx1
+	.byte	62                              # DW_AT_encoding
+	.byte	11                              # DW_FORM_data1
+	.byte	11                              # DW_AT_byte_size
+	.byte	11                              # DW_FORM_data1
+	.byte	0                               # EOM(1)
+	.byte	0                               # EOM(2)
+	.byte	3                               # Abbreviation Code
+	.byte	46                              # DW_TAG_subprogram
+	.byte	1                               # DW_CHILDREN_yes
+	.byte	17                              # DW_AT_low_pc
+	.byte	27                              # DW_FORM_addrx
+	.byte	18                              # DW_AT_high_pc
+	.byte	6                               # DW_FORM_data4
+	.byte	64                              # DW_AT_frame_base
+	.byte	24                              # DW_FORM_exprloc
+	.byte	122                             # DW_AT_call_all_calls
+	.byte	25                              # DW_FORM_flag_present
+	.byte	110                             # DW_AT_linkage_name
+	.byte	37                              # DW_FORM_strx1
+	.byte	3                               # DW_AT_name
+	.byte	37                              # DW_FORM_strx1
+	.byte	58                              # DW_AT_decl_file
+	.byte	11                              # DW_FORM_data1
+	.byte	59                              # DW_AT_decl_line
+	.byte	11                              # DW_FORM_data1
+	.byte	73                              # DW_AT_type
+	.byte	19                              # DW_FORM_ref4
+	.byte	63                              # DW_AT_external
+	.byte	25                              # DW_FORM_flag_present
+	.byte	0                               # EOM(1)
+	.byte	0                               # EOM(2)
+	.byte	4                               # Abbreviation Code
+	.byte	5                               # DW_TAG_formal_parameter
+	.byte	0                               # DW_CHILDREN_no
+	.byte	2                               # DW_AT_location
+	.byte	34                              # DW_FORM_loclistx
+	.byte	3                               # DW_AT_name
+	.byte	37                              # DW_FORM_strx1
+	.byte	58                              # DW_AT_decl_file
+	.byte	11                              # DW_FORM_data1
+	.byte	59                              # DW_AT_decl_line
+	.byte	11                              # DW_FORM_data1
+	.byte	73                              # DW_AT_type
+	.byte	19                              # DW_FORM_ref4
+	.byte	0                               # EOM(1)
+	.byte	0                               # EOM(2)
+	.byte	5                               # Abbreviation Code
+	.byte	5                               # DW_TAG_formal_parameter
+	.byte	0                               # DW_CHILDREN_no
+	.byte	2                               # DW_AT_location
+	.byte	24                              # DW_FORM_exprloc
+	.byte	3                               # DW_AT_name
+	.byte	37                              # DW_FORM_strx1
+	.byte	58                              # DW_AT_decl_file
+	.byte	11                              # DW_FORM_data1
+	.byte	59                              # DW_AT_decl_line
+	.byte	11                              # DW_FORM_data1
+	.byte	73                              # DW_AT_type
+	.byte	19                              # DW_FORM_ref4
+	.byte	0                               # EOM(1)
+	.byte	0                               # EOM(2)
+	.byte	0                               # EOM(3)
+	.section	.debug_info,"",@progbits
+.Lcu_begin0:
+	.long	.Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
+.Ldebug_info_start0:
+	.short	5                               # DWARF version number
+	.byte	1                               # DWARF Unit Type
+	.byte	8                               # Address Size (in bytes)
+	.long	.debug_abbrev                   # Offset Into Abbrev. Section
+	.byte	1                               # Abbrev [1] 0xc:0x50 DW_TAG_compile_unit
+	.byte	0                               # DW_AT_producer
+	.short	33                              # DW_AT_language
+	.byte	1                               # DW_AT_name
+	.long	.Lstr_offsets_base0             # DW_AT_str_offsets_base
+	.long	.Lline_table_start0             # DW_AT_stmt_list
+	.byte	2                               # DW_AT_comp_dir
+	.byte	0                               # DW_AT_low_pc
+	.long	.Lfunc_end0-.Lfunc_begin0       # DW_AT_high_pc
+	.long	.Laddr_table_base0              # DW_AT_addr_base
+	.long	.Lloclists_table_base0          # DW_AT_loclists_base
+	.byte	2                               # Abbrev [2] 0x27:0x4 DW_TAG_base_type
+	.byte	4                               # DW_AT_name
+	.byte	7                               # DW_AT_encoding
+	.byte	1                               # DW_AT_byte_size
+	.byte	2                               # Abbrev [2] 0x2b:0x4 DW_TAG_base_type
+	.byte	3                               # DW_AT_name
+	.byte	7                               # DW_AT_encoding
+	.byte	1                               # DW_AT_byte_size
+	.byte	3                               # Abbrev [3] 0x2f:0x24 DW_TAG_subprogram
+	.byte	0                               # DW_AT_low_pc
+	.long	.Lfunc_end0-.Lfunc_begin0       # DW_AT_high_pc
+	.byte	1                               # DW_AT_frame_base
+	.byte	87
+                                        # DW_AT_call_all_calls
+	.byte	5                               # DW_AT_linkage_name
+	.byte	6                               # DW_AT_name
+	.byte	0                               # DW_AT_decl_file
+	.byte	1                               # DW_AT_decl_line
+	.long	83                              # DW_AT_type
+                                        # DW_AT_external
+	.byte	4                               # Abbrev [4] 0x3f:0x9 DW_TAG_formal_parameter
+	.byte	0                               # DW_AT_location
+	.byte	8                               # DW_AT_name
+	.byte	0                               # DW_AT_decl_file
+	.byte	1                               # DW_AT_decl_line
+	.long	87                              # DW_AT_type
+	.byte	5                               # Abbrev [5] 0x48:0xa DW_TAG_formal_parameter
+	.byte	1                               # DW_AT_location
+	.byte	84
+	.byte	10                              # DW_AT_name
+	.byte	0                               # DW_AT_decl_file
+	.byte	1                               # DW_AT_decl_line
+	.long	83                              # DW_AT_type
+	.byte	0                               # End Of Children Mark
+	.byte	2                               # Abbrev [2] 0x53:0x4 DW_TAG_base_type
+	.byte	7                               # DW_AT_name
+	.byte	5                               # DW_AT_encoding
+	.byte	4                               # DW_AT_byte_size
+	.byte	2                               # Abbrev [2] 0x57:0x4 DW_TAG_base_type
+	.byte	9                               # DW_AT_name
+	.byte	2                               # DW_AT_encoding
+	.byte	1                               # DW_AT_byte_size
+	.byte	0                               # End Of Children Mark
+.Ldebug_info_end0:
+	.section	.debug_str_offsets,"",@progbits
+	.long	48                              # Length of String Offsets Set
+	.short	5
+	.short	0
+.Lstr_offsets_base0:
+	.section	.debug_str,"MS",@progbits,1
+.Linfo_string0:
+	.asciz	"clang version 21.0.0git (git@github.com:ZequanWu/llvm-project.git 317f3bdcc1f96586489a9e48b494e593592b68cf)" # string offset=0
+.Linfo_string1:
+	.asciz	"foo.cpp"                       # string offset=108
+.Linfo_string2:
+	.asciz	"/tmp"                          # string offset=116
+.Linfo_string3:
+	.asciz	"DW_ATE_unsigned_8"             # string offset=121
+.Linfo_string4:
+	.asciz	"DW_ATE_unsigned_1"             # string offset=139
+.Linfo_string5:
+	.asciz	"_Z3foobi"                      # string offset=157
+.Linfo_string6:
+	.asciz	"foo"                           # string offset=166
+.Linfo_string7:
+	.asciz	"int"                           # string offset=170
+.Linfo_string8:
+	.asciz	"b"                             # string offset=174
+.Linfo_string9:
+	.asciz	"bool"                          # string offset=176
+.Linfo_string10:
+	.asciz	"x"                             # string offset=181
+	.section	.debug_str_offsets,"",@progbits
+	.long	.Linfo_string0
+	.long	.Linfo_string1
+	.long	.Linfo_string2
+	.long	.Linfo_string3
+	.long	.Linfo_string4
+	.long	.Linfo_string5
+	.long	.Linfo_string6
+	.long	.Linfo_string7
+	.long	.Linfo_string8
+	.long	.Linfo_string9
+	.long	.Linfo_string10
+	.section	.debug_addr,"",@progbits
+	.long	.Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
+.Ldebug_addr_start0:
+	.short	5                               # DWARF version number
+	.byte	8                               # Address size
+	.byte	0                               # Segment selector size
+.Laddr_table_base0:
+	.quad	.Lfunc_begin0
+.Ldebug_addr_end0:
+	.ident	"clang version 21.0.0git (git@github.com:ZequanWu/llvm-project.git 317f3bdcc1f96586489a9e48b494e593592b68cf)"
+	.section	".note.GNU-stack","",@progbits
+	.addrsig
+	.section	.debug_line,"",@progbits
+.Lline_table_start0:

@ZequanWu ZequanWu merged commit 821cd6a into llvm:main May 29, 2025
8 of 9 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented May 29, 2025

LLVM Buildbot has detected a new failure on builder ml-opt-devrel-x86-64 running on ml-opt-devrel-x86-64-b2 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/175/builds/19407

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: tools/llvm-dwarfdump/X86/debug_info_crel.test' FAILED ********************
Exit Code: 127

Command Output (stderr):
--
echo "void foo(){}" | clang++ --target=x86_64-pc-linux -Wa,--crel,--allow-experimental-crel -g -c -x c++ - -o /b/ml-opt-devrel-x86-64-b1/build/test/tools/llvm-dwarfdump/X86/Output/debug_info_crel.test.tmp # RUN: at line 2
+ clang++ --target=x86_64-pc-linux -Wa,--crel,--allow-experimental-crel -g -c -x c++ - -o /b/ml-opt-devrel-x86-64-b1/build/test/tools/llvm-dwarfdump/X86/Output/debug_info_crel.test.tmp
/b/ml-opt-devrel-x86-64-b1/build/test/tools/llvm-dwarfdump/X86/Output/debug_info_crel.test.script: line 1: clang++: command not found
+ echo 'void foo(){}'

--

********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented May 29, 2025

LLVM Buildbot has detected a new failure on builder ml-opt-dev-x86-64 running on ml-opt-dev-x86-64-b2 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/137/builds/19459

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: tools/llvm-dwarfdump/X86/debug_info_crel.test' FAILED ********************
Exit Code: 127

Command Output (stderr):
--
echo "void foo(){}" | clang++ --target=x86_64-pc-linux -Wa,--crel,--allow-experimental-crel -g -c -x c++ - -o /b/ml-opt-dev-x86-64-b1/build/test/tools/llvm-dwarfdump/X86/Output/debug_info_crel.test.tmp # RUN: at line 2
+ clang++ --target=x86_64-pc-linux -Wa,--crel,--allow-experimental-crel -g -c -x c++ - -o /b/ml-opt-dev-x86-64-b1/build/test/tools/llvm-dwarfdump/X86/Output/debug_info_crel.test.tmp
/b/ml-opt-dev-x86-64-b1/build/test/tools/llvm-dwarfdump/X86/Output/debug_info_crel.test.script: line 1: clang++: command not found
+ echo 'void foo(){}'

--

********************


@ZequanWu
Copy link
Contributor Author

Fixed at b3457d8

@llvm-ci
Copy link
Collaborator

llvm-ci commented May 29, 2025

LLVM Buildbot has detected a new failure on builder lld-x86_64-ubuntu-fast running on as-builder-4 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/33/builds/17388

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: tools/llvm-dwarfdump/X86/debug_info_crel.test' FAILED ********************
Exit Code: 127

Command Output (stderr):
--
echo "void foo(){}" | clang++ --target=x86_64-pc-linux -Wa,--crel,--allow-experimental-crel -g -c -x c++ - -o /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/test/tools/llvm-dwarfdump/X86/Output/debug_info_crel.test.tmp # RUN: at line 2
+ echo 'void foo(){}'
+ clang++ --target=x86_64-pc-linux -Wa,--crel,--allow-experimental-crel -g -c -x c++ - -o /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/test/tools/llvm-dwarfdump/X86/Output/debug_info_crel.test.tmp
/home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/test/tools/llvm-dwarfdump/X86/Output/debug_info_crel.test.script: line 1: clang++: command not found

--

********************


google-yfyang pushed a commit to google-yfyang/llvm-project that referenced this pull request May 29, 2025
dwblaikie added a commit that referenced this pull request May 30, 2025
…elocation data" (#142068)

Reverts #141843

The test case relies on clang, which LLVM test cases can't use.
@dwblaikie
Copy link
Collaborator

Reverted to fix trunk - llvm test cases can't use/rely on clang. (llvm doesn't know about/doesn't depend on clang)

Please open a new PR with a reapplication of this work with an updated test case that doesn't depend on clang.

@MaskRay suggested looking for a test that already exercises this functionality, and adding a new RUN line that uses the existing coverage, but with crel - please try that.

llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request May 30, 2025
…resolving relocation data" (#142068)

Reverts llvm/llvm-project#141843

The test case relies on clang, which LLVM test cases can't use.
@llvm-ci
Copy link
Collaborator

llvm-ci commented May 30, 2025

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-expensive-checks-debian running on gribozavr4 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/16/builds/19897

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: tools/llvm-dwarfdump/X86/debug_info_crel.test' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
echo "void foo(){}" | clang++ --target=x86_64-pc-linux -Wa,--crel,--allow-experimental-crel -g -c -x c++ - -o /b/1/llvm-clang-x86_64-expensive-checks-debian/build/test/tools/llvm-dwarfdump/X86/Output/debug_info_crel.test.tmp # RUN: at line 2
+ clang++ --target=x86_64-pc-linux -Wa,--crel,--allow-experimental-crel -g -c -x c++ - -o /b/1/llvm-clang-x86_64-expensive-checks-debian/build/test/tools/llvm-dwarfdump/X86/Output/debug_info_crel.test.tmp
+ echo 'void foo(){}'
clang: error: unsupported argument '--crel' to option 'Wa,'
clang: error: unsupported argument '--allow-experimental-crel' to option 'Wa,'

--

********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented May 30, 2025

LLVM Buildbot has detected a new failure on builder llvm-nvptx-nvidia-ubuntu running on as-builder-7 while building llvm at step 6 "test-build-unified-tree-check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/180/builds/18467

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-llvm) failure: test (failure)
******************** TEST 'LLVM :: tools/llvm-dwarfdump/X86/debug_info_crel.test' FAILED ********************
Exit Code: 127

Command Output (stderr):
--
echo "void foo(){}" | clang++ --target=x86_64-pc-linux -Wa,--crel,--allow-experimental-crel -g -c -x c++ - -o /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/test/tools/llvm-dwarfdump/X86/Output/debug_info_crel.test.tmp # RUN: at line 2
+ echo 'void foo(){}'
+ clang++ --target=x86_64-pc-linux -Wa,--crel,--allow-experimental-crel -g -c -x c++ - -o /home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/test/tools/llvm-dwarfdump/X86/Output/debug_info_crel.test.tmp
/home/buildbot/worker/as-builder-7/llvm-nvptx-nvidia-ubuntu/build/test/tools/llvm-dwarfdump/X86/Output/debug_info_crel.test.script: line 1: clang++: command not found

--

********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented May 30, 2025

LLVM Buildbot has detected a new failure on builder llvm-nvptx64-nvidia-ubuntu running on as-builder-7 while building llvm at step 6 "test-build-unified-tree-check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/160/builds/18324

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-llvm) failure: test (failure)
******************** TEST 'LLVM :: tools/llvm-dwarfdump/X86/debug_info_crel.test' FAILED ********************
Exit Code: 127

Command Output (stderr):
--
echo "void foo(){}" | clang++ --target=x86_64-pc-linux -Wa,--crel,--allow-experimental-crel -g -c -x c++ - -o /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/test/tools/llvm-dwarfdump/X86/Output/debug_info_crel.test.tmp # RUN: at line 2
+ echo 'void foo(){}'
+ clang++ --target=x86_64-pc-linux -Wa,--crel,--allow-experimental-crel -g -c -x c++ - -o /home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/test/tools/llvm-dwarfdump/X86/Output/debug_info_crel.test.tmp
/home/buildbot/worker/as-builder-7/llvm-nvptx64-nvidia-ubuntu/build/test/tools/llvm-dwarfdump/X86/Output/debug_info_crel.test.script: line 1: clang++: command not found

--

********************


@dwblaikie
Copy link
Collaborator

Fixed at b3457d8

Ah, sorry I missed this amongst the buildbot spam/noise. Sorry about that. Thanks for the fix. (might still be worth considering an existing test for the functionality that could have an extra RUN line, rather than a separate test - like @MaskRay was suggesting)

@ZequanWu
Copy link
Contributor Author

I found that b3457d8 is the easiest way I can think about to test it. Otherwise, I need to manually create the .debug_info, .debug_abbrev, .debug_str, .debug_str_offsets sections to create a meaningful test (when llvm-dwarfdump prints strings inside .debug_info with .debug_abbrev, it needs to access the string from crel relocation sections)

@dwblaikie
Copy link
Collaborator

I found that b3457d8 is the easiest way I can think about to test it. Otherwise, I need to manually create the .debug_info, .debug_abbrev, .debug_str, .debug_str_offsets sections to create a meaningful test (when llvm-dwarfdump prints strings inside .debug_info with .debug_abbrev, it needs to access the string from crel relocation sections)

Have you looked at existing test files, that cover the functionality of relocation handling, and could be extended with a new RUN line to cover crel?

For instance, this seems to work:

diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_info_addrx.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_info_addrx.s
index ec1ad227bd56..51f61496d71f 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_info_addrx.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_info_addrx.s
@@ -1,6 +1,8 @@
 # RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux -o %t.o
 # RUN: llvm-dwarfdump -debug-info %t.o | FileCheck %s
 # RUN: llvm-dwarfdump -debug-info %t.o -v | FileCheck --check-prefix=VERBOSE %s
+# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux -o %t.o -crel
+# RUN: llvm-dwarfdump -debug-info %t.o | FileCheck %s

 # CHECK: DW_TAG_compile_unit
 # CHECK:   DW_AT_low_pc                                              (0x0000000000000000)

@ZequanWu
Copy link
Contributor Author

ZequanWu commented Jun 3, 2025

I found that b3457d8 is the easiest way I can think about to test it. Otherwise, I need to manually create the .debug_info, .debug_abbrev, .debug_str, .debug_str_offsets sections to create a meaningful test (when llvm-dwarfdump prints strings inside .debug_info with .debug_abbrev, it needs to access the string from crel relocation sections)

Have you looked at existing test files, that cover the functionality of relocation handling, and could be extended with a new RUN line to cover crel?

For instance, this seems to work:

diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_info_addrx.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_info_addrx.s
index ec1ad227bd56..51f61496d71f 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_info_addrx.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_info_addrx.s
@@ -1,6 +1,8 @@
 # RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux -o %t.o
 # RUN: llvm-dwarfdump -debug-info %t.o | FileCheck %s
 # RUN: llvm-dwarfdump -debug-info %t.o -v | FileCheck --check-prefix=VERBOSE %s
+# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux -o %t.o -crel
+# RUN: llvm-dwarfdump -debug-info %t.o | FileCheck %s

 # CHECK: DW_TAG_compile_unit
 # CHECK:   DW_AT_low_pc                                              (0x0000000000000000)

Yeah, that also provides the same test coverage. I didn't know that you can pass -crel to llvm-mc to enable the crel feature. Send #142644.

sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
…elocation data" (llvm#142068)

Reverts llvm#141843

The test case relies on clang, which LLVM test cases can't use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

llvm-dwarfdump doesn't support CREL
5 participants