bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gas bug: out-of-order .file directives do not work


From: mat
Subject: gas bug: out-of-order .file directives do not work
Date: 22 Feb 2006 14:22:40 -0500

This happens on x86-linux in gas 2.14 and 2.16, and the bug
is still in the source code in the latest CVS version.

.file directives do not work unless they are emitted in numerical
order. For example, this fails:

        .file   2       "/something_else"
        .loc    2 402 1
        .file   1       "/something"
        .loc    2 402 1

$ as bar.s
bar.s: Assembler messages:
bar.s:4: Error: unassigned file number 2


It looks like a 'get_filenum' bug. 'get_filenum' tries to correctly
handle file numbers being declared out of order, e.g. it understands
there may be "holes" in the numbering space containing NULL
filenames. But it always sets files_in_use to one beyond the latest
number it has seen, effectively forgetting about any higher-numbered
file that was already declared.

Fortunately, the patch is trivial.


--- dwarf2dbg.c.orig    2006-01-11 11:16:47.000000000 -0500
+++ dwarf2dbg.c 2006-02-22 13:38:53.000000000 -0500
@@ -415,19 +415,20 @@
       files_allocated = i + 32;
       files = (struct file_entry *)
        xrealloc (files, (i + 32) * sizeof (struct file_entry));
 
       memset (files + old, 0, (i + 32 - old) * sizeof (struct file_entry));
     }
 
   files[i].filename = num ? file : xstrdup (file);
   files[i].dir = dir;
-  files_in_use = i + 1;
+  if (i + 1 > files_in_use)
+    files_in_use = i + 1;
   last_used = i;
   last_used_dir_len = dir_len;
 
   return i;
 }
 
 /* Handle two forms of .file directive:
    - Pass .file "source.c" to s_app_file
    - Handle .file 1 "source.c" by adding an entry to the DWARF-2 file table


Of course, if the assembler really wants to require .files to appear
in order, it should report an error rather than silently dropping
entries. But I think it's supposed to work.

-Mat





reply via email to

[Prev in Thread] Current Thread [Next in Thread]