]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link, cmd/oldlink: remove more darwin/386 and darwin/arm code
authorCherry Zhang <cherryyz@google.com>
Wed, 22 Apr 2020 04:00:03 +0000 (00:00 -0400)
committerCherry Zhang <cherryyz@google.com>
Wed, 22 Apr 2020 15:27:18 +0000 (15:27 +0000)
Updates #37610, #37611.

Change-Id: I0a497af03e24ddea40ed3e342f3a9362bf21ac0c
Reviewed-on: https://go-review.googlesource.com/c/go/+/229323
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
src/cmd/link/internal/arm/asm.go
src/cmd/link/internal/ld/data.go
src/cmd/link/internal/x86/asm.go
src/cmd/oldlink/internal/arm/asm.go
src/cmd/oldlink/internal/ld/data.go
src/cmd/oldlink/internal/x86/asm.go

index e9eea5ce2c9ec1c8819092e1e2b30a62c4f68b41..446691f31856ea8e0f11b0f954aefecc2fa1bd13 100644 (file)
@@ -314,87 +314,7 @@ func elfsetupplt(ctxt *ld.Link, plt, got *loader.SymbolBuilder, dynamic loader.S
 }
 
 func machoreloc1(arch *sys.Arch, out *ld.OutBuf, s *sym.Symbol, r *sym.Reloc, sectoff int64) bool {
-       var v uint32
-
-       rs := r.Xsym
-
-       if r.Type == objabi.R_PCREL {
-               if rs.Type == sym.SHOSTOBJ {
-                       ld.Errorf(s, "pc-relative relocation of external symbol is not supported")
-                       return false
-               }
-               if r.Siz != 4 {
-                       return false
-               }
-
-               // emit a pair of "scattered" relocations that
-               // resolve to the difference of section addresses of
-               // the symbol and the instruction
-               // this value is added to the field being relocated
-               o1 := uint32(sectoff)
-               o1 |= 1 << 31 // scattered bit
-               o1 |= ld.MACHO_ARM_RELOC_SECTDIFF << 24
-               o1 |= 2 << 28 // size = 4
-
-               o2 := uint32(0)
-               o2 |= 1 << 31 // scattered bit
-               o2 |= ld.MACHO_ARM_RELOC_PAIR << 24
-               o2 |= 2 << 28 // size = 4
-
-               out.Write32(o1)
-               out.Write32(uint32(ld.Symaddr(rs)))
-               out.Write32(o2)
-               out.Write32(uint32(s.Value + int64(r.Off)))
-               return true
-       }
-
-       if rs.Type == sym.SHOSTOBJ || r.Type == objabi.R_CALLARM {
-               if rs.Dynid < 0 {
-                       ld.Errorf(s, "reloc %d (%s) to non-macho symbol %s type=%d (%s)", r.Type, sym.RelocName(arch, r.Type), rs.Name, rs.Type, rs.Type)
-                       return false
-               }
-
-               v = uint32(rs.Dynid)
-               v |= 1 << 27 // external relocation
-       } else {
-               v = uint32(rs.Sect.Extnum)
-               if v == 0 {
-                       ld.Errorf(s, "reloc %d (%s) to symbol %s in non-macho section %s type=%d (%s)", r.Type, sym.RelocName(arch, r.Type), rs.Name, rs.Sect.Name, rs.Type, rs.Type)
-                       return false
-               }
-       }
-
-       switch r.Type {
-       default:
-               return false
-
-       case objabi.R_ADDR:
-               v |= ld.MACHO_GENERIC_RELOC_VANILLA << 28
-
-       case objabi.R_CALLARM:
-               v |= 1 << 24 // pc-relative bit
-               v |= ld.MACHO_ARM_RELOC_BR24 << 28
-       }
-
-       switch r.Siz {
-       default:
-               return false
-       case 1:
-               v |= 0 << 25
-
-       case 2:
-               v |= 1 << 25
-
-       case 4:
-               v |= 2 << 25
-
-       case 8:
-               v |= 3 << 25
-       }
-
-       out.Write32(uint32(sectoff))
-       out.Write32(v)
-       return true
+       return false
 }
 
 func pereloc1(arch *sys.Arch, out *ld.OutBuf, s *sym.Symbol, r *sym.Reloc, sectoff int64) bool {
index 6569c155c6c9fb3f516350763eccfd1bed8edf1d..46fc6ec304c7ac701b64db8e674c84a5f25af266 100644 (file)
@@ -465,14 +465,9 @@ func relocsym(target *Target, ldr *loader.Loader, err *ErrorReporter, syms *Arch
                                } else if target.IsDarwin() {
                                        if r.Type == objabi.R_CALL {
                                                if target.IsExternal() && rs.Type == sym.SDYNIMPORT {
-                                                       switch target.Arch.Family {
-                                                       case sys.AMD64:
+                                                       if target.IsAMD64() {
                                                                // AMD64 dynamic relocations are relative to the end of the relocation.
                                                                o += int64(r.Siz)
-                                                       case sys.I386:
-                                                               // I386 dynamic relocations are relative to the start of the section.
-                                                               o -= int64(r.Off)                         // offset in symbol
-                                                               o -= int64(s.Value - int64(s.Sect.Vaddr)) // offset of symbol in section
                                                        }
                                                } else {
                                                        if rs.Type != sym.SHOSTOBJ {
@@ -480,9 +475,6 @@ func relocsym(target *Target, ldr *loader.Loader, err *ErrorReporter, syms *Arch
                                                        }
                                                        o -= int64(r.Off) // relative to section offset, not symbol
                                                }
-                                       } else if target.IsARM() {
-                                               // see ../arm/asm.go:/machoreloc1
-                                               o += Symaddr(rs) - s.Value - int64(r.Off)
                                        } else {
                                                o += int64(r.Siz)
                                        }
index 7dcdda0fa80d4539a605acf60ba7b8d67bb63a58..650fe12f94a91b5f4a605c4564c8eacbb48b7e88 100644 (file)
@@ -372,53 +372,7 @@ func elfreloc1(ctxt *ld.Link, r *sym.Reloc, sectoff int64) bool {
 }
 
 func machoreloc1(arch *sys.Arch, out *ld.OutBuf, s *sym.Symbol, r *sym.Reloc, sectoff int64) bool {
-       var v uint32
-
-       rs := r.Xsym
-
-       if rs.Type == sym.SHOSTOBJ || r.Type == objabi.R_CALL {
-               if rs.Dynid < 0 {
-                       ld.Errorf(s, "reloc %d (%s) to non-macho symbol %s type=%d (%s)", r.Type, sym.RelocName(arch, r.Type), rs.Name, rs.Type, rs.Type)
-                       return false
-               }
-
-               v = uint32(rs.Dynid)
-               v |= 1 << 27 // external relocation
-       } else {
-               v = uint32(rs.Sect.Extnum)
-               if v == 0 {
-                       ld.Errorf(s, "reloc %d (%s) to symbol %s in non-macho section %s type=%d (%s)", r.Type, sym.RelocName(arch, r.Type), rs.Name, rs.Sect.Name, rs.Type, rs.Type)
-                       return false
-               }
-       }
-
-       switch r.Type {
-       default:
-               return false
-       case objabi.R_ADDR:
-               v |= ld.MACHO_GENERIC_RELOC_VANILLA << 28
-       case objabi.R_CALL,
-               objabi.R_PCREL:
-               v |= 1 << 24 // pc-relative bit
-               v |= ld.MACHO_GENERIC_RELOC_VANILLA << 28
-       }
-
-       switch r.Siz {
-       default:
-               return false
-       case 1:
-               v |= 0 << 25
-       case 2:
-               v |= 1 << 25
-       case 4:
-               v |= 2 << 25
-       case 8:
-               v |= 3 << 25
-       }
-
-       out.Write32(uint32(sectoff))
-       out.Write32(v)
-       return true
+       return false
 }
 
 func pereloc1(arch *sys.Arch, out *ld.OutBuf, s *sym.Symbol, r *sym.Reloc, sectoff int64) bool {
index a2a0879c5b0331faaa3c69a6ef9c04aa9fda36fd..de6173569ae851f540459ce0176d8310c9a7ab73 100644 (file)
@@ -328,87 +328,7 @@ func elfsetupplt(ctxt *ld.Link) {
 }
 
 func machoreloc1(arch *sys.Arch, out *ld.OutBuf, s *sym.Symbol, r *sym.Reloc, sectoff int64) bool {
-       var v uint32
-
-       rs := r.Xsym
-
-       if r.Type == objabi.R_PCREL {
-               if rs.Type == sym.SHOSTOBJ {
-                       ld.Errorf(s, "pc-relative relocation of external symbol is not supported")
-                       return false
-               }
-               if r.Siz != 4 {
-                       return false
-               }
-
-               // emit a pair of "scattered" relocations that
-               // resolve to the difference of section addresses of
-               // the symbol and the instruction
-               // this value is added to the field being relocated
-               o1 := uint32(sectoff)
-               o1 |= 1 << 31 // scattered bit
-               o1 |= ld.MACHO_ARM_RELOC_SECTDIFF << 24
-               o1 |= 2 << 28 // size = 4
-
-               o2 := uint32(0)
-               o2 |= 1 << 31 // scattered bit
-               o2 |= ld.MACHO_ARM_RELOC_PAIR << 24
-               o2 |= 2 << 28 // size = 4
-
-               out.Write32(o1)
-               out.Write32(uint32(ld.Symaddr(rs)))
-               out.Write32(o2)
-               out.Write32(uint32(s.Value + int64(r.Off)))
-               return true
-       }
-
-       if rs.Type == sym.SHOSTOBJ || r.Type == objabi.R_CALLARM {
-               if rs.Dynid < 0 {
-                       ld.Errorf(s, "reloc %d (%s) to non-macho symbol %s type=%d (%s)", r.Type, sym.RelocName(arch, r.Type), rs.Name, rs.Type, rs.Type)
-                       return false
-               }
-
-               v = uint32(rs.Dynid)
-               v |= 1 << 27 // external relocation
-       } else {
-               v = uint32(rs.Sect.Extnum)
-               if v == 0 {
-                       ld.Errorf(s, "reloc %d (%s) to symbol %s in non-macho section %s type=%d (%s)", r.Type, sym.RelocName(arch, r.Type), rs.Name, rs.Sect.Name, rs.Type, rs.Type)
-                       return false
-               }
-       }
-
-       switch r.Type {
-       default:
-               return false
-
-       case objabi.R_ADDR:
-               v |= ld.MACHO_GENERIC_RELOC_VANILLA << 28
-
-       case objabi.R_CALLARM:
-               v |= 1 << 24 // pc-relative bit
-               v |= ld.MACHO_ARM_RELOC_BR24 << 28
-       }
-
-       switch r.Siz {
-       default:
-               return false
-       case 1:
-               v |= 0 << 25
-
-       case 2:
-               v |= 1 << 25
-
-       case 4:
-               v |= 2 << 25
-
-       case 8:
-               v |= 3 << 25
-       }
-
-       out.Write32(uint32(sectoff))
-       out.Write32(v)
-       return true
+       return false
 }
 
 func pereloc1(arch *sys.Arch, out *ld.OutBuf, s *sym.Symbol, r *sym.Reloc, sectoff int64) bool {
index 13f412ccd85baf782d33b47711528772c95b52f6..ba4a74156be45814685917ea6d1bab052863c582 100644 (file)
@@ -455,14 +455,9 @@ func relocsym(ctxt *Link, s *sym.Symbol) {
                                } else if ctxt.HeadType == objabi.Hdarwin {
                                        if r.Type == objabi.R_CALL {
                                                if ctxt.LinkMode == LinkExternal && rs.Type == sym.SDYNIMPORT {
-                                                       switch ctxt.Arch.Family {
-                                                       case sys.AMD64:
+                                                       if ctxt.Arch.Family == sys.AMD64 {
                                                                // AMD64 dynamic relocations are relative to the end of the relocation.
                                                                o += int64(r.Siz)
-                                                       case sys.I386:
-                                                               // I386 dynamic relocations are relative to the start of the section.
-                                                               o -= int64(r.Off)                         // offset in symbol
-                                                               o -= int64(s.Value - int64(s.Sect.Vaddr)) // offset of symbol in section
                                                        }
                                                } else {
                                                        if rs.Type != sym.SHOSTOBJ {
@@ -470,9 +465,6 @@ func relocsym(ctxt *Link, s *sym.Symbol) {
                                                        }
                                                        o -= int64(r.Off) // relative to section offset, not symbol
                                                }
-                                       } else if ctxt.Arch.Family == sys.ARM {
-                                               // see ../arm/asm.go:/machoreloc1
-                                               o += Symaddr(rs) - s.Value - int64(r.Off)
                                        } else {
                                                o += int64(r.Siz)
                                        }
index 34668063dae5ff08502a73abcfbdc2d5320d858b..e8e52f671fbd4181ac709d458321b81a653afca5 100644 (file)
@@ -410,53 +410,7 @@ func elfreloc1(ctxt *ld.Link, r *sym.Reloc, sectoff int64) bool {
 }
 
 func machoreloc1(arch *sys.Arch, out *ld.OutBuf, s *sym.Symbol, r *sym.Reloc, sectoff int64) bool {
-       var v uint32
-
-       rs := r.Xsym
-
-       if rs.Type == sym.SHOSTOBJ || r.Type == objabi.R_CALL {
-               if rs.Dynid < 0 {
-                       ld.Errorf(s, "reloc %d (%s) to non-macho symbol %s type=%d (%s)", r.Type, sym.RelocName(arch, r.Type), rs.Name, rs.Type, rs.Type)
-                       return false
-               }
-
-               v = uint32(rs.Dynid)
-               v |= 1 << 27 // external relocation
-       } else {
-               v = uint32(rs.Sect.Extnum)
-               if v == 0 {
-                       ld.Errorf(s, "reloc %d (%s) to symbol %s in non-macho section %s type=%d (%s)", r.Type, sym.RelocName(arch, r.Type), rs.Name, rs.Sect.Name, rs.Type, rs.Type)
-                       return false
-               }
-       }
-
-       switch r.Type {
-       default:
-               return false
-       case objabi.R_ADDR:
-               v |= ld.MACHO_GENERIC_RELOC_VANILLA << 28
-       case objabi.R_CALL,
-               objabi.R_PCREL:
-               v |= 1 << 24 // pc-relative bit
-               v |= ld.MACHO_GENERIC_RELOC_VANILLA << 28
-       }
-
-       switch r.Siz {
-       default:
-               return false
-       case 1:
-               v |= 0 << 25
-       case 2:
-               v |= 1 << 25
-       case 4:
-               v |= 2 << 25
-       case 8:
-               v |= 3 << 25
-       }
-
-       out.Write32(uint32(sectoff))
-       out.Write32(v)
-       return true
+       return false
 }
 
 func pereloc1(arch *sys.Arch, out *ld.OutBuf, s *sym.Symbol, r *sym.Reloc, sectoff int64) bool {