[PATCH] D65716: [ELF] Consistently priority non-* wildcards overs "*" in version scripts

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 4 03:04:04 PDT 2019


MaskRay created this revision.
MaskRay added reviewers: emaste, grimar, peter.smith, ruiu.
Herald added subscribers: llvm-commits, arichardson.
Herald added a reviewer: espindola.
Herald added a project: LLVM.

We prioritize non-* wildcards overs VER_NDX_LOCAL/VER_NDX_GLOBAL "*".
This patch generalizes the rule to "*" of other versions and thus fixes PR40176.
I don't feel strongly about this GNU linkers' behavior but the
generalization simplifies code.

Delete `config->defaultSymbolVersion` which was used to special case
VER_NDX_LOCAL/VER_NDX_GLOBAL "*".

In `SymbolTable::scanVersionScript`, custom versions are handled the same
way as VER_NDX_LOCAL/VER_NDX_GLOBAL. So merge
`config->versionScript{Locals,Globals}` into `config->versionDefinitions`.
Overall this seems to simplify the code.

In `SymbolTable::assign{Exact,Wildcard}Versions`,
`sym->verdefIndex == config->defaultSymbolVersion` is changed to
`verdefIndex == UINT32_C(-1)`.
This allows us to give duplicate assignment diagnostics for
`{ global: foo; };` `V1 { global: foo; };`

In test/linkerscript/version-script.s:

  vs_index of an undefined symbol changes from 0 to 1. This doesn't matter (arguably 1 is better because the binding is STB_GLOBAL) because vs_index of an undefined symbol is ignored.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D65716

Files:
  ELF/Config.h
  ELF/Driver.cpp
  ELF/ScriptParser.cpp
  ELF/SymbolTable.cpp
  ELF/Symbols.cpp
  ELF/SyntheticSections.cpp
  ELF/Writer.cpp
  test/ELF/linkerscript/version-script.s
  test/ELF/version-script-reassign-glob.s
  test/ELF/version-script-reassign.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65716.213238.patch
Type: text/x-patch
Size: 13287 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190804/8d97e3bd/attachment.bin>


More information about the llvm-commits mailing list