xref: /openbsd-src/gnu/usr.bin/binutils/bfd/ticoff.h (revision d2201f2f89f0be1a0be6f7568000ed297414a06d)
1*d2201f2fSdrahn /* Copyright 2002 Free Software Foundation, Inc.
2*d2201f2fSdrahn 
3*d2201f2fSdrahn    This file is part of BFD, the Binary File Descriptor library.
4*d2201f2fSdrahn 
5*d2201f2fSdrahn    This program is free software; you can redistribute it and/or modify
6*d2201f2fSdrahn    it under the terms of the GNU General Public License as published by
7*d2201f2fSdrahn    the Free Software Foundation; either version 2 of the License, or
8*d2201f2fSdrahn    (at your option) any later version.
9*d2201f2fSdrahn 
10*d2201f2fSdrahn    This program is distributed in the hope that it will be useful,
11*d2201f2fSdrahn    but WITHOUT ANY WARRANTY; without even the implied warranty of
12*d2201f2fSdrahn    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13*d2201f2fSdrahn    GNU General Public License for more details.
14*d2201f2fSdrahn 
15*d2201f2fSdrahn    You should have received a copy of the GNU General Public License
16*d2201f2fSdrahn    along with this program; if not, write to the Free Software
17*d2201f2fSdrahn    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
18*d2201f2fSdrahn 
19*d2201f2fSdrahn #undef  F_LSYMS
20*d2201f2fSdrahn #define	F_LSYMS		F_LSYMS_TICOFF
21*d2201f2fSdrahn 
22*d2201f2fSdrahn static bfd_boolean
ticoff0_bad_format_hook(abfd,filehdr)23*d2201f2fSdrahn ticoff0_bad_format_hook (abfd, filehdr)
24*d2201f2fSdrahn      bfd *abfd;
25*d2201f2fSdrahn      PTR filehdr;
26*d2201f2fSdrahn {
27*d2201f2fSdrahn   struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
28*d2201f2fSdrahn 
29*d2201f2fSdrahn   if (COFF0_BADMAG (*internal_f))
30*d2201f2fSdrahn     return FALSE;
31*d2201f2fSdrahn 
32*d2201f2fSdrahn   return TRUE;
33*d2201f2fSdrahn }
34*d2201f2fSdrahn 
35*d2201f2fSdrahn static bfd_boolean
ticoff1_bad_format_hook(abfd,filehdr)36*d2201f2fSdrahn ticoff1_bad_format_hook (abfd, filehdr)
37*d2201f2fSdrahn      bfd *abfd ATTRIBUTE_UNUSED;
38*d2201f2fSdrahn      PTR filehdr;
39*d2201f2fSdrahn {
40*d2201f2fSdrahn   struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
41*d2201f2fSdrahn 
42*d2201f2fSdrahn   if (COFF1_BADMAG (*internal_f))
43*d2201f2fSdrahn     return FALSE;
44*d2201f2fSdrahn 
45*d2201f2fSdrahn   return TRUE;
46*d2201f2fSdrahn }
47*d2201f2fSdrahn 
48*d2201f2fSdrahn /* Replace the stock _bfd_coff_is_local_label_name
49*d2201f2fSdrahn    to recognize TI COFF local labels.  */
50*d2201f2fSdrahn static bfd_boolean
ticoff_bfd_is_local_label_name(abfd,name)51*d2201f2fSdrahn ticoff_bfd_is_local_label_name (abfd, name)
52*d2201f2fSdrahn   bfd *abfd ATTRIBUTE_UNUSED;
53*d2201f2fSdrahn   const char *name;
54*d2201f2fSdrahn {
55*d2201f2fSdrahn   if (TICOFF_LOCAL_LABEL_P(name))
56*d2201f2fSdrahn     return TRUE;
57*d2201f2fSdrahn   return FALSE;
58*d2201f2fSdrahn }
59*d2201f2fSdrahn 
60*d2201f2fSdrahn #define coff_bfd_is_local_label_name ticoff_bfd_is_local_label_name
61*d2201f2fSdrahn 
62*d2201f2fSdrahn /* Customize coffcode.h; the default coff_ functions are set up to use COFF2;
63*d2201f2fSdrahn    coff_bad_format_hook uses BADMAG, so set that for COFF2.  The COFF1
64*d2201f2fSdrahn    and COFF0 vectors use custom _bad_format_hook procs instead of setting
65*d2201f2fSdrahn    BADMAG.  */
66*d2201f2fSdrahn #define BADMAG(x) COFF2_BADMAG(x)
67*d2201f2fSdrahn #include "coffcode.h"
68*d2201f2fSdrahn 
69*d2201f2fSdrahn /* COFF0 differs in file/section header size and relocation entry size.  */
70*d2201f2fSdrahn static const bfd_coff_backend_data ticoff0_swap_table =
71*d2201f2fSdrahn {
72*d2201f2fSdrahn   coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in,
73*d2201f2fSdrahn   coff_SWAP_aux_out, coff_SWAP_sym_out,
74*d2201f2fSdrahn   coff_SWAP_lineno_out, coff_SWAP_reloc_out,
75*d2201f2fSdrahn   coff_SWAP_filehdr_out, coff_SWAP_aouthdr_out,
76*d2201f2fSdrahn   coff_SWAP_scnhdr_out,
77*d2201f2fSdrahn   FILHSZ_V0, AOUTSZ, SCNHSZ_V01, SYMESZ, AUXESZ, RELSZ_V0, LINESZ, FILNMLEN,
78*d2201f2fSdrahn #ifdef COFF_LONG_FILENAMES
79*d2201f2fSdrahn   TRUE,
80*d2201f2fSdrahn #else
81*d2201f2fSdrahn   FALSE,
82*d2201f2fSdrahn #endif
83*d2201f2fSdrahn #ifdef COFF_LONG_SECTION_NAMES
84*d2201f2fSdrahn   TRUE,
85*d2201f2fSdrahn #else
86*d2201f2fSdrahn   FALSE,
87*d2201f2fSdrahn #endif
88*d2201f2fSdrahn   COFF_DEFAULT_SECTION_ALIGNMENT_POWER,
89*d2201f2fSdrahn   coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in,
90*d2201f2fSdrahn   coff_SWAP_reloc_in, ticoff0_bad_format_hook, coff_set_arch_mach_hook,
91*d2201f2fSdrahn   coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook,
92*d2201f2fSdrahn   coff_slurp_symbol_table, symname_in_debug_hook, coff_pointerize_aux_hook,
93*d2201f2fSdrahn   coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate,
94*d2201f2fSdrahn   coff_classify_symbol, coff_compute_section_file_positions,
95*d2201f2fSdrahn   coff_start_final_link, coff_relocate_section, coff_rtype_to_howto,
96*d2201f2fSdrahn   coff_adjust_symndx, coff_link_add_one_symbol,
97*d2201f2fSdrahn   coff_link_output_has_begun, coff_final_link_postscript
98*d2201f2fSdrahn };
99*d2201f2fSdrahn 
100*d2201f2fSdrahn /* COFF1 differs in section header size.  */
101*d2201f2fSdrahn static const bfd_coff_backend_data ticoff1_swap_table =
102*d2201f2fSdrahn {
103*d2201f2fSdrahn   coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in,
104*d2201f2fSdrahn   coff_SWAP_aux_out, coff_SWAP_sym_out,
105*d2201f2fSdrahn   coff_SWAP_lineno_out, coff_SWAP_reloc_out,
106*d2201f2fSdrahn   coff_SWAP_filehdr_out, coff_SWAP_aouthdr_out,
107*d2201f2fSdrahn   coff_SWAP_scnhdr_out,
108*d2201f2fSdrahn   FILHSZ, AOUTSZ, SCNHSZ_V01, SYMESZ, AUXESZ, RELSZ, LINESZ, FILNMLEN,
109*d2201f2fSdrahn #ifdef COFF_LONG_FILENAMES
110*d2201f2fSdrahn   TRUE,
111*d2201f2fSdrahn #else
112*d2201f2fSdrahn   FALSE,
113*d2201f2fSdrahn #endif
114*d2201f2fSdrahn #ifdef COFF_LONG_SECTION_NAMES
115*d2201f2fSdrahn   TRUE,
116*d2201f2fSdrahn #else
117*d2201f2fSdrahn   FALSE,
118*d2201f2fSdrahn #endif
119*d2201f2fSdrahn   COFF_DEFAULT_SECTION_ALIGNMENT_POWER,
120*d2201f2fSdrahn   coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in,
121*d2201f2fSdrahn   coff_SWAP_reloc_in, ticoff1_bad_format_hook, coff_set_arch_mach_hook,
122*d2201f2fSdrahn   coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook,
123*d2201f2fSdrahn   coff_slurp_symbol_table, symname_in_debug_hook, coff_pointerize_aux_hook,
124*d2201f2fSdrahn   coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate,
125*d2201f2fSdrahn   coff_classify_symbol, coff_compute_section_file_positions,
126*d2201f2fSdrahn   coff_start_final_link, coff_relocate_section, coff_rtype_to_howto,
127*d2201f2fSdrahn   coff_adjust_symndx, coff_link_add_one_symbol,
128*d2201f2fSdrahn   coff_link_output_has_begun, coff_final_link_postscript
129*d2201f2fSdrahn };
130*d2201f2fSdrahn 
131