Hi List, I think that the problem is the same of this:
http://gcc.gnu.org/ml/gcc-patches/2008-06/msg00094.html Starting form the patch proposed in the post above, I produced (with few changes) the attached patch for gcc.4.3.1. ciao luigi On dom, 2008-06-22 at 12:24 +0200, Luigi 'Comio' Mantellini wrote: > Dear All, > > I'm trying to compile the e2fs progs for a coldfire 547x cpu. I'm using the > gcc4.3.1 compiler. > I have this error and I don't understand what can be wrong: > > make[5]: Entering directory > `/mnt/devel/openwrt/OpenWRT.git/build_dir/m68k/e2fsprogs-1.39' > make[6]: Entering directory > `/mnt/devel/openwrt/OpenWRT.git/build_dir/m68k/e2fsprogs-1.39' > make[6]: `lib/ext2fs/ext2_types.h' is up to date. > make[6]: Leaving directory > `/mnt/devel/openwrt/OpenWRT.git/build_dir/m68k/e2fsprogs-1.39' > make[6]: Entering directory > `/mnt/devel/openwrt/OpenWRT.git/build_dir/m68k/e2fsprogs-1.39' > make[6]: `lib/blkid/blkid_types.h' is up to date. > make[6]: Leaving directory > `/mnt/devel/openwrt/OpenWRT.git/build_dir/m68k/e2fsprogs-1.39' > make[6]: Entering directory > `/mnt/devel/openwrt/OpenWRT.git/build_dir/m68k/e2fsprogs-1.39' > make[6]: `lib/uuid/uuid_types.h' is up to date. > make[6]: Leaving directory > `/mnt/devel/openwrt/OpenWRT.git/build_dir/m68k/e2fsprogs-1.39' > making all in e2fsck > make[6]: Entering directory > `/mnt/devel/openwrt/OpenWRT.git/build_dir/m68k/e2fsprogs-1.39/e2fsck' > LD e2fsck.static > /mnt/devel/openwrt/OpenWRT.git/staging_dir/toolchain-m68k_gcc4.3.1/lib/gcc/m68k-linux-uclibc/4.3.1/libgcc.a(_eqdf2.o): > In function `__eqdf2': > /mnt/devel/openwrt/OpenWRT.git/build_dir/toolchain-m68k_gcc4.3.1/gcc-4.3.1/libgcc/../gcc/config/m68k/lb1sf68.asm:3895: > relocation truncated to fit: R_68K_PC16 against symbol `__cmpdf2_internal' > defined in .text section in > /mnt/devel/openwrt/OpenWRT.git/staging_dir/toolchain-m68k_gcc4.3.1/lib/gcc/m68k-linux-uclibc/4.3.1/libgcc.a(_double.o) > /mnt/devel/openwrt/OpenWRT.git/staging_dir/toolchain-m68k_gcc4.3.1/lib/gcc/m68k-linux-uclibc/4.3.1/libgcc.a(_nedf2.o): > In function `__nedf2': > /mnt/devel/openwrt/OpenWRT.git/build_dir/toolchain-m68k_gcc4.3.1/gcc-4.3.1/libgcc/../gcc/config/m68k/lb1sf68.asm:3911: > relocation truncated to fit: R_68K_PC16 against symbol `__cmpdf2_internal' > defined in .text section in > /mnt/devel/openwrt/OpenWRT.git/staging_dir/toolchain-m68k_gcc4.3.1/lib/gcc/m68k-linux-uclibc/4.3.1/libgcc.a(_double.o) > /mnt/devel/openwrt/OpenWRT.git/staging_dir/toolchain-m68k_gcc4.3.1/lib/gcc/m68k-linux-uclibc/4.3.1/libgcc.a(_gedf2.o): > In function `__gedf2': > /mnt/devel/openwrt/OpenWRT.git/build_dir/toolchain-m68k_gcc4.3.1/gcc-4.3.1/libgcc/../gcc/config/m68k/lb1sf68.asm:3943: > relocation truncated to fit: R_68K_PC16 against symbol `__cmpdf2_internal' > defined in .text section in > /mnt/devel/openwrt/OpenWRT.git/staging_dir/toolchain-m68k_gcc4.3.1/lib/gcc/m68k-linux-uclibc/4.3.1/libgcc.a(_double.o) > /mnt/devel/openwrt/OpenWRT.git/staging_dir/toolchain-m68k_gcc4.3.1/lib/gcc/m68k-linux-uclibc/4.3.1/libgcc.a(_ltdf2.o): > In function `__ltdf2': > /mnt/devel/openwrt/OpenWRT.git/build_dir/toolchain-m68k_gcc4.3.1/gcc-4.3.1/libgcc/../gcc/config/m68k/lb1sf68.asm:3959: > relocation truncated to fit: R_68K_PC16 against symbol `__cmpdf2_internal' > defined in .text section in > /mnt/devel/openwrt/OpenWRT.git/staging_dir/toolchain-m68k_gcc4.3.1/lib/gcc/m68k-linux-uclibc/4.3.1/libgcc.a(_double.o) > collect2: ld returned 1 exit status > make[6]: *** [e2fsck.static] Error 1 > make[6]: Leaving directory > `/mnt/devel/openwrt/OpenWRT.git/build_dir/m68k/e2fsprogs-1.39/e2fsck' > make[5]: *** [all-progs-recursive] Error 1 > make[5]: Leaving directory > `/mnt/devel/openwrt/OpenWRT.git/build_dir/m68k/e2fsprogs-1.39' > make[4]: *** [all] Error 2 > make[4]: Leaving directory > `/mnt/devel/openwrt/OpenWRT.git/build_dir/m68k/e2fsprogs-1.39' > make[3]: *** > [/mnt/devel/openwrt/OpenWRT.git/build_dir/m68k/e2fsprogs-1.39/.built] Error 2 > make[3]: Leaving directory `/mnt/devel/openwrt/OpenWRT.git/package/e2fsprogs' > make[2]: *** [package/e2fsprogs/compile] Error 2 > make[2]: Leaving directory `/mnt/devel/openwrt/OpenWRT.git' > make[1]: *** > [/mnt/devel/openwrt/OpenWRT.git/staging_dir/m68k/stamp/.package_compile] > Error 2 > make[1]: Leaving directory `/mnt/devel/openwrt/OpenWRT.git' > make: *** [world] Error 2 > > To complete the picture, I'm using an OpenWRT building-environment with some > patch in order to compile Gcc4.3.1 ( > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36559), binutils 2.18 and > uClibc0.9.29. If needed, I can provide any additional information. > > Any ideas? What can I check to understand and resolve this issue? > > Thanks in advance for any suggestion. > > > luigi > -- ______ Luigi Mantellini .'______'. R&D - Software (.' '.) Industrie Dial Face S.p.A. ( :=----=: ) Via Canzo, 4 ('.______.') 20068 Peschiera Borromeo (MI), Italy '.______.' Tel.: +39 02 5167 2813 Fax: +39 02 5167 2459 Ind. Dial Face Email: [EMAIL PROTECTED] www.idf-hit.com GPG fingerprint: 3DD1 7B71 FBDF 6376 1B4A B003 175F E979 907E 1650
2008-06-03 Joseph Myers <[EMAIL PROTECTED]> Maxim Kuvyrkov <[EMAIL PROTECTED]> * config/m68k/m68k.opt (mxgot): New option. * config/m68k/m68k.c (legitimize_pic_address): Handle -mxgot. (m68k_output_addr_const_extra): New. * config/m68k/m68k.h (OUTPUT_ADDR_CONST_EXTRA): New. * config/m68k/m68k-protos.h (m68k_output_addr_const_extra): Declare. * config/m68k/m68k.md (UNSPEC_GOTOFF): Define. * doc/invoke.texi (M680x0 Options): Document -mxgot. testsuite: 2008-06-03 Joseph Myers <[EMAIL PROTECTED]> Maxim Kuvyrkov <[EMAIL PROTECTED]> * gcc.target/m68k/xgot-1.c: New test. Index: gcc-4.3.1/gcc/doc/invoke.texi =================================================================== --- gcc-4.3.1/gcc/doc/invoke.texi (revision 136283) +++ gcc-4.3.1/gcc/doc/invoke.texi (working copy) @@ -607,7 +607,8 @@ -mnobitfield -mrtd -mno-rtd -mdiv -mno-div -mshort @gol -mno-short -mhard-float -m68881 -msoft-float -mpcrel @gol -malign-int -mstrict-align -msep-data -mno-sep-data @gol --mshared-library-id=n -mid-shared-library -mno-id-shared-library} +-mshared-library-id=n -mid-shared-library -mno-id-shared-library @gol +-mxgot -mno-xgot} @emph{M68hc1x Options} @gccoptlist{-m6811 -m6812 -m68hc11 -m68hc12 -m68hcs12 @gol @@ -11776,6 +11777,38 @@ other values will force the allocation of that number to the current library but is no more space or time efficient than omitting this option. [EMAIL PROTECTED] -mxgot [EMAIL PROTECTED] -mno-xgot [EMAIL PROTECTED] mxgot [EMAIL PROTECTED] mno-xgot +When generating position-independent code for ColdFire, generate code +that works if the GOT has more than 8192 entries. This code is +larger and slower than code generated without this option. On M680x0 +processors, this option is not needed; @option{-fPIC} suffices. + +GCC normally uses a single instruction to load values from the [EMAIL PROTECTED] +While this is relatively efficient, it only works if the GOT +is smaller than about 64k. Anything larger causes the linker +to report an error such as: + [EMAIL PROTECTED] relocation truncated to fit (ColdFire) [EMAIL PROTECTED] +relocation truncated to fit: R_68K_GOT16O foobar [EMAIL PROTECTED] smallexample + +If this happens, you should recompile your code with @option{-mxgot}. +It should then work with very large GOTs. However, code generated with [EMAIL PROTECTED] is less efficient, since it takes 4 instructions to fetch +the value of a global symbol. + +Note that some linkers, including newer versions of the GNU linker, +can create multiple GOTs and sort GOT entries. If you have such a linker, +you should only need to use @option{-mxgot} when compiling a single +object file that accesses more than 8192 GOT entries. Very few do. + +These options have no effect unless GCC is generating +position-independent code. + @end table @node M68hc1x Options Index: gcc-4.3.1/gcc/testsuite/gcc.target/m68k/xgot-1.c =================================================================== --- gcc-4.3.1/gcc/testsuite/gcc.target/m68k/xgot-1.c (revision 0) +++ gcc-4.3.1/gcc/testsuite/gcc.target/m68k/xgot-1.c (revision 0) @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-fpic -mxgot" } */ +/* { dg-final { scan-assembler "[EMAIL PROTECTED],\%\[ad\]\[0-7\]" } } */ + +extern int foo; + +int +bar (void) +{ + return foo; +} Index: gcc-4.3.1/gcc/config/m68k/m68k.md =================================================================== --- gcc-4.3.1/gcc/config/m68k/m68k.md.orig 2007-11-06 17:52:17.000000000 +0100 +++ gcc-4.3.1/gcc/config/m68k/m68k.md 2008-06-22 13:15:38.000000000 +0200 @@ -115,6 +115,8 @@ (UNSPEC_COS 2) (UNSPEC_GOT 3) (UNSPEC_IB 4) + (UNSPEC_TIE 5) + (UNSPEC_GOTOFF 6) ]) ;; UNSPEC_VOLATILE usage: =================================================================== --- gcc-4.3.1/gcc/config/m68k/m68k-protos.h (revision 136283) +++ gcc-4.3.1/gcc/config/m68k/m68k-protos.h (working copy) @@ -50,6 +50,7 @@ extern int standard_68881_constant_p (rtx); extern void print_operand_address (FILE *, rtx); extern void print_operand (FILE *, rtx, int); +extern bool m68k_output_addr_const_extra (FILE *, rtx); extern void notice_update_cc (rtx, rtx); extern bool m68k_legitimate_base_reg_p (rtx, bool); extern bool m68k_legitimate_index_reg_p (rtx, bool); Index: gcc-4.3.1/gcc/config/m68k/m68k.opt =================================================================== --- gcc-4.3.1/gcc/config/m68k/m68k.opt (revision 136283) +++ /m68k.opt (working copy) @@ -178,3 +178,7 @@ mtune= Target RejectNegative Joined Tune for the specified target CPU or architecture + +mxgot +Target Report Mask(XGOT) +Support more than 8192 GOT entries on ColdFire --- gcc-4.3.1/gcc/config/m68k/m68k.c.orig 2007-11-06 17:52:17.000000000 +0100 +++ gcc-4.3.1/gcc/config/m68k/m68k.c 2008-06-22 13:24:03.000000000 +0200 @@ -2029,9 +2029,32 @@ { gcc_assert (reg); + + if (TARGET_COLDFIRE && TARGET_XGOT) + /* When compiling with -mxgot switch the code for the above + example will look like this: + + movel a5, a0 + addl [EMAIL PROTECTED], a0 + movel a0@, a0 + movel #12345, a0@ */ + { + rtx pic_offset; + + /* Wrap ORIG in UNSPEC_GOTOFF to tip m68k_output_addr_const_extra + to put @GOT after reference. */ + pic_offset = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, orig), + UNSPEC_GOTOFF); + pic_offset = gen_rtx_CONST (Pmode, pic_offset); + emit_move_insn (reg, pic_offset); + emit_insn (gen_addsi3 (reg, reg, pic_offset_table_rtx)); + pic_ref = gen_rtx_MEM (Pmode, reg); + } + else pic_ref = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, pic_offset_table_rtx, orig)); + current_function_uses_pic_offset_table = 1; MEM_READONLY_P (pic_ref) = 1; emit_move_insn (reg, pic_ref); @@ -3839,6 +3862,20 @@ } } +/* m68k implementation of OUTPUT_ADDR_CONST_EXTRA. */ + +bool +m68k_output_addr_const_extra (FILE *file, rtx x) +{ + if (GET_CODE (x) != UNSPEC || XINT (x, 1) != UNSPEC_GOTOFF) + return false; + + output_addr_const (file, XVECEXP (x, 0, 0)); + /* ??? What is the non-MOTOROLA syntax? */ + fputs ("@GOT", file); + return true; +} + /* A C compound statement to output to stdio stream STREAM the assembler syntax for an instruction operand that is a memory Index: gcc-4.3.1/gcc/config/m68k/m68k.h =================================================================== --- gcc-4.3.1/gcc/config/m68k/m68k.h (revision 136283) +++ gcc-4.3.1/gcc/config/m68k/m68k.h (working copy) @@ -1079,6 +1079,12 @@ #define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR) +#define OUTPUT_ADDR_CONST_EXTRA(FILE, X, FAIL) \ +do { \ + if (! m68k_output_addr_const_extra (FILE, (X))) \ + goto FAIL; \ +} while (0); + /* Values used in the MICROARCH argument to M68K_DEVICE. */ enum uarch_type {