On Sun, Oct 28, 2018 at 01:25:54AM +0000, Richard Henderson wrote:
> On 10/27/18 5:37 AM, Stafford Horne wrote:
> > +/* Here _init and _fini are empty because .init_array/.fini_array are used
> > +   exclusively.  However, the functions are still needed as required when
> > +   linking.  */
> > +   .align 4
> > +   .global _init
> > +   .type   _init,@function
> > +_init:
> > +   .global _fini
> > +   .type   _fini,@function
> > +_fini:
> > +   l.jr    r9
> > +    l.nop
> 
> Where are they referenced from?  Perhaps just a binutils bug, in that the
> linker script needs adjustment?

I was getting the issue with newlib.  Here:

 
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=newlib/libc/misc/init.c
 
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=newlib/libc/misc/fini.c

The HAVE_INIT_FINI was not there when I last checked. Now, thanks to risc-v, we
can turn off the need for _init/_fini see:

 
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=commit;f=newlib/libc/misc/fini.c;h=6158b30e3e9b1b582ae60b15d64e775fa1705483

I guess thats what you were referring to before though, I just missed it.

> > +   /* Given R = X * Y ... */
> > +1: l.sfeq          r4, r0                  /* while (y != 0) */
> > +   l.bf            2f
> > +    l.andi         r5, r4, 1               /* if (y & 1) ... */
> > +   l.add           r12, r11, r3
> > +   l.sfne          r5, r0
> > +#if defined(__or1k_cmov__)
> > +   l.cmov          r11, r12, r11           /* ... r += x. */
> > +   l.srli          r4, r4, 1               /* y >>= 1 */
> > +#else
> > +   l.bnf           3f
> > +    l.srli         r4, r4, 1               /* y >>= 1 */
> > +   l.ori           r11, r12, 0
> 
> This move could be the add to save 1 cycle in the !cmov case.
> 
> > +   /* Shift Y back to the right again, subtracting from X.  */
> > +2: l.add           r7, r11, r6     /* tmp1 = quot + mask */
> > +3: l.srli          r6, r6, 1       /* mask >>= 1 */
> > +   l.sub           r8, r12, r4     /* tmp2 = x - y */
> > +   l.sfleu         r4, r12         /* y <= x */
> > +   l.srli          r4, r4, 1       /* y >>= 1 */
> > +#if defined(__or1k_cmov__)
> > +   l.cmov          r11, r7, r11    /* if (y <= x) quot = tmp1 */
> > +   l.cmov          r12, r8, r12    /* if (y <= x) x = tmp2 */
> > +#else
> > +   l.bnf           4f
> > +    l.nop
> > +   l.ori           r11, r7, 0
> > +   l.ori           r12, r8, 0
> 
> Simiarly.
> 
> Although both mul nor div are correct as-is, and need not be fixed 
> immediately.
>  I'm only concerned about _init and _fini.

Sure, let me look into them.

-Stafford

Reply via email to