bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/10009] Conflict between MIPS PLTS and abicalls stubs


From: cburgess at qnx dot com
Subject: [Bug ld/10009] Conflict between MIPS PLTS and abicalls stubs
Date: 26 Mar 2009 13:40:27 -0000

------- Additional Comments From cburgess at qnx dot com  2009-03-26 13:40 
-------
For some reason attachments don't work for me, here are the example source 
files...

a.c:

#include <a.h>

int main(void)
{
    fptr *fp;

    /*  
     * Here we call function(), which initially selects a traditional
     * abicalls stub
     */
    function();

    /* We show as this function to give us the address of function(),
     * however the linker is not aware that the address of function() will
     * be referenced within the shared object
     */ 
    set_function_address(&fp);

    /* when we now as this funtion to invoke our function pointer, it does
     * so from the GOT context of b.so, and thus if it transfer into an
     * abicalls stub it will load the incorrect got entry (ie that from
     * b.so rather a) and havoc will ensue!
     */
    invoke_function(fp);

#if 0
    /* But if this code is enabled, the reference to the address of function()
     * causes a PLT to be used, and the address of the PLT becomes
     * the canonical address of function()
     */
    fp = function;
#endif

    return 0;
}

a.h:
typedef void (fptr)(void);

extern void function(void);
extern void invoke_function(fptr *f);
extern void set_funtion_address(fptr **f);

b.c:
#include <a.h>

void function(void)
{
}

void set_function_address(fptr **fp)
{
    *fp = function;
}

void invoke_function(fptr *fp)
{
    (fp)();
}

Makefile:
QCC=env QNX_TARGET=/home/cburgess/qssl/stage qcc -V4.3.3,gcc_ntomipsbe -I .

all: a b.so

clean:
    rm -f a b.so *.o

a.o: a.c
    $(QCC) -g -c a.c

b.o: b.c
    $(QCC) -g -shared -c b.c

a.s: 
    $(QCC) -S a.c

a: a.o b.so
    $(QCC) -o a a.o b.so

b.so: b.o
    $(QCC) -shared -o b.so -Wl,-soname=b.so b.o



-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=10009

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]