"Unexpected section on exit" error when linking to linux

I get this error at the linker stage when compiling the webkit-1.1.5 package in 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 would like some pointers on how to attack this problem, either by looking at the "hidden sybmol" error, or by helping me understand what the "Inaccessible section on output" message from the linker actually means.

I have already verified that this is a consistent behavior that persists in a make clean;make call.

+6
c ++ linux linker-errors
source share
3 answers

I got an "unrepresentable output section" error when crossing for ARM, and some libraries were not compiled correctly with -fPIC. Sure it's not a mistake here, though ...

+5
source share

Try removing the -fvisibility = hidden option from the command line. It will create a larger object (with some unnecessary characters, which ultimately does not matter because it is doable), but should fix the problem. This is not a solution; rather a workaround. Please check (this is just a hunch) if there are no libc error libraries between the libraries and GtkLauncher.o

+3
source share

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 # 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 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 .

+3
source share

All Articles