This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

read correct xcoff auxiliary entry & skip reading @fix entries.


Last year we sent these patches and got comments from joel. Here is the 
reference https://sourceware.org/ml/gdb-patches/2015-12/msg00110.html.
I have incorporated the comments i got from joel.

Here is the information about each patch and the changes.


Patch #1:
 It seems that @fix entries are generated when extra code is needed for 
every reference to a TOC symbol that cannot be addressed with a 16-bit 
offset. 
 So looks like we can safely ignore these symbols.
 Used a startswith function instead of directly using strncmp function and 
little bit code rearrangement to have proper readability.
 

Patch #2

When we use -qfuncsect xlc or -ffunction-sections gcc option,
it places instructions for each function in a separate control section or 
CSECT.

One more extra symbol entry with one or more auxiliary entries will be 
created as shown below.
So in below output, symbol 104 is having two auxiliary entries to indicate 
a separate csect.

We were missing to read SD/PR and information about a each separate 
functions csect.
If no csect entry is present, we would just be going through and looking 
for LD/PR and reading function start address
by doing jump to function_entry_point: label.


[104]   m   0x10000500     .text     2  unamex                    .baz
[105]   a1           0         0    92       0       0 
[106]   a4  0x0000005c       0    0     SD       PR    0    0
[107]   m   0x10000500     .text     2  extern                    .baz
[108]   a2           0              92    3808     119 
[109]   a4  0x00000068       0    0     LD       PR    0    0
[110]   m   0x00000000     debug     0     fun                    baz:F-1
[111]   m   0x10000518     .text     1     fcn                    .bf
[112]   a1           0         4     0       0       0 
[113]   m   0x00000068     debug     0    psym                    a:p-1
[114]   m   0x000000a4     debug     0   bstat                    .bs
[115]   m   0x00000008     debug     0   stsym __func__:V13
[116]   m   0x00000000     debug     0   estat                    .es
[117]   m   0x10000540     .text     1     fcn                    .ef 

And in case of gcc compiled binaries we were having symbol table entries 
as.

[149]   m   0x1000045c     .text     1  unamex                    .baz
[150]   a4  0x0000005c       0    0     SD       PR    0    0
[151]   m   0x1000045c     .text     2  extern                    .baz
[152]   a2           0              92   29522     160 
[153]   a4  0x00000095       0    0     LD       PR    0    0
[154]   m   0x00000000     debug     0     fun                    baz:F-1
[155]   m   0x100003d8     .text     1     fcn                    .bf

So the below changes to read correct auxiliary entry works for both gcc & 
xlc compiled binaries even if we have 1 entry.


Here is the details on each section of changes.

-  char *filestring = " _start_ ";      /* Name of the current file.  */
+  char *filestring = pst->filename;    /* Name of the current file.  */

When -qfuncsect options is used each function csect associated with each 
psymtab.
So each psymtab will have the it's corresponding c filename entries set.

If the name isn't set then we will be seeing the below output when we set 
a breakpoint.

(gdb) br main
Breakpoint 1 at 0x10000374: file  _start_ , line 18.

 


 
@@ -1141,8 +1141,7 @@
          /* Done with all files, everything from here on is globals.  */
        }
 
-      if ((cs->c_sclass == C_EXT || cs->c_sclass == C_HIDEXT)
-         && cs->c_naux == 1)
+      if ((cs->c_sclass == C_EXT || cs->c_sclass == C_HIDEXT))
        {
          /* Dealing with a symbol with a csect entry.  */
 
@@ -1153,8 +1152,31 @@
 #define        CSECT_SCLAS(PP) (CSECT(PP).x_smclas)
 
          /* Convert the auxent to something we can access.  */
-         bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, 
cs->c_sclass,
-                               0, cs->c_naux, &main_aux);
+             /* XCOFF can have more than 1 auxent. */
+             if (cs->c_naux > 1)
+               {
+                 if (ISFCN (cs->c_type) && cs->c_sclass != C_TPDEF)
+                  {
+                    bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type,
+                                          cs->c_sclass, 0, cs->c_naux,
+                                          &main_aux);
+                    goto function_entry_point;
+                  }
+                 else
+                   bfd_coff_swap_aux_in (abfd,
+                                        raw_auxptr
+                                        + ((coff_data 
(abfd)->local_symesz)
+                                        * (cs->c_naux - 1)),
+                                        cs->c_type, cs->c_sclass,
+                                        cs->c_naux - 1, cs->c_naux,
+                                        &main_aux);
+               }
+             else if (cs->c_naux == 1)
+               bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type,
+                                     cs->c_sclass, 0, cs->c_naux,
+                                     &main_aux);
+             else
+                continue;
 
          switch (CSECT_SMTYP (&main_aux))
            {

Here is the offical xcoff documentation say about csect auxilirary entry.

And we always need to read last auxiliary entry as symbols having a 
storage class of C_EXT, C_WEAKEXT or C_HIDEXT 
and more than one auxiliary entry must have the csect auxiliary entry as 
the last auxiliary entry.

So we need to read the last auxiliary entry which is having the SD/PR in 
case of qfuncsect or LD/PR is case of no csects.

If we don't have above changes then the gdb output would look something 
like this.

gcc
===
Breakpoint 1, main () at  _start_ :16
16       _start_ : A file or directory in the path name does not exist..
(gdb) n

xlc
===
(gdb) br main
warning: (Internal error: pc 0x10000380 in read in psymtab, but not in 
symtab.)
.................
.................
Breakpoint 1 at 0x1000038c
(gdb) 




Thanks,
-Sangamesh

Attachment: ChangeLog
Description: Binary data

Attachment: skip_@fix.patch
Description: Binary data

Attachment: xcoffread_symtab-.patch
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]