This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Special names tha ld needs to recognize for hppa64-hp-hpux11.X
- From: "John David Anglin" <dave at hiauly1 dot hia dot nrc dot ca>
- To: law at redhat dot com
- Cc: binutils at sources dot redhat dot com
- Date: Mon, 11 Feb 2002 21:40:31 -0500 (EST)
- Subject: Re: Special names tha ld needs to recognize for hppa64-hp-hpux11.X
> "John David Anglin" writes:
>
> > bash-2.05$ gcc -g -static -o main main.c
> > bash-2.05$ ./main
> > Segmentation fault (core dumped)
> >
> > The problem is this code in the exitcu.o module:
> >
> > 8: 2b 60 00 00 addil 0,dp,%r1
> > 8: R_PARISC_LTOFF_FPTR21L do_exitcu
> > c: 50 3a 00 00 ldd 0(r1),r26
> > c: R_PARISC_LTOFF_FPTR14DR do_exitcu
> >
> > When linked with gnu ld, r26 ends up with actual address of "do_exitcu".
> > However, r26 should contain the address of the .opd entry for "do_exitcu".
> Hmmm, what is the scope of do_exitcu? global or file-local?
It's local.
Symbols from exitcu.o:
[Index] Value Size Type Bind O Shndx Name
[3] | 0| 180|FUNC |LOCAL|0| .text|do_exitcu
> I vaguely recall that the behavior of these are different; specifically
> the .dlt entry isn't supposed to point to a .opd entry (since we don't
> have .opd entries for static functions).
That's definitely strange as the HP compiler is definitely passing a
pointer to an .opd entry for do_excite when it calls ___stdio_unsup_1.
The GNU linked code seg faults on the bve,l call to do_exitcu which
occurs here:
36c: 50 a2 00 20 ldd 10(r5),rp
370: 50 bb 00 30 ldd 18(r5),dp
374: 35 9a 00 00 ldo 0(r12),r26
378: e8 40 f0 00 bve,l (rp),%r2
It seems that the HP compiler and linker use an .opd entry for an indirect
call to a static function in a different module. This little test program
shows the difference between what cc +DA2.0W and gcc are doing:
extern void f (void (*)(void));
static void g (void) { }
main ()
{
f (g);
}
cc +DA2.0W -c:
18: 2b 60 00 00 addil 0,dp,%r1
18: R_PARISC_LTOFF_FPTR21L g
1c: 50 3a 00 00 ldd 0(r1),r26
1c: R_PARISC_LTOFF_FPTR14DR g
20: e8 00 a0 00 b,l 28 <main+0x28>,%r2
20: R_PARISC_PCREL22F f
24: 37 dd 3f a1 ldo -30(sp),ret1
gcc:
40: 2b 60 00 00 addil 0,dp,%r1
40: R_PARISC_DLTIND21L L$C0000
44: 50 21 00 00 ldd 0(r1),r1
44: R_PARISC_DLTIND14R L$C0000
48: 0c 20 10 da ldd 0(sr0,r1),r26
4c: 37 dd 3f e1 ldo -10(sp),ret1
50: e8 00 a0 00 b,l 58 <main+0x40>,%r2
50: R_PARISC_PCREL22F f
54: 08 00 02 40 nop
Dave
--
J. David Anglin dave.anglin@nrc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6605)