1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22: #include "sysdep.h"
23: #include "bfd.h"
24: #include "libbfd.h"
25: #include "coff/ia64.h"
26: #include "coff/internal.h"
27: #include "coff/pe.h"
28: #include "libcoff.h"
29:
30: #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
31:
32:
33: #define COFF_PAGE_SIZE 0x1000
34:
35: static reloc_howto_type howto_table[] =
36: {
37: EMPTY_HOWTO (0),
38: };
39:
40: #define BADMAG(x) IA64BADMAG(x)
41: #define IA64 1
42:
43: #ifdef COFF_WITH_pep
44: # undef AOUTSZ
45: # define AOUTSZ PEPAOUTSZ
46: # define PEAOUTHDR PEPAOUTHDR
47: #endif
48:
49: #define RTYPE2HOWTO(cache_ptr, dst) \
50: (cache_ptr)->howto = howto_table + (dst)->r_type;
51:
52: #ifdef COFF_WITH_PE
53:
54:
55:
56: static bfd_boolean in_reloc_p PARAMS ((bfd *, reloc_howto_type *));
57:
58: static bfd_boolean
59: in_reloc_p(abfd, howto)
60: bfd * abfd ATTRIBUTE_UNUSED;
61: reloc_howto_type *howto ATTRIBUTE_UNUSED;
62: {
63: return FALSE;
64: }
65: #endif
66:
67: #include "coffcode.h"
68:
69: static const bfd_target *ia64coff_object_p PARAMS ((bfd *));
70:
71: static const bfd_target *
72: ia64coff_object_p (abfd)
73: bfd *abfd;
74: {
75: #ifdef COFF_IMAGE_WITH_PE
76: {
77: struct external_PEI_DOS_hdr dos_hdr;
78: struct external_PEI_IMAGE_hdr image_hdr;
79: file_ptr offset;
80:
81: if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
82: || (bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd)
83: != sizeof (dos_hdr)))
84: {
85: if (bfd_get_error () != bfd_error_system_call)
86: bfd_set_error (bfd_error_wrong_format);
87: return NULL;
88: }
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100: if (H_GET_16 (abfd, dos_hdr.e_magic) != DOSMAGIC)
101: {
102: bfd_set_error (bfd_error_wrong_format);
103: return NULL;
104: }
105:
106: offset = H_GET_32 (abfd, dos_hdr.e_lfanew);
107: if (bfd_seek (abfd, offset, SEEK_SET) != 0
108: || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd)
109: != sizeof (image_hdr)))
110: {
111: if (bfd_get_error () != bfd_error_system_call)
112: bfd_set_error (bfd_error_wrong_format);
113: return NULL;
114: }
115:
116: if (H_GET_32 (abfd, image_hdr.nt_signature)
117: != 0x4550)
118: {
119: bfd_set_error (bfd_error_wrong_format);
120: return NULL;
121: }
122:
123:
124:
125:
126: if (bfd_seek (abfd, offset - sizeof (dos_hdr), SEEK_SET) != 0)
127: {
128: if (bfd_get_error () != bfd_error_system_call)
129: bfd_set_error (bfd_error_wrong_format);
130: return NULL;
131: }
132: }
133: #endif
134:
135: return coff_object_p (abfd);
136: }
137:
138: const bfd_target
139: #ifdef TARGET_SYM
140: TARGET_SYM =
141: #else
142: ia64coff_vec =
143: #endif
144: {
145: #ifdef TARGET_NAME
146: TARGET_NAME,
147: #else
148: "coff-ia64",
149: #endif
150: bfd_target_coff_flavour,
151: BFD_ENDIAN_LITTLE,
152: BFD_ENDIAN_LITTLE,
153:
154: (HAS_RELOC | EXEC_P |
155: HAS_LINENO | HAS_DEBUG |
156: HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
157:
158: #ifndef COFF_WITH_PE
159: (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC
160: | SEC_CODE | SEC_DATA),
161: #else
162: (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC
163: | SEC_CODE | SEC_DATA
164: | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
165: #endif
166:
167: #ifdef TARGET_UNDERSCORE
168: TARGET_UNDERSCORE,
169: #else
170: 0,
171: #endif
172: '/',
173: 15,
174:
175: bfd_getl64, bfd_getl_signed_64, bfd_putl64,
176: bfd_getl32, bfd_getl_signed_32, bfd_putl32,
177: bfd_getl16, bfd_getl_signed_16, bfd_putl16,
178: bfd_getl64, bfd_getl_signed_64, bfd_putl64,
179: bfd_getl32, bfd_getl_signed_32, bfd_putl32,
180: bfd_getl16, bfd_getl_signed_16, bfd_putl16,
181:
182:
183: {_bfd_dummy_target, ia64coff_object_p,
184: bfd_generic_archive_p, ia64coff_object_p},
185: {bfd_false, coff_mkobject, _bfd_generic_mkarchive,
186: bfd_false},
187: {bfd_false, coff_write_object_contents,
188: _bfd_write_archive_contents, bfd_false},
189:
190: BFD_JUMP_TABLE_GENERIC (coff),
191: BFD_JUMP_TABLE_COPY (coff),
192: BFD_JUMP_TABLE_CORE (_bfd_nocore),
193: BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
194: BFD_JUMP_TABLE_SYMBOLS (coff),
195: BFD_JUMP_TABLE_RELOCS (coff),
196: BFD_JUMP_TABLE_WRITE (coff),
197: BFD_JUMP_TABLE_LINK (coff),
198: BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
199:
200: NULL,
201:
202: COFF_SWAP_TABLE
203: };