public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: edk2-devel@lists.01.org
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Michael D Kinney <michael.d.kinney@intel.com>,
	Liming Gao <liming.gao@intel.com>,
	Bob Feng <bob.c.feng@intel.com>,
	Leif Lindholm <leif.lindholm@linaro.org>,
	Laszlo Ersek <lersek@redhat.com>
Subject: [PATCH 1/3] MdePkg/BaseMemoryLibOptDxe ARM: add missing function annotations
Date: Wed, 12 Dec 2018 11:33:06 +0100	[thread overview]
Message-ID: <20181212103308.8099-2-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <20181212103308.8099-1-ard.biesheuvel@linaro.org>

ARM uses the low order bit of a branch target address to decide in
which execution mode (ARM or Thumb) a function needs to be called.
In order for this to work across object files, ELF function symbols
will have the low bit set if they were emitted in Thumb mode and
cleared otherwise. This annotation is only emitted if the ELF symbols
are annotated as function, since taking the address of some data
symbol (e.g., a literal) should not produce a value with the low bit
set, even if it appears in an object file containing Thumb code.

This means that all functions coded in assembler must have this
function annotation, or they may end up getting called in the
wrong mode, crashing the program.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 MdePkg/Library/BaseMemoryLibOptDxe/Arm/CompareGuid.S | 1 +
 MdePkg/Library/BaseMemoryLibOptDxe/Arm/CompareMem.S  | 1 +
 MdePkg/Library/BaseMemoryLibOptDxe/Arm/CopyMem.S     | 1 +
 MdePkg/Library/BaseMemoryLibOptDxe/Arm/SetMem.S      | 5 +++++
 4 files changed, 8 insertions(+)

diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/Arm/CompareGuid.S b/MdePkg/Library/BaseMemoryLibOptDxe/Arm/CompareGuid.S
index 6d0089049d48..b74056fa1f5f 100644
--- a/MdePkg/Library/BaseMemoryLibOptDxe/Arm/CompareGuid.S
+++ b/MdePkg/Library/BaseMemoryLibOptDxe/Arm/CompareGuid.S
@@ -30,6 +30,7 @@
     .thumb
     .syntax unified
     .align  5
+    .type   ASM_PFX(InternalMemCompareGuid), %function
 ASM_GLOBAL ASM_PFX(InternalMemCompareGuid)
 ASM_PFX(InternalMemCompareGuid):
     push    {r4, lr}
diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/Arm/CompareMem.S b/MdePkg/Library/BaseMemoryLibOptDxe/Arm/CompareMem.S
index 9483aab61a0c..25a9a0994524 100644
--- a/MdePkg/Library/BaseMemoryLibOptDxe/Arm/CompareMem.S
+++ b/MdePkg/Library/BaseMemoryLibOptDxe/Arm/CompareMem.S
@@ -46,6 +46,7 @@
     .thumb
     .syntax unified
     .align  5
+    .type   ASM_PFX(InternalMemCompareMem), %function
 ASM_GLOBAL ASM_PFX(InternalMemCompareMem)
 ASM_PFX(InternalMemCompareMem):
     push    {r4-r8, lr}
diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/Arm/CopyMem.S b/MdePkg/Library/BaseMemoryLibOptDxe/Arm/CopyMem.S
index 195a0b23f770..e1543f3c2a43 100644
--- a/MdePkg/Library/BaseMemoryLibOptDxe/Arm/CopyMem.S
+++ b/MdePkg/Library/BaseMemoryLibOptDxe/Arm/CopyMem.S
@@ -42,6 +42,7 @@ InternalMemCopyMem (
   IN      UINTN                     Length
   )
 **/
+    .type   ASM_PFX(InternalMemCopyMem), %function
 ASM_GLOBAL ASM_PFX(InternalMemCopyMem)
 ASM_PFX(InternalMemCopyMem):
     push    {r4-r11, lr}
diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/Arm/SetMem.S b/MdePkg/Library/BaseMemoryLibOptDxe/Arm/SetMem.S
index 2d8f4d5b8621..928c1a12d558 100644
--- a/MdePkg/Library/BaseMemoryLibOptDxe/Arm/SetMem.S
+++ b/MdePkg/Library/BaseMemoryLibOptDxe/Arm/SetMem.S
@@ -16,6 +16,7 @@
     .thumb
     .syntax unified
     .align  5
+    .type   ASM_PFX(InternalMemSetMem16), %function
 ASM_GLOBAL ASM_PFX(InternalMemSetMem16)
 ASM_PFX(InternalMemSetMem16):
     uxth    r2, r2
@@ -23,17 +24,20 @@ ASM_PFX(InternalMemSetMem16):
     orr     r2, r2, r2, lsl #16
     b       0f
 
+    .type   ASM_PFX(InternalMemSetMem32), %function
 ASM_GLOBAL ASM_PFX(InternalMemSetMem32)
 ASM_PFX(InternalMemSetMem32):
     lsl     r1, r1, #2
     b       0f
 
+    .type   ASM_PFX(InternalMemSetMem64), %function
 ASM_GLOBAL ASM_PFX(InternalMemSetMem64)
 ASM_PFX(InternalMemSetMem64):
     lsl     r1, r1, #3
     b       1f
 
     .align  5
+    .type   ASM_PFX(InternalMemSetMem), %function
 ASM_GLOBAL ASM_PFX(InternalMemSetMem)
 ASM_PFX(InternalMemSetMem):
     uxtb    r2, r2
@@ -41,6 +45,7 @@ ASM_PFX(InternalMemSetMem):
     orr     r2, r2, r2, lsl #16
     b       0f
 
+    .type   ASM_PFX(InternalMemZeroMem), %function
 ASM_GLOBAL ASM_PFX(InternalMemZeroMem)
 ASM_PFX(InternalMemZeroMem):
     movs    r2, #0
-- 
2.19.2



  reply	other threads:[~2018-12-12 10:33 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-12 10:33 [PATCH 0/3] fixes for CLANG35 on ARM Ard Biesheuvel
2018-12-12 10:33 ` Ard Biesheuvel [this message]
2018-12-12 11:48   ` [PATCH 1/3] MdePkg/BaseMemoryLibOptDxe ARM: add missing function annotations Laszlo Ersek
2018-12-12 10:33 ` [PATCH 2/3] BaseTools/tools_def ARM CLANG35: work around -mno-movt option name change Ard Biesheuvel
2018-12-12 11:49   ` Laszlo Ersek
2018-12-12 11:51     ` Ard Biesheuvel
2018-12-12 12:04       ` Laszlo Ersek
2018-12-12 12:30   ` Ard Biesheuvel
2018-12-12 12:34     ` Leif Lindholm
2018-12-12 10:33 ` [PATCH 3/3] ArmVirtPkg/PrePi ARM CLANG35: drop incompatible command line option Ard Biesheuvel
2018-12-12 11:51   ` Laszlo Ersek
2018-12-12 12:37 ` [PATCH 0/3] fixes for CLANG35 on ARM Leif Lindholm
2018-12-12 14:01 ` Gao, Liming
2018-12-12 14:02   ` Ard Biesheuvel
2018-12-12 14:19     ` Gao, Liming
2018-12-12 14:19       ` Ard Biesheuvel
2018-12-13 10:49         ` Ard Biesheuvel
2018-12-13 11:42           ` Gao, Liming
2018-12-13 11:49             ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181212103308.8099-2-ard.biesheuvel@linaro.org \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox