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