can't handle reloc type 0x6

pcj at uclibc.sez.to pcj at uclibc.sez.to
Thu Dec 22 22:37:28 UTC 2005


I also observed the "can't handle reloc type 0x6" message on PowerPC
when running programs linked against libm.so and dug in a little
deeper.

I found two separate problems.

First, the architecture-optimized math routines in libm/powerpc/*.c
are not getting compiled with -fpic.  The following Makefile patch
solves that problem:

--- libm/powerpc/Makefile.arch~      2005-12-21 00:10:22.000000000 -0800
+++ libm/powerpc/Makefile.arch       2005-12-22 12:06:31.000000000 -0800
@@ -13,7 +13,11 @@
 
 libm_ARCH_OBJS:=$(libm_ARCH_OBJ)
 
-libm-a-$(DO_C99_MATH)+=$(libm_ARCH_OBJS)
+ifeq ($(DOPIC),y)
+libm-a-$(DO_C99_MATH) += $(libm_ARCH_OBJS:.o=.os)
+else
+libm-a-$(DO_C99_MATH) += $(libm_ARCH_OBJS)
+endif
 libm-so-$(DO_C99_MATH)+=$(libm_ARCH_OBJS:.o=.os)
 
 libm-multi-$(DO_C99_MATH)+=$(libm_ARCH_SRC)

The second problem is with ldso.  I can describe it but I don't have
the ldso mojo to provide a patch for it. 

When you create a shared object without -fpic, you get relocs in the
.so that look like this:

Relocation section [ 6] '.rela.dyn' for section [ 0] '' at offset
0x1494 contains 15 entries:
  Offset      Type            Value       Addend Name
[...]
  0x00001706  PPC_ADDR16_HA   0x000019a8  + 6568 .rodata
  0x0000170e  PPC_ADDR16_LO   0x000019a8  + 6568 .rodata

This is a fixup for a const double.   The corresponding symbol looks
like
  Num:    Value   Size Type    Bind   Vis          Ndx Name
    4: 000019a8      0 SECTION LOCAL  DEFAULT       11 

The relevant LD_DEBUG=all output is:

value=0x19a8  size=0x0  info=0x3  other=0x0  shndx=0xb 
  R_PPC_ADDR16_HA offset=0x1706   addend=0x19a8

But ldso can't handle this fixup.  In _dl_do_reloc, what happens is
that there is a nonzero symtab_index (line 199), but no symbol_addr.
So the STB_WEAK check at line 206 fails, _dl_do_reloc returns -1, and
you get the somewhat cryptic error message:

./t1: symbol '': can't handle reloc type 'R_PPC_ADDR16_HA' in lib './t1.so'

-- Paul




More information about the uClibc mailing list