Regenerate AArch64 opcodes files
[binutils-gdb.git] / bfd / bfd-in.h
blob04e65aad5f0c235a5013513c545e57a01e96541f
1 /* Main header file for the bfd library -- portable access to object files.
3 Copyright (C) 1990-2024 Free Software Foundation, Inc.
5 Contributed by Cygnus Support.
7 This file is part of BFD, the Binary File Descriptor library.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
23 #ifndef __BFD_H_SEEN__
24 #define __BFD_H_SEEN__
26 /* PR 14072: Ensure that config.h is included first. */
27 #if !defined PACKAGE && !defined PACKAGE_VERSION
28 #error config.h must be included before this header
29 #endif
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
35 #include "ansidecl.h"
36 #include "symcat.h"
37 #include <stdint.h>
38 #include <stdbool.h>
39 #include <time.h>
40 #include "diagnostics.h"
41 #include <stdarg.h>
42 #include <string.h>
43 #include <sys/stat.h>
45 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
46 #ifndef SABER
47 /* This hack is to avoid a problem with some strict ANSI C preprocessors.
48 The problem is, "32_" is not a valid preprocessing token, and we don't
49 want extra underscores (e.g., "nlm_32_"). The XCONCAT2 macro will
50 cause the inner CONCAT2 macros to be evaluated first, producing
51 still-valid pp-tokens. Then the final concatenation can be done. */
52 #undef CONCAT4
53 #define CONCAT4(a,b,c,d) XCONCAT2(CONCAT2(a,b),CONCAT2(c,d))
54 #endif
55 #endif
57 /* This is a utility macro to handle the situation where the code
58 wants to place a constant string into the code, followed by a
59 comma and then the length of the string. Doing this by hand
60 is error prone, so using this macro is safer. */
61 #define STRING_COMMA_LEN(STR) (STR), (sizeof (STR) - 1)
63 #define BFD_SUPPORTS_PLUGINS @supports_plugins@
65 /* The word size used by BFD on the host. This may be 64 with a 32
66 bit target if the host is 64 bit, or if other 64 bit targets have
67 been selected with --enable-targets, or if --enable-64-bit-bfd. */
68 #define BFD_ARCH_SIZE @wordsize@
70 /* The word size of the default bfd target. */
71 #define BFD_DEFAULT_TARGET_SIZE @bfd_default_target_size@
73 #include <inttypes.h>
75 #if BFD_ARCH_SIZE >= 64
76 #define BFD64
77 #endif
79 /* Boolean type used in bfd.
80 General rule: Functions which are bfd_boolean return TRUE on
81 success and FALSE on failure (unless they're a predicate). */
83 #ifdef POISON_BFD_BOOLEAN
84 # pragma GCC poison bfd_boolean
85 #else
86 # define bfd_boolean bool
87 # undef FALSE
88 # undef TRUE
89 # define FALSE 0
90 # define TRUE 1
91 #endif
93 /* Silence "applying zero offset to null pointer" UBSAN warnings. */
94 #define PTR_ADD(P,A) ((A) != 0 ? (P) + (A) : (P))
95 /* Also prevent non-zero offsets from being applied to a null pointer. */
96 #define NPTR_ADD(P,A) ((P) != NULL ? (P) + (A) : (P))
98 #ifdef BFD64
100 /* Represent a target address. Also used as a generic unsigned type
101 which is guaranteed to be big enough to hold any arithmetic types
102 we need to deal with. */
103 typedef uint64_t bfd_vma;
105 /* A generic signed type which is guaranteed to be big enough to hold any
106 arithmetic types we need to deal with. Can be assumed to be compatible
107 with bfd_vma in the same way that signed and unsigned ints are compatible
108 (as parameters, in assignment, etc). */
109 typedef int64_t bfd_signed_vma;
111 typedef uint64_t bfd_size_type;
112 typedef uint64_t symvalue;
114 #else /* not BFD64 */
116 typedef uint32_t bfd_vma;
117 typedef int32_t bfd_signed_vma;
118 typedef uint32_t bfd_size_type;
119 typedef uint32_t symvalue;
121 #endif /* not BFD64 */
123 #define HALF_BFD_SIZE_TYPE \
124 (((bfd_size_type) 1) << (8 * sizeof (bfd_size_type) / 2))
126 /* An offset into a file. BFD always uses the largest possible offset
127 based on the build time availability of fseek, fseeko, or fseeko64. */
128 typedef @bfd_file_ptr@ file_ptr;
129 typedef @bfd_ufile_ptr@ ufile_ptr;
131 typedef uint32_t flagword; /* 32 bits of flags */
132 typedef uint8_t bfd_byte;
134 /* Forward declarations. */
135 typedef struct bfd bfd;
136 struct bfd_link_info;
137 struct bfd_link_hash_entry;
138 typedef struct bfd_section *sec_ptr;
139 typedef struct reloc_cache_entry arelent;
140 struct orl;
142 #define align_power(addr, align) \
143 (((addr) + ((bfd_vma) 1 << (align)) - 1) & (-((bfd_vma) 1 << (align))))
145 /* Align an address upward to a boundary, expressed as a number of bytes.
146 E.g. align to an 8-byte boundary with argument of 8. Take care never
147 to wrap around if the address is within boundary-1 of the end of the
148 address space. */
149 #define BFD_ALIGN(this, boundary) \
150 ((((bfd_vma) (this) + (boundary) - 1) >= (bfd_vma) (this)) \
151 ? (((bfd_vma) (this) + ((boundary) - 1)) & ~ (bfd_vma) ((boundary)-1)) \
152 : ~ (bfd_vma) 0)
154 /* Return TRUE if the start of STR matches PREFIX, FALSE otherwise. */
156 static inline bool
157 startswith (const char *str, const char *prefix)
159 return strncmp (str, prefix, strlen (prefix)) == 0;