"cmd/compile/internal/types"
"cmd/internal/obj"
"cmd/internal/obj/arm64"
- "internal/buildcfg"
)
-var darwin = buildcfg.GOOS == "darwin" || buildcfg.GOOS == "ios"
-
func padframe(frame int64) int64 {
// arm64 requires that the frame size (not counting saved FP&LR)
// be 16 bytes aligned. If not, pad it.
for i := int64(0); i < cnt; i += int64(types.PtrSize) {
p = pp.Append(p, arm64.AMOVD, obj.TYPE_REG, arm64.REGZERO, 0, obj.TYPE_MEM, arm64.REGSP, 8+off+i)
}
- } else if cnt <= int64(128*types.PtrSize) && !darwin { // darwin ld64 cannot handle BR26 reloc with non-zero addend
+ } else if cnt <= int64(128*types.PtrSize) {
if cnt%(2*int64(types.PtrSize)) != 0 {
p = pp.Append(p, arm64.AMOVD, obj.TYPE_REG, arm64.REGZERO, 0, obj.TYPE_MEM, arm64.REGSP, 8+off)
off += int64(types.PtrSize)
v |= ld.MACHO_ARM64_RELOC_UNSIGNED << 28
case objabi.R_CALLARM64:
if xadd != 0 {
- ldr.Errorf(s, "ld64 doesn't allow BR26 reloc with non-zero addend: %s+%d", ldr.SymName(rs), xadd)
+ out.Write32(uint32(sectoff))
+ out.Write32((ld.MACHO_ARM64_RELOC_ADDEND << 28) | (2 << 25) | uint32(xadd&0xffffff))
}
v |= 1 << 24 // pc-relative bit
}
return val, nExtReloc, isOk
- case objabi.R_CALLARM64,
- objabi.R_ARM64_TLS_LE,
- objabi.R_ARM64_TLS_IE:
+
+ case objabi.R_CALLARM64:
nExtReloc = 1
- if rt == objabi.R_ARM64_TLS_IE {
- nExtReloc = 2 // need two ELF relocations. see elfreloc1
+ if target.IsDarwin() && r.Add() != 0 {
+ nExtReloc = 2 // need another relocation for addend
}
return val, nExtReloc, isOk
+ case objabi.R_ARM64_TLS_LE:
+ nExtReloc = 1
+ return val, nExtReloc, isOk
+
+ case objabi.R_ARM64_TLS_IE:
+ nExtReloc = 2 // need two ELF relocations. see elfreloc1
+ return val, nExtReloc, isOk
+
case objabi.R_ADDR:
if target.IsWindows() && r.Add() != 0 {
if r.Siz() == 8 {
case objabi.R_ARM64_GOTPCREL,
objabi.R_ADDRARM64:
rr := ld.ExtrelocViaOuterSym(ldr, r, s)
-
- // Note: ld64 currently has a bug that any non-zero addend for BR26 relocation
- // will make the linking fail because it thinks the code is not PIC even though
- // the BR26 relocation should be fully resolved at link time.
- // That is the reason why the next if block is disabled. When the bug in ld64
- // is fixed, we can enable this block and also enable duff's device in cmd/7g.
- if false && target.IsDarwin() {
- // Mach-O wants the addend to be encoded in the instruction
- // Note that although Mach-O supports ARM64_RELOC_ADDEND, it
- // can only encode 24-bit of signed addend, but the instructions
- // supports 33-bit of signed addend, so we always encode the
- // addend in place.
- rr.Xadd = 0
- }
return rr, true
case objabi.R_CALLARM64,
objabi.R_ARM64_TLS_LE,