Skip to content

Commit

Permalink
[AArch64][libunwind] Unwinding support for return address signing wit…
Browse files Browse the repository at this point in the history
…h B Key

- Support for the case where the return address has been signed with the B key
- When the B key is used, a 'B' character is present in the augmentation string
  of CIE associated with the FDE for the function.

Differential Revision: https://reviews.llvm.org/D55704

llvm-svn: 349339
  • Loading branch information
Luke Cheeseman committed Dec 17, 2018
1 parent 490ae11 commit 3579731
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
10 changes: 7 additions & 3 deletions libunwind/src/DwarfInstructions.hpp
Expand Up @@ -211,9 +211,13 @@ int DwarfInstructions<A, R>::stepWithDwarf(A &addressSpace, pint_t pc,
register unsigned long long x17 __asm("x17") = returnAddress;
register unsigned long long x16 __asm("x16") = cfa;

// This is the autia1716 instruction. The hint instruction is used here
// as gcc does not assemble autia1716 for pre armv8.3a targets.
asm("hint 0xc": "+r"(x17): "r"(x16));
// These are the autia1716/autib1716 instructions. The hint instructions
// are used here as gcc does not assemble autia1716/autib1716 for pre
// armv8.3a targets.
if (cieInfo.addressesSignedWithBKey)
asm("hint 0xe" : "+r"(x17) : "r"(x16)); // autib1716
else
asm("hint 0xc" : "+r"(x17) : "r"(x16)); // autia1716
returnAddress = x17;
#endif
}
Expand Down
11 changes: 11 additions & 0 deletions libunwind/src/DwarfParser.hpp
Expand Up @@ -49,6 +49,9 @@ class CFI_Parser {
bool isSignalFrame;
bool fdesHaveAugmentationData;
uint8_t returnAddressRegister;
#if defined(_LIBUNWIND_TARGET_AARCH64)
bool addressesSignedWithBKey;
#endif
};

/// Information about an FDE (Frame Description Entry)
Expand Down Expand Up @@ -263,6 +266,9 @@ const char *CFI_Parser<A>::parseCIE(A &addressSpace, pint_t cie,
cieInfo->dataAlignFactor = 0;
cieInfo->isSignalFrame = false;
cieInfo->fdesHaveAugmentationData = false;
#if defined(_LIBUNWIND_TARGET_AARCH64)
cieInfo->addressesSignedWithBKey = false;
#endif
cieInfo->cieStart = cie;
pint_t p = cie;
pint_t cieLength = (pint_t)addressSpace.get32(p);
Expand Down Expand Up @@ -326,6 +332,11 @@ const char *CFI_Parser<A>::parseCIE(A &addressSpace, pint_t cie,
case 'S':
cieInfo->isSignalFrame = true;
break;
#if defined(_LIBUNWIND_TARGET_AARCH64)
case 'B':
cieInfo->addressesSignedWithBKey = true;
break;
#endif
default:
// ignore unknown letters
break;
Expand Down

0 comments on commit 3579731

Please sign in to comment.