QITableEntry uses 32-bit offset, preventing PIC (position independent code)




8 years ago
8 years ago


(Reporter: David Ward, Unassigned)


Firefox Tracking Flags

(Not tracked)




8 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20100106 Ubuntu/9.10 (karmic) Firefox/3.5.7
Build Identifier: Mozilla 1.9.0, 1.9.1, and 1.9.2

A QueryInterface table entry (or 'struct QITableEntry'), defined in mozilla/xpcom/glue/nsISupportsImpl.h, is hard-coded to use a 32-bit offset (of type 'PROffset32').  As a result, relocations of type R_X86_64_PC32 occur when this struct is used in a 64-bit environment, even when compiling with '-fPIC'.  This prevents linking against libxpcomglue_s.a in a shared library, when in turn breaks building IcedTea6 1.7 (http://icedtea.classpath.org).

Reproducible: Always

Steps to Reproduce:
In RHEL 5.4 or Ubuntu 9.10, inspecting libxpcomglue_s.a(nsThreadUtils.o) reveals the R_X86_64_PC32 relocations:

(RHEL 5.4 64-bit, with xulrunner-devel installed)
$ cd /tmp
$ ar x /usr/lib64/xulrunner-sdk-1.9/lib/libxpcomglue_s.a
$ objdump -r -C nsThreadUtils.o | grep R_X86_64_PC32
000000000000001d R_X86_64_PC32     nsIThreadManager::COMTypeInfo<int>::kIID+0xfffffffffffffffc

(Ubuntu 9.10 64-bit, with xulrunner-1.9.1-dev installed)
$ cd /tmp
$ ar x /usr/lib/xulrunner-devel-
$ objdump -r -C nsThreadUtils.o | grep R_X86_64_PC32
0000000000000007 R_X86_64_PC32     nsIThreadManager::COMTypeInfo<int>::kIID-0x0000000000000004
Actual Results:  
The error that is produced when building IcedTea6 1.7 under RHEL 5.4 is:

g++ -g -O2 \
          IcedTeaPlugin.o \
          -L/lib64 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0   \
          -L/usr/lib64/xulrunner-sdk-1.9/sdk/lib -L/usr/lib64/xulrunner-sdk-1.9/lib -lmozjs -lxpcomglue_s -lxul -lxpcom -lplds4 -lplc4 -lnspr4 -lpthread -ldl   \
          -shared -o IcedTeaPlugin.so
/usr/bin/ld: /usr/lib64/xulrunner-sdk-1.9/sdk/lib/libxpcomglue_s.a(nsThreadUtils.o): relocation R_X86_64_PC32 against `nsIThreadManager::COMTypeInfo<int>::kIID' can not be used when making a shared object; recompile with -fPIC

However I verified that -fPIC is used when compiling nsThreadUtils.o...the error message is misleading:

c++ -o nsThreadUtils.o -c -I../../dist/include/system_wrappers -include ../../config/gcc_hidden.h -DOSTYPE=\"Linux2.6.18-164.11.1\" -DOSARCH=Linux -DTARGET_XPCOM_ABI=\"x86_64-gcc3\" -I./../build  -I. -I. -I../../dist/include/string -I../../dist/include   -I../../dist/include/xpcom -I/usr/include/nspr4     -I../../dist/sdk/include    -fPIC   -fno-rtti -fno-exceptions -Wall -Wconversion -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wcast-align -Wno-long-long -pedantic -fno-strict-aliasing -fshort-wchar -pthread -pipe  -DNDEBUG -DTRIMMED -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic   -DMOZILLA_CLIENT -include ../../mozilla-config.h -Wp,-MD,.deps/nsThreadUtils.pp nsThreadUtils.cpp

Expected Results:  
No R_X86_64_PC32 relocations should occur in libxpcomglue_s.a(nsThreadUtils.o), so that IcedTea6 1.7 should be able to compile.

The uses of a 32-bit offset persists across Mozilla 1.9.0, 1.9.1, and 1.9.2, so please ensure that any fix is backported to all versions.
You need to log in before you can comment on or make changes to this bug.