[PATCH] as: Automatically enable DWARF5 support

Alan Modra amodra@gmail.com
Mon Jan 18 05:57:21 GMT 2021


On Sun, Jan 17, 2021 at 08:00:25AM -0800, H.J. Lu via Binutils wrote:
> How about this patch to automatically enable DWARF5 support?

> diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
> index a428370ecca..6c9871cb300 100644
> --- a/gas/dwarf2dbg.c
> +++ b/gas/dwarf2dbg.c
> @@ -551,7 +551,7 @@ dwarf2_gen_line_info (addressT ofs, struct dwarf2_line_info *loc)
>    if (loc->line == 0)
>      return;
>    if (loc->filenum == 0 && DWARF2_LINE_VERSION < 5)
> -    return;
> +    dwarf_level = 5;
>  
>    /* Don't emit sequences of line symbols for the same line when the
>       symbols apply to assembler code.  It is necessary to emit

A target may override the default DWARF2_LINE_VERSION, so I think you
should write something like

  if (loc->filenum == 0 && dwarf_level < 5)
    dwarf_level = 5;
  if (loc->filenum == 0 && DWARF2_LINE_VERSION < 5)
    return;


> @@ -1043,11 +1043,7 @@ dwarf2_directive_filename (void)
>    num = get_absolute_expression ();
>  
>    if ((offsetT) num < 1 && DWARF2_LINE_VERSION < 5)
> -    {
> -      as_bad (_("file number less than one"));
> -      ignore_rest_of_line ();
> -      return NULL;
> -    }
> +    dwarf_level = 5;
>  
>    /* FIXME: Should we allow ".file <N>\n" as an expression meaning
>       "switch back to the already allocated file <N> as the current

Similarly here, and in any case we shouldn't ignore a negative file
number.  This should be

  if (num == 0 && dwarf_level < 5)
    dwarf_level = 5;
  if ((offsetT) num < 0 || (num != 0 && DWARF2_LINE_VERSION < 5))
    {
      as_bad (_("file number less than one"));
      ignore_rest_of_line ();
      return NULL;
    }

> @@ -1142,10 +1138,7 @@ dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED)
>    if (filenum < 1)
>      {
>        if (filenum != 0 || DWARF2_LINE_VERSION < 5)
> -	{
> -	  as_bad (_("file number less than one"));
> -	  return;
> -	}
> +	dwarf_level = 5;
>      }
>  
>    if (filenum >= (int) files_in_use || files[filenum].filename == NULL)

Similarly.

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list