If you compile the following code (cut down from crtstuff.c) with -mcmodel=large -fPIC -O2 on a 64 bit x86 target GCC will ICE. There are at least two problems, one in cselib_hash_rtx, and if that is fixed then I get a shared rtx abort. The test case is typedef long unsigned int size_t; typedef void (*func_ptr) (void); static func_ptr __DTOR_LIST__[1] = { (func_ptr) (-1) }; static void __attribute__((used)) __do_global_dtors_aux (void) { extern func_ptr __DTOR_END__[]; size_t dtor_idx = 0; const size_t max_idx = __DTOR_END__ - __DTOR_LIST__ - 1; func_ptr f; while (dtor_idx < max_idx) { f = __DTOR_LIST__[++dtor_idx]; f (); } }
Do you have a testcase to show that -mcmodel=large doesn't work for you?
By testcase, I meant a user application, not crtstuff.c, like # gcc -mcmodel=large foo.c # ./a.out
No, I don't have a user application. I believe the problem was that the user was compiling a program with something like -Wl,--section-start,.text=0x110000000 and because the crt files weren't compiled with -mcmodel=large they couldn't reach the text section. If I compile a simple hello world program with this linker option I get a number of errors about relocations being truncated.
Assuming you have solved crtstuff.c issue, will /usr/lib64/crt1.o work with -Wl,--section-start,.text=0x110000000? Can you try the latest binutils from CVS with [hjl@gnu-6 pr38988]$ cat f.c #include <stdio.h> int main () { printf ("hello\n"); return 0; } [hjl@gnu-6 pr38988]$ gcc f.c -Wl,-Ttext-segment,0x110000000 -fpie -pie -g [hjl@gnu-6 pr38988]$ gdb a.out GNU gdb (GDB) 6.8.50.20081208-cvs (AVX revision 4683) Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-unknown-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... (gdb) b main Breakpoint 1 at 0x110000708: file f.c, line 6. (gdb) r Starting program: /export/home/hjl/bugs/gcc/pr38988/a.out Breakpoint 1, main () at f.c:6 6 printf ("hello\n"); (gdb) p $rip $1 = (void (*)()) 0x110000708 <main+4> (gdb) c Continuing. hello Program exited normally. (gdb) I added a new linker switch: -Ttext-segment ADDRESS Set address of text segment It may work for you.
Created attachment 17195 [details] Patch to fix crtstuff.c failure This patch fixes crtstuff failure with -mcmodel=large.
Steve, can you test this patch if it fixes your bootstrap?
Did you change cselib_hash_rtx too? I don't see that change in your patch but I know I need it to get to the shared rtx bug that your patch will hopefully fix.
(In reply to comment #7) > Did you change cselib_hash_rtx too? I don't see that change in your patch but > I know I need it to get to the shared rtx bug that your patch will hopefully > fix. The fix is not necessary, since we now pass correct RTX to hash function. IOW, the patch as attached is complete and fixes test from comment #0.
Yes, your patch does fix my problem.
Subject: Bug 38988 Author: uros Date: Wed Jan 28 07:58:07 2009 New Revision: 143720 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143720 Log: PR target/38988 * config/i386/i386.md (set_rip_rex64): Wrap operand 1 in label_ref. (set_got_offset_rex64): Ditto. Added: trunk/gcc/testsuite/gcc.target/i386/pr38988.c Modified: trunk/gcc/ChangeLog trunk/gcc/config/i386/i386.md
Subject: Bug 38988 Author: uros Date: Thu Jan 29 10:05:17 2009 New Revision: 143752 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143752 Log: Backport from mainline: 2009-01-28 Uros Bizjak <ubizjak@gmail.com> PR target/38988 * gcc.target/i386/pr38988.c: New test. 2009-01-27 Uros Bizjak <ubizjak@gmail.com> PR middle-end/38969 * gcc.c-torture/execute/pr38969.c: New test. testsuite/ChangeLog: Backport from mainline: 2009-01-28 Uros Bizjak <ubizjak@gmail.com> PR target/38988 * config/i386/i386.md (set_rip_rex64): Wrap operand 1 in label_ref. (set_got_offset_rex64): Ditto. 2009-01-27 Uros Bizjak <ubizjak@gmail.com> PR middle-end/38969 * calls.c (initialize_argument_information): Do not wrap complex arguments in SAVE_EXPR. Added: branches/gcc-4_3-branch/gcc/testsuite/gcc.c-torture/execute/pr38969.c - copied unchanged from r143699, trunk/gcc/testsuite/gcc.c-torture/execute/pr38969.c branches/gcc-4_3-branch/gcc/testsuite/gcc.target/i386/pr38988.c - copied unchanged from r143720, trunk/gcc/testsuite/gcc.target/i386/pr38988.c Modified: branches/gcc-4_3-branch/gcc/ChangeLog branches/gcc-4_3-branch/gcc/calls.c branches/gcc-4_3-branch/gcc/config/i386/i386.md branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
Fixed.
*** Bug 39296 has been marked as a duplicate of this bug. ***