mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 02:33:33 +00:00
[MC/Mach-O] Load commands are supposed to 8-byte aligned on 64-bit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173120 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7511aab27b
commit
849209686f
@ -377,25 +377,25 @@ void MachObjectWriter::WriteLinkeditLoadCommand(uint32_t Type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static unsigned ComputeLinkerOptionsLoadCommandSize(
|
static unsigned ComputeLinkerOptionsLoadCommandSize(
|
||||||
const std::vector<std::string> &Options)
|
const std::vector<std::string> &Options, bool is64Bit)
|
||||||
{
|
{
|
||||||
unsigned Size = sizeof(macho::LinkerOptionsLoadCommand);
|
unsigned Size = sizeof(macho::LinkerOptionsLoadCommand);
|
||||||
for (unsigned i = 0, e = Options.size(); i != e; ++i)
|
for (unsigned i = 0, e = Options.size(); i != e; ++i)
|
||||||
Size += Options[i].size() + 1;
|
Size += Options[i].size() + 1;
|
||||||
return RoundUpToAlignment(Size, 4);
|
return RoundUpToAlignment(Size, is64Bit ? 8 : 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MachObjectWriter::WriteLinkerOptionsLoadCommand(
|
void MachObjectWriter::WriteLinkerOptionsLoadCommand(
|
||||||
const std::vector<std::string> &Options)
|
const std::vector<std::string> &Options)
|
||||||
{
|
{
|
||||||
unsigned Size = ComputeLinkerOptionsLoadCommandSize(Options);
|
unsigned Size = ComputeLinkerOptionsLoadCommandSize(Options, is64Bit());
|
||||||
uint64_t Start = OS.tell();
|
uint64_t Start = OS.tell();
|
||||||
(void) Start;
|
(void) Start;
|
||||||
|
|
||||||
Write32(macho::LCT_LinkerOptions);
|
Write32(macho::LCT_LinkerOptions);
|
||||||
Write32(Size);
|
Write32(Size);
|
||||||
Write32(Options.size());
|
Write32(Options.size());
|
||||||
uint64_t BytesWritten = 0;
|
uint64_t BytesWritten = sizeof(macho::LinkerOptionsLoadCommand);
|
||||||
for (unsigned i = 0, e = Options.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Options.size(); i != e; ++i) {
|
||||||
// Write each string, including the null byte.
|
// Write each string, including the null byte.
|
||||||
const std::string &Option = Options[i];
|
const std::string &Option = Options[i];
|
||||||
@ -403,8 +403,8 @@ void MachObjectWriter::WriteLinkerOptionsLoadCommand(
|
|||||||
BytesWritten += Option.size() + 1;
|
BytesWritten += Option.size() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pad to a multiple of 4.
|
// Pad to a multiple of the pointer size.
|
||||||
WriteBytes("", OffsetToAlignment(BytesWritten, 4));
|
WriteBytes("", OffsetToAlignment(BytesWritten, is64Bit() ? 8 : 4));
|
||||||
|
|
||||||
assert(OS.tell() - Start == Size);
|
assert(OS.tell() - Start == Size);
|
||||||
}
|
}
|
||||||
@ -747,7 +747,8 @@ void MachObjectWriter::WriteObject(MCAssembler &Asm,
|
|||||||
Asm.getLinkerOptions();
|
Asm.getLinkerOptions();
|
||||||
for (unsigned i = 0, e = LinkerOptions.size(); i != e; ++i) {
|
for (unsigned i = 0, e = LinkerOptions.size(); i != e; ++i) {
|
||||||
++NumLoadCommands;
|
++NumLoadCommands;
|
||||||
LoadCommandsSize += ComputeLinkerOptionsLoadCommandSize(LinkerOptions[i]);
|
LoadCommandsSize += ComputeLinkerOptionsLoadCommandSize(LinkerOptions[i],
|
||||||
|
is64Bit());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute the total size of the section data, as well as its file size and vm
|
// Compute the total size of the section data, as well as its file size and vm
|
||||||
|
@ -24,12 +24,20 @@
|
|||||||
; CHECK-OBJ: "-framework",
|
; CHECK-OBJ: "-framework",
|
||||||
; CHECK-OBJ: "Cocoa",
|
; CHECK-OBJ: "Cocoa",
|
||||||
; CHECK-OBJ: ])
|
; CHECK-OBJ: ])
|
||||||
|
; CHECK-OBJ: # Load Command 3
|
||||||
|
; CHECK-OBJ: (('command', 45)
|
||||||
|
; CHECK-OBJ: ('size', 24)
|
||||||
|
; CHECK-OBJ: ('count', 1)
|
||||||
|
; CHECK-OBJ: ('_strings', [
|
||||||
|
; CHECK-OBJ: "-lmath",
|
||||||
|
; CHECK-OBJ: ])
|
||||||
; CHECK-OBJ: ),
|
; CHECK-OBJ: ),
|
||||||
; CHECK-OBJ: ])
|
; CHECK-OBJ: ])
|
||||||
|
|
||||||
!0 = metadata !{ i32 6, metadata !"Linker Options",
|
!0 = metadata !{ i32 6, metadata !"Linker Options",
|
||||||
metadata !{
|
metadata !{
|
||||||
metadata !{ metadata !"-lz" },
|
metadata !{ metadata !"-lz" },
|
||||||
metadata !{ metadata !"-framework", metadata !"Cocoa" } } }
|
metadata !{ metadata !"-framework", metadata !"Cocoa" },
|
||||||
|
metadata !{ metadata !"-lmath" } } }
|
||||||
|
|
||||||
!llvm.module.flags = !{ !0 }
|
!llvm.module.flags = !{ !0 }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user