Add support for deterministically linked binaries on macOS to lldb.
authorNico Weber <nicolasweber@gmx.de>
Wed, 7 Aug 2019 19:29:04 +0000 (19:29 +0000)
committerNico Weber <nicolasweber@gmx.de>
Wed, 7 Aug 2019 19:29:04 +0000 (19:29 +0000)
commit8883ec7da2e9d010c1355d90fc2f0c543826f355
tree4c536c7697c7d4e931f8ae1068bc36162727a5c9
parent353938ec687cf93a3cd0b567ee1d040230b7c9f8
Add support for deterministically linked binaries on macOS to lldb.

When ld64 links a binary deterministically using the flag ZERO_AR_DATE,
it sets a timestamp of 0 for N_OSO members in the symtab section, rather
than the usual last modified date of the object file. Prior to this
patch, lldb would compare the timestamp from the N_OSO member against
the last modified date of the object file, and skip loading the object
file if there was a mismatch. This patch updates the logic to ignore the
timestamp check if the N_OSO member has timestamp 0.

The original logic was added in https://reviews.llvm.org/rL181631 as a
safety check to avoid problems when debugging if the object file was out
of date. This was prior to the introduction of deterministic build in
ld64. lld still doesn't support deterministic build.

Other code in llvm already relies on and uses the assumption that a
timestamp of 0 means deterministic build. For example, commit
9ccfddc39d4d27f9b16fcc72ab30d483151d6d08 adds similar timestamp checking
logic to dsymutil, but special cases timestamp 0. Likewise, commit
0d1bb79a0413f221432a7b1d0d2d10c84c4bbb99 adds a long comment describing
deterministic archive, which mostly uses timestamp 0 for determinism.

Patch from Erik Chen <erikchen@chromium.org>!

Differential Revision: https://reviews.llvm.org/D65826

llvm-svn: 368199
lldb/lit/SymbolFile/DWARF/deterministic-build.cpp [new file with mode: 0644]
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp