Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>So the solution we have for now is as follows:</p> <p>test.cpp</p> <pre><code>#include &lt;cmath&gt; #include &lt;vector&gt; #include &lt;typeinfo&gt; struct private_struct { float f; }; float private_function(float f) { return std::abs(f); } void other_private_function() { std::vector&lt;private_struct&gt; f(1); } extern "C" void __attribute__ ((visibility ("default"))) public_function2() { other_private_function(); } extern "C" float __attribute__ ((visibility ("default"))) public_function1(float f) { return private_function(f); } </code></pre> <p>exports.version</p> <pre><code>LIBTEST { global: public*; local: *; }; </code></pre> <p>compiled with</p> <pre><code>g++ -shared test.cpp -o libtest.so -fvisibility=hidden -fvisibility-inlines-hidden -s -Wl,--version-script=exports.version </code></pre> <p>gives </p> <pre><code>00000000 A LIBTEST w _Jv_RegisterClasses U _Unwind_Resume U std::__throw_bad_alloc() U operator delete(void*) U operator new(unsigned int) w __cxa_finalize w __gmon_start__ U __gxx_personality_v0 000005db T public_function1 00000676 T public_function2 </code></pre> <p>Which is fairly close to what we're looking for. There are a few gotchas though:</p> <ul> <li>We have to ensure we don't use the "exported" prefix (in this simple example "public", but obviously something more useful in our case) in the internal code.</li> <li>Many symbol names still end up in the string table, which appears to be down to RTTI, -fno-rtti makes them go away in my simple tests, but is a rather nuclear solution.</li> </ul> <p>I'm happy to accept any better solutions anyone comes up with!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload