[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug gold/14330] New: failure to link global hidden symbol
From: |
wingo at pobox dot com |
Subject: |
[Bug gold/14330] New: failure to link global hidden symbol |
Date: |
Wed, 04 Jul 2012 13:44:39 +0000 |
http://sourceware.org/bugzilla/show_bug.cgi?id=14330
Bug #: 14330
Summary: failure to link global hidden symbol
Product: binutils
Version: 2.22
Status: NEW
Severity: normal
Priority: P2
Component: gold
AssignedTo: address@hidden
ReportedBy: address@hidden
CC: address@hidden
Classification: Unclassified
When compiling JavaScriptCore in some configurations, we get a link error. I
believe this is due to a bug in gold. I know it might sound far-fetched, but
it is my only explanation.
The situation is a bit complicated. The symbol in question
(getHostCallReturnValue) is defined in assembler, and is hidden with .hidden.
There is a public declaration for the symbol, as a function. Like this:
HostCallReturnValue.h:
extern "C" EncodedJSValue getHostCallReturnValue() __attribute__((used))
__attribute__((visibility("hidden")));
DFGOperations.cpp:
asm (
".globl getHostCallReturnValue\n"
".hidden getHostCallReturnValue\n"
"getHostCallReturnValue:\n"
"mov -40(%r13), %r13\n"
"mov %r13, %rdi\n"
"jmp getHostCallReturnValueWithExecState\n"
);
LLIntSlowPaths.cpp has a reinterpret_cast<void*>(getHostCallReturnValue). It
is this reference that is failing to relocate.
The strange thing is, the build usually works. However if you build it with
CPPFLAGS=-DENABLE_DFG_JIT=0 (effectively disabling some code, but neither the
use nor the definition of getHostCallReturnValue are affected) *and* -g, then I
get the error:
g++ -fPIC -DPIC -shared -nostdlib [...] \
Source/JavaScriptCore/dfg/.libs/libjavascriptcoregtk_3_0_la-DFGOperations.o \
[...] \
Source/JavaScriptCore/llint/.libs/libjavascriptcoregtk_3_0_la-LLIntSlowPaths.o
\
-Wl,--whole-archive ./.libs/libWTF.a -Wl,--no-whole-archive
-L/home/wingo/src/WebKit/WebKitBuild/Dependencies/Root/lib64 -lpthread
-licui18n -licuuc -licudata -lgmodule-2.0 -lgthread-2.0 -lrt -lgio-2.0
-lgobject-2.0 -lglib-2.0 -L/usr/lib/gcc/x86_64-linux-gnu/4.7
-L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu
-L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib -L/lib/x86_64-linux-gnu
-L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib
-L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../.. -lstdc++ -lm -lc -lgcc_s
/usr/lib/gcc/x86_64-linux-gnu/4.7/crtendS.o
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crtn.o -O3
-pthread -O0 -Wl,--export-dynamic -pthread -pthread -Wl,-soname
-Wl,libjavascriptcoregtk-3.0.so.0 -o .libs/libjavascriptcoregtk-3.0.so.0.13.3
/usr/bin/ld: error:
Source/JavaScriptCore/llint/.libs/libjavascriptcoregtk_3_0_la-LLIntSlowPaths.o:
requires dynamic R_X86_64_PC32 reloc against 'getHostCallReturnValue' which may
overflow at runtime; recompile with -fPIC
../../Source/JavaScriptCore/llint/LLIntSlowPaths.cpp:1302: warning: relocation
refers to discarded section
/usr/bin/ld: error: hidden symbol 'getHostCallReturnValue' is not defined
locally
../../Source/JavaScriptCore/llint/LLIntSlowPaths.cpp:1325: warning: relocation
refers to discarded section
/usr/bin/ld: error: hidden symbol 'getHostCallReturnValue' is not defined
locally
../../Source/JavaScriptCore/llint/LLIntSlowPaths.cpp:1456: warning: relocation
refers to discarded section
/usr/bin/ld: error: hidden symbol 'getHostCallReturnValue' is not defined
locally
collect2: error: ld returned 1 exit status
I have elided a number of the .o files. I will paste a full command line as an
attachment.
Now, clearly the symbol is defined:
$ readelf -a
WebKitBuild/Debug/Source/JavaScriptCore/dfg/.libs/libjavascriptcoregtk_3_0_la-DFGOperations.o
| grep getHostCallReturnValue
000000000032 010200000002 R_X86_64_PC32 0000000000000030
getHostCallReturnValue - 4
257: 000000000000002a 0 NOTYPE GLOBAL HIDDEN 32
getHostCallReturnValue
258: 0000000000000030 74 FUNC GLOBAL HIDDEN 12
getHostCallReturnValueWit
Also the uses are clear:
$ readelf -a
WebKitBuild/Debug/Source/JavaScriptCore/llint/.libs/libjavascriptcoregtk_3_0_la-LLIntSlowPaths.o
| grep getHostCall
00000000b87d 0d3f00000002 R_X86_64_PC32 0000000000000000
getHostCallReturnValue - 4
00000000bb6e 0d3f00000002 R_X86_64_PC32 0000000000000000
getHostCallReturnValue - 4
00000000c23e 0d3f00000002 R_X86_64_PC32 0000000000000000
getHostCallReturnValue - 4
3391: 0000000000000000 0 NOTYPE GLOBAL HIDDEN UND
getHostCallReturnValue
The Debug build has some extra code paths, and is build -g -O0. The Release
build, while differing in the extra code paths and just -O3, shows the same
definitions and uses, but does succeed in linking, without runtime text
relocations:
$ readelf -a
WebKitBuild/Release/Source/JavaScriptCore/dfg/.libs/libjavascriptcoregtk_3_0_la-DFGOperations.o
| grep getHostCallReturnValue
000000000008 000900000002 R_X86_64_PC32 0000000000000010
getHostCallReturnValue - 4
8: 0000000000000000 0 NOTYPE GLOBAL HIDDEN 1
getHostCallReturnValue
9: 0000000000000010 27 FUNC GLOBAL HIDDEN 1
getHostCallReturnValueWit
$ readelf -a
WebKitBuild/Release/Source/JavaScriptCore/llint/.libs/libjavascriptcoregtk_3_0_la-LLIntSlowPaths.o
| grep getHostCall
00000000010e 004c00000002 R_X86_64_PC32 0000000000000000
getHostCallReturnValue - 4
00000000c395 004c00000002 R_X86_64_PC32 0000000000000000
getHostCallReturnValue - 4
76: 0000000000000000 0 NOTYPE GLOBAL HIDDEN UND
getHostCallReturnValue
$ readelf -a WebKitBuild/Release/.libs/libjavascriptcoregtk-3.0.so | grep
getHostCall
2034: 0000000000119f60 0 NOTYPE LOCAL HIDDEN 13
getHostCallReturnValue
2035: 0000000000119f70 27 FUNC LOCAL HIDDEN 13
getHostCallReturnValueWit
$ readelf -a WebKitBuild/Release/.libs/libjavascriptcoregtk-3.0.so | grep PC32
$
I can only conclude that gold is not doing its job correctly. What do you
think?
I apologize for not attaching a test case, but the cases in which this bug hits
are sufficiently strange that I don't know how to reduce it. However you can
reproduce it directly if you check out WebKit from git, then:
CPPFLAGS='-DENABLE_DFG_JIT=0' Tools/Scripts/build-jsc --gtk --debug
$ gcc --version
gcc (Debian 4.7.1-2) 4.7.1
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ ld --version
GNU gold (GNU Binutils for Debian 2.22) 1.11
Copyright 2011 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
- [Bug gold/14330] New: failure to link global hidden symbol,
wingo at pobox dot com <=
- [Bug gold/14330] failure to link global hidden symbol, wingo at pobox dot com, 2012/07/04
- [Bug gold/14330] failure to link global hidden symbol, wingo at pobox dot com, 2012/07/05
- [Bug gold/14330] failure to link global hidden symbol, ian at airs dot com, 2012/07/09
- [Bug gold/14330] failure to link global hidden symbol, wingo at pobox dot com, 2012/07/09
- [Bug gold/14330] failure to link global hidden symbol, ccoutant at google dot com, 2012/07/09
- [Bug gold/14330] failure to link global hidden symbol, ccoutant at google dot com, 2012/07/09