This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]


On Fri, May 11, 2012 at 09:48:22AM -0700, H.J. Lu wrote:
> Hi,
> X32 and x86-64 share the same assembly codes as well as C codes with
> inline asm statements.  When dealing with longs and pointers in assembly
> codes or inline asm statements, we need to use proper register names,
> 64-bit register for x86-64 and 32-bit register for x32, as well as
> proper size for longs and pointers.  In assembly code, we don't need
> the `q' instruction suffix if there is a register operand.  We just
> need to use the proper register and assembler will take care of it.  But
> there is no register operand, we must use the proper instruction suffix,
> `q' for x86-64 and `l' for x32.  Also to take the address of symbol, foo,
> x86-64 uses
> 	.quad  foo
> x32 uses
> 	.long foo
> This patch defines
> 1. LP_SIZE: Size of long and pointer.
> 2. LP_OP(insn): Add the proper instruction suffix to "insn".
> 3. ASM_ADDR: Assembly directive to take the address of symbol.
> 4. RXX_LP: Register used for long and pointer.
> Tested on Linux/x32 and Linux/x86-64.  OK to install?


This patch adds the x32 version of these macros.  Tested on Linux/x32.
OK to install?


	* sysdeps/x86_64/x32/sysdep.h: New file.

diff --git a/sysdeps/x86_64/x32/sysdep.h b/sysdeps/x86_64/x32/sysdep.h
new file mode 100644
index 0000000..7817c29
--- /dev/null
+++ b/sysdeps/x86_64/x32/sysdep.h
@@ -0,0 +1,90 @@
+/* Assembler macros for x32.
+   Copyright (C) 2012 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   Lesser General Public License for more details.
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <>.  */
+#undef LP_SIZE
+#undef LP_OP
+#undef ASM_ADDR
+#undef RAX_LP
+#undef RBP_LP
+#undef RBX_LP
+#undef RCX_LP
+#undef RDI_LP
+#undef RDX_LP
+#undef RSP_LP
+#undef RSI_LP
+#undef R8_LP
+#undef R9_LP
+#undef R10_LP
+#undef R11_LP
+#undef R12_LP
+#undef R13_LP
+#undef R14_LP
+#undef R15_LP
+#ifdef	__ASSEMBLER__
+# define LP_SIZE 4
+# define LP_OP(insn) insn##l
+# define ASM_ADDR .long
+# define RAX_LP	eax
+# define RBP_LP	ebp
+# define RBX_LP	ebx
+# define RCX_LP	ecx
+# define RDI_LP	edi
+# define RDX_LP	edx
+# define RSI_LP	esi
+# define RSP_LP	esp
+# define R8_LP	r8d
+# define R9_LP	r9d
+# define R10_LP	r10d
+# define R11_LP	r11d
+# define R12_LP	r12d
+# define R13_LP	r13d
+# define R14_LP	r14d
+# define R15_LP	r15d
+#else	/* __ASSEMBLER__ */
+# define LP_SIZE "4"
+# define LP_OP(insn) #insn "l"
+# define ASM_ADDR ".long"
+# define RAX_LP	"eax"
+# define RBP_LP	"ebp"
+# define RBX_LP	"ebx"
+# define RCX_LP	"ecx"
+# define RDI_LP	"edi"
+# define RDX_LP	"edx"
+# define RSI_LP	"esi"
+# define RSP_LP	"esp"
+# define R8_LP	"r8d"
+# define R9_LP	"r9d"
+# define R10_LP	"r10d"
+# define R11_LP	"r11d"
+# define R12_LP	"r12d"
+# define R13_LP	"r13d"
+# define R14_LP	"r14d"
+# define R15_LP	"r15d"
+#endif	/* __ASSEMBLER__ */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]