Bug 32465 - [4.3 Regression] Linking 64-bit libgcj.so fails on Solaris 10/x86: non-PIC code despite -fPIC
Summary: [4.3 Regression] Linking 64-bit libgcj.so fails on Solaris 10/x86: non-PIC co...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libgcj (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Rainer Orth
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-22 17:42 UTC by Rainer Orth
Modified: 2007-07-16 17:10 UTC (History)
2 users (show)

See Also:
Host: i386-pc-solaris2.10
Target: i386-pc-solaris2.10
Build: i386-pc-solaris2.10
Known to work:
Known to fail:
Last reconfirmed: 2007-07-12 14:27:59


Attachments
runtime.s built with gcj 4.2.1 20070611 (59.14 KB, application/octet-stream)
2007-07-03 18:10 UTC, Rainer Orth
Details
runtime.s built with gcj 4.3.0 20070618 (59.57 KB, application/octet-stream)
2007-07-03 18:11 UTC, Rainer Orth
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rainer Orth 2007-06-22 17:42:54 UTC
A mainline bootstrap as of 20070618 on Solaris 10/x86 with the bundled gas
2.15 and my patch to support boehm-gc for x86-64

     http://gcc.gnu.org/ml/java-patches/2007-q2/msg00330.html

fails when linking the 64-bit libgcj:

[ca. 6800 lines omitted]
gnu::gcj::runtime::FinalizerThread::finalizer_ready    0x602     	gnu/gcj/.libs/runtime.o
ld: fatal: relocations remain against allocatable but non-writable sections
collect2: ld returned 1 exit status

I've checked for some of the affected object files that they have been
built with -fPIC, nonetheless text relocations remain, thus breaking the
link.

Environment:
System: SunOS erebus 5.11 snv_60 i86pc i386 i86pc
Architecture: i86pc

	
host: i386-pc-solaris2.10
build: i386-pc-solaris2.10
target: i386-pc-solaris2.10
configured with: /vol/gcc/src/gcc/configure --prefix=/vol/gcc --with-local-prefix=/vol/gcc --disable-nls --with-gnu-as --with-as=/usr/sfw/bin/gas --with-gmp=/vol/gcc --with-mpfr=/vol/gcc --enable-languages=c,c++,fortran,java,objc,ada --disable-libmudflap

How-To-Repeat:
Bootstrap mainline as described above.
Comment 1 Rainer Orth 2007-06-22 17:42:54 UTC
Fix:
It is possible to link with -mimpure-text as a workaround.
Comment 2 H.J. Lu 2007-06-22 18:26:42 UTC
On Linux, I got

0000000002e1b960     1 OBJECT  LOCAL  HIDDEN   25 gnu::gcj::runtime::FinalizerThread::finalizer_ready

It looks like assembler/linker on Solaris don't have proper visibility
support.

BTW, the last symbol visibility bug in GNU binutils was fixed on
2006-12-12.
Comment 3 Rainer Orth 2007-06-25 17:38:55 UTC
Subject: Re:  Linking 64-bit libgcj.so fails on Solaris 10/x86: non-PIC code despite -fPIC

hjl at lucon dot org writes:

> ------- Comment #2 from hjl at lucon dot org  2007-06-22 18:26 -------
> On Linux, I got
> 
> 0000000002e1b960     1 OBJECT  LOCAL  HIDDEN   25
> gnu::gcj::runtime::FinalizerThread::finalizer_ready

This is

221554: 0000000003024d80     1 OBJECT  GLOBAL DEFAULT  256 gnu::gcj::runtime::FinalizerThread::finalizer_ready

on Solaris 10.

> It looks like assembler/linker on Solaris don't have proper visibility
> support.

The assembler (gas 2.15 bundled with Solaris) does, but since I'm using the
native linker, gcc/configure.ac disables hidden support.  It should work in
Solaris 10, though.  Due to PR libgcj/32462 (which happens with GNU ld,
too), I haven't tried gas and gld yet.

	Rainer
Comment 4 Rainer Orth 2007-07-03 18:10:42 UTC
Created attachment 13839 [details]
runtime.s built with gcj 4.2.1 20070611
Comment 5 Rainer Orth 2007-07-03 18:11:13 UTC
Created attachment 13840 [details]
runtime.s built with gcj 4.3.0 20070618
Comment 6 Rainer Orth 2007-07-03 18:11:47 UTC
This is a regression from 4.2.1.

I'm uploading the assembler files corresponding to gnu/gcj/.libs/runtime.o and
built with gcj 4.2.1 20070611 and 4.3.0 20070618 for comparison.
Comment 7 Rainer Orth 2007-07-12 10:20:13 UTC
Like PR libgcj/32462, this is also caused by this patch:

2007-04-03  Andrew Haley  <aph@redhat.com>

        * jvgenmain.c (main): Change main to use class$, not class$$.
        (do_mangle_classname): Likewise.
        * class.c (hide): New function.
        (add_field): Hide everything that shouldn't be visible outside a
        DSO.
        (build_static_class_ref): Likewise.
        (build_classdollar_field): Likewise.
        (make_class_data): Likewise.
        (layout_class_method): Likewise.
        * expr.c (special_method_p): New function.

	* class.c (push_class): Don't bogusly guess the source filename.
	* jcf-parse.c (give_name_to_class): Don't set input_location from
	DECL_ARTIFICIAL decls.

Again, the missing visibility support in this configuration causes the problem.

    Rainer
Comment 8 Rainer Orth 2007-07-12 14:27:59 UTC
Mine.  Patch here:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32462#c10
Comment 9 Rainer Orth 2007-07-16 17:07:47 UTC
Subject: Bug 32465

Author: ro
Date: Mon Jul 16 17:07:25 2007
New Revision: 126684

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126684
Log:
	PR target/32462
	PR libgcj/32465
	* class.c (hide): Wrap in HAVE_GAS_HIDDEN.


Modified:
    trunk/gcc/java/ChangeLog
    trunk/gcc/java/class.c

Comment 10 Rainer Orth 2007-07-16 17:10:40 UTC
Fixed for 4.3.