BSD

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Text relocations in libpthread

    3 answers - 279 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    [should this be on tech-userlevel?]
    The attached (untested) patch removes the text relocations from libpthread.so
    for i386, sh3, sparc, sparc64, and x86_64
    Can someone test and/or comment before I commit - not sure I've got sh3 right?
    Nick
  • No.1 | | 660 bytes | |

    Tuesday 27 December 2005 08:38, Valeriy E. Ushakov wrote:
    Tue, Dec 27, 2005 at 08:11:47 +0000, Nick Hudson wrote:
    not sure I've got sh3 right?

    sh3 also needs r12 to be set up before doing plt calls. You can leave
    sh3 out and I will take care of it.

    K.

    [x86_64 diff snipped]

    I think these *_return_point symbols should be made .hidden, then
    these diffs will not be necessary. As with cerror, I don't see a
    reason why we would want to make them globally visible/overridable.

    This makes sense to me.

    Any objection to me fixing the text relocations while this is discussed?

    Nick
  • No.2 | | 1552 bytes | |

    Tue, Dec 27, 2005 at 08:11:47 +0000, Nick Hudson wrote:

    not sure I've got sh3 right?

    sh3 also needs r12 to be set up before doing plt calls. You can leave
    sh3 out and I will take care of it.

    Index:

    RCS file: /,v
    retrieving revision 1.10
    diff -u -p -u -r1.10 pthread_switch.S
    23 Apr 2004 02:58:27 -00001.10
    27 Dec 2005 07:12:17 -0000
    @@ -136,7 +136,11 @@ ENTRY(pthread__switch)
    * Edit the context so that it continues as if returning from
    * the _setcontext_u below.
    */
    +#ifdef PIC
    +movqPIC_GT(pthread__switch_return_point), %r15
    +#else
    leaqpthread__switch_return_point(%rip), %r15
    +#endif
    movq%r15, UC_RIP(%r14)
    movq%r14, PT_UC(%r12)

    @@ -157,7 +161,6 @@ NENTRY(pthread__switch_return_point)
    * Helper switch code used by pthread__locked_switch() and
    * pthread__upcall_switch() when they discover spinlock preemption.
    */
    -.globl pthread__switch_away
    pthread__switch_away:
    STACK_SWITCH

    @@ -204,7 +207,11 @@ ENTRY(pthread__locked_switch)
    * Edit the context so that it continues as if returning from
    * the _setcontext_u below.
    */
    +#ifdef PIC
    +movqPIC_GT(locked_return_point), %r15
    +#else
    leaqlocked_return_point(%rip), %r15
    +#endif
    movq%r15, UC_RIP(%r14)
    movq%r14, PT_UC(%r12)

    I think these *_return_point symbols should be made .hidden, then
    these diffs will not be necessary. As with cerror, I don't see a
    reason why we would want to make them globally visible/overridable.

    SY, Uwe
  • No.3 | | 1968 bytes | |

    Tue, Dec 27, 2005 at 11:38:05 +0300, Valeriy E. Ushakov wrote:

    Index:

    RCS file: /,v
    retrieving revision 1.10
    diff -u -p -u -r1.10 pthread_switch.S
    23 Apr 2004 02:58:27 -00001.10
    27 Dec 2005 07:12:17 -0000
    @@ -136,7 +136,11 @@ ENTRY(pthread__switch)
    * Edit the context so that it continues as if returning from
    * the _setcontext_u below.
    */
    +#ifdef PIC
    +movqPIC_GT(pthread__switch_return_point), %r15
    +#else
    leaqpthread__switch_return_point(%rip), %r15
    +#endif
    movq%r15, UC_RIP(%r14)
    movq%r14, PT_UC(%r12)

    I think these *_return_point symbols should be made .hidden, then
    these diffs will not be necessary. As with cerror, I don't see a
    reason why we would want to make them globally visible/overridable.

    I did a quick review of the arch/*/pthread_switch.S and the situation
    seems to be quite messy.

    pthread__switch_return_point is mentioned in pthread_sa.c as:

    extern void pthread__switch_return_point(void);

    In pthread__upcall() the code checks if:

    psrp = pthread__switch_return_point;
    pc = (fptr_t)((intptr_t)
    pthread__uc_pc(victim->pt_uc));
    if ((victim->pt_spinlocks == 0) &&
    ((victim->pt_switchto != NULL) ||
    (pc == psrp))) {

    }

    Now, my reading of the pthread_switch.S files is that most of the
    architectures set the pc (pthread__uc_pc(victim->pt_uc)) to the
    absolute address of the pthread__switch_return_point label during the
    pthread__switch. But psrp = pthread__switch_return_point assignment
    will set psrp to the PLT entry instead, b/c pthread__switch_return_point
    is not .hidden, so (pc == psrp) will never be true.

    PS: Then there's VAX on which pthread__switch_return_point is *not*
    the label that pthread__switch use, so on VAX that (pc == psrp) will
    never be true even for static linking, or pthread__switch_return_point
    marked as .hidden.

    SY, Uwe

Re: Text relocations in libpthread


max 4000 letters.
Your nickname that display:
In order to stop the spam: 5 + 5 =
QUESTION ON "BSD"

EMSDN.COM