1

I compiled my one of the Contiki application (power-cons.c: which evaluate the power consumption of TelosB mote) as a Contiki executable (power-cons.ce). The Contiki executable is then uploaded to the Sky platform via serial and is stored in the file system Then the executable is loaded via the shell command "exec".

But when running the command exec the following error is displayed...

Symbol not found __udivsi3

How can I resolve this symbol?

Beryllium
  • 12,808
  • 10
  • 56
  • 86
siju koshy
  • 21
  • 3
  • Why are you using dynamic linking? – CL. Mar 09 '15 at 07:55
  • Quite similar problem with [this one](http://stackoverflow.com/questions/26240516/contiki-error-if-elf-file-contains-calculation-with-several-unsinged-int/27908999#27908999). Check if the answer there helps. – finmor Mar 09 '15 at 17:58
  • @CL when I dynamically link (elf loader) the .ce module without using "exec" command, the same error symbol not found is displayed – siju koshy Apr 10 '15 at 05:30

2 Answers2

2

The problem is, that all functions used by your .ce must already be on your Sky node (I'll call it base-system). All symbols provided by your base-system can be listed by running nm base-system.sky. Symbols needed by your .ce are the ones marked with U when running nm power-cons.ce. To solve your problem you have the following options:

  • Do not use __udivsi3 is your .ce. It used for dividing two unsigned int (manual). You can for example use a signed int.
  • Use __udivsi3 in your base-system.
  • Add
    void__udivsi3(void); void (*additional_symbol1)(void) = &void__udivsi3;
    to one of your files. This will cost you two bytes though.
  • Use the solution presented in this answer as suggested by @finmor
  • Tell the linker to include the function to your base-system. This is a bit tricky as a wasn't able to find a convenient way to do so. I did some experiments and it is not as simple as I hoped.
  • You can add __udivsi3 to your .ce. I'm not sure about the best or easiest way of doing this. Probably you want to extract the .o containing __udivsi3 from the .a. This needs some searching. For __udivsi3 this comes with the gcc (not the libc). Then you can merge it with your power-cons.ce using ld -r (starting point). There are other ways of ding this, too, but I'd have to do some research, as I'm currently not actively working on this topic.
Morty
  • 2,889
  • 2
  • 19
  • 28
0

You probably need to link with libm.

Try adding -lm to your linker command line. Also make sure libm is available on your target.