相关文章推荐
冷冷的单杠  ·  SSL/TLS 安全测试 - ...·  8 月前    · 
英姿勃勃的地瓜  ·  mongodb ...·  8 月前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I get this error at the linker stage when compiling the webkit-1.1.5 package on my Ubuntu 9.04 box:

libtool: link: gcc -ansi -fno-strict-aliasing -O2 -Wall -W -Wcast-align -Wchar-subscripts -Wreturn-type -Wformat -Wformat-security -Wno-format-y2k -Wundef -Wmissing-format-attribute -Wpointer-arith -Wwrite-strings -Wno-unused-parameter -Wno-parentheses -fno-exceptions -fvisibility=hidden -D_REENTRANT -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libsoup-2.4 -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -g -O2 -O2 -o Programs/.libs/GtkLauncher WebKitTools/GtkLauncher/Programs_GtkLauncher-main.o -pthread  ./.libs/libwebkit-1.0.so /usr/lib/libgtk-x11-2.0.so /usr/lib/libgdk-x11-2.0.so /usr/lib/libatk-1.0.so /usr/lib/libpangoft2-1.0.so /usr/lib/libgdk_pixbuf-2.0.so -lm /usr/lib/libpangocairo-1.0.so /usr/lib/libgio-2.0.so /usr/lib/libcairo.so /usr/lib/libpango-1.0.so /usr/lib/libfreetype.so -lfontconfig /usr/lib/libgmodule-2.0.so /usr/lib/libgobject-2.0.so /usr/lib/libgthread-2.0.so -lrt /usr/lib/libglib-2.0.so -pthread
make[1]: Leaving directory `/home/nagul/build_area/webkit-1.1.5'
WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/TestNetscapePlugin.cpp: In function ‘NPError webkit_test_plugin_get_value(NPP_t*, NPPVariable, void*)’:
WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/TestNetscapePlugin.cpp:221: warning: deprecated conversion from string constant to ‘char*’
WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/TestNetscapePlugin.cpp:224: warning: deprecated conversion from string constant to ‘char*’
WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/TestNetscapePlugin.cpp: In function ‘char* NP_GetMIMEDescription()’:
WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/TestNetscapePlugin.cpp:260: warning: deprecated conversion from string constant to ‘char*’
/usr/bin/ld: Programs/.libs/GtkLauncher: hidden symbol `__stack_chk_fail_local' in /usr/lib/libc_nonshared.a(stack_chk_fail_local.oS) is referenced by DSO
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
make[1]: *** [Programs/GtkLauncher] Error 1
make: *** [all] Error 2

I'd like some pointers on how to attack this problem, either by looking into the "hidden sybmol" error or by helping me understand what the "Nonrepresentable section on output" message from the linker actually means.

I have already checked that this is consistent behaviour that persists across a make clean;make invocation.

I've received the "nonrepresentable section on output" error when crosscompiling for ARM and some of the libraries was not correctly compiled with -fPIC. Pretty sure that's not the error here though...

This was our problem: multiple ARM compilers, resulting in the "nonrepresentable section on output" error. Adding -fPIC resolved the problem. – Jason Swager Jan 31, 2013 at 16:46

My answer is specific to the combination of the hidden symbol (...) is referenced by DSO and Nonrepresentable section on output errors.

The short answer is: a symbol was marked extern but also marked hidden (see Visibility (GCC wiki) and How To Write Shared Libraries (Ulrich Drepper)). No objects or archives were linked in to satisfy the dependency, but a shared object was linked in with a matching symbol.

You probably compiled with -fvisibility=hidden, and whether it was a compiler-added feature (like stack protector) or something else entirely, the symbol emitted in your code overrode the default visibility of an undefined symbol reference of the same name in libc_nonshared.a that would normally be satisfied by libc.so.

You can reproduce a similar problem like this:

#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 compiling 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
# with gcc 4.4.7:
~ gcc badcode.c -shared -fPIC -o libbad.so -lc
/tmp/cc2SHUFD.o: In function `blah':
badcode.c:(.text+0x26): undefined reference to `open_memstream'
/usr/bin/ld: /tmp/libbad.so: hidden symbol `open_memstream' isn't defined
/usr/bin/ld: final link failed: Nonrepresentable section on output
# with oracle solaris studio (still in Linux) 12.3:
~ cc -shared -Kpic -o /tmp/libbad.so badcode.c -lc
badcode.o: In function `blah':
badcode.c:(.text+0x32): undefined reference to `open_memstream'
/usr/bin/ld: /tmp/libbad.so: hidden symbol `open_memstream' isn't defined
/usr/bin/ld: final link failed: Nonrepresentable section on output

In short: I've forward declared the existence of a symbol, marked it hidden, then didn't link in a static library or object file that satisfied the dependency. Since it's marked hidden, the dependency must be satisfied, otherwise it's an invalid ELF object.

In my specific case, a header was going down the wrong #if path and causing the above hidden declaration of open_memstream.

Whoa... resurrecting is OK, but 6 years after the fact? I'm not sure OP is still programming... – dascandy Oct 8, 2015 at 20:01 Keep in mind that long after you're dead, assuming SO fulfills their goal, people will still be using whatever is posted here and potentially be interested in problems we are dealing with now. – Brian Vandenberg Oct 8, 2015 at 20:34

Please try removing the -fvisibility=hidden option from the commandline. It will produce a larger object (with some unnecessary symbols, which won't matter in the end because it is an execultable), but should eliminate the problem. This is not a solution; rather a workaround. Please check (this is just a hunch) if there are no libc version mismatches between libraries and GtkLauncher.o

looks like -fvisibility=hidden is a somewhat new feature in gcc. Or the docs haven't been updated and are still saying it's new... Maybe it's causing you trouble with some compiler-added safety checks to defend against stack attacks (stack_chk...), if some code was compiled with defenses turned on, and some wasn't? – Peter Cordes Dec 8, 2009 at 18:16

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.