This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Emit empty string as first entry of string table
ClosedPublic

Authored by int3 on Oct 17 2020, 8:46 PM.

Details

Summary

ld64 emits string tables which start with a space and a zero byte. We
match its behavior here since some tools depend on it.

Similar rationale as D89561: [MC] Adjust StringTableBuilder for linked Mach-O binaries.

Diff Detail

Event Timeline

int3 created this revision.Oct 17 2020, 8:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 17 2020, 8:46 PM
int3 requested review of this revision.Oct 17 2020, 8:46 PM
int3 added a comment.Oct 17 2020, 8:48 PM

Note that unlike D89561, this diff doesn't need to make any alignment-related changes as LLD should already be handling that correctly. See the linkedit-contiguity.s test for more details.

Do we have any logic to emit an n_strx for an empty string? If so, that would need to be adjusted to emit 1 instead of 0. If not, LGTM.

int3 added a comment.Oct 19 2020, 7:04 PM

Do we have any logic to emit an n_strx for an empty string?

Nope. In general, we don't make any attempt to dedup strings (I think ld64 does the same thing)

This revision is now accepted and ready to land.Oct 20 2020, 10:00 PM
This revision was landed with ongoing or failed builds.Dec 1 2020, 3:05 PM
This revision was automatically updated to reflect the committed changes.