Created attachment 15022 [details] binutils.log.xz The '--only-keep-debug for ELF relocatables' binutils/objcopy test fails for me with binutils-2.41. ``` $ grep -rsin ^FAIL /var/tmp/portage/sys-devel/binutils-2.41/temp/build.log 12755:FAIL: tmpdir/gp-collect-app_F 12819:FAIL: --only-keep-debug for ELF relocatables 13115:FAIL: Run pr23169b ```
ccing doko as they hit it too at https://inbox.sourceware.org/binutils/86e6e812-4968-cd28-0c1c-6a38a053c404@debian.org/
(wrong bug, sorry)
Hi Sam, The test appears to be failing because it thinks that the .debug_macro sections, and their associated .rela.debug_macro sections do not contain debug information and as a result, should not appear (with contents) in a file that has been stripped of everything but debugging: Expected SHT_NOBITS type for .debug_macro Expected SHT_NOBITS type for .rela.debug_macro FAIL: --only-keep-debug for ELF relocatables The reason that the test thinks that these sections do not contain debug info is because they are part of a section group. The test code runs readelf over the before-being-stripped version of the file and looks for any section with either the ALLOC or GROUP flags set. Any such section found is added to a list of non-debug sections: if { $type != "NOTE" && [regexp {[AG]} $flag] } { lappend non_debug_sections $name But two of the .debug_macro sections are part of a group: [14] .debug_macro PROGBITS 0000000000000000 00070f 00001a 00 0 0 1 [15] .rela.debug_macro RELA 0000000000000000 001ed8 000048 18 I 29 14 8 [16] .debug_macro PROGBITS 0000000000000000 000730 000038 00 GC 0 0 8 [17] .rela.debug_macro RELA 0000000000000000 001f20 0028f8 18 IG 29 16 8 [18] .debug_macro PROGBITS 0000000000000000 000768 000028 00 G 0 0 1 [19] .rela.debug_macro RELA 0000000000000000 004818 000090 18 IG 29 18 8 (I assume that this is normal behaviour for gcc when it is creating .debug_macro sections). So I think that the logic in proc keep_debug_symbols_for_elf_relocatable in binutils/testsuite/binutils-all/objcopy.exp needs to be updated. Would it be possible for you to upload a copy of the unstriped version of testprog.o that is triggering these results ? The version of gcc that I am using does not generate .debug_macro sections, so I cannot test any changes that I make using my own compiler. Cheers Nick
Created attachment 15029 [details] testprog.o Hi Nick, I've attached testprog.o, let me know if you need anything else. It may or may not be to do with building with -ggdb3, but I can't reproduce it yet when running `runtest` manually (but I'm not super familiar with dejagnu yet, I usually just run `make check). $ file /var/tmp/portage/sys-devel/binutils-2.41/work/build/binutils/tmpdir/testprog.o /var/tmp/portage/sys-devel/binutils-2.41/work/build/binutils/tmpdir/testprog.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), with debug_info, not stripped
Created attachment 15030 [details] Proposed patch Hi Sam, Please could you try out this patch and let me know if it works for you ? Cheers Nick
That works for me, thanks Nick! $ grep -rsin -- ": --only-keep-debug for ELF relocatables" /var/tmp/portage/sys-devel/binutils-2.41/work/build/binutils/binutils.log 6516:PASS: --only-keep-debug for ELF relocatables
The master branch has been updated by Nick Clifton <nickc@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b99a9693430a9f04165b1b868f890b622bb1b46c commit b99a9693430a9f04165b1b868f890b622bb1b46c Author: Nick Clifton <nickc@redhat.com> Date: Tue Aug 1 14:37:04 2023 +0100 Fix "--only-keep-debug for ELF relocatables" binutils test for compilers which add .debug_macro sections to object files. PR 30699 * binutils/testsuite/binutils-all/objcopy.exp (keep_debug_symbols_for_elf_relocatable): Do not add sections containing the string "debug_" to the list of non-debug sections.
Fixed.
The binutils-2_41-branch branch has been updated by Sam James <sjames@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=83d5e7b750556c9c7389a888bf1e3bfc33622b58 commit 83d5e7b750556c9c7389a888bf1e3bfc33622b58 Author: Nick Clifton <nickc@redhat.com> Date: Tue Aug 1 14:37:04 2023 +0100 Fix "--only-keep-debug for ELF relocatables" binutils test for compilers which add .debug_macro sections to object files. PR 30699 * binutils/testsuite/binutils-all/objcopy.exp (keep_debug_symbols_for_elf_relocatable): Do not add sections containing the string "debug_" to the list of non-debug sections. (cherry picked from commit b99a9693430a9f04165b1b868f890b622bb1b46c)