This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug gdb/20948] New: --write option to GDB causes


https://sourceware.org/bugzilla/show_bug.cgi?id=20948

            Bug ID: 20948
           Summary: --write option to GDB causes
           Product: gdb
           Version: HEAD
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: clm at codesourcery dot com
  Target Milestone: ---

A segmentation fault occurs when opening an executable file for writing. 
Although this problem was encountered with a mips-sde-elf target, it can be
reproduced for other targets.  It can also be reproduced using the command "set
write on".

It looks like the segmentation fault was introduced with the addition of
compressed debug sections in bfd probably because it causes extra fiddling with
the strtab during the writing of an executable.

To reproduce:

$ cat null.c
int
main ()
{
}

$mips-sde-elf-gcc null.o -e main -o null.x

$mips-sde-elf-gdb -quiet --write null.x
Reading symbols from /scratch/cmoore/2016.11-mips-elf/test/null.x...(no
debugging symbols found)...done.
(gdb) quit
Segmentation fault (core dumped)


 gdb -quiet ./mips-sde-elf-gdb
Reading symbols from ./mips-sde-elf-gdb...done.
(gdb) set prompt (top)
(top) run --write -quiet ./null.x
Starting program: /scratch/cmoore/2016.11-mips-elf/test/mips-sde-elf-gdb
--write -quiet ./null.x
Reading symbols from /scratch/cmoore/2016.11-mips-elf/test/null.x...(no
debugging symbols found)...done.
(gdb) quit

Program received signal SIGSEGV, Segmentation fault.
0x0000000000783a52 in _bfd_elf_strtab_finalize (tab=0x0) at
/scratch/cmoore/2016.11-mips-elf/obj/gdb-src-2016.11-999999-mips-sde-elf-x86_64-linux-gnu/bfd/elf-strtab.c:341
341       amt = tab->size * sizeof (struct elf_strtab_hash_entry *);
(top) p tab
$1 = (struct elf_strtab_hash *) 0x0
(top) bt 2
#0  0x0000000000783a52 in _bfd_elf_strtab_finalize (tab=0x0) at
/scratch/cmoore/2016.11-mips-elf/obj/gdb-src-2016.11-999999-mips-sde-elf-x86_64-linux-gnu/bfd/elf-strtab.c:341
#1  0x0000000000759c90 in _bfd_elf_assign_file_positions_for_non_load
(abfd=0xe97770) at
/scratch/cmoore/2016.11-mips-elf/obj/gdb-src-2016.11-999999-mips-sde-elf-x86_64-linux-gnu/bfd/elf.c:5840
(More stack frames follow...)
(top) up 1
#1  0x0000000000759c90 in _bfd_elf_assign_file_positions_for_non_load
(abfd=0xe97770) at
/scratch/cmoore/2016.11-mips-elf/obj/gdb-src-2016.11-999999-mips-sde-elf-x86_64-linux-gnu/bfd/elf.c:5840
5840      _bfd_elf_strtab_finalize (elf_shstrtab (abfd));
(top) p abfd->tdata.elf_obj_data->o->shstrtab_section
$4 = 0x0
(top)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]