[PATCH] Fix seg fault with --write PR gdb/20948

Jozef Lawrynowicz jozef.l@mittosystems.com
Tue Mar 13 22:43:00 GMT 2018


On 11/03/18 16:47, Simon Marchi wrote:
> Hi Jozef,
>
> Thanks for looking into this.
>
> Because of the change in bfd/, this patch should also be sent to the
> binutils@sourceware.org mailing list.  The change we'll have to do
> in GDB may depend on what is the final solution on the BFD side.
>
> Also, is the problem illustrated in comment #3 of the bug report related?
>
> https://sourceware.org/bugzilla/show_bug.cgi?id=20948#c3
>
> I tried that snippet with your patch applied, and still get a segfault.
> I think it would be good to get a fix for the minimal reproducing example
> first.
>
> When you post your patch to the binutils mailing list, you can also refer
> to the gdb bug (PR20948) and CC the gdb-patches mailing list, so we can
> follow the discussion.
>
> Thanks!
>
> Simon
>
> Simon

Hi Simon,

I missed the example in comment #3, you are right there is a general issue with
BFD rather than this being GDB specific.

It seems that the internal representation of SHSTRTAB (elf_shstrtab(bfd)) does
not get initialized or populated when opening an existing BFD. This is not an
issue when only reading, as this specific internal representation is not
required. It is also not an issue (or at least doesn't cause any errors) when
only writing as a new shstrtab is created. But when reading and writing,
elf_shstrtab needs to be populated using the existing elf data in the loaded
BFD and this doesn't happen at the moment.

I'm working on a patch.

I reckon when the BFD issue is fixed, we may not need any specific patch for
GDB.

Thanks,
Jozef



More information about the Gdb-patches mailing list