From 8dabc6eab444607a68d710f0b09942277095e219 Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.com>
Date: Wed, 12 Jan 2022 17:27:03 +0000
Subject: [PATCH] arm: Fix annoying .eh_frame section warnings

Replace the cfi directives with the UNWIND equivalents. This prevents
the .eh_frame section from being created, eliminating the warnings.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
---
 arch/arm/lib/memcpy_rpi.S  |  2 ++
 arch/arm/lib/memcpymove.h  | 45 ++++++++++++--------------------------
 arch/arm/lib/memmove_rpi.S |  2 ++
 3 files changed, 18 insertions(+), 31 deletions(-)

--- a/arch/arm/lib/memcpy_rpi.S
+++ b/arch/arm/lib/memcpy_rpi.S
@@ -27,6 +27,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBI
 */
 
 #include <linux/linkage.h>
+#include <asm/assembler.h>
+#include <asm/unwind.h>
 #include "arm-mem.h"
 #include "memcpymove.h"
 
--- a/arch/arm/lib/memcpymove.h
+++ b/arch/arm/lib/memcpymove.h
@@ -280,6 +280,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBI
 199:
         pop     {DAT3, DAT4, DAT5, DAT6, DAT7}
         pop     {D, DAT1, DAT2, pc}
+        UNWIND( .fnend )
 .endm
 
 .macro memcpy_medium_inner_loop  backwards, align
@@ -358,19 +359,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBI
         LAST    .req    ip
         OFF     .req    lr
 
-        .cfi_startproc
+        UNWIND( .fnstart )
 
         push    {D, DAT1, DAT2, lr}
+        UNWIND( .fnend )
 
-        .cfi_def_cfa_offset 16
-        .cfi_rel_offset D, 0
-        .cfi_undefined  S
-        .cfi_undefined  N
-        .cfi_undefined  DAT0
-        .cfi_rel_offset DAT1, 4
-        .cfi_rel_offset DAT2, 8
-        .cfi_undefined  LAST
-        .cfi_rel_offset lr, 12
+        UNWIND( .fnstart )
+        UNWIND( .save {D, DAT1, DAT2, lr} )
 
  .if backwards
         add     D, D, N
@@ -386,17 +381,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBI
 
         /* Long case */
         push    {DAT3, DAT4, DAT5, DAT6, DAT7}
+        UNWIND( .fnend )
 
-        .cfi_def_cfa_offset 36
-        .cfi_rel_offset D, 20
-        .cfi_rel_offset DAT1, 24
-        .cfi_rel_offset DAT2, 28
-        .cfi_rel_offset DAT3, 0
-        .cfi_rel_offset DAT4, 4
-        .cfi_rel_offset DAT5, 8
-        .cfi_rel_offset DAT6, 12
-        .cfi_rel_offset DAT7, 16
-        .cfi_rel_offset lr, 32
+        UNWIND( .fnstart )
+        UNWIND( .save {D, DAT1, DAT2, lr} )
+        UNWIND( .save {DAT3, DAT4, DAT5, DAT6, DAT7} )
 
         /* Adjust N so that the decrement instruction can also test for
          * inner loop termination. We want it to stop when there are
@@ -436,16 +425,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBI
 156:    memcpy_long_inner_loop  backwards, 2
 157:    memcpy_long_inner_loop  backwards, 3
 
-        .cfi_def_cfa_offset 16
-        .cfi_rel_offset D, 0
-        .cfi_rel_offset DAT1, 4
-        .cfi_rel_offset DAT2, 8
-        .cfi_same_value DAT3
-        .cfi_same_value DAT4
-        .cfi_same_value DAT5
-        .cfi_same_value DAT6
-        .cfi_same_value DAT7
-        .cfi_rel_offset lr, 12
+        UNWIND( .fnend )
+
+        UNWIND( .fnstart )
+        UNWIND( .save {D, DAT1, DAT2, lr} )
 
 160:    /* Medium case */
         preload_all  backwards, 0, 0, S, N, DAT2, OFF
@@ -488,7 +471,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBI
         memcpy_short_inner_loop  backwards, 0
 140:    memcpy_short_inner_loop  backwards, 1
 
-        .cfi_endproc
+        UNWIND( .fnend )
 
         .unreq  D
         .unreq  S
--- a/arch/arm/lib/memmove_rpi.S
+++ b/arch/arm/lib/memmove_rpi.S
@@ -27,6 +27,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBI
 */
 
 #include <linux/linkage.h>
+#include <asm/assembler.h>
+#include <asm/unwind.h>
 #include "arm-mem.h"
 #include "memcpymove.h"
 
