xref: /netbsd/sys/sys/cdefs_elf.h (revision bf9ec67e)
1 /*	$NetBSD: cdefs_elf.h,v 1.11 2002/01/27 07:19:25 lukem Exp $	*/
2 
3 /*
4  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
5  * All rights reserved.
6  *
7  * Author: Chris G. Demetriou
8  *
9  * Permission to use, copy, modify and distribute this software and
10  * its documentation is hereby granted, provided that both the copyright
11  * notice and this permission notice appear in all copies of the
12  * software, derivative works or modified versions, and any portions
13  * thereof, and that both notices appear in supporting documentation.
14  *
15  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18  *
19  * Carnegie Mellon requests users of this software to return to
20  *
21  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
22  *  School of Computer Science
23  *  Carnegie Mellon University
24  *  Pittsburgh PA 15213-3890
25  *
26  * any improvements or extensions that they make and grant Carnegie the
27  * rights to redistribute these changes.
28  */
29 
30 #ifndef _SYS_CDEFS_ELF_H_
31 #define	_SYS_CDEFS_ELF_H_
32 
33 #ifdef __LEADING_UNDERSCORE
34 #define	_C_LABEL(x)	__CONCAT(_,x)
35 #define _C_LABEL_STRING(x)	"_"x
36 #else
37 #define	_C_LABEL(x)	x
38 #define _C_LABEL_STRING(x)	x
39 #endif
40 
41 #if __STDC__
42 #define	___RENAME(x)	__asm__(___STRING(_C_LABEL(x)))
43 #else
44 #ifdef __LEADING_UNDERSCORE
45 #define	___RENAME(x)	____RENAME(_/**/x)
46 #define	____RENAME(x)	__asm__(___STRING(x))
47 #else
48 #define	___RENAME(x)	__asm__(___STRING(x))
49 #endif
50 #endif
51 
52 #undef	__DO_NOT_DO_WEAK__		/* we use weak syms */
53 
54 #ifndef __DO_NOT_DO_WEAK__
55 #define	__indr_reference(sym,alias)	/* nada, since we do weak refs */
56 #endif /* !__DO_NOT_DO_WEAK__ */
57 
58 #if __STDC__
59 
60 #ifndef __DO_NOT_DO_WEAK__
61 #define	__weak_alias(alias,sym)						\
62     __asm__(".weak " _C_LABEL_STRING(#alias) " ; "			\
63 	    _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym));
64 #endif /* !__DO_NOT_DO_WEAK__ */
65 #define	__weak_extern(sym)						\
66     __asm__(".weak " _C_LABEL_STRING(#sym));
67 #define	__warn_references(sym,msg)					\
68     __asm__(".section .gnu.warning." #sym " ; .ascii \"" msg "\" ; .text");
69 
70 #else /* !__STDC__ */
71 
72 #ifndef __DO_NOT_DO_WEAK__
73 #ifdef __LEADING_UNDERSCORE
74 #define __weak_alias(alias,sym) ___weak_alias(_/**/alias,_/**/sym)
75 #define	___weak_alias(alias,sym)					\
76     __asm__(".weak alias ; alias = sym");
77 #else
78 #define	__weak_alias(alias,sym)						\
79     __asm__(".weak alias ; alias = sym");
80 #endif
81 #endif /* !__DO_NOT_DO_WEAK__ */
82 #ifdef __LEADING_UNDERSCORE
83 #define __weak_extern(sym) ___weak_extern(_/**/sym)
84 #define	___weak_extern(sym)						\
85     __asm__(".weak sym");
86 #else
87 #define	__weak_extern(sym)						\
88     __asm__(".weak sym");
89 #endif
90 #define	__warn_references(sym,msg)					\
91     __asm__(".section .gnu.warning.sym ; .ascii msg ; .text");
92 
93 #endif /* !__STDC__ */
94 
95 #if __STDC__
96 #define	__SECTIONSTRING(_sec, _str)					\
97 	__asm__(".section " #_sec " ; .asciz \"" _str "\" ; .text")
98 #else
99 #define	__SECTIONSTRING(_sec, _str)					\
100 	__asm__(".section _sec ; .asciz _str ; .text")
101 #endif
102 
103 #define	__IDSTRING(_n,_s)		__SECTIONSTRING(.ident,_s)
104 
105 #define	__RCSID(_s)			__IDSTRING(rcsid,_s)
106 #define	__SCCSID(_s)
107 #define __SCCSID2(_s)
108 #if 0	/* XXX userland __COPYRIGHTs have \ns in them */
109 #define	__COPYRIGHT(_s)			__SECTIONSTRING(.copyright,_s)
110 #else
111 #define	__COPYRIGHT(_s)							\
112 	static const char copyright[] __attribute__((__unused__)) = _s
113 #endif
114 
115 #define	__KERNEL_RCSID(_n, _s)		__RCSID(_s)
116 #define	__KERNEL_SCCSID(_n, _s)
117 #if 0	/* XXX see above */
118 #define	__KERNEL_COPYRIGHT(_n, _s)	__COPYRIGHT(_s)
119 #else
120 #define	__KERNEL_COPYRIGHT(_n, _s)	__SECTIONSTRING(.copyright, _s)
121 #endif
122 
123 #endif /* !_SYS_CDEFS_ELF_H_ */
124