libbfd-in.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958
  1. /* libbfd.h -- Declarations used by bfd library *implementation*.
  2. (This include file is not for users of the library.)
  3. Copyright (C) 1990-2022 Free Software Foundation, Inc.
  4. Written by Cygnus Support.
  5. This file is part of BFD, the Binary File Descriptor library.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 3 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  17. MA 02110-1301, USA. */
  18. #ifndef _LIBBFD_H
  19. #define _LIBBFD_H 1
  20. #ifndef ATTRIBUTE_HIDDEN
  21. #if HAVE_HIDDEN
  22. #define ATTRIBUTE_HIDDEN __attribute__ ((__visibility__ ("hidden")))
  23. #else
  24. #define ATTRIBUTE_HIDDEN
  25. #endif
  26. #endif
  27. #include "hashtab.h"
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /* If you want to read and write large blocks, you might want to do it
  32. in quanta of this amount */
  33. #define DEFAULT_BUFFERSIZE 8192
  34. /* Set a tdata field. Can't use the other macros for this, since they
  35. do casts, and casting to the left of assignment isn't portable. */
  36. #define set_tdata(bfd, v) ((bfd)->tdata.any = (v))
  37. /* If BFD_IN_MEMORY is set for a BFD, then the iostream fields points
  38. to an instance of this structure. */
  39. struct bfd_in_memory
  40. {
  41. /* Size of buffer. */
  42. bfd_size_type size;
  43. /* Buffer holding contents of BFD. */
  44. bfd_byte *buffer;
  45. };
  46. struct section_hash_entry
  47. {
  48. struct bfd_hash_entry root;
  49. asection section;
  50. };
  51. /* Unique section id. */
  52. extern unsigned int _bfd_section_id ATTRIBUTE_HIDDEN;
  53. /* tdata for an archive. For an input archive, cache
  54. needs to be free()'d. For an output archive, symdefs do. */
  55. struct artdata
  56. {
  57. file_ptr first_file_filepos;
  58. /* Speed up searching the armap */
  59. htab_t cache;
  60. bfd *archive_head; /* Only interesting in output routines. */
  61. carsym *symdefs; /* The symdef entries. */
  62. symindex symdef_count; /* How many there are. */
  63. char *extended_names; /* Clever intel extension. */
  64. bfd_size_type extended_names_size; /* Size of extended names. */
  65. /* When more compilers are standard C, this can be a time_t. */
  66. long armap_timestamp; /* Timestamp value written into armap.
  67. This is used for BSD archives to check
  68. that the timestamp is recent enough
  69. for the BSD linker to not complain,
  70. just before we finish writing an
  71. archive. */
  72. file_ptr armap_datepos; /* Position within archive to seek to
  73. rewrite the date field. */
  74. void *tdata; /* Backend specific information. */
  75. };
  76. #define bfd_ardata(bfd) ((bfd)->tdata.aout_ar_data)
  77. /* Goes in bfd's arelt_data slot */
  78. struct areltdata
  79. {
  80. char * arch_header; /* It's actually a string. */
  81. bfd_size_type parsed_size; /* Octets of filesize not including ar_hdr. */
  82. bfd_size_type extra_size; /* BSD4.4: extra bytes after the header. */
  83. char *filename; /* Null-terminated. */
  84. file_ptr origin; /* For element of a thin archive. */
  85. void *parent_cache; /* Where and how to find this member. */
  86. file_ptr key;
  87. };
  88. #define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size)
  89. extern void *bfd_malloc
  90. (bfd_size_type) ATTRIBUTE_HIDDEN;
  91. static inline char *
  92. bfd_strdup (const char *str)
  93. {
  94. size_t len = strlen (str) + 1;
  95. char *buf = bfd_malloc (len);
  96. if (buf != NULL)
  97. memcpy (buf, str, len);
  98. return buf;
  99. }
  100. /* These routines allocate and free things on the BFD's objalloc. */
  101. extern void bfd_release
  102. (bfd *, void *) ATTRIBUTE_HIDDEN;
  103. extern bfd * _bfd_create_empty_archive_element_shell
  104. (bfd *) ATTRIBUTE_HIDDEN;
  105. extern bfd * _bfd_look_for_bfd_in_cache
  106. (bfd *, file_ptr) ATTRIBUTE_HIDDEN;
  107. extern bool _bfd_add_bfd_to_archive_cache
  108. (bfd *, file_ptr, bfd *) ATTRIBUTE_HIDDEN;
  109. extern bool _bfd_generic_mkarchive
  110. (bfd *) ATTRIBUTE_HIDDEN;
  111. extern char *_bfd_append_relative_path
  112. (bfd *, char *) ATTRIBUTE_HIDDEN;
  113. extern bfd_cleanup bfd_generic_archive_p
  114. (bfd *) ATTRIBUTE_HIDDEN;
  115. extern bool bfd_slurp_armap
  116. (bfd *) ATTRIBUTE_HIDDEN;
  117. #define bfd_slurp_bsd_armap bfd_slurp_armap
  118. #define bfd_slurp_coff_armap bfd_slurp_armap
  119. extern bool _bfd_archive_64_bit_slurp_armap
  120. (bfd *) ATTRIBUTE_HIDDEN;
  121. extern bool _bfd_archive_64_bit_write_armap
  122. (bfd *, unsigned int, struct orl *, unsigned int, int) ATTRIBUTE_HIDDEN;
  123. #define _bfd_archive_64_bit_slurp_extended_name_table \
  124. _bfd_slurp_extended_name_table
  125. #define _bfd_archive_64_bit_construct_extended_name_table \
  126. _bfd_archive_coff_construct_extended_name_table
  127. #define _bfd_archive_64_bit_truncate_arname \
  128. bfd_dont_truncate_arname
  129. #define _bfd_archive_64_bit_read_ar_hdr \
  130. _bfd_generic_read_ar_hdr
  131. #define _bfd_archive_64_bit_write_ar_hdr \
  132. _bfd_generic_write_ar_hdr
  133. #define _bfd_archive_64_bit_openr_next_archived_file \
  134. bfd_generic_openr_next_archived_file
  135. #define _bfd_archive_64_bit_get_elt_at_index \
  136. _bfd_generic_get_elt_at_index
  137. #define _bfd_archive_64_bit_generic_stat_arch_elt \
  138. bfd_generic_stat_arch_elt
  139. #define _bfd_archive_64_bit_update_armap_timestamp _bfd_bool_bfd_true
  140. extern bool _bfd_slurp_extended_name_table
  141. (bfd *) ATTRIBUTE_HIDDEN;
  142. extern bool _bfd_construct_extended_name_table
  143. (bfd *, bool, char **, bfd_size_type *) ATTRIBUTE_HIDDEN;
  144. extern bool _bfd_write_archive_contents
  145. (bfd *) ATTRIBUTE_HIDDEN;
  146. extern bool _bfd_compute_and_write_armap
  147. (bfd *, unsigned int) ATTRIBUTE_HIDDEN;
  148. extern bfd *_bfd_get_elt_at_filepos
  149. (bfd *, file_ptr, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
  150. extern bfd *_bfd_generic_get_elt_at_index
  151. (bfd *, symindex) ATTRIBUTE_HIDDEN;
  152. extern bfd * _bfd_new_bfd
  153. (void) ATTRIBUTE_HIDDEN;
  154. extern bool _bfd_free_cached_info
  155. (bfd *) ATTRIBUTE_HIDDEN;
  156. extern bool _bfd_bool_bfd_false
  157. (bfd *) ATTRIBUTE_HIDDEN;
  158. extern bool _bfd_bool_bfd_asymbol_false
  159. (bfd *, asymbol *) ATTRIBUTE_HIDDEN;
  160. extern bool _bfd_bool_bfd_false_error
  161. (bfd *) ATTRIBUTE_HIDDEN;
  162. extern bool _bfd_bool_bfd_link_false_error
  163. (bfd *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
  164. extern bool _bfd_bool_bfd_true
  165. (bfd *) ATTRIBUTE_HIDDEN;
  166. extern bool _bfd_bool_bfd_link_true
  167. (bfd *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
  168. extern bool _bfd_bool_bfd_bfd_true
  169. (bfd *, bfd *) ATTRIBUTE_HIDDEN;
  170. extern bool _bfd_bool_bfd_uint_true
  171. (bfd *, unsigned int) ATTRIBUTE_HIDDEN;
  172. extern bool _bfd_bool_bfd_asection_bfd_asection_true
  173. (bfd *, asection *, bfd *, asection *) ATTRIBUTE_HIDDEN;
  174. extern bool _bfd_bool_bfd_asymbol_bfd_asymbol_true
  175. (bfd *, asymbol *, bfd *, asymbol *) ATTRIBUTE_HIDDEN;
  176. extern bool _bfd_bool_bfd_ptr_true
  177. (bfd *, void *) ATTRIBUTE_HIDDEN;
  178. extern void *_bfd_ptr_bfd_null_error
  179. (bfd *) ATTRIBUTE_HIDDEN;
  180. extern int _bfd_int_bfd_0
  181. (bfd *) ATTRIBUTE_HIDDEN;
  182. extern unsigned int _bfd_uint_bfd_0
  183. (bfd *) ATTRIBUTE_HIDDEN;
  184. extern long _bfd_long_bfd_0
  185. (bfd *) ATTRIBUTE_HIDDEN;
  186. extern long _bfd_long_bfd_n1_error
  187. (bfd *) ATTRIBUTE_HIDDEN;
  188. extern void _bfd_void_bfd
  189. (bfd *) ATTRIBUTE_HIDDEN;
  190. extern void _bfd_void_bfd_link
  191. (bfd *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
  192. extern void _bfd_void_bfd_asection
  193. (bfd *, asection *) ATTRIBUTE_HIDDEN;
  194. extern bfd *_bfd_new_bfd_contained_in
  195. (bfd *) ATTRIBUTE_HIDDEN;
  196. extern bfd_cleanup _bfd_dummy_target
  197. (bfd *) ATTRIBUTE_HIDDEN;
  198. #define _bfd_no_cleanup _bfd_void_bfd
  199. extern void bfd_dont_truncate_arname
  200. (bfd *, const char *, char *) ATTRIBUTE_HIDDEN;
  201. extern void bfd_bsd_truncate_arname
  202. (bfd *, const char *, char *) ATTRIBUTE_HIDDEN;
  203. extern void bfd_gnu_truncate_arname
  204. (bfd *, const char *, char *) ATTRIBUTE_HIDDEN;
  205. extern bool _bfd_bsd_write_armap
  206. (bfd *, unsigned int, struct orl *, unsigned int, int) ATTRIBUTE_HIDDEN;
  207. extern bool _bfd_coff_write_armap
  208. (bfd *, unsigned int, struct orl *, unsigned int, int) ATTRIBUTE_HIDDEN;
  209. extern void *_bfd_generic_read_ar_hdr
  210. (bfd *) ATTRIBUTE_HIDDEN;
  211. extern void _bfd_ar_spacepad
  212. (char *, size_t, const char *, long) ATTRIBUTE_HIDDEN;
  213. extern bool _bfd_ar_sizepad
  214. (char *, size_t, bfd_size_type) ATTRIBUTE_HIDDEN;
  215. extern void *_bfd_generic_read_ar_hdr_mag
  216. (bfd *, const char *) ATTRIBUTE_HIDDEN;
  217. extern bool _bfd_generic_write_ar_hdr
  218. (bfd *, bfd *) ATTRIBUTE_HIDDEN;
  219. extern bool _bfd_bsd44_write_ar_hdr
  220. (bfd *, bfd *) ATTRIBUTE_HIDDEN;
  221. extern bfd * bfd_generic_openr_next_archived_file
  222. (bfd *, bfd *) ATTRIBUTE_HIDDEN;
  223. extern int bfd_generic_stat_arch_elt
  224. (bfd *, struct stat *) ATTRIBUTE_HIDDEN;
  225. #define _bfd_read_ar_hdr(abfd) \
  226. BFD_SEND (abfd, _bfd_read_ar_hdr_fn, (abfd))
  227. #define _bfd_write_ar_hdr(archive, abfd) \
  228. BFD_SEND (abfd, _bfd_write_ar_hdr_fn, (archive, abfd))
  229. /* Generic routines to use for BFD_JUMP_TABLE_GENERIC. Use
  230. BFD_JUMP_TABLE_GENERIC (_bfd_generic). */
  231. #define _bfd_generic_close_and_cleanup _bfd_archive_close_and_cleanup
  232. extern bool _bfd_archive_close_and_cleanup
  233. (bfd *) ATTRIBUTE_HIDDEN;
  234. extern void _bfd_unlink_from_archive_parent (bfd *) ATTRIBUTE_HIDDEN;
  235. #define _bfd_generic_bfd_free_cached_info _bfd_bool_bfd_true
  236. extern bool _bfd_generic_new_section_hook
  237. (bfd *, asection *) ATTRIBUTE_HIDDEN;
  238. extern bool _bfd_generic_get_section_contents
  239. (bfd *, asection *, void *, file_ptr, bfd_size_type) ATTRIBUTE_HIDDEN;
  240. extern bool _bfd_generic_get_section_contents_in_window
  241. (bfd *, asection *, bfd_window *, file_ptr, bfd_size_type) ATTRIBUTE_HIDDEN;
  242. /* Generic routines to use for BFD_JUMP_TABLE_COPY. Use
  243. BFD_JUMP_TABLE_COPY (_bfd_generic). */
  244. #define _bfd_generic_bfd_copy_private_bfd_data _bfd_bool_bfd_bfd_true
  245. #define _bfd_generic_bfd_merge_private_bfd_data \
  246. _bfd_bool_bfd_link_true
  247. #define _bfd_generic_bfd_set_private_flags _bfd_bool_bfd_uint_true
  248. #define _bfd_generic_bfd_copy_private_section_data \
  249. _bfd_bool_bfd_asection_bfd_asection_true
  250. #define _bfd_generic_bfd_copy_private_symbol_data \
  251. _bfd_bool_bfd_asymbol_bfd_asymbol_true
  252. #define _bfd_generic_bfd_copy_private_header_data _bfd_bool_bfd_bfd_true
  253. #define _bfd_generic_bfd_print_private_bfd_data _bfd_bool_bfd_ptr_true
  254. extern bool _bfd_generic_init_private_section_data
  255. (bfd *, asection *, bfd *, asection *, struct bfd_link_info *)
  256. ATTRIBUTE_HIDDEN;
  257. /* Routines to use for BFD_JUMP_TABLE_CORE when there is no core file
  258. support. Use BFD_JUMP_TABLE_CORE (_bfd_nocore). */
  259. extern char *_bfd_nocore_core_file_failing_command
  260. (bfd *) ATTRIBUTE_HIDDEN;
  261. extern int _bfd_nocore_core_file_failing_signal
  262. (bfd *) ATTRIBUTE_HIDDEN;
  263. extern bool _bfd_nocore_core_file_matches_executable_p
  264. (bfd *, bfd *) ATTRIBUTE_HIDDEN;
  265. extern int _bfd_nocore_core_file_pid
  266. (bfd *) ATTRIBUTE_HIDDEN;
  267. /* Routines to use for BFD_JUMP_TABLE_ARCHIVE when there is no archive
  268. file support. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive). */
  269. #define _bfd_noarchive_slurp_armap _bfd_bool_bfd_false_error
  270. #define _bfd_noarchive_slurp_extended_name_table _bfd_bool_bfd_false_error
  271. extern bool _bfd_noarchive_construct_extended_name_table
  272. (bfd *, char **, bfd_size_type *, const char **) ATTRIBUTE_HIDDEN;
  273. extern void _bfd_noarchive_truncate_arname
  274. (bfd *, const char *, char *) ATTRIBUTE_HIDDEN;
  275. extern bool _bfd_noarchive_write_armap
  276. (bfd *, unsigned int, struct orl *, unsigned int, int) ATTRIBUTE_HIDDEN;
  277. #define _bfd_noarchive_read_ar_hdr _bfd_ptr_bfd_null_error
  278. extern bool _bfd_noarchive_write_ar_hdr
  279. (bfd *, bfd *) ATTRIBUTE_HIDDEN;
  280. extern bfd *
  281. _bfd_noarchive_openr_next_archived_file
  282. (bfd *, bfd *) ATTRIBUTE_HIDDEN;
  283. extern bfd * _bfd_noarchive_get_elt_at_index
  284. (bfd *, symindex) ATTRIBUTE_HIDDEN;
  285. #define _bfd_noarchive_generic_stat_arch_elt bfd_generic_stat_arch_elt
  286. #define _bfd_noarchive_update_armap_timestamp _bfd_bool_bfd_false_error
  287. /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get BSD style
  288. archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd). */
  289. #define _bfd_archive_bsd_slurp_armap bfd_slurp_bsd_armap
  290. #define _bfd_archive_bsd_slurp_extended_name_table \
  291. _bfd_slurp_extended_name_table
  292. extern bool _bfd_archive_bsd_construct_extended_name_table
  293. (bfd *, char **, bfd_size_type *, const char **) ATTRIBUTE_HIDDEN;
  294. #define _bfd_archive_bsd_truncate_arname bfd_bsd_truncate_arname
  295. #define _bfd_archive_bsd_write_armap _bfd_bsd_write_armap
  296. #define _bfd_archive_bsd_read_ar_hdr _bfd_generic_read_ar_hdr
  297. #define _bfd_archive_bsd_write_ar_hdr _bfd_generic_write_ar_hdr
  298. #define _bfd_archive_bsd_openr_next_archived_file \
  299. bfd_generic_openr_next_archived_file
  300. #define _bfd_archive_bsd_get_elt_at_index _bfd_generic_get_elt_at_index
  301. #define _bfd_archive_bsd_generic_stat_arch_elt \
  302. bfd_generic_stat_arch_elt
  303. extern bool _bfd_archive_bsd_update_armap_timestamp
  304. (bfd *) ATTRIBUTE_HIDDEN;
  305. /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get COFF style
  306. archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff). */
  307. #define _bfd_archive_coff_slurp_armap bfd_slurp_coff_armap
  308. #define _bfd_archive_coff_slurp_extended_name_table \
  309. _bfd_slurp_extended_name_table
  310. extern bool _bfd_archive_coff_construct_extended_name_table
  311. (bfd *, char **, bfd_size_type *, const char **) ATTRIBUTE_HIDDEN;
  312. #define _bfd_archive_coff_truncate_arname bfd_dont_truncate_arname
  313. #define _bfd_archive_coff_write_armap _bfd_coff_write_armap
  314. #define _bfd_archive_coff_read_ar_hdr _bfd_generic_read_ar_hdr
  315. #define _bfd_archive_coff_write_ar_hdr _bfd_generic_write_ar_hdr
  316. #define _bfd_archive_coff_openr_next_archived_file \
  317. bfd_generic_openr_next_archived_file
  318. #define _bfd_archive_coff_get_elt_at_index _bfd_generic_get_elt_at_index
  319. #define _bfd_archive_coff_generic_stat_arch_elt \
  320. bfd_generic_stat_arch_elt
  321. #define _bfd_archive_coff_update_armap_timestamp _bfd_bool_bfd_true
  322. /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get BSD4.4 style
  323. archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd44). */
  324. #define _bfd_archive_bsd44_slurp_armap bfd_slurp_bsd_armap
  325. #define _bfd_archive_bsd44_slurp_extended_name_table \
  326. _bfd_slurp_extended_name_table
  327. extern bool _bfd_archive_bsd44_construct_extended_name_table
  328. (bfd *, char **, bfd_size_type *, const char **) ATTRIBUTE_HIDDEN;
  329. #define _bfd_archive_bsd44_truncate_arname bfd_bsd_truncate_arname
  330. #define _bfd_archive_bsd44_write_armap _bfd_bsd_write_armap
  331. #define _bfd_archive_bsd44_read_ar_hdr _bfd_generic_read_ar_hdr
  332. #define _bfd_archive_bsd44_write_ar_hdr _bfd_bsd44_write_ar_hdr
  333. #define _bfd_archive_bsd44_openr_next_archived_file \
  334. bfd_generic_openr_next_archived_file
  335. #define _bfd_archive_bsd44_get_elt_at_index _bfd_generic_get_elt_at_index
  336. #define _bfd_archive_bsd44_generic_stat_arch_elt \
  337. bfd_generic_stat_arch_elt
  338. #define _bfd_archive_bsd44_update_armap_timestamp \
  339. _bfd_archive_bsd_update_armap_timestamp
  340. /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get VMS style
  341. archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib). Some of them
  342. are irrelevant. */
  343. extern bool _bfd_vms_lib_write_archive_contents
  344. (bfd *) ATTRIBUTE_HIDDEN;
  345. #define _bfd_vms_lib_slurp_armap _bfd_noarchive_slurp_armap
  346. #define _bfd_vms_lib_slurp_extended_name_table \
  347. _bfd_noarchive_slurp_extended_name_table
  348. #define _bfd_vms_lib_construct_extended_name_table \
  349. _bfd_noarchive_construct_extended_name_table
  350. #define _bfd_vms_lib_truncate_arname _bfd_noarchive_truncate_arname
  351. #define _bfd_vms_lib_write_armap _bfd_noarchive_write_armap
  352. #define _bfd_vms_lib_read_ar_hdr _bfd_noarchive_read_ar_hdr
  353. #define _bfd_vms_lib_write_ar_hdr _bfd_noarchive_write_ar_hdr
  354. extern bfd *_bfd_vms_lib_openr_next_archived_file
  355. (bfd *, bfd *) ATTRIBUTE_HIDDEN;
  356. extern bfd *_bfd_vms_lib_get_elt_at_index
  357. (bfd *, symindex) ATTRIBUTE_HIDDEN;
  358. extern int _bfd_vms_lib_generic_stat_arch_elt
  359. (bfd *, struct stat *) ATTRIBUTE_HIDDEN;
  360. #define _bfd_vms_lib_update_armap_timestamp _bfd_bool_bfd_true
  361. /* Extra routines for VMS style archives. */
  362. extern symindex _bfd_vms_lib_find_symbol
  363. (bfd *, const char *) ATTRIBUTE_HIDDEN;
  364. extern bfd *_bfd_vms_lib_get_imagelib_file
  365. (bfd *) ATTRIBUTE_HIDDEN;
  366. extern bfd_cleanup _bfd_vms_lib_alpha_archive_p
  367. (bfd *) ATTRIBUTE_HIDDEN;
  368. extern bfd_cleanup _bfd_vms_lib_ia64_archive_p
  369. (bfd *) ATTRIBUTE_HIDDEN;
  370. extern bool _bfd_vms_lib_alpha_mkarchive
  371. (bfd *) ATTRIBUTE_HIDDEN;
  372. extern bool _bfd_vms_lib_ia64_mkarchive
  373. (bfd *) ATTRIBUTE_HIDDEN;
  374. /* Routines to use for BFD_JUMP_TABLE_SYMBOLS where there is no symbol
  375. support. Use BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols). */
  376. #define _bfd_nosymbols_get_symtab_upper_bound _bfd_long_bfd_n1_error
  377. extern long _bfd_nosymbols_canonicalize_symtab
  378. (bfd *, asymbol **) ATTRIBUTE_HIDDEN;
  379. #define _bfd_nosymbols_make_empty_symbol _bfd_generic_make_empty_symbol
  380. extern void _bfd_nosymbols_print_symbol
  381. (bfd *, void *, asymbol *, bfd_print_symbol_type) ATTRIBUTE_HIDDEN;
  382. extern void _bfd_nosymbols_get_symbol_info
  383. (bfd *, asymbol *, symbol_info *) ATTRIBUTE_HIDDEN;
  384. extern const char * _bfd_nosymbols_get_symbol_version_string
  385. (bfd *, asymbol *, bool, bool *) ATTRIBUTE_HIDDEN;
  386. extern bool _bfd_nosymbols_bfd_is_local_label_name
  387. (bfd *, const char *) ATTRIBUTE_HIDDEN;
  388. #define _bfd_nosymbols_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
  389. extern alent *_bfd_nosymbols_get_lineno
  390. (bfd *, asymbol *) ATTRIBUTE_HIDDEN;
  391. extern bool _bfd_nosymbols_find_nearest_line
  392. (bfd *, asymbol **, asection *, bfd_vma,
  393. const char **, const char **, unsigned int *, unsigned int *)
  394. ATTRIBUTE_HIDDEN;
  395. extern bool _bfd_nosymbols_find_line
  396. (bfd *, asymbol **, asymbol *, const char **, unsigned int *)
  397. ATTRIBUTE_HIDDEN;
  398. extern bool _bfd_nosymbols_find_inliner_info
  399. (bfd *, const char **, const char **, unsigned int *) ATTRIBUTE_HIDDEN;
  400. extern asymbol *_bfd_nosymbols_bfd_make_debug_symbol
  401. (bfd *, void *, unsigned long) ATTRIBUTE_HIDDEN;
  402. extern long _bfd_nosymbols_read_minisymbols
  403. (bfd *, bool, void **, unsigned int *) ATTRIBUTE_HIDDEN;
  404. extern asymbol *_bfd_nosymbols_minisymbol_to_symbol
  405. (bfd *, bool, const void *, asymbol *) ATTRIBUTE_HIDDEN;
  406. /* Routines to use for BFD_JUMP_TABLE_RELOCS when there is no reloc
  407. support. Use BFD_JUMP_TABLE_RELOCS (_bfd_norelocs). */
  408. extern long _bfd_norelocs_get_reloc_upper_bound
  409. (bfd *, asection *) ATTRIBUTE_HIDDEN;
  410. extern long _bfd_norelocs_canonicalize_reloc
  411. (bfd *, asection *, arelent **, asymbol **) ATTRIBUTE_HIDDEN;
  412. extern void _bfd_norelocs_set_reloc
  413. (bfd *, asection *, arelent **, unsigned int) ATTRIBUTE_HIDDEN;
  414. extern reloc_howto_type *_bfd_norelocs_bfd_reloc_type_lookup
  415. (bfd *, bfd_reloc_code_real_type) ATTRIBUTE_HIDDEN;
  416. extern reloc_howto_type *_bfd_norelocs_bfd_reloc_name_lookup
  417. (bfd *, const char *) ATTRIBUTE_HIDDEN;
  418. /* Routines to use for BFD_JUMP_TABLE_WRITE for targets which may not
  419. be written. Use BFD_JUMP_TABLE_WRITE (_bfd_nowrite). */
  420. extern bool _bfd_nowrite_set_arch_mach
  421. (bfd *, enum bfd_architecture, unsigned long) ATTRIBUTE_HIDDEN;
  422. extern bool _bfd_nowrite_set_section_contents
  423. (bfd *, asection *, const void *, file_ptr, bfd_size_type) ATTRIBUTE_HIDDEN;
  424. /* Generic routines to use for BFD_JUMP_TABLE_WRITE. Use
  425. BFD_JUMP_TABLE_WRITE (_bfd_generic). */
  426. #define _bfd_generic_set_arch_mach bfd_default_set_arch_mach
  427. extern bool _bfd_generic_set_section_contents
  428. (bfd *, asection *, const void *, file_ptr, bfd_size_type) ATTRIBUTE_HIDDEN;
  429. /* Routines to use for BFD_JUMP_TABLE_LINK for targets which do not
  430. support linking. Use BFD_JUMP_TABLE_LINK (_bfd_nolink). */
  431. extern int _bfd_nolink_sizeof_headers
  432. (bfd *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
  433. extern bfd_byte *_bfd_nolink_bfd_get_relocated_section_contents
  434. (bfd *, struct bfd_link_info *, struct bfd_link_order *,
  435. bfd_byte *, bool, asymbol **) ATTRIBUTE_HIDDEN;
  436. extern bool _bfd_nolink_bfd_relax_section
  437. (bfd *, asection *, struct bfd_link_info *, bool *) ATTRIBUTE_HIDDEN;
  438. #define _bfd_nolink_bfd_gc_sections _bfd_bool_bfd_link_false_error
  439. extern bool _bfd_nolink_bfd_lookup_section_flags
  440. (struct bfd_link_info *, struct flag_info *, asection *) ATTRIBUTE_HIDDEN;
  441. #define _bfd_nolink_bfd_merge_sections _bfd_bool_bfd_link_false_error
  442. extern bool _bfd_nolink_bfd_is_group_section
  443. (bfd *, const asection *) ATTRIBUTE_HIDDEN;
  444. extern const char *_bfd_nolink_bfd_group_name
  445. (bfd *, const asection *) ATTRIBUTE_HIDDEN;
  446. extern bool _bfd_nolink_bfd_discard_group
  447. (bfd *, asection *) ATTRIBUTE_HIDDEN;
  448. extern struct bfd_link_hash_table *_bfd_nolink_bfd_link_hash_table_create
  449. (bfd *) ATTRIBUTE_HIDDEN;
  450. #define _bfd_nolink_bfd_link_add_symbols _bfd_bool_bfd_link_false_error
  451. extern void _bfd_nolink_bfd_link_just_syms
  452. (asection *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
  453. extern void _bfd_nolink_bfd_copy_link_hash_symbol_type
  454. (bfd *, struct bfd_link_hash_entry *, struct bfd_link_hash_entry *)
  455. ATTRIBUTE_HIDDEN;
  456. #define _bfd_nolink_bfd_final_link _bfd_bool_bfd_link_false_error
  457. extern bool _bfd_nolink_bfd_link_split_section
  458. (bfd *, struct bfd_section *) ATTRIBUTE_HIDDEN;
  459. extern bool _bfd_nolink_section_already_linked
  460. (bfd *, asection *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
  461. extern bool _bfd_nolink_bfd_define_common_symbol
  462. (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *)
  463. ATTRIBUTE_HIDDEN;
  464. #define _bfd_nolink_bfd_link_hide_symbol \
  465. _bfd_generic_link_hide_symbol
  466. extern struct bfd_link_hash_entry *_bfd_nolink_bfd_define_start_stop
  467. (struct bfd_link_info *, const char *, asection *) ATTRIBUTE_HIDDEN;
  468. #define _bfd_nolink_bfd_link_check_relocs \
  469. _bfd_generic_link_check_relocs
  470. /* Routines to use for BFD_JUMP_TABLE_DYNAMIC for targets which do not
  471. have dynamic symbols or relocs. Use BFD_JUMP_TABLE_DYNAMIC
  472. (_bfd_nodynamic). */
  473. #define _bfd_nodynamic_get_dynamic_symtab_upper_bound _bfd_long_bfd_n1_error
  474. #define _bfd_nodynamic_canonicalize_dynamic_symtab \
  475. _bfd_nosymbols_canonicalize_symtab
  476. extern long _bfd_nodynamic_get_synthetic_symtab
  477. (bfd *, long, asymbol **, long, asymbol **, asymbol **) ATTRIBUTE_HIDDEN;
  478. #define _bfd_nodynamic_get_dynamic_reloc_upper_bound _bfd_long_bfd_n1_error
  479. extern long _bfd_nodynamic_canonicalize_dynamic_reloc
  480. (bfd *, arelent **, asymbol **) ATTRIBUTE_HIDDEN;
  481. /* Generic routine to determine of the given symbol is a local
  482. label. */
  483. extern bool bfd_generic_is_local_label_name
  484. (bfd *, const char *) ATTRIBUTE_HIDDEN;
  485. /* Generic minisymbol routines. */
  486. extern long _bfd_generic_read_minisymbols
  487. (bfd *, bool, void **, unsigned int *) ATTRIBUTE_HIDDEN;
  488. extern asymbol *_bfd_generic_minisymbol_to_symbol
  489. (bfd *, bool, const void *, asymbol *) ATTRIBUTE_HIDDEN;
  490. /* Find the nearest line using .stab/.stabstr sections. */
  491. extern bool _bfd_stab_section_find_nearest_line
  492. (bfd *, asymbol **, asection *, bfd_vma, bool *,
  493. const char **, const char **, unsigned int *, void **) ATTRIBUTE_HIDDEN;
  494. /* Find the nearest line using DWARF 1 debugging information. */
  495. extern bool _bfd_dwarf1_find_nearest_line
  496. (bfd *, asymbol **, asection *, bfd_vma,
  497. const char **, const char **, unsigned int *) ATTRIBUTE_HIDDEN;
  498. struct dwarf_debug_section
  499. {
  500. const char * uncompressed_name;
  501. const char * compressed_name;
  502. };
  503. /* Map of uncompressed DWARF debug section name to compressed one. It
  504. is terminated by NULL uncompressed_name. */
  505. extern const struct dwarf_debug_section dwarf_debug_sections[] ATTRIBUTE_HIDDEN;
  506. /* Find the nearest line using DWARF 2 debugging information. */
  507. extern int _bfd_dwarf2_find_nearest_line
  508. (bfd *, asymbol **, asymbol *, asection *, bfd_vma,
  509. const char **, const char **, unsigned int *, unsigned int *,
  510. const struct dwarf_debug_section *, void **) ATTRIBUTE_HIDDEN;
  511. /* Find the bias between DWARF addresses and real addresses. */
  512. extern bfd_signed_vma _bfd_dwarf2_find_symbol_bias
  513. (asymbol **, void **) ATTRIBUTE_HIDDEN;
  514. /* Find inliner info after calling bfd_find_nearest_line. */
  515. extern bool _bfd_dwarf2_find_inliner_info
  516. (bfd *, const char **, const char **, unsigned int *, void **)
  517. ATTRIBUTE_HIDDEN;
  518. /* Read DWARF 2 debugging information. */
  519. extern bool _bfd_dwarf2_slurp_debug_info
  520. (bfd *, bfd *, const struct dwarf_debug_section *, asymbol **, void **,
  521. bool) ATTRIBUTE_HIDDEN;
  522. /* Clean up the data used to handle DWARF 2 debugging information. */
  523. extern void _bfd_dwarf2_cleanup_debug_info
  524. (bfd *, void **) ATTRIBUTE_HIDDEN;
  525. /* Create a new section entry. */
  526. extern struct bfd_hash_entry *bfd_section_hash_newfunc
  527. (struct bfd_hash_entry *, struct bfd_hash_table *, const char *)
  528. ATTRIBUTE_HIDDEN;
  529. /* A routine to create entries for a bfd_link_hash_table. */
  530. extern struct bfd_hash_entry *_bfd_link_hash_newfunc
  531. (struct bfd_hash_entry *entry, struct bfd_hash_table *table,
  532. const char *string) ATTRIBUTE_HIDDEN;
  533. /* Initialize a bfd_link_hash_table. */
  534. extern bool _bfd_link_hash_table_init
  535. (struct bfd_link_hash_table *, bfd *,
  536. struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
  537. struct bfd_hash_table *,
  538. const char *),
  539. unsigned int) ATTRIBUTE_HIDDEN;
  540. /* Generic link hash table creation routine. */
  541. extern struct bfd_link_hash_table *_bfd_generic_link_hash_table_create
  542. (bfd *) ATTRIBUTE_HIDDEN;
  543. /* Generic link hash table destruction routine. */
  544. extern void _bfd_generic_link_hash_table_free
  545. (bfd *) ATTRIBUTE_HIDDEN;
  546. /* Generic add symbol routine. */
  547. extern bool _bfd_generic_link_add_symbols
  548. (bfd *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
  549. /* Generic archive add symbol routine. */
  550. extern bool _bfd_generic_link_add_archive_symbols
  551. (bfd *, struct bfd_link_info *,
  552. bool (*) (bfd *, struct bfd_link_info *,
  553. struct bfd_link_hash_entry *, const char *,
  554. bool *)) ATTRIBUTE_HIDDEN;
  555. /* Forward declaration to avoid prototype errors. */
  556. typedef struct bfd_link_hash_entry _bfd_link_hash_entry;
  557. /* Generic routine to add a single symbol. */
  558. extern bool _bfd_generic_link_add_one_symbol
  559. (struct bfd_link_info *, bfd *, const char *name, flagword,
  560. asection *, bfd_vma, const char *, bool copy,
  561. bool constructor, struct bfd_link_hash_entry **) ATTRIBUTE_HIDDEN;
  562. /* Generic routine to mark section as supplying symbols only. */
  563. extern void _bfd_generic_link_just_syms
  564. (asection *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
  565. /* Generic routine that does nothing. */
  566. extern void _bfd_generic_copy_link_hash_symbol_type
  567. (bfd *, struct bfd_link_hash_entry *, struct bfd_link_hash_entry *)
  568. ATTRIBUTE_HIDDEN;
  569. /* Generic link routine. */
  570. extern bool _bfd_generic_final_link
  571. (bfd *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
  572. extern bool _bfd_generic_link_split_section
  573. (bfd *, struct bfd_section *) ATTRIBUTE_HIDDEN;
  574. extern bool _bfd_generic_section_already_linked
  575. (bfd *, asection *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
  576. /* Generic reloc_link_order processing routine. */
  577. extern bool _bfd_generic_reloc_link_order
  578. (bfd *, struct bfd_link_info *, asection *, struct bfd_link_order *)
  579. ATTRIBUTE_HIDDEN;
  580. /* Default link order processing routine. */
  581. extern bool _bfd_default_link_order
  582. (bfd *, struct bfd_link_info *, asection *, struct bfd_link_order *)
  583. ATTRIBUTE_HIDDEN;
  584. /* Count the number of reloc entries in a link order list. */
  585. extern unsigned int _bfd_count_link_order_relocs
  586. (struct bfd_link_order *) ATTRIBUTE_HIDDEN;
  587. /* Final link relocation routine. */
  588. extern bfd_reloc_status_type _bfd_final_link_relocate
  589. (reloc_howto_type *, bfd *, asection *, bfd_byte *,
  590. bfd_vma, bfd_vma, bfd_vma) ATTRIBUTE_HIDDEN;
  591. /* Relocate a particular location by a howto and a value. */
  592. extern bfd_reloc_status_type _bfd_relocate_contents
  593. (reloc_howto_type *, bfd *, bfd_vma, bfd_byte *) ATTRIBUTE_HIDDEN;
  594. /* Clear a given location using a given howto. */
  595. extern bfd_reloc_status_type _bfd_clear_contents
  596. (reloc_howto_type *, bfd *, asection *, bfd_byte *, bfd_vma) ATTRIBUTE_HIDDEN;
  597. /* Link stabs in sections in the first pass. */
  598. extern bool _bfd_link_section_stabs
  599. (bfd *, struct stab_info *, asection *, asection *, void **,
  600. bfd_size_type *) ATTRIBUTE_HIDDEN;
  601. /* Eliminate stabs for discarded functions and symbols. */
  602. extern bool _bfd_discard_section_stabs
  603. (bfd *, asection *, void *, bool (*) (bfd_vma, void *), void *)
  604. ATTRIBUTE_HIDDEN;
  605. /* Write out the .stab section when linking stabs in sections. */
  606. extern bool _bfd_write_section_stabs
  607. (bfd *, struct stab_info *, asection *, void **, bfd_byte *)
  608. ATTRIBUTE_HIDDEN;
  609. /* Write out the .stabstr string table when linking stabs in sections. */
  610. extern bool _bfd_write_stab_strings
  611. (bfd *, struct stab_info *) ATTRIBUTE_HIDDEN;
  612. /* Find an offset within a .stab section when linking stabs in
  613. sections. */
  614. extern bfd_vma _bfd_stab_section_offset
  615. (asection *, void *, bfd_vma) ATTRIBUTE_HIDDEN;
  616. /* Register a SEC_MERGE section as a candidate for merging. */
  617. extern bool _bfd_add_merge_section
  618. (bfd *, void **, asection *, void **) ATTRIBUTE_HIDDEN;
  619. /* Attempt to merge SEC_MERGE sections. */
  620. extern bool _bfd_merge_sections
  621. (bfd *, struct bfd_link_info *, void *, void (*) (bfd *, asection *))
  622. ATTRIBUTE_HIDDEN;
  623. /* Write out a merged section. */
  624. extern bool _bfd_write_merged_section
  625. (bfd *, asection *, void *) ATTRIBUTE_HIDDEN;
  626. /* Find an offset within a modified SEC_MERGE section. */
  627. extern bfd_vma _bfd_merged_section_offset
  628. (bfd *, asection **, void *, bfd_vma) ATTRIBUTE_HIDDEN;
  629. /* Tidy up when done. */
  630. extern void _bfd_merge_sections_free (void *) ATTRIBUTE_HIDDEN;
  631. /* Create a string table. */
  632. extern struct bfd_strtab_hash *_bfd_stringtab_init
  633. (void) ATTRIBUTE_HIDDEN;
  634. /* Create an XCOFF .debug section style string table. */
  635. extern struct bfd_strtab_hash *_bfd_xcoff_stringtab_init
  636. (bool isxcoff64) ATTRIBUTE_HIDDEN;
  637. /* Free a string table. */
  638. extern void _bfd_stringtab_free
  639. (struct bfd_strtab_hash *) ATTRIBUTE_HIDDEN;
  640. /* Get the size of a string table. */
  641. extern bfd_size_type _bfd_stringtab_size
  642. (struct bfd_strtab_hash *) ATTRIBUTE_HIDDEN;
  643. /* Add a string to a string table. */
  644. extern bfd_size_type _bfd_stringtab_add
  645. (struct bfd_strtab_hash *, const char *, bool hash, bool copy)
  646. ATTRIBUTE_HIDDEN;
  647. /* Write out a string table. */
  648. extern bool _bfd_stringtab_emit
  649. (bfd *, struct bfd_strtab_hash *) ATTRIBUTE_HIDDEN;
  650. /* Macros to tell if bfds are read or write enabled.
  651. Note that bfds open for read may be scribbled into if the fd passed
  652. to bfd_fdopenr is actually open both for read and write
  653. simultaneously. However an output bfd will never be open for
  654. read. Therefore sometimes you want to check bfd_read_p or
  655. !bfd_read_p, and only sometimes bfd_write_p.
  656. */
  657. #define bfd_read_p(abfd) \
  658. ((abfd)->direction == read_direction || (abfd)->direction == both_direction)
  659. #define bfd_write_p(abfd) \
  660. ((abfd)->direction == write_direction || (abfd)->direction == both_direction)
  661. extern void bfd_assert
  662. (const char*,int) ATTRIBUTE_HIDDEN;
  663. #define BFD_ASSERT(x) \
  664. do { if (!(x)) bfd_assert(__FILE__,__LINE__); } while (0)
  665. #define BFD_FAIL() \
  666. do { bfd_assert(__FILE__,__LINE__); } while (0)
  667. extern void _bfd_abort
  668. (const char *, int, const char *) ATTRIBUTE_NORETURN ATTRIBUTE_HIDDEN;
  669. /* if gcc >= 2.6, we can give a function name, too */
  670. #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6)
  671. #define __PRETTY_FUNCTION__ ((char *) NULL)
  672. #endif
  673. #undef abort
  674. #define abort() _bfd_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__)
  675. /* Manipulate a system FILE but using BFD's "file_ptr", rather than
  676. the system "off_t" or "off64_t", as the offset. */
  677. extern file_ptr _bfd_real_ftell
  678. (FILE *) ATTRIBUTE_HIDDEN;
  679. extern int _bfd_real_fseek
  680. (FILE *, file_ptr, int) ATTRIBUTE_HIDDEN;
  681. extern FILE *_bfd_real_fopen
  682. (const char *, const char *) ATTRIBUTE_HIDDEN;
  683. /* List of supported target vectors, and the default vector (if
  684. bfd_default_vector[0] is NULL, there is no default). */
  685. extern const bfd_target *const *const bfd_target_vector ATTRIBUTE_HIDDEN;
  686. extern const bfd_target *bfd_default_vector[] ATTRIBUTE_HIDDEN;
  687. /* List of associated target vectors. */
  688. extern const bfd_target *const *const bfd_associated_vector ATTRIBUTE_HIDDEN;
  689. /* Functions shared by the ECOFF and MIPS ELF backends, which have no
  690. other common header files. */
  691. #if defined(__STDC__) || defined(ALMOST_STDC)
  692. struct ecoff_find_line;
  693. #endif
  694. extern bool _bfd_ecoff_locate_line
  695. (bfd *, asection *, bfd_vma, struct ecoff_debug_info * const,
  696. const struct ecoff_debug_swap * const, struct ecoff_find_line *,
  697. const char **, const char **, unsigned int *) ATTRIBUTE_HIDDEN;
  698. extern bool _bfd_ecoff_get_accumulated_pdr
  699. (void *, bfd_byte *) ATTRIBUTE_HIDDEN;
  700. extern bool _bfd_ecoff_get_accumulated_sym
  701. (void *, bfd_byte *) ATTRIBUTE_HIDDEN;
  702. extern bool _bfd_ecoff_get_accumulated_ss
  703. (void *, bfd_byte *) ATTRIBUTE_HIDDEN;
  704. extern bfd_vma _bfd_get_gp_value
  705. (bfd *) ATTRIBUTE_HIDDEN;
  706. extern void _bfd_set_gp_value
  707. (bfd *, bfd_vma) ATTRIBUTE_HIDDEN;
  708. /* Function shared by the COFF and ELF SH backends, which have no
  709. other common header files. */
  710. #ifndef _bfd_sh_align_load_span
  711. extern bool _bfd_sh_align_load_span
  712. (bfd *, asection *, bfd_byte *,
  713. bool (*) (bfd *, asection *, void *, bfd_byte *, bfd_vma),
  714. void *, bfd_vma **, bfd_vma *, bfd_vma, bfd_vma, bool *) ATTRIBUTE_HIDDEN;
  715. #endif
  716. /* This is the shape of the elements inside the already_linked hash
  717. table. It maps a name onto a list of already_linked elements with
  718. the same name. */
  719. struct bfd_section_already_linked_hash_entry
  720. {
  721. struct bfd_hash_entry root;
  722. struct bfd_section_already_linked *entry;
  723. };
  724. struct bfd_section_already_linked
  725. {
  726. struct bfd_section_already_linked *next;
  727. asection *sec;
  728. };
  729. extern struct bfd_section_already_linked_hash_entry *
  730. bfd_section_already_linked_table_lookup (const char *) ATTRIBUTE_HIDDEN;
  731. extern bool bfd_section_already_linked_table_insert
  732. (struct bfd_section_already_linked_hash_entry *, asection *)
  733. ATTRIBUTE_HIDDEN;
  734. extern void bfd_section_already_linked_table_traverse
  735. (bool (*) (struct bfd_section_already_linked_hash_entry *,
  736. void *), void *) ATTRIBUTE_HIDDEN;
  737. extern bfd_vma _bfd_read_unsigned_leb128
  738. (bfd *, bfd_byte *, unsigned int *) ATTRIBUTE_HIDDEN;
  739. extern bfd_signed_vma _bfd_read_signed_leb128
  740. (bfd *, bfd_byte *, unsigned int *) ATTRIBUTE_HIDDEN;
  741. extern bfd_vma _bfd_safe_read_leb128
  742. (bfd *, bfd_byte **, bool, const bfd_byte * const) ATTRIBUTE_HIDDEN;
  743. extern bfd_byte * _bfd_write_unsigned_leb128
  744. (bfd_byte *, bfd_byte *, bfd_vma) ATTRIBUTE_HIDDEN;
  745. extern struct bfd_link_info *_bfd_get_link_info (bfd *);
  746. extern bool _bfd_link_keep_memory (struct bfd_link_info *)
  747. ATTRIBUTE_HIDDEN;
  748. #if GCC_VERSION >= 7000
  749. #define _bfd_mul_overflow(a, b, res) __builtin_mul_overflow (a, b, res)
  750. #else
  751. /* Assumes unsigned values. Careful! Args evaluated multiple times. */
  752. #define _bfd_mul_overflow(a, b, res) \
  753. ((*res) = (a), (*res) *= (b), (b) != 0 && (*res) / (b) != (a))
  754. #endif
  755. #ifdef __GNUC__
  756. #define _bfd_constant_p(v) __builtin_constant_p (v)
  757. #else
  758. #define _bfd_constant_p(v) 0
  759. #endif
  760. static inline bfd_byte *
  761. _bfd_alloc_and_read (bfd *abfd, bfd_size_type asize, bfd_size_type rsize)
  762. {
  763. bfd_byte *mem;
  764. if (!_bfd_constant_p (rsize))
  765. {
  766. ufile_ptr filesize = bfd_get_file_size (abfd);
  767. if (filesize != 0 && rsize > filesize)
  768. {
  769. bfd_set_error (bfd_error_file_truncated);
  770. return NULL;
  771. }
  772. }
  773. mem = bfd_alloc (abfd, asize);
  774. if (mem != NULL)
  775. {
  776. if (bfd_bread (mem, rsize, abfd) == rsize)
  777. return mem;
  778. bfd_release (abfd, mem);
  779. }
  780. return NULL;
  781. }
  782. static inline bfd_byte *
  783. _bfd_malloc_and_read (bfd *abfd, bfd_size_type asize, bfd_size_type rsize)
  784. {
  785. bfd_byte *mem;
  786. if (!_bfd_constant_p (rsize))
  787. {
  788. ufile_ptr filesize = bfd_get_file_size (abfd);
  789. if (filesize != 0 && rsize > filesize)
  790. {
  791. bfd_set_error (bfd_error_file_truncated);
  792. return NULL;
  793. }
  794. }
  795. mem = bfd_malloc (asize);
  796. if (mem != NULL)
  797. {
  798. if (bfd_bread (mem, rsize, abfd) == rsize)
  799. return mem;
  800. free (mem);
  801. }
  802. return NULL;
  803. }