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 libstdc++/108969] [13/14 Regression] Initializing iostreams in the library needs a GLIBCXX_3.4.31 versioned symbol Date: Wed, 19 Apr 2023 14:17:11 +0000 [thread overview] Message-ID: <bug-108969-4-T7fWwnRtYc@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-108969-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108969 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|FIXED |--- --- Comment #20 from Jakub Jelinek <jakub at gcc dot gnu.org> --- So, ( for i in 7.c 7.ver 7a.c 7a.ver 8.c 7.h; do echo $i; cat /tmp/$i; done; gcc -shared -fpic -Wl,--version-script=/tmp/7.ver /tmp/7.c -o /tmp/7.so; gcc -I /tmp/ -o /tmp/8 /tmp/8.c /tmp/7.so; /tmp/8; echo $?; gcc -shared -fpic -Wl,--version-script=/tmp/7a.ver /tmp/7a.c -o /tmp/7.so; /tmp/8; echo $? ) 7.c void _Zwhatever (void) { } void foo (void) { } 7.ver GLIBCXX_3.4.31 { global: foo; local: *; }; GLIBCXX_3.4.32 { global: _Zwhatever; } GLIBCXX_3.4.31; 7a.c void foo (void) { } 7a.ver GLIBCXX_3.4.31 { global: foo; local: *; }; 8.c #include "7.h" int main () { } 7.h asm (".globl _Zwhatever"); 0 /tmp/8: /tmp/7.so: version `GLIBCXX_3.4.32' not found (required by /tmp/8) 1 is one proof-of-concept on what we could do. Another one is /tmp/4.C namespace std { # define _GLIBCXX_IO_GLOBAL(type, X, N) namespace __io { type X __attribute__((__symver__ ("_ZSt" #N #X "@GLIBCXX_3.4"))); } \ extern type X##alias __attribute__((__weak__, __alias__ ("_ZNSt4__io" #N #X "E"), __symver__ ("_ZSt" #N #X "@@GLIBCXX_3.4.31"))); _GLIBCXX_IO_GLOBAL(int, cin, 3) _GLIBCXX_IO_GLOBAL(int, cout, 4) _GLIBCXX_IO_GLOBAL(int, cerr, 4) _GLIBCXX_IO_GLOBAL(int, clog, 4) } /tmp/4.c extern int _ZSt4cerr; int main () { _ZSt4cerr++; } /tmp/4.ver GLIBCXX_3.4 { global: _ZSt3cin; _ZSt4cerr; _ZSt4cout; _ZSt4clog; local: *; }; GLIBCXX_3.4.31 { global: _ZSt3cin; _ZSt4cerr; _ZSt4cout; _ZSt4clog; } GLIBCXX_3.4; gcc -shared -o /tmp/4.so /tmp/4.C -fpic -Wl,--version-script=/tmp/4.ver gcc -o /tmp/4 /tmp/4.c /tmp/4.so eadelf -Wa /tmp/4 2>&1 | grep cerr 000000000040401c 0000000400000005 R_X86_64_COPY 000000000040401c _ZSt4cerr@GLIBCXX_3.4 + 0 3: 000000000040401c 4 OBJECT WEAK DEFAULT 23 _ZSt4cerr@GLIBCXX_3.4.31 (3) 4: 000000000040401c 4 OBJECT GLOBAL DEFAULT 23 _ZSt4cerr@GLIBCXX_3.4 (4) 58: 000000000040401c 4 OBJECT WEAK DEFAULT 23 _ZSt4cerr@GLIBCXX_3.4.31 59: 000000000040401c 4 OBJECT GLOBAL DEFAULT 23 _ZSt4cerr@GLIBCXX_3.4 So, when the @@GLIBCXX_3.4.31 alias is weak, at least the F36 linker puts into the binary not just one but both symbols and so the aliasing isn't broken. We'd need to also arrange for ios_init.o to refer to _ZSt4cerr@GLIBCXX_3.4 rather than _ZSt4cerr, because binaries built against older libstdc++ will have just _ZSt4cerr@GLIBCXX_3.4 symbol on the copy relocation. Or combination of both, do the former on Solaris and the latter on Linux. To be tested with older linkers/assemblers, non-glibc dynamic linkers and the like.
next prev parent reply other threads:[~2023-04-19 14:17 UTC|newest] Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-28 13:08 [Bug libstdc++/108969] New: [13 " redi at gcc dot gnu.org 2023-02-28 13:09 ` [Bug libstdc++/108969] " redi at gcc dot gnu.org 2023-02-28 13:21 ` jakub at gcc dot gnu.org 2023-02-28 13:22 ` redi at gcc dot gnu.org 2023-02-28 13:25 ` jakub at gcc dot gnu.org 2023-02-28 13:28 ` redi at gcc dot gnu.org 2023-02-28 13:30 ` jakub at gcc dot gnu.org 2023-02-28 13:34 ` fw at gcc dot gnu.org 2023-02-28 13:36 ` redi at gcc dot gnu.org 2023-02-28 13:51 ` jakub at gcc dot gnu.org 2023-02-28 13:54 ` rguenth at gcc dot gnu.org 2023-02-28 14:09 ` redi at gcc dot gnu.org 2023-03-03 17:25 ` ppalka at gcc dot gnu.org 2023-03-08 9:20 ` rguenth at gcc dot gnu.org 2023-03-08 9:28 ` jakub at gcc dot gnu.org 2023-03-27 10:55 ` rguenth at gcc dot gnu.org 2023-04-18 15:58 ` [Bug libstdc++/108969] [13/14 " cvs-commit at gcc dot gnu.org 2023-04-18 16:00 ` cvs-commit at gcc dot gnu.org 2023-04-18 16:00 ` redi at gcc dot gnu.org 2023-04-18 16:31 ` cvs-commit at gcc dot gnu.org 2023-04-18 16:31 ` cvs-commit at gcc dot gnu.org 2023-04-19 14:17 ` jakub at gcc dot gnu.org [this message] 2023-04-19 14:17 ` sjames at gcc dot gnu.org 2023-04-19 14:25 ` jakub at gcc dot gnu.org 2023-04-19 14:45 ` fw at gcc dot gnu.org 2023-04-19 14:48 ` jakub at gcc dot gnu.org 2023-04-26 6:57 ` rguenth at gcc dot gnu.org 2023-04-26 18:15 ` xry111 at gcc dot gnu.org 2023-04-28 8:50 ` cvs-commit at gcc dot gnu.org 2023-04-28 20:57 ` romain.geissler at amadeus dot com 2023-04-28 20:58 ` romain.geissler at amadeus dot com 2023-04-28 21:16 ` redi at gcc dot gnu.org 2023-04-28 21:21 ` romain.geissler at amadeus dot com 2023-05-04 7:44 ` cvs-commit at gcc dot gnu.org 2023-05-04 7:49 ` jakub 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-108969-4-T7fWwnRtYc@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).