aboutsummaryrefslogtreecommitdiff
path: root/gas/macro.c
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2022-04-12 09:03:13 +0200
committerJan Beulich <jbeulich@suse.com>2022-04-12 09:03:13 +0200
commit2ee1792bec225ea19c71095cee5a3a9ae6df7c59 (patch)
treece92065f05ebf6d086191bcb901306c07fa64b5d /gas/macro.c
parent1a42a9fe4e60599bba1f047743a5b8b2ba96ee1f (diff)
downloadbinutils-2ee1792bec225ea19c71095cee5a3a9ae6df7c59.zip
binutils-2ee1792bec225ea19c71095cee5a3a9ae6df7c59.tar.gz
binutils-2ee1792bec225ea19c71095cee5a3a9ae6df7c59.tar.bz2
gas: further adjust file/line handling for .irp and alike
Commit 7992631e8c0b ("gas/Dwarf: improve debug info generation from .irp and alike blocks"), while dealing okay with actual assembly source files not using .file/.line and alike outside but not inside of .irp et al, has undue effects when the logical file/line pair was already overridden: Line numbers would continuously increment upon every iteration, thus potentially getting far off. Furthermore it left it to the user to actually insert .file/.line inside such constructs. Note though that before aforementioned change things weren't pretty either: Diagnostics (and debug info) would be associated with the directive terminating the iteration construct, rather than with the actual lines. Handle this automatically by simply latching the present line and then re-instating coordinates first thing on every iteration; note that the file can't change from what was previously pushed on the scrubber's state stack, and hence can be taken from there by using a new flavor of .linefile (which is far better memory-footprint-wise than recording the full path in the inserted directive). (This then leaves undisturbed any file/line control occurring in the body of the construct, as these will only be seen and processed afterwards.)
Diffstat (limited to 'gas/macro.c')
-rw-r--r--gas/macro.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/gas/macro.c b/gas/macro.c
index 0d143dc..871a2a8 100644
--- a/gas/macro.c
+++ b/gas/macro.c
@@ -126,6 +126,21 @@ buffer_and_nest (const char *from, const char *to, sb *ptr,
else
from_len = strlen (from);
+ /* Except for macros record the present source position, such that
+ diagnostics and debug info will be properly associated with the
+ respective original lines, rather than with the line of the ending
+ directive (TO). */
+ if (from == NULL || strcasecmp (from, "MACRO") != 0)
+ {
+ unsigned int line;
+ char *linefile;
+
+ as_where (&line);
+ linefile = xasprintf ("\t.linefile %u .\n", line);
+ sb_add_buffer (ptr, linefile, strlen (linefile));
+ xfree (linefile);
+ }
+
while (more)
{
/* Try to find the first pseudo op on the line. */