[dev.link] cmd/link: fix R_GOTOFF handling

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>
This commit is contained in:
Cherry Zhang 2020-04-29 10:07:07 -04:00
parent 095d2a4532
commit df2a46f85a
3 changed files with 6 additions and 24 deletions

View file

@ -528,6 +528,12 @@ func relocsym(target *Target, ldr *loader.Loader, err *ErrorReporter, syms *Arch
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() {