[PATCH] D103821: [lld/mac] Take dylib version numbers from first loaded dylib with name, load reexports after reexporter

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 7 08:31:51 PDT 2021


thakis created this revision.
thakis added a reviewer: lld-macho.
Herald added a reviewer: int3.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
thakis requested review of this revision.

When a library "host"'s reexports change their installName with `$ld$os10.11$install_name$host`,
we used to write a load command for "host" but write the version numbers of the reexport
instead of "host". This fixes that.

I first thought that the rule is to take the version numbers from the library that originally had
that install name (implemented in D103819 <https://reviews.llvm.org/D103819>), but that's not what ld64 seems to be doing: It
takes the version number from the first dylib with that install name it loads, and it loads
the reexporting library before the reexports. We already did most of that, we just added
reexports before the reexporter. After this change, we add the reexporter before the reexports.

Addresses https://bugs.llvm.org/show_bug.cgi?id=49800#c11 part 1.

(ld64 seems to add reexports after processing _all_ files on the command line, while we add
them right after the reexporter. For the common case of reexport + $ld$ symbol changing back
to the exporter name, this doesn't make a difference, but you can construct a case where it
does. I expect this to not make a difference in practice though.)


https://reviews.llvm.org/D103821

Files:
  lld/MachO/Driver.cpp
  lld/MachO/InputFiles.cpp
  lld/test/MachO/implicit-dylibs.s
  lld/test/MachO/special-symbol-ld-install-name.s
  lld/test/MachO/tapi-link.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103821.350308.patch
Type: text/x-patch
Size: 6593 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210607/c0cacabe/attachment.bin>


More information about the llvm-commits mailing list