1 /// -*- mode: asm; asm-comment-char: ?/ -*-
3 /// Fancy SIMD implementation of Salsa20
5 /// (c) 2015 Straylight/Edgeware
8 ///----- Licensing notice ---------------------------------------------------
10 /// This file is part of Catacomb.
12 /// Catacomb is free software; you can redistribute it and/or modify
13 /// it under the terms of the GNU Library General Public License as
14 /// published by the Free Software Foundation; either version 2 of the
15 /// License, or (at your option) any later version.
17 /// Catacomb is distributed in the hope that it will be useful,
18 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
19 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 /// GNU Library General Public License for more details.
22 /// You should have received a copy of the GNU Library General Public
23 /// License along with Catacomb; if not, write to the Free
24 /// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25 /// MA 02111-1307, USA.
27 ///--------------------------------------------------------------------------
28 /// General definitions.
30 // Announcing an external function.
34 .macro ENDFUNC; _ENDFUNC(name); .endm; \
39 // Marking the end of a function.
40 #define _ENDFUNC(name) \
45 ///--------------------------------------------------------------------------
46 /// ELF-specific hacking.
50 #if __PIC__ || __PIE__
54 #define TYPE_FUNC(name) .type name, STT_FUNC
56 #define SIZE_OBJ(name) .size name, . - name
60 ///--------------------------------------------------------------------------
61 /// x86-specific hacking.
65 // Set the function hooks.
66 #define FUNC_PREHOOK(_) .balign 16
68 // Don't use the wretched AT&T syntax. It's festooned with pointless
69 // punctuation, and all of the data movement is backwards. Ugh!
70 .intel_syntax noprefix
72 // Call external subroutine at ADDR, possibly via PLT.
81 // Do I need to arrange a spare GOT register?
82 #if WANT_PIC && CPUFAM_X86
85 #define GOTREG ebx // Not needed in AMD64 so don't care.
87 // Maybe load GOT address into GOT.
88 .macro ldgot got=GOTREG
91 add \got, offset _GLOBAL_OFFSET_TABLE_
95 // Maybe build a helper subroutine for `ldgot GOT'.
96 .macro gotaux got=GOTREG
105 // Load address of external symbol ADDR into REG, maybe using GOT.
106 .macro leaext reg, addr, got=GOTREG
108 mov \reg, [\got + \addr@GOT]
110 mov \reg, offset \addr
114 // Address expression (possibly using a base register, and a displacement)
115 // referring to ADDR, which is within our module, maybe using GOT.
116 #define INTADDR(...) INTADDR__0(__VA_ARGS__, GOTREG, dummy)
117 #define INTADDR__0(addr, got, ...) INTADDR__1(addr, got)
119 # define INTADDR__1(addr, got) got + addr@GOTOFF
121 # define INTADDR__1(addr, got) addr
126 ///--------------------------------------------------------------------------
129 // Default values for the various hooks.
131 # define FUNC_PREHOOK(name)
133 #ifndef FUNC_POSTHOOK
134 # define FUNC_POSTHOOK(name)
137 # define ENDFUNC_HOOK(name)
141 # define F(name) name
145 # define TYPE_FUNC(name)
149 # define SIZE_OBJ(name)
152 ///----- That's all, folks --------------------------------------------------