Page MenuHomePhabricator

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

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

Details

Reviewers
alexshap
smeenai
Group Reviewers
Restricted Project
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.Sat, Oct 17, 8:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptSat, Oct 17, 8:46 PM
int3 requested review of this revision.Sat, Oct 17, 8:46 PM
int3 added a comment.Sat, Oct 17, 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.Mon, Oct 19, 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.Tue, Oct 20, 10:00 PM