This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
[PATCH 2/8] sparc: Tidy up symbols
- From: Richard Henderson <rth at twiddle dot net>
- To: libffi-discuss at sourceware dot org
- Cc: davem at davemloft dot net
- Date: Tue, 28 Oct 2014 12:45:49 -0700
- Subject: [PATCH 2/8] sparc: Tidy up symbols
- Authentication-results: sourceware.org; auth=none
- References: <1414525555-21256-1-git-send-email-rth at twiddle dot net>
Assembly to use local labels, .type annotation, hidden annotation.
I do retain the _prefix for the symbols, but given that it wasn't
done consistently across all symbols, I doubt it's actually needed.
---
src/sparc/ffi.c | 34 +++++-----
src/sparc/v8.S | 198 +++++++++++++++++++-------------------------------------
src/sparc/v9.S | 156 ++++++++++++++------------------------------
3 files changed, 133 insertions(+), 255 deletions(-)
diff --git a/src/sparc/ffi.c b/src/sparc/ffi.c
index c2a0d14..1f38f54 100644
--- a/src/sparc/ffi.c
+++ b/src/sparc/ffi.c
@@ -44,7 +44,8 @@
/* ffi_prep_args is called by the assembly routine once stack space
has been allocated for the function's arguments */
-void ffi_prep_args_v8(char *stack, extended_cif *ecif)
+void FFI_HIDDEN
+ffi_prep_args_v8(char *stack, extended_cif *ecif)
{
int i;
void **p_argv;
@@ -127,7 +128,8 @@ void ffi_prep_args_v8(char *stack, extended_cif *ecif)
return;
}
-int ffi_prep_args_v9(char *stack, extended_cif *ecif)
+int FFI_HIDDEN
+ffi_prep_args_v9(char *stack, extended_cif *ecif)
{
int i, ret = 0;
int tmp;
@@ -254,7 +256,8 @@ int ffi_prep_args_v9(char *stack, extended_cif *ecif)
}
/* Perform machine dependent cif processing */
-ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
+ffi_status FFI_HIDDEN
+ffi_prep_cif_machdep(ffi_cif *cif)
{
int wordsize;
@@ -337,7 +340,8 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
return FFI_OK;
}
-int ffi_v9_layout_struct(ffi_type *arg, int off, char *ret, char *intg, char *flt)
+static int
+ffi_v9_layout_struct(ffi_type *arg, int off, char *ret, char *intg, char *flt)
{
ffi_type **ptr = &arg->elements[0];
@@ -371,14 +375,14 @@ int ffi_v9_layout_struct(ffi_type *arg, int off, char *ret, char *intg, char *fl
#ifdef SPARC64
extern int ffi_call_v9(void *, extended_cif *, unsigned,
- unsigned, unsigned *, void (*fn)(void));
+ unsigned, unsigned *, void (*fn)(void)) FFI_HIDDEN;
#else
extern int ffi_call_v8(void *, extended_cif *, unsigned,
- unsigned, unsigned *, void (*fn)(void));
+ unsigned, unsigned *, void (*fn)(void)) FFI_HIDDEN;
#endif
#ifndef __GNUC__
-void ffi_flush_icache (void *, size_t);
+void ffi_flush_icache (void *, size_t) FFI_HIDDEN;
#endif
void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
@@ -478,9 +482,9 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
#ifdef SPARC64
-extern void ffi_closure_v9(void);
+extern void ffi_closure_v9(void) FFI_HIDDEN;
#else
-extern void ffi_closure_v8(void);
+extern void ffi_closure_v8(void) FFI_HIDDEN;
#endif
ffi_status
@@ -534,9 +538,9 @@ ffi_prep_closure_loc (ffi_closure* closure,
return FFI_OK;
}
-int
-ffi_closure_sparc_inner_v8(ffi_closure *closure,
- void *rvalue, unsigned long *gpr, unsigned long *scratch)
+int FFI_HIDDEN
+ffi_closure_sparc_inner_v8(ffi_closure *closure, void *rvalue,
+ unsigned long *gpr, unsigned long *scratch)
{
ffi_cif *cif;
ffi_type **arg_types;
@@ -592,9 +596,9 @@ ffi_closure_sparc_inner_v8(ffi_closure *closure,
return cif->rtype->type;
}
-int
-ffi_closure_sparc_inner_v9(ffi_closure *closure,
- void *rvalue, unsigned long *gpr, double *fpr)
+int FFI_HIDDEN
+ffi_closure_sparc_inner_v9(ffi_closure *closure, void *rvalue,
+ unsigned long *gpr, double *fpr)
{
ffi_cif *cif;
ffi_type **arg_types;
diff --git a/src/sparc/v8.S b/src/sparc/v8.S
index 6bf7ac0..10c66ba 100644
--- a/src/sparc/v8.S
+++ b/src/sparc/v8.S
@@ -28,18 +28,31 @@
#define LIBFFI_ASM
#include <fficonfig.h>
#include <ffi.h>
+#include <ffi_cfi.h>
#define STACKFRAME 96 /* Minimum stack framesize for SPARC */
#define ARGS (64+4) /* Offset of register area in frame */
-#ifndef __GNUC__
+#define C2(X, Y) X ## Y
+#define C1(X, Y) C2(X, Y)
+
+#ifdef __USER_LABEL_PREFIX__
+# define C(Y) C1(__USER_LABEL_PREFIX__, Y)
+#else
+# define C(Y) Y
+#endif
+#define L(Y) C1(.L, Y)
+
.text
+
+#ifndef __GNUC__
.align 8
-.globl ffi_flush_icache
-.globl _ffi_flush_icache
+ .globl C(ffi_flush_icache)
+ .type C(ffi_flush_icache),@function
+ FFI_HIDDEN(C(ffi_flush_icache))
-ffi_flush_icache:
-_ffi_flush_icache:
+C(ffi_flush_icache):
+ cfi_startproc
add %o0, %o1, %o2
#ifdef SPARC64
1: flush %o0
@@ -56,20 +69,20 @@ _ffi_flush_icache:
nop
retl
nop
-.ffi_flush_icache_end:
- .size ffi_flush_icache,.ffi_flush_icache_end-ffi_flush_icache
+ cfi_endproc
+ .size C(ffi_flush_icache), . - C(ffi_flush_icache)
#endif
- .text
.align 8
-.globl ffi_call_v8
-.globl _ffi_call_v8
+ .globl C(ffi_call_v8)
+ .type C(ffi_call_v8),@function
+ FFI_HIDDEN(C(ffi_call_v8))
-ffi_call_v8:
-_ffi_call_v8:
-.LLFB1:
+C(ffi_call_v8):
+ cfi_startproc
save %sp, -STACKFRAME, %sp
-.LLCFI0:
+ cfi_def_cfa_register(%fp)
+ cfi_window_save
sub %sp, %i2, %sp ! alloca() space in stack for frame to set up
add %sp, STACKFRAME, %l0 ! %l0 has start of
@@ -91,81 +104,81 @@ _ffi_call_v8:
! If the return value pointer is NULL, assume no return value.
tst %i4
- bz done
+ bz L(done)
nop
cmp %i3, FFI_TYPE_INT
- be,a done
+ be,a L(done)
st %o0, [%i4] ! (delay)
cmp %i3, FFI_TYPE_FLOAT
- be,a done
+ be,a L(done)
st %f0, [%i4+0] ! (delay)
cmp %i3, FFI_TYPE_DOUBLE
- be,a double
+ be,a L(double)
st %f0, [%i4+0] ! (delay)
cmp %i3, FFI_TYPE_SINT8
- be,a sint8
+ be,a L(sint8)
sll %o0, 24, %o0 ! (delay)
cmp %i3, FFI_TYPE_UINT8
- be,a uint8
+ be,a L(uint8)
sll %o0, 24, %o0 ! (delay)
cmp %i3, FFI_TYPE_SINT16
- be,a sint16
+ be,a L(sint16)
sll %o0, 16, %o0 ! (delay)
cmp %i3, FFI_TYPE_UINT16
- be,a uint16
+ be,a L(uint16)
sll %o0, 16, %o0 ! (delay)
cmp %i3, FFI_TYPE_SINT64
- be,a longlong
+ be,a L(longlong)
st %o0, [%i4+0] ! (delay)
-done:
+
+L(done):
ret
restore
-double:
+L(double):
st %f1, [%i4+4]
ret
restore
-sint8:
+L(sint8):
sra %o0, 24, %o0
st %o0, [%i4+0]
ret
restore
-uint8:
+L(uint8):
srl %o0, 24, %o0
st %o0, [%i4+0]
ret
restore
-sint16:
+L(sint16):
sra %o0, 16, %o0
st %o0, [%i4+0]
ret
restore
-uint16:
+L(uint16):
srl %o0, 16, %o0
st %o0, [%i4+0]
ret
restore
-longlong:
+L(longlong):
st %o1, [%i4+4]
ret
restore
-.LLFE1:
+ cfi_endproc
-.ffi_call_v8_end:
- .size ffi_call_v8,.ffi_call_v8_end-ffi_call_v8
+ .size C(ffi_call_v8),. - C(ffi_call_v8)
#undef STACKFRAME
@@ -178,15 +191,16 @@ longlong:
Receives the closure argument in %g2. */
- .text
.align 8
- .globl ffi_closure_v8
+ .globl C(ffi_closure_v8)
+ .type C(ffi_closure_v8),@function
+ FFI_HIDDEN(C(ffi_closure_v8))
-ffi_closure_v8:
+C(ffi_closure_v8):
#ifdef HAVE_AS_REGISTER_PSEUDO_OP
.register %g2, #scratch
#endif
-.LLFB2:
+ cfi_startproc
! Reserve frame space for all arguments in case
! we need to align them on a 8-byte boundary.
ld [%g2+FFI_TRAMPOLINE_SIZE], %g1
@@ -196,7 +210,8 @@ ffi_closure_v8:
! %g1 == STACKFRAME + 8*nargs
neg %g1
save %sp, %g1, %sp
-.LLCFI1:
+ cfi_def_cfa_register(%fp)
+ cfi_window_save
! Store all of the potential argument registers in va_list format.
st %i0, [%fp+68+0]
@@ -216,130 +231,47 @@ ffi_closure_v8:
! Load up the return value in the proper type.
! See ffi_prep_cif_machdep for the list of cases.
cmp %o0, FFI_TYPE_VOID
- be done1
+ be L(done1)
cmp %o0, FFI_TYPE_INT
- be done1
+ be L(done1)
ld [%fp-8], %i0
cmp %o0, FFI_TYPE_FLOAT
- be,a done1
+ be,a L(done1)
ld [%fp-8], %f0
cmp %o0, FFI_TYPE_DOUBLE
- be,a done1
+ be,a L(done1)
ldd [%fp-8], %f0
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
cmp %o0, FFI_TYPE_LONGDOUBLE
- be done2
+ be L(done2)
#endif
cmp %o0, FFI_TYPE_STRUCT
- be done2
+ be L(done2)
cmp %o0, FFI_TYPE_SINT64
- be,a done1
+ be,a L(done1)
ldd [%fp-8], %i0
cmp %o0, FFI_TYPE_UINT64
- be,a done1
+ be,a L(done1)
ldd [%fp-8], %i0
ld [%fp-8], %i0
-done1:
+L(done1):
jmp %i7+8
restore
-done2:
+L(done2):
! Skip 'unimp'.
jmp %i7+12
restore
-.LLFE2:
-
-.ffi_closure_v8_end:
- .size ffi_closure_v8,.ffi_closure_v8_end-ffi_closure_v8
-#ifdef SPARC64
-#define WS 8
-#define nword xword
-#define uanword uaxword
-#else
-#define WS 4
-#define nword long
-#define uanword uaword
-#endif
-
-#ifdef HAVE_RO_EH_FRAME
- .section ".eh_frame",#alloc
-#else
- .section ".eh_frame",#alloc,#write
-#endif
-.LLframe1:
- .uaword .LLECIE1-.LLSCIE1 ! Length of Common Information Entry
-.LLSCIE1:
- .uaword 0x0 ! CIE Identifier Tag
- .byte 0x1 ! CIE Version
- .ascii "zR\0" ! CIE Augmentation
- .byte 0x1 ! uleb128 0x1; CIE Code Alignment Factor
- .byte 0x80-WS ! sleb128 -WS; CIE Data Alignment Factor
- .byte 0xf ! CIE RA Column
- .byte 0x1 ! uleb128 0x1; Augmentation size
-#ifdef HAVE_AS_SPARC_UA_PCREL
- .byte 0x1b ! FDE Encoding (pcrel sdata4)
-#else
- .byte 0x50 ! FDE Encoding (aligned absolute)
-#endif
- .byte 0xc ! DW_CFA_def_cfa
- .byte 0xe ! uleb128 0xe
- .byte 0x0 ! uleb128 0x0
- .align WS
-.LLECIE1:
-.LLSFDE1:
- .uaword .LLEFDE1-.LLASFDE1 ! FDE Length
-.LLASFDE1:
- .uaword .LLASFDE1-.LLframe1 ! FDE CIE offset
-#ifdef HAVE_AS_SPARC_UA_PCREL
- .uaword %r_disp32(.LLFB1)
- .uaword .LLFE1-.LLFB1 ! FDE address range
-#else
- .align WS
- .nword .LLFB1
- .uanword .LLFE1-.LLFB1 ! FDE address range
-#endif
- .byte 0x0 ! uleb128 0x0; Augmentation size
- .byte 0x4 ! DW_CFA_advance_loc4
- .uaword .LLCFI0-.LLFB1
- .byte 0xd ! DW_CFA_def_cfa_register
- .byte 0x1e ! uleb128 0x1e
- .byte 0x2d ! DW_CFA_GNU_window_save
- .byte 0x9 ! DW_CFA_register
- .byte 0xf ! uleb128 0xf
- .byte 0x1f ! uleb128 0x1f
- .align WS
-.LLEFDE1:
-.LLSFDE2:
- .uaword .LLEFDE2-.LLASFDE2 ! FDE Length
-.LLASFDE2:
- .uaword .LLASFDE2-.LLframe1 ! FDE CIE offset
-#ifdef HAVE_AS_SPARC_UA_PCREL
- .uaword %r_disp32(.LLFB2)
- .uaword .LLFE2-.LLFB2 ! FDE address range
-#else
- .align WS
- .nword .LLFB2
- .uanword .LLFE2-.LLFB2 ! FDE address range
-#endif
- .byte 0x0 ! uleb128 0x0; Augmentation size
- .byte 0x4 ! DW_CFA_advance_loc4
- .uaword .LLCFI1-.LLFB2
- .byte 0xd ! DW_CFA_def_cfa_register
- .byte 0x1e ! uleb128 0x1e
- .byte 0x2d ! DW_CFA_GNU_window_save
- .byte 0x9 ! DW_CFA_register
- .byte 0xf ! uleb128 0xf
- .byte 0x1f ! uleb128 0x1f
- .align WS
-.LLEFDE2:
+ cfi_endproc
+ .size C(ffi_closure_v8), . - C(ffi_closure_v8)
#if defined __ELF__ && defined __linux__
.section .note.GNU-stack,"",@progbits
diff --git a/src/sparc/v9.S b/src/sparc/v9.S
index bf31a2b..aba468e 100644
--- a/src/sparc/v9.S
+++ b/src/sparc/v9.S
@@ -27,25 +27,38 @@
#define LIBFFI_ASM
#include <fficonfig.h>
#include <ffi.h>
+#include <ffi_cfi.h>
#ifdef SPARC64
/* Only compile this in for 64bit builds, because otherwise the object file
will have inproper architecture due to used instructions. */
+#define C2(X, Y) X ## Y
+#define C1(X, Y) C2(X, Y)
+
+#ifdef __USER_LABEL_PREFIX__
+# define C(Y) C1(__USER_LABEL_PREFIX__, Y)
+#else
+# define C(Y) Y
+#endif
+#define L(Y) C1(.L, Y)
+
+
#define STACKFRAME 176 /* Minimum stack framesize for SPARC 64-bit */
#define STACK_BIAS 2047
#define ARGS (128) /* Offset of register area in frame */
.text
.align 8
-.globl ffi_call_v9
-.globl _ffi_call_v9
+ .globl C(ffi_call_v9)
+ .type C(ffi_call_v9),@function
+ FFI_HIDDEN(C(ffi_call_v9))
-ffi_call_v9:
-_ffi_call_v9:
-.LLFB1:
+C(ffi_call_v9):
+ cfi_startproc
save %sp, -STACKFRAME, %sp
-.LLCFI0:
+ cfi_def_cfa_register(%fp)
+ cfi_window_save
sub %sp, %i2, %sp ! alloca() space in stack for frame to set up
add %sp, STACKFRAME+STACK_BIAS, %l0 ! %l0 has start of
@@ -83,34 +96,35 @@ _ffi_call_v9:
sub %l0, STACK_BIAS, %sp ! (delay) switch to frame
! If the return value pointer is NULL, assume no return value.
- brz,pn %i4, done
+ brz,pn %i4, L(done)
nop
cmp %i3, FFI_TYPE_INT
- be,a,pt %icc, done
+ be,a,pt %icc, L(done)
stx %o0, [%i4+0] ! (delay)
cmp %i3, FFI_TYPE_FLOAT
- be,a,pn %icc, done
+ be,a,pn %icc, L(done)
st %f0, [%i4+0] ! (delay)
cmp %i3, FFI_TYPE_DOUBLE
- be,a,pn %icc, done
+ be,a,pn %icc, L(done)
std %f0, [%i4+0] ! (delay)
cmp %i3, FFI_TYPE_STRUCT
- be,pn %icc, dostruct
+ be,pn %icc, L(dostruct)
cmp %i3, FFI_TYPE_LONGDOUBLE
- bne,pt %icc, done
+ bne,pt %icc, L(done)
nop
std %f0, [%i4+0]
std %f2, [%i4+8]
-done: ret
+L(done):
+ ret
restore
-dostruct:
+L(dostruct):
/* This will not work correctly for unions. */
stx %o0, [%i4+0]
stx %o1, [%i4+8]
@@ -122,10 +136,9 @@ dostruct:
std %f6, [%i4+56]
ret
restore
-.LLFE1:
-.ffi_call_v9_end:
- .size ffi_call_v9,.ffi_call_v9_end-ffi_call_v9
+ cfi_endproc
+ .size C(ffi_call_v9), . - C(ffi_call_v9)
#undef STACKFRAME
@@ -138,14 +151,16 @@ dostruct:
Receives the closure argument in %g1. */
- .text
.align 8
- .globl ffi_closure_v9
+ .globl C(ffi_closure_v9)
+ .type C(ffi_closure_v9),@function
+ FFI_HIDDEN(C(ffi_closure_v9))
-ffi_closure_v9:
-.LLFB2:
+C(ffi_closure_v9):
+ cfi_startproc
save %sp, -STACKFRAME, %sp
-.LLCFI1:
+ cfi_def_cfa_register(%fp)
+ cfi_window_save
! Store all of the potential argument registers in va_list format.
stx %i0, [FP+128+0]
@@ -177,28 +192,28 @@ ffi_closure_v9:
mov %g1, %o0
add %fp, STACK_BIAS-160, %o1
add %fp, STACK_BIAS+128, %o2
- call ffi_closure_sparc_inner_v9
+ call C(ffi_closure_sparc_inner_v9)
add %fp, STACK_BIAS-128, %o3
! Load up the return value in the proper type.
! See ffi_prep_cif_machdep for the list of cases.
cmp %o0, FFI_TYPE_VOID
- be,pn %icc, done1
+ be,pn %icc, L(done1)
cmp %o0, FFI_TYPE_INT
- be,pn %icc, integer
+ be,pn %icc, L(integer)
cmp %o0, FFI_TYPE_FLOAT
- be,a,pn %icc, done1
+ be,a,pn %icc, L(done1)
ld [FP-160], %f0
cmp %o0, FFI_TYPE_DOUBLE
- be,a,pn %icc, done1
+ be,a,pn %icc, L(done1)
ldd [FP-160], %f0
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
cmp %o0, FFI_TYPE_LONGDOUBLE
- be,a,pn %icc, longdouble1
+ be,a,pn %icc, L(longdouble1)
ldd [FP-160], %f0
#endif
@@ -211,97 +226,24 @@ ffi_closure_v9:
ldd [FP-144], %f4
ldd [FP-136], %f6
-integer:
+L(integer):
ldx [FP-160], %i0
-done1:
+L(done1):
ret
restore
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
-longdouble1:
+L(longdouble1):
ldd [FP-152], %f2
ret
restore
#endif
-.LLFE2:
-.ffi_closure_v9_end:
- .size ffi_closure_v9,.ffi_closure_v9_end-ffi_closure_v9
-
-#ifdef HAVE_RO_EH_FRAME
- .section ".eh_frame",#alloc
-#else
- .section ".eh_frame",#alloc,#write
-#endif
-.LLframe1:
- .uaword .LLECIE1-.LLSCIE1 ! Length of Common Information Entry
-.LLSCIE1:
- .uaword 0x0 ! CIE Identifier Tag
- .byte 0x1 ! CIE Version
- .ascii "zR\0" ! CIE Augmentation
- .byte 0x1 ! uleb128 0x1; CIE Code Alignment Factor
- .byte 0x78 ! sleb128 -8; CIE Data Alignment Factor
- .byte 0xf ! CIE RA Column
- .byte 0x1 ! uleb128 0x1; Augmentation size
-#ifdef HAVE_AS_SPARC_UA_PCREL
- .byte 0x1b ! FDE Encoding (pcrel sdata4)
-#else
- .byte 0x50 ! FDE Encoding (aligned absolute)
-#endif
- .byte 0xc ! DW_CFA_def_cfa
- .byte 0xe ! uleb128 0xe
- .byte 0xff,0xf ! uleb128 0x7ff
- .align 8
-.LLECIE1:
-.LLSFDE1:
- .uaword .LLEFDE1-.LLASFDE1 ! FDE Length
-.LLASFDE1:
- .uaword .LLASFDE1-.LLframe1 ! FDE CIE offset
-#ifdef HAVE_AS_SPARC_UA_PCREL
- .uaword %r_disp32(.LLFB1)
- .uaword .LLFE1-.LLFB1 ! FDE address range
-#else
- .align 8
- .xword .LLFB1
- .uaxword .LLFE1-.LLFB1 ! FDE address range
-#endif
- .byte 0x0 ! uleb128 0x0; Augmentation size
- .byte 0x4 ! DW_CFA_advance_loc4
- .uaword .LLCFI0-.LLFB1
- .byte 0xd ! DW_CFA_def_cfa_register
- .byte 0x1e ! uleb128 0x1e
- .byte 0x2d ! DW_CFA_GNU_window_save
- .byte 0x9 ! DW_CFA_register
- .byte 0xf ! uleb128 0xf
- .byte 0x1f ! uleb128 0x1f
- .align 8
-.LLEFDE1:
-.LLSFDE2:
- .uaword .LLEFDE2-.LLASFDE2 ! FDE Length
-.LLASFDE2:
- .uaword .LLASFDE2-.LLframe1 ! FDE CIE offset
-#ifdef HAVE_AS_SPARC_UA_PCREL
- .uaword %r_disp32(.LLFB2)
- .uaword .LLFE2-.LLFB2 ! FDE address range
-#else
- .align 8
- .xword .LLFB2
- .uaxword .LLFE2-.LLFB2 ! FDE address range
-#endif
- .byte 0x0 ! uleb128 0x0; Augmentation size
- .byte 0x4 ! DW_CFA_advance_loc4
- .uaword .LLCFI1-.LLFB2
- .byte 0xd ! DW_CFA_def_cfa_register
- .byte 0x1e ! uleb128 0x1e
- .byte 0x2d ! DW_CFA_GNU_window_save
- .byte 0x9 ! DW_CFA_register
- .byte 0xf ! uleb128 0xf
- .byte 0x1f ! uleb128 0x1f
- .align 8
-.LLEFDE2:
-#endif
+ cfi_endproc
+ .size C(ffi_closure_v9), . - C(ffi_closure_v9)
+#endif /* SPARC64 */
#ifdef __linux__
.section .note.GNU-stack,"",@progbits
#endif
--
1.9.3