public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/38988]  New: Cannot build crtstuff.c with -mcmodel=large -fPIC -O2
@ 2009-01-27 17:15 sje at cup dot hp dot com
  2009-01-27 17:46 ` [Bug target/38988] " hjl dot tools at gmail dot com
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: sje at cup dot hp dot com @ 2009-01-27 17:15 UTC (permalink / raw)
  To: gcc-bugs

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 ();
          }
        }


-- 
           Summary: Cannot build crtstuff.c with -mcmodel=large -fPIC -O2
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sje at cup dot hp dot com
GCC target triplet: x86_64-*-*


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38988


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

* [Bug target/38988] Cannot build crtstuff.c with -mcmodel=large -fPIC -O2
  2009-01-27 17:15 [Bug target/38988] New: Cannot build crtstuff.c with -mcmodel=large -fPIC -O2 sje at cup dot hp dot com
@ 2009-01-27 17:46 ` hjl dot tools at gmail dot com
  2009-01-27 17:48 ` hjl dot tools at gmail dot com
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-01-27 17:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from hjl dot tools at gmail dot com  2009-01-27 17:46 -------
Do you have a testcase to show that -mcmodel=large doesn't work for
you?


-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hjl dot tools at gmail dot
                   |                            |com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38988


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

* [Bug target/38988] Cannot build crtstuff.c with -mcmodel=large -fPIC -O2
  2009-01-27 17:15 [Bug target/38988] New: Cannot build crtstuff.c with -mcmodel=large -fPIC -O2 sje at cup dot hp dot com
  2009-01-27 17:46 ` [Bug target/38988] " hjl dot tools at gmail dot com
@ 2009-01-27 17:48 ` hjl dot tools at gmail dot com
  2009-01-27 17:55 ` sje at cup dot hp dot com
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-01-27 17:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from hjl dot tools at gmail dot com  2009-01-27 17:48 -------
By testcase, I meant a user application, not crtstuff.c, like

# gcc -mcmodel=large foo.c
# ./a.out


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38988


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

* [Bug target/38988] Cannot build crtstuff.c with -mcmodel=large -fPIC -O2
  2009-01-27 17:15 [Bug target/38988] New: Cannot build crtstuff.c with -mcmodel=large -fPIC -O2 sje at cup dot hp dot com
  2009-01-27 17:46 ` [Bug target/38988] " hjl dot tools at gmail dot com
  2009-01-27 17:48 ` hjl dot tools at gmail dot com
@ 2009-01-27 17:55 ` sje at cup dot hp dot com
  2009-01-27 18:07 ` hjl dot tools at gmail dot com
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: sje at cup dot hp dot com @ 2009-01-27 17:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from sje at cup dot hp dot com  2009-01-27 17:54 -------
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.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38988


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

* [Bug target/38988] Cannot build crtstuff.c with -mcmodel=large -fPIC -O2
  2009-01-27 17:15 [Bug target/38988] New: Cannot build crtstuff.c with -mcmodel=large -fPIC -O2 sje at cup dot hp dot com
                   ` (2 preceding siblings ...)
  2009-01-27 17:55 ` sje at cup dot hp dot com
@ 2009-01-27 18:07 ` hjl dot tools at gmail dot com
  2009-01-27 19:55 ` ubizjak at gmail dot com
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-01-27 18:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from hjl dot tools at gmail dot com  2009-01-27 18:07 -------
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.


-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38988


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

* [Bug target/38988] Cannot build crtstuff.c with -mcmodel=large -fPIC -O2
  2009-01-27 17:15 [Bug target/38988] New: Cannot build crtstuff.c with -mcmodel=large -fPIC -O2 sje at cup dot hp dot com
                   ` (3 preceding siblings ...)
  2009-01-27 18:07 ` hjl dot tools at gmail dot com
@ 2009-01-27 19:55 ` ubizjak at gmail dot com
  2009-01-27 19:57 ` ubizjak at gmail dot com
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: ubizjak at gmail dot com @ 2009-01-27 19:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from ubizjak at gmail dot com  2009-01-27 19:55 -------
Created an attachment (id=17195)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17195&action=view)
Patch to fix crtstuff.c failure

This patch fixes crtstuff failure with -mcmodel=large.


-- 

ubizjak at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |ubizjak at gmail dot com
                   |dot org                     |
             Status|WAITING                     |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38988


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

* [Bug target/38988] Cannot build crtstuff.c with -mcmodel=large -fPIC -O2
  2009-01-27 17:15 [Bug target/38988] New: Cannot build crtstuff.c with -mcmodel=large -fPIC -O2 sje at cup dot hp dot com
                   ` (4 preceding siblings ...)
  2009-01-27 19:55 ` ubizjak at gmail dot com
@ 2009-01-27 19:57 ` ubizjak at gmail dot com
  2009-01-27 20:03 ` sje at cup dot hp dot com
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: ubizjak at gmail dot com @ 2009-01-27 19:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from ubizjak at gmail dot com  2009-01-27 19:57 -------
Steve, can you test this patch if it fixes your bootstrap?


-- 

ubizjak at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|ubizjak at gmail dot com    |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38988


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

* [Bug target/38988] Cannot build crtstuff.c with -mcmodel=large -fPIC -O2
  2009-01-27 17:15 [Bug target/38988] New: Cannot build crtstuff.c with -mcmodel=large -fPIC -O2 sje at cup dot hp dot com
                   ` (5 preceding siblings ...)
  2009-01-27 19:57 ` ubizjak at gmail dot com
@ 2009-01-27 20:03 ` sje at cup dot hp dot com
  2009-01-27 20:28 ` ubizjak at gmail dot com
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: sje at cup dot hp dot com @ 2009-01-27 20:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from sje at cup dot hp dot com  2009-01-27 20:03 -------
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.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38988


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

* [Bug target/38988] Cannot build crtstuff.c with -mcmodel=large -fPIC -O2
  2009-01-27 17:15 [Bug target/38988] New: Cannot build crtstuff.c with -mcmodel=large -fPIC -O2 sje at cup dot hp dot com
                   ` (6 preceding siblings ...)
  2009-01-27 20:03 ` sje at cup dot hp dot com
@ 2009-01-27 20:28 ` ubizjak at gmail dot com
  2009-01-27 23:45 ` sje at cup dot hp dot com
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: ubizjak at gmail dot com @ 2009-01-27 20:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from ubizjak at gmail dot com  2009-01-27 20:28 -------
(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.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38988


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

* [Bug target/38988] Cannot build crtstuff.c with -mcmodel=large -fPIC -O2
  2009-01-27 17:15 [Bug target/38988] New: Cannot build crtstuff.c with -mcmodel=large -fPIC -O2 sje at cup dot hp dot com
                   ` (7 preceding siblings ...)
  2009-01-27 20:28 ` ubizjak at gmail dot com
@ 2009-01-27 23:45 ` sje at cup dot hp dot com
  2009-01-28  7:58 ` uros at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: sje at cup dot hp dot com @ 2009-01-27 23:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from sje at cup dot hp dot com  2009-01-27 23:45 -------
Yes, your patch does fix my problem.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38988


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

* [Bug target/38988] Cannot build crtstuff.c with -mcmodel=large -fPIC -O2
  2009-01-27 17:15 [Bug target/38988] New: Cannot build crtstuff.c with -mcmodel=large -fPIC -O2 sje at cup dot hp dot com
                   ` (8 preceding siblings ...)
  2009-01-27 23:45 ` sje at cup dot hp dot com
@ 2009-01-28  7:58 ` uros at gcc dot gnu dot org
  2009-01-29 10:05 ` uros at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: uros at gcc dot gnu dot org @ 2009-01-28  7:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from uros at gcc dot gnu dot org  2009-01-28 07:58 -------
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


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38988


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

* [Bug target/38988] Cannot build crtstuff.c with -mcmodel=large -fPIC -O2
  2009-01-27 17:15 [Bug target/38988] New: Cannot build crtstuff.c with -mcmodel=large -fPIC -O2 sje at cup dot hp dot com
                   ` (9 preceding siblings ...)
  2009-01-28  7:58 ` uros at gcc dot gnu dot org
@ 2009-01-29 10:05 ` uros at gcc dot gnu dot org
  2009-01-29 10:09 ` ubizjak at gmail dot com
  2009-02-25  1:48 ` hjl dot tools at gmail dot com
  12 siblings, 0 replies; 14+ messages in thread
From: uros at gcc dot gnu dot org @ 2009-01-29 10:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from uros at gcc dot gnu dot org  2009-01-29 10:05 -------
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


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38988


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

* [Bug target/38988] Cannot build crtstuff.c with -mcmodel=large -fPIC -O2
  2009-01-27 17:15 [Bug target/38988] New: Cannot build crtstuff.c with -mcmodel=large -fPIC -O2 sje at cup dot hp dot com
                   ` (10 preceding siblings ...)
  2009-01-29 10:05 ` uros at gcc dot gnu dot org
@ 2009-01-29 10:09 ` ubizjak at gmail dot com
  2009-02-25  1:48 ` hjl dot tools at gmail dot com
  12 siblings, 0 replies; 14+ messages in thread
From: ubizjak at gmail dot com @ 2009-01-29 10:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from ubizjak at gmail dot com  2009-01-29 10:09 -------
Fixed.


-- 

ubizjak at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.4


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38988


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

* [Bug target/38988] Cannot build crtstuff.c with -mcmodel=large -fPIC -O2
  2009-01-27 17:15 [Bug target/38988] New: Cannot build crtstuff.c with -mcmodel=large -fPIC -O2 sje at cup dot hp dot com
                   ` (11 preceding siblings ...)
  2009-01-29 10:09 ` ubizjak at gmail dot com
@ 2009-02-25  1:48 ` hjl dot tools at gmail dot com
  12 siblings, 0 replies; 14+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-02-25  1:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from hjl dot tools at gmail dot com  2009-02-25 01:47 -------
*** Bug 39296 has been marked as a duplicate of this bug. ***


-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38988


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

end of thread, other threads:[~2009-02-25  1:48 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-27 17:15 [Bug target/38988] New: Cannot build crtstuff.c with -mcmodel=large -fPIC -O2 sje at cup dot hp dot com
2009-01-27 17:46 ` [Bug target/38988] " hjl dot tools at gmail dot com
2009-01-27 17:48 ` hjl dot tools at gmail dot com
2009-01-27 17:55 ` sje at cup dot hp dot com
2009-01-27 18:07 ` hjl dot tools at gmail dot com
2009-01-27 19:55 ` ubizjak at gmail dot com
2009-01-27 19:57 ` ubizjak at gmail dot com
2009-01-27 20:03 ` sje at cup dot hp dot com
2009-01-27 20:28 ` ubizjak at gmail dot com
2009-01-27 23:45 ` sje at cup dot hp dot com
2009-01-28  7:58 ` uros at gcc dot gnu dot org
2009-01-29 10:05 ` uros at gcc dot gnu dot org
2009-01-29 10:09 ` ubizjak at gmail dot com
2009-02-25  1:48 ` hjl dot tools at gmail dot com

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).