linker dont use ptrsize to align TEXT symbol, but ld.Arch.Funcalign
linker use MINFUNC = 16 as minimal funcsize at assignAddress
// src(go1.19.6)/cmd/link/internal/amd64/l.go
package amd64
const (
maxAlign = 32 // max data alignment
minAlign = 1 // min data alignment
funcAlign = 32
)
// src/cmd/link/internal/ld/data.go
// assign addresses to text
func (ctxt *Link) textaddress() {
addsection(ctxt.loader, ctxt.Arch, &Segtext, ".text", 05)
// Assign PCs in text segment.
// Could parallelize, by assigning to text
// and then letting threads copy down, but probably not worth it.
sect := Segtext.Sections[0]
sect.Align = int32(Funcalign)
// ...
}
// assigns address for a text symbol, returns (possibly new) section, its number, and the address
func assignAddress(ctxt *Link, sect *sym.Section, n int, s loader.Sym, va uint64, isTramp, big bool) (*sym.Section, int, uint64) {
// ...
funcsize := uint64(MINFUNC) // spacing required for findfunctab
if ldr.SymSize(s) > MINFUNC {
funcsize = uint64(ldr.SymSize(s))
}
// ...
}
2 things should be notice:
ld.Arch.Funcalign
MINFUNC = 16
as minimal funcsize atassignAddress