Re: [PATCH] Fix call functions command bug in 64-bit programs for AIX and PC read in psymtab-symtab warning

Ulrich Weigand via Gdb-patches
2023-04-24T15:45:25Z

>So here is the thing, there are 4 values for which the psymtab entries are created. Their addresses are 0, 1a0, 0 and 8.
>
>In the object dump outputs I see they are like this..
>[235] m 0x00000000 debug 0 gsym __new_exitfn_called:G13=14=@s64;r14;0;01777777777777777777777;
>[236] m 0x00000008 debug 0 gsym __exit_funcs:G4
>[188] m 0x000001a0 debug 0 fun __internal_atexit:F8=r8;-2147483648;2147483647;
>[177] m 0x00000000 debug 0 fun __new_exitfn:F1=*2=xsexit_function:

It seems to be these numbers are not actual addresses,
which looks like the root cause of the problem.

In fact, looking e.g. at "__new_exitfn" in the detailed dump below:

>[174] m 0x100007a8 .text 2 extern .__new_exitfn
>[175] a2 0 416 7670 185
>[176] a4 0x000000ac 0 0 LD PR 0 0
>[177] m 0x00000000 debug 0 fun __new_exitfn:F1=*2=xsexit_function:
>[178] m 0x100007a8 .text 1 fcn .bf
>[179] a1 0 75 0 0 0
>[180] m 0x0000001f debug 0 rpsym listp:R3=*4=*5=xsexit_function_list:
>[181] m 0x00000003 debug 0 rsym r:r1
>[182] m 0x00000009 debug 0 rsym i:r6=7=r7;0;037777777777;
>[183] m 0x10000924 .text 1 fcn .ef
>[184] a1 0 131 0 0 0

We see that there is an actual symbol (in the .text section)
at address 0x100007a8, covering 416 byte (until 0x10000948).

*In addition*, there is a "debug" (stabs) symbol giving the
type of that function. This also has an address field, but
this is simply zero.

My understanding, and that is apparently confirmed by the
text in the GNU stabs documentation here:
https://sourceware.org/gdb/download/onlinedocs/stabs/Transformations-On-Global-Variables.html
is that the "address" value in the debug entry is not used,
but the actual address should be taken from the .text entry.

Now I'm not sure why this doesn't work correctly, but this
may be a place to investigate further.

(One interesting thing to note is that the names do not match
exactly, as the .text entry has the leading '.' that is used
on ppc64 ... maybe this throws off some of the stabs logic?)

Bye,
Ulrich