Re: [parisc-linux] -pie is broken on hppa
On Fri, Jun 01, 2007 at 08:07:48PM -0400, John David Anglin wrote:
> > I think this snip of code is of concern.
> > #if SHARED
> > /* load main (1st argument) */
> > addil LR'.Lpmain, %r19
> > ldw RR'.Lpmain(%r1), %r26
> > ldw 0(%r26),%r26
>
> This is wrong. The above should be
>
> addil LT'.Lpmain, %r19
> ldw RT'.Lpmain(%r1), %r26
> ldw 0(%r26),%r26
Ok, I applied the first fix, and now -pie exe are working again !!!
>
> I.e., we need to go through the linkage table when generating PIC code.
>
> > #else
> > /* load main (1st argument) */
> > ldil LR'.Lpmain, %r26
> > ldw RR'.Lpmain(%r26), %r26
>
> This is also wrong although it might work. Should be
>
> addil LR'.Lpmain-$global$, %r27
> ldw RR'.Lpmain-$global$(%r1), %r26
I tried to fix this but it only resulted in a crash for linking with gcrt1.o and crt1.o.
So, if they are not broken, don't fix them :-).
I reverted the fix to the old code.
Please find the fix included.
For my information, where are described the calling convention used by gcc ?
>
> Here we need to do offsets using global pointer r27. The above
> two sequences are the ones used by GCC for indirect calls.
>
> The same treatement is needed for the other symbols.
>
> Hope this helps,
> Dave
> --
> J. David Anglin dave.anglin@nrc-cnrc.gc.ca
> National Research Council of Canada (613) 990-0752 (FAX: 952-6602)
--- glibc-2.5/ports/sysdeps/hppa/elf/start.S.orig 2007-06-02 12:27:53.000000000 +0200
+++ glibc-2.5/ports/sysdeps/hppa/elf/start.S 2007-06-02 12:27:49.000000000 +0200
@@ -96,16 +96,16 @@
#if SHARED
/* load main (1st argument) */
- addil LR'.Lpmain, %r19
- ldw RR'.Lpmain(%r1), %r26
+ addil LT'.Lpmain, %r19
+ ldw RT'.Lpmain(%r1), %r26
ldw 0(%r26),%r26
/* void (*init) (void) (4th argument) */
- addil LR'.Lp__libc_csu_init, %r19
- ldw RR'.Lp__libc_csu_init(%r1), %r23
+ addil LT'.Lp__libc_csu_init, %r19
+ ldw RT'.Lp__libc_csu_init(%r1), %r23
ldw 0(%r23), %r23
/* void (*fini) (void) (5th argument) */
- addil LR'.Lp__libc_csu_fini, %r19
- ldw RR'.Lp__libc_csu_fini(%r1), %r22
+ addil LT'.Lp__libc_csu_fini, %r19
+ ldw RT'.Lp__libc_csu_fini(%r1), %r22
ldw 0(%r22), %r22
#else
/* load main (1st argument) */
Reply to: