[PATCH v2] gdb: fix build errors in coffread.c and xcoffread.c

Andrew Burgess aburgess@redhat.com
Wed Nov 10 10:37:55 GMT 2021


* Tiezhu Yang <yangtiezhu@loongson.cn> [2021-11-10 17:50:00 +0800]:

> There exist the following build errors in gdb/coffread.c:
> 
>     CXX    coffread.o
>   gdb/coffread.c: In function ‘const char* coff_getfilename(internal_auxent*)’:
>   gdb/coffread.c:1343:29: error: ‘union internal_auxent::<unnamed struct>::<unnamed>’ has no member named ‘x_zeroes’
>     if (aux_entry->x_file.x_n.x_zeroes == 0)
>                               ^~~~~~~~
>   gdb/coffread.c:1345:53: error: ‘union internal_auxent::<unnamed struct>::<unnamed>’ has no member named ‘x_offset’
>         if (strlen (stringtab + aux_entry->x_file.x_n.x_offset) >= BUFSIZ)
>                                                       ^~~~~~~~
>   gdb/coffread.c:1347:57: error: ‘union internal_auxent::<unnamed struct>::<unnamed>’ has no member named ‘x_offset’
>         strcpy (buffer, stringtab + aux_entry->x_file.x_n.x_offset);
>                                                           ^~~~~~~~
>   gdb/coffread.c:1351:42: error: ‘struct internal_auxent::<unnamed>’ has no member named ‘x_fname’; did you mean ‘x_ftype’?
>         strncpy (buffer, aux_entry->x_file.x_fname, FILNMLEN);
>                                            ^~~~~~~
>                                            x_ftype
> 
> Similar problems exist in gdb/xcoffread.c, just fix them according to the
> definition of struct x_file in include/coff/internal.h:
> 
>   struct
>   {
>     union {
>       ...
>       char x_fname[20];
>       struct
>       {
>         long x_zeroes;
>         long x_offset;
>       }      x_n;
>     } x_n;
>     unsigned char x_ftype;
>   }     x_file;
> 
> This patch is related with commit e86fc4a5bc37 ("PR 28447: implement
> multiple parameters for .file on XCOFF").
> 
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
> 
> v2: update the commit message
> 
>  gdb/coffread.c  | 8 ++++----
>  gdb/xcoffread.c | 6 +++---
>  2 files changed, 7 insertions(+), 7 deletions(-)

Thanks for fixing this.  LGTM.

Thanks,
Andrew


> 
> diff --git a/gdb/coffread.c b/gdb/coffread.c
> index 225e0e2..4723662 100644
> --- a/gdb/coffread.c
> +++ b/gdb/coffread.c
> @@ -1340,15 +1340,15 @@ coff_getfilename (union internal_auxent *aux_entry)
>    static char buffer[BUFSIZ];
>    const char *result;
>  
> -  if (aux_entry->x_file.x_n.x_zeroes == 0)
> +  if (aux_entry->x_file.x_n.x_n.x_zeroes == 0)
>      {
> -      if (strlen (stringtab + aux_entry->x_file.x_n.x_offset) >= BUFSIZ)
> +      if (strlen (stringtab + aux_entry->x_file.x_n.x_n.x_offset) >= BUFSIZ)
>  	internal_error (__FILE__, __LINE__, _("coff file name too long"));
> -      strcpy (buffer, stringtab + aux_entry->x_file.x_n.x_offset);
> +      strcpy (buffer, stringtab + aux_entry->x_file.x_n.x_n.x_offset);
>      }
>    else
>      {
> -      strncpy (buffer, aux_entry->x_file.x_fname, FILNMLEN);
> +      strncpy (buffer, aux_entry->x_file.x_n.x_fname, FILNMLEN);
>        buffer[FILNMLEN] = '\0';
>      }
>    result = buffer;
> diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
> index a854d4d..067f6fe 100644
> --- a/gdb/xcoffread.c
> +++ b/gdb/xcoffread.c
> @@ -1678,12 +1678,12 @@ coff_getfilename (union internal_auxent *aux_entry, struct objfile *objfile)
>  {
>    static char buffer[BUFSIZ];
>  
> -  if (aux_entry->x_file.x_n.x_zeroes == 0)
> +  if (aux_entry->x_file.x_n.x_n.x_zeroes == 0)
>      strcpy (buffer, (XCOFF_DATA (objfile)->strtbl
> -		     + aux_entry->x_file.x_n.x_offset));
> +		     + aux_entry->x_file.x_n.x_n.x_offset));
>    else
>      {
> -      strncpy (buffer, aux_entry->x_file.x_fname, FILNMLEN);
> +      strncpy (buffer, aux_entry->x_file.x_n.x_fname, FILNMLEN);
>        buffer[FILNMLEN] = '\0';
>      }
>    return (buffer);
> -- 
> 2.1.0
> 



More information about the Gdb-patches mailing list