"symbol '': can't resolve symbol"

View: New views
8 Messages — Rating Filter:   Alert me  

"symbol '': can't resolve symbol"

by Stéphan Kochen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

I have a problem executing several application with uClibc. Busybox
appears to be working fine, even when linked dynamically. But, for
example, dbus-daemon and bluez-util's hcid immediately exit with errors
similar to the following:

  dbus-daemon: symbol '': can't resolve symbol in lib 'dbus-daemon'.

I was able to obtain the full output of LD_DEBUG=all, and uploaded it at
the following location:
  http://stephan.kochen.nl/proj/wii-oe/dbus-daemon_ld_debug.txt

The environment I'm using is OpenEmbedded, cross-compiling on an x86 for
PowerPC 750 (specifically, a Nintendo Wii). I produced the error above
with uClibc from SVN, revisions:
 * 21996 (from about two months ago)
 * 22935 (latest at the time of writing)
I've also tried 0.9.29, which simply segfaults.

Now I really don't understand much of what is going on here. I cannot
explain what appears to be garbage during the libexpat relocations;
readelf and objdump seem to handle the file without any issues. However,
the 'nameless' symbol that actually causes the program to exit appears
to refer to this entry in .dynsym of dbus-daemon:

   Num:    Value  Size Type    Bind   Vis      Ndx Name
     1: 00000114     0 SECTION LOCAL  DEFAULT    1

The exact dbus-daemon and libexpat binaries I used are available at:
  http://stephan.kochen.nl/proj/wii-oe/dbus-daemon
  http://stephan.kochen.nl/proj/wii-oe/libexpat.so.1.5.0

This is as much as I understand about the problem; I'm not sure how to
proceed. I'll be happy to provide any more info at request. Can anyone
help me with this problem?

Thanks in advance,
- -- Stéphan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIjIGDcFUq0gzqDwQRAi58AKDhrZPytIhjRZscu3P+sHKxDq3aKACgvyih
RstqvrXv61DY3F1flepXuVg=
=Mvks
-----END PGP SIGNATURE-----
_______________________________________________
uClibc mailing list
uClibc@...
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Re: "symbol '': can't resolve symbol"

by Joakim Tjernlund-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Sun, 2008-07-27 at 16:09 +0200, Stéphan Kochen wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello,
>
> I have a problem executing several application with uClibc. Busybox
> appears to be working fine, even when linked dynamically. But, for
> example, dbus-daemon and bluez-util's hcid immediately exit with errors
> similar to the following:
>
>   dbus-daemon: symbol '': can't resolve symbol in lib 'dbus-daemon'.
>
> I was able to obtain the full output of LD_DEBUG=all, and uploaded it at
> the following location:
>   http://stephan.kochen.nl/proj/wii-oe/dbus-daemon_ld_debug.txt
>
> The environment I'm using is OpenEmbedded, cross-compiling on an x86 for
> PowerPC 750 (specifically, a Nintendo Wii). I produced the error above
> with uClibc from SVN, revisions:
>  * 21996 (from about two months ago)
>  * 22935 (latest at the time of writing)
> I've also tried 0.9.29, which simply segfaults.
>
> Now I really don't understand much of what is going on here. I cannot
> explain what appears to be garbage during the libexpat relocations;
> readelf and objdump seem to handle the file without any issues. However,
> the 'nameless' symbol that actually causes the program to exit appears
> to refer to this entry in .dynsym of dbus-daemon:
>
>    Num:    Value  Size Type    Bind   Vis      Ndx Name
>      1: 00000114     0 SECTION LOCAL  DEFAULT    1
>
> The exact dbus-daemon and libexpat binaries I used are available at:
>   http://stephan.kochen.nl/proj/wii-oe/dbus-daemon
>   http://stephan.kochen.nl/proj/wii-oe/libexpat.so.1.5.0
>
> This is as much as I understand about the problem; I'm not sure how to
> proceed. I'll be happy to provide any more info at request. Can anyone
> help me with this problem?
>
> Thanks in advance,
> - -- Stéphan

Nintendo Wii, cool. What are you trying to do?

Thanks for so detailed report. It seems like you have build dbus-daemon
in a strange way. It is built similar to a shared lib and has both
TEXTREL and these "funny" relocs in it(use readelf -a to see):
0000529e  00000106 R_PPC_ADDR16_HA   00000114   .interp + 55248
000052a2  00000104 R_PPC_ADDR16_LO   00000114   .interp + 55248
000052c2  00000106 R_PPC_ADDR16_HA   00000114   .interp + 5270
000052c6  00000104 R_PPC_ADDR16_LO   00000114   .interp + 5270
000052ca  00000106 R_PPC_ADDR16_HA   00000114   .interp + 35f68
000052ce  00000104 R_PPC_ADDR16_LO   00000114   .interp + 35f68
000052d2  00000106 R_PPC_ADDR16_HA   00000114   .interp + 15820
000052d6  00000104 R_PPC_ADDR16_LO   00000114   .interp + 15820
000052d8  0000500a R_PPC_REL24       00000000   __uClibc_main + 0

There may be a bug in powerpc reloc code for ADDR_16_XX but you won't
get past ther REL24 reloc, you will get an unsupported error. See
ldso/powerpc/elfinterp.c, _dl_do_reloc()

What flags did you pass to the linker?

    Jocke


_______________________________________________
uClibc mailing list
uClibc@...
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Re: "symbol '': can't resolve symbol"

by Stéphan Kochen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Joakim Tjernlund schreef:
> Nintendo Wii, cool. What are you trying to do?

Thanks for the quick reply.

Right now, Linux on the Wii, and pretty much any unofficial software, is
in the early stages. I'm working towards networking using a Bluetooth
PAN, since that's the only way to get networking in Linux without
additional accessories. (At least, until someone figures out how to talk
to the wifi hardware.)

> Thanks for so detailed report. It seems like you have build dbus-daemon
> in a strange way. It is built similar to a shared lib and has both
> TEXTREL and these "funny" relocs in it(use readelf -a to see):
> 0000529e  00000106 R_PPC_ADDR16_HA   00000114   .interp + 55248
> 000052a2  00000104 R_PPC_ADDR16_LO   00000114   .interp + 55248
> 000052c2  00000106 R_PPC_ADDR16_HA   00000114   .interp + 5270
> 000052c6  00000104 R_PPC_ADDR16_LO   00000114   .interp + 5270
> 000052ca  00000106 R_PPC_ADDR16_HA   00000114   .interp + 35f68
> 000052ce  00000104 R_PPC_ADDR16_LO   00000114   .interp + 35f68
> 000052d2  00000106 R_PPC_ADDR16_HA   00000114   .interp + 15820
> 000052d6  00000104 R_PPC_ADDR16_LO   00000114   .interp + 15820
> 000052d8  0000500a R_PPC_REL24       00000000   __uClibc_main + 0

I see them, but have no idea why it's wrong. :)

> There may be a bug in powerpc reloc code for ADDR_16_XX but you won't
> get past ther REL24 reloc, you will get an unsupported error. See
> ldso/powerpc/elfinterp.c, _dl_do_reloc()

So I should be using -pic? Is -pie sufficient? (Which is what is
happening now.)

> What flags did you pass to the linker?

Here's the linker command line:

powerpc-linux-uclibc-gcc -mcpu=750 -mhard-float -ffunction-sections
- -fdata-sections
-
-isystem/home/shteef/Desktop/wii/oe/tmp/staging/powerpc-linux-uclibc/usr/include
- -fexpensive-optimizations -fomit-frame-pointer -frename-registers -Os
- -Wall -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes
- -Wnested-externs -Wpointer-arith -Wcast-align -Wsign-compare
- -Wdeclaration-after-statement -fno-common -Wl,--gc-sections -pie -Wl,-z
- -Wl,relro -Wl,-rpath-link
- -Wl,/home/shteef/Desktop/wii/oe/tmp/staging/powerpc-linux-uclibc/usr/lib
- -Wl,-O1 -o .libs/dbus-daemon activation.o bus.o config-parser.o
config-parser-common.o connection.o desktop-file.o dir-watch-inotify.o
dispatch.o driver.o expirelist.o policy.o selinux.o services.o signals.o
test.o utils.o config-loader-expat.o main.o
- -L/home/shteef/Desktop/wii/oe/tmp/staging/powerpc-linux-uclibc/usr/lib
/home/shteef/Desktop/wii/oe/tmp/staging/powerpc-linux-uclibc/usr/lib/libexpat.so
../dbus/.libs/libdbus-convenience.a

The gcc version here is 4.1.1.

Thanks,
- -- Stéphan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIjMFZcFUq0gzqDwQRAmS8AJ4mmiU6Zc2Fj6AIxN+fiCL2mGzdswCg48M2
bjWvoKvyX/jlLqTXWVtG77c=
=1Wu5
-----END PGP SIGNATURE-----
_______________________________________________
uClibc mailing list
uClibc@...
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

RE: "symbol '': can't resolve symbol"

by Joakim Tjernlund-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> -----Original Message-----
> From: Stéphan Kochen [mailto:stephan@...]
> Sent: den 27 juli 2008 20:42
> To: Joakim Tjernlund
> Cc: uclibc@...
> Subject: Re: "symbol '': can't resolve symbol"
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Joakim Tjernlund schreef:
> > Nintendo Wii, cool. What are you trying to do?
>
> Thanks for the quick reply.
>
> Right now, Linux on the Wii, and pretty much any unofficial software, is
> in the early stages. I'm working towards networking using a Bluetooth
> PAN, since that's the only way to get networking in Linux without
> additional accessories. (At least, until someone figures out how to talk
> to the wifi hardware.)

OK.

>
> > Thanks for so detailed report. It seems like you have build dbus-daemon
> > in a strange way. It is built similar to a shared lib and has both
> > TEXTREL and these "funny" relocs in it(use readelf -a to see):
> > 0000529e  00000106 R_PPC_ADDR16_HA   00000114   .interp + 55248
> > 000052a2  00000104 R_PPC_ADDR16_LO   00000114   .interp + 55248
> > 000052c2  00000106 R_PPC_ADDR16_HA   00000114   .interp + 5270
> > 000052c6  00000104 R_PPC_ADDR16_LO   00000114   .interp + 5270
> > 000052ca  00000106 R_PPC_ADDR16_HA   00000114   .interp + 35f68
> > 000052ce  00000104 R_PPC_ADDR16_LO   00000114   .interp + 35f68
> > 000052d2  00000106 R_PPC_ADDR16_HA   00000114   .interp + 15820
> > 000052d6  00000104 R_PPC_ADDR16_LO   00000114   .interp + 15820
> > 000052d8  0000500a R_PPC_REL24       00000000   __uClibc_main + 0
>
> I see them, but have no idea why it's wrong. :)
>
> > There may be a bug in powerpc reloc code for ADDR_16_XX but you won't
> > get past ther REL24 reloc, you will get an unsupported error. See
> > ldso/powerpc/elfinterp.c, _dl_do_reloc()
>
> So I should be using -pic? Is -pie sufficient? (Which is what is
> happening now.)

If you use -pie, you should also use -fPIC (gcc option). But why
use -pie? Just drop it if you don't have special reasons.

      Jocke



_______________________________________________
uClibc mailing list
uClibc@...
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Re: "symbol '': can't resolve symbol"

by Stéphan Kochen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Joakim Tjernlund schreef:
> If you use -pie, you should also use -fPIC (gcc option). But why
> use -pie? Just drop it if you don't have special reasons.

Excellent! Turns out bluez-utils, bluez-libs and dbus all have some
magic in their autoconf setup for additional PIE support. Getting rid of
it fixed the issues, and they now execute!

Many thanks for the help!
- -- Stéphan

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIjPr/cFUq0gzqDwQRApu4AKCEZqwJiuKdh4qEHEK6HekzZKuuSACcC17T
k4ubqn8zbte2xupjEEokhTU=
=DlqJ
-----END PGP SIGNATURE-----
_______________________________________________
uClibc mailing list
uClibc@...
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Re: "symbol '': can't resolve symbol"

by Joakim Tjernlund-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Mon, 2008-07-28 at 00:47 +0200, Stéphan Kochen wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Joakim Tjernlund schreef:
> > If you use -pie, you should also use -fPIC (gcc option). But why
> > use -pie? Just drop it if you don't have special reasons.
>
> Excellent! Turns out bluez-utils, bluez-libs and dbus all have some
> magic in their autoconf setup for additional PIE support. Getting rid of
> it fixed the issues, and they now execute!
>
> Many thanks for the help!
> - -- Stéphan

Good, however you should have made it to the REL24 reloc before
crashing. Would you mind trying the below patch with the old
dbus-daemon(built with -pie) to see if takes you to the
REL24 reloc?

 Jocke

>From 249f6028ea36580388deb1f963d71e77665e29a8 Mon Sep 17 00:00:00 2001
From: Joakim Tjernlund <Joakim.Tjernlund@...>
Date: Mon, 28 Jul 2008 17:11:17 +0200
Subject: [PATCH] Add check for STB_LOCAL.

Needed for "strange" relocs like R_PPC_ADDR16_HA,
R_PPC_ADDR16_HI and R_PPC_ADDR16_LO.
---
 ldso/ldso/powerpc/elfinterp.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/ldso/ldso/powerpc/elfinterp.c b/ldso/ldso/powerpc/elfinterp.c
index eeb3250..66decca 100644
--- a/ldso/ldso/powerpc/elfinterp.c
+++ b/ldso/ldso/powerpc/elfinterp.c
@@ -195,24 +195,28 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
  char *symname;
  Elf32_Addr *reloc_addr;
  Elf32_Addr finaladdr;
-
+ const Elf32_Sym *sym;
  unsigned long symbol_addr;
 #if defined (__SUPPORT_LD_DEBUG__)
  unsigned long old_val;
 #endif
  reloc_addr   = (Elf32_Addr *)(intptr_t) (tpnt->loadaddr + (unsigned long) rpnt->r_offset);
  reloc_type   = ELF32_R_TYPE(rpnt->r_info);
- symbol_addr  = tpnt->loadaddr; /* For R_PPC_RELATIVE */
+ symbol_addr  = tpnt->loadaddr; /* For R_PPC_RELATIVE and STB_LOCAL */
  symtab_index = ELF32_R_SYM(rpnt->r_info);
- symname      = strtab + symtab[symtab_index].st_name;
- if (symtab_index) {
+ sym          = &symtab[symtab_index];
+ symname      = strtab + sym->st_name;
+ /* binutils on ppc32 includes st_value in r_addend for relocations
+   against local symbols.  */
+ if (symtab_index && !(ELF32_ST_BIND (sym->st_info) == STB_LOCAL
+      && sym->st_shndx != SHN_UNDEF)) {
  symbol_addr = (unsigned long) _dl_find_hash(symname, scope, tpnt,
     elf_machine_type_class(reloc_type));
  /* We want to allow undefined references to weak symbols - this might
  * have been intentional.  We should not be linking local symbols
  * here, so all bases should be covered.
  */
- if (unlikely(!symbol_addr && ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK))
+ if (unlikely(!symbol_addr && ELF32_ST_BIND(sym->st_info) != STB_WEAK))
  return 1;
  }
 #if defined (__SUPPORT_LD_DEBUG__)
@@ -272,7 +276,7 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
  case R_PPC_ADDR16_HI:
  finaladdr >>= 16; /* fall through. */
  case R_PPC_ADDR16_LO:
- *(short *)reloc_addr = finaladdr;
+ *(Elf32_Half *)reloc_addr = finaladdr;
  break;
  case R_PPC_REL24:
 #if 0
--
1.5.6.3


_______________________________________________
uClibc mailing list
uClibc@...
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Re: "symbol '': can't resolve symbol"

by Stéphan Kochen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Joakim Tjernlund schreef:
> Good, however you should have made it to the REL24 reloc before
> crashing. Would you mind trying the below patch with the old
> dbus-daemon(built with -pie) to see if takes you to the
> REL24 reloc?

I had to fight with my build environment for a bit. But I'm glad to know
I can be of help in return. :)

Your patch appears to work as you intended. You can find the full
LD_DEBUG=all output at:
  http://stephan.kochen.nl/proj/wii-oe/dbus-daemon_ld_debug_2.txt

Regards,
- -- Stéphan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIj0uxcFUq0gzqDwQRAliSAKCtNRm7CNAWiWVBuT7LM2lG8ZLlFACgpFjW
uwHmHbp3cPVyW0WmY6fgZ5k=
=JzYX
-----END PGP SIGNATURE-----
_______________________________________________
uClibc mailing list
uClibc@...
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

RE: "symbol '': can't resolve symbol"

by Joakim Tjernlund-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> -----Original Message-----
> From: Stéphan Kochen [mailto:stephan@...]
> Sent: den 29 juli 2008 18:56
> To: joakim.tjernlund@...
> Cc: uclibc@...
> Subject: Re: "symbol '': can't resolve symbol"
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Joakim Tjernlund schreef:
> > Good, however you should have made it to the REL24 reloc before
> > crashing. Would you mind trying the below patch with the old
> > dbus-daemon(built with -pie) to see if takes you to the
> > REL24 reloc?
>
> I had to fight with my build environment for a bit. But I'm glad to know
> I can be of help in return. :)
>
> Your patch appears to work as you intended. You can find the full
> LD_DEBUG=all output at:
>   http://stephan.kochen.nl/proj/wii-oe/dbus-daemon_ld_debug_2.txt

OK, thanks. Now I have learnt something new :)

I do wonder though if we should make the R_PPC_ADDR16_XX unsupported too, like
R_PPC_REL24. I am pretty sure all of these relocs will only appear in
code is used in a shared library fashion but hasn't been compiled
with -fPIC/-fpic. There is no point to support R_PPC_ADDR16_XX but not
R_PPC_REL24.

Comments?

 Jocke, still recovering from a week in the sun with lots of beer :)

PS.
 I bet it would work if you changed the #if 0 to #if 1 surrounding the
 R_PPC_REL24 code.


_______________________________________________
uClibc mailing list
uClibc@...
http://busybox.net/cgi-bin/mailman/listinfo/uclibc
LightInTheBox - Buy quality products at wholesale price!