00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "bfd.h"
00022 #include "sysdep.h"
00023 #include "libbfd.h"
00024 #include "coff/ia64.h"
00025 #include "coff/internal.h"
00026 #include "coff/pe.h"
00027 #include "libcoff.h"
00028
00029 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
00030
00031
00032 #define COFF_PAGE_SIZE 0x1000
00033
00034 static reloc_howto_type howto_table[] =
00035 {
00036 EMPTY_HOWTO (0),
00037 };
00038
00039 #define BADMAG(x) IA64BADMAG(x)
00040 #define IA64 1
00041
00042 #ifdef COFF_WITH_pep
00043 # undef AOUTSZ
00044 # define AOUTSZ PEPAOUTSZ
00045 # define PEAOUTHDR PEPAOUTHDR
00046 #endif
00047
00048 #define RTYPE2HOWTO(cache_ptr, dst) \
00049 (cache_ptr)->howto = howto_table + (dst)->r_type;
00050
00051 #ifdef COFF_WITH_PE
00052
00053
00054
00055 static bfd_boolean in_reloc_p PARAMS ((bfd *, reloc_howto_type *));
00056
00057 static bfd_boolean
00058 in_reloc_p(abfd, howto)
00059 bfd * abfd ATTRIBUTE_UNUSED;
00060 reloc_howto_type *howto ATTRIBUTE_UNUSED;
00061 {
00062 return FALSE;
00063 }
00064 #endif
00065
00066 #include "coffcode.h"
00067
00068 static const bfd_target *ia64coff_object_p PARAMS ((bfd *));
00069
00070 static const bfd_target *
00071 ia64coff_object_p (abfd)
00072 bfd *abfd;
00073 {
00074 #ifdef COFF_IMAGE_WITH_PE
00075 {
00076 struct external_PEI_DOS_hdr dos_hdr;
00077 struct external_PEI_IMAGE_hdr image_hdr;
00078 file_ptr offset;
00079
00080 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
00081 || (bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd)
00082 != sizeof (dos_hdr)))
00083 {
00084 if (bfd_get_error () != bfd_error_system_call)
00085 bfd_set_error (bfd_error_wrong_format);
00086 return NULL;
00087 }
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 if (H_GET_16 (abfd, dos_hdr.e_magic) != DOSMAGIC)
00100 {
00101 bfd_set_error (bfd_error_wrong_format);
00102 return NULL;
00103 }
00104
00105 offset = H_GET_32 (abfd, dos_hdr.e_lfanew);
00106 if (bfd_seek (abfd, offset, SEEK_SET) != 0
00107 || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd)
00108 != sizeof (image_hdr)))
00109 {
00110 if (bfd_get_error () != bfd_error_system_call)
00111 bfd_set_error (bfd_error_wrong_format);
00112 return NULL;
00113 }
00114
00115 if (H_GET_32 (abfd, image_hdr.nt_signature)
00116 != 0x4550)
00117 {
00118 bfd_set_error (bfd_error_wrong_format);
00119 return NULL;
00120 }
00121
00122
00123
00124
00125 if (bfd_seek (abfd, offset - sizeof (dos_hdr), SEEK_SET) != 0)
00126 {
00127 if (bfd_get_error () != bfd_error_system_call)
00128 bfd_set_error (bfd_error_wrong_format);
00129 return NULL;
00130 }
00131 }
00132 #endif
00133
00134 return coff_object_p (abfd);
00135 }
00136
00137 const bfd_target
00138 #ifdef TARGET_SYM
00139 TARGET_SYM =
00140 #else
00141 ia64coff_vec =
00142 #endif
00143 {
00144 #ifdef TARGET_NAME
00145 TARGET_NAME,
00146 #else
00147 "coff-ia64",
00148 #endif
00149 bfd_target_coff_flavour,
00150 BFD_ENDIAN_LITTLE,
00151 BFD_ENDIAN_LITTLE,
00152
00153 (HAS_RELOC | EXEC_P |
00154 HAS_LINENO | HAS_DEBUG |
00155 HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
00156
00157 #ifndef COFF_WITH_PE
00158 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC
00159 | SEC_CODE | SEC_DATA),
00160 #else
00161 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC
00162 | SEC_CODE | SEC_DATA
00163 | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
00164 #endif
00165
00166 #ifdef TARGET_UNDERSCORE
00167 TARGET_UNDERSCORE,
00168 #else
00169 0,
00170 #endif
00171 '/',
00172 15,
00173
00174 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
00175 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
00176 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
00177 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
00178 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
00179 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
00180
00181
00182 {_bfd_dummy_target, ia64coff_object_p,
00183 bfd_generic_archive_p, ia64coff_object_p},
00184 {bfd_false, coff_mkobject, _bfd_generic_mkarchive,
00185 bfd_false},
00186 {bfd_false, coff_write_object_contents,
00187 _bfd_write_archive_contents, bfd_false},
00188
00189 BFD_JUMP_TABLE_GENERIC (coff),
00190 BFD_JUMP_TABLE_COPY (coff),
00191 BFD_JUMP_TABLE_CORE (_bfd_nocore),
00192 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
00193 BFD_JUMP_TABLE_SYMBOLS (coff),
00194 BFD_JUMP_TABLE_RELOCS (coff),
00195 BFD_JUMP_TABLE_WRITE (coff),
00196 BFD_JUMP_TABLE_LINK (coff),
00197 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
00198
00199 NULL,
00200
00201 COFF_SWAP_TABLE
00202 };