diff options
| author | Bratislav Filipovic <bfilipov@amd.com> | 2026-04-17 10:16:44 +0000 |
|---|---|---|
| committer | Bratislav Filipovic <bfilipov@amd.com> | 2026-04-27 10:27:14 +0000 |
| commit | 831f056f767fe775c8862a09dc3bbe2e69c5e17c (patch) | |
| tree | ecb837529eca525c54405693939b88b22e932a8b | |
| parent | 8f583ac13920391c22e864f9aa6487379edb3995 (diff) | |
| download | binutils-831f056f767fe775c8862a09dc3bbe2e69c5e17c.tar.gz binutils-831f056f767fe775c8862a09dc3bbe2e69c5e17c.tar.bz2 binutils-831f056f767fe775c8862a09dc3bbe2e69c5e17c.zip | |
gdb.dwarf2: Fix fission-dw-form-strx.exp workflow
The test was using gdb_compile_shlib to create the .dwo file, which
runs the linker. This is incorrect for DWARF fission - .dwo files
should be created by objcopy extraction, not linking.
Per commit 6a29913eeb9, "it was a bad idea to generate a .dwo file
using the linker, since the idea behind .dwo files is that they do
not need to be linked."
GCC's assembler doesn't set the SHF_EXCLUDE flag on .debug_*.dwo
sections, so the linker preserves them in the output. Clang's
assembler sets SHF_EXCLUDE, causing the linker to exclude these
sections. Both approaches are valid, but only the GCC approach
happens to work with this test's incorrect use of the linker.
Rewrite the test to use build_executable_and_dwo_files with the
split-dwo option, matching all other fission-*.exp tests. This uses
objcopy to properly extract .dwo sections without involving the
linker.
Changes:
- Use build_executable_and_dwo_files instead of gdb_compile_shlib
- Generate both skeleton and DWO CUs in single Dwarf::assemble block
- Add debug_str_offsets section for DW_FORM_strx support
- Add is_remote host check (required for objcopy-based workflow)
- Fix DW_AT_dwo_name to match generated filename
Tested: GCC 13.3.0, Clang-23 (passes)
| -rw-r--r-- | gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp b/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp index b0b842fe911..313e4eafe76 100644 --- a/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp +++ b/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp @@ -17,30 +17,26 @@ load_lib dwarf.exp +# We run objcopy locally to split out the .dwo file. +if [is_remote host] { + return 0 +} + # This test can only be run on targets which support DWARF-2 and use gas. require dwarf2_support -standard_testfile main.c -dw.S -dwo.S +standard_testfile main.c -dw.S -set main_asm_file [standard_output_file $srcfile2] -set dwo_asm_file [standard_output_file $srcfile3] +set asm_file [standard_output_file $srcfile2] -# Debug info in the main file. -Dwarf::assemble $main_asm_file { - cu { - version 5 - dwo_id 0xF00D - } { - compile_unit { - DW_AT_dwo_name ${::gdb_test_file_name}.dwo DW_FORM_strp - } {} - } -} +# Generate DWARF assembly with both skeleton and DWO sections. +Dwarf::assemble $asm_file { + global srcfile testfile -# Debug info in the DWO file. -Dwarf::assemble $dwo_asm_file { + # String offsets table for DWO. debug_str_offsets { dwo 1 } int + # The information that will be split out into the .dwo file. cu { fission 1 version 5 @@ -65,22 +61,24 @@ Dwarf::assemble $dwo_asm_file { } } } -} - -# Build main file. -if { [build_executable "${testfile}.exp" $binfile \ - [list ${srcfile} ${main_asm_file}] {nodebug}] } { - return -} -# Build DWO file. -set dwo_file [standard_output_file ${testfile}.dwo] -if { [gdb_compile_shlib $dwo_asm_file $dwo_file nodebug] != "" } { - return + # The skeleton information that will remain in the .o file. + cu { + version 5 + dwo_id 0xF00D + } { + compile_unit { + DW_AT_dwo_name ${testfile}-dw.dwo DW_FORM_strp + } {} + } } -if { [is_remote host] } { - gdb_remote_download host $dwo_file +# Build the executable and extract the .dwo file using objcopy. +set obj [standard_output_file "${testfile}-dw.o"] +if [build_executable_and_dwo_files "$testfile.exp" "${binfile}" {nodebug} \ + [list $asm_file [list nodebug split-dwo] $obj] \ + [list $srcfile [list nodebug]]] { + return -1 } clean_restart $::testfile |
