1 // Copyright 2016 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // This file defines macros to handle the output of the shlib-symbols
6 // script (run without the -a switch).  These macros generate assembly
7 // code that should define symbols in a DSO such that the resultant DSO
8 // has the same ABI as the DSO input to shlib-symbols.
9 
10 #define FUNCTION(NAME, SIZE) FUNCTION_1(global, NAME)
11 #define WEAK_FUNCTION(NAME, SIZE) FUNCTION_1(weak, NAME)
12 
13 #define FUNCTION_1(BINDING, NAME) \
14     .pushsection .text,"ax",%progbits; \
15     .BINDING NAME; \
16     .type NAME,%function; \
17     NAME: .space 1; \
18     .popsection
19 
20 #define OBJECT_1(SECTION, SECFLAGS, SECTYPE, BINDING, NAME, SIZE) \
21     .pushsection SECTION,SECFLAGS,%SECTYPE; \
22     .BINDING NAME; \
23     .type NAME,%object; \
24     NAME: .space SIZE; \
25     .size NAME,SIZE; \
26     .popsection
27 
28 #define RODATA_OBJECT(NAME, SIZE) \
29     OBJECT_1(.rodata, "a", progbits, global, NAME, SIZE)
30 #define DATA_OBJECT(NAME, SIZE) \
31     OBJECT_1(.data, "aw", progbits, global, NAME, SIZE)
32 #define WEAK_DATA_OBJECT(NAME, SIZE) \
33     OBJECT_1(.data, "aw", progbits, weak, NAME, SIZE)
34 #define BSS_OBJECT(NAME, SIZE) \
35     OBJECT_1(.bss, "aw", nobits, global, NAME, SIZE)
36 
37 #define UNDEFINED_WEAK(NAME, SIZE) UNDEFINED_1(weak, NAME)
38 #define UNDEFINED(NAME, SIZE) UNDEFINED_1(globl, NAME)
39 #define UNDEFINED_1(BINDING, NAME) \
40     .pushsection .undefined,"aw",%progbits; \
41     .BINDING NAME; \
42     .dc.a NAME; \
43     .popsection
44