summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_linker.c
diff options
context:
space:
mode:
authorarr <arr@FreeBSD.org>2001-11-18 18:19:35 +0000
committerarr <arr@FreeBSD.org>2001-11-18 18:19:35 +0000
commit47cd77ddbdb2cc3dc758299fce4bc95699d63378 (patch)
tree7736597570471d49b80fcf81411fd2535fcdb9a2 /sys/kern/kern_linker.c
parentd2ab0884a69fac77b1a551e9e41c7d368e542987 (diff)
downloadFreeBSD-src-47cd77ddbdb2cc3dc758299fce4bc95699d63378.zip
FreeBSD-src-47cd77ddbdb2cc3dc758299fce4bc95699d63378.tar.gz
- Ensure that linker file id's are unique, rather than blindly
incrementing the value. Reviewed by: dfr, peter
Diffstat (limited to 'sys/kern/kern_linker.c')
-rw-r--r--sys/kern/kern_linker.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c
index ca032a9..bc969e4 100644
--- a/sys/kern/kern_linker.c
+++ b/sys/kern/kern_linker.c
@@ -70,6 +70,20 @@ static linker_class_list_t classes;
static linker_file_list_t linker_files;
static int next_file_id = 1;
+#define LINKER_GET_NEXT_FILE_ID(a) do { \
+ linker_file_t lftmp; \
+ \
+retry: \
+ TAILQ_FOREACH(lftmp, &linker_files, link) { \
+ if (next_file_id == lftmp->id) { \
+ next_file_id++; \
+ goto retry; \
+ } \
+ } \
+ (a) = next_file_id; \
+} while(0)
+
+
/* XXX wrong name; we're looking at version provision tags here, not modules */
typedef TAILQ_HEAD(, modlist) modlisthead_t;
struct modlist {
@@ -401,7 +415,7 @@ linker_make_file(const char* pathname, linker_class_t lc)
lf->userrefs = 0;
lf->flags = 0;
lf->filename = linker_strdup(filename);
- lf->id = next_file_id++;
+ LINKER_GET_NEXT_FILE_ID(lf->id);
lf->ndeps = 0;
lf->deps = NULL;
STAILQ_INIT(&lf->common);
OpenPOWER on IntegriCloud