github.com/bananabytelabs/wazero@v0.0.0-20240105073314-54b22a776da8/internal/platform/mremap_unix.go (about)

     1  //go:build darwin || linux || freebsd
     2  
     3  package platform
     4  
     5  func remapCodeSegmentAMD64(code []byte, size int) ([]byte, error) {
     6  	return remapCodeSegment(code, size, mmapProtAMD64)
     7  }
     8  
     9  func remapCodeSegmentARM64(code []byte, size int) ([]byte, error) {
    10  	return remapCodeSegment(code, size, mmapProtARM64)
    11  }
    12  
    13  func remapCodeSegment(code []byte, size, prot int) ([]byte, error) {
    14  	b, err := mmapCodeSegment(size, prot)
    15  	if err != nil {
    16  		return nil, err
    17  	}
    18  	copy(b, code)
    19  	mustMunmapCodeSegment(code)
    20  	return b, nil
    21  }