Hi Xavier,
On Wed, 2020-07-29 at 18:50 +0200, Xavier Leroy wrote:
If we need to add a directive to the generated assembly, or pass a
`-g`
option to the assembler, or use `gcc -c -g` as the assembler, let us know
and we'll see what we can do.
However, please keep backward compatibility in mind: from the Info manual
it looks like gas version 2.34 has no `-g` option and no directives to
control the generation of DWARF information. So there should be reasonable
defaults for gas 2.35 to behave roughly like gas 2.34.
I think the change in binutils/gas 2.35 was supposed to be backward
compatible. I am pretty sure it was just an oversight that the DWARF
version (dwarf_level) was not set in the none -g case.
Lets see what Nick (the binutils maintainer) says. My patch is just the
first thing I came up with. I am sure there are other ways to fix this.
Cheers,
Mark
> > But... in 2.35 you can give the DWARF level you want.
> > The problem with not supplying -g (or --gdwarf-[VERSION]) is that the
> > dwarf_level is never set! And then gas will happily create an
> > .debug_info section with DWARF CUs that have a version of zero (!).
> >
> > This, defaulting to version 4. Fixes it for me:
> >
> > diff --git a/gas/as.c b/gas/as.c
> > index 4c5881abd88..c2da78870ef 100644
> > --- a/gas/as.c
> > +++ b/gas/as.c
> > @@ -103,7 +103,7 @@ int verbose = 0;
> > int flag_dwarf_cie_version = -1;
> >
> > /* The maximum level of DWARF DEBUG information we should
> > manufacture. */
> > -unsigned int dwarf_level = 0;
> > +unsigned int dwarf_level = 4;
> >
> > #if defined OBJ_ELF || defined OBJ_MAYBE_ELF
> > int flag_use_elf_stt_common = DEFAULT_GENERATE_ELF_STT_COMMON;