V3 [PATCH] gas: Clear all auto-assigned file slots
H.J. Lu
hjl.tools@gmail.com
Sat Oct 24 15:26:24 GMT 2020
On Fri, Oct 23, 2020 at 6:55 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Fri, Oct 23, 2020 at 1:06 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > On Fri, Oct 23, 2020 at 12:50 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> > >
> > > Since a file slot is auto-assigned for the #APP marker appeared before
> > > the first .file <NUMBER> directive has been seen, clear all auto-assigned
> > > file slots when seeing the first .file <NUMBER> directive.
> > >
> > > PR gas/26778
> > > * * dwarf2dbg.c (file_entry): Restore auto_assigned.
> > > (assign_file_to_slot): Restore the auto_assign argument.
> > > (allocate_filenum): Pass TRUE to file_entry.
> > > (allocate_filename_to_slot): Pass FALSE to file_entry.
> > > (dwarf2_directive_filename): Clear the slots auto-assigned
> > > before the first .file <NUMBER> directive was seen.
> > > * testsuite/gas/i386/dwarf4-line-1.d: New file.
> > > * testsuite/gas/i386/dwarf4-line-1.s: Likewise.
> > > * testsuite/gas/i386/i386.exp: Run dwarf4-line-1.
> >
> > The updated patch with some optimization. OK for master?
> >
>
> Fix a bug:
>
> diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
> index 96f79c743f8..4c7f552b968 100644
> --- a/gas/dwarf2dbg.c
> +++ b/gas/dwarf2dbg.c
> @@ -1093,6 +1093,7 @@ dwarf2_directive_filename (void)
> if (files[i].auto_assigned)
> files[i].filename = NULL;
> files_in_use -= num_of_auto_assigned;
> + num_of_auto_assigned = 0;
> }
>
> if (! allocate_filename_to_slot (dirname, filename, (unsigned int) num,
>
The simplified patch with
if (num_of_auto_assigned)
{
/* Clear slots auto-assigned before the first .file <NUMBER>
directive was seen. */
if (files_in_use != (num_of_auto_assigned + 1))
abort ();
for (i = 1; i < files_in_use; i++)
files[i].filename = NULL;
files_in_use = 0;
num_of_auto_assigned = 0;
}
Tested with binutils, kernel 5.9, GCC 11 and glibc master on x86-64.
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-gas-Clear-all-auto-assigned-file-slots.patch
Type: text/x-patch
Size: 5282 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20201024/b54d1a2a/attachment.bin>
More information about the Binutils
mailing list