Skip to content

Commit

Permalink
fix: handle arm64 w/o caps
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Jul 11, 2020
1 parent f75204c commit eda599b
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions types/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,12 @@ func (st CPUSubtype) String(cpu CPU) string {
case CPUArm64:
var feature string
caps := st & CpuSubtypeFeatureMask
// TODO handle old files with NO features
if caps&CpuSubtypePtrauthAbiUser == 0 {
feature = fmt.Sprintf(" caps: PAC%02d", (caps&CpuSubtypeArm64PtrAuthMask)>>24)
} else {
feature = fmt.Sprintf(" caps: PAK%02d", (caps&CpuSubtypeArm64PtrAuthMask)>>24)
if caps > 0 {
if caps&CpuSubtypePtrauthAbiUser == 0 {
feature = fmt.Sprintf(" caps: PAC%02d", (caps&CpuSubtypeArm64PtrAuthMask)>>24)
} else {
feature = fmt.Sprintf(" caps: PAK%02d", (caps&CpuSubtypeArm64PtrAuthMask)>>24)
}
}
return StringName(uint32(st&CpuSubtypeMask), cpuSubtypeArm64Strings, false) + feature
}
Expand All @@ -145,10 +146,12 @@ func (st CPUSubtype) GoString(cpu CPU) string {
case CPUArm64:
var feature string
caps := st & CpuSubtypeFeatureMask
if caps&CpuSubtypePtrauthAbiUser == 0 {
feature = fmt.Sprintf(" caps: PAC%02d", (caps&CpuSubtypeArm64PtrAuthMask)>>24)
} else {
feature = fmt.Sprintf(" caps: PAK%02d", (caps&CpuSubtypeArm64PtrAuthMask)>>24)
if caps > 0 {
if caps&CpuSubtypePtrauthAbiUser == 0 {
feature = fmt.Sprintf(" caps: PAC%02d", (caps&CpuSubtypeArm64PtrAuthMask)>>24)
} else {
feature = fmt.Sprintf(" caps: PAK%02d", (caps&CpuSubtypeArm64PtrAuthMask)>>24)
}
}
return StringName(uint32(st&CpuSubtypeMask), cpuSubtypeArm64Strings, true) + feature
}
Expand Down

0 comments on commit eda599b

Please sign in to comment.