@@ -695,26 +695,6 @@ func elfWriteMipsAbiFlags(ctxt *Link) int {
695695 return int (sh .Size )
696696}
697697
698-
699- var ELF_COMMENT_HAIKU = "GCC: (GNU) 11.2.0"
700-
701- func elfhaikucomment (sh * ElfShdr , startva uint64 , resoff uint64 ) int {
702- n := len (ELF_COMMENT_HAIKU ) + 1
703- sh .Addr = startva + resoff - uint64 (n )
704- sh .Off = resoff - uint64 (n )
705- sh .Size = uint64 (n )
706-
707- return n
708- }
709-
710- func elfwritehaikucomment (out * OutBuf ) int {
711- sh := elfshname (".comment" )
712- out .SeekSet (int64 (sh .Off ))
713- out .WriteString (ELF_COMMENT_HAIKU )
714- out .Write8 (0 )
715- return int (sh .Size )
716- }
717-
718698func elfnote (sh * ElfShdr , startva uint64 , resoff uint64 , sizes ... int ) int {
719699 n := resoff % 4
720700 // if section contains multiple notes (as is the case with FreeBSD signature),
@@ -746,6 +726,30 @@ func elfwritenotehdr(out *OutBuf, str string, namesz uint32, descsz uint32, tag
746726 return sh
747727}
748728
729+ var ELF_COMMENT_HAIKU = []byte ("GCC: (GNU) 13.3.0\x00 " )
730+
731+ func elfhaikucomment (sh * ElfShdr , startva uint64 , resoff uint64 ) int {
732+ n := len (ELF_COMMENT_HAIKU )
733+ sh .Addr = startva + resoff - uint64 (n )
734+ sh .Off = resoff - uint64 (n )
735+ sh .Size = uint64 (n )
736+
737+ return n
738+ }
739+
740+ func elfwritehaikucomment (out * OutBuf ) int {
741+ // Write Elf_Note header.
742+ sh := elfwritenotehdr (out , ".comment" , uint32 (len (ELF_COMMENT_HAIKU )), 0 , 0 )
743+
744+ if sh == nil {
745+ return 0
746+ }
747+
748+ out .SeekSet (int64 (sh .Off ))
749+ out .Write (ELF_COMMENT_HAIKU )
750+ return int (sh .Size )
751+ }
752+
749753// NetBSD Signature (as per sys/exec_elf.h)
750754const (
751755 ELF_NOTE_NETBSD_NAMESZ = 7
@@ -2339,9 +2343,9 @@ elfobj:
23392343 if * flagBuildid != "" {
23402344 a += int64 (elfwritegobuildid (ctxt .Out ))
23412345 }
2342- }
2343- if ctxt . HeadType == objabi . Hhaiku {
2344- a += int64 ( elfwritehaikucomment ( ctxt . Out ))
2346+ if ctxt . HeadType == objabi . Hhaiku {
2347+ a += int64 ( elfwritehaikucomment ( ctxt . Out ))
2348+ }
23452349 }
23462350 if * flagRace && ctxt .IsNetbsd () {
23472351 a += int64 (elfwritenetbsdpax (ctxt .Out ))
0 commit comments