mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-20 16:17:38 +00:00
Darwin: Add assembler directives to create version-min load commands.
Allow object files to be tagged with a version-min load command for iOS or MacOSX. Teach macho-dump to understand the version-min load commands for testcases. rdar://11337778 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204190 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -737,6 +737,8 @@ IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
|
||||
void MachObjectWriter::WriteObject(MCAssembler &Asm,
|
||||
const MCAsmLayout &Layout) {
|
||||
unsigned NumSections = Asm.size();
|
||||
const MCAssembler::VersionMinInfoType &VersionInfo =
|
||||
Layout.getAssembler().getVersionMinInfo();
|
||||
|
||||
// The section data starts after the header, the segment load command (and
|
||||
// section headers) and the symbol table.
|
||||
@@ -745,6 +747,12 @@ void MachObjectWriter::WriteObject(MCAssembler &Asm,
|
||||
sizeof(MachO::segment_command_64) + NumSections * sizeof(MachO::section_64):
|
||||
sizeof(MachO::segment_command) + NumSections * sizeof(MachO::section);
|
||||
|
||||
// Add the deployment target version info load command size, if used.
|
||||
if (VersionInfo.Major != 0) {
|
||||
++NumLoadCommands;
|
||||
LoadCommandsSize += sizeof(MachO::version_min_command);
|
||||
}
|
||||
|
||||
// Add the data-in-code load command size, if used.
|
||||
unsigned NumDataRegions = Asm.getDataRegions().size();
|
||||
if (NumDataRegions) {
|
||||
@@ -817,6 +825,20 @@ void MachObjectWriter::WriteObject(MCAssembler &Asm,
|
||||
RelocTableEnd += NumRelocs * sizeof(MachO::any_relocation_info);
|
||||
}
|
||||
|
||||
// Write out the deployment target information, if it's available.
|
||||
if (VersionInfo.Major != 0) {
|
||||
assert(VersionInfo.Update < 256 && "unencodable update target version");
|
||||
assert(VersionInfo.Minor < 256 && "unencodable minor target version");
|
||||
assert(VersionInfo.Major < 65536 && "unencodable major target version");
|
||||
uint32_t EncodedVersion = VersionInfo.Update | (VersionInfo.Minor << 8) |
|
||||
(VersionInfo.Major << 16);
|
||||
Write32(VersionInfo.Kind == MCVM_OSXVersionMin ? MachO::LC_VERSION_MIN_MACOSX :
|
||||
MachO::LC_VERSION_MIN_IPHONEOS);
|
||||
Write32(sizeof(MachO::version_min_command));
|
||||
Write32(EncodedVersion);
|
||||
Write32(0); // reserved.
|
||||
}
|
||||
|
||||
// Write the data-in-code load command, if used.
|
||||
uint64_t DataInCodeTableEnd = RelocTableEnd + NumDataRegions * 8;
|
||||
if (NumDataRegions) {
|
||||
|
||||
Reference in New Issue
Block a user