View Single Post
  #2   Spotlight this post!  
Unread 21-02-2013, 17:55
codes02 codes02 is offline
Randolph aka Roxbury aka R_______
AKA: Cody Schafer
no team (Formerly: Team 11, MORT)
 
Join Date: Oct 2007
Rookie Year: 2008
Location: MA, USA
Posts: 57
codes02 is on a distinguished road
Re: How to detect unresolved references at compile time?

Assuming a unix like shell
Code:
powerpc-wrs-vxworks-readelf -s FRC_UserProgram.out
will list all symbols in your program. The ones marked 'UND' are undefined.

A simple filter for them (not exact, you also only need worry about GLOBAL syms, not LOCAL ones).
Code:
powerpc-wrs-vxworks-readelf -s FRC_UserProgram.out | grep UND
A better one (that only prints symbol names):
Code:
powerpc-wrs-vxworks-readelf -s FRC_UserProgram.out \
| awk '{ if ($5 == "GLOBAL" && $7 == "UND") print $8 }'
Of course, vxworks provides some of those unresolved symbols, and what is useful to you is determining whether your program uses symbols that vxworks does not provide.

Potentially you could construct a list of symbols provided by vxworks (adding new ones that your code uses as needed), filter those out, and if any are left produce an error in your build scripts.

The following shows how to filter out known vxworks symbols (assuming you list them, 1 per line, in vxworks_syms.txt):
Code:
powerpc-wrs-vxworks-readelf -s FRC_UserProgram.out \
 | awk '{ if ($5 == "GLOBAL" && $7 == "UND") print $8 }' \
 | grep -vFf vxworks_syms.txt

Edit: also, sorry that this is not quite compile time . I can't help you there (though -Wmissing-prototypes helps)

Last edited by codes02 : 21-02-2013 at 17:58.
Reply With Quote