Bug 28814 - Support creating empty ELF symbol versions without VER_FLG_WEAK
Summary: Support creating empty ELF symbol versions without VER_FLG_WEAK
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-24 14:20 UTC by Florian Weimer
Modified: 2022-01-31 16:33 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
Project(s) to access:
ssh public key:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Weimer 2022-01-24 14:20:56 UTC
In some sense this is opposite of bug 24718.

If an object defines a sequence of versions A, B, C, and does not associate any symbol versions with (say) version B, BFD ld sets VER_FLG_WEAK on that symbol version. It would be nice if this could be avoided. In glibc, to suppress the flag, we currently create an otherwise-unused placeholder symbol. If we had a way to avoid the flag, we would not need to do that.
Comment 1 Nick Clifton 2022-01-31 16:27:28 UTC
Hi Florian,

  Do you have an example to demonstrate what you want to happen ?

  Ideally I would like to find a method that is compatible with 
  the other linkers, rather than being ld.bfd specific.  (This
  may not be possible however).

Cheers
  Nick
Comment 2 Florian Weimer 2022-01-31 16:32:46 UTC
Version definition section '.gnu.version_d' contains 4 entries:
 Addr: 0x00000000000004a8  Offset: 0x0004a8  Link: 5 (.dynstr)
  000000: Rev: 1  Flags: BASE  Index: 1  Cnt: 1  Name: a.out
  0x001c: Rev: 1  Flags: none  Index: 2  Cnt: 1  Name: VER_1
  0x0038: Rev: 1  Flags: WEAK  Index: 3  Cnt: 2  Name: VER_2
  0x0054: Parent 1: VER_1
  0x005c: Rev: 1  Flags: none  Index: 4  Cnt: 2  Name: VER_3
  0x0078: Parent 1: VER_2

a.out built from:

$ head -v ex.c ex.lds 
==> ex.c <==
void f1(void) {}
void f3(void) {}

==> ex.lds <==
VER_1 {
  global: f1;
  local: *;
};
VER_2 {
} VER_1;
VER_3 {
  global: f2;
} VER_2;

using:

gcc -shared ex.c -Wl,--version-script=ex.lds
Comment 3 Florian Weimer 2022-01-31 16:33:32 UTC
Mailing list thread:

[PATCH] elf: Don't set VER_FLG_WEAK
https://sourceware.org/pipermail/binutils/2022-January/119497.html