This flag instructs dyld to mark the segment read-only after fixups have
been performed.
I'm not sure why this flag is needed, as on macOS 13 beta at least,
__DATA_CONST is read-only even without this flag, but ld64 sets it as
well.
Paths
| Differential D133010
[lld-macho] Set the SG_READ_ONLY flag on __DATA_CONST ClosedPublic Authored by BertalanD on Aug 31 2022, 3:53 AM.
Details
Summary This flag instructs dyld to mark the segment read-only after fixups have I'm not sure why this flag is needed, as on macOS 13 beta at least,
Diff Detail Event TimelineComment Actions lgtm
This revision is now accepted and ready to land.Aug 31 2022, 5:32 AM Comment Actions lg
Closed by commit rGf7b752d27766: [lld-macho] Set the SG_READ_ONLY flag on __DATA_CONST (authored by BertalanD). · Explain WhyAug 31 2022, 8:22 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 456947 lld/MachO/OutputSegment.h
lld/MachO/OutputSegment.cpp
lld/MachO/Writer.cpp
lld/test/MachO/builtin-rename.s
llvm/include/llvm/BinaryFormat/MachO.h
llvm/tools/llvm-objdump/MachODump.cpp
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ld64 checks this:
I think we only end up with dataConst segments if config->dataConst (the first check) (…or if users use that segment name explicitly, but then they kind of ask for this treatment, so that seems fine).
We don't implement neither -dylinker nor -add_split_seg_info / -not_for_dyld_shared_cache (not sure why the positive and negative forms of that have different names…), and it's unlikely we'll add them (seems they're only needed for the linker used to link the OS), so we don't really have to worry about the second part. But maybe this could grow a comment around the lines of "If we ever implement shared cache output support, don't set this for shared cache dylibs".
(Or not. As-is is fine too, up to you.)