public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* MIPS / assertion fail or the build error when using --gc-sections and --export-dynamic option
@ 2007-08-23  8:23 Yuji Ogihara
  2007-08-24  3:50 ` David Daney
  0 siblings, 1 reply; 3+ messages in thread
From: Yuji Ogihara @ 2007-08-23  8:23 UTC (permalink / raw)
  To: binutils; +Cc: 'Yuji Ogihara', Satoru.Ueda

Dear binutils experts.

I am using the MIPS cross toolchain as follows.

+ binutils 2.18.50.20070819
  - configured/builded with
    --host=i686-pc-linux-gnu 
    --target=mips-xxx-linux 
    --build=i686-pc-linux-gnu 

(Is this the latest version in main CVS repository ?)

+ gcc 4.1.1
  - configured/builded with
     --host=mips-xxx-linux 
     --build=i686-pc-linux-gnu 
     --with-arch=mips2 

I found the several cases that the linker may outputs the "assertion fail"
messages,
or cause the build error when using the --gc-sections and --export-dynamic
option
at the same time.

Would you please give me the information 
that this is the known issue, or limitation, or 
the something wrong with me.

Followings are the testcases and the descriptions.

* Common
---------
  + This may cause when using the --gc-sections and --export-dynamic option 
    at the same time.
    Only one of those options does not cause it , for every testcases below.

  + main function
    The testcases below uses the main function which do nothing as follows.

/* main.c */
int main(void)
{
  return 0 ;
}

* Testcase #1
--------------
  Linking main with libc_p.a or libc.a in glibc cause the output of the
assertion fail
  message as follows, even the executable is created with no error.

  # mips-xxx-linux-gcc -o main main.c -lc_p -Wl,--gc-sections
-Wl,--export-dynamic
  ..ld: BFD (GNU Binutils) 2.18.50.20070819 assertion fail
../../bfd/elfxx-mips.c:10310

* Testcase #2
--------------
  This case can be produced without linking the glibc archives.

  + Prepare the following 2 source codes which implements , 

    1) #N functions

/* t1.c */
void func1() { }
void func2() { }
...
void funcN() {}

    2) One function which call every N functions in 1) (t1.c) above.

/* t2.c */
extern void func1() ;
extern void func2() ;
..
extern void funcN() ;

void funcXXX(void) {
  func1() ;
  func2() ;
  ..
  funcN() ;
}

  + Compilation every sources with -ffunction-sections option.

    # mips-xxx-linux-gcc -ffunction-sections -c -o main.o main.c
    # mips-xxx-linux-gcc -ffunction-sections -c -o t1.o t1.c
    # mips-xxx-linux-gcc -ffunction-sections -c -o t2.o t2.c

  + Linking with --gc-sections and --export-dynamic options.

    # mips-xxx-linux-gcc -Wl,--gc-sections -Wl,--export-dynamic -o main
main.o t1.o t2.o

  - Case 2-1 : N=1
  ----------------
    This is the simplest case.
    Linking completes but may assertion fails appears.

/* main.c */
int main(void)
{
  return 0 ;
}

/* t1.c */
void func1() { }

/* t2.c */
extern void func1() ;
void func_XXX(void) {
  func1() ;
}

    # mips-xxx-linux-gcc -Wl,--gc-sections -Wl,--export-dynamic -o main
main.o t1.o t2.o
    ..ld: BFD (GNU Binutils) 2.18.50.20070819 assertion fail
../../bfd/elfxx-mips.c:10310
    ..ld: BFD (GNU Binutils) 2.18.50.20070819 assertion fail
../../bfd/elfxx-mips.c:2535
    ..ld: BFD (GNU Binutils) 2.18.50.20070819 assertion fail
../../bfd/elfxx-mips.c:2535
    #

  - Case 2-2 : N=10000
  ----------------------
    This is the case for many functions (symbols) .   
    Not only the assertion fail at the case below ,but the linker outputs
    "relocation truncated to fit:" and finally build fails.

    # mips-xxx-linux-gcc -Wl,--gc-sections -Wl,--export-dynamic -o main
main.o t1.o t2.o

    ../ld: BFD (GNU Binutils) 2.18.50.20070819 assertion fail
../../bfd/elfxx-mips.c:10310
    ..
    < several assertion fails >
    ..
    ..target/usr/lib/crt1.o: In function `__start':
    (.text+0x38): relocation truncated to fit: R_MIPS_GOT16 against
`__libc_csu_fini'
    ../ld: BFD (GNU Binutils) 2.18.50.20070819 assertion fail
../../bfd/elfxx-mips.c:2535
    ../target/usr/lib/crt1.o: In function `__start':
    (.text+0x48): relocation truncated to fit: R_MIPS_CALL16 against
`__libc_start_main@@GLIBC_2.0'
    ../ld: BFD (GNU Binutils) 2.18.50.20070819 assertion fail
../../bfd/elfxx-mips.c:2535
 
../target/usr/lib/crti.o:/home/takekin/rpmdir/BUILD/glibc-2.5/objdir/csu/crt
i.S:19: 
    relocation truncated to fit: R_MIPS_GOT16 against `__gmon_start__'
    ...
    < More than 10 "relocation truncated to fit:" >
    ...
    crtstuff.c:(.text+0x90): relocation truncated to fit: 
    R_MIPS_GOT16 against `_Jv_RegisterClasses'

    ..
    < several assertion fails >
    ..
    collect2: ld returned 1 exit status

Thanks in advance.

-- Yuji Ogihara

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: MIPS / assertion fail or the build error when using --gc-sections  and --export-dynamic option
  2007-08-23  8:23 MIPS / assertion fail or the build error when using --gc-sections and --export-dynamic option Yuji Ogihara
@ 2007-08-24  3:50 ` David Daney
  2007-08-27 15:17   ` Yuji Ogihara
  0 siblings, 1 reply; 3+ messages in thread
From: David Daney @ 2007-08-24  3:50 UTC (permalink / raw)
  To: Yuji Ogihara; +Cc: binutils, Satoru.Ueda

Yuji Ogihara wrote:
> Dear binutils experts.
> 
> I am using the MIPS cross toolchain as follows.
> 
> + binutils 2.18.50.20070819
>   - configured/builded with
>     --host=i686-pc-linux-gnu 
>     --target=mips-xxx-linux 
>     --build=i686-pc-linux-gnu 
> 
> (Is this the latest version in main CVS repository ?)
> 
> + gcc 4.1.1
>   - configured/builded with
>      --host=mips-xxx-linux 
>      --build=i686-pc-linux-gnu 
>      --with-arch=mips2 
> 
> I found the several cases that the linker may outputs the "assertion fail"
> messages,

That is not good.

> or cause the build error when using the --gc-sections and --export-dynamic
> option
> at the same time.
> 
> Would you please give me the information 
> that this is the known issue, or limitation, or 
> the something wrong with me.
> 

It does not surprise me that this happens.  I spent quite a bit of 
effort getting --gc-sections working on mipsel-linux, but I never tried 
it in conjunction with --export-dynamic.

Unfortunately I don't know of any alternative to running ld under a 
debugger and figuring out what is going wrong, and then fixing it.

David Daney




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: MIPS / assertion fail or the build error when using --gc-sections and --export-dynamic option
  2007-08-24  3:50 ` David Daney
@ 2007-08-27 15:17   ` Yuji Ogihara
  0 siblings, 0 replies; 3+ messages in thread
From: Yuji Ogihara @ 2007-08-27 15:17 UTC (permalink / raw)
  To: binutils; +Cc: Satoru.Ueda, 'Yuji Ogihara'

Hello binutils experts.

It seems that the mips_elf_sort_hash_table() called from the
_bfd_mips_elf_final_link() contain the symbol information which
should be sweeped by --gc-sections ,
only when this optionis used in conjunction with 
--export-dynamic.

Following may be  the patch to fix this, and I checked that
the testcases specified by the previous Emails were successfully 
completed , without any assertion fail output or any errors.

I don't think this patch is the correct, real way to fix this due to 
the following reasons.

First,  I do not check other cases or run any tests like "make check" .
Second, I am not familiar with the design of the MIPS binutils.

This may be only one of the information to help the further investigation
to fix this.

Thanks in advance.

-- Yuji

--- binutils-2.18.50.org/bfd/elfxx-mips.c	2007-08-14
06:16:38.000000000 +0900
+++ binutils-2.18.50/bfd/elfxx-mips.c	2007-08-27 18:10:59.118275200 +0900
@@ -3324,6 +3324,9 @@ mips_elf_resolve_final_got_entry (void *
  	     || h->root.root.type == bfd_link_hash_warning)
 	h = (struct mips_elf_link_hash_entry *) h->root.root.u.i.link;
 
+      if (h->root.root.u.def.section->flags & SEC_EXCLUDE) {
+	h->root.other = STV_HIDDEN | (h->root.other & ~ELF_ST_VISIBILITY
(-1)) ;
+      }
       if (entry->d.h == h)
 	return 1;


> CC: binutils@sourceware.org; Satoru.Ueda@jp.sony.com
> 件名: Re: MIPS / assertion fail or the build error when using 
> --gc-sections and --export-dynamic option
> 
> Yuji Ogihara wrote:
> > Dear binutils experts.
> > 
> > I am using the MIPS cross toolchain as follows.
> > 
> > + binutils 2.18.50.20070819
> >   - configured/builded with
> >     --host=i686-pc-linux-gnu 
> >     --target=mips-xxx-linux 
> >     --build=i686-pc-linux-gnu
> > 
> > (Is this the latest version in main CVS repository ?)
> > 
> > + gcc 4.1.1
> >   - configured/builded with
> >      --host=mips-xxx-linux 
> >      --build=i686-pc-linux-gnu 
> >      --with-arch=mips2
> > 
> > I found the several cases that the linker may outputs the 
> "assertion fail"
> > messages,
> 
> That is not good.
> 
> > or cause the build error when using the --gc-sections and 
> > --export-dynamic option at the same time.
> > 
> > Would you please give me the information that this is the 
> known issue, 
> > or limitation, or the something wrong with me.
> > 
> 
> It does not surprise me that this happens.  I spent quite a 
> bit of effort getting --gc-sections working on mipsel-linux, 
> but I never tried it in conjunction with --export-dynamic.
> 
> Unfortunately I don't know of any alternative to running ld 
> under a debugger and figuring out what is going wrong, and 
> then fixing it.
> 
> David Daney

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-08-27  9:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-23  8:23 MIPS / assertion fail or the build error when using --gc-sections and --export-dynamic option Yuji Ogihara
2007-08-24  3:50 ` David Daney
2007-08-27 15:17   ` Yuji Ogihara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).