This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gld.c3.4.5-p4.ppc: t1t2(.text+0x40): R_PPC_PLTREL24 reloc against local symbol


Hello There,

I have a function test1a() defined in test1.c that invokes test2a in test2.c.
Using objdump, I have combined the .o's of test1.c and test2.c, call this t1t2
Using objcopy, I want to keep the symbols defined in test1.c as global
and the rest of the symbols defined in test2.c as local.(test2a() as
local)
After step 3, if I try to create a shared object, I get this "reloc
against local symbol" error :(

Please note, This happens only on powerpc gld. Using X86 gld, things work fine.

Why am I unable to relocate the local symbols in powerpc gld.? Is
there a way I can create a shared object?

I will really appreciate any help on this.

Many Thanks for taking time to read this.
-Jalaja


This is what I did:

>cat test1.c
#include <stdio.h>

extern void test2a();
extern void test2b();
extern int test2_var;


void test1a() {
        printf("%d\n", test2_var);

        test2a();
        test2b();

}
>cat test2.c
#include <stdio.h>

int test2_var;

void test2b() {
                printf("%s, %d", __FUNCTION__, __LINE__);
}
void test2a() {
                printf("%s, %d", __FUNCTION__, __LINE__);
}



>gcc.c3.4.5-p4.ppc -fPIC -DGENPIC -c test1.c -o t1    ==============> compile test1.c
>gcc.c3.4.5-p4.ppc -fPIC -DGENPIC -c test2.c -o t2   ===============> compile test2.c
>objdump.c3.4.5-p4.ppc -t t1 > t1.dump                     ==============> objdump on test1.c

>cat t1.dump                                                            ===============> displaying the objdump of test1.c
t1:     file format elf32-powerpc

SYMBOL TABLE:
00000000 l    df *ABS*  00000000 test1.c
00000001 l       *ABS*  00000000 PPC_CPUOP_ENABLED
00000000 l    d  .text  00000000
00000000 l    d  .data  00000000
00000000 l    d  .bss   00000000
00000000 l    d  .got2  00000000
00000000 l    d  .rodata        00000000
00000000 l    d  .comment       00000000
00000000         *UND*  00000000 test2_var
00000004 g     F .text  00000060 test1a
00000000         *UND*  00000000 printf
00000000         *UND*  00000000 test2a
00000000         *UND*  00000000 test2b


>grep " g " t1.dump | grep text | awk '{print $6}' > extern.symbols ===============> Finding the global symbols defined in test1.c

>cat extern.symbols
>test1a

>gld.c3.4.5-p4.ppc -nostdlib -r -o t1t2 t1 t2                     ====================> combine the .o's of test1.c and test2.c
>objdump.c3.4.5-p4.ppc -t t1t2
>objcopy.c3.4.5-p4.ppc --keep-global-symbols=extern.symbols t1t2    =============> Keep the symbols in test1.c as global and the rest as local
>objdump.c3.4.5-p4.ppc -t t1t2
t1t2:     file format elf32-powerpc

SYMBOL TABLE:
00000000 l    d  .text  00000000
00000000 l    d  *ABS*  00000000
00000000 l    d  .rodata        00000000
00000000 l    d  .data  00000000
00000000 l    d  .got2  00000000
00000000 l    d  *ABS*  00000000
00000000 l    d  .bss   00000000
00000000 l    d  .comment       00000000
00000000 l    d  *ABS*  00000000
00000000 l    d  *ABS*  00000000
00000000 l    d  *ABS*  00000000
00000000 l    df *ABS*  00000000 test1.c
00000001 l       *ABS*  00000000 PPC_CPUOP_ENABLED
00000000 l    df *ABS*  00000000 test2.c
00000001 l       *ABS*  00000000 PPC_CPUOP_ENABLED
00000004 l     O .rodata        00000007 __FUNCTION__.0
00000014 l     O .rodata        00000007 __FUNCTION__.1
000000c4 l     F .text  00000058 test2a
===============> Made this local
00000068 l     F .text  00000058 test2b
================> Made this local
00000000         *UND*  00000000 printf
00000004 g     F .text  00000060 test1a
===============> Note only this symbol is global
00000004       O *COM*  00000004 test2_var


>gld.c3.4.5-p4.ppc -shared -soname libt1t2.so -nostdlib -o libt1t2.so t1t2 -Bdynamic -L /usr/lib/
gld.c3.4.5-p4.ppc: t1t2(.text+0x40): R_PPC_PLTREL24 reloc against local symbol
t1t2: could not read symbols: Bad value


/ws/jganapat/junk/nonk9>readelf.c3.4.5-p4.ppc -r t1t2

Relocation section '.rela.text' at offset 0x5ac contains 0 entries:
 Offset     Info    Type            Sym.Value  Sym. Name + Addend
00000000  0000051a R_PPC_REL32       0000000000000000   .got2 + 7fe0
0000003c  00001412 R_PPC_PLTREL24    0000000000000000   printf + 0
00000040  00001212 R_PPC_PLTREL24    00000000000000c4   test2a + 0
00000044  00001312 R_PPC_PLTREL24    0000000000000068   test2b + 0
00000064  0000051a R_PPC_REL32       0000000000000000   .got2 + 7fe8
000000a0  00001412 R_PPC_PLTREL24    0000000000000000   printf + 0
000000c0  0000051a R_PPC_REL32       0000000000000000   .got2 + 7fe8
000000fc  00001412 R_PPC_PLTREL24    0000000000000000   printf + 0

Relocation section '.rela.got2' at offset 0x60c contains 0 entries:
 Offset     Info    Type            Sym.Value  Sym. Name + Addend
00000000  00001601 R_PPC_ADDR32      0000000000000004   test2_var + 0
00000004  00000301 R_PPC_ADDR32      0000000000000000   .rodata + 0
00000008  00000301 R_PPC_ADDR32      0000000000000000   .rodata + c
0000000c  00001001 R_PPC_ADDR32      0000000000000004   __FUNCTION__.0 + 0
00000010  00001101 R_PPC_ADDR32      0000000000000014   __FUNCTION__.1 + 0
/ws/jganapat/junk/nonk9>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]