0

I want to add functions to the default vxworks Ball DKM project. I've copied the style I see for all the functions that I am able to call from a given header file and declared my own in master/vxworks-6.9/target/h/wrn/coreip/netBufLib.h:

EXTERN void hello(void); //also tried EXTERN void hello();

I then added the body in the only corresponding source file with the same name (master/components/ip_net2-6.9/vxmux/src/mem/netBufLib.c)

void hello() { 
    printf("hello, world from netbuflib.c!"); 
}

At project build time I get the warning:

On downloading module '/ball/SIMLINUXdiab/ball/Debug/ball.out' on target vxsim2_0, the module symbols could not be fully resolved
Unresolved symbols list: hello
Do you want to continue launch and ignore...

If I proceed, naturally a seg violation occurs when I call hello().

Is there a linking step or something I have to do besides clean the project and rebuild it because of Eclipse/VXWorks? Or is it maybe related to using SIMLINUX or a target vxsim simulator? Finally I suppose it could be that the source file is not the correct corresponding source code, even though it is the only same named one in this directory (VXWorks repo could only come with compiled assembly)?

zx485
  • 28,498
  • 28
  • 50
  • 59
  • 1
    How did you "add" the source file? Where did you add it? – Some programmer dude Aug 20 '20 at 23:41
  • I didn't add it as an import to the project--I used find file command @ the project level for netBufLib.c and the only result was at the path given. It has all the same functions so I figured the EXTERN's must be pointing there. I figure a linker or Makefile was responsible for the #include – Frankie Guzikowski Aug 21 '20 at 01:09
  • *or that the #include netBufLib.h did the work. – Frankie Guzikowski Aug 21 '20 at 01:15
  • 1
    The linker doesn't search for source files. You must, one way or another, list the source file in the project configuration. – Some programmer dude Aug 21 '20 at 01:16
  • But if the previous function calls from that header work that means the source file must already be listed, right? (P.S. opening the declaration of netBufLib.h from the source file I listed also bring me to the correct .h) – Frankie Guzikowski Aug 21 '20 at 01:17
  • 1
    The header file only contains the *declaration*, telling the compiler that the function *may* exist in another [translation unit](https://en.m.wikipedia.org/wiki/Translation_unit_(programming)). The source file isn't used at all by the `#include` directive where you include the header file. You need to see each source file as a separate entity, totally unknown to any other source file. – Some programmer dude Aug 21 '20 at 01:23
  • Great info, thanks! This does seem most relevant for adding a new source file--not for a per function basis. I'm simply adding one function to a configuration that already works (any calls of the other existing ones works and if I can step through the debug out file made) so does my function have to be explicitly added somewhere in the translation unit too? – Frankie Guzikowski Aug 21 '20 at 03:24

1 Answers1

1

Since you are trying to define the function hello() in DKM you should add the definition in some source file related to the DKM project(not in the core libraries) and add the declaration in the source file where you are calling hello then rebuild and run it.

Or, if you want to add the function in core libraries(as you have done) you have to rebuild the library and add the declaration of the function in the file where you are calling the hello.

  • Thanks! I added it into master/components/ip_net2-6.9/vxmux/src/mem/netBufLib.c then made a VSB to rebuild the source code. From there I made a VIP based off this VSB and added my DKM as a referenced project. Still doesn't recognize the symbol though...As this is the only C file in the repo I see corresponding to the netBufLib it must be the right location right? – Frankie Guzikowski Aug 25 '20 at 16:13
  • After reading this post https://stackoverflow.com/questions/45456403/linking-dkm-projects-to-kernel-imagevip-project-as-a-sub-project-extra-module it seems maybe I must execute the VIP. Any ideas on how to do this--I don't see any guidance in the WR guides on what to do after building (I usually run the DKM as a kernel task on a simulator target, but obviously you cannot run a VIP as such). – Frankie Guzikowski Aug 25 '20 at 16:47