diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2002-08-11 12:13:17 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2002-08-11 12:13:17 +0000 |
commit | 2602573e86449ad72340ab515d5962bad4856642 (patch) | |
tree | b70be10522792b3dbbe6c0a0c635b7b34089f70f /sys/arch/sparc/include | |
parent | 05722dbc2443ec4362e73a5e2fa77bb8de847d34 (diff) |
Prepare for ELF.
Diffstat (limited to 'sys/arch/sparc/include')
-rw-r--r-- | sys/arch/sparc/include/asm.h | 29 | ||||
-rw-r--r-- | sys/arch/sparc/include/cdefs.h | 23 | ||||
-rw-r--r-- | sys/arch/sparc/include/profile.h | 32 |
3 files changed, 59 insertions, 25 deletions
diff --git a/sys/arch/sparc/include/asm.h b/sys/arch/sparc/include/asm.h index d1f4082b5f0..d3382f94cda 100644 --- a/sys/arch/sparc/include/asm.h +++ b/sys/arch/sparc/include/asm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: asm.h,v 1.2 1997/08/08 08:26:02 downsj Exp $ */ +/* $OpenBSD: asm.h,v 1.3 2002/08/11 12:13:16 art Exp $ */ /* $NetBSD: asm.h,v 1.5 1997/07/16 15:16:43 christos Exp $ */ /* @@ -45,13 +45,36 @@ #ifndef _ASM_H_ #define _ASM_H_ +#ifdef __ELF__ +#define _C_LABEL(name) name +#else #ifdef __STDC__ #define _C_LABEL(name) _ ## name #else #define _C_LABEL(name) _/**/name #endif +#endif #define _ASM_LABEL(name) name +/* + * WEAK_ALIAS: create a weak alias (ELF only) + */ +#ifdef __ELF__ +#define WEAK_ALIAS(alias,sym) \ + .weak alias; \ + alias = sym +#endif + +/* + * WARN_REFERENCES: create a warning if the specified symbol is referenced + * (ELF only). + */ +#ifdef __ELF__ +#define WARN_REFERENCES(_sym,_msg) \ + .section .gnu.warning. ## _sym ; .ascii _msg ; .text +#endif /* __ELF__ */ + + #ifdef PIC /* * PIC_PROLOGUE() is akin to the compiler generated function prologue for @@ -61,8 +84,8 @@ */ #define PIC_PROLOGUE(dest,tmp) \ mov %o7,tmp; 3: call 4f; nop; 4: \ - sethi %hi(__GLOBAL_OFFSET_TABLE_-(3b-.)),dest; \ - or dest,%lo(__GLOBAL_OFFSET_TABLE_-(3b-.)),dest; \ + sethi %hi(_C_LABEL(_GLOBAL_OFFSET_TABLE_)-(3b-.)),dest; \ + or dest,%lo(_C_LABEL(_GLOBAL_OFFSET_TABLE_)-(3b-.)),dest; \ add dest,%o7,dest; mov tmp,%o7 /* diff --git a/sys/arch/sparc/include/cdefs.h b/sys/arch/sparc/include/cdefs.h index 9173258112a..711af194ebc 100644 --- a/sys/arch/sparc/include/cdefs.h +++ b/sys/arch/sparc/include/cdefs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cdefs.h,v 1.7 2002/02/14 04:23:33 fgsch Exp $ */ +/* $OpenBSD: cdefs.h,v 1.8 2002/08/11 12:13:16 art Exp $ */ /* $NetBSD: cdefs.h,v 1.3 1996/12/27 20:51:31 pk Exp $ */ /* @@ -15,8 +15,14 @@ #define _C_LABEL(x) _STRING(_/**/x) #endif -#ifdef __GNUC__ -#ifdef __STDC__ +#if defined(__GNUC__) && defined(__STDC__) +#ifdef __ELF__ +#define __weak_alias(alias,sym) \ + __asm__(".weak " __STRING(alias) " ; " __STRING(alias) " = " __STRING(sym)) +#define __warn_references(sym,msg) \ + __asm__(".section .gnu.warning." __STRING(sym) " ; .ascii \"" msg "\" ; .text") + +#else #define __indr_reference(sym,alias) \ __asm__(".stabs \"_" #alias "\",11,0,0,0"); \ __asm__(".stabs \"_" #sym "\",1,0,0,0") @@ -25,16 +31,7 @@ __asm__(".stabs \"_" #sym "\",1,0,0,0") #define __weak_alias(alias,sym) \ __asm__(".weak _" #alias "; _" #alias "= _" __STRING(sym)) -#else -#define __indr_reference(sym,alias) \ - __asm__(".stabs \"_/**/alias\",11,0,0,0"); \ - __asm__(".stabs \"_/**/sym\",1,0,0,0") -#define __warn_references(sym,msg) \ - __asm__(".stabs msg,30,0,0,0"); \ - __asm__(".stabs \"_/**/sym\",1,0,0,0") -#define __weak_alias(alias,sym) \ - __asm__(".weak _/**/alias; _/**/alias = _/**/sym") -#endif +#endif /* __ELF__ */ #else #define __indr_reference(sym,alias) #define __warn_references(sym,msg) diff --git a/sys/arch/sparc/include/profile.h b/sys/arch/sparc/include/profile.h index b932ae050d6..3cc3c389fec 100644 --- a/sys/arch/sparc/include/profile.h +++ b/sys/arch/sparc/include/profile.h @@ -1,4 +1,4 @@ -/* $OpenBSD: profile.h,v 1.6 1998/11/20 20:31:08 deraadt Exp $ */ +/* $OpenBSD: profile.h,v 1.7 2002/08/11 12:13:16 art Exp $ */ /* $NetBSD: profile.h,v 1.8 1997/02/01 20:56:40 mrg Exp $ */ /* @@ -45,28 +45,42 @@ * @(#)profile.h 8.1 (Berkeley) 6/11/93 */ +/* + * Can't use _C_LABEL here. + */ + +#ifdef __ELF__ +#define _MCOUNT_SYM "__mcount" +#define _MCOUNT_ENTRY "_mcount" +#else +#define _MCOUNT_SYM "___mcount" +#define _MCOUNT_ENTRY "mcount" +#endif + #ifdef PIC /* Inline expansion of PICCY_SET() (see <machine/asm.h>). */ #define MCOUNT \ - __asm__(".global mcount");\ - __asm__("mcount:");\ + __asm__(".global " _MCOUNT_ENTRY);\ + __asm__(".text");\ + __asm__(_MCOUNT_ENTRY ":");\ __asm__("add %o7, 8, %o1");\ __asm__("1: call 2f; nop; 2:");\ - __asm__("add %o7,__mcount-1b, %o2");\ + __asm__("add %o7," _MCOUNT_SYM "-1b, %o2");\ __asm__("ld [%o2], %o2");\ __asm__("jmpl %o2, %g0");\ __asm__("add %i7, 8, %o0"); #else #define MCOUNT \ - __asm__(".global mcount");\ - __asm__("mcount:");\ + __asm__(".global " _MCOUNT_ENTRY);\ + __asm__(".text");\ + __asm__(_MCOUNT_ENTRY ":");\ __asm__("add %i7, 8, %o0");\ - __asm__("sethi %hi(__mcount), %o2");\ - __asm__("jmpl %o2 + %lo(__mcount), %g0");\ + __asm__("sethi %hi(" _MCOUNT_SYM "), %o2");\ + __asm__("jmpl %o2 + %lo(" _MCOUNT_SYM "), %g0");\ __asm__("add %o7, 8, %o1"); #endif -#define _MCOUNT_DECL static void _mcount +#define _MCOUNT_DECL static void __mcount #ifdef _KERNEL /* |