public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] gdb: fix build errors in coffread.c and xcoffread.c
@ 2021-11-10  9:50 Tiezhu Yang
  2021-11-10 10:37 ` Andrew Burgess
  0 siblings, 1 reply; 3+ messages in thread
From: Tiezhu Yang @ 2021-11-10  9:50 UTC (permalink / raw)
  To: gdb-patches

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(-)

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] gdb: fix build errors in coffread.c and xcoffread.c
  2021-11-10  9:50 [PATCH v2] gdb: fix build errors in coffread.c and xcoffread.c Tiezhu Yang
@ 2021-11-10 10:37 ` Andrew Burgess
  2021-11-10 12:57   ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Burgess @ 2021-11-10 10:37 UTC (permalink / raw)
  To: Tiezhu Yang; +Cc: gdb-patches

* 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
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] gdb: fix build errors in coffread.c and xcoffread.c
  2021-11-10 10:37 ` Andrew Burgess
@ 2021-11-10 12:57   ` Simon Marchi
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2021-11-10 12:57 UTC (permalink / raw)
  To: Andrew Burgess, Tiezhu Yang; +Cc: gdb-patches



On 2021-11-10 05:37, Andrew Burgess via Gdb-patches wrote:
> * 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

Oh, I just merged a similar patch.  I think the code change was exactly the same,
since it was obvious.

Simon

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-10 12:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-10  9:50 [PATCH v2] gdb: fix build errors in coffread.c and xcoffread.c Tiezhu Yang
2021-11-10 10:37 ` Andrew Burgess
2021-11-10 12:57   ` Simon Marchi

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).