Skip to content

[dsymutil] Only set a translation lambda if the translator is valid #987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2020
Merged

Conversation

JDevlieghere
Copy link

The SymbolMapTranslator defines an operator bool() which checks whether
we should translate at all. This returns false if the list of obfuscated
strings is empty.

The NonRelocatableStringPool (OffsetsStringPool) takes a lambda for
translating obfuscated strings rather than a SymbolMapTranslator.
However, we were unconditionally passing the SymbolMapTranslator, which
got implicitly converted to a std::function because it defines an
operator().

In the string pool, we call operator bool but on the lambda, and not on
the SymbolMapTranslator. This would always be true, because we were
passing the translator unconditionally. This caused spurious warnings
about obfuscated strings not being found.

This patch fixes the problem by only passing the translation lambda when
SymbolMapTranslator::operator bool() is true.

The SymbolMapTranslator defines an operator bool() which checks whether
we should translate at all. This returns false if the list of obfuscated
strings is empty.

The NonRelocatableStringPool (OffsetsStringPool) takes a lambda for
translating obfuscated strings rather than a SymbolMapTranslator.
However, we were unconditionally passing the SymbolMapTranslator, which
got implicitly converted to a std::function because it defines an
operator().

In the string pool, we call operator bool but on the lambda, and not on
the SymbolMapTranslator. This would always be true, because we were
passing the translator unconditionally. This caused spurious warnings
about obfuscated strings not being found.

This patch fixes the problem by only passing the translation lambda when
SymbolMapTranslator::operator bool() is true.
@JDevlieghere JDevlieghere requested a review from fredriss March 27, 2020 00:30
@JDevlieghere
Copy link
Author

rdar://60641222

This issue does not exist upstream, because it was (probably unintentionally) fixed during the big refactor that pulls up the DWARF linking logic so LLD can reuse it.

@JDevlieghere
Copy link
Author

@swift-ci please test macOS

@JDevlieghere JDevlieghere merged commit b1b73d7 into swiftlang:apple/stable/20200108 Mar 27, 2020
@JDevlieghere JDevlieghere deleted the rdar60641222 branch March 27, 2020 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant