ELF: Teach the linker about the 'B' augmentation string character.
authorPeter Collingbourne <peter@pcc.me.uk>
Thu, 31 Dec 2020 06:11:45 +0000 (22:11 -0800)
committerPeter Collingbourne <peter@pcc.me.uk>
Wed, 6 Jan 2021 03:51:11 +0000 (19:51 -0800)
This character indicates that when return pointer authentication is
being used, the function signs the return address using the B key.

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

lld/ELF/EhFrame.cpp
lld/test/ELF/eh-frame-cfi-b-key.s [new file with mode: 0644]

index 13f0484..578c640 100644 (file)
@@ -194,7 +194,7 @@ uint8_t EhReader::getFdeEncoding() {
       readByte();
     else if (c == 'P')
       skipAugP();
-    else if (c != 'S')
+    else if (c != 'B' && c != 'S')
       failOn(aug.data(), "unknown .eh_frame augmentation string: " + aug);
   }
   return DW_EH_PE_absptr;
@@ -211,7 +211,7 @@ bool EhReader::hasLSDA() {
       skipAugP();
     else if (c == 'R')
       readByte();
-    else if (c != 'S')
+    else if (c != 'B' && c != 'S')
       failOn(aug.data(), "unknown .eh_frame augmentation string: " + aug);
   }
   return false;
diff --git a/lld/test/ELF/eh-frame-cfi-b-key.s b/lld/test/ELF/eh-frame-cfi-b-key.s
new file mode 100644 (file)
index 0000000..406674e
--- /dev/null
@@ -0,0 +1,9 @@
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple aarch64-arm-none-eabi %s -o %t.o
+// RUN: ld.lld %t.o -o %t --icf=all --eh-frame-hdr
+
+.globl _start
+_start:
+.cfi_startproc
+.cfi_b_key_frame
+.cfi_endproc