public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/102772] [12 regression] g++.dg/torture/pr80334.C FAILs Date: Fri, 25 Mar 2022 13:49:28 +0000 [thread overview] Message-ID: <bug-102772-4-HmQJ6bR5KV@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-102772-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102772 --- Comment #29 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Ok, that looks like a linker bug: movaps %xmm7, thr.1@ntpoff(%ebx) ... movaps %xmm7, thr.1@ntpoff+16(%ebx) ... movl %eax, thr.1@ntpoff+32(%ebx) in assembly correctly turned into: 2a: 0f 29 bb 00 00 00 00 movaps %xmm7,0x0(%ebx) 2d: R_386_TLS_LE thr.1 ... 36: 0f 29 bb 10 00 00 00 movaps %xmm7,0x10(%ebx) 39: R_386_TLS_LE thr.1 ... 40: 89 83 20 00 00 00 mov %eax,0x20(%ebx) 42: R_386_TLS_LE thr.1 [ 5] .tbss NOBITS 00000000 000570 000024 00 WAT 0 0 16 But linker turns that into: 80517ba: 0f 29 bb d8 ff ff ff movaps %xmm7,-0x28(%ebx) ... 80517c6: 0f 29 bb e8 ff ff ff movaps %xmm7,-0x18(%ebx) ... 80517d0: 89 83 f8 ff ff ff mov %eax,-0x8(%ebx) Even when dynamic linker properly ensures the %gs:0 base is 16-byte aligned because PT_TLS segment is: TLS 0x00b6f0 0x0806b6f0 0x00000000 0x00000 0x00024 RW 0x10 the R_386_TLS_LE immediates are off, they don't take into account the needed alignment. We should probably use a better small testcase: struct S { char buf[0x24]; }; __thread struct S s __attribute__((aligned (16))); __attribute__((noipa)) struct S *foo (void) { return &s; } int main () { #pragma omp parallel __builtin_printf ("%p\n", foo ()); return 0; } because with the aligned (16) attribute on struct S we've increased its size to 0x30 that way. https://akkadia.org/drepper/tls.pdf says that tsoffset_1 = round(tlssize_1, align_1) tlsoffset_m+1 = round(tlsoffset_m + tlssize_m+1, align_m+1) and as tlssize_1 (of the binary) is 36 and align_1 is 16, tlsoffset_1 is 48 and so R_386_TLS_LE thr.1 should resolve to -48 + 0 (thr.1 is at offset 0 of the segment). But it seems the linker instead uses -40, i.e. just the size rounded up to 8 byte alignment boundary rather than 16. We could work around it on GCC side by padding up any TLS vars up to their alignment, but that would be horribly expensive, potentially wasting a lot of the precious TLS memory.
next prev parent reply other threads:[~2022-03-25 13:49 UTC|newest] Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-10-15 11:39 [Bug target/102772] New: " ro at gcc dot gnu.org 2021-10-15 11:40 ` [Bug target/102772] " ro at gcc dot gnu.org 2021-10-15 11:40 ` ro at gcc dot gnu.org 2021-10-15 11:40 ` ro at gcc dot gnu.org 2021-10-15 12:06 ` hjl.tools at gmail dot com 2021-10-15 13:02 ` rguenth at gcc dot gnu.org 2021-10-15 14:29 ` ro at CeBiTec dot Uni-Bielefeld.DE 2021-10-15 20:44 ` hjl.tools at gmail dot com 2021-11-16 11:51 ` jakub at gcc dot gnu.org 2021-11-23 12:36 ` ro at gcc dot gnu.org 2022-03-17 15:05 ` jakub at gcc dot gnu.org 2022-03-17 15:14 ` ro at CeBiTec dot Uni-Bielefeld.DE 2022-03-21 11:44 ` jakub at gcc dot gnu.org 2022-03-21 12:01 ` ro at CeBiTec dot Uni-Bielefeld.DE 2022-03-21 12:03 ` ro at gcc dot gnu.org 2022-03-21 12:03 ` ro at gcc dot gnu.org 2022-03-21 13:17 ` jakub at gcc dot gnu.org 2022-03-21 13:31 ` jakub at gcc dot gnu.org 2022-03-22 15:12 ` ro at CeBiTec dot Uni-Bielefeld.DE 2022-03-22 17:00 ` jakub at gcc dot gnu.org 2022-03-23 13:56 ` ro at CeBiTec dot Uni-Bielefeld.DE 2022-03-23 14:11 ` jakub at gcc dot gnu.org 2022-03-23 14:17 ` jakub at gcc dot gnu.org 2022-03-25 12:48 ` ro at CeBiTec dot Uni-Bielefeld.DE 2022-03-25 12:53 ` ro at CeBiTec dot Uni-Bielefeld.DE 2022-03-25 12:54 ` jakub at gcc dot gnu.org 2022-03-25 13:00 ` ro at CeBiTec dot Uni-Bielefeld.DE 2022-03-25 13:06 ` jakub at gcc dot gnu.org 2022-03-25 13:13 ` ro at CeBiTec dot Uni-Bielefeld.DE 2022-03-25 13:18 ` jakub at gcc dot gnu.org 2022-03-25 13:22 ` ro at gcc dot gnu.org 2022-03-25 13:49 ` jakub at gcc dot gnu.org [this message] 2022-03-30 14:06 ` cvs-commit at gcc dot gnu.org 2022-03-30 14:45 ` jakub at gcc dot gnu.org 2022-03-30 14:52 ` redi at gcc dot gnu.org 2022-03-30 14:56 ` redi at gcc dot gnu.org 2022-03-30 15:04 ` redi at gcc dot gnu.org 2022-03-30 15:13 ` redi at gcc dot gnu.org 2022-03-30 15:23 ` jakub at gcc dot gnu.org 2022-03-31 13:46 ` ro at CeBiTec dot Uni-Bielefeld.DE 2022-03-31 13:47 ` ro at gcc dot gnu.org 2022-03-31 14:16 ` redi at gcc dot gnu.org 2022-03-31 14:18 ` redi at gcc dot gnu.org 2022-03-31 14:49 ` jakub at gcc dot gnu.org 2022-03-31 15:15 ` redi at gcc dot gnu.org 2022-03-31 15:47 ` jakub at gcc dot gnu.org 2022-04-04 11:54 ` jakub at gcc dot gnu.org 2022-04-11 9:13 ` jakub at gcc dot gnu.org 2022-04-11 14:19 ` ro at CeBiTec dot Uni-Bielefeld.DE 2022-04-11 14:19 ` ro at CeBiTec dot Uni-Bielefeld.DE 2022-04-11 15:29 ` jakub at gcc dot gnu.org 2022-04-12 7:53 ` jakub at gcc dot gnu.org 2022-04-13 14:47 ` ro at CeBiTec dot Uni-Bielefeld.DE 2022-05-06 8:31 ` [Bug target/102772] [12/13 " jakub at gcc dot gnu.org 2023-05-08 12:22 ` [Bug target/102772] [12/13/14 " rguenth at gcc dot gnu.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-102772-4-HmQJ6bR5KV@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).