abstract type/size specification for assembly
PATCH 1/1 abstract type/size specification for assembly
OK?
From: Jan Beulich <[email protected]>
Provide abstraction for generating type and size information of assembly routines and data.
---
include/linux/linkage.h | 5 +++++ 1 files changed, 5 insertions(+)
include/linux/linkage.h renamed from include/linux/linkage.h~abstract-type-size-specification-for-assembly +5 -0
@@ -39,6 +39,11 @@ALIGN ; \ name: +#define ENDPROC (name) \ + .type name, @function; \ + END(name) +#define END (name) \ + .size name, .-name#endif
_
From: Jan Beulich <[email protected]>
Provide abstraction for generating type and size information of assembly routines and data.
include/linux/linkage.h renamed from home/jbeulich/tmp/linux-2.6.16-rc1/include/linux/linkage.h +5 -0
@@ -39,6 +39,11 @@ALIGN ; \ name: +#define ENDPROC (name) \ + .type name, @function; \ + END(name) +#define END (name) \ + .size name, .-name#endif
Quoted 2 lines · Andrew Morton
OK?
Yes.
Quoted 32 lines
From: Jan Beulich <[email protected]>
Provide abstraction for generating type and size information of assembly routines and data.
Signed-off-by Jan Beulich <[email protected]>Signed-off-by Andrew Morton <[email protected]>---
include/linux/linkage.h | 5 +++++ 1 files changed, 5 insertions(+)diff -puN
include/linux/linkage.h~abstract-type-size-specification-for-assemblyinclude/linux/linkage.hinclude/linux/linkage.h renamed from include/linux/linkage.h~abstract-type-size-specification-for-assembly +5
-0@@ -39,6 +39,11 @@ALIGN ; \ name: +#define ENDPROC (name) \ + .type name, @function; \ + END(name) +#define END (name) \ + .size name, .-name#endif _
Quoted 5 lines · Andi Kleen
Quoted 2 lines · Andrew Morton
OK?
Yes.
No.
Quoted 5 lines
include/linux/linkage.h line 46
Quoted 5 lines
include/linux/linkage.h renamed from include/linux/linkage.h~abstract-type-size-specification-for-assembly +5
-0+#define ENDPROC (name) \ + .type name, @function; \ + END(name) +#define END (name) \ + .size name, .-name
@ is the comment character on ARM, so this can't go here - we use
.type name, %function
instead. Interestingly, the info pages for as seem to indicate that there's a number of alternatives - maybe the most benign one should be used, iow:
.type name, "function"
or alternatively make ENDPROC arch-overridable.
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Quoted 11 lines · Russell King
@ is the comment character on ARM, so this can't go here - we use
.type name, %function
instead. Interestingly, the info pages for as seem to indicate that there's a number of alternatives - maybe the most benign one should be used, iow:
.type name, "function"
or alternatively make ENDPROC arch-overridable.
Actually it could be just per architecture. Or do you see ARM specific assembly code using ENDPROC() any time soon? And there are no portable assembly files.
I assume Jan only wants/needs it for x86(-32/64) and perhaps ia64/ppc.
-Andi
Quoted 10 lines · Andi Kleen
Quoted 8 lines · Russell King
@ is the comment character on ARM, so this can't go here - we use
.type name, %function
instead. Interestingly, the info pages for as seem to indicate that there's a number of alternatives - maybe the most benign one should be used, iow:
Quoted 7 lines
Quoted 3 lines
.type name, "function"
or alternatively make ENDPROC arch-overridable.
Actually it could be just per architecture. Or do you see ARM specific assembly code using
ENDPROC()any time soon? And there are no portable assembly files.
I do have a number of .type and .size stuff in the ARM assembly files - it aids objdump in working out whether it should dump the contents as data or code. IOW, it might be useful to have.
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Russell King <[email protected]> 01.02.06 09:32:43 >>>
@ is the comment character on ARM, so this can't go here - we use
.type name, %function
instead.
Bad.
Quoted 5 lines
Interestingly, the info pages for as seem to indicate that there's a number of alternatives - maybe the most benign one should be used, iow:
.type name, "function"
While gas seems to generally accept it, ias doesn't (and the assembly language spec for ia64 doesn't either).
Quoted 1 line
or alternatively make ENDPROC arch-overridable.
That seems to be the only choice then. I'll send a revised patch soon.
Jan
Attached an updated patch.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Russell King <[email protected]> 01.02.06 09:32:43 >>>
Quoted 5 lines · Andi Kleen
Quoted 2 lines · Andrew Morton
OK?
Yes.
No.
Quoted 5 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+#define ENDPROC(name) \ + .type name, @function; \ + END(name) +#define END(name) \ + .size name, .-name
@ is the comment character on ARM, so this can't go here - we use
.type name, %function
instead. Interestingly, the info pages for as seem to indicate that there's a number of alternatives - maybe the most benign one should be used, iow:
.type name, "function"
or alternatively make ENDPROC arch-overridable.
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
From: Jan Beulich <[email protected]>
Updated patch, to provide abstraction for generating type and size information of assembly routines and data, while permitting architectures to override these defaults.
include/asm-ia64/linkage.h renamed from home/jbeulich/tmp/linux-2.6.16-rc2/include/asm-ia64/linkage.h +8 -0
@@ -1,6 +1,14 @@#ifndef __ASM_LINKAGE_H#define __ASM_LINKAGE_H +#ifndef __ASSEMBLY__ +#define asmlinkage CPP_ASMLINKAGE __attribute__((syscall_linkage)) +#else + +#include <asm/asmmacro.h> + +#endif +#endif
include/asm-mips/linkage.h renamed from home/jbeulich/tmp/linux-2.6.16-rc2/include/asm-mips/linkage.h +3 -1
@@ -1,6 +1,8 @@#ifndef __ASM_LINKAGE_H#define __ASM_LINKAGE_H -/* Nothing to see here... */ +#ifdef __ASSEMBLY__ +#include <asm/asm.h> +#endif #endif
include/asm-v850/linkage.h renamed from home/jbeulich/tmp/linux-2.6.16-rc2/include/asm-v850/linkage.h +3 -1
@@ -1,6 +1,8 @@#ifndef __ASM_LINKAGE_H#define __ASM_LINKAGE_H -/* Nothing to see here... */ +#ifdef __ASSEMBLY__ +#include <asm/asm.h> +#endif #endif
include/linux/linkage.h renamed from home/jbeulich/tmp/linux-2.6.16-rc2/include/linux/linkage.h +13 -3
@@ -28,17 +28,27 @@#define ALIGN __ALIGN#define ALIGN_STR __ALIGN_STR +#ifndef ENTRY #define ENTRY (name) \ .globl name; \ ALIGN; \ name: +#endif #define KPROBE_ENTRY (name) \ .section .kprobes.text, "ax"; \ - .globl name; \ - ALIGN; \ - name: + ENTRY(name) +#ifndef END +#define END (name) \ + .size name, .-name +#endif + +#ifndef ENDPROC +#define ENDPROC (name) \ + .type name, @function; \ + END(name) +#endif #endif
Quoted 1 line · Andrew Morton
OK?
No.
Quoted 4 lines
diff -puN
include/linux/linkage.h~abstract-type-size-specification-for-assemblyinclude/linux/linkage.h
include/linux/linkage.h line 48
Quoted 10 lines
include/linux/linkage.h renamed from include/linux/linkage.h~abstract-type-size-specification-for-assembly +5
-0@@ -39,6 +39,11 @@ALIGN ; \ name: +#define ENDPROC (name) \ + .type name, @function; \ + END(name) +#define END (name) \ + .size name, .-name#endif
No. On MIPS we need a .end directive as well; since the dawn of Linux I have the following in include/asm-mips/asm.h:
#define END(function) \
.end function; \
.size function,.-functionAnd while we're at it, the ENTRY definition there isn't usable on MIPS either; we need two different definitions for leaf and no-leaf functions which again are in asm.h:
/*
* LEAF - declare leaf routine
*/
#define LEAF(symbol) \
.globl symbol; \
.align 2; \
.type symbol,@function; \
.ent symbol,0; \symbol: .frame sp,0,ra
/*
* NESTED - declare nested routine entry point
*/
#define NESTED(symbol, framesize, rpc) \
.globl symbol; \
.align 2; \
.type symbol,@function; \
.ent symbol,0; \symbol: .frame sp, framesize, rpc
Ralf