@@ -901,6 +901,31 @@ func elfwritegobuildid(out *OutBuf) int {
901
901
return int (sh .Size )
902
902
}
903
903
904
+ const (
905
+ ELF_NOTE_PVH_TAG = 0x12
906
+ )
907
+
908
+ var ELF_NOTE_PVH_NAME = []byte ("Xen\x00 " )
909
+
910
+ func elfpvh (sh * ElfShdr , startva uint64 , resoff uint64 ) int {
911
+ n := len (ELF_NOTE_PVH_NAME ) + 8
912
+ return elfnote (sh , startva , resoff , n )
913
+ }
914
+
915
+ func elfwritepvh (ctxt * Link ) int {
916
+ sh := elfwritenotehdr (ctxt .Out , ".note.go.pvh" , uint32 (len (ELF_NOTE_PVH_NAME )), 8 , ELF_NOTE_PVH_TAG )
917
+ if sh == nil {
918
+ return 0
919
+ }
920
+
921
+ ctxt .Out .Write (ELF_NOTE_PVH_NAME )
922
+ var entry = make ([]byte , 8 )
923
+ binary .LittleEndian .PutUint64 (entry , uint64 (Entryvalue (ctxt )))
924
+ ctxt .Out .Write (entry )
925
+
926
+ return int (sh .Size )
927
+ }
928
+
904
929
// Go specific notes
905
930
const (
906
931
ELF_NOTE_GOPKGLIST_TAG = 1
@@ -1467,6 +1492,9 @@ func (ctxt *Link) doelf() {
1467
1492
if * flagBuildid != "" {
1468
1493
shstrtabAddstring (".note.go.buildid" )
1469
1494
}
1495
+ if buildcfg .GOOS == "tamago" {
1496
+ shstrtabAddstring (".note.go.pvh" )
1497
+ }
1470
1498
shstrtabAddstring (".elfdata" )
1471
1499
shstrtabAddstring (".rodata" )
1472
1500
// See the comment about data.rel.ro.FOO section names in data.go.
@@ -2015,6 +2043,12 @@ func asmbElf(ctxt *Link) {
2015
2043
phsh (getpnote (), sh )
2016
2044
}
2017
2045
2046
+ if buildcfg .GOOS == "tamago" {
2047
+ sh := elfshname (".note.go.pvh" )
2048
+ resoff -= int64 (elfpvh (sh , uint64 (startva ), uint64 (resoff )))
2049
+ phsh (getpnote (), sh )
2050
+ }
2051
+
2018
2052
// Additions to the reserved area must be above this line.
2019
2053
2020
2054
elfphload (& Segtext )
@@ -2385,6 +2419,9 @@ elfobj:
2385
2419
if * flagBuildid != "" {
2386
2420
a += int64 (elfwritegobuildid (ctxt .Out ))
2387
2421
}
2422
+ if buildcfg .GOOS == "tamago" {
2423
+ a += int64 (elfwritepvh (ctxt ))
2424
+ }
2388
2425
}
2389
2426
if * flagRace && ctxt .IsNetbsd () {
2390
2427
a += int64 (elfwritenetbsdpax (ctxt .Out ))
0 commit comments