From: "H.J. Lu" <hjl.tools@gmail.com>
To: Mark Wielaard <mark@klomp.org>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
Jakub Jelinek <jakub@redhat.com>,
Binutils <binutils@sourceware.org>
Subject: Re: Duplicate .debug_lines (Was: [PATCH 5/5] Add --gdwarf-5 to ASM_SPEC)
Date: Wed, 26 Aug 2020 16:38:21 -0700 [thread overview]
Message-ID: <CAMe9rOpc4c3uCWM5O=7S2bUqf3pfVG+9Q+WtJyD_Nfw6rHY63w@mail.gmail.com> (raw)
In-Reply-To: <20200826213729.GG3062@wildebeest.org>
On Wed, Aug 26, 2020 at 2:38 PM Mark Wielaard <mark@klomp.org> wrote:
>
> Hi gcc hackers, binutils hackers,
>
> Nick, Jakub and I were discussing the gcc patch below and all the ways
> it is wrong. Most things can be fixed in the spec. Like only passing
> -gdwarf if we are generating DWARF and passing the right DWARF version
> as -gdwarf-N for the version that gcc itself creates. But whether or
> not we want gas to generate .debug_line info is a bit tricky. But when
> giving -gdwarf-N gas will always try to generate a .debug_line section
> and error out when there is already one.
>
> Would it be possible to have something like the following in gas, so
> that it doesn't try generating a .debug_line section if there already
> is one, even when -gdwarf-N is given (unless the assembly also
> contains .loc directives because that shows the user is really
> confused)?
>
> diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
> index e4ba56d82ba..c0c09f4e9d0 100644
> --- a/gas/dwarf2dbg.c
> +++ b/gas/dwarf2dbg.c
> @@ -2626,7 +2626,7 @@ dwarf2_init (void)
>
>
> /* Finish the dwarf2 debug sections. We emit .debug.line if there
> - were any .file/.loc directives, or --gdwarf2 was given, or if the
> + were any .file/.loc directives, or --gdwarf2 was given, and if the
> file has a non-empty .debug_info section and an empty .debug_line
> section. If we emit .debug_line, and the .debug_info section is
> empty, we also emit .debug_info, .debug_aranges and .debug_abbrev.
> @@ -2650,9 +2650,16 @@ dwarf2_finish (void)
> empty_debug_line = line_seg == NULL || !seg_not_empty_p (line_seg);
>
> /* We can't construct a new debug_line section if we already have one.
> - Give an error. */
> + Give an error if we have seen any .loc, otherwise trust the user
> + knows what they are doing and want to generate the .debug_line
> + (and all other debug sections) themselves. */
> if (all_segs && !empty_debug_line)
> - as_fatal ("duplicate .debug_line sections");
> + {
> + if (dwarf2_loc_directive_seen)
> + as_fatal ("duplicate .debug_line sections");
> + else
> + return;
> + }
>
> if ((!all_segs && emit_other_sections)
> || (!emit_other_sections && !empty_debug_line))
>
I have run into this issue before. "as -g" shouldn't silently
generate incorrect
debug info when input assembly codes already contain debug directives.
AS should either issue an error or ignore -g. In either case, we need
a testcase
to verify it.
--
H.J.
next prev parent reply other threads:[~2020-08-26 23:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200824125658.22526-1-mark@klomp.org>
[not found] ` <20200824125658.22526-6-mark@klomp.org>
2020-08-26 21:37 ` Mark Wielaard
2020-08-26 23:38 ` H.J. Lu [this message]
2020-08-29 12:23 ` Mark Wielaard
2020-08-29 14:34 ` H.J. Lu
2020-08-29 15:23 ` Mark Wielaard
2020-08-29 15:43 ` H.J. Lu
2020-08-29 16:32 ` Mark Wielaard
2020-08-29 16:44 ` H.J. Lu
2020-08-29 17:32 ` Mark Wielaard
2020-09-07 12:37 ` [PATCH] gas: Don't error when .debug_line already exists, unless .loc was used Mark Wielaard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMe9rOpc4c3uCWM5O=7S2bUqf3pfVG+9Q+WtJyD_Nfw6rHY63w@mail.gmail.com' \
--to=hjl.tools@gmail.com \
--cc=binutils@sourceware.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=mark@klomp.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).