macho: use smaller padding until we have branch islands on arm64

Without branch islands, it is impossible to link self-hosted using
the common linker path.
This commit is contained in:
Jakub Konka 2021-09-08 13:17:43 +02:00
parent e229202cb8
commit e00b9d6192
2 changed files with 14 additions and 3 deletions

View File

@ -262,7 +262,7 @@ pub const GotIndirectionKey = struct {
/// When allocating, the ideal_capacity is calculated by
/// actual_capacity + (actual_capacity / ideal_factor)
const ideal_factor = 2;
const ideal_factor = 4;
/// Default path to dyld
const default_dyld_path: [*:0]const u8 = "/usr/lib/dyld";

View File

@ -243,10 +243,21 @@ pub const Relocation = struct {
pub fn resolve(self: Branch, args: ResolveArgs) !void {
switch (self.arch) {
.aarch64 => {
const displacement = try math.cast(
const displacement = math.cast(
i28,
@intCast(i64, args.target_addr) - @intCast(i64, args.source_addr),
);
) catch |err| switch (err) {
error.Overflow => {
log.err("jump too big to encode as i28 displacement value", .{});
log.err(" (target - source) = displacement => 0x{x} - 0x{x} = 0x{x}", .{
args.target_addr,
args.source_addr,
@intCast(i64, args.target_addr) - @intCast(i64, args.source_addr),
});
log.err(" TODO implement branch islands to extend jump distance for arm64", .{});
return error.TODOImplementBranchIslands;
},
};
const code = args.block.code.items[args.offset..][0..4];
var inst = aarch64.Instruction{
.unconditional_branch_immediate = mem.bytesToValue(meta.TagPayload(