unresolvable R_PPC_REL16_{HA,LO} relocation against symbol

Hiroki Kaminaga kaminaga@sm.sony.co.jp
Wed Nov 8 07:44:00 GMT 2006


From: Hiroki Kaminaga <kaminaga@sm.sony.co.jp>
> Hi,
> 
> I'm using toolchain version:
>  gcc-4.1.1
>  glibc-2.5
>  binutils-2.17
> 
> and trying to cross compile glibc-2.5 for powerpc on i386 host machine.
> 
> I get below error:
> 
> /usr/local/powerpc-gnu-linux/devel/lib/gcc/powerpc-gnu-linux/4.1.1/../../../../powerpc-gnu-linux/bin/ld: /var/rpm/BUILD/glibc-2.5/objdir/linuxthreads/libpthread_pic.a(ptw-write.os)(.text+0xe): unresolvable R_PPC_REL16_HA relocation against symbol `__librt_multiple_threads@@GLIBC_PRIVATE'
> /usr/local/powerpc-gnu-linux/devel/lib/gcc/powerpc-gnu-linux/4.1.1/../../../../powerpc-gnu-linux/bin/ld: /var/rpm/BUILD/glibc-2.5/objdir/linuxthreads/libpthread_pic.a(ptw-write.os)(.text+0x12): unresolvable R_PPC_REL16_LO relocation against symbol `__librt_multiple_threads@@GLIBC_PRIVATE'
> /usr/local/powerpc-gnu-linux/devel/lib/gcc/powerpc-gnu-linux/4.1.1/../../../../powerpc-gnu-linux/bin/ld: final link failed: Nonrepresentable section on output
> collect2: ld returned 1 exit status
> make[2]: *** [/var/rpm/BUILD/glibc-2.5/objdir/linuxthreads/libpthread.so] Error 1
> make[2]: Leaving directory `/var/rpm/BUILD/glibc-2.5/linuxthreads'
> make[1]: *** [linuxthreads/others] Error 2
> 
> 
>   *  *  *  *  *
> 
> when I changed to different binutils version and build again,
> below is the result:
> 
> binutils-2.16.1      + glibc-2.5 + gcc-4.1.1 = OK
> binutils-2.17        + glibc-2.5 + gcc-4.1.1 = NG
> binutils-2.17.50.0.6 + glibc-2.5 + gcc-4.1.1 = NG


Below is reduced test case, with binutils version >= 2.17.

$ cat foo.c 
int foo(void) {return 0;}

$ cat bar.S 
	.section ".text"
	.align 2
	.globl bar
	.type bar, @function
bar:
	li 14,0
	addis 10,10,foo-.@ha
	lwz 10,foo-.@l(10)
	mr 3,14
	blr
	.size bar, .-bar

$ cat Makefile 
CROSS=powerpc-gnu-linux-
CC=$(CROSS)gcc

all: foo bar
foo: 
	$(CC) -shared -o libfoo.so foo.c
bar: foo
	$(CC) -shared bar.S libfoo.so

$ make
powerpc-gnu-linux-gcc -shared -o libfoo.so foo.c
powerpc-gnu-linux-gcc -shared bar.S libfoo.so
/usr/local/powerpc-gnu-linux/devel/lib/gcc/powerpc-gnu-linux/4.1.1/../../../../powerpc-gnu-linux/bin/ld: /tmp/ccmkHfFo.o(.text+0x6): unresolvable R_PPC_REL16_HA relocation against symbol `foo'
/usr/local/powerpc-gnu-linux/devel/lib/gcc/powerpc-gnu-linux/4.1.1/../../../../powerpc-gnu-linux/bin/ld: /tmp/ccmkHfFo.o(.text+0xa): unresolvable R_PPC_REL16_LO relocation against symbol `foo'
/usr/local/powerpc-gnu-linux/devel/lib/gcc/powerpc-gnu-linux/4.1.1/../../../../powerpc-gnu-linux/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
make: *** [bar] Error 1


And my question:
1) Is this the right ML to post?
2) Is this a bad programming or sane programming?
   This sample is made by mimicing glibc-2.5 failure above.


Thanks in Advance.

(Hiroki Kaminaga)
t
--



More information about the Binutils mailing list