This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

arm-wince-pe-ld: Multiply defined symbols in libgcj


Hello All:

We have made a substantial amount of progress with gcj/libgcj and we now
have some simple Java programs, compiled w/GCJ, running on Wince 3.0.

We have encountered another binutils problem though, this time with ld.
To get test programs working w/arm-wince-pe-gcj, we are currently forced
to build libgcj C++ stuff with -O0.  This in turn is leading to trouble
with multiply defined symbols where there should be none.

Here is what's happening.  Consider java/lang/String.h: The class
definition in the header file for ::java::lang::String contains several
function declarations that include the body of the function, e.g.
class ::java::lang::String : public ::java::lang::Object
{
public:
.
.
jint length () { return count; }
.
.
}

Compiled with -O2, there is no symbol generated for length() - it
apparently gets inlined, which is just fine.  It just doesn't work :-)
Compiled with -O0, the symbol 

00000000 T __ZN4java4lang6String6lengthEv

By itself this should not be a problem because the assembler code
contains the directive

.linkonce discard

Which is exactly what you'd want - The first instance of the function
body is supposed to be linked, the other instances "silently discarded",
according to the documentation.

The trouble is it doesn't work:  On arm-wince-pe, for the following gcj
compile of HelloWorld.java, I see the following:

zetar% arm-wince-pe-gcj -v --main=HelloWorld HelloWorld.java -lgcj -lc -lgcc -lwinsock -lcoredll
.
.
.
/usr/local/wince/lib/gcc-lib/arm-wince-pe/3.3/collect2 -X /usr/local/wince/lib/gcc-lib/arm-wince-pe/3.3/../../../../arm-wince-pe/lib/crt0.o -L/usr/local/wince/
lib/gcc-lib/arm-wince-pe/3.3 -L/usr/local/wince/lib/gcc-lib/arm-wince-pe/3.3/../../../../arm-wince-pe/lib /tmp/ccmCd2Ek.o /tmp/ccuYWv2H.o -lgcj -lc -lgcc -lwins
ock -lcoredll -lgcc -lgcj -lm -lgcc -lc -lgcc
/usr/local/wince/lib/gcc-lib/arm-wince-pe/3.3/../../../../arm-wince-pe/lib/libgcj.a(String.o)(.text+0x4fc): multiple definition of `java::lang::String::length()
'
/usr/local/wince/lib/gcc-lib/arm-wince-pe/3.3/../../../../arm-wince-pe/lib/libgcj.a(prims.o)(.text$_ZN4java4lang6String6lengthEv+0x0): first defined here
/usr/local/wince/lib/gcc-lib/arm-wince-pe/3.3/../../../../arm-wince-pe/lib/libgcj.a(ThreadGroup.o)(.text+0x234): multiple definition of `java::lang::ThreadGroup
::getMaxPriority()'
.
.

My conclusion: the ".linkonce discard" directive is not being honored by
arm-wince-pe-ld.  What should we do about this?  We have been able to get our
initial tests running by compiling with "-Wl,--allow-multiple-definition",
but this can't continue - it's too tacky.  I'd be happy to fix the 
linker and submit a patch if someone could point me to the right place
in the sources..

Thanks in advance
craig vanderborgh
voxware incorporated


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]