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]

[PATCH] Read corrrect auxiliary entry in AIX.


Hi Ulrich and et all,

Attaching the modified patch which i sent earlier for reading correct 
auxiliary entry in AIX.
Description is almost same, with the output of test case results added.


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.

As 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 the changes then the gdb output would look something like 
this in case of xlc compiler binaries.

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


diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 974152f..694206b 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1140,8 +1140,7 @@ read_xcoff_symtab (struct objfile *objfile, struct 
partial_symtab *pst)
          /* 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.  */
 
@@ -1152,8 +1151,25 @@ read_xcoff_symtab (struct objfile *objfile, struct 
partial_symtab *pst)
 #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) &&
+                              (ISFCN (cs->c_type) && cs->c_sclass != 
C_TPDEF))
+         {
+           /* We need to read the size if we have LD/PR, and with more 
than
+              one auxiliary entry.  */
+           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);
+         }
 
          switch (CSECT_SMTYP (&main_aux))
            {

Here is the test results
========================

gcc without fix (with -ffunction-sections)
--------------------------------------------------
# of expected passes            8607
# of unexpected failures        3083
# of unexpected successes       1
# of expected failures          14
# of unresolved testcases       4
# of untested testcases         60
# of unsupported tests          30

gcc with fix (with -ffunction-sections)
----------------------------------------------
# of expected passes            8607
# of unexpected failures        3083
# of unexpected successes       1
# of expected failures          14
# of unresolved testcases       4
# of untested testcases         60
# of unsupported tests          30

xlc without fix (with -qfuncsect)
---------------------------------------
# of expected passes            2798
# of unexpected failures        2721
# of expected failures          10
# of unresolved testcases       71
# of untested testcases         92
# of unsupported tests          15

xlc with fix (with -qfuncsect)
-----------------------------------
# of expected passes            7559
# of unexpected failures        3415
# of unexpected successes       1
# of expected failures          13
# of unresolved testcases       9
# of untested testcases         71
# of unsupported tests          29




Thanks,
-Sangamesh

Attachment: ChangeLog
Description: Binary data

Attachment: xcoff_read.patch
Description: Binary data


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