Subject: Re: getting ld to issue link-time warnings
To: None <lm@rmit.edu.au>
From: J.T. Conklin <jconklin@netcom.com>
List: current-users
Date: 07/12/1994 23:04:09
> A while ago there was a comment that ld should issue a warning when
> gets() is linked in instead of using a run-time warning. I think
> setreuid() is that category too.
> 
> How do I get ld to do this? 

You use inline assembly to insert a .stabs directive in the object file.
I've been playing with the feature by adding the following macro to
<sys/cdefs.h>:

	/* 
	 * The __warn_symbol macro is used to instruct the linker to print
	 * warning message "msg" if symbol "sym" is referenced.
	 */   
	#ifdef __STDC__
	#define __warn_symbol(sym,msg)  \
	__asm__(".stabs \"" msg "\",30,0,0,0\n.stabs \"_" #sym "\",1,0,0,0")
	#else 
	#define __warn_symbol(sym,msg)  \
	__asm__(".stabs msg,30,0,0,0\n.stabs \"_/**/sym\",1,0,0,0")
	#endif  

The link time warnings work fine as long as the object files aren't 
incrementaly linked as our library files are.  The "ld -r -x" in the 
standard make rules seems to strip out the stabs.  I haven't figured
out how to keep them perform the incremental link at the same time.

	--jtc

------------------------------------------------------------------------------