Index: /trunk/include/iprt/asmdefs.mac
===================================================================
--- /trunk/include/iprt/asmdefs.mac	(revision 58749)
+++ /trunk/include/iprt/asmdefs.mac	(revision 58750)
@@ -23,4 +23,9 @@
 ; terms and conditions of either the GPL or the CDDL or both.
 ;
+
+; Special hack for bs3kit.
+%ifdef RT_ASMDEFS_INC_FIRST_FILE
+ %include "asmdefs-first.mac"
+%endif
 
 %ifndef ___iprt_asmdefs_mac
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk	(revision 58749)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk	(revision 58750)
@@ -382,4 +382,5 @@
 	bs3-cmn-TestSendStrCmd.asm \
 	bs3-cmn-TestIsVmmDevTestingPresent.asm \
+       ../../../Runtime/common/asm/ASMBitFirstClear.asm
 
 # The BS3Kit library.
@@ -387,4 +388,5 @@
 bs3kit-common-16_TEMPLATE = VBoxBS3KitImg
 bs3kit-common-16_DEFS     = TMPL_PE16 BS3_CMN_ONLY
+bs3kit-common-16_ASDEFS   = RT_ASMDEFS_INC_FIRST_FILE
 bs3kit-common-16_SOURCES  = $(VBOX_BS3KIT_COMMON_SOURCES) \
 	bs3-system-data.asm
@@ -394,4 +396,5 @@
 bs3kit-common-32_TEMPLATE = VBoxBS3KitImg32
 bs3kit-common-32_DEFS     = TMPL_PE32 BS3_CMN_ONLY
+bs3kit-common-32_ASDEFS   = RT_ASMDEFS_INC_FIRST_FILE
 bs3kit-common-32_SOURCES  = $(VBOX_BS3KIT_COMMON_SOURCES)
 
@@ -400,4 +403,5 @@
 bs3kit-common-64-asm_TEMPLATE = VBoxBS3KitImg64
 bs3kit-common-64-asm_DEFS     = TMPL_LM64 BS3_CMN_ONLY
+bs3kit-common-64-asm_ASDEFS   = RT_ASMDEFS_INC_FIRST_FILE
 bs3kit-common-64-asm_SOURCES  = $(filter %.asm,$(VBOX_BS3KIT_COMMON_SOURCES))
 
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/asmdefs-first.mac
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/asmdefs-first.mac	(revision 58750)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/asmdefs-first.mac	(revision 58750)
@@ -0,0 +1,44 @@
+; $Id$
+;; @file
+; BS3Kit - Included by asmdefs.mac when assembling IPRT code.
+;
+; This will only be included if asmdefs.mac is included before bs3kit.mac, so
+; it will not be used for bs3*.asm files, only IPRT ones.
+;
+
+;
+; Copyright (C) 2006-2015 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; The contents of this file may alternatively be used under the terms
+; of the Common Development and Distribution License Version 1.0
+; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+; VirtualBox OSE distribution, in which case the provisions of the
+; CDDL are applicable instead of those of the GPL.
+;
+; You may elect to license modified versions of this file under the
+; terms and conditions of either the GPL or the CDDL or both.
+;
+
+
+%ifndef ___asmdefs_first_mac
+%define ___asmdefs_first_mac
+
+%include "bs3kit-template-header.mac"
+
+; Redefine some macros to suite us.
+%define BEGINCODE               TMPL_BEGIN_TEXT
+%define BEGINPROC_EXPORTED      BS3_PROC_BEGIN_CMN
+%define ENDPROC                 BS3_PROC_END_CMN
+%undef  NAME
+%define NAME(a)                 BS3_CMN_NM(a)
+
+%endif
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h	(revision 58749)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h	(revision 58750)
@@ -36,5 +36,16 @@
 # undef  IN_RING0
 #endif
+
+/*
+ * We may want to reuse some IPRT code in the common name space, so we
+ * redefine the RT_MANGLER to work like BS3_CMN_NM.  (We cannot use
+ * BS3_CMN_NM yet, as we need to include IPRT headers with function
+ * declarations before we can define it. Thus the duplciate effort.)
+ */
+#define RT_MANGLER(a_Name) RT_CONCAT3(a_Name,_c,ARCH_BITS)
+#include <iprt/mangling.h>
 #include <iprt/x86.h>
+
+
 
 RT_C_DECLS_BEGIN
@@ -335,4 +346,5 @@
 # define BS3_DATA_NM(a_Name)  a_Name
 #endif
+
 
 /**
@@ -387,4 +399,5 @@
 
 
+
 /** @defgroup grp_bs3kit_system System structures
  * @{ */
@@ -1181,4 +1194,5 @@
 RT_C_DECLS_END
 
-#endif
-
+
+#endif
+
Index: /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac
===================================================================
--- /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac	(revision 58749)
+++ /trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.mac	(revision 58750)
@@ -32,4 +32,7 @@
 ; If we don't do the latter we end up with an unused 'text' section.
 ;
+
+; Drop the asmdefs-first.mac header for native bs3kit files.
+%undef RT_ASMDEFS_INC_FIRST_FILE
 
 ;; Wrapper around BITS.
