0

All I am trying to do, extacting some symbols from an image and using (linking) symbols from different image.

With armccc/armlink, when specify --symdefs=, it creates file which includes symbols ad their addresses.
On the other hand, if you remove unused symbols, it just updates existing symbols. And if you include this file to compilation, it links previous image's symbols with new image.

But I cannot find similar approach for GNU toolchaing (arm-none-eabi-). if I use arm-none-eabi-nm, it creates symbol list like armcc --symdefs option but cannot find a way to use this symbol list with second image compliation. (Also there is no way to filter symbols without grep).

Other option seems also using arm-none-eabi-objcopy but could not find how to use it with second image compliation too.

In GNU toolchain, how can we do that? Any idea?

On the other hand, I want to apply that for Keil uVision IDE if possible. Thanks.

artless noise
  • 21,212
  • 6
  • 68
  • 105
muratcakmak
  • 325
  • 2
  • 14

1 Answers1

1

Not knowing much about armcc, it may be quite easy to emulate this behavior with standard GNU tools. E.g. to generate symdef file:

$ cat tmp.c
int foo() { return 0; }
int bar() { return 1; }
int main() { return 0; }
$ gcc tmp.c
$  readelf -sW a.out | grep GLOBAL | awk '{print $8 " " $2 }' | grep -v '^_' > symdef.lst

And then use it to define missing symbols for linker via --defsym flag:

$ LDFLAGS=$(cat symdef.lst |  awk '{print "-Wl,--defsym=" $1 "=" $2}' | tr '\n' ' ')
$ echo $LDFLAGS
-Wl,--defsym=bar=0000000000400481 -Wl,--defsym=foo=0000000000400476 -Wl,--defsym=main=000000000040048
yugr
  • 19,769
  • 3
  • 51
  • 96
  • 1
    Thanks yugr. I found a linker option for GCC. -Wl,--just-symbols= It seems it works but it uses huge elf file. I would prefer just shared object and their address like armcc. – muratcakmak Jan 02 '17 at 21:13