// PE/COFF's PC32 relocation uses the address after the relocated
// bytes as the base. Compensate by skewing the addend.
o += int64(r.Siz)
- // GNU ld always add VirtualAddress of the .text section to the
- // relocated address, compensate that.
- o -= int64(s.Sect.Vaddr - PEBASE)
} else {
Errorf(s, "unhandled pcrel relocation to %s on %v", rs.Name, Headtype)
}
} else {
binary.Write(&coutbuf, binary.LittleEndian, &oh)
}
+ if Linkmode == LinkExternal {
+ for i := range sh[:pensect] {
+ sh[i].VirtualAddress = 0
+ }
+ }
binary.Write(&coutbuf, binary.LittleEndian, sh[:pensect])
}
if r.Xsym.Dynid < 0 {
Errorf(sym, "reloc %d to non-coff symbol %s (outer=%s) %d", r.Type, r.Sym.Name, r.Xsym.Name, r.Sym.Type)
}
- if !Thearch.PEreloc1(sym, r, int64(uint64(sym.Value+int64(r.Off))-PEBASE)) {
+ if !Thearch.PEreloc1(sym, r, int64(uint64(sym.Value+int64(r.Off))-sect.Seg.Vaddr)) {
Errorf(sym, "unsupported obj reloc %d/%d to %s", r.Type, r.Siz, r.Sym.Name)
}
dottext := ctxt.Syms.Lookup(".text", 0)
ctors.NumberOfRelocations = 1
ctors.PointerToRelocations = uint32(coutbuf.Offset())
- sectoff := ctors.VirtualAddress
- Lputl(sectoff)
+ Lputl(0)
Lputl(uint32(dottext.Dynid))
switch obj.GOARCH {
default: