From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x234.google.com (mail-wm0-x234.google.com [IPv6:2a00:1450:400c:c09::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 058751A1DF8 for ; Wed, 10 Aug 2016 08:18:24 -0700 (PDT) Received: by mail-wm0-x234.google.com with SMTP id f65so96799286wmi.0 for ; Wed, 10 Aug 2016 08:18:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=y4VZYLGhW1yOT8lhqyzQfY+PZaN7lKQUbOU4OckuZgY=; b=OpqGqsO9VquieRaklulrcQmIl3i8Fl/MbVU6car10397DRqHqar/jk7FBcIR5+GVJj avVKfUu4JBpkrwtf/i097iXJxhGCx1kpt6CLBULvwmuWnkyH10xpmSRQDxgeFJMAmaMu Ot5Wp9rbWZWCqdv+VC7VMNddFXi/Lv+OWx00o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=y4VZYLGhW1yOT8lhqyzQfY+PZaN7lKQUbOU4OckuZgY=; b=M8zszABaBRklXbVM0a7J0PwtUZwgPGlNS+9fiQin0vePRWqKUZeTC6tyRQ1wa0lsc+ e2u5TzIuUDWKqpkmyb+9MJmoy2jIPVbJz0EWQL6/8Jq2PtnkhDyXX/Rqw7Kgok54ilph sYVke6M3vp89vYKdPPx7ZGtBmjajVonIzkhmdBWI4j1L2Ta0xxwEtaj8Gl1TeY/Piqbh omToB6VQ1g/LjlyB0R96CIb1NLlAwB+onkfm/J/5M6aqt9ybjiEZwFaFj3Dn67oQ1Lz7 TnhWLR4wkB2ns/lA/PQcy18rC4LxlyDxhQQcQPP2l4vK12S+/QNAijdt1VSEhsf5MOQP sczw== X-Gm-Message-State: AEkoousJ6Q93VQIsY2xwGnYOHq4xom0LkZOWEPQ0rY7/4dGNl/txBb96eamShCTtSJPyKHJX X-Received: by 10.194.242.71 with SMTP id wo7mr4399241wjc.179.1470842302157; Wed, 10 Aug 2016 08:18:22 -0700 (PDT) Received: from localhost.localdomain (46.red-81-37-107.dynamicip.rima-tde.net. [81.37.107.46]) by smtp.gmail.com with ESMTPSA id c16sm8908374wme.4.2016.08.10.08.18.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Aug 2016 08:18:21 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, eugene@hp.com Cc: lersek@redhat.com, Ard Biesheuvel Date: Wed, 10 Aug 2016 17:17:41 +0200 Message-Id: <1470842282-8415-6-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1470842282-8415-1-git-send-email-ard.biesheuvel@linaro.org> References: <1470842282-8415-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [PATCH 05/26] ArmPkg: introduce ASM_FUNC, MOV32/MOV64 and ADRL/LDRL macros X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Aug 2016 15:18:24 -0000 This introduces the ASM_FUNC() macro to annotate function entry points in assembler files. This allows us to add additional metadata that marks a function entry point as a function, and allows us to emit a .section directive for each function, which makes it possible for the linker to drop unreferenced code. In addition, introduce a couple of utility macros that we can use to clean up the code. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- ArmPkg/Include/AsmMacroIoLib.h | 23 ++++++++++++++++++++ ArmPkg/Include/AsmMacroIoLibV8.h | 20 ++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/ArmPkg/Include/AsmMacroIoLib.h b/ArmPkg/Include/AsmMacroIoLib.h index 551b87803d19..fb73ea9a4694 100644 --- a/ArmPkg/Include/AsmMacroIoLib.h +++ b/ArmPkg/Include/AsmMacroIoLib.h @@ -3,6 +3,7 @@ Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
Copyright (c) 2011-2012, ARM Ltd. All rights reserved.
+ Copyright (c) 2016, Linaro Ltd. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -51,4 +52,26 @@ #endif +#define _ASM_FUNC(Name, Section) \ + .global Name ; \ + .section #Section, "ax" ; \ + .type Name, %function ; \ + Name: + +#define ASM_FUNC(Name) _ASM_FUNC(ASM_PFX(Name), .text. ## Name) + +#define MOV32(Reg, Val) \ + movw Reg, #(Val) & 0xffff ; \ + movt Reg, #(Val) >> 16 + +#define ADRL(Reg, Sym) \ + movw Reg, #:lower16:(Sym) - (. + 16) ; \ + movt Reg, #:upper16:(Sym) - (. + 12) ; \ + add Reg, Reg, pc + +#define LDRL(Reg, Sym) \ + movw Reg, #:lower16:(Sym) - (. + 16) ; \ + movt Reg, #:upper16:(Sym) - (. + 12) ; \ + ldr Reg, [pc, Reg] + #endif diff --git a/ArmPkg/Include/AsmMacroIoLibV8.h b/ArmPkg/Include/AsmMacroIoLibV8.h index 37fa255f842e..e9285f78e7d6 100644 --- a/ArmPkg/Include/AsmMacroIoLibV8.h +++ b/ArmPkg/Include/AsmMacroIoLibV8.h @@ -3,6 +3,7 @@ Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
Portions copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
+ Copyright (c) 2016, Linaro Ltd. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -71,5 +72,22 @@ #endif // __GNUC__ -#endif // __MACRO_IO_LIBV8_H__ +#define _ASM_FUNC(Name, Section) \ + .global Name ; \ + .section #Section, "ax" ; \ + .type Name, %function ; \ + Name: + +#define ASM_FUNC(Name) _ASM_FUNC(ASM_PFX(Name), .text. ## Name) + +#define MOV32(Reg, Val) \ + movz Reg, (Val) >> 16, lsl #16 ; \ + movk Reg, (Val) & 0xffff +#define MOV64(Reg, Val) \ + movz Reg, (Val) >> 48, lsl #48 ; \ + movk Reg, ((Val) >> 32) & 0xffff, lsl #32 ; \ + movk Reg, ((Val) >> 16) & 0xffff, lsl #16 ; \ + movk Reg, (Val) & 0xffff + +#endif // __MACRO_IO_LIBV8_H__ -- 2.7.4