This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: .symver GAS directive and local symbols


On 2019-11-15, Florian Weimer wrote:
Jan noticed that if you start out with a local alias of a global
symbol and apply symbol version to that, you get a local symbol:

	.globl foo
	.type foo, @function
	.size foo, 4
foo:
	.long 0
	.set foo.symver.1, foo
	.symver foo.symver.1, foo@VER

Symbol table '.symtab' contains 7 entries:
  Num:    Value          Size Type    Bind   Vis      Ndx Name
    0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
    1: 0000000000000000     0 SECTION LOCAL  DEFAULT    1
    2: 0000000000000000     0 SECTION LOCAL  DEFAULT    2
    3: 0000000000000000     0 SECTION LOCAL  DEFAULT    3
    4: 0000000000000000     4 FUNC    LOCAL  DEFAULT    1 foo.symver.1
    5: 0000000000000000     4 FUNC    LOCAL  DEFAULT    1 foo@VER
    6: 0000000000000000     4 FUNC    GLOBAL DEFAULT    1 foo

Is there a good reason for this behavior?

What we really want to do is to export the same symbol@multiple
versions, like this:

	.symver foo, foo@VER1
	.symver foo, foo@VER2

But GAS explicitly rejects that.

Currently, for `.symver foo, foo@VER1` :

* If foo is defined => both foo and foo@VER1 are emitted.
* If foo is undefined, and foo is used => only foo@VER1 is emitted.

I think a better semantic for single-@ .symver is renaming, like @@@ added by
HJ.Lu on 2000-11-13.

* If foo is defined => only foo@VER1 is emitted.


The problem with keeping foo around:

If the object file is linked into a shared object, great, the project
developers can decide to link it with a version script to eliminate the
symbol foo. If the object file is shipped as an archive, every
dependent project needs a post-processing mechanism (version script,
objcopy, etc) to eliminate foo.



To make the renaming semantic possible in the future, I think we
probably should not allow:

 .symver foo, foo@VER1
 .symver foo, foo@VER2



The renaming semantic is not backward compatible, but fortunately not
many projects rely on it. libfuse is one instance.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]