exception: ensure base exception vtable is non-hidden

I found that when building this library under Yocto, `-flto=auto` is
used by default and the vtable for the exception class ends up becoming
hidden (since there are no non-pure/non-inline functions).  I've tried
using `__attribute__((visibility("default")))` with no luck.  The only
thing which seems to work is defining some non-inline function to force
the vtable to be emitted.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Iaac957591be38d38d021503e15e16f0c982808a9
diff --git a/include/sdbusplus/exception.hpp b/include/sdbusplus/exception.hpp
index 2977d4d..b02e993 100644
--- a/include/sdbusplus/exception.hpp
+++ b/include/sdbusplus/exception.hpp
@@ -20,6 +20,13 @@
     virtual const char* name() const noexcept = 0;
     virtual const char* description() const noexcept = 0;
     virtual int get_errno() const noexcept = 0;
+
+  private:
+    // This unused function is to ensure that the vtable for this class is
+    // properly emitted when `-flto=auto` is used, which is the default in
+    // Yocto builds.  Without this, the vtable is a hidden symbol and no
+    // users can inherit from our exception type directly.
+    virtual void unused() const noexcept;
 };
 
 /** base exception class for all errors created by the sdbus++ generator */
diff --git a/src/exception.cpp b/src/exception.cpp
index df0baa5..f44cdaa 100644
--- a/src/exception.cpp
+++ b/src/exception.cpp
@@ -14,6 +14,9 @@
 namespace exception
 {
 
+void exception::unused() const noexcept
+{}
+
 int generated_exception::get_errno() const noexcept
 {
     return EIO;