gitlab.com/Raven-IO/raven-delve@v1.22.4/pkg/dwarf/regnum/arm64.go (about)

     1  package regnum
     2  
     3  import (
     4  	"fmt"
     5  )
     6  
     7  // The mapping between hardware registers and DWARF registers is specified
     8  // in the DWARF for the DWARF for the ArmĀ® 64-bit Architecture (AArch64),
     9  // Section 4, Table 1
    10  // https://github.com/ARM-software/abi-aa/blob/main/aadwarf64/aadwarf64.rst#4arm-specific-dwarf-definitions
    11  
    12  const (
    13  	ARM64_X0         = 0  // X1 through X30 follow
    14  	ARM64_BP         = 29 // also X29
    15  	ARM64_LR         = 30 // also X30
    16  	ARM64_SP         = 31
    17  	ARM64_PC         = 32
    18  	ARM64_V0         = 64 // V1 through V31 follow
    19  	_ARM64_MaxRegNum = ARM64_V0 + 31
    20  )
    21  
    22  func ARM64ToName(num uint64) string {
    23  	switch {
    24  	case num <= 30:
    25  		return fmt.Sprintf("X%d", num)
    26  	case num == ARM64_SP:
    27  		return "SP"
    28  	case num == ARM64_PC:
    29  		return "PC"
    30  	case num >= ARM64_V0 && num <= 95:
    31  		return fmt.Sprintf("V%d", num-64)
    32  	default:
    33  		return fmt.Sprintf("unknown%d", num)
    34  	}
    35  }
    36  
    37  func ARM64MaxRegNum() uint64 {
    38  	return _ARM64_MaxRegNum
    39  }
    40  
    41  var ARM64NameToDwarf = func() map[string]int {
    42  	r := make(map[string]int)
    43  	for i := 0; i <= 32; i++ {
    44  		r[fmt.Sprintf("x%d", i)] = ARM64_X0 + i
    45  	}
    46  	r["fp"] = 29
    47  	r["lr"] = 30
    48  	r["sp"] = 31
    49  	r["pc"] = 32
    50  
    51  	for i := 0; i <= 31; i++ {
    52  		r[fmt.Sprintf("v%d", i)] = ARM64_V0 + i
    53  	}
    54  
    55  	return r
    56  }()