My answer is specific to a combination of errors hidden symbol (...) is referenced by DSO and Nonrepresentable section on output .
Short answer: the symbol was marked extern , but also marked as hidden (see Visibility (GCC wiki) and How to write shared libraries (Ulrich Drepper) ). No objects or archives were linked to satisfy the dependencies, but a common object was associated with the corresponding symbol.
You probably compiled with -fvisibility=hidden and regardless of whether this function was an addition to the compiler (for example, a stack protector) or something else, the character published in your code redefined the visibility of the undefined link symbol of the same name in libc_nonshared.a , which is usually executed by libc.so
You can reproduce a similar problem as follows:
#include <stdio.h> extern __attribute__((visibility ("hidden"))) FILE* open_memstream( char**, size_t* ); char* asdf; size_t mysize; FILE* blah() { return open_memstream( &asdf, &mysize ); }
... then compile it:
# with gcc 4.9.2: ~ gcc badcode.c -shared -fPIC -o libbad.so -lc /tmp/ccC0uG80.o: In function `blah': badcode.c:(.text+0x19): undefined reference to `open_memstream' /usr/bin/ld: /tmp/libbad.so: hidden symbol `open_memstream' isn't defined /usr/bin/ld: final link failed: Bad value
In short: I already announced the existence of the symbol, marked it hidden, and then did not link in the static library or object file that satisfied the dependency. Since it is marked as hidden, the dependency must be satisfied, otherwise it is an invalid ELF object.
In my particular case, the header changed the wrong #if path and caused the above hidden open_memstream .
Brian vandenberg
source share