bug 826481 - mark PrepareAndDispatch() as __attribute__((used)) when building with gcc or clang r=froydnj
☠☠ backed out by 66f9f6671c10 ☠ ☠
authorTrevor Saunders <trev.saunders@gmail.com>
Fri, 17 Jan 2014 16:17:20 -0500
changeset 169803 f59bb340e3e67bbbd74e2a1332a27a819986fa1f
parent 169802 bcc5a1ceef1d3e9273704143766aad03c0b2bf9a
child 169804 e43584cd2994f4522adba5b06dd63462554ad9ed
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersfroydnj
bugs826481
milestone30.0a1
bug 826481 - mark PrepareAndDispatch() as __attribute__((used)) when building with gcc or clang r=froydnj
xpcom/reflect/xptcall/src/md/unix/xptc_gcc_x86_unix.h
xpcom/reflect/xptcall/src/md/unix/xptcstubs_alpha_openbsd.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_amd64_openbsd.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_arm.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_arm_netbsd.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_arm_openbsd.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_ipf32.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_ipf64.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_linux_alpha.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_linux_m68k.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_linux_s390.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_linux_s390x.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_mips.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_mips64.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_netbsd_m68k.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_pa32.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc64_linux.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_aix.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_aix64.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_linux.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_netbsd.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_openbsd.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_rhapsody.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_sparc64_openbsd.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_sparc_netbsd.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_sparc_openbsd.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_sparc_solaris.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_sparcv9_solaris.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_darwin.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_solaris.cpp
xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_solaris.cpp
xpcom/reflect/xptcall/src/md/win32/xptcstubs_x86_64_gnu.cpp
xpcom/reflect/xptcall/src/xptcprivate.h
--- a/xpcom/reflect/xptcall/src/md/unix/xptc_gcc_x86_unix.h
+++ b/xpcom/reflect/xptcall/src/md/unix/xptc_gcc_x86_unix.h
@@ -10,10 +10,8 @@
 //
 
 #ifdef MOZ_NEED_LEADING_UNDERSCORE
 #define SYMBOL_UNDERSCORE "_"
 #else
 #define SYMBOL_UNDERSCORE
 #endif
 
-
-#define ATTRIBUTE_USED __attribute__ ((__used__))
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_alpha_openbsd.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_alpha_openbsd.cpp
@@ -6,17 +6,17 @@
 /* Implement shared vtbl methods. */
 
 #include "xptcprivate.h"
 #include "xptiprivate.h"
 
 /* Prototype specifies unmangled function name and disables unused warning */
 static nsresult
 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args)
-__asm__("PrepareAndDispatch") __attribute__((used));
+__asm__("PrepareAndDispatch") ATTRIBUTE_USED;
 
 static nsresult
 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args)
 {
     const uint8_t PARAM_BUFFER_COUNT = 16;
     const uint8_t NUM_ARG_REGS = 6-1;        // -1 for "this" pointer
 
     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_amd64_openbsd.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_amd64_openbsd.cpp
@@ -23,17 +23,17 @@ const uint32_t FPR_COUNT            = 8;
 //
 // - 'args[]' contains the arguments passed on stack
 // - 'gpregs[]' contains the arguments passed in integer registers
 // - 'fpregs[]' contains the arguments passed in floating point registers
 // 
 // The parameters are mapped into an array of type 'nsXPTCMiniVariant'
 // and then the method gets called.
 
-extern "C" nsresult
+extern "C" nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase * self, uint32_t methodIndex,
                    uint64_t * args, uint64_t * gpregs, double *fpregs)
 {
     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
     nsXPTCMiniVariant* dispatchParams = nullptr;
     const nsXPTMethodInfo* info;
     uint32_t paramCount;
     uint32_t i;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_arm.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_arm.cpp
@@ -7,31 +7,19 @@
 
 #include "xptcprivate.h"
 #include "xptiprivate.h"
 
 #if !defined(__arm__) && !(defined(LINUX) || defined(ANDROID))
 #error "This code is for Linux ARM only. Please check if it works for you, too.\nDepends strongly on gcc behaviour."
 #endif
 
-#ifdef __GNUC__
-/* This tells gcc3.4+ not to optimize away symbols.
- * @see http://gcc.gnu.org/gcc-3.4/changes.html
- */
-#define DONT_DROP_OR_WARN __attribute__((used))
-#else
-/* This tells older gccs not to warn about unused vairables.
- * @see http://docs.freebsd.org/info/gcc/gcc.info.Variable_Attributes.html
- */
-#define DONT_DROP_OR_WARN __attribute__((unused))
-#endif
-
 /* Specify explicitly a symbol for this function, don't try to guess the c++ mangled symbol.  */
 static nsresult PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args) asm("_PrepareAndDispatch")
-DONT_DROP_OR_WARN;
+ATTRIBUTE_USED;
 
 #ifdef __ARM_EABI__
 #define DOUBLEWORD_ALIGN(p) ((uint32_t *)((((uint32_t)(p)) + 7) & 0xfffffff8))
 #else
 #define DOUBLEWORD_ALIGN(p) (p)
 #endif
 
 // Apple's iOS toolchain is lame and does not support .cfi directives.
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_arm_netbsd.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_arm_netbsd.cpp
@@ -2,17 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* Implement shared vtbl methods. */
 
 #include "xptcprivate.h"
 
-nsresult
+nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
 {
 #define PARAM_BUFFER_COUNT     16
 
     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
     nsXPTCMiniVariant* dispatchParams = nullptr;
     nsIInterfaceInfo* iface_info = nullptr;
     const nsXPTMethodInfo* info;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_arm_openbsd.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_arm_openbsd.cpp
@@ -19,17 +19,17 @@
  */
 #define DONT_DROP_OR_WARN __attribute__((unused))
 #endif
 
 /* Specify explicitly a symbol for this function, don't try to guess the c++ mangled symbol.  */
 static nsresult PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args) asm("_PrepareAndDispatch")
 DONT_DROP_OR_WARN;
 
-static nsresult
+static nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
 {
 #define PARAM_BUFFER_COUNT     16
 
     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
     nsXPTCMiniVariant* dispatchParams = nullptr;
     const nsXPTMethodInfo* info;
     uint8_t paramCount;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ipf32.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ipf32.cpp
@@ -11,17 +11,17 @@
 
 #include <stddef.h>
 #include <stdlib.h>
 
 // "This code is for IA64 only"
 
 /* Implement shared vtbl methods. */
 
-extern "C" nsresult
+extern "C" nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex,
   uint64_t* intargs, uint64_t* floatargs, uint64_t* restargs)
 {
 
 #define PARAM_BUFFER_COUNT     16
 
   nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
   nsXPTCMiniVariant* dispatchParams = nullptr;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ipf64.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ipf64.cpp
@@ -12,17 +12,17 @@
 #include <stddef.h>
 #include <stdlib.h>
 #include <stdint.h>
 
 // "This code is for IA64 only"
 
 /* Implement shared vtbl methods. */
 
-extern "C" nsresult
+extern "C" nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex,
   uint64_t* intargs, uint64_t* floatargs, uint64_t* restargs)
 {
 
 #define PARAM_BUFFER_COUNT     16
 
   nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
   nsXPTCMiniVariant* dispatchParams = nullptr;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_linux_alpha.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_linux_alpha.cpp
@@ -6,17 +6,17 @@
 /* Implement shared vtbl methods. */
 
 #include "xptcprivate.h"
 #include "xptiprivate.h"
 
 /* Prototype specifies unmangled function name and disables unused warning */
 static nsresult
 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args)
-__asm__("PrepareAndDispatch") __attribute__((used));
+__asm__("PrepareAndDispatch") ATTRIBUTE_USED;
 
 static nsresult
 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args)
 {
     const uint8_t PARAM_BUFFER_COUNT = 16;
     const uint8_t NUM_ARG_REGS = 6-1;        // -1 for "this" pointer
 
     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_linux_m68k.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_linux_m68k.cpp
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* Implement shared vtbl methods. */
 
 #include "xptcprivate.h"
 #include "xptiprivate.h"
 
 extern "C" {
-    nsresult
+    nsresult ATTRIBUTE_USED
     PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
     {
 #define PARAM_BUFFER_COUNT     16
 
         nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
         nsXPTCMiniVariant* dispatchParams = nullptr;
         const nsXPTMethodInfo* info;
         uint8_t paramCount;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_linux_s390.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_linux_s390.cpp
@@ -4,17 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* Implement shared vtbl methods. */
 
 #include "xptcprivate.h"
 #include "xptiprivate.h"
 
-static nsresult
+static nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, 
                    uint32_t* a_gpr, uint64_t *a_fpr, uint32_t *a_ov)
 {
 #define PARAM_BUFFER_COUNT     16
 
     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
     nsXPTCMiniVariant* dispatchParams = nullptr;
     const nsXPTMethodInfo* info;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_linux_s390x.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_linux_s390x.cpp
@@ -4,17 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* Implement shared vtbl methods. */
 
 #include "xptcprivate.h"
 #include "xptiprivate.h"
 
-static nsresult
+static nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, 
                    uint64_t* a_gpr, uint64_t *a_fpr, uint64_t *a_ov)
 {
 #define PARAM_BUFFER_COUNT     16
 
     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
     nsXPTCMiniVariant* dispatchParams = nullptr;
     const nsXPTMethodInfo* info;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_mips.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_mips.cpp
@@ -10,17 +10,17 @@
 
 #include <stdint.h>
 
 /*
  * This is for MIPS O32 ABI
  * Args contains a0-3 and then the stack.
  * Because a0 is 'this', we want to skip it
  */
-extern "C" nsresult
+extern "C" nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
 {
     args++; // always skip over a0
 
 #define PARAM_BUFFER_COUNT		16
 
     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
     nsXPTCMiniVariant* dispatchParams = nullptr;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_mips64.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_mips64.cpp
@@ -15,17 +15,17 @@
  *
  * When we're called, the "gp" registers are stored in gprData and
  * the "fp" registers are stored in fprData.  There are 8 regs
  * available which correspond to the first 7 parameters of the
  * function and the "this" pointer.  If there are additional parms,
  * they are stored on the stack at address "args".
  *
  */
-extern "C" nsresult
+extern "C" nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args,
                    uint64_t *gprData, double *fprData)
 {
 #define PARAM_BUFFER_COUNT        16
 #define PARAM_GPR_COUNT            7
 #define PARAM_FPR_COUNT            7
 
     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_netbsd_m68k.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_netbsd_m68k.cpp
@@ -7,17 +7,17 @@
 
 #include "xptcprivate.h"
 
 #if !defined(__NetBSD__) || !defined(__m68k__)
 #error This code is for NetBSD/m68k only
 #endif
 
 extern "C" {
-    static nsresult
+    static nsresult ATTRIBUTE_USED
     PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
     {
 #define PARAM_BUFFER_COUNT     16
 
         nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
         nsXPTCMiniVariant* dispatchParams = nullptr;
         nsIInterfaceInfo* iface_info = nullptr;
         const nsXPTMethodInfo* info;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_pa32.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_pa32.cpp
@@ -9,17 +9,17 @@
 
 #include "xptcprivate.h"
 #include "xptiprivate.h" 
 
 #if _HPUX
 #error "This code is for HP-PA RISC 32 bit mode only"
 #endif
 
-extern "C" nsresult
+extern "C" nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex,
   uint32_t* args, uint32_t* floatargs)
 {
 
   typedef struct {
     uint32_t hi;
     uint32_t lo;
   } DU;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc64_linux.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc64_linux.cpp
@@ -27,17 +27,17 @@
 //
 // - 'args[]' contains the arguments passed on stack
 // - 'gprData[]' contains the arguments passed in integer registers
 // - 'fprData[]' contains the arguments passed in floating point registers
 // 
 // The parameters are mapped into an array of type 'nsXPTCMiniVariant'
 // and then the method gets called.
 #include <stdio.h>
-extern "C" nsresult
+extern "C" nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase* self,
                    uint64_t methodIndex,
                    uint64_t* args,
                    uint64_t *gprData,
                    double *fprData)
 {
     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
     nsXPTCMiniVariant* dispatchParams = nullptr;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_aix.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_aix.cpp
@@ -11,17 +11,17 @@
 #if defined(AIX)
 
 /*
         For PPC (AIX & MAC), the first 8 integral and the first 13 f.p. parameters 
         arrive in a separate chunk of data that has been loaded from the registers. 
         The args pointer has been set to the start of the parameters BEYOND the ones
         arriving in registers
 */
-extern "C" nsresult
+extern "C" nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args, uint32_t *gprData, double *fprData)
 {
     typedef struct {
         uint32_t hi;
         uint32_t lo;      // have to move 64 bit entities as 32 bit halves since
     } DU;               // stack slots are not guaranteed 16 byte aligned
 
 #define PARAM_BUFFER_COUNT     16
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_aix64.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_aix64.cpp
@@ -10,17 +10,17 @@
 #if defined(AIX)
 
 /*
         For PPC (AIX & MAC), the first 8 integral and the first 13 f.p. parameters 
         arrive in a separate chunk of data that has been loaded from the registers. 
         The args pointer has been set to the start of the parameters BEYOND the ones
         arriving in registers
 */
-extern "C" nsresult
+extern "C" nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase* self, uint64_t methodIndex, uint64_t* args, uint64_t *gprData, double *fprData)
 {
 
 #define PARAM_BUFFER_COUNT     16
 #define PARAM_GPR_COUNT         7  
 
     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
     nsXPTCMiniVariant* dispatchParams = nullptr;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_linux.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_linux.cpp
@@ -26,17 +26,17 @@
 //
 // - 'args[]' contains the arguments passed on stack
 // - 'gprData[]' contains the arguments passed in integer registers
 // - 'fprData[]' contains the arguments passed in floating point registers
 // 
 // The parameters are mapped into an array of type 'nsXPTCMiniVariant'
 // and then the method gets called.
 
-extern "C" nsresult
+extern "C" nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase* self,
                    uint32_t methodIndex,
                    uint32_t* args,
                    uint32_t *gprData,
                    double *fprData)
 {
     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
     nsXPTCMiniVariant* dispatchParams = nullptr;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_netbsd.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_netbsd.cpp
@@ -22,17 +22,17 @@
 //
 // - 'args[]' contains the arguments passed on stack
 // - 'gprData[]' contains the arguments passed in integer registers
 // - 'fprData[]' contains the arguments passed in floating point registers
 // 
 // The parameters are mapped into an array of type 'nsXPTCMiniVariant'
 // and then the method gets called.
 
-extern "C" nsresult
+extern "C" nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase* self,
                    uint32_t methodIndex,
                    uint32_t* args,
                    uint32_t *gprData,
                    double *fprData)
 {
     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
     nsXPTCMiniVariant* dispatchParams = nullptr;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_openbsd.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_openbsd.cpp
@@ -23,17 +23,17 @@
 //
 // - 'args[]' contains the arguments passed on stack
 // - 'gprData[]' contains the arguments passed in integer registers
 // - 'fprData[]' contains the arguments passed in floating point registers
 // 
 // The parameters are mapped into an array of type 'nsXPTCMiniVariant'
 // and then the method gets called.
 
-extern "C" nsresult
+extern "C" nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase* self,
                    uint32_t methodIndex,
                    uint32_t* args,
                    uint32_t *gprData,
                    double *fprData)
 {
     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
     nsXPTCMiniVariant* dispatchParams = nullptr;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_rhapsody.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_rhapsody.cpp
@@ -30,17 +30,17 @@
  * stack without any special padding.
  *
  * See also xptcstubs_asm_ppc_darwin.s.m4:_SharedStub.
  *
  * ABI reference:
  * http://developer.apple.com/documentation/DeveloperTools/Conceptual/
  *  MachORuntime/PowerPCConventions/chapter_3_section_1.html */
 
-extern "C" nsresult
+extern "C" nsresult ATTRIBUTE_USED
 PrepareAndDispatch(
   nsXPTCStubBase *self,
   uint32_t        methodIndex,
   uint32_t       *argsStack,
   uint32_t       *argsGPR,
   double         *argsFPR) {
 #define PARAM_BUFFER_COUNT 16
 #define PARAM_FPR_COUNT    13
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_sparc64_openbsd.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_sparc64_openbsd.cpp
@@ -6,17 +6,17 @@
 
 /* Implement shared vtbl methods. */
 
 #include "xptcprivate.h"
 #include "xptiprivate.h"
 
 #if defined(sparc) || defined(__sparc__)
 
-extern "C" nsresult
+extern "C" nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase* self, uint64_t methodIndex, uint64_t* args)
 {
 
 #define PARAM_BUFFER_COUNT     16
 
     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
     nsXPTCMiniVariant* dispatchParams = nullptr;
     const nsXPTMethodInfo* info;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_sparc_netbsd.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_sparc_netbsd.cpp
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* Implement shared vtbl methods. */
 
 #include "xptcprivate.h"
 
 #if defined(sparc) || defined(__sparc__)
 
-extern "C" nsresult
+extern "C" nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
 {
 
     typedef struct {
         uint32_t hi;
         uint32_t lo;
     } DU;               // have to move 64 bit entities as 32 bit halves since
                         // stack slots are not guaranteed 16 byte aligned
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_sparc_openbsd.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_sparc_openbsd.cpp
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* Implement shared vtbl methods. */
 
 #include "xptcprivate.h"
 
 #if defined(sparc) || defined(__sparc__)
 
-extern "C" nsresult
+extern "C" nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
 {
 
     typedef struct {
         uint32_t hi;
         uint32_t lo;
     } DU;               // have to move 64 bit entities as 32 bit halves since
                         // stack slots are not guaranteed 16 byte aligned
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_sparc_solaris.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_sparc_solaris.cpp
@@ -5,17 +5,17 @@
 
 /* Implement shared vtbl methods. */
 
 #include "xptcprivate.h"
 #include "xptiprivate.h"
 
 #if defined(sparc) || defined(__sparc__)
 
-extern "C" nsresult
+extern "C" nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
 {
 
     typedef struct {
         uint32_t hi;
         uint32_t lo;
     } DU;               // have to move 64 bit entities as 32 bit halves since
                         // stack slots are not guaranteed 16 byte aligned
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_sparcv9_solaris.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_sparcv9_solaris.cpp
@@ -6,17 +6,17 @@
 
 /* Implement shared vtbl methods. */
 
 #include "xptcprivate.h"
 #include "xptiprivate.h"
 
 #if defined(sparc) || defined(__sparc__)
 
-extern "C" nsresult
+extern "C" nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase* self, uint64_t methodIndex, uint64_t* args)
 {
 
 #define PARAM_BUFFER_COUNT     16
 
     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
     nsXPTCMiniVariant* dispatchParams = nullptr;
     const nsXPTMethodInfo* info;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_darwin.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_darwin.cpp
@@ -25,17 +25,17 @@ const uint32_t FPR_COUNT            = 8;
 //
 // - 'args[]' contains the arguments passed on stack
 // - 'gpregs[]' contains the arguments passed in integer registers
 // - 'fpregs[]' contains the arguments passed in floating point registers
 // 
 // The parameters are mapped into an array of type 'nsXPTCMiniVariant'
 // and then the method gets called.
 
-extern "C" nsresult
+extern "C" nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase * self, uint32_t methodIndex,
                    uint64_t * args, uint64_t * gpregs, double *fpregs)
 {
     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
     nsXPTCMiniVariant* dispatchParams = nullptr;
     const nsXPTMethodInfo* info;
     uint32_t paramCount;
     uint32_t i;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp
@@ -25,17 +25,17 @@ const uint32_t FPR_COUNT            = 8;
 //
 // - 'args[]' contains the arguments passed on stack
 // - 'gpregs[]' contains the arguments passed in integer registers
 // - 'fpregs[]' contains the arguments passed in floating point registers
 // 
 // The parameters are mapped into an array of type 'nsXPTCMiniVariant'
 // and then the method gets called.
 
-extern "C" nsresult
+extern "C" nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase * self, uint32_t methodIndex,
                    uint64_t * args, uint64_t * gpregs, double *fpregs)
 {
     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
     nsXPTCMiniVariant* dispatchParams = nullptr;
     const nsXPTMethodInfo* info;
     uint32_t paramCount;
     uint32_t i;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_solaris.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_solaris.cpp
@@ -25,17 +25,17 @@ const uint32_t FPR_COUNT            = 8;
 //
 // - 'args[]' contains the arguments passed on stack
 // - 'gpregs[]' contains the arguments passed in integer registers
 // - 'fpregs[]' contains the arguments passed in floating point registers
 // 
 // The parameters are mapped into an array of type 'nsXPTCMiniVariant'
 // and then the method gets called.
 
-extern "C" nsresult
+extern "C" nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase * self, uint32_t methodIndex,
                    uint64_t * args, uint64_t * gpregs, double *fpregs)
 {
     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
     nsXPTCMiniVariant* dispatchParams = nullptr;
     const nsXPTMethodInfo* info;
     uint32_t paramCount;
     uint32_t i;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_solaris.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_solaris.cpp
@@ -4,17 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* Implement shared vtbl methods. */
 
 #include "xptcprivate.h"
 #include "xptiprivate.h"
 
-nsresult
+nsresult ATTRIBUTE_USED
 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
 {
 #define PARAM_BUFFER_COUNT     16
 
     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
     nsXPTCMiniVariant* dispatchParams = nullptr;
     const nsXPTMethodInfo* info;
     uint8_t paramCount;
--- a/xpcom/reflect/xptcall/src/md/win32/xptcstubs_x86_64_gnu.cpp
+++ b/xpcom/reflect/xptcall/src/md/win32/xptcstubs_x86_64_gnu.cpp
@@ -11,17 +11,17 @@
  * This is for Windows 64 bit (x86_64) using GCC syntax
  * Code was copied from the MSVC version.
  */
 
 #if !defined(_AMD64_) || !defined(__GNUC__)
 #  error xptcstubs_x86_64_gnu.cpp being used unexpectedly
 #endif
 
-extern "C" nsresult
+extern "C" nsresult __attribute__((__used__))
 PrepareAndDispatch(nsXPTCStubBase * self, uint32_t methodIndex,
                    uint64_t * args, uint64_t * gprData, double *fprData)
 {
 #define PARAM_BUFFER_COUNT  16
 //
 // "this" pointer is first parameter, so parameter count is 3.
 //
 #define PARAM_GPR_COUNT   3
--- a/xpcom/reflect/xptcall/src/xptcprivate.h
+++ b/xpcom/reflect/xptcall/src/xptcprivate.h
@@ -53,9 +53,15 @@ public:
     xptiInterfaceEntry*    mEntry;
 
     ~nsXPTCStubBase() { }
 };
 
 #undef STUB_ENTRY
 #undef SENTINEL_ENTRY
 
+#if defined(__clang__) || defined(__GNUCC__)
+#define ATTRIBUTE_USED __attribute__ ((__used__))
+#else
+#define ATTRIBUTE_USED
+#endif
+
 #endif /* xptcprivate_h___ */