When applying relocations, we need to resolve ABI aliases.
relocsym does that. Architecture-specific archreloc also needs to
do that. The old code doesn't do that since ABI aliases are
resolved in loadlibfull, or, in the old linker, in a much earlier
stage. We don't do this in the new linker, as we want to avoid
mutating relocations.
While here, move R_CONST and R_GOTOFF handling to generic code.
They appear on several architectures and the handling are same.
Should fix 386-clang and *bsd-386 builds.
Change-Id: I6681c94f0327555d6cf329d0a518c88848773671
Reviewed-on: https://go-review.googlesource.com/c/go/+/230857
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
case objabi.R_DWARFFILEREF:
// We don't renumber files in dwarf.go:writelines anymore.
continue
+
+ case objabi.R_CONST:
+ o = r.Add()
+
+ case objabi.R_GOTOFF:
+ o = ldr.SymValue(rs) + r.Add() - ldr.SymValue(syms.GOT2)
}
//if target.IsPPC64() || target.IsS390X() {
}
func archreloc2(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, r *loader.Reloc2, sym loader.Sym, val int64) (int64, bool) {
- if target.IsExternal() {
- return val, false
- }
- switch r.Type() {
- case objabi.R_CONST:
- return r.Add(), true
- case objabi.R_GOTOFF:
- return ldr.SymValue(r.Sym()) + r.Add() - ldr.SymValue(syms.GOT2), true
- }
- return val, false
-}
-
-func archreloc(target *ld.Target, syms *ld.ArchSyms, r *sym.Reloc, s *sym.Symbol, val int64) (int64, bool) {
- if target.IsExternal() {
- return val, false
- }
- switch r.Type {
- case objabi.R_CONST:
- return r.Add, true
- case objabi.R_GOTOFF:
- return ld.Symaddr(r.Sym) + r.Add - ld.Symaddr(syms.GOT), true
- }
-
return val, false
}
Adddynrel2: adddynrel2,
Archinit: archinit,
- Archreloc: archreloc,
Archreloc2: archreloc2,
Archrelocvariant: archrelocvariant,
Asmb: asmb,