https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48200
--- Comment #38 from Jan Hubicka <hubicka at ucw dot cz> --- Hi, I am attaching prototype patch. It implements "symver" attribute which can be attached to a definition such as: hubicka@lomikamen-jh:/aux/hubicka/trunk5/build4/gcc$ cat t.c __attribute__ ((symver("bar@2.2"))) int t() { } hubicka@lomikamen-jh:/aux/hubicka/trunk5/build4/gcc$ ./xgcc -B ./ -O2 t.c -S hubicka@lomikamen-jh:/aux/hubicka/trunk5/build4/gcc$ cat t.s .file "t.c" .text .p2align 4 .globl t .type t, @function t: .LFB0: .cfi_startproc ret .cfi_endproc .LFE0: .size t, .-t .symver t, bar@2.2 .ident "GCC: (GNU) 10.0.0 20191114 (experimental)" .section .note.GNU-stack,"",@progbits Internally it defines a new kind of alias (symver alias) with assembler name "bar@2.2" so LTO symbol table match ELF symbol table for the unit: hubicka@lomikamen-jh:/aux/hubicka/trunk5/build4/gcc$ nm t.o 0000000000000000 T bar@2.2 0000000000000000 T t hubicka@lomikamen-jh:/aux/hubicka/trunk5/build4/gcc$ ./xgcc -B ./ -O2 t.c -c -flto hubicka@lomikamen-jh:/aux/hubicka/trunk5/build4/gcc$ gcc-nm t.o 00000000 T bar@2.2 00000000 T t Internally in GCC the symver is handled just as normal alias only output differntly. I think GCC, just like static linker, does not really need to understand the versions because there are no direct ways to bind to those symbols. I wonder if someone sees limitations to this design (in particular attaching the symver directly to the definition). In PR66825 Carlos proposed "version_def" attribute which can be implemented too (I suppose all I need is to concatenate the strings into the actual name). I wonder what would be preferred and easier for users? Also Carlos proposes "version_ref" that can be used for external definitions. I am not quite sure how to do that with existing GAS and LTO since different translation units can reffer to different versions. But my understnading is that for LTO it is critical to implement the def part. Hopefully I can turn this into a patch proposal tomorrow to meet the stage1 deadline, so comments are welcome especially if they come really soon :) Honza