libbfd-in.h 31 KB

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