@@ -801,7 +801,7 @@ func addexports(ctxt *Link) {
801
801
802
802
// perelocsect relocates symbols from first in section sect, and returns
803
803
// the total number of relocations emitted.
804
- func perelocsect (ctxt * Link , sect * Section , syms []* Symbol ) int {
804
+ func perelocsect (ctxt * Link , sect * Section , syms []* Symbol , base uint64 ) int {
805
805
// If main section has no bits, nothing to relocate.
806
806
if sect .Vaddr >= sect .Seg .Vaddr + sect .Seg .Filelen {
807
807
return 0
@@ -841,7 +841,7 @@ func perelocsect(ctxt *Link, sect *Section, syms []*Symbol) int {
841
841
if r .Xsym .Dynid < 0 {
842
842
Errorf (sym , "reloc %d to non-coff symbol %s (outer=%s) %d" , r .Type , r .Sym .Name , r .Xsym .Name , r .Sym .Type )
843
843
}
844
- if ! Thearch .PEreloc1 (sym , r , int64 (uint64 (sym .Value + int64 (r .Off ))- sect . Seg . Vaddr )) {
844
+ if ! Thearch .PEreloc1 (sym , r , int64 (uint64 (sym .Value + int64 (r .Off ))- base )) {
845
845
Errorf (sym , "unsupported obj reloc %d/%d to %s" , r .Type , r .Siz , r .Sym .Name )
846
846
}
847
847
@@ -887,21 +887,34 @@ func peemitreloc(ctxt *Link, text, data, ctors *IMAGE_SECTION_HEADER) {
887
887
}
888
888
889
889
peemitsectreloc (text , func () int {
890
- n := perelocsect (ctxt , Segtext .Sect , ctxt .Textp )
890
+ n := perelocsect (ctxt , Segtext .Sect , ctxt .Textp , Segtext . Vaddr )
891
891
for sect := Segtext .Sect .Next ; sect != nil ; sect = sect .Next {
892
- n += perelocsect (ctxt , sect , datap )
892
+ n += perelocsect (ctxt , sect , datap , Segtext . Vaddr )
893
893
}
894
894
return n
895
895
})
896
896
897
897
peemitsectreloc (data , func () int {
898
898
var n int
899
899
for sect := Segdata .Sect ; sect != nil ; sect = sect .Next {
900
- n += perelocsect (ctxt , sect , datap )
900
+ n += perelocsect (ctxt , sect , datap , Segdata . Vaddr )
901
901
}
902
902
return n
903
903
})
904
904
905
+ dwarfLoop:
906
+ for sect := Segdwarf .Sect ; sect != nil ; sect = sect .Next {
907
+ for i , name := range shNames {
908
+ if sect .Name == name {
909
+ peemitsectreloc (& sh [i ], func () int {
910
+ return perelocsect (ctxt , sect , dwarfp , sect .Vaddr )
911
+ })
912
+ continue dwarfLoop
913
+ }
914
+ }
915
+ Errorf (nil , "peemitsectreloc: could not find %q section" , sect .Name )
916
+ }
917
+
905
918
peemitsectreloc (ctors , func () int {
906
919
dottext := ctxt .Syms .Lookup (".text" , 0 )
907
920
Lputl (0 )
0 commit comments