This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] Add support for link-time warning on DLL usage
- From: Thorsten Glaser <x86 at ePost dot de>
- To: binutils at sources dot redhat dot com
- Date: Sat, 10 Apr 2004 01:38:41 +0000 (UTC)
- Subject: [PATCH] Add support for link-time warning on DLL usage
Hello all,
the patch below adds support for emitting a link-time warning each
time a DLL is used.
We can already offer link-time warnings for used symbols (OpenBSD
uses this for strcpy() for example; this is performed by adding
a .gnu.warning.strcpy section into the source), and object-generation
time warnings (section .gnu.warning).
What we can't do yet is to warn each time a shared library is
referenced (the user could be warned about licence problems,
for example, or security problems); my approach would have been
to add .gnu.warning.main since there is no C programme without
a main() function (please send me a hint if it could do better
by different means).
The code checks if the symbol is contained within the shared
library though, that's why I came up with the idea to somehow
escape this check.
With the patch below, add a section .gnu.warning.*main to the
source, and ld(1) will warn you each time you link an executable
with the library (even when it's just a hello world programme,
not using any of the library's functions).
PS: at lines 625 and 1994, there are trailing blanks at the
end of line; I don't think that's supposed to be good style.
PPS: the diff is against binutils 2.14
Index: elflink.h
===================================================================
RCS file: /cvs/src/gnu/usr.bin/binutils/bfd/elflink.h,v
retrieving revision 1.1.2.2
retrieving revision 1.4
diff -d -u -r1.1.2.2 -r1.4
--- elflink.h 23 Sep 2003 16:04:05 -0000 1.1.2.2
+++ elflink.h 8 Apr 2004 23:50:17 -0000 1.4
@@ -1357,6 +1357,14 @@
name += sizeof ".gnu.warning." - 1;
+ /* If the symbol starts with an asterisk, skip it and
+ always warn on it. */
+ if (*name == '*')
+ {
+ ++name;
+ }
+ else /* fall through */
+
/* If this is a shared object, then look up the symbol
in the hash table. If it is there, and it is already
been defined, then we will not be using the entry
bye,
//Thorsten
--
Solange man keine schmutzigen Tricks macht, und ich meine *wirklich*
schmutzige Tricks, wie bei einer doppelt verketteten Liste beide
Pointer XORen und in nur einem Word speichern, funktioniert Boehm ganz
hervorragend. -- Andreas Bogk über boehm-gc in d.a.s.r