blob: bb846b7fd74369e6bc950b91d3a5fea1ad04c50a [file] [log] [blame]
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08001/* $NetBSD: cdefs_elf.h,v 1.22 2005/02/26 22:25:34 perry 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
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080041#define ___RENAME(x) __asm__(___STRING(_C_LABEL(x)))
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080042
43#define __indr_reference(sym,alias) /* nada, since we do weak refs */
44
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080045#define __strong_alias(alias,sym) \
46 __asm__(".global " _C_LABEL_STRING(#alias) "\n" \
47 _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym));
48
49#define __weak_alias(alias,sym) \
50 __asm__(".weak " _C_LABEL_STRING(#alias) "\n" \
51 _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym));
52#define __weak_extern(sym) \
53 __asm__(".weak " _C_LABEL_STRING(#sym));
Elliott Hughesc13fb752013-12-17 20:43:30 -080054
55/* We use __warnattr instead of __warn_references.
56 * TODO: remove this and put an empty definition in one of the upstream-* compatibility headers.
57 */
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080058#define __warn_references(sym,msg) \
Elliott Hughesc13fb752013-12-17 20:43:30 -080059 /*__asm__(".section .gnu.warning." #sym "\n\t.ascii \"" msg "\"\n\t.text");*/
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080060
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080061#define __SECTIONSTRING(_sec, _str) \
62 __asm__(".section " #_sec "\n\t.asciz \"" _str "\"\n\t.previous")
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080063
Jim Huang9d16a792010-09-27 19:23:06 +080064/* GCC visibility helper macro */
David 'Digit' Turner5fbf2e02012-01-23 15:15:30 +010065/* This must be used to tag non-static functions that are private, i.e.
66 * never exposed by the shared library. */
Jim Huang9d16a792010-09-27 19:23:06 +080067#define __LIBC_HIDDEN__ \
68 __attribute__ ((visibility ("hidden")))
69
David 'Digit' Turner5fbf2e02012-01-23 15:15:30 +010070/* This must be used to tag non-static functions that are public, i.e.
71 * exposed by the shared library, and part of the stable NDK ABI */
72#define __LIBC_ABI_PUBLIC__ \
73 __attribute__ ((visibility ("default")))
74
75/* This must be used to tag non-static functions that must be exported
76 * by the shared library, but whose implementation is private to the
77 * platform. For now this is equivalent to __LIBC_ABI_PUBLIC__, but we
78 * may want to change this later.
79 */
80#define __LIBC_ABI_PRIVATE__ \
81 __attribute__ ((visibility ("default")))
82
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080083#define __IDSTRING(_n,_s) __SECTIONSTRING(.ident,_s)
84
85#define __RCSID(_s) __IDSTRING(rcsid,_s)
86#define __SCCSID(_s)
87#define __SCCSID2(_s)
88#if 0 /* XXX userland __COPYRIGHTs have \ns in them */
89#define __COPYRIGHT(_s) __SECTIONSTRING(.copyright,_s)
90#else
91#define __COPYRIGHT(_s) \
92 static const char copyright[] \
93 __attribute__((__unused__,__section__(".copyright"))) = _s
94#endif
95
96#define __KERNEL_RCSID(_n, _s) __RCSID(_s)
97#define __KERNEL_SCCSID(_n, _s)
98#if 0 /* XXX see above */
99#define __KERNEL_COPYRIGHT(_n, _s) __COPYRIGHT(_s)
100#else
101#define __KERNEL_COPYRIGHT(_n, _s) __SECTIONSTRING(.copyright, _s)
102#endif
103
104#ifndef __lint__
105#define __link_set_make_entry(set, sym) \
106 static void const * const __link_set_##set##_sym_##sym \
107 __section("link_set_" #set) __used = &sym
108#define __link_set_make_entry2(set, sym, n) \
109 static void const * const __link_set_##set##_sym_##sym##_##n \
110 __section("link_set_" #set) __used = &sym[n]
111#else
112#define __link_set_make_entry(set, sym) \
113 extern void const * const __link_set_##set##_sym_##sym
114#define __link_set_make_entry2(set, sym, n) \
115 extern void const * const __link_set_##set##_sym_##sym##_##n
116#endif /* __lint__ */
117
118#define __link_set_add_text(set, sym) __link_set_make_entry(set, sym)
119#define __link_set_add_rodata(set, sym) __link_set_make_entry(set, sym)
120#define __link_set_add_data(set, sym) __link_set_make_entry(set, sym)
121#define __link_set_add_bss(set, sym) __link_set_make_entry(set, sym)
122#define __link_set_add_text2(set, sym, n) __link_set_make_entry2(set, sym, n)
123#define __link_set_add_rodata2(set, sym, n) __link_set_make_entry2(set, sym, n)
124#define __link_set_add_data2(set, sym, n) __link_set_make_entry2(set, sym, n)
125#define __link_set_add_bss2(set, sym, n) __link_set_make_entry2(set, sym, n)
126
127#define __link_set_decl(set, ptype) \
128 extern ptype * const __start_link_set_##set[]; \
129 extern ptype * const __stop_link_set_##set[] \
130
131#define __link_set_start(set) (__start_link_set_##set)
132#define __link_set_end(set) (__stop_link_set_##set)
133
134#define __link_set_count(set) \
135 (__link_set_end(set) - __link_set_start(set))
136
137#endif /* !_SYS_CDEFS_ELF_H_ */