[PATCH] D80059: [ELF] Parse SHT_GNU_verneed and respect versioned undefined symbols in shared objects

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 16 00:50:17 PDT 2020


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

An undefined symbol in a shared object can be versioned, like `f at v1`.
We currently insert `f` as an Undefined into the symbol table, but we
should insert `f at v1` instead.

The string `v1` is deferred from SHT_GNU_versym and SHT_GNU_verneed.
This patch implements the functionality.

Failing to do this can cause two issues:

- If a versioned symbol referenced by a shared object is defined in the executable, we will fail to export it.
- If a versioned symbol referenced by a shared object in another object file, --no-allow-shlib-undefined may spuriously report an "undefined reference to " error. See https://bugs.llvm.org/show_bug.cgi?id=44842 (Linking -lfftw3 -lm on Arch Linux can cause `undefined reference to __log_finite`)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80059

Files:
  lld/ELF/InputFiles.cpp
  lld/ELF/InputFiles.h
  lld/test/ELF/invalid/verneed-shared.yaml
  lld/test/ELF/verneed-shared-undefined.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80059.264420.patch
Type: text/x-patch
Size: 9765 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200516/cfd47cc2/attachment.bin>


More information about the llvm-commits mailing list