NetBSD Problem Report #47061
From apb@apb.cequrux.com Fri Oct 12 10:17:54 2012
Return-Path: <apb@apb.cequrux.com>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
by www.NetBSD.org (Postfix) with ESMTP id EB05B63B8DB
for <gnats-bugs@gnats.NetBSD.org>; Fri, 12 Oct 2012 10:17:53 +0000 (UTC)
Message-Id: <20121012101750.97D6D3B6098@apb-laptoy.apb.alt.za>
Date: Fri, 12 Oct 2012 10:17:50 +0000 (UTC)
From: apb@cequrux.com
To: gnats-bugs@gnats.NetBSD.org
Subject: ld.elf_so does not understand R_386_TLS_TPOFF32
X-Send-Pr-Version: 3.95
>Number: 47061
>Category: port-i386
>Synopsis: ld.elf_so does not understand R_386_TLS_TPOFF32
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: port-i386-maintainer
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Oct 12 10:20:00 +0000 2012
>Closed-Date: Wed Nov 07 08:12:19 +0000 2012
>Last-Modified: Sun Nov 18 18:55:04 +0000 2012
>Originator: Alan Barrett
>Release: NetBSD 6.99.11
>Organization:
Not much
>Environment:
System: NetBSD 6.99.11 i386
Architecture: i386
Machine: i386
>Description:
The base system's gcc-4.5 compiler and toolchain in NetBSD-current/i386
appears to produce relocation entries that ld.elf_so can't handle.
On a current i386 system, when I attempt to build pkgsrc/lang/gcc47 with
the "gcc-go" option, I get this error while the "go" compiler is being
built:
.../pkgsrc/lang/gcc47/work/build/./gcc/go1: Unsupported relocation type 37 in non-PLT relocations
That message appears to be printed by ld.elf_so. Relocation type 37 is
R_386_TLS_TPOFF32.
According to objdump, the go1 executable contains these relocation
entries of that type:
$ objdump -R build/./gcc/go1 | grep TLS
08bd8a48 R_386_TLS_TPOFF32 _ZSt15__once_callable
08bd8bec R_386_TLS_TPOFF32 _ZSt11__once_call
$ objdump --demangle -R build/./gcc/go1 | grep TLS
08bd8a48 R_386_TLS_TPOFF32 std::__once_callable
08bd8bec R_386_TLS_TPOFF32 std::__once_call
Those symbols appear to come from the new libc++11 that comes with
gcc-4.7, and that is statically linked into the go1 executable The
library is built with "#define _GLIBCXX_HAVE_TLS 1". Here are the
references to __once_call and __once_callable in the library source:
gcc-4.7.0/libstdc++-v3/src/c++11/mutex.cc:
42-_GLIBCXX_BEGIN_NAMESPACE_VERSION
43-
44-#ifdef _GLIBCXX_HAVE_TLS
45: __thread void* __once_callable;
46: __thread void (*__once_call)();
47-#else
48- // Explicit instantiation due to -fno-implicit-instantiation.
49- template class function<void()>;
--
77- void __once_proxy()
78- {
79-#ifndef _GLIBCXX_HAVE_TLS
80: function<void()> __once_call = std::move(__once_functor);
81- if (unique_lock<mutex>* __lock = __get_once_functor_lock_ptr())
82- {
83- // caller is using new ABI and provided lock ptr
--
87- else
88- __get_once_functor_lock().unlock(); // global lock
89-#endif
90: __once_call();
91- }
92- }
93-
>How-To-Repeat:
On a NetBSD/i386 system with a recent pkgsrc:
cd pkgsrc/lang/gcc47
make PKG_OPTIONS.gcc47=gcc-go
After a while, the build will fail with a message like this:
.../pkgsrc/lang/gcc47/work/build/./gcc/go1: Unsupported relocation type 37 in non-PLT relocations
>Fix:
Add support for relocation type 37 (R_386_TLS_TPOFF32) to ld.elf_so.
>Release-Note:
>Audit-Trail:
From: Nick Hudson <skrll@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: port-i386-maintainer@netbsd.org,
gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org
Subject: Re: port-i386/47061: ld.elf_so does not understand R_386_TLS_TPOFF32
Date: Fri, 19 Oct 2012 11:45:25 +0100
--Boundary-00=_F9SgQ/Zj+/MZhXf
Content-Type: text/plain;
charset="iso-8859-15"
Content-Transfer-Encoding: 7bit
On Friday 12 October 2012 11:20:00 apb@cequrux.com wrote:
> >Number: 47061
> >Category: port-i386
> >Synopsis: ld.elf_so does not understand R_386_TLS_TPOFF32
The attached patch adds support and adds in addend (presumably always zero)
for R_386_TLS_TPOFF.
It's untested.
Nick
--Boundary-00=_F9SgQ/Zj+/MZhXf
Content-Type: text/x-patch;
charset="iso-8859-1";
name="pr47061.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="pr47061.diff"
Index: libexec/ld.elf_so/arch/i386/mdreloc.c
===================================================================
RCS file: /cvsroot/src/libexec/ld.elf_so/arch/i386/mdreloc.c,v
retrieving revision 1.34
diff -u -p -u -r1.34 mdreloc.c
--- libexec/ld.elf_so/arch/i386/mdreloc.c 25 Mar 2011 18:07:05 -0000 1.34
+++ libexec/ld.elf_so/arch/i386/mdreloc.c 19 Oct 2012 10:11:18 -0000
@@ -121,6 +121,7 @@ _rtld_relocate_nonplt_objects(Obj_Entry
break;
case R_TYPE(TLS_TPOFF):
+ case R_TYPE(TLS_TPOFF32):
def = _rtld_find_symdef(symnum, obj, &defobj, false);
if (def == NULL)
return -1;
@@ -129,9 +130,13 @@ _rtld_relocate_nonplt_objects(Obj_Entry
_rtld_tls_offset_allocate(obj))
return -1;
- *where = (Elf_Addr)(def->st_value - defobj->tlsoffset);
+ if (ELF_R_TYPE(rel->r_info) == R_TYPE(TLS_TPOFF))
+ *where += (Elf_Addr)(def->st_value - defobj->tlsoffset);
+ else
+ *where += (Elf_Addr)(defobj->tlsoffset - def->st_value);
- rdbg(("TLS_TPOFF %s in %s --> %p",
+ rdbg(("TLS_TPOFF%s %s in %s --> %p",
+ ELF_R_TYPE(rel->r_info) == R_TYPE(TLS_TPOFF) ? "" : "32",
obj->strtab + obj->symtab[symnum].st_name,
obj->path, (void *)*where));
break;
--Boundary-00=_F9SgQ/Zj+/MZhXf--
From: "Alan Barrett" <apb@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/47061 CVS commit: src/libexec/ld.elf_so/arch/i386
Date: Wed, 7 Nov 2012 07:24:47 +0000
Module Name: src
Committed By: apb
Date: Wed Nov 7 07:24:46 UTC 2012
Modified Files:
src/libexec/ld.elf_so/arch/i386: mdreloc.c
Log Message:
Add support for R_386_TLS_TPOFF32. This patch was created by
Nick Hudson for PR 47061.
To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/libexec/ld.elf_so/arch/i386/mdreloc.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: skrll@NetBSD.org
State-Changed-When: Wed, 07 Nov 2012 08:12:19 +0000
State-Changed-Why:
Fix got committed
From: "SAITOH Masanobu" <msaitoh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/47061 CVS commit: [netbsd-6] src/libexec/ld.elf_so/arch/i386
Date: Sun, 18 Nov 2012 18:50:57 +0000
Module Name: src
Committed By: msaitoh
Date: Sun Nov 18 18:50:56 UTC 2012
Modified Files:
src/libexec/ld.elf_so/arch/i386 [netbsd-6]: mdreloc.c
Log Message:
Pull up following revision(s) (requested by apb in ticket #667):
libexec/ld.elf_so/arch/i386/mdreloc.c: revision 1.35
Add support in ld.elf_so for relocation type R_386_TLS_TPOFF32.
Fixes PR#47061.
To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.34.6.1 src/libexec/ld.elf_so/arch/i386/mdreloc.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.