This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] Fix separate-debug with non-unique section names (PR 11409)
On Wed, 24 Mar 2010 21:18:31 +0100, Daniel Jacobowitz wrote:
> On Wed, Mar 24, 2010 at 09:09:43PM +0100, Jan Kratochvil wrote:
> > While the algorithm could be much more clever - if we ever need to resync at
> > the point of non-unique section names the files are too different it makes no
> > sence to try to match them by addr_info_make_relative at all.
>
> What if we assume that in a valid separate debug file, the only
> sections that will be different will have been totally stripped from
> either the before or after file?
>
> IOW:
>
> i = 0 // index in main file
> j = 0 // index in separate file
> for each section in main file:
> if (section names match)
> good
> else if (section i's name is not present in separate file)
> i++, continue
> else if (section j's name is not present in separate file)
or main?
> j++, continue
> else
> complain that the two files do not match
>
> ?
.dynstr is present in both files and on different places from my real
prelinked /bin/bash example.
#! /usr/bin/perl
use strict; use warnings;
my @main=qw(.interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .gnu.liblist .gnu.conflict .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame .ctors .dtors .jcr .dynamic .got .got.plt .data .dynbss .bss .dynstr .gnu_debuglink .gnu.prelink_undo .shstrtab);
my @debug=qw(.interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame .ctors .dtors .jcr .dynamic .got .got.plt .data .bss .comment .debug_aranges .debug_pubnames .debug_info .debug_abbrev .debug_line .debug_str .debug_loc .debug_pubtypes .debug_ranges .shstrtab .symtab .strtab);
my $i = 0; # index in main file
my $j = 0; # index in separate file
while ($i < @main || $j < @debug) {
$i++,$j++,next if $main[$i] eq $debug[$j];
# section i's name is not present in separate file
$i++,next if !grep /^\Q$main[$i]\E$/,@debug;
# section j's name is not present in separate file
$j++,next if !grep /^\Q$debug[$j]\E$/,@debug;
die "complain that the two files do not match: $i=$main[$i] $j=$debug[$j]\n";
}
print "OK\n";
->
complain that the two files do not match: 7=.gnu.version 5=.dynstr
Not sure how this algorithm could be improved to cope with it.
Thanks,
Jan