This is the mail archive of the binutils@sourceware.org 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]

Re: MIPS -gc-sections broken?


Hi,

From: Nick Clifton <nickc@redhat.com>
> > I've tried latest binutils-2.19.51.0.8 and gcc-4.5-20090604, and I still
> > have the same problem...
> 
> > Humm, I'm using mips2 insn with o32.
> 
> Well I added the -mabi=32 switch to my command line to select the o32 
> ABI but the link still works. :-(
> 
> Exactly how was the toolchain that you are using configured ?

binutils-2.19.51.0.8 is configured as:
+ ../configure --host=i686-pc-linux-gnu --target=mips-unknown-linux --build=i686-pc-linux-gnu --prefix=/usr/local/mips-unknown-linux --disable-nls --prefix=/usr/local/mips-unknown-linux/devel '--program-transform-name=s,^,mips-unknown-linux-dev-,' --with-sysroot=/usr/local/mips-unknown-linux/devel/target

and gcc-4.5-20090604 is configured as:
+ ../configure --host=i686-pc-linux-gnu --target=mips-unknown-linux --build=i686-pc-linux-gnu --prefix=/usr/local/mips-unknown-linux --disable-nls --prefix=/usr/local/mips-unknown-linux/devel '--program-transform-name=s,^,mips-unknown-linux-dev-,' --with-arch=mips2 --with-local-prefix=/usr/local/mips-unknown-linux/devel/target --with-sysroot=/usr/local/mips-unknown-linux/devel/target --with-gmp=/usr/local/mips-unknown-linux/devel --with-mpfr=/usr/local/mips-unknown-linux/devel '--with-pkgversion=20090604' --enable-__cxa_atexit --enable-languages=c,c++ --disable-multilib --enable-threads=posix --enable-shared --enable-symvers=gnu --with-gxx-include-dir=/usr/include/c++/4.5.0

> One thing that you might like to try is adding the -fno-common to your 
> gcc command line.  Perhaps the problem is associated with the garbage 
> collection of common symbols.

Yes, the symbol in question is common symbol, and the phenomenon is gone
if doing the following:

   - add -fno-common
   - change size of symbol less than 8 byte, (and will be located into
     .sbss not .bss)
   - change scope to LOCAL by adding static keyword
   - change symbol to not common symbol by initalizing, to value
     other than zero

You have mentioned that the symbol: gbl_common is swept away in your
environment, do you have separate section against gbl_common symbol?
Since it is common symbol, there is no section against gbl_common 
symbol in my environment, and since it is of type GLOBAL OBJECT, it
is left in the final executable binary, causing the problem.

> > binutils/bfd/elfxx-mips.c:_bfd_mips_elf_gc_sweep_hook() is currently
> > #if 0 'ed, however, other arch, such as arm, ppc reduces refcont for
> > plt. MIPS does not have plt count, but while sweeping away section 
> > .text.func_not_used and .rel.text.func_not_used, don't we need some
> > handling of relocation entries in these sections?
> 
> Possibly, although this comment in the code would seem to suggest that 
> the MIPS toolchains are not really designed to support this kind of thing:
> 
>     /* ??? It would seem that the existing MIPS code does no sort
>             of reference counting or whatnot on its GOT and PLT entries,
> 	   so it is not possible to garbage collect them at this time.
> 
> Maybe the issue is with the loader that you are using to start the 
> execution of your program.  Perhaps loaders for MIPS executables need to 
> be able to ignore relocations for discarded symbols ?

One solution could be modifying the loader to check such a symbol,
however, it would result in slower startup time... I'd appreciate if
pointer to information regarding how section is swept in binutils is
supplied.


Best Regards,

----
(Hiroki Kaminaga)
t


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