libcoff.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988
  1. /* DO NOT EDIT! -*- buffer-read-only: t -*- This file is automatically
  2. generated from "libcoff-in.h" and "coffcode.h".
  3. Run "make headers" in your build bfd/ to regenerate. */
  4. /* BFD COFF object file private structure.
  5. Copyright (C) 1990-2022 Free Software Foundation, Inc.
  6. Written by Cygnus Support.
  7. This file is part of BFD, the Binary File Descriptor library.
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 3 of the License, or
  11. (at your option) any later version.
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  19. MA 02110-1301, USA. */
  20. #ifndef _LIBCOFF_H
  21. #define _LIBCOFF_H 1
  22. #include "bfdlink.h"
  23. #include "coff-bfd.h"
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /* Object file tdata; access macros. */
  28. #define coff_data(bfd) ((bfd)->tdata.coff_obj_data)
  29. #define obj_pe(bfd) (coff_data (bfd)->pe)
  30. #define obj_go32(bfd) (coff_data (bfd)->go32)
  31. #define obj_symbols(bfd) (coff_data (bfd)->symbols)
  32. #define obj_sym_filepos(bfd) (coff_data (bfd)->sym_filepos)
  33. #define obj_relocbase(bfd) (coff_data (bfd)->relocbase)
  34. #define obj_raw_syments(bfd) (coff_data (bfd)->raw_syments)
  35. #define obj_raw_syment_count(bfd) (coff_data (bfd)->raw_syment_count)
  36. #define obj_convert(bfd) (coff_data (bfd)->conversion_table)
  37. #define obj_conv_table_size(bfd) (coff_data (bfd)->conv_table_size)
  38. #define obj_coff_external_syms(bfd) (coff_data (bfd)->external_syms)
  39. #define obj_coff_keep_syms(bfd) (coff_data (bfd)->keep_syms)
  40. #define obj_coff_strings(bfd) (coff_data (bfd)->strings)
  41. #define obj_coff_strings_len(bfd) (coff_data (bfd)->strings_len)
  42. #define obj_coff_keep_strings(bfd) (coff_data (bfd)->keep_strings)
  43. #define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes)
  44. #define obj_coff_strings_written(bfd) (coff_data (bfd)->strings_written)
  45. #define obj_coff_local_toc_table(bfd) (coff_data (bfd)->local_toc_sym_map)
  46. /* `Tdata' information kept for COFF files. */
  47. typedef struct coff_tdata
  48. {
  49. struct coff_symbol_struct *symbols; /* Symtab for input bfd. */
  50. unsigned int *conversion_table;
  51. int conv_table_size;
  52. file_ptr sym_filepos;
  53. struct coff_ptr_struct *raw_syments;
  54. unsigned long raw_syment_count;
  55. /* These are only valid once writing has begun. */
  56. unsigned long int relocbase;
  57. /* These members communicate important constants about the symbol table
  58. to GDB's symbol-reading code. These `constants' unfortunately vary
  59. from coff implementation to implementation... */
  60. unsigned local_n_btmask;
  61. unsigned local_n_btshft;
  62. unsigned local_n_tmask;
  63. unsigned local_n_tshift;
  64. unsigned local_symesz;
  65. unsigned local_auxesz;
  66. unsigned local_linesz;
  67. /* The unswapped external symbols. May be NULL. Read by
  68. _bfd_coff_get_external_symbols. */
  69. void * external_syms;
  70. /* If this is TRUE, the external_syms may not be freed. */
  71. bool keep_syms;
  72. /* The string table. May be NULL. Read by
  73. _bfd_coff_read_string_table. */
  74. char *strings;
  75. /* The length of the strings table. For error checking. */
  76. bfd_size_type strings_len;
  77. /* If this is TRUE, the strings may not be freed. */
  78. bool keep_strings;
  79. /* If this is TRUE, the strings have been written out already. */
  80. bool strings_written;
  81. /* Is this a PE format coff file? */
  82. int pe;
  83. /* Used by the COFF backend linker. */
  84. struct coff_link_hash_entry **sym_hashes;
  85. /* Used by the pe linker for PowerPC. */
  86. int *local_toc_sym_map;
  87. struct bfd_link_info *link_info;
  88. /* Used by coff_find_nearest_line. */
  89. void * line_info;
  90. /* A place to stash dwarf2 info for this bfd. */
  91. void * dwarf2_find_line_info;
  92. /* The timestamp from the COFF file header. */
  93. long timestamp;
  94. /* Copy of some of the f_flags bits in the COFF filehdr structure,
  95. used by ARM code. */
  96. flagword flags;
  97. /* Is this a GO32 coff file? */
  98. bool go32;
  99. /* A stub (extra data prepended before the COFF image) and its size.
  100. Used by coff-go32-exe, it contains executable data that loads the
  101. COFF object into memory. */
  102. char * stub;
  103. bfd_size_type stub_size;
  104. } coff_data_type;
  105. /* Tdata for pe image files. */
  106. typedef struct pe_tdata
  107. {
  108. coff_data_type coff;
  109. struct internal_extra_pe_aouthdr pe_opthdr;
  110. int dll;
  111. int has_reloc_section;
  112. int dont_strip_reloc;
  113. int dos_message[16];
  114. /* The timestamp to insert into the output file.
  115. If the timestamp is -1 then the current time is used. */
  116. int timestamp;
  117. bool (*in_reloc_p) (bfd *, reloc_howto_type *);
  118. flagword real_flags;
  119. /* Build-id info. */
  120. struct
  121. {
  122. bool (*after_write_object_contents) (bfd *);
  123. const char *style;
  124. asection *sec;
  125. } build_id;
  126. } pe_data_type;
  127. #define pe_data(bfd) ((bfd)->tdata.pe_obj_data)
  128. /* Tdata for XCOFF files. */
  129. struct xcoff_tdata
  130. {
  131. /* Basic COFF information. */
  132. coff_data_type coff;
  133. /* TRUE if this is an XCOFF64 file. */
  134. bool xcoff64;
  135. /* TRUE if a large a.out header should be generated. */
  136. bool full_aouthdr;
  137. /* TOC value. */
  138. bfd_vma toc;
  139. /* Index of section holding TOC. */
  140. int sntoc;
  141. /* Index of section holding entry point. */
  142. int snentry;
  143. /* .text alignment from optional header. */
  144. int text_align_power;
  145. /* .data alignment from optional header. */
  146. int data_align_power;
  147. /* modtype from optional header. */
  148. short modtype;
  149. /* cputype from optional header. */
  150. short cputype;
  151. /* maxdata from optional header. */
  152. bfd_vma maxdata;
  153. /* maxstack from optional header. */
  154. bfd_vma maxstack;
  155. /* Used by the XCOFF backend linker. */
  156. asection **csects;
  157. long *debug_indices;
  158. unsigned int *lineno_counts;
  159. unsigned int import_file_id;
  160. };
  161. #define xcoff_data(abfd) ((abfd)->tdata.xcoff_obj_data)
  162. /* We take the address of the first element of an asymbol to ensure that the
  163. macro is only ever applied to an asymbol. */
  164. #define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd)))
  165. /* Tdata for sections in XCOFF files. This is used by the linker. */
  166. struct xcoff_section_tdata
  167. {
  168. /* Used for XCOFF csects created by the linker; points to the real
  169. XCOFF section which contains this csect. */
  170. asection *enclosing;
  171. /* The lineno_count field for the enclosing section, because we are
  172. going to clobber it there. */
  173. unsigned int lineno_count;
  174. /* The first and last symbol indices for symbols used by this csect. */
  175. unsigned long first_symndx;
  176. unsigned long last_symndx;
  177. };
  178. /* An accessor macro the xcoff_section_tdata structure. */
  179. #define xcoff_section_data(abfd, sec) \
  180. ((struct xcoff_section_tdata *) coff_section_data ((abfd), (sec))->tdata)
  181. /* Tdata for sections in PE files. */
  182. struct pei_section_tdata
  183. {
  184. /* The virtual size of the section. */
  185. bfd_size_type virt_size;
  186. /* The PE section flags. */
  187. long pe_flags;
  188. };
  189. /* An accessor macro for the pei_section_tdata structure. */
  190. #define pei_section_data(abfd, sec) \
  191. ((struct pei_section_tdata *) coff_section_data ((abfd), (sec))->tdata)
  192. /* COFF linker hash table entries. */
  193. struct coff_link_hash_entry
  194. {
  195. struct bfd_link_hash_entry root;
  196. /* Symbol index in output file. This is initialized to -1. It is
  197. set to -2 if the symbol is used by a reloc. It is set to -3 if
  198. this symbol is defined in a discarded section. */
  199. long indx;
  200. /* Symbol type. */
  201. unsigned short type;
  202. /* Symbol class. */
  203. unsigned char symbol_class;
  204. /* Number of auxiliary entries. */
  205. char numaux;
  206. /* BFD to take auxiliary entries from. */
  207. bfd *auxbfd;
  208. /* Pointer to array of auxiliary entries, if any. */
  209. union internal_auxent *aux;
  210. /* Flag word; legal values follow. */
  211. unsigned short coff_link_hash_flags;
  212. /* Symbol is a PE section symbol. */
  213. #define COFF_LINK_HASH_PE_SECTION_SYMBOL (01)
  214. };
  215. /* COFF linker hash table. */
  216. struct coff_link_hash_table
  217. {
  218. struct bfd_link_hash_table root;
  219. /* A pointer to information used to link stabs in sections. */
  220. struct stab_info stab_info;
  221. };
  222. struct coff_reloc_cookie
  223. {
  224. struct internal_reloc * rels;
  225. struct internal_reloc * rel;
  226. struct internal_reloc * relend;
  227. struct coff_symbol_struct * symbols; /* Symtab for input bfd. */
  228. bfd * abfd;
  229. struct coff_link_hash_entry ** sym_hashes;
  230. };
  231. /* Look up an entry in a COFF linker hash table. */
  232. #define coff_link_hash_lookup(table, string, create, copy, follow) \
  233. ((struct coff_link_hash_entry *) \
  234. bfd_link_hash_lookup (&(table)->root, (string), (create), \
  235. (copy), (follow)))
  236. /* Traverse a COFF linker hash table. */
  237. #define coff_link_hash_traverse(table, func, info) \
  238. (bfd_link_hash_traverse \
  239. (&(table)->root, \
  240. (bool (*) (struct bfd_link_hash_entry *, void *)) (func), \
  241. (info)))
  242. /* Get the COFF linker hash table from a link_info structure. */
  243. #define coff_hash_table(p) ((struct coff_link_hash_table *) ((p)->hash))
  244. /* Functions in coffgen.c. */
  245. extern bfd_cleanup coff_object_p
  246. (bfd *);
  247. extern struct bfd_section *coff_section_from_bfd_index
  248. (bfd *, int);
  249. extern long coff_get_symtab_upper_bound
  250. (bfd *);
  251. extern long coff_canonicalize_symtab
  252. (bfd *, asymbol **);
  253. extern int coff_count_linenumbers
  254. (bfd *);
  255. extern bool coff_renumber_symbols
  256. (bfd *, int *);
  257. extern void coff_mangle_symbols
  258. (bfd *);
  259. extern bool coff_write_symbols
  260. (bfd *);
  261. extern bool coff_write_alien_symbol
  262. (bfd *, asymbol *, struct internal_syment *, union internal_auxent *,
  263. bfd_vma *, bfd_size_type *, asection **, bfd_size_type *);
  264. extern bool coff_write_linenumbers
  265. (bfd *);
  266. extern alent *coff_get_lineno
  267. (bfd *, asymbol *);
  268. extern asymbol *coff_section_symbol
  269. (bfd *, char *);
  270. extern bool _bfd_coff_get_external_symbols
  271. (bfd *);
  272. extern const char *_bfd_coff_read_string_table
  273. (bfd *);
  274. extern bool _bfd_coff_free_symbols
  275. (bfd *);
  276. extern struct coff_ptr_struct *coff_get_normalized_symtab
  277. (bfd *);
  278. extern long coff_get_reloc_upper_bound
  279. (bfd *, sec_ptr);
  280. extern asymbol *coff_make_empty_symbol
  281. (bfd *);
  282. extern void coff_print_symbol
  283. (bfd *, void * filep, asymbol *, bfd_print_symbol_type);
  284. extern void coff_get_symbol_info
  285. (bfd *, asymbol *, symbol_info *ret);
  286. #define coff_get_symbol_version_string \
  287. _bfd_nosymbols_get_symbol_version_string
  288. extern bool _bfd_coff_is_local_label_name
  289. (bfd *, const char *);
  290. extern asymbol *coff_bfd_make_debug_symbol
  291. (bfd *, void *, unsigned long);
  292. extern bool coff_find_nearest_line
  293. (bfd *, asymbol **, asection *, bfd_vma,
  294. const char **, const char **, unsigned int *, unsigned int *);
  295. #define coff_find_line _bfd_nosymbols_find_line
  296. struct dwarf_debug_section;
  297. extern bool coff_find_nearest_line_with_names
  298. (bfd *, asymbol **, asection *, bfd_vma, const char **, const char **,
  299. unsigned int *, const struct dwarf_debug_section *);
  300. extern bool coff_find_inliner_info
  301. (bfd *, const char **, const char **, unsigned int *);
  302. extern int coff_sizeof_headers
  303. (bfd *, struct bfd_link_info *);
  304. extern bool bfd_coff_reloc16_relax_section
  305. (bfd *, asection *, struct bfd_link_info *, bool *);
  306. extern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents
  307. (bfd *, struct bfd_link_info *, struct bfd_link_order *,
  308. bfd_byte *, bool, asymbol **);
  309. extern bfd_vma bfd_coff_reloc16_get_value
  310. (arelent *, struct bfd_link_info *, asection *);
  311. extern void bfd_perform_slip
  312. (bfd *, unsigned int, asection *, bfd_vma);
  313. extern bool _bfd_coff_close_and_cleanup
  314. (bfd *);
  315. /* Functions and types in cofflink.c. */
  316. #define STRING_SIZE_SIZE 4
  317. /* We use a hash table to merge identical enum, struct, and union
  318. definitions in the linker. */
  319. /* Information we keep for a single element (an enum value, a
  320. structure or union field) in the debug merge hash table. */
  321. struct coff_debug_merge_element
  322. {
  323. /* Next element. */
  324. struct coff_debug_merge_element *next;
  325. /* Name. */
  326. const char *name;
  327. /* Type. */
  328. unsigned int type;
  329. /* Symbol index for complex type. */
  330. long tagndx;
  331. };
  332. /* A linked list of debug merge entries for a given name. */
  333. struct coff_debug_merge_type
  334. {
  335. /* Next type with the same name. */
  336. struct coff_debug_merge_type *next;
  337. /* Class of type. */
  338. int type_class;
  339. /* Symbol index where this type is defined. */
  340. long indx;
  341. /* List of elements. */
  342. struct coff_debug_merge_element *elements;
  343. };
  344. /* Information we store in the debug merge hash table. */
  345. struct coff_debug_merge_hash_entry
  346. {
  347. struct bfd_hash_entry root;
  348. /* A list of types with this name. */
  349. struct coff_debug_merge_type *types;
  350. };
  351. /* The debug merge hash table. */
  352. struct coff_debug_merge_hash_table
  353. {
  354. struct bfd_hash_table root;
  355. };
  356. /* Initialize a COFF debug merge hash table. */
  357. #define coff_debug_merge_hash_table_init(table) \
  358. (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc, \
  359. sizeof (struct coff_debug_merge_hash_entry)))
  360. /* Free a COFF debug merge hash table. */
  361. #define coff_debug_merge_hash_table_free(table) \
  362. (bfd_hash_table_free (&(table)->root))
  363. /* Look up an entry in a COFF debug merge hash table. */
  364. #define coff_debug_merge_hash_lookup(table, string, create, copy) \
  365. ((struct coff_debug_merge_hash_entry *) \
  366. bfd_hash_lookup (&(table)->root, (string), (create), (copy)))
  367. /* Information we keep for each section in the output file when doing
  368. a relocatable link. */
  369. struct coff_link_section_info
  370. {
  371. /* The relocs to be output. */
  372. struct internal_reloc *relocs;
  373. /* For each reloc against a global symbol whose index was not known
  374. when the reloc was handled, the global hash table entry. */
  375. struct coff_link_hash_entry **rel_hashes;
  376. };
  377. /* Information that we pass around while doing the final link step. */
  378. struct coff_final_link_info
  379. {
  380. /* General link information. */
  381. struct bfd_link_info *info;
  382. /* Output BFD. */
  383. bfd *output_bfd;
  384. /* Used to indicate failure in traversal routine. */
  385. bool failed;
  386. /* If doing "task linking" set only during the time when we want the
  387. global symbol writer to convert the storage class of defined global
  388. symbols from global to static. */
  389. bool global_to_static;
  390. /* Hash table for long symbol names. */
  391. struct bfd_strtab_hash *strtab;
  392. /* When doing a relocatable link, an array of information kept for
  393. each output section, indexed by the target_index field. */
  394. struct coff_link_section_info *section_info;
  395. /* Symbol index of last C_FILE symbol (-1 if none). */
  396. long last_file_index;
  397. /* Contents of last C_FILE symbol. */
  398. struct internal_syment last_file;
  399. /* Symbol index of first aux entry of last .bf symbol with an empty
  400. endndx field (-1 if none). */
  401. long last_bf_index;
  402. /* Contents of last_bf_index aux entry. */
  403. union internal_auxent last_bf;
  404. /* Hash table used to merge debug information. */
  405. struct coff_debug_merge_hash_table debug_merge;
  406. /* Buffer large enough to hold swapped symbols of any input file. */
  407. struct internal_syment *internal_syms;
  408. /* Buffer large enough to hold sections of symbols of any input file. */
  409. asection **sec_ptrs;
  410. /* Buffer large enough to hold output indices of symbols of any
  411. input file. */
  412. long *sym_indices;
  413. /* Buffer large enough to hold output symbols for any input file. */
  414. bfd_byte *outsyms;
  415. /* Buffer large enough to hold external line numbers for any input
  416. section. */
  417. bfd_byte *linenos;
  418. /* Buffer large enough to hold any input section. */
  419. bfd_byte *contents;
  420. /* Buffer large enough to hold external relocs of any input section. */
  421. bfd_byte *external_relocs;
  422. /* Buffer large enough to hold swapped relocs of any input section. */
  423. struct internal_reloc *internal_relocs;
  424. };
  425. /* Most COFF variants have no way to record the alignment of a
  426. section. This struct is used to set a specific alignment based on
  427. the name of the section. */
  428. struct coff_section_alignment_entry
  429. {
  430. /* The section name. */
  431. const char *name;
  432. /* This is either (unsigned int) -1, indicating that the section
  433. name must match exactly, or it is the number of letters which
  434. must match at the start of the name. */
  435. unsigned int comparison_length;
  436. /* These macros may be used to fill in the first two fields in a
  437. structure initialization. */
  438. #define COFF_SECTION_NAME_EXACT_MATCH(name) (name), ((unsigned int) -1)
  439. #define COFF_SECTION_NAME_PARTIAL_MATCH(name) (name), (sizeof (name) - 1)
  440. /* Only use this entry if the default section alignment for this
  441. target is at least that much (as a power of two). If this field
  442. is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored. */
  443. unsigned int default_alignment_min;
  444. /* Only use this entry if the default section alignment for this
  445. target is no greater than this (as a power of two). If this
  446. field is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored. */
  447. unsigned int default_alignment_max;
  448. #define COFF_ALIGNMENT_FIELD_EMPTY ((unsigned int) -1)
  449. /* The desired alignment for this section (as a power of two). */
  450. unsigned int alignment_power;
  451. };
  452. extern struct bfd_hash_entry *_bfd_coff_link_hash_newfunc
  453. (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
  454. extern bool _bfd_coff_link_hash_table_init
  455. (struct coff_link_hash_table *, bfd *,
  456. struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
  457. struct bfd_hash_table *,
  458. const char *),
  459. unsigned int);
  460. extern struct bfd_link_hash_table *_bfd_coff_link_hash_table_create
  461. (bfd *);
  462. extern const char *_bfd_coff_internal_syment_name
  463. (bfd *, const struct internal_syment *, char *);
  464. extern bool _bfd_coff_section_already_linked
  465. (bfd *, asection *, struct bfd_link_info *);
  466. extern bool _bfd_coff_link_add_symbols
  467. (bfd *, struct bfd_link_info *);
  468. extern bool _bfd_coff_final_link
  469. (bfd *, struct bfd_link_info *);
  470. extern struct internal_reloc *_bfd_coff_read_internal_relocs
  471. (bfd *, asection *, bool, bfd_byte *, bool,
  472. struct internal_reloc *);
  473. extern bool _bfd_coff_generic_relocate_section
  474. (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
  475. struct internal_reloc *, struct internal_syment *, asection **);
  476. extern struct bfd_hash_entry *_bfd_coff_debug_merge_hash_newfunc
  477. (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
  478. extern bool _bfd_coff_write_global_sym
  479. (struct bfd_hash_entry *, void *);
  480. extern bool _bfd_coff_write_task_globals
  481. (struct coff_link_hash_entry *, void *);
  482. extern bool _bfd_coff_link_input_bfd
  483. (struct coff_final_link_info *, bfd *);
  484. extern bool _bfd_coff_reloc_link_order
  485. (bfd *, struct coff_final_link_info *, asection *,
  486. struct bfd_link_order *);
  487. extern bool bfd_coff_gc_sections
  488. (bfd *, struct bfd_link_info *);
  489. extern const char *bfd_coff_group_name
  490. (bfd *, const asection *);
  491. #define coff_get_section_contents_in_window \
  492. _bfd_generic_get_section_contents_in_window
  493. /* Functions in xcofflink.c. */
  494. extern long _bfd_xcoff_get_dynamic_symtab_upper_bound
  495. (bfd *);
  496. extern long _bfd_xcoff_canonicalize_dynamic_symtab
  497. (bfd *, asymbol **);
  498. extern long _bfd_xcoff_get_dynamic_reloc_upper_bound
  499. (bfd *);
  500. extern long _bfd_xcoff_canonicalize_dynamic_reloc
  501. (bfd *, arelent **, asymbol **);
  502. extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create
  503. (bfd *);
  504. extern bool _bfd_xcoff_bfd_link_add_symbols
  505. (bfd *, struct bfd_link_info *);
  506. extern bool _bfd_xcoff_bfd_final_link
  507. (bfd *, struct bfd_link_info *);
  508. extern bool _bfd_xcoff_define_common_symbol
  509. (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
  510. extern bool _bfd_ppc_xcoff_relocate_section
  511. (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
  512. struct internal_reloc *, struct internal_syment *, asection **);
  513. /* Extracted from coffcode.h. */
  514. typedef struct coff_ptr_struct
  515. {
  516. /* Remembers the offset from the first symbol in the file for
  517. this symbol. Generated by coff_renumber_symbols. */
  518. unsigned int offset;
  519. /* Should the value of this symbol be renumbered. Used for
  520. XCOFF C_BSTAT symbols. Set by coff_slurp_symbol_table. */
  521. unsigned int fix_value : 1;
  522. /* Should the tag field of this symbol be renumbered.
  523. Created by coff_pointerize_aux. */
  524. unsigned int fix_tag : 1;
  525. /* Should the endidx field of this symbol be renumbered.
  526. Created by coff_pointerize_aux. */
  527. unsigned int fix_end : 1;
  528. /* Should the x_csect.x_scnlen field be renumbered.
  529. Created by coff_pointerize_aux. */
  530. unsigned int fix_scnlen : 1;
  531. /* Fix up an XCOFF C_BINCL/C_EINCL symbol. The value is the
  532. index into the line number entries. Set by coff_slurp_symbol_table. */
  533. unsigned int fix_line : 1;
  534. /* The container for the symbol structure as read and translated
  535. from the file. */
  536. union
  537. {
  538. union internal_auxent auxent;
  539. struct internal_syment syment;
  540. } u;
  541. /* Selector for the union above. */
  542. bool is_sym;
  543. /* An extra pointer which can used by format based on COFF (like XCOFF)
  544. to provide extra information to their backend. */
  545. void *extrap;
  546. } combined_entry_type;
  547. /* Each canonical asymbol really looks like this: */
  548. typedef struct coff_symbol_struct
  549. {
  550. /* The actual symbol which the rest of BFD works with */
  551. asymbol symbol;
  552. /* A pointer to the hidden information for this symbol */
  553. combined_entry_type *native;
  554. /* A pointer to the linenumber information for this symbol */
  555. struct lineno_cache_entry *lineno;
  556. /* Have the line numbers been relocated yet ? */
  557. bool done_lineno;
  558. } coff_symbol_type;
  559. /* COFF symbol classifications. */
  560. enum coff_symbol_classification
  561. {
  562. /* Global symbol. */
  563. COFF_SYMBOL_GLOBAL,
  564. /* Common symbol. */
  565. COFF_SYMBOL_COMMON,
  566. /* Undefined symbol. */
  567. COFF_SYMBOL_UNDEFINED,
  568. /* Local symbol. */
  569. COFF_SYMBOL_LOCAL,
  570. /* PE section symbol. */
  571. COFF_SYMBOL_PE_SECTION
  572. };
  573. typedef asection * (*coff_gc_mark_hook_fn)
  574. (asection *, struct bfd_link_info *, struct internal_reloc *,
  575. struct coff_link_hash_entry *, struct internal_syment *);
  576. typedef struct
  577. {
  578. void (*_bfd_coff_swap_aux_in)
  579. (bfd *, void *, int, int, int, int, void *);
  580. void (*_bfd_coff_swap_sym_in)
  581. (bfd *, void *, void *);
  582. void (*_bfd_coff_swap_lineno_in)
  583. (bfd *, void *, void *);
  584. unsigned int (*_bfd_coff_swap_aux_out)
  585. (bfd *, void *, int, int, int, int, void *);
  586. unsigned int (*_bfd_coff_swap_sym_out)
  587. (bfd *, void *, void *);
  588. unsigned int (*_bfd_coff_swap_lineno_out)
  589. (bfd *, void *, void *);
  590. unsigned int (*_bfd_coff_swap_reloc_out)
  591. (bfd *, void *, void *);
  592. unsigned int (*_bfd_coff_swap_filehdr_out)
  593. (bfd *, void *, void *);
  594. unsigned int (*_bfd_coff_swap_aouthdr_out)
  595. (bfd *, void *, void *);
  596. unsigned int (*_bfd_coff_swap_scnhdr_out)
  597. (bfd *, void *, void *);
  598. unsigned int _bfd_filhsz;
  599. unsigned int _bfd_aoutsz;
  600. unsigned int _bfd_scnhsz;
  601. unsigned int _bfd_symesz;
  602. unsigned int _bfd_auxesz;
  603. unsigned int _bfd_relsz;
  604. unsigned int _bfd_linesz;
  605. unsigned int _bfd_filnmlen;
  606. bool _bfd_coff_long_filenames;
  607. bool _bfd_coff_long_section_names;
  608. bool (*_bfd_coff_set_long_section_names)
  609. (bfd *, int);
  610. unsigned int _bfd_coff_default_section_alignment_power;
  611. bool _bfd_coff_force_symnames_in_strings;
  612. unsigned int _bfd_coff_debug_string_prefix_length;
  613. unsigned int _bfd_coff_max_nscns;
  614. void (*_bfd_coff_swap_filehdr_in)
  615. (bfd *, void *, void *);
  616. void (*_bfd_coff_swap_aouthdr_in)
  617. (bfd *, void *, void *);
  618. void (*_bfd_coff_swap_scnhdr_in)
  619. (bfd *, void *, void *);
  620. void (*_bfd_coff_swap_reloc_in)
  621. (bfd *abfd, void *, void *);
  622. bool (*_bfd_coff_bad_format_hook)
  623. (bfd *, void *);
  624. bool (*_bfd_coff_set_arch_mach_hook)
  625. (bfd *, void *);
  626. void * (*_bfd_coff_mkobject_hook)
  627. (bfd *, void *, void *);
  628. bool (*_bfd_styp_to_sec_flags_hook)
  629. (bfd *, void *, const char *, asection *, flagword *);
  630. void (*_bfd_set_alignment_hook)
  631. (bfd *, asection *, void *);
  632. bool (*_bfd_coff_slurp_symbol_table)
  633. (bfd *);
  634. bool (*_bfd_coff_symname_in_debug)
  635. (bfd *, struct internal_syment *);
  636. bool (*_bfd_coff_pointerize_aux_hook)
  637. (bfd *, combined_entry_type *, combined_entry_type *,
  638. unsigned int, combined_entry_type *);
  639. bool (*_bfd_coff_print_aux)
  640. (bfd *, FILE *, combined_entry_type *, combined_entry_type *,
  641. combined_entry_type *, unsigned int);
  642. void (*_bfd_coff_reloc16_extra_cases)
  643. (bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *,
  644. bfd_byte *, unsigned int *, unsigned int *);
  645. int (*_bfd_coff_reloc16_estimate)
  646. (bfd *, asection *, arelent *, unsigned int,
  647. struct bfd_link_info *);
  648. enum coff_symbol_classification (*_bfd_coff_classify_symbol)
  649. (bfd *, struct internal_syment *);
  650. bool (*_bfd_coff_compute_section_file_positions)
  651. (bfd *);
  652. bool (*_bfd_coff_start_final_link)
  653. (bfd *, struct bfd_link_info *);
  654. bool (*_bfd_coff_relocate_section)
  655. (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
  656. struct internal_reloc *, struct internal_syment *, asection **);
  657. reloc_howto_type *(*_bfd_coff_rtype_to_howto)
  658. (bfd *, asection *, struct internal_reloc *,
  659. struct coff_link_hash_entry *, struct internal_syment *, bfd_vma *);
  660. bool (*_bfd_coff_adjust_symndx)
  661. (bfd *, struct bfd_link_info *, bfd *, asection *,
  662. struct internal_reloc *, bool *);
  663. bool (*_bfd_coff_link_add_one_symbol)
  664. (struct bfd_link_info *, bfd *, const char *, flagword,
  665. asection *, bfd_vma, const char *, bool, bool,
  666. struct bfd_link_hash_entry **);
  667. bool (*_bfd_coff_link_output_has_begun)
  668. (bfd *, struct coff_final_link_info *);
  669. bool (*_bfd_coff_final_link_postscript)
  670. (bfd *, struct coff_final_link_info *);
  671. bool (*_bfd_coff_print_pdata)
  672. (bfd *, void *);
  673. } bfd_coff_backend_data;
  674. #define coff_backend_info(abfd) \
  675. ((bfd_coff_backend_data *) (abfd)->xvec->backend_data)
  676. #define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \
  677. ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i))
  678. #define bfd_coff_swap_sym_in(a,e,i) \
  679. ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
  680. #define bfd_coff_swap_lineno_in(a,e,i) \
  681. ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
  682. #define bfd_coff_swap_reloc_out(abfd, i, o) \
  683. ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
  684. #define bfd_coff_swap_lineno_out(abfd, i, o) \
  685. ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
  686. #define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \
  687. ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o))
  688. #define bfd_coff_swap_sym_out(abfd, i,o) \
  689. ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
  690. #define bfd_coff_swap_scnhdr_out(abfd, i,o) \
  691. ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
  692. #define bfd_coff_swap_filehdr_out(abfd, i,o) \
  693. ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
  694. #define bfd_coff_swap_aouthdr_out(abfd, i,o) \
  695. ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
  696. #define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz)
  697. #define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz)
  698. #define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz)
  699. #define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz)
  700. #define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz)
  701. #define bfd_coff_relsz(abfd) (coff_backend_info (abfd)->_bfd_relsz)
  702. #define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz)
  703. #define bfd_coff_filnmlen(abfd) (coff_backend_info (abfd)->_bfd_filnmlen)
  704. #define bfd_coff_long_filenames(abfd) \
  705. (coff_backend_info (abfd)->_bfd_coff_long_filenames)
  706. #define bfd_coff_long_section_names(abfd) \
  707. (coff_backend_info (abfd)->_bfd_coff_long_section_names)
  708. #define bfd_coff_set_long_section_names(abfd, enable) \
  709. ((coff_backend_info (abfd)->_bfd_coff_set_long_section_names) (abfd, enable))
  710. #define bfd_coff_default_section_alignment_power(abfd) \
  711. (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power)
  712. #define bfd_coff_max_nscns(abfd) \
  713. (coff_backend_info (abfd)->_bfd_coff_max_nscns)
  714. #define bfd_coff_swap_filehdr_in(abfd, i,o) \
  715. ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
  716. #define bfd_coff_swap_aouthdr_in(abfd, i,o) \
  717. ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
  718. #define bfd_coff_swap_scnhdr_in(abfd, i,o) \
  719. ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
  720. #define bfd_coff_swap_reloc_in(abfd, i, o) \
  721. ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o))
  722. #define bfd_coff_bad_format_hook(abfd, filehdr) \
  723. ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
  724. #define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
  725. ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
  726. #define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
  727. ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook)\
  728. (abfd, filehdr, aouthdr))
  729. #define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name, section, flags_ptr)\
  730. ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook)\
  731. (abfd, scnhdr, name, section, flags_ptr))
  732. #define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
  733. ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
  734. #define bfd_coff_slurp_symbol_table(abfd)\
  735. ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
  736. #define bfd_coff_symname_in_debug(abfd, sym)\
  737. ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
  738. #define bfd_coff_force_symnames_in_strings(abfd)\
  739. (coff_backend_info (abfd)->_bfd_coff_force_symnames_in_strings)
  740. #define bfd_coff_debug_string_prefix_length(abfd)\
  741. (coff_backend_info (abfd)->_bfd_coff_debug_string_prefix_length)
  742. #define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\
  743. ((coff_backend_info (abfd)->_bfd_coff_print_aux)\
  744. (abfd, file, base, symbol, aux, indaux))
  745. #define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order,\
  746. reloc, data, src_ptr, dst_ptr)\
  747. ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
  748. (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
  749. #define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\
  750. ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\
  751. (abfd, section, reloc, shrink, link_info))
  752. #define bfd_coff_classify_symbol(abfd, sym)\
  753. ((coff_backend_info (abfd)->_bfd_coff_classify_symbol)\
  754. (abfd, sym))
  755. #define bfd_coff_compute_section_file_positions(abfd)\
  756. ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\
  757. (abfd))
  758. #define bfd_coff_start_final_link(obfd, info)\
  759. ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\
  760. (obfd, info))
  761. #define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\
  762. ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\
  763. (obfd, info, ibfd, o, con, rel, isyms, secs))
  764. #define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\
  765. ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\
  766. (abfd, sec, rel, h, sym, addendp))
  767. #define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\
  768. ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
  769. (obfd, info, ibfd, sec, rel, adjustedp))
  770. #define bfd_coff_link_add_one_symbol(info, abfd, name, flags, section,\
  771. value, string, cp, coll, hashp)\
  772. ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
  773. (info, abfd, name, flags, section, value, string, cp, coll, hashp))
  774. #define bfd_coff_link_output_has_begun(a,p) \
  775. ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a, p))
  776. #define bfd_coff_final_link_postscript(a,p) \
  777. ((coff_backend_info (a)->_bfd_coff_final_link_postscript) (a, p))
  778. #define bfd_coff_have_print_pdata(a) \
  779. (coff_backend_info (a)->_bfd_coff_print_pdata)
  780. #define bfd_coff_print_pdata(a,p) \
  781. ((coff_backend_info (a)->_bfd_coff_print_pdata) (a, p))
  782. /* Macro: Returns true if the bfd is a PE executable as opposed to a
  783. PE object file. */
  784. #define bfd_pei_p(abfd) \
  785. (startswith ((abfd)->xvec->name, "pei-"))
  786. #ifdef __cplusplus
  787. }
  788. #endif
  789. #endif