public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ian at airs dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/29198] New: Incorrect reference to __thread array with -fPIC -O2 on x86 Date: Sun, 24 Sep 2006 05:21:00 -0000 [thread overview] Message-ID: <bug-29198-1313@http.gcc.gnu.org/bugzilla/> (raw) I compiled this C code with current mainline with -fPIC -O2 on x86 GNU/Linux: extern int f2 (int, int, int, int); struct s { char b[4]; }; __thread struct s a[2]; void f1 (int a1, int a2) { int i, j; for (i = 0; i < 4; i++) { int tot = 0; for (j = 0; j < 4; j++) tot += f2 (a1, a2, i, j); a[0].b[i] = tot; } } The resulting assembler file had this in it: movl a@GOT(%ebx), %ecx But a is declared with __thread. This should instead be something like: leal a@TLSGD(,%ebx,1), %eax call ___tls_get_addr@PLT In the real code there are other references to a, which leads to a linker error: `a' accessed both as normal and thread local symbol I believe the bug is in legitimize_address or in legitimize_pic_address in config/i386/i386.c. legitimize_address gets called with (plus:SI (reg/v:SI 64 [ i ]) (symbol_ref:SI ("a") [flags 0x8] <var_decl 0xb7c630b0 a>)) When it sees a symbol as the right-hand operand of a PLUS, it calls legitimize_pic_address. That returns an UNSPEC_GOT. Somewhere along the way, it needs to call legitimize_tls_address. -- Summary: Incorrect reference to __thread array with -fPIC -O2 on x86 Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ian at airs dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29198
next reply other threads:[~2006-09-24 5:21 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2006-09-24 5:21 ian at airs dot com [this message] 2006-09-24 5:29 ` [Bug target/29198] [4.0/4.1/4.2 Regression] " pinskia at gcc dot gnu dot org 2006-09-24 5:31 ` pinskia at gcc dot gnu dot org 2006-09-24 5:34 ` pinskia at gcc dot gnu dot org 2006-09-29 11:30 ` jakub at gcc dot gnu dot org 2006-10-01 22:59 ` mmitchel at gcc dot gnu dot org 2006-10-06 7:25 ` jakub at gcc dot gnu dot org 2006-10-06 7:36 ` jakub at gcc dot gnu dot org 2006-10-06 7:41 ` [Bug target/29198] [4.0 " jakub at gcc dot gnu dot org 2007-02-03 20:22 ` gdr at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-29198-1313@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).