• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*  $NetBSD: cdefs_aout.h,v 1.20 2006/05/18 17:55:38 christos Exp $ */
2 
3 /*
4  * Written by J.T. Conklin <jtc@wimsey.com> 01/17/95.
5  * Public domain.
6  */
7 
8 #ifndef _SYS_CDEFS_AOUT_H_
9 #define _SYS_CDEFS_AOUT_H_
10 
11 #define _C_LABEL(x)   __CONCAT(_,x)
12 #define _C_LABEL_STRING(x)  "_"x
13 
14 #define ___RENAME(x)
15 
16 #define __indr_reference(sym,alias) /* nada, since we do weak refs */
17 
18 #ifdef __GNUC__
19 #if __STDC__
20   #ifndef   DONT_USE_STRONG_WEAK_ALIAS
21     #define __strong_alias(alias,sym)               \
22         __asm(".global " _C_LABEL_STRING(#alias) "\n"     \
23           _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym));
24     #define __weak_alias(alias,sym)           \
25         __asm(".weak " _C_LABEL_STRING(#alias) "\n"     \
26           _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym));
27 
28     /* Do not use __weak_extern, use __weak_reference instead */
29     #define __weak_extern(sym)            \
30         __asm(".weak " _C_LABEL_STRING(#sym));
31 
32     #if __GNUC_PREREQ__(4, 0)
33       #define __weak_reference(sym) __attribute__((__weakref__))
34     #else
35       #define __weak_reference(sym) ; __asm(".weak " _C_LABEL_STRING(#sym))
36     #endif
37 
38     #define __warn_references(sym,msg)          \
39       __asm(".stabs \"" msg "\",30,0,0,0");       \
40       __asm(".stabs \"_" #sym "\",1,0,0,0");
41   #else
42     #define __strong_alias(alias,sym)   /* NOTHING */
43     #define __weak_alias(alias,sym)     /* NOTHING */
44     #define __weak_extern(sym)          /* NOTHING */
45     #define __weak_reference(sym)       /* NOTHING */
46 
47     #if defined(__CC_ARM) || defined(__APPLE__)
48       #define __warn_references(sym,msg)
49     #else
50       #define __warn_references(sym,msg)              \
51               __asm(".stabs \"" msg "\",30,0,0,0");   \
52               __asm(".stabs \"_" #sym "\",1,0,0,0");
53     #endif
54   #endif
55 #else   /* __STDC__ */
56   #define __weak_alias(alias,sym) ___weak_alias(_/**/alias,_/**/sym)
57   #define ___weak_alias(alias,sym)          \
58       __asm(".weak alias\nalias = sym");
59   /* Do not use __weak_extern, use __weak_reference instead */
60   #define __weak_extern(sym) ___weak_extern(_/**/sym)
61   #define ___weak_extern(sym)           \
62       __asm(".weak sym");
63 
64   #if __GNUC_PREREQ__(4, 0)
65     #define __weak_reference(sym) __attribute__((__weakref__))
66   #else
67     #define ___weak_reference(sym)  ; __asm(".weak sym");
68     #define __weak_reference(sym) ___weak_reference(_/**/sym)
69   #endif
70 
71   #define __warn_references(sym,msg)          \
72     __asm(".stabs msg,30,0,0,0");         \
73     __asm(".stabs \"_/**/sym\",1,0,0,0");
74 #endif /* __STDC__ */
75 #else /* __GNUC__ */
76   #define __warn_references(sym,msg)
77 #endif /* __GNUC__ */
78 
79 #if defined(__sh__)   /* XXX SH COFF */
80 #undef __indr_reference(sym,alias)
81 #undef __warn_references(sym,msg)
82 #define __warn_references(sym,msg)
83 #endif
84 
85 #define __IDSTRING(_n,_s)           \
86   __asm(".data ; .asciz \"" _s "\" ; .text")
87 
88 #undef __KERNEL_RCSID
89 
90 //#define __RCSID(_s) __IDSTRING(rcsid,_s)
91 #define __RCSID(_s)
92 #define __SCCSID(_s)
93 #define __SCCSID2(_s)
94 #if 0 /* XXX userland __COPYRIGHTs have \ns in them */
95 #define __COPYRIGHT(_s) __IDSTRING(copyright,_s)
96 #else
97 #define __COPYRIGHT(_s)             \
98   static const char copyright[] __attribute__((__unused__)) = _s
99 #endif
100 
101 #if defined(USE_KERNEL_RCSIDS) || !defined(_KERNEL)
102 #define __KERNEL_RCSID(_n,_s) __IDSTRING(__CONCAT(rcsid,_n),_s)
103 #else
104 #define __KERNEL_RCSID(_n,_s)
105 #endif
106 #define __KERNEL_SCCSID(_n,_s)
107 #define __KERNEL_COPYRIGHT(_n, _s) __IDSTRING(__CONCAT(copyright,_n),_s)
108 
109 #ifndef __lint__
110 #define __link_set_make_entry(set, sym, type)       \
111   static void const * const         \
112       __link_set_##set##_sym_##sym __used = &sym;   \
113   __asm(".stabs \"___link_set_" #set "\", " #type ", 0, 0, _" #sym)
114 #else
115 #define __link_set_make_entry(set, sym, type)       \
116   extern void const * const __link_set_##set##_sym_##sym
117 #endif /* __lint__ */
118 
119 #define __link_set_add_text(set, sym) __link_set_make_entry(set, sym, 23)
120 #define __link_set_add_rodata(set, sym) __link_set_make_entry(set, sym, 23)
121 #define __link_set_add_data(set, sym) __link_set_make_entry(set, sym, 25)
122 #define __link_set_add_bss(set, sym)  __link_set_make_entry(set, sym, 27)
123 
124 #define __link_set_decl(set, ptype)         \
125 extern struct {               \
126   int __ls_length;            \
127   ptype *__ls_items[1];           \
128 } __link_set_##set
129 
130 #define __link_set_start(set) (&(__link_set_##set).__ls_items[0])
131 #define __link_set_end(set)           \
132   (&(__link_set_##set).__ls_items[(__link_set_##set).__ls_length])
133 
134 #define __link_set_count(set) ((__link_set_##set).__ls_length)
135 
136 #endif /* !_SYS_CDEFS_AOUT_H_ */
137