Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:14

0001 /*  $NetBSD: cdefs_elf.h,v 1.24 2005/07/16 17:53:36 christos Exp $  */
0002 
0003 /*
0004  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
0005  * All rights reserved.
0006  *
0007  * Author: Chris G. Demetriou
0008  *
0009  * Permission to use, copy, modify and distribute this software and
0010  * its documentation is hereby granted, provided that both the copyright
0011  * notice and this permission notice appear in all copies of the
0012  * software, derivative works or modified versions, and any portions
0013  * thereof, and that both notices appear in supporting documentation.
0014  *
0015  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
0016  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
0017  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
0018  *
0019  * Carnegie Mellon requests users of this software to return to
0020  *
0021  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
0022  *  School of Computer Science
0023  *  Carnegie Mellon University
0024  *  Pittsburgh PA 15213-3890
0025  *
0026  * any improvements or extensions that they make and grant Carnegie the
0027  * rights to redistribute these changes.
0028  */
0029 
0030 #ifndef _SYS_CDEFS_ELF_H_
0031 #define _SYS_CDEFS_ELF_H_
0032 
0033 #ifdef __LEADING_UNDERSCORE
0034 #define _C_LABEL(x) __CONCAT(_,x)
0035 #define _C_LABEL_STRING(x)  "_"x
0036 #else
0037 #define _C_LABEL(x) x
0038 #define _C_LABEL_STRING(x)  x
0039 #endif
0040 
0041 #if __STDC__
0042 #define ___RENAME(x)    __asm__(___STRING(_C_LABEL(x)))
0043 #else
0044 #ifdef __LEADING_UNDERSCORE
0045 #define ___RENAME(x)    ____RENAME(_/**/x)
0046 #define ____RENAME(x)   __asm__(___STRING(x))
0047 #else
0048 #define ___RENAME(x)    __asm__(___STRING(x))
0049 #endif
0050 #endif
0051 
0052 #define __indr_reference(sym,alias) /* nada, since we do weak refs */
0053 
0054 #if __STDC__
0055 #define __strong_alias(alias,sym)                       \
0056     __asm__(".global " _C_LABEL_STRING(#alias) "\n"         \
0057         _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym));
0058 
0059 #define __weak_alias(alias,sym)                     \
0060     __asm__(".weak " _C_LABEL_STRING(#alias) "\n"           \
0061         _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym));
0062 #define __weak_extern(sym)                      \
0063     __asm__(".weak " _C_LABEL_STRING(#sym));
0064 #define __warn_references(sym,msg)                  \
0065     __asm__(".section .gnu.warning." #sym "\n\t.ascii \"" msg "\"\n\t.text");
0066 
0067 #else /* !__STDC__ */
0068 
0069 #ifdef __LEADING_UNDERSCORE
0070 #define __weak_alias(alias,sym) ___weak_alias(_/**/alias,_/**/sym)
0071 #define ___weak_alias(alias,sym)                    \
0072     __asm__(".weak alias\nalias = sym");
0073 #else
0074 #define __weak_alias(alias,sym)                     \
0075     __asm__(".weak alias\nalias = sym");
0076 #endif
0077 #ifdef __LEADING_UNDERSCORE
0078 #define __weak_extern(sym) ___weak_extern(_/**/sym)
0079 #define ___weak_extern(sym)                     \
0080     __asm__(".weak sym");
0081 #else
0082 #define __weak_extern(sym)                      \
0083     __asm__(".weak sym");
0084 #endif
0085 #define __warn_references(sym,msg)                  \
0086     __asm__(".section .gnu.warning.sym\n\t.ascii msg ; .text");
0087 
0088 #endif /* !__STDC__ */
0089 
0090 #if __STDC__
0091 #define __SECTIONSTRING(_sec, _str)                 \
0092     __asm__(".section " #_sec "\n\t.asciz \"" _str "\"\n\t.previous")
0093 #else
0094 #define __SECTIONSTRING(_sec, _str)                 \
0095     __asm__(".section _sec\n\t.asciz _str\n\t.previous")
0096 #endif
0097 
0098 #define __IDSTRING(_n,_s)       __SECTIONSTRING(.ident,_s)
0099 
0100 #define __RCSID(_s)         __IDSTRING(rcsid,_s)
0101 #define __SCCSID(_s)
0102 #define __SCCSID2(_s)
0103 #if 0   /* XXX userland __COPYRIGHTs have \ns in them */
0104 #define __COPYRIGHT(_s)         __SECTIONSTRING(.copyright,_s)
0105 #else
0106 #define __COPYRIGHT(_s)                         \
0107     static const char copyright[]                   \
0108         __attribute__((__unused__,__section__(".copyright"))) = _s
0109 #endif
0110 
0111 #define __KERNEL_RCSID(_n, _s)      __RCSID(_s)
0112 #define __KERNEL_SCCSID(_n, _s)
0113 #if 0   /* XXX see above */
0114 #define __KERNEL_COPYRIGHT(_n, _s)  __COPYRIGHT(_s)
0115 #else
0116 #define __KERNEL_COPYRIGHT(_n, _s)  __SECTIONSTRING(.copyright, _s)
0117 #endif
0118 
0119 #ifndef __lint__
0120 #define __link_set_make_entry(set, sym)                 \
0121     static void const * const __link_set_##set##_sym_##sym      \
0122         __section("link_set_" #set) __used = &sym
0123 #define __link_set_make_entry2(set, sym, n)             \
0124     static void const * const __link_set_##set##_sym_##sym##_##n    \
0125         __section("link_set_" #set) __used = &sym[n]
0126 #else
0127 #define __link_set_make_entry(set, sym)                 \
0128     extern void const * const __link_set_##set##_sym_##sym
0129 #define __link_set_make_entry2(set, sym, n)             \
0130     extern void const * const __link_set_##set##_sym_##sym##_##n
0131 #endif /* __lint__ */
0132 
0133 #define __link_set_add_text(set, sym)   __link_set_make_entry(set, sym)
0134 #define __link_set_add_rodata(set, sym) __link_set_make_entry(set, sym)
0135 #define __link_set_add_data(set, sym)   __link_set_make_entry(set, sym)
0136 #define __link_set_add_bss(set, sym)    __link_set_make_entry(set, sym)
0137 #define __link_set_add_text2(set, sym, n)   __link_set_make_entry2(set, sym, n)
0138 #define __link_set_add_rodata2(set, sym, n) __link_set_make_entry2(set, sym, n)
0139 #define __link_set_add_data2(set, sym, n)   __link_set_make_entry2(set, sym, n)
0140 #define __link_set_add_bss2(set, sym, n)    __link_set_make_entry2(set, sym, n)
0141 
0142 #define __link_set_decl(set, ptype)                 \
0143     extern ptype * const __start_link_set_##set[];          \
0144     extern ptype * const __stop_link_set_##set[]            \
0145 
0146 #define __link_set_start(set)   (__start_link_set_##set)
0147 #define __link_set_end(set) (__stop_link_set_##set)
0148 
0149 #define __link_set_count(set)                       \
0150     (__link_set_end(set) - __link_set_start(set))
0151 
0152 #endif /* !_SYS_CDEFS_ELF_H_ */