Bug 70610 - TEXTREL in libjavascriptcoregtk-1.0.so.0.11.0 on x86 (or i586)
Summary: TEXTREL in libjavascriptcoregtk-1.0.so.0.11.0 on x86 (or i586)
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-21 08:12 PDT by Alexey Shabalin
Modified: 2014-08-19 14:25 PDT (History)
13 users (show)

See Also:


Attachments
fix TEXTREL (1.33 KB, patch)
2011-10-24 02:58 PDT, Alexey Shabalin
no flags Details | Formatted Diff | Diff
Updated patch to fix the textrel (450 bytes, patch)
2014-03-13 13:30 PDT, Magnus Granberg
no flags Details | Formatted Diff | Diff
Patch to add plt to fix the textrel (449 bytes, patch)
2014-03-13 13:42 PDT, Magnus Granberg
no flags Details | Formatted Diff | Diff
add plt and fix %ebx for use with plt (1.79 KB, patch)
2014-03-20 14:48 PDT, Magnus Granberg
no flags Details | Formatted Diff | Diff
Patch (2.94 KB, patch)
2014-03-24 02:49 PDT, Alberto Garcia
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Shabalin 2011-10-21 08:12:11 PDT
own verifying ELF objects script say about error

either the file containing the function '_ZN3JSC3JIT13testPrototypeENS_7JSValueERNS_22AbstractMacroAssemblerINS_12X86AssemblerEE8JumpListE' or the file containing the function 'cti_op_put_by_id_generic' is not compiled with -fpic/-fPIC
either the file containing the function 'jsRoundThunk' or the file containing the function 'expThunk' is not compiled with -fpic/-fPIC
either the file containing the function 'expThunk' or the file containing the function 'logThunk' is not compiled with -fpic/-fPIC
either the file containing the function 'logThunk' or the file containing the function 'floorThunk' is not compiled with -fpic/-fPIC
either the file containing the function 'floorThunk' or the file containing the function 'ceilThunk' is not compiled with -fpic/-fPIC
either the file containing the function 'ceilThunk' or the file containing the function 'jsRound' is not compiled with -fpic/-fPIC

verify-elf: ERROR: ./usr/lib/libjavascriptcoregtk-1.0.so.0.11.0: TEXTREL entry found: 0x00000000

on x86_64 all fine.
Comment 1 Martin Robinson 2011-10-21 13:21:35 PDT
What platform? Did you build yourself? How do you reproduce this?
Comment 2 Alexey Shabalin 2011-10-24 02:58:22 PDT
Created attachment 112169 [details]
fix TEXTREL

fix TEXTREL
Comment 3 Alexey Shabalin 2011-10-24 02:59:09 PDT
I was build for ALTLinux for x86.
Gentoo have some warning. http://gentwoo.elisp.net/emerges/88345

QA Notice: The following files contain runtime text relocations
 Text relocations force the dynamic linker to perform extra
 work at startup, waste system resources, and may pose a security
 risk.  On some architectures, the code may not even function
 properly, if at all.
 For more information, see http://hardened.gentoo.org/pic-fix-guide.xml
 Please include the following list of files in your report:
TEXTREL usr/lib/libjavascriptcoregtk-3.0.so.0.11.0

For reproduce this:
- build for i586 with --disable-silent-rules
- you can see for libjavascriptcoregtk
  "/usr/bin/ld: warning: creating a DT_TEXTREL in a shared object."
- after build you can check:

$ eu-findtextrel ./libwebkitgtk-3.0.so.0.11.0 
eu-findtextrel: no text relocations reported in './libwebkitgtk-3.0.so.0.11.0'

$ eu-findtextrel ./libjavascriptcoregtk-3.0.so.0.11.0 
either the file containing the function '_ZN3JSC3JIT13testPrototypeENS_7JSValueERNS_22AbstractMacroAssemblerINS_12X86AssemblerEE8JumpListE' or the file containing the function 'cti_op_put_by_id_generic' is not compiled with -fpic/-fPIC
either the file containing the function 'jsRoundThunk' or the file containing the function 'expThunk' is not compiled with -fpic/-fPIC
either the file containing the function 'expThunk' or the file containing the function 'logThunk' is not compiled with -fpic/-fPIC
either the file containing the function 'logThunk' or the file containing the function 'floorThunk' is not compiled with -fpic/-fPIC
either the file containing the function 'floorThunk' or the file containing the function 'ceilThunk' is not compiled with -fpic/-fPIC
either the file containing the function 'ceilThunk' or the file containing the function 'jsRound' is not compiled with -fpic/-fPIC

simple patch in attach, but i have doubts about Source/JavaScriptCore/jit/JSInterfaceJIT.h in #elif CPU(X86)
 static const RegisterID regT3 = X86Registers::ebx;
Comment 4 Martin Robinson 2011-10-25 00:04:34 PDT
CCing some people more familiar with JSC internals.
Comment 5 Oliver Hunt 2011-10-25 08:44:49 PDT
Comment on attachment 112169 [details]
fix TEXTREL

This fix seems reasonable to me -- it's just a matter of ensuring the all the asm we have is correctly annotated to allow it to be shuffled around.
Comment 6 WebKit Review Bot 2011-10-25 11:48:41 PDT
Attachment 112169 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files']" exit_code: 1

Total errors found: 0 in 0 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 Martin Robinson 2011-11-02 12:28:09 PDT
Comment on attachment 112169 [details]
fix TEXTREL

I will land this one. Thanks for the patch Alexey. In the future when you make a patch, do you mind making it against trunk and include a ChangeLog? See: http://www.webkit.org/coding/contributing.html
Comment 8 Martin Robinson 2011-11-02 12:28:55 PDT
Committed r99089: <http://trac.webkit.org/changeset/99089>
Comment 9 Alexey Shabalin 2011-11-02 12:47:18 PDT
Hello.
This patch is not complete fix.
After apply this patch you can not build seed (http://live.gnome.org/Seed) on linux x86(i386, not x86_64). I don't know how fix it.

I think, should be reopen bug.
Comment 10 Martin Robinson 2011-11-02 12:49:55 PDT
(In reply to comment #9)
> After apply this patch you can not build seed (http://live.gnome.org/Seed) on linux x86(i386, not x86_64). I don't know how fix it.
> 
> I think, should be reopen bug.

In that case it's probably best to roll out the patch.
Comment 11 Martin Robinson 2011-11-02 13:04:42 PDT
(In reply to comment #10)
> (In reply to comment #9)
> > After apply this patch you can not build seed (http://live.gnome.org/Seed) on linux x86(i386, not x86_64). I don't know how fix it.

How does the build break?
Comment 12 Csaba Osztrogonác 2011-11-03 00:42:25 PDT
It made many tests crash on the Qt bot :-/ (only 32 bit)
Comment 13 Zoltan Herczeg 2011-11-03 01:43:42 PDT
(In reply to comment #12)
> It made many tests crash on the Qt bot :-/ (only 32 bit)

ThunkGenerators.cpp:140
0xf6ccf694 <floorThunk+8>:      call   0xf5960f18 <floor@plt>
x $ebx+0x218c
0xf171004b:     0x00000000

and there is a crash after that:
0x0:    Cannot access memory at address 0x0

Thus, although the symbol is defined it points to NULL.

I think the idea is good, but we need a more sophisticated check what is available in the target system.
Comment 14 Zoltan Herczeg 2011-11-03 01:52:49 PDT
Oh, one line is missing.

> ThunkGenerators.cpp:140
> 0xf6ccf694 <floorThunk+8>:      call   0xf5960f18 <floor@plt>

0xf5960f18 <floor@plt>: jmp    *0x218c(%ebx)

> x $ebx+0x218c
> 0xf171004b:     0x00000000

So <floor@plt> does an indirect jump to a NULL address.
Comment 15 Zoltan Herczeg 2011-11-03 01:54:44 PDT
I created a rollout: https://bugs.webkit.org/show_bug.cgi?id=71448
Comment 16 Csaba Osztrogonác 2011-11-03 03:02:50 PDT
(In reply to comment #15)
> I created a rollout: https://bugs.webkit.org/show_bug.cgi?id=71448

Rollout landed in http://trac.webkit.org/changeset/99152
Comment 17 Magnus Granberg 2014-03-02 14:43:05 PST
Any progress on this bug? I still get TEXTREL when building
webkit-gtk-2.2.5 on Gentoo x86.
mv -f Tools/DumpRenderTree/gtk/.deps/Programs_DumpRenderTree-EventSender.Tpo Tools/DumpRenderTree/gtk/.deps/Programs_DumpRenderTree-EventSender.Po
mv -f Tools/DumpRenderTree/gtk/.deps/Programs_DumpRenderTree-PixelDumpSupportGtk.Tpo Tools/DumpRenderTree/gtk/.deps/Programs_DumpRenderTree-PixelDumpSupportGtk.Po
mv -f Source/JavaScriptCore/.deps/Programs_jsc_1-jsc.Tpo Source/JavaScriptCore/.deps/Programs_jsc_1-jsc.Po
mv -f Tools/DumpRenderTree/gtk/.deps/Programs_DumpRenderTree-WorkQueueItemGtk.Tpo Tools/DumpRenderTree/gtk/.deps/Programs_DumpRenderTree-WorkQueueItemGtk.Po
mv -f Tools/DumpRenderTree/gtk/.deps/Programs_DumpRenderTree-DumpRenderTree.Tpo Tools/DumpRenderTree/gtk/.deps/Programs_DumpRenderTree-DumpRenderTree.Po
/usr/lib/gcc/i686-pc-linux-gnu/4.7.3/../../../../i686-pc-linux-gnu/bin/ld: Source/JavaScriptCore/jit/.libs/libjavascriptcoregtk_1_0_la-ThunkGenerators.o: warning: relocation against `floor@@GLIBC_2.0' in readonly section `.text'.
/usr/lib/gcc/i686-pc-linux-gnu/4.7.3/../../../../i686-pc-linux-gnu/bin/ld: warning: creating a DT_TEXTREL in object.
libtool: link: (cd ".libs" && rm -f "libjavascriptcoregtk-1.0.so.0" && ln -s "libjavascriptcoregtk-1.0.so.0.15.10" "libjavascriptcoregtk-1.0.so.0")
libtool: link: (cd ".libs" && rm -f "libjavascriptcoregtk-1.0.so" && ln -s "libjavascriptcoregtk-1.0.so.0.15.10" "libjavascriptcoregtk-1.0.so")
libtool: link: ( cd ".libs" && rm -f "libjavascriptcoregtk-1.0.la" && ln -s "../libjavascriptcoregtk-1.0.la" "libjavascriptcoregtk-1.0.la" )
Comment 18 Magnus Granberg 2014-03-13 13:30:04 PDT
Created attachment 226616 [details]
Updated patch to fix the textrel

This patch is a update of the patch that was posted before.
Don't know if it will have that same prob as the old one for i
can't run the testsuite.
Comment 19 Early Warning System Bot 2014-03-13 13:32:45 PDT
Attachment 226616 [details] did not pass style-queue:


Total errors found: 0 in 0 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 20 Magnus Granberg 2014-03-13 13:42:59 PDT
Created attachment 226618 [details]
Patch to add plt to fix the textrel

Update to fix the typo in the last patch.
To fix the textrel.
Comment 21 Early Warning System Bot 2014-03-13 14:46:22 PDT
Attachment 226618 [details] did not pass style-queue:


Total errors found: 0 in 0 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 22 Alberto Garcia 2014-03-14 04:40:59 PDT
(In reply to comment #20)
> Created an attachment (id=226618) [details]
> Patch to add plt to fix the textrel

The browser crashes all the time with this patch. Did you try to run
GtkLauncher or the MiniBrowser?
Comment 23 Magnus Granberg 2014-03-20 14:48:53 PDT
Created attachment 227339 [details]
add plt and fix %ebx for use with plt

* Source/WTF/wtf/InlineASM.h GLOBAL_REFERENCE: Add plt if PIC
* Source/JavaScriptCore/jit/ThunkGenerators.cpp defineUnaryDoubleOpWrapper: if PIC then setup %ebx so we can use plt
Comment 24 Magnus Granberg 2014-03-20 14:55:47 PDT
(In reply to comment #22)
> (In reply to comment #20)
> > Created an attachment (id=226618) [details] [details]
> > Patch to add plt to fix the textrel
> 
> The browser crashes all the time with this patch. Did you try to run
> GtkLauncher or the MiniBrowser?
The prob is that i can't test any x86 stuff only compile.
the asm code was missing to setup %ebx with the needed info for plt.
Comment 25 Alberto Garcia 2014-03-21 06:13:36 PDT
(In reply to comment #23)
> Created an attachment (id=227339) [details]
> add plt and fix %ebx for use with plt

This actually seems to work fine, thanks!
Comment 26 Alberto Garcia 2014-03-24 01:55:19 PDT
I did a full rebuild of webkitgtk with this patch and I haven't noticed any problem, I think we can go ahead with it.

Thanks again for the patch.
Comment 27 Alberto Garcia 2014-03-24 02:49:12 PDT
Created attachment 227634 [details]
Patch

I rebased your patch and added the ChangeLog entry.
Comment 28 Alberto Garcia 2014-05-27 09:13:10 PDT
Debian has been shipping this patch for a while and we didn't detect any problem.
Comment 29 Alberto Garcia 2014-08-19 14:25:44 PDT
Committed r172759: <http://trac.webkit.org/changeset/172759>