- ((xcoff_backend(a)->_xcoff_loader_reloc_offset((a), (b))))
-
-#define bfd_xcoff_glink_code(a, b) ((xcoff_backend(a)->_xcoff_glink_code[(b)]))
-#define bfd_xcoff_glink_code_size(a) ((xcoff_backend(a)->_xcoff_glink_size))
-
-#define bfd_xcoff_is_xcoff64(a) (0x01EF == (bfd_xcoff_magic_number(a)))
-#define bfd_xcoff_is_xcoff32(a) (0x01DF == (bfd_xcoff_magic_number(a)))
-
-/* Functions in xcofflink.c. */
-
-extern long _bfd_xcoff_get_dynamic_symtab_upper_bound PARAMS ((bfd *));
-extern long _bfd_xcoff_canonicalize_dynamic_symtab
- PARAMS ((bfd *, asymbol **));
-extern long _bfd_xcoff_get_dynamic_reloc_upper_bound PARAMS ((bfd *));
-extern long _bfd_xcoff_canonicalize_dynamic_reloc
- PARAMS ((bfd *, arelent **, asymbol **));
-extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create
- PARAMS ((bfd *));
-extern boolean _bfd_xcoff_bfd_link_add_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean _bfd_xcoff_bfd_final_link
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean _bfd_xcoff_slurp_symbol_table
- PARAMS ((bfd *));
-extern long _bfd_xcoff_get_symbol_table
- PARAMS ((bfd *, asymbol **));
-extern asymbol *_bfd_xcoff_make_empty_symbol
- PARAMS ((bfd *));
-extern long _bfd_xcoff_get_symbol_table_upper_bound
- PARAMS ((bfd *));
-extern void _bfd_xcoff_print_symbol
- PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
-extern void _bfd_xcoff_get_symbol_info
- PARAMS ((bfd *, asymbol *, symbol_info *));
-extern long _bfd_xcoff_canonicalize_reloc
- PARAMS((bfd *, sec_ptr, arelent **, asymbol **));
-extern reloc_howto_type *_bfd_xcoff_rtype_to_howto
- PARAMS ((bfd *, asection *, struct internal_reloc *,
- struct coff_link_hash_entry *, struct internal_syment *,
- bfd_vma *));
-extern boolean _bfd_xcoff_set_section_contents
- PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
-boolean _bfd_xcoff_write_object_contents PARAMS ((bfd *));
-
-
-/* XCOFF support routines for the linker. */
-
-extern boolean bfd_xcoff_link_record_set
- PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
- bfd_size_type));
-extern boolean bfd_xcoff_import_symbol
- PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
- bfd_vma, const char *, const char *, const char *, unsigned int));
-extern boolean bfd_xcoff_export_symbol
- PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *));
-extern boolean bfd_xcoff_link_count_reloc
- PARAMS ((bfd *, struct bfd_link_info *, const char *));
-extern boolean bfd_xcoff_record_link_assignment
- PARAMS ((bfd *, struct bfd_link_info *, const char *));
-extern boolean bfd_xcoff_size_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *, const char *, const char *,
- unsigned long, unsigned long, unsigned long, boolean,
- int, boolean, boolean, struct sec **));
-extern boolean xcoff_slurp_reloc_table
- PARAMS ((bfd *, asection *, asymbol **));
+ ((xcoff_backend (a)->_xcoff_loader_reloc_offset((a), (b))))
+
+#define bfd_xcoff_glink_code(a, b) ((xcoff_backend (a)->_xcoff_glink_code[(b)]))
+#define bfd_xcoff_glink_code_size(a) ((xcoff_backend (a)->_xcoff_glink_size))
+
+#define bfd_xcoff_stub_indirect_call_code(a, b) ((xcoff_backend (a)->_xcoff_stub_indirect_call_code[(b)]))
+#define bfd_xcoff_stub_indirect_call_size(a) ((xcoff_backend (a)->_xcoff_stub_indirect_call_size))
+#define bfd_xcoff_stub_shared_call_code(a, b) ((xcoff_backend (a)->_xcoff_stub_shared_call_code[(b)]))
+#define bfd_xcoff_stub_shared_call_size(a) ((xcoff_backend (a)->_xcoff_stub_shared_call_size))
+
+/* Check for the magic number U803XTOCMAGIC or U64_TOCMAGIC for 64 bit
+ targets. */
+#define bfd_xcoff_is_xcoff64(a) \
+ ( (0x01EF == (bfd_xcoff_magic_number (a))) \
+ || (0x01F7 == (bfd_xcoff_magic_number (a))))
+
+/* Check for the magic number U802TOMAGIC for 32 bit targets. */
+#define bfd_xcoff_is_xcoff32(a) (0x01DF == (bfd_xcoff_magic_number (a)))
+
+#define bfd_xcoff_rtinit_size(a) ((xcoff_backend (a)->_xcoff_rtinit_size))
+#define bfd_xcoff_generate_rtinit(a, b, c, d) ((xcoff_backend (a)->_xcoff_generate_rtinit ((a), (b), (c), (d))))
+
+/* Accessor macros for tdata. */
+#define bfd_xcoff_text_align_power(a) ((xcoff_data (a)->text_align_power))
+#define bfd_xcoff_data_align_power(a) ((xcoff_data (a)->data_align_power))
+
+/* xcoff*_ppc_relocate_section macros */
+#define XCOFF_MAX_CALCULATE_RELOCATION (0x32)
+#define XCOFF_MAX_COMPLAIN_OVERFLOW (4)
+/* N_ONES produces N one bits, without overflowing machine arithmetic. */
+#ifdef N_ONES
+#undef N_ONES
+#endif
+#define N_ONES(n) (((((bfd_vma) 1 << ((n) - 1)) - 1) << 1) | 1)
+
+typedef bool xcoff_reloc_function (bfd *, asection *, bfd *,
+ struct internal_reloc *,
+ struct internal_syment *,
+ struct reloc_howto_struct *,
+ bfd_vma, bfd_vma,
+ bfd_vma *, bfd_byte *,
+ struct bfd_link_info *);
+
+typedef bool xcoff_complain_function (bfd *, bfd_vma, bfd_vma,
+ struct reloc_howto_struct *);
+
+extern xcoff_reloc_function *const xcoff_calculate_relocation[];
+extern xcoff_complain_function *const xcoff_complain_overflow[];
+
+#define XCOFF_NO_LONG_SECTION_NAMES (false), bfd_coff_set_long_section_names_disallowed
+
+/* Relocation functions */
+extern xcoff_reloc_function xcoff_reloc_type_noop;
+extern xcoff_reloc_function xcoff_reloc_type_fail;
+extern xcoff_reloc_function xcoff_reloc_type_pos;
+extern xcoff_reloc_function xcoff_reloc_type_neg;
+extern xcoff_reloc_function xcoff_reloc_type_rel;
+extern xcoff_reloc_function xcoff_reloc_type_toc;
+extern xcoff_reloc_function xcoff_reloc_type_ba;
+extern xcoff_reloc_function xcoff_reloc_type_crel;
+extern xcoff_reloc_function xcoff_reloc_type_tls;
+
+/* Structure to describe dwarf sections.
+ Useful to convert from XCOFF section name to flag and vice-versa.
+ Also mark if section has a length field at the beginning. */
+struct xcoff_dwsect_name {
+ /* A XCOFF dwarf section is identified by its name. */
+ unsigned int flag;
+
+ /* Corresponding XCOFF section name. */
+ const char *xcoff_name;
+
+ /* Corresponding DWARF section name. */
+ const char *dwarf_name;
+
+ /* True if size must be prepended. */
+ bool def_size;
+};
+
+/* Number of entries in the array. The number is known and public so that user
+ can 'extend' this array by index. */
+#define XCOFF_DWSECT_NBR_NAMES 11
+
+/* The dwarf sections array. */
+extern const struct xcoff_dwsect_name
+ xcoff_dwsect_names[XCOFF_DWSECT_NBR_NAMES];
+
+/* Structure and functions needed by backend in order to handle
+ stubs created in xcofflink.c. */
+
+enum xcoff_stub_type
+ {
+ xcoff_stub_none,
+ xcoff_stub_indirect_call,
+ xcoff_stub_shared_call
+ };
+
+struct xcoff_stub_hash_entry
+{
+ /* Base hash table entry structure. */
+ struct bfd_hash_entry root;
+
+ enum xcoff_stub_type stub_type;
+
+ /* The hash table entry of the stub's csect. */
+ struct xcoff_link_hash_entry *hcsect;
+
+ /* Offset in the stub's csect. */
+ bfd_vma stub_offset;
+
+ /* The target's section. */
+ asection *target_section;
+
+ /* The target's hash table entry. */
+ struct xcoff_link_hash_entry *htarget;
+};
+
+
+extern enum xcoff_stub_type bfd_xcoff_type_of_stub
+ (asection *, const struct internal_reloc *, bfd_vma,
+ struct xcoff_link_hash_entry *);
+
+extern struct xcoff_stub_hash_entry *bfd_xcoff_get_stub_entry
+ (asection *, struct xcoff_link_hash_entry *, struct bfd_link_info *);