noticed after upgrading to 2.17.50.0.7 (the 2.17.50.0.6 and older work fine): $ mkdir build $ cd build $ CFLAGS='-pipe -O0 -g' ../configure $ make all-binutils $ ./binutils/objcopy --only-keep-debug ./binutils/objcopy ./binutils/objcopy.out Segmentation fault $ gdb --args ./binutils/objcopy --only-keep-debug ./binutils/objcopy ./binutils/objcopy.out Using host libthread_db library "/lib/libthread_db.so.1". (gdb) r Starting program: /usr/local/src/gnu/sourceware/build/binutils/objcopy --only-keep-debug ./binutils/objcopy ./binutils/objcopy.out Program received signal SIGSEGV, Segmentation fault. 0x0000000000462f5f in rewrite_elf_program_header (ibfd=0x60fbd0, obfd=0x610d40) at ../../bfd/elf.c:5433 5433 if (first_section->output_section != NULL) (gdb) bt #0 0x0000000000462f5f in rewrite_elf_program_header (ibfd=0x60fbd0, obfd=0x610d40) at ../../bfd/elf.c:5433 #1 0x0000000000464cad in copy_private_bfd_data (ibfd=0x60fbd0, obfd=0x610d40) at ../../bfd/elf.c:5952 #2 0x000000000046508e in _bfd_elf_copy_private_header_data (ibfd=0x60fbd0, obfd=0x610d40) at ../../bfd/elf.c:6069 #3 0x000000000040579d in setup_bfd_headers (ibfd=0x60fbd0, obfd=0x610d40) at ../../binutils/objcopy.c:2130 #4 0x00000000004040f6 in copy_object (ibfd=0x60fbd0, obfd=0x610d40) at ../../binutils/objcopy.c:1389 #5 0x000000000040551a in copy_file (input_filename=0x7a0570f68042 "./binutils/objcopy", output_filename=0x7a0570f68055 "./binutils/objcopy.out", input_target=0x0, output_target=0x4de188 "elf64-x86-64") at ../../binutils/objcopy.c:2019 #6 0x0000000000407d16 in copy_main (argc=4, argv=0x7a0570f67cd8) at ../../binutils/objcopy.c:3348 #7 0x0000000000407fef in main (argc=4, argv=0x7a0570f67cd8) at ../../binutils/objcopy.c:3438 (gdb)
Created attachment 1445 [details] Do not use the first_section pointer if it is null.
Hi Mike, A simple case of a pointer being used when it was NULL. I have applied the uploaded patch to fix this. Cheers Nick
Hi Mike, A simple case of a pointer being used when it was NULL. I have applied the uploaded patch to fix this. Cheers Nick bfd/ChangeLog 2006-12-01 Nick Clifton <nickc@redhat.com> PR 3609 * elf.c (rewrite_elf_program_header): Do not use the first_section pointer if it is null.
The fix is incorrect. The correct patch is posted at http://sourceware.org/ml/binutils/2006-12/msg00011.html
Fixed.