This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
MIPS / assertion fail or the build error when using --gc-sections and --export-dynamic option
- From: "Yuji Ogihara" <Yuji dot Ogihara at jp dot sony dot com>
- To: <binutils at sourceware dot org>
- Cc: "'Yuji Ogihara'" <Yuji dot Ogihara at jp dot sony dot com>, <Satoru dot Ueda at jp dot sony dot com>
- Date: Thu, 23 Aug 2007 13:36:13 +0900
- Subject: MIPS / assertion fail or the build error when using --gc-sections and --export-dynamic option
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