}
func duintxxLSym(s *obj.LSym, off int, v uint64, wid int) int {
- // Update symbol data directly instead of generating a
- // DATA instruction that liblink will have to interpret later.
- // This reduces compilation time and memory usage.
- off = int(Rnd(int64(off), int64(wid)))
-
- return int(obj.Setuintxx(Ctxt, s, int64(off), v, int64(wid)))
+ if s.Type == 0 {
+ // TODO(josharian): Do this in obj.prepwrite instead.
+ s.Type = obj.SDATA
+ }
+ if off&(wid-1) != 0 {
+ Fatalf("duintxxLSym: misaligned: v=%d wid=%d off=%d", v, wid, off)
+ }
+ s.WriteInt(Ctxt, int64(off), wid, int64(v))
+ return off + wid
}
func duint8(s *types.Sym, off int, v uint8) int {
s.R = append(s.R, Reloc{})
return &s.R[len(s.R)-1]
}
-
-func Setuintxx(ctxt *Link, s *LSym, off int64, v uint64, wid int64) int64 {
- if s.Type == 0 {
- s.Type = SDATA
- }
- if s.Size < off+wid {
- s.Size = off + wid
- s.Grow(s.Size)
- }
-
- switch wid {
- case 1:
- s.P[off] = uint8(v)
- case 2:
- ctxt.Arch.ByteOrder.PutUint16(s.P[off:], uint16(v))
- case 4:
- ctxt.Arch.ByteOrder.PutUint32(s.P[off:], uint32(v))
- case 8:
- ctxt.Arch.ByteOrder.PutUint64(s.P[off:], v)
- }
-
- return off + wid
-}