Previously by default, when not using --ifc=, lld would not
deduplicate string literals. This reveals reliance on undefined behavior
where string literal addresses are compared instead of using string
equality checks. While ideally you would be able to easily identify and
eliminate the reliance on this UB, this can be difficult, especially for
third party code, and increases the friction and risk of users migrating
to lld. This flips the default to deduplicate strings unless
--no-deduplicate-strings is passed, matching ld64's behavior.
Details
- Reviewers
MaskRay int3 - Group Reviewers
Restricted Project - Commits
- rG2e5989e8140d: [lld-macho] Flip string deduplication default
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Discussion: https://discord.com/channels/636084430946959380/636732801042874388/1055235620844355595
Previous discussion: https://reviews.llvm.org/D117250
Thanks for doing this!
lld/MachO/InputFiles.cpp | ||
---|---|---|
345–346 | since we're deduping all word literals unconditionally now, we should hoist line 362 into its own if block & not gate it on config->dedupStrings. And I guess if we find any relocations in literal sections we should just error out unconditionally. | |
lld/MachO/Options.td | ||
61 | Is comparing string pointers actually undefined, or just not what the code author intended? | |
lld/MachO/Writer.cpp | ||
1329 | make unconditional |
Remove literal deduping
lld/MachO/Options.td | ||
---|---|---|
61 | Through the previous convos it sounded like it was UB but I can't find another source on that so I reworded. |
since we're deduping all word literals unconditionally now, we should hoist line 362 into its own if block & not gate it on config->dedupStrings. And I guess if we find any relocations in literal sections we should just error out unconditionally.