Bug 28422 - Linking fails with "relocation R_X86_64_PC32 against symbol `cti_vm_throw'"
Summary: Linking fails with "relocation R_X86_64_PC32 against symbol `cti_vm_throw'"
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords:
: 28798 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-08-18 00:27 PDT by Priit Laes (IRC: plaes)
Modified: 2009-10-06 22:44 PDT (History)
7 users (show)

See Also:


Attachments
webkit-bug-28422-fix-debug-symbol-visibility.patch (1.63 KB, patch)
2009-08-18 00:34 PDT, Priit Laes (IRC: plaes)
jmalonzo: review-
Details | Formatted Diff | Diff
webkit-bug-28422-use-plt-segment-for-cti_vm_throw-v2.patch (2.28 KB, patch)
2009-08-24 06:57 PDT, Priit Laes (IRC: plaes)
no flags Details | Formatted Diff | Diff
webkit-bug-28422-use-plt-segment-for-cti_vm_throw-v3.patch (4.54 KB, patch)
2009-08-26 05:55 PDT, Priit Laes (IRC: plaes)
no flags Details | Formatted Diff | Diff
webkit-bug-28422-use-plt-segment-for-cti_vm_throw-final.patch (4.33 KB, patch)
2009-09-10 01:37 PDT, Priit Laes (IRC: plaes)
no flags Details | Formatted Diff | Diff
webkit-bug-28422-use-plt-segment-for-cti_vm_throw-final.patch (4.31 KB, patch)
2009-09-29 00:28 PDT, Priit Laes (IRC: plaes)
barraclough: review+
eric: commit-queue-
Details | Formatted Diff | Diff
webkit-plt.patch (4.32 KB, patch)
2009-10-06 11:59 PDT, Priit Laes (IRC: plaes)
oliver: commit-queue-
Details | Formatted Diff | Diff
webkit-plt-reviewed.patch (4.32 KB, patch)
2009-10-06 22:28 PDT, Priit Laes (IRC: plaes)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Priit Laes (IRC: plaes) 2009-08-18 00:27:34 PDT
When building with --enable-debug, linking libwebkit-1.0.la fails with relocation error:

plaes@sol ~/code/WebKit $ make
make  all-am
make[1]: Entering directory `/home/plaes/code/WebKit'
/bin/mkdir -p ./.deps/DerivedSources
  CXXLD  libwebkit-1.0.la
/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.1/../../../../x86_64-pc-linux-gnu/bin/ld: ./.libs/libJavaScriptCore.a(libJavaScriptCore_la-JITStubs.o): relocation R_X86_64_PC32 against symbol `cti_vm_throw' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.1/../../../../x86_64-pc-linux-gnu/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make[1]: *** [libwebkit-1.0.la] Error 1
make[1]: Leaving directory `/home/plaes/code/WebKit'
make: *** [all] Error 2

plaes@sol ~/code/WebKit $ make V=1
make  all-am
make[1]: Entering directory `/home/plaes/code/WebKit'
/bin/mkdir -p ./.deps/DerivedSources
./doltlibtool  --tag=CXX   --mode=link g++ -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-inlines-hidden -fno-rtti -fno-strict-aliasing  -I/usr/include/enchant -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include   -I/usr/include/gail-1.0 -I/usr/include/atk-1.0 -I/usr/include/gtk-2.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/lib64/gtk-2.0/include -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12    -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include   -pthread -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libxml2   -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12    -I/usr/include/libsoup-2.4 -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include   -I/usr/include/libxml2   -I/usr/include/libxml2    -I/usr/include   -ggdb -g -O0 -version-info 10:1:8 -Wl,--version-script,./autotools/symbols.filter   -o libwebkit-1.0.la -rpath /home/plaes/opt/lib WebKit/gtk/WebCoreSupport/libwebkit_1_0_la-ChromeClientGtk.lo WebKit/gtk/WebCoreSupport/libwebkit_1_0_la-ContextMenuClientGtk.lo WebKit/gtk/WebCoreSupport/libwebkit_1_0_la-DragClientGtk.lo WebKit/gtk/WebCoreSupport/libwebkit_1_0_la-EditorClientGtk.lo WebKit/gtk/WebCoreSupport/libwebkit_1_0_la-FrameLoaderClientGtk.lo WebKit/gtk/WebCoreSupport/libwebkit_1_0_la-InspectorClientGtk.lo WebKit/gtk/WebCoreSupport/libwebkit_1_0_la-PasteboardHelperGtk.lo WebKit/gtk/webkit/libwebkit_1_0_la-webkitapplicationcache.lo WebKit/gtk/webkit/libwebkit_1_0_la-webkitdownload.lo WebKit/gtk/webkit/libwebkit_1_0_la-webkiterror.lo WebKit/gtk/webkit/libwebkit_1_0_la-webkitnetworkrequest.lo WebKit/gtk/webkit/libwebkit_1_0_la-webkitprivate.lo WebKit/gtk/webkit/libwebkit_1_0_la-webkitsoupauthdialog.lo WebKit/gtk/webkit/libwebkit_1_0_la-webkitversion.lo WebKit/gtk/webkit/libwebkit_1_0_la-webkitwebbackforwardlist.lo WebKit/gtk/webkit/libwebkit_1_0_la-webkitwebframe.lo WebKit/gtk/webkit/libwebkit_1_0_la-webkitwebhistoryitem.lo WebKit/gtk/webkit/libwebkit_1_0_la-webkitwebinspector.lo WebKit/gtk/webkit/libwebkit_1_0_la-webkitwebnavigationaction.lo WebKit/gtk/webkit/libwebkit_1_0_la-webkitwebpolicydecision.lo WebKit/gtk/webkit/libwebkit_1_0_la-webkitwebsettings.lo WebKit/gtk/webkit/libwebkit_1_0_la-webkitwebview.lo WebKit/gtk/webkit/libwebkit_1_0_la-webkitwebwindowfeatures.lo DerivedSources/libwebkit_1_0_la-webkitenumtypes.lo DerivedSources/libwebkit_1_0_la-webkitmarshal.lo -lpthread libJavaScriptCore.la libWebCore.la libWebCoreJS.la  -lcairo    -Wl,--export-dynamic -lenchant -lgmodule-2.0 -lglib-2.0   -lcairo -lfontconfig -lfreetype   -lgailutil -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0    -pthread -lgobject-2.0 -lgthread-2.0 -lrt -lglib-2.0   -pthread -lgstvideo-0.10 -lgstbase-0.10 -lgstreamer-0.10 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lxml2 -lglib-2.0   -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0    -ljpeg -lsoup-2.4 -lgio-2.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0   -lxml2   -lxslt -lz -lm -lxml2   -lpangoft2-1.0 -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0   -lpng12   -lsqlite3   -lpthread -lm   -L/usr/lib64 -licui18n -licuuc -licudata  -lpthread -lm    -lXt -lX11 -lSM -lICE   
libtool: link: g++ -shared -nostdlib /usr/lib/gcc/x86_64-pc-linux-gnu/4.4.1/../../../../lib64/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.4.1/crtbeginS.o  WebKit/gtk/WebCoreSupport/.libs/libwebkit_1_0_la-ChromeClientGtk.o WebKit/gtk/WebCoreSupport/.libs/libwebkit_1_0_la-ContextMenuClientGtk.o WebKit/gtk/WebCoreSupport/.libs/libwebkit_1_0_la-DragClientGtk.o WebKit/gtk/WebCoreSupport/.libs/libwebkit_1_0_la-EditorClientGtk.o WebKit/gtk/WebCoreSupport/.libs/libwebkit_1_0_la-FrameLoaderClientGtk.o WebKit/gtk/WebCoreSupport/.libs/libwebkit_1_0_la-InspectorClientGtk.o WebKit/gtk/WebCoreSupport/.libs/libwebkit_1_0_la-PasteboardHelperGtk.o WebKit/gtk/webkit/.libs/libwebkit_1_0_la-webkitapplicationcache.o WebKit/gtk/webkit/.libs/libwebkit_1_0_la-webkitdownload.o WebKit/gtk/webkit/.libs/libwebkit_1_0_la-webkiterror.o WebKit/gtk/webkit/.libs/libwebkit_1_0_la-webkitnetworkrequest.o WebKit/gtk/webkit/.libs/libwebkit_1_0_la-webkitprivate.o WebKit/gtk/webkit/.libs/libwebkit_1_0_la-webkitsoupauthdialog.o WebKit/gtk/webkit/.libs/libwebkit_1_0_la-webkitversion.o WebKit/gtk/webkit/.libs/libwebkit_1_0_la-webkitwebbackforwardlist.o WebKit/gtk/webkit/.libs/libwebkit_1_0_la-webkitwebframe.o WebKit/gtk/webkit/.libs/libwebkit_1_0_la-webkitwebhistoryitem.o WebKit/gtk/webkit/.libs/libwebkit_1_0_la-webkitwebinspector.o WebKit/gtk/webkit/.libs/libwebkit_1_0_la-webkitwebnavigationaction.o WebKit/gtk/webkit/.libs/libwebkit_1_0_la-webkitwebpolicydecision.o WebKit/gtk/webkit/.libs/libwebkit_1_0_la-webkitwebsettings.o WebKit/gtk/webkit/.libs/libwebkit_1_0_la-webkitwebview.o WebKit/gtk/webkit/.libs/libwebkit_1_0_la-webkitwebwindowfeatures.o DerivedSources/.libs/libwebkit_1_0_la-webkitenumtypes.o DerivedSources/.libs/libwebkit_1_0_la-webkitmarshal.o  -Wl,--whole-archive ./.libs/libJavaScriptCore.a ./.libs/libWebCore.a ./.libs/libWebCoreJS.a -Wl,--no-whole-archive  -L/usr/lib64 /usr/lib64/libenchant.so /usr/lib64/libgailutil.so /usr/lib64/libXinerama.so /usr/lib64/libXrandr.so /usr/lib64/libXcursor.so /usr/lib64/libXcomposite.so /usr/lib64/libXdamage.so /usr/lib64/libXfixes.so /usr/lib64/libgstvideo-0.10.so /usr/lib64/libgstbase-0.10.so /usr/lib64/libgstreamer-0.10.so /usr/lib64/libgtk-x11-2.0.so /usr/lib64/libgdk-x11-2.0.so /usr/lib64/libatk-1.0.so /usr/lib64/libgdk_pixbuf-2.0.so /usr/lib64/libpangocairo-1.0.so /usr/lib64/libcairo.so /usr/lib64/libpixman-1.so /usr/lib64/libglitz-glx.so /usr/lib64/libGL.so /usr/lib64/libXmu.so /usr/lib64/libXext.so /usr/lib64/libXi.so /usr/lib64/libglitz.so /usr/lib64/libxcb-render-util.so /usr/lib64/libxcb-render.so /usr/lib64/libXrender.so /usr/lib64/libjpeg.so /usr/lib64/libsoup-2.4.so /usr/lib64/libgthread-2.0.so -lrt /usr/lib64/libgnutls.so /usr/lib64/libtasn1.so /usr/lib64/libgcrypt.so /usr/lib64/libgpg-error.so /usr/lib64/libgio-2.0.so -lresolv /usr/lib64/libxslt.so /usr/lib64/libxml2.so /usr/lib64/libpangoft2-1.0.so /usr/lib64/libpango-1.0.so /usr/lib64/libfontconfig.so /usr/lib64/libfreetype.so /usr/lib64/libexpat.so /usr/lib64/libgobject-2.0.so /usr/lib64/libgmodule-2.0.so /usr/lib64/libglib-2.0.so /usr/lib64/libpng12.so -lz /usr/lib64/libsqlite3.so -licui18n -licuuc -licudata -lpthread /usr/lib64/libXt.so /usr/lib64/libX11.so /usr/lib64/libxcb.so /usr/lib64/libXau.so /usr/lib64/libXdmcp.so -ldl /usr/lib64/libSM.so -luuid /usr/lib64/libICE.so -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.1 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.1/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.1/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.1/../../.. -lstdc++ -lm -lc -lgcc_s /usr/lib/gcc/x86_64-pc-linux-gnu/4.4.1/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.4.1/../../../../lib64/crtn.o  -pthread -pthread -Wl,--version-script -Wl,./autotools/symbols.filter -Wl,--export-dynamic -pthread -pthread   -pthread -Wl,-soname -Wl,libwebkit-1.0.so.2 -o .libs/libwebkit-1.0.so.2.8.1
/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.1/../../../../x86_64-pc-linux-gnu/bin/ld: ./.libs/libJavaScriptCore.a(libJavaScriptCore_la-JITStubs.o): relocation R_X86_64_PC32 against symbol `cti_vm_throw' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.1/../../../../x86_64-pc-linux-gnu/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make[1]: *** [libwebkit-1.0.la] Error 1
make[1]: Leaving directory `/home/plaes/code/WebKit'
make: *** [all] Error 2
plaes@sol ~/code/WebKit $
Comment 1 Priit Laes (IRC: plaes) 2009-08-18 00:34:21 PDT
Created attachment 35026 [details]
webkit-bug-28422-fix-debug-symbol-visibility.patch

Not sure whether this is the right way to fix it, but at least it WORKSFORME :)
Comment 2 Jan Alonzo 2009-08-18 03:32:38 PDT
Why? Have you tried recompiling with -fPIC?
Comment 3 Jan Alonzo 2009-08-18 15:13:07 PDT
Comment on attachment 35026 [details]
webkit-bug-28422-fix-debug-symbol-visibility.patch

Hiding/filtering the symbols is not the right fix here. You might as well do a release build. Have you tried forcing  -fPIC in CFLAGS? If that works then we need to fix our build scripts to do that automatically.
Comment 4 Priit Laes (IRC: plaes) 2009-08-23 11:17:18 PDT
(In reply to comment #3)
> (From update of attachment 35026 [details])
> Hiding/filtering the symbols is not the right fix here. You might as well do a
> release build. Have you tried forcing  -fPIC in CFLAGS? If that works then we
> need to fix our build scripts to do that automatically.

Tried with CXXFLAGS="-fPIC" CFLAGS="-fPIC" but it didn't work.

I have an alternative patch that seems to fix this issue (at least on my machine):
http://plaes.org/files/2009-Q3/webkit-bug-28422-use-plt-segment-for-cti_vm_throw.patch

It seems to be the right approach ( See section 1.5.5 in http://people.redhat.com/drepper/dsohowto.pdf paper..)
Comment 5 Priit Laes (IRC: plaes) 2009-08-24 06:57:49 PDT
Created attachment 38479 [details]
webkit-bug-28422-use-plt-segment-for-cti_vm_throw-v2.patch

Added #if PLATFORM(LINUX) guards suggested by bdash.
Comment 6 Mark Rowe (bdash) 2009-08-24 21:50:44 PDT
The SYMBOL_NAME macro is intended to abstract the variance in symbol names between platforms.  #if'ing it at the call site defeats that purpose.
Comment 7 Priit Laes (IRC: plaes) 2009-08-26 05:55:54 PDT
Created attachment 38607 [details]
webkit-bug-28422-use-plt-segment-for-cti_vm_throw-v3.patch

I had to introduce another macro SYMBOL_STRING_INTERNAL in order to properly change symbol name..

Tested on Linux x86-64 (built with and without debugging).
Comment 8 Mark Rowe (bdash) 2009-08-27 23:55:12 PDT
*** Bug 28798 has been marked as a duplicate of this bug. ***
Comment 9 Eric Seidel (no email) 2009-09-01 01:36:30 PDT
Oliver would know if this looks sane.
Comment 10 Oliver Hunt 2009-09-08 23:02:19 PDT
I am deferring to Gavin on this one -- conceivably hoisting to vm_throw should just use a safer mechanism to enter the trampoline
Comment 11 Gavin Barraclough 2009-09-08 23:58:05 PDT
Not a clue whether we should be doing this on Mac or not.  :o)

Lemme give this a test in the morning.
G.
Comment 12 Gavin Barraclough 2009-09-09 13:40:01 PDT
Comment on attachment 38607 [details]
webkit-bug-28422-use-plt-segment-for-cti_vm_throw-v3.patch

This patch seems sensible to me, seems reasonable to use plt-indirect calls on linux.  Doesn't seem to be a relevant issue to Mac.

My one concern would be the name, SYMBOL_STRING_INTERNAL, which doesn't seem to be accurately descriptive to me.  The strings formed by this macro seem specific to the use case – I don't believe foo@plt syntax is commonly used outside of use in a call?  For symbols internal to a compilation module, it is just a question of omitting the .globl directive?  I'd suggest renaming the macro to something like SYMBOL_FOR_CALL would probably be clearer, but I don't know linux x86-64 asm that well, so perhaps I'm wrong.
Comment 13 Priit Laes (IRC: plaes) 2009-09-09 21:36:24 PDT
I chose the SYMBOL_STRING_INTERNAL because it is supposedly used only inside the function.
How about SYMBOL_STRING_CALL or SYMBOL_STRING_FOR_CALL?
Comment 14 Gavin Barraclough 2009-09-10 00:12:40 PDT
(In reply to comment #13)
> I chose the SYMBOL_STRING_INTERNAL because it is supposedly used only inside
> the function.
> How about SYMBOL_STRING_CALL or SYMBOL_STRING_FOR_CALL?

To my mind either of those is nice and clear, I'd happily r+ either.  Your choice.
Comment 15 Priit Laes (IRC: plaes) 2009-09-10 01:37:26 PDT
Created attachment 39330 [details]
webkit-bug-28422-use-plt-segment-for-cti_vm_throw-final.patch

I decided to go with SYMBOL_STRING_RELOCATION which seemed more appropriate (only PC platforms seem to have call opcode, arms have branch)..

I also took the liberty to fill the Reviewed by slot :P
Comment 16 Priit Laes (IRC: plaes) 2009-09-29 00:28:37 PDT
Created attachment 40285 [details]
webkit-bug-28422-use-plt-segment-for-cti_vm_throw-final.patch

Resynced the patch.
Comment 17 Eric Seidel (no email) 2009-10-02 17:06:16 PDT
Comment on attachment 40285 [details]
webkit-bug-28422-use-plt-segment-for-cti_vm_throw-final.patch

Please don't change NOBODY (OOPS!) or svn-apply (and thus the commit-queue) won't be able to handle the patch.  cq- for this patch, you could post another which would be commit-queue compatible, or someone else can land this by hand for you.  Thanks for the patch. :)
Comment 18 Priit Laes (IRC: plaes) 2009-10-06 11:59:47 PDT
Created attachment 40732 [details]
webkit-plt.patch

Updated the patch (again.. and already getting tired...)
Comment 19 Oliver Hunt 2009-10-06 12:02:01 PDT
Comment on attachment 40732 [details]
webkit-plt.patch

This patch has been reviewed -- can you update the changelog so it can be marked commit+ ?
Comment 20 Priit Laes (IRC: plaes) 2009-10-06 22:28:12 PDT
Created attachment 40764 [details]
webkit-plt-reviewed.patch

Added "Reviewed by Gavin Barraclough." there...
Comment 21 Eric Seidel (no email) 2009-10-06 22:34:30 PDT
Comment on attachment 40764 [details]
webkit-plt-reviewed.patch

I'm not sure I fully understand Oliver's request.  But OK.  To use the commit-queue you need both an r+ and a cq+.  I'll add the r+.  Since you already edited the ChangeLog to state that Gavin reviewed this (which is fine, but not normally done) the commit-queue will not set me as the reviewer, as it would have normally done having seen my r+.
Comment 22 WebKit Commit Bot 2009-10-06 22:44:54 PDT
Comment on attachment 40764 [details]
webkit-plt-reviewed.patch

Clearing flags on attachment: 40764

Committed r49224: <http://trac.webkit.org/changeset/49224>
Comment 23 WebKit Commit Bot 2009-10-06 22:44:59 PDT
All reviewed patches have been landed.  Closing bug.