Bug 28197

Summary: compat_symbol should migrate to .symver *, *, remove
Product: glibc Reporter: Fangrui Song <i>
Component: buildAssignee: Not yet assigned to anyone <unassigned>
Status: UNCONFIRMED ---    
Severity: normal CC: carlos
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:

Description Fangrui Song 2021-08-05 18:17:45 UTC
Due to an assembler design flaw (IMO), .symver foo,foo@v1 produces two symbols `foo` and foo@v1 if foo is defined. This has caused all sorts of linker complexity (in all of GNU ld, gold, and ld.lld AFAICT from PRs). .symver should really behave like "rename" && there should only be one defined symbol 'foo@v1'

I implemented a hack for LLD 13.0.0: https://reviews.llvm.org/D107235

Due to PR gold/28196, gold linked libc.so has many default version symbols (e.g. __free_hook@@GLIBC_2.2.5) while they should be non-default version symbols instead.

Migrating to .symver foo,foo@v1, remove  can make all of GNU ld, gold, and ld.lld happier. They all implement some hacks to ensure foo and foo@v1 don't end up with two dynamic symbols. The migration is blocked on PR gas/28157 (make relocations work).

After glibc is migrated, if at some point the compatibility with the old `.symver foo,foo@v1` behavior is no longer needed, we can default gas to `,remove`. Over time, all linkers can drop their foo && foo@v1 combining hacks.