/src/binutils-gdb/bfd/peicode.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* Support for the generic parts of PE/PEI, for BFD. |
2 | | Copyright (C) 1995-2023 Free Software Foundation, Inc. |
3 | | Written by Cygnus Solutions. |
4 | | |
5 | | This file is part of BFD, the Binary File Descriptor library. |
6 | | |
7 | | This program is free software; you can redistribute it and/or modify |
8 | | it under the terms of the GNU General Public License as published by |
9 | | the Free Software Foundation; either version 3 of the License, or |
10 | | (at your option) any later version. |
11 | | |
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 | | |
17 | | You should have received a copy of the GNU General Public License |
18 | | along with this program; if not, write to the Free Software |
19 | | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
20 | | MA 02110-1301, USA. */ |
21 | | |
22 | | |
23 | | /* Most of this hacked by Steve Chamberlain, |
24 | | sac@cygnus.com |
25 | | |
26 | | PE/PEI rearrangement (and code added): Donn Terry |
27 | | Softway Systems, Inc. */ |
28 | | |
29 | | /* Hey look, some documentation [and in a place you expect to find it]! |
30 | | |
31 | | The main reference for the pei format is "Microsoft Portable Executable |
32 | | and Common Object File Format Specification 4.1". Get it if you need to |
33 | | do some serious hacking on this code. |
34 | | |
35 | | Another reference: |
36 | | "Peering Inside the PE: A Tour of the Win32 Portable Executable |
37 | | File Format", MSJ 1994, Volume 9. |
38 | | |
39 | | The *sole* difference between the pe format and the pei format is that the |
40 | | latter has an MSDOS 2.0 .exe header on the front that prints the message |
41 | | "This app must be run under Windows." (or some such). |
42 | | (FIXME: Whether that statement is *really* true or not is unknown. |
43 | | Are there more subtle differences between pe and pei formats? |
44 | | For now assume there aren't. If you find one, then for God sakes |
45 | | document it here!) |
46 | | |
47 | | The Microsoft docs use the word "image" instead of "executable" because |
48 | | the former can also refer to a DLL (shared library). Confusion can arise |
49 | | because the `i' in `pei' also refers to "image". The `pe' format can |
50 | | also create images (i.e. executables), it's just that to run on a win32 |
51 | | system you need to use the pei format. |
52 | | |
53 | | FIXME: Please add more docs here so the next poor fool that has to hack |
54 | | on this code has a chance of getting something accomplished without |
55 | | wasting too much time. */ |
56 | | |
57 | | #include "libpei.h" |
58 | | |
59 | | static bool (*pe_saved_coff_bfd_print_private_bfd_data) (bfd *, void *) = |
60 | | #ifndef coff_bfd_print_private_bfd_data |
61 | | NULL; |
62 | | #else |
63 | | coff_bfd_print_private_bfd_data; |
64 | | #undef coff_bfd_print_private_bfd_data |
65 | | #endif |
66 | | |
67 | | static bool pe_print_private_bfd_data (bfd *, void *); |
68 | | #define coff_bfd_print_private_bfd_data pe_print_private_bfd_data |
69 | | |
70 | | static bool (*pe_saved_coff_bfd_copy_private_bfd_data) (bfd *, bfd *) = |
71 | | #ifndef coff_bfd_copy_private_bfd_data |
72 | | NULL; |
73 | | #else |
74 | | coff_bfd_copy_private_bfd_data; |
75 | | #undef coff_bfd_copy_private_bfd_data |
76 | | #endif |
77 | | |
78 | | static bool pe_bfd_copy_private_bfd_data (bfd *, bfd *); |
79 | | #define coff_bfd_copy_private_bfd_data pe_bfd_copy_private_bfd_data |
80 | | |
81 | | #define coff_mkobject pe_mkobject |
82 | | #define coff_mkobject_hook pe_mkobject_hook |
83 | | |
84 | | #ifdef COFF_IMAGE_WITH_PE |
85 | | /* This structure contains static variables used by the ILF code. */ |
86 | | typedef asection * asection_ptr; |
87 | | |
88 | | typedef struct |
89 | | { |
90 | | bfd * abfd; |
91 | | bfd_byte * data; |
92 | | struct bfd_in_memory * bim; |
93 | | unsigned short magic; |
94 | | |
95 | | arelent * reltab; |
96 | | unsigned int relcount; |
97 | | |
98 | | coff_symbol_type * sym_cache; |
99 | | coff_symbol_type * sym_ptr; |
100 | | unsigned int sym_index; |
101 | | |
102 | | unsigned int * sym_table; |
103 | | unsigned int * table_ptr; |
104 | | |
105 | | combined_entry_type * native_syms; |
106 | | combined_entry_type * native_ptr; |
107 | | |
108 | | coff_symbol_type ** sym_ptr_table; |
109 | | coff_symbol_type ** sym_ptr_ptr; |
110 | | |
111 | | unsigned int sec_index; |
112 | | |
113 | | char * string_table; |
114 | | char * string_ptr; |
115 | | char * end_string_ptr; |
116 | | |
117 | | SYMENT * esym_table; |
118 | | SYMENT * esym_ptr; |
119 | | |
120 | | struct internal_reloc * int_reltab; |
121 | | } |
122 | | pe_ILF_vars; |
123 | | #endif /* COFF_IMAGE_WITH_PE */ |
124 | | |
125 | | bfd_cleanup coff_real_object_p |
126 | | (bfd *, unsigned, struct internal_filehdr *, struct internal_aouthdr *); |
127 | | |
128 | | #ifndef NO_COFF_RELOCS |
129 | | static void |
130 | | coff_swap_reloc_in (bfd * abfd, void * src, void * dst) |
131 | 214k | { |
132 | 214k | RELOC *reloc_src = (RELOC *) src; |
133 | 214k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; |
134 | | |
135 | 214k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); |
136 | 214k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); |
137 | 214k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); |
138 | | #ifdef SWAP_IN_RELOC_OFFSET |
139 | 15.9k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); |
140 | | #endif |
141 | 214k | } pei-i386.c:coff_swap_reloc_in Line | Count | Source | 131 | 87 | { | 132 | 87 | RELOC *reloc_src = (RELOC *) src; | 133 | 87 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 87 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 87 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 87 | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | | #ifdef SWAP_IN_RELOC_OFFSET | 139 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | | #endif | 141 | 87 | } |
pe-x86_64.c:coff_swap_reloc_in Line | Count | Source | 131 | 4.63k | { | 132 | 4.63k | RELOC *reloc_src = (RELOC *) src; | 133 | 4.63k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 4.63k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 4.63k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 4.63k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | | #ifdef SWAP_IN_RELOC_OFFSET | 139 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | | #endif | 141 | 4.63k | } |
pei-x86_64.c:coff_swap_reloc_in Line | Count | Source | 131 | 65 | { | 132 | 65 | RELOC *reloc_src = (RELOC *) src; | 133 | 65 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 65 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 65 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 65 | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | | #ifdef SWAP_IN_RELOC_OFFSET | 139 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | | #endif | 141 | 65 | } |
pei-aarch64.c:coff_swap_reloc_in Line | Count | Source | 131 | 46 | { | 132 | 46 | RELOC *reloc_src = (RELOC *) src; | 133 | 46 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 46 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 46 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 46 | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | | #ifdef SWAP_IN_RELOC_OFFSET | 139 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | | #endif | 141 | 46 | } |
pe-aarch64.c:coff_swap_reloc_in Line | Count | Source | 131 | 11.0k | { | 132 | 11.0k | RELOC *reloc_src = (RELOC *) src; | 133 | 11.0k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 11.0k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 11.0k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 11.0k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | | #ifdef SWAP_IN_RELOC_OFFSET | 139 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | | #endif | 141 | 11.0k | } |
pei-ia64.c:coff_swap_reloc_in Line | Count | Source | 131 | 88 | { | 132 | 88 | RELOC *reloc_src = (RELOC *) src; | 133 | 88 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 88 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 88 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 88 | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | | #ifdef SWAP_IN_RELOC_OFFSET | 139 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | | #endif | 141 | 88 | } |
pei-loongarch64.c:coff_swap_reloc_in Line | Count | Source | 131 | 40 | { | 132 | 40 | RELOC *reloc_src = (RELOC *) src; | 133 | 40 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 40 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 40 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 40 | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 40 | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 40 | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 40 | #endif | 141 | 40 | } |
pe-arm-wince.c:coff_swap_reloc_in Line | Count | Source | 131 | 53 | { | 132 | 53 | RELOC *reloc_src = (RELOC *) src; | 133 | 53 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 53 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 53 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 53 | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 53 | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 53 | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 53 | #endif | 141 | 53 | } |
pe-arm.c:coff_swap_reloc_in Line | Count | Source | 131 | 53 | { | 132 | 53 | RELOC *reloc_src = (RELOC *) src; | 133 | 53 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 53 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 53 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 53 | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 53 | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 53 | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 53 | #endif | 141 | 53 | } |
pe-i386.c:coff_swap_reloc_in Line | Count | Source | 131 | 176k | { | 132 | 176k | RELOC *reloc_src = (RELOC *) src; | 133 | 176k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 176k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 176k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 176k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | | #ifdef SWAP_IN_RELOC_OFFSET | 139 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | | #endif | 141 | 176k | } |
pe-mcore.c:coff_swap_reloc_in Line | Count | Source | 131 | 15.6k | { | 132 | 15.6k | RELOC *reloc_src = (RELOC *) src; | 133 | 15.6k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 15.6k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 15.6k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 15.6k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 15.6k | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 15.6k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 15.6k | #endif | 141 | 15.6k | } |
pe-sh.c:coff_swap_reloc_in Line | Count | Source | 131 | 5.86k | { | 132 | 5.86k | RELOC *reloc_src = (RELOC *) src; | 133 | 5.86k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 5.86k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 5.86k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 5.86k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | | #ifdef SWAP_IN_RELOC_OFFSET | 139 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | | #endif | 141 | 5.86k | } |
pei-arm-wince.c:coff_swap_reloc_in Line | Count | Source | 131 | 68 | { | 132 | 68 | RELOC *reloc_src = (RELOC *) src; | 133 | 68 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 68 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 68 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 68 | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 68 | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 68 | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 68 | #endif | 141 | 68 | } |
pei-arm.c:coff_swap_reloc_in Line | Count | Source | 131 | 94 | { | 132 | 94 | RELOC *reloc_src = (RELOC *) src; | 133 | 94 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 94 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 94 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 94 | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 94 | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 94 | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 94 | #endif | 141 | 94 | } |
pei-mcore.c:coff_swap_reloc_in Line | Count | Source | 131 | 43 | { | 132 | 43 | RELOC *reloc_src = (RELOC *) src; | 133 | 43 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 43 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 43 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 43 | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 43 | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 43 | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 43 | #endif | 141 | 43 | } |
pei-sh.c:coff_swap_reloc_in Line | Count | Source | 131 | 101 | { | 132 | 101 | RELOC *reloc_src = (RELOC *) src; | 133 | 101 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 101 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 101 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 101 | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | | #ifdef SWAP_IN_RELOC_OFFSET | 139 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | | #endif | 141 | 101 | } |
|
142 | | |
143 | | static unsigned int |
144 | | coff_swap_reloc_out (bfd * abfd, void * src, void * dst) |
145 | 0 | { |
146 | 0 | struct internal_reloc *reloc_src = (struct internal_reloc *) src; |
147 | 0 | struct external_reloc *reloc_dst = (struct external_reloc *) dst; |
148 | |
|
149 | 0 | H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr); |
150 | 0 | H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx); |
151 | 0 | H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type); |
152 | |
|
153 | | #ifdef SWAP_OUT_RELOC_OFFSET |
154 | 0 | SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset); |
155 | | #endif |
156 | | #ifdef SWAP_OUT_RELOC_EXTRA |
157 | | SWAP_OUT_RELOC_EXTRA (abfd, reloc_src, reloc_dst); |
158 | | #endif |
159 | 0 | return RELSZ; |
160 | 0 | } Unexecuted instantiation: pei-i386.c:coff_swap_reloc_out Unexecuted instantiation: pe-x86_64.c:coff_swap_reloc_out Unexecuted instantiation: pei-x86_64.c:coff_swap_reloc_out Unexecuted instantiation: pei-aarch64.c:coff_swap_reloc_out Unexecuted instantiation: pe-aarch64.c:coff_swap_reloc_out Unexecuted instantiation: pei-ia64.c:coff_swap_reloc_out Unexecuted instantiation: pei-loongarch64.c:coff_swap_reloc_out Unexecuted instantiation: pe-arm-wince.c:coff_swap_reloc_out Unexecuted instantiation: pe-arm.c:coff_swap_reloc_out Unexecuted instantiation: pe-i386.c:coff_swap_reloc_out Unexecuted instantiation: pe-mcore.c:coff_swap_reloc_out Unexecuted instantiation: pe-sh.c:coff_swap_reloc_out Unexecuted instantiation: pei-arm-wince.c:coff_swap_reloc_out Unexecuted instantiation: pei-arm.c:coff_swap_reloc_out Unexecuted instantiation: pei-mcore.c:coff_swap_reloc_out Unexecuted instantiation: pei-sh.c:coff_swap_reloc_out |
161 | | #endif /* not NO_COFF_RELOCS */ |
162 | | |
163 | | #ifdef COFF_IMAGE_WITH_PE |
164 | | #undef FILHDR |
165 | 27.2k | #define FILHDR struct external_PEI_IMAGE_hdr |
166 | | #endif |
167 | | |
168 | | static void |
169 | | coff_swap_filehdr_in (bfd * abfd, void * src, void * dst) |
170 | 244k | { |
171 | 244k | FILHDR *filehdr_src = (FILHDR *) src; |
172 | 244k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; |
173 | | |
174 | 244k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); |
175 | 244k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); |
176 | 244k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); |
177 | 244k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); |
178 | 244k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); |
179 | 244k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); |
180 | | |
181 | | /* Other people's tools sometimes generate headers with an nsyms but |
182 | | a zero symptr. */ |
183 | 244k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) |
184 | 27.6k | { |
185 | 27.6k | filehdr_dst->f_nsyms = 0; |
186 | 27.6k | filehdr_dst->f_flags |= F_LSYMS; |
187 | 27.6k | } |
188 | | |
189 | 244k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); |
190 | 244k | } pei-i386.c:coff_swap_filehdr_in Line | Count | Source | 170 | 3.19k | { | 171 | 3.19k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 3.19k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 3.19k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 3.19k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 3.19k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 3.19k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 3.19k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 3.19k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 3.19k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 122 | { | 185 | 122 | filehdr_dst->f_nsyms = 0; | 186 | 122 | filehdr_dst->f_flags |= F_LSYMS; | 187 | 122 | } | 188 | | | 189 | 3.19k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 3.19k | } |
pe-x86_64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 22.0k | { | 171 | 22.0k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 22.0k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 22.0k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 22.0k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 22.0k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 22.0k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 22.0k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 22.0k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 22.0k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 2.66k | { | 185 | 2.66k | filehdr_dst->f_nsyms = 0; | 186 | 2.66k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 2.66k | } | 188 | | | 189 | 22.0k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 22.0k | } |
pei-x86_64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 3.12k | { | 171 | 3.12k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 3.12k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 3.12k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 3.12k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 3.12k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 3.12k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 3.12k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 3.12k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 3.12k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 127 | { | 185 | 127 | filehdr_dst->f_nsyms = 0; | 186 | 127 | filehdr_dst->f_flags |= F_LSYMS; | 187 | 127 | } | 188 | | | 189 | 3.12k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 3.12k | } |
pei-aarch64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 2.99k | { | 171 | 2.99k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 2.99k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 2.99k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 2.99k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 2.99k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 2.99k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 2.99k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 2.99k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 2.99k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 116 | { | 185 | 116 | filehdr_dst->f_nsyms = 0; | 186 | 116 | filehdr_dst->f_flags |= F_LSYMS; | 187 | 116 | } | 188 | | | 189 | 2.99k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 2.99k | } |
pe-aarch64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 21.6k | { | 171 | 21.6k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 21.6k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 21.6k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 21.6k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 21.6k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 21.6k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 21.6k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 21.6k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 21.6k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 2.65k | { | 185 | 2.65k | filehdr_dst->f_nsyms = 0; | 186 | 2.65k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 2.65k | } | 188 | | | 189 | 21.6k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 21.6k | } |
pei-ia64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 2.57k | { | 171 | 2.57k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 2.57k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 2.57k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 2.57k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 2.57k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 2.57k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 2.57k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 2.57k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 2.57k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 80 | { | 185 | 80 | filehdr_dst->f_nsyms = 0; | 186 | 80 | filehdr_dst->f_flags |= F_LSYMS; | 187 | 80 | } | 188 | | | 189 | 2.57k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 2.57k | } |
pei-loongarch64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 2.99k | { | 171 | 2.99k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 2.99k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 2.99k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 2.99k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 2.99k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 2.99k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 2.99k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 2.99k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 2.99k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 116 | { | 185 | 116 | filehdr_dst->f_nsyms = 0; | 186 | 116 | filehdr_dst->f_flags |= F_LSYMS; | 187 | 116 | } | 188 | | | 189 | 2.99k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 2.99k | } |
pe-arm-wince.c:coff_swap_filehdr_in Line | Count | Source | 170 | 43.2k | { | 171 | 43.2k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 43.2k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 43.2k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 43.2k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 43.2k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 43.2k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 43.2k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 43.2k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 43.2k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 5.31k | { | 185 | 5.31k | filehdr_dst->f_nsyms = 0; | 186 | 5.31k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 5.31k | } | 188 | | | 189 | 43.2k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 43.2k | } |
pe-arm.c:coff_swap_filehdr_in Line | Count | Source | 170 | 43.2k | { | 171 | 43.2k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 43.2k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 43.2k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 43.2k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 43.2k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 43.2k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 43.2k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 43.2k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 43.2k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 5.31k | { | 185 | 5.31k | filehdr_dst->f_nsyms = 0; | 186 | 5.31k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 5.31k | } | 188 | | | 189 | 43.2k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 43.2k | } |
pe-i386.c:coff_swap_filehdr_in Line | Count | Source | 170 | 21.6k | { | 171 | 21.6k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 21.6k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 21.6k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 21.6k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 21.6k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 21.6k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 21.6k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 21.6k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 21.6k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 2.65k | { | 185 | 2.65k | filehdr_dst->f_nsyms = 0; | 186 | 2.65k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 2.65k | } | 188 | | | 189 | 21.6k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 21.6k | } |
pe-mcore.c:coff_swap_filehdr_in Line | Count | Source | 170 | 43.2k | { | 171 | 43.2k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 43.2k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 43.2k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 43.2k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 43.2k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 43.2k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 43.2k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 43.2k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 43.2k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 5.31k | { | 185 | 5.31k | filehdr_dst->f_nsyms = 0; | 186 | 5.31k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 5.31k | } | 188 | | | 189 | 43.2k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 43.2k | } |
pe-sh.c:coff_swap_filehdr_in Line | Count | Source | 170 | 21.6k | { | 171 | 21.6k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 21.6k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 21.6k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 21.6k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 21.6k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 21.6k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 21.6k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 21.6k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 21.6k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 2.65k | { | 185 | 2.65k | filehdr_dst->f_nsyms = 0; | 186 | 2.65k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 2.65k | } | 188 | | | 189 | 21.6k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 21.6k | } |
pei-arm-wince.c:coff_swap_filehdr_in Line | Count | Source | 170 | 3.13k | { | 171 | 3.13k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 3.13k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 3.13k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 3.13k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 3.13k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 3.13k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 3.13k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 3.13k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 3.13k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 118 | { | 185 | 118 | filehdr_dst->f_nsyms = 0; | 186 | 118 | filehdr_dst->f_flags |= F_LSYMS; | 187 | 118 | } | 188 | | | 189 | 3.13k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 3.13k | } |
pei-arm.c:coff_swap_filehdr_in Line | Count | Source | 170 | 3.13k | { | 171 | 3.13k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 3.13k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 3.13k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 3.13k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 3.13k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 3.13k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 3.13k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 3.13k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 3.13k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 118 | { | 185 | 118 | filehdr_dst->f_nsyms = 0; | 186 | 118 | filehdr_dst->f_flags |= F_LSYMS; | 187 | 118 | } | 188 | | | 189 | 3.13k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 3.13k | } |
pei-mcore.c:coff_swap_filehdr_in Line | Count | Source | 170 | 3.13k | { | 171 | 3.13k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 3.13k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 3.13k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 3.13k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 3.13k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 3.13k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 3.13k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 3.13k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 3.13k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 118 | { | 185 | 118 | filehdr_dst->f_nsyms = 0; | 186 | 118 | filehdr_dst->f_flags |= F_LSYMS; | 187 | 118 | } | 188 | | | 189 | 3.13k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 3.13k | } |
pei-sh.c:coff_swap_filehdr_in Line | Count | Source | 170 | 2.99k | { | 171 | 2.99k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 2.99k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 2.99k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 2.99k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 2.99k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 2.99k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 2.99k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 2.99k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 2.99k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 116 | { | 185 | 116 | filehdr_dst->f_nsyms = 0; | 186 | 116 | filehdr_dst->f_flags |= F_LSYMS; | 187 | 116 | } | 188 | | | 189 | 2.99k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 2.99k | } |
|
191 | | |
192 | | #ifdef COFF_IMAGE_WITH_PE |
193 | | # define coff_swap_filehdr_out _bfd_XXi_only_swap_filehdr_out |
194 | | #elif defined COFF_WITH_peAArch64 |
195 | | # define coff_swap_filehdr_out _bfd_XX_only_swap_filehdr_out |
196 | | #elif defined COFF_WITH_pex64 |
197 | | # define coff_swap_filehdr_out _bfd_pex64_only_swap_filehdr_out |
198 | | #elif defined COFF_WITH_pep |
199 | | # define coff_swap_filehdr_out _bfd_pep_only_swap_filehdr_out |
200 | | #else |
201 | | # define coff_swap_filehdr_out _bfd_pe_only_swap_filehdr_out |
202 | | #endif |
203 | | |
204 | | static void |
205 | | coff_swap_scnhdr_in (bfd * abfd, void * ext, void * in) |
206 | 55.3k | { |
207 | 55.3k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; |
208 | 55.3k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; |
209 | | |
210 | 55.3k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); |
211 | | |
212 | 55.3k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); |
213 | 55.3k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); |
214 | 55.3k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); |
215 | 55.3k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); |
216 | 55.3k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); |
217 | 55.3k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); |
218 | 55.3k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); |
219 | | |
220 | | /* MS handles overflow of line numbers by carrying into the reloc |
221 | | field (it appears). Since it's supposed to be zero for PE |
222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ |
223 | | #ifdef COFF_IMAGE_WITH_PE |
224 | 29.1k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) |
225 | 29.1k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); |
226 | | scnhdr_int->s_nreloc = 0; |
227 | | #else |
228 | 26.2k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); |
229 | 26.2k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); |
230 | | #endif |
231 | | |
232 | 55.3k | if (scnhdr_int->s_vaddr != 0) |
233 | 33.9k | { |
234 | 33.9k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; |
235 | | /* Do not cut upper 32-bits for 64-bit vma. */ |
236 | | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) |
237 | | scnhdr_int->s_vaddr &= 0xffffffff; |
238 | | #endif |
239 | 33.9k | } |
240 | | |
241 | 55.3k | #ifndef COFF_NO_HACK_SCNHDR_SIZE |
242 | | /* If this section holds uninitialized data and is from an object file |
243 | | or from an executable image that has not initialized the field, |
244 | | or if the image is an executable file and the physical size is padded, |
245 | | use the virtual size (stored in s_paddr) instead. */ |
246 | 55.3k | if (scnhdr_int->s_paddr > 0 |
247 | 55.3k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 |
248 | 37.8k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) |
249 | 37.8k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) |
250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, |
251 | | coff_set_alignment_hook stores s_paddr in virt_size, which |
252 | | only works if it correctly holds the virtual size of the |
253 | | section. */ |
254 | 7.60k | scnhdr_int->s_size = scnhdr_int->s_paddr; |
255 | 55.3k | #endif |
256 | 55.3k | } pei-i386.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 3.24k | { | 207 | 3.24k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 3.24k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 3.24k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 3.24k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 3.24k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 3.24k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 3.24k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 3.24k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 3.24k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 3.24k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 3.24k | #ifdef COFF_IMAGE_WITH_PE | 224 | 3.24k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 3.24k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 3.24k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 3.24k | if (scnhdr_int->s_vaddr != 0) | 233 | 1.44k | { | 234 | 1.44k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 1.44k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 1.44k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 1.44k | #endif | 239 | 1.44k | } | 240 | | | 241 | 3.24k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 3.24k | if (scnhdr_int->s_paddr > 0 | 247 | 3.24k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 1.66k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 1.66k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 347 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 3.24k | #endif | 256 | 3.24k | } |
pe-x86_64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 5.30k | { | 207 | 5.30k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 5.30k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 5.30k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 5.30k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 5.30k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 5.30k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 5.30k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 5.30k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 5.30k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 5.30k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | | #ifdef COFF_IMAGE_WITH_PE | 224 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | 5.30k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 5.30k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 5.30k | #endif | 231 | | | 232 | 5.30k | if (scnhdr_int->s_vaddr != 0) | 233 | 3.03k | { | 234 | 3.03k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | | #endif | 239 | 3.03k | } | 240 | | | 241 | 5.30k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 5.30k | if (scnhdr_int->s_paddr > 0 | 247 | 5.30k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 3.18k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 3.18k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 250 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 5.30k | #endif | 256 | 5.30k | } |
pei-x86_64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 3.26k | { | 207 | 3.26k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 3.26k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 3.26k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 3.26k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 3.26k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 3.26k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 3.26k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 3.26k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 3.26k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 3.26k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 3.26k | #ifdef COFF_IMAGE_WITH_PE | 224 | 3.26k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 3.26k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 3.26k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 3.26k | if (scnhdr_int->s_vaddr != 0) | 233 | 1.38k | { | 234 | 1.38k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | | #endif | 239 | 1.38k | } | 240 | | | 241 | 3.26k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 3.26k | if (scnhdr_int->s_paddr > 0 | 247 | 3.26k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 1.66k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 1.66k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 389 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 3.26k | #endif | 256 | 3.26k | } |
pei-aarch64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 1.73k | { | 207 | 1.73k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 1.73k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 1.73k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 1.73k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 1.73k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 1.73k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 1.73k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 1.73k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 1.73k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 1.73k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 1.73k | #ifdef COFF_IMAGE_WITH_PE | 224 | 1.73k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 1.73k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 1.73k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 1.73k | if (scnhdr_int->s_vaddr != 0) | 233 | 867 | { | 234 | 867 | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | | #endif | 239 | 867 | } | 240 | | | 241 | 1.73k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 1.73k | if (scnhdr_int->s_paddr > 0 | 247 | 1.73k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 865 | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 865 | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 179 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 1.73k | #endif | 256 | 1.73k | } |
pe-aarch64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 5.47k | { | 207 | 5.47k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 5.47k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 5.47k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 5.47k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 5.47k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 5.47k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 5.47k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 5.47k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 5.47k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 5.47k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | | #ifdef COFF_IMAGE_WITH_PE | 224 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | 5.47k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 5.47k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 5.47k | #endif | 231 | | | 232 | 5.47k | if (scnhdr_int->s_vaddr != 0) | 233 | 1.96k | { | 234 | 1.96k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | | #endif | 239 | 1.96k | } | 240 | | | 241 | 5.47k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 5.47k | if (scnhdr_int->s_paddr > 0 | 247 | 5.47k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 3.58k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 3.58k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 156 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 5.47k | #endif | 256 | 5.47k | } |
pei-ia64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 2.23k | { | 207 | 2.23k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 2.23k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 2.23k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 2.23k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 2.23k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 2.23k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 2.23k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 2.23k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 2.23k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 2.23k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 2.23k | #ifdef COFF_IMAGE_WITH_PE | 224 | 2.23k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 2.23k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 2.23k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 2.23k | if (scnhdr_int->s_vaddr != 0) | 233 | 1.15k | { | 234 | 1.15k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 1.15k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 1.15k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 1.15k | #endif | 239 | 1.15k | } | 240 | | | 241 | 2.23k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 2.23k | if (scnhdr_int->s_paddr > 0 | 247 | 2.23k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 1.44k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 1.44k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 471 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 2.23k | #endif | 256 | 2.23k | } |
pei-loongarch64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 8.55k | { | 207 | 8.55k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 8.55k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 8.55k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 8.55k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 8.55k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 8.55k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 8.55k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 8.55k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 8.55k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 8.55k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 8.55k | #ifdef COFF_IMAGE_WITH_PE | 224 | 8.55k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 8.55k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 8.55k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 8.55k | if (scnhdr_int->s_vaddr != 0) | 233 | 7.42k | { | 234 | 7.42k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | | #endif | 239 | 7.42k | } | 240 | | | 241 | 8.55k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 8.55k | if (scnhdr_int->s_paddr > 0 | 247 | 8.55k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 7.60k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 7.60k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 422 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 8.55k | #endif | 256 | 8.55k | } |
pe-arm-wince.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 1.21k | { | 207 | 1.21k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 1.21k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 1.21k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 1.21k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 1.21k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 1.21k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 1.21k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 1.21k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 1.21k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 1.21k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | | #ifdef COFF_IMAGE_WITH_PE | 224 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | 1.21k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 1.21k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 1.21k | #endif | 231 | | | 232 | 1.21k | if (scnhdr_int->s_vaddr != 0) | 233 | 880 | { | 234 | 880 | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 880 | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 880 | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 880 | #endif | 239 | 880 | } | 240 | | | 241 | 1.21k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 1.21k | if (scnhdr_int->s_paddr > 0 | 247 | 1.21k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 936 | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 936 | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 244 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 1.21k | #endif | 256 | 1.21k | } |
pe-arm.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 1.21k | { | 207 | 1.21k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 1.21k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 1.21k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 1.21k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 1.21k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 1.21k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 1.21k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 1.21k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 1.21k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 1.21k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | | #ifdef COFF_IMAGE_WITH_PE | 224 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | 1.21k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 1.21k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 1.21k | #endif | 231 | | | 232 | 1.21k | if (scnhdr_int->s_vaddr != 0) | 233 | 880 | { | 234 | 880 | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 880 | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 880 | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 880 | #endif | 239 | 880 | } | 240 | | | 241 | 1.21k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 1.21k | if (scnhdr_int->s_paddr > 0 | 247 | 1.21k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 936 | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 936 | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 244 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 1.21k | #endif | 256 | 1.21k | } |
pe-i386.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 7.12k | { | 207 | 7.12k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 7.12k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 7.12k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 7.12k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 7.12k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 7.12k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 7.12k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 7.12k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 7.12k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 7.12k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | | #ifdef COFF_IMAGE_WITH_PE | 224 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | 7.12k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 7.12k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 7.12k | #endif | 231 | | | 232 | 7.12k | if (scnhdr_int->s_vaddr != 0) | 233 | 4.82k | { | 234 | 4.82k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 4.82k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 4.82k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 4.82k | #endif | 239 | 4.82k | } | 240 | | | 241 | 7.12k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 7.12k | if (scnhdr_int->s_paddr > 0 | 247 | 7.12k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 5.27k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 5.27k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 3.08k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 7.12k | #endif | 256 | 7.12k | } |
pe-mcore.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 3.32k | { | 207 | 3.32k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 3.32k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 3.32k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 3.32k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 3.32k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 3.32k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 3.32k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 3.32k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 3.32k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 3.32k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | | #ifdef COFF_IMAGE_WITH_PE | 224 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | 3.32k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 3.32k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 3.32k | #endif | 231 | | | 232 | 3.32k | if (scnhdr_int->s_vaddr != 0) | 233 | 1.62k | { | 234 | 1.62k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 1.62k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 1.62k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 1.62k | #endif | 239 | 1.62k | } | 240 | | | 241 | 3.32k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 3.32k | if (scnhdr_int->s_paddr > 0 | 247 | 3.32k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 1.74k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 1.74k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 295 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 3.32k | #endif | 256 | 3.32k | } |
pe-sh.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 2.57k | { | 207 | 2.57k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 2.57k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 2.57k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 2.57k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 2.57k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 2.57k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 2.57k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 2.57k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 2.57k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 2.57k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | | #ifdef COFF_IMAGE_WITH_PE | 224 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | 2.57k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 2.57k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 2.57k | #endif | 231 | | | 232 | 2.57k | if (scnhdr_int->s_vaddr != 0) | 233 | 1.61k | { | 234 | 1.61k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 1.61k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 1.61k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 1.61k | #endif | 239 | 1.61k | } | 240 | | | 241 | 2.57k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 2.57k | if (scnhdr_int->s_paddr > 0 | 247 | 2.57k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 1.67k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 1.67k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 132 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 2.57k | #endif | 256 | 2.57k | } |
pei-arm-wince.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 2.09k | { | 207 | 2.09k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 2.09k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 2.09k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 2.09k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 2.09k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 2.09k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 2.09k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 2.09k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 2.09k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 2.09k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 2.09k | #ifdef COFF_IMAGE_WITH_PE | 224 | 2.09k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 2.09k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 2.09k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 2.09k | if (scnhdr_int->s_vaddr != 0) | 233 | 1.49k | { | 234 | 1.49k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 1.49k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 1.49k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 1.49k | #endif | 239 | 1.49k | } | 240 | | | 241 | 2.09k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 2.09k | if (scnhdr_int->s_paddr > 0 | 247 | 2.09k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 1.48k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 1.48k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 313 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 2.09k | #endif | 256 | 2.09k | } |
pei-arm.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 2.74k | { | 207 | 2.74k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 2.74k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 2.74k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 2.74k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 2.74k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 2.74k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 2.74k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 2.74k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 2.74k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 2.74k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 2.74k | #ifdef COFF_IMAGE_WITH_PE | 224 | 2.74k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 2.74k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 2.74k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 2.74k | if (scnhdr_int->s_vaddr != 0) | 233 | 1.69k | { | 234 | 1.69k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 1.69k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 1.69k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 1.69k | #endif | 239 | 1.69k | } | 240 | | | 241 | 2.74k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 2.74k | if (scnhdr_int->s_paddr > 0 | 247 | 2.74k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 1.77k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 1.77k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 416 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 2.74k | #endif | 256 | 2.74k | } |
pei-mcore.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 3.55k | { | 207 | 3.55k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 3.55k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 3.55k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 3.55k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 3.55k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 3.55k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 3.55k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 3.55k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 3.55k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 3.55k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 3.55k | #ifdef COFF_IMAGE_WITH_PE | 224 | 3.55k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 3.55k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 3.55k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 3.55k | if (scnhdr_int->s_vaddr != 0) | 233 | 2.77k | { | 234 | 2.77k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 2.77k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 2.77k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 2.77k | #endif | 239 | 2.77k | } | 240 | | | 241 | 3.55k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 3.55k | if (scnhdr_int->s_paddr > 0 | 247 | 3.55k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 3.04k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 3.04k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 427 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 3.55k | #endif | 256 | 3.55k | } |
pei-sh.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 1.70k | { | 207 | 1.70k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 1.70k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 1.70k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 1.70k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 1.70k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 1.70k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 1.70k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 1.70k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 1.70k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 1.70k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 1.70k | #ifdef COFF_IMAGE_WITH_PE | 224 | 1.70k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 1.70k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 1.70k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 1.70k | if (scnhdr_int->s_vaddr != 0) | 233 | 926 | { | 234 | 926 | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 926 | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 926 | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 926 | #endif | 239 | 926 | } | 240 | | | 241 | 1.70k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 1.70k | if (scnhdr_int->s_paddr > 0 | 247 | 1.70k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 1.00k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 1.00k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 240 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 1.70k | #endif | 256 | 1.70k | } |
|
257 | | |
258 | | static bool |
259 | | pe_mkobject (bfd * abfd) |
260 | 7.61k | { |
261 | 7.61k | pe_data_type *pe; |
262 | 7.61k | size_t amt = sizeof (pe_data_type); |
263 | | |
264 | 7.61k | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); |
265 | | |
266 | 7.61k | if (abfd->tdata.pe_obj_data == 0) |
267 | 0 | return false; |
268 | | |
269 | 7.61k | pe = pe_data (abfd); |
270 | | |
271 | 7.61k | pe->coff.pe = 1; |
272 | | |
273 | | /* in_reloc_p is architecture dependent. */ |
274 | 7.61k | pe->in_reloc_p = in_reloc_p; |
275 | | |
276 | | /* Default DOS message string. */ |
277 | 7.61k | pe->dos_message[0] = 0x0eba1f0e; |
278 | 7.61k | pe->dos_message[1] = 0xcd09b400; |
279 | 7.61k | pe->dos_message[2] = 0x4c01b821; |
280 | 7.61k | pe->dos_message[3] = 0x685421cd; |
281 | 7.61k | pe->dos_message[4] = 0x70207369; |
282 | 7.61k | pe->dos_message[5] = 0x72676f72; |
283 | 7.61k | pe->dos_message[6] = 0x63206d61; |
284 | 7.61k | pe->dos_message[7] = 0x6f6e6e61; |
285 | 7.61k | pe->dos_message[8] = 0x65622074; |
286 | 7.61k | pe->dos_message[9] = 0x6e757220; |
287 | 7.61k | pe->dos_message[10] = 0x206e6920; |
288 | 7.61k | pe->dos_message[11] = 0x20534f44; |
289 | 7.61k | pe->dos_message[12] = 0x65646f6d; |
290 | 7.61k | pe->dos_message[13] = 0x0a0d0d2e; |
291 | 7.61k | pe->dos_message[14] = 0x24; |
292 | 7.61k | pe->dos_message[15] = 0x0; |
293 | | |
294 | 7.61k | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); |
295 | | |
296 | 7.61k | bfd_coff_long_section_names (abfd) |
297 | 7.61k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; |
298 | | |
299 | 7.61k | return true; |
300 | 7.61k | } Line | Count | Source | 260 | 570 | { | 261 | 570 | pe_data_type *pe; | 262 | 570 | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 570 | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 570 | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 570 | pe = pe_data (abfd); | 270 | | | 271 | 570 | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 570 | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 570 | pe->dos_message[0] = 0x0eba1f0e; | 278 | 570 | pe->dos_message[1] = 0xcd09b400; | 279 | 570 | pe->dos_message[2] = 0x4c01b821; | 280 | 570 | pe->dos_message[3] = 0x685421cd; | 281 | 570 | pe->dos_message[4] = 0x70207369; | 282 | 570 | pe->dos_message[5] = 0x72676f72; | 283 | 570 | pe->dos_message[6] = 0x63206d61; | 284 | 570 | pe->dos_message[7] = 0x6f6e6e61; | 285 | 570 | pe->dos_message[8] = 0x65622074; | 286 | 570 | pe->dos_message[9] = 0x6e757220; | 287 | 570 | pe->dos_message[10] = 0x206e6920; | 288 | 570 | pe->dos_message[11] = 0x20534f44; | 289 | 570 | pe->dos_message[12] = 0x65646f6d; | 290 | 570 | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 570 | pe->dos_message[14] = 0x24; | 292 | 570 | pe->dos_message[15] = 0x0; | 293 | | | 294 | 570 | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 570 | bfd_coff_long_section_names (abfd) | 297 | 570 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 570 | return true; | 300 | 570 | } |
Line | Count | Source | 260 | 1.44k | { | 261 | 1.44k | pe_data_type *pe; | 262 | 1.44k | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 1.44k | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 1.44k | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 1.44k | pe = pe_data (abfd); | 270 | | | 271 | 1.44k | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 1.44k | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 1.44k | pe->dos_message[0] = 0x0eba1f0e; | 278 | 1.44k | pe->dos_message[1] = 0xcd09b400; | 279 | 1.44k | pe->dos_message[2] = 0x4c01b821; | 280 | 1.44k | pe->dos_message[3] = 0x685421cd; | 281 | 1.44k | pe->dos_message[4] = 0x70207369; | 282 | 1.44k | pe->dos_message[5] = 0x72676f72; | 283 | 1.44k | pe->dos_message[6] = 0x63206d61; | 284 | 1.44k | pe->dos_message[7] = 0x6f6e6e61; | 285 | 1.44k | pe->dos_message[8] = 0x65622074; | 286 | 1.44k | pe->dos_message[9] = 0x6e757220; | 287 | 1.44k | pe->dos_message[10] = 0x206e6920; | 288 | 1.44k | pe->dos_message[11] = 0x20534f44; | 289 | 1.44k | pe->dos_message[12] = 0x65646f6d; | 290 | 1.44k | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 1.44k | pe->dos_message[14] = 0x24; | 292 | 1.44k | pe->dos_message[15] = 0x0; | 293 | | | 294 | 1.44k | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 1.44k | bfd_coff_long_section_names (abfd) | 297 | 1.44k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 1.44k | return true; | 300 | 1.44k | } |
Line | Count | Source | 260 | 484 | { | 261 | 484 | pe_data_type *pe; | 262 | 484 | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 484 | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 484 | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 484 | pe = pe_data (abfd); | 270 | | | 271 | 484 | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 484 | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 484 | pe->dos_message[0] = 0x0eba1f0e; | 278 | 484 | pe->dos_message[1] = 0xcd09b400; | 279 | 484 | pe->dos_message[2] = 0x4c01b821; | 280 | 484 | pe->dos_message[3] = 0x685421cd; | 281 | 484 | pe->dos_message[4] = 0x70207369; | 282 | 484 | pe->dos_message[5] = 0x72676f72; | 283 | 484 | pe->dos_message[6] = 0x63206d61; | 284 | 484 | pe->dos_message[7] = 0x6f6e6e61; | 285 | 484 | pe->dos_message[8] = 0x65622074; | 286 | 484 | pe->dos_message[9] = 0x6e757220; | 287 | 484 | pe->dos_message[10] = 0x206e6920; | 288 | 484 | pe->dos_message[11] = 0x20534f44; | 289 | 484 | pe->dos_message[12] = 0x65646f6d; | 290 | 484 | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 484 | pe->dos_message[14] = 0x24; | 292 | 484 | pe->dos_message[15] = 0x0; | 293 | | | 294 | 484 | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 484 | bfd_coff_long_section_names (abfd) | 297 | 484 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 484 | return true; | 300 | 484 | } |
pei-aarch64.c:pe_mkobject Line | Count | Source | 260 | 321 | { | 261 | 321 | pe_data_type *pe; | 262 | 321 | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 321 | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 321 | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 321 | pe = pe_data (abfd); | 270 | | | 271 | 321 | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 321 | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 321 | pe->dos_message[0] = 0x0eba1f0e; | 278 | 321 | pe->dos_message[1] = 0xcd09b400; | 279 | 321 | pe->dos_message[2] = 0x4c01b821; | 280 | 321 | pe->dos_message[3] = 0x685421cd; | 281 | 321 | pe->dos_message[4] = 0x70207369; | 282 | 321 | pe->dos_message[5] = 0x72676f72; | 283 | 321 | pe->dos_message[6] = 0x63206d61; | 284 | 321 | pe->dos_message[7] = 0x6f6e6e61; | 285 | 321 | pe->dos_message[8] = 0x65622074; | 286 | 321 | pe->dos_message[9] = 0x6e757220; | 287 | 321 | pe->dos_message[10] = 0x206e6920; | 288 | 321 | pe->dos_message[11] = 0x20534f44; | 289 | 321 | pe->dos_message[12] = 0x65646f6d; | 290 | 321 | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 321 | pe->dos_message[14] = 0x24; | 292 | 321 | pe->dos_message[15] = 0x0; | 293 | | | 294 | 321 | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 321 | bfd_coff_long_section_names (abfd) | 297 | 321 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 321 | return true; | 300 | 321 | } |
Line | Count | Source | 260 | 509 | { | 261 | 509 | pe_data_type *pe; | 262 | 509 | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 509 | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 509 | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 509 | pe = pe_data (abfd); | 270 | | | 271 | 509 | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 509 | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 509 | pe->dos_message[0] = 0x0eba1f0e; | 278 | 509 | pe->dos_message[1] = 0xcd09b400; | 279 | 509 | pe->dos_message[2] = 0x4c01b821; | 280 | 509 | pe->dos_message[3] = 0x685421cd; | 281 | 509 | pe->dos_message[4] = 0x70207369; | 282 | 509 | pe->dos_message[5] = 0x72676f72; | 283 | 509 | pe->dos_message[6] = 0x63206d61; | 284 | 509 | pe->dos_message[7] = 0x6f6e6e61; | 285 | 509 | pe->dos_message[8] = 0x65622074; | 286 | 509 | pe->dos_message[9] = 0x6e757220; | 287 | 509 | pe->dos_message[10] = 0x206e6920; | 288 | 509 | pe->dos_message[11] = 0x20534f44; | 289 | 509 | pe->dos_message[12] = 0x65646f6d; | 290 | 509 | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 509 | pe->dos_message[14] = 0x24; | 292 | 509 | pe->dos_message[15] = 0x0; | 293 | | | 294 | 509 | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 509 | bfd_coff_long_section_names (abfd) | 297 | 509 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 509 | return true; | 300 | 509 | } |
Line | Count | Source | 260 | 382 | { | 261 | 382 | pe_data_type *pe; | 262 | 382 | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 382 | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 382 | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 382 | pe = pe_data (abfd); | 270 | | | 271 | 382 | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 382 | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 382 | pe->dos_message[0] = 0x0eba1f0e; | 278 | 382 | pe->dos_message[1] = 0xcd09b400; | 279 | 382 | pe->dos_message[2] = 0x4c01b821; | 280 | 382 | pe->dos_message[3] = 0x685421cd; | 281 | 382 | pe->dos_message[4] = 0x70207369; | 282 | 382 | pe->dos_message[5] = 0x72676f72; | 283 | 382 | pe->dos_message[6] = 0x63206d61; | 284 | 382 | pe->dos_message[7] = 0x6f6e6e61; | 285 | 382 | pe->dos_message[8] = 0x65622074; | 286 | 382 | pe->dos_message[9] = 0x6e757220; | 287 | 382 | pe->dos_message[10] = 0x206e6920; | 288 | 382 | pe->dos_message[11] = 0x20534f44; | 289 | 382 | pe->dos_message[12] = 0x65646f6d; | 290 | 382 | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 382 | pe->dos_message[14] = 0x24; | 292 | 382 | pe->dos_message[15] = 0x0; | 293 | | | 294 | 382 | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 382 | bfd_coff_long_section_names (abfd) | 297 | 382 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 382 | return true; | 300 | 382 | } |
pei-loongarch64.c:pe_mkobject Line | Count | Source | 260 | 455 | { | 261 | 455 | pe_data_type *pe; | 262 | 455 | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 455 | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 455 | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 455 | pe = pe_data (abfd); | 270 | | | 271 | 455 | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 455 | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 455 | pe->dos_message[0] = 0x0eba1f0e; | 278 | 455 | pe->dos_message[1] = 0xcd09b400; | 279 | 455 | pe->dos_message[2] = 0x4c01b821; | 280 | 455 | pe->dos_message[3] = 0x685421cd; | 281 | 455 | pe->dos_message[4] = 0x70207369; | 282 | 455 | pe->dos_message[5] = 0x72676f72; | 283 | 455 | pe->dos_message[6] = 0x63206d61; | 284 | 455 | pe->dos_message[7] = 0x6f6e6e61; | 285 | 455 | pe->dos_message[8] = 0x65622074; | 286 | 455 | pe->dos_message[9] = 0x6e757220; | 287 | 455 | pe->dos_message[10] = 0x206e6920; | 288 | 455 | pe->dos_message[11] = 0x20534f44; | 289 | 455 | pe->dos_message[12] = 0x65646f6d; | 290 | 455 | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 455 | pe->dos_message[14] = 0x24; | 292 | 455 | pe->dos_message[15] = 0x0; | 293 | | | 294 | 455 | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 455 | bfd_coff_long_section_names (abfd) | 297 | 455 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 455 | return true; | 300 | 455 | } |
pe-arm-wince.c:pe_mkobject Line | Count | Source | 260 | 229 | { | 261 | 229 | pe_data_type *pe; | 262 | 229 | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 229 | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 229 | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 229 | pe = pe_data (abfd); | 270 | | | 271 | 229 | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 229 | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 229 | pe->dos_message[0] = 0x0eba1f0e; | 278 | 229 | pe->dos_message[1] = 0xcd09b400; | 279 | 229 | pe->dos_message[2] = 0x4c01b821; | 280 | 229 | pe->dos_message[3] = 0x685421cd; | 281 | 229 | pe->dos_message[4] = 0x70207369; | 282 | 229 | pe->dos_message[5] = 0x72676f72; | 283 | 229 | pe->dos_message[6] = 0x63206d61; | 284 | 229 | pe->dos_message[7] = 0x6f6e6e61; | 285 | 229 | pe->dos_message[8] = 0x65622074; | 286 | 229 | pe->dos_message[9] = 0x6e757220; | 287 | 229 | pe->dos_message[10] = 0x206e6920; | 288 | 229 | pe->dos_message[11] = 0x20534f44; | 289 | 229 | pe->dos_message[12] = 0x65646f6d; | 290 | 229 | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 229 | pe->dos_message[14] = 0x24; | 292 | 229 | pe->dos_message[15] = 0x0; | 293 | | | 294 | 229 | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 229 | bfd_coff_long_section_names (abfd) | 297 | 229 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 229 | return true; | 300 | 229 | } |
Line | Count | Source | 260 | 229 | { | 261 | 229 | pe_data_type *pe; | 262 | 229 | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 229 | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 229 | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 229 | pe = pe_data (abfd); | 270 | | | 271 | 229 | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 229 | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 229 | pe->dos_message[0] = 0x0eba1f0e; | 278 | 229 | pe->dos_message[1] = 0xcd09b400; | 279 | 229 | pe->dos_message[2] = 0x4c01b821; | 280 | 229 | pe->dos_message[3] = 0x685421cd; | 281 | 229 | pe->dos_message[4] = 0x70207369; | 282 | 229 | pe->dos_message[5] = 0x72676f72; | 283 | 229 | pe->dos_message[6] = 0x63206d61; | 284 | 229 | pe->dos_message[7] = 0x6f6e6e61; | 285 | 229 | pe->dos_message[8] = 0x65622074; | 286 | 229 | pe->dos_message[9] = 0x6e757220; | 287 | 229 | pe->dos_message[10] = 0x206e6920; | 288 | 229 | pe->dos_message[11] = 0x20534f44; | 289 | 229 | pe->dos_message[12] = 0x65646f6d; | 290 | 229 | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 229 | pe->dos_message[14] = 0x24; | 292 | 229 | pe->dos_message[15] = 0x0; | 293 | | | 294 | 229 | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 229 | bfd_coff_long_section_names (abfd) | 297 | 229 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 229 | return true; | 300 | 229 | } |
Line | Count | Source | 260 | 725 | { | 261 | 725 | pe_data_type *pe; | 262 | 725 | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 725 | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 725 | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 725 | pe = pe_data (abfd); | 270 | | | 271 | 725 | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 725 | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 725 | pe->dos_message[0] = 0x0eba1f0e; | 278 | 725 | pe->dos_message[1] = 0xcd09b400; | 279 | 725 | pe->dos_message[2] = 0x4c01b821; | 280 | 725 | pe->dos_message[3] = 0x685421cd; | 281 | 725 | pe->dos_message[4] = 0x70207369; | 282 | 725 | pe->dos_message[5] = 0x72676f72; | 283 | 725 | pe->dos_message[6] = 0x63206d61; | 284 | 725 | pe->dos_message[7] = 0x6f6e6e61; | 285 | 725 | pe->dos_message[8] = 0x65622074; | 286 | 725 | pe->dos_message[9] = 0x6e757220; | 287 | 725 | pe->dos_message[10] = 0x206e6920; | 288 | 725 | pe->dos_message[11] = 0x20534f44; | 289 | 725 | pe->dos_message[12] = 0x65646f6d; | 290 | 725 | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 725 | pe->dos_message[14] = 0x24; | 292 | 725 | pe->dos_message[15] = 0x0; | 293 | | | 294 | 725 | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 725 | bfd_coff_long_section_names (abfd) | 297 | 725 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 725 | return true; | 300 | 725 | } |
Line | Count | Source | 260 | 399 | { | 261 | 399 | pe_data_type *pe; | 262 | 399 | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 399 | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 399 | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 399 | pe = pe_data (abfd); | 270 | | | 271 | 399 | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 399 | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 399 | pe->dos_message[0] = 0x0eba1f0e; | 278 | 399 | pe->dos_message[1] = 0xcd09b400; | 279 | 399 | pe->dos_message[2] = 0x4c01b821; | 280 | 399 | pe->dos_message[3] = 0x685421cd; | 281 | 399 | pe->dos_message[4] = 0x70207369; | 282 | 399 | pe->dos_message[5] = 0x72676f72; | 283 | 399 | pe->dos_message[6] = 0x63206d61; | 284 | 399 | pe->dos_message[7] = 0x6f6e6e61; | 285 | 399 | pe->dos_message[8] = 0x65622074; | 286 | 399 | pe->dos_message[9] = 0x6e757220; | 287 | 399 | pe->dos_message[10] = 0x206e6920; | 288 | 399 | pe->dos_message[11] = 0x20534f44; | 289 | 399 | pe->dos_message[12] = 0x65646f6d; | 290 | 399 | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 399 | pe->dos_message[14] = 0x24; | 292 | 399 | pe->dos_message[15] = 0x0; | 293 | | | 294 | 399 | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 399 | bfd_coff_long_section_names (abfd) | 297 | 399 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 399 | return true; | 300 | 399 | } |
Line | Count | Source | 260 | 479 | { | 261 | 479 | pe_data_type *pe; | 262 | 479 | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 479 | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 479 | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 479 | pe = pe_data (abfd); | 270 | | | 271 | 479 | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 479 | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 479 | pe->dos_message[0] = 0x0eba1f0e; | 278 | 479 | pe->dos_message[1] = 0xcd09b400; | 279 | 479 | pe->dos_message[2] = 0x4c01b821; | 280 | 479 | pe->dos_message[3] = 0x685421cd; | 281 | 479 | pe->dos_message[4] = 0x70207369; | 282 | 479 | pe->dos_message[5] = 0x72676f72; | 283 | 479 | pe->dos_message[6] = 0x63206d61; | 284 | 479 | pe->dos_message[7] = 0x6f6e6e61; | 285 | 479 | pe->dos_message[8] = 0x65622074; | 286 | 479 | pe->dos_message[9] = 0x6e757220; | 287 | 479 | pe->dos_message[10] = 0x206e6920; | 288 | 479 | pe->dos_message[11] = 0x20534f44; | 289 | 479 | pe->dos_message[12] = 0x65646f6d; | 290 | 479 | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 479 | pe->dos_message[14] = 0x24; | 292 | 479 | pe->dos_message[15] = 0x0; | 293 | | | 294 | 479 | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 479 | bfd_coff_long_section_names (abfd) | 297 | 479 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 479 | return true; | 300 | 479 | } |
pei-arm-wince.c:pe_mkobject Line | Count | Source | 260 | 284 | { | 261 | 284 | pe_data_type *pe; | 262 | 284 | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 284 | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 284 | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 284 | pe = pe_data (abfd); | 270 | | | 271 | 284 | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 284 | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 284 | pe->dos_message[0] = 0x0eba1f0e; | 278 | 284 | pe->dos_message[1] = 0xcd09b400; | 279 | 284 | pe->dos_message[2] = 0x4c01b821; | 280 | 284 | pe->dos_message[3] = 0x685421cd; | 281 | 284 | pe->dos_message[4] = 0x70207369; | 282 | 284 | pe->dos_message[5] = 0x72676f72; | 283 | 284 | pe->dos_message[6] = 0x63206d61; | 284 | 284 | pe->dos_message[7] = 0x6f6e6e61; | 285 | 284 | pe->dos_message[8] = 0x65622074; | 286 | 284 | pe->dos_message[9] = 0x6e757220; | 287 | 284 | pe->dos_message[10] = 0x206e6920; | 288 | 284 | pe->dos_message[11] = 0x20534f44; | 289 | 284 | pe->dos_message[12] = 0x65646f6d; | 290 | 284 | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 284 | pe->dos_message[14] = 0x24; | 292 | 284 | pe->dos_message[15] = 0x0; | 293 | | | 294 | 284 | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 284 | bfd_coff_long_section_names (abfd) | 297 | 284 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 284 | return true; | 300 | 284 | } |
Line | Count | Source | 260 | 469 | { | 261 | 469 | pe_data_type *pe; | 262 | 469 | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 469 | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 469 | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 469 | pe = pe_data (abfd); | 270 | | | 271 | 469 | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 469 | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 469 | pe->dos_message[0] = 0x0eba1f0e; | 278 | 469 | pe->dos_message[1] = 0xcd09b400; | 279 | 469 | pe->dos_message[2] = 0x4c01b821; | 280 | 469 | pe->dos_message[3] = 0x685421cd; | 281 | 469 | pe->dos_message[4] = 0x70207369; | 282 | 469 | pe->dos_message[5] = 0x72676f72; | 283 | 469 | pe->dos_message[6] = 0x63206d61; | 284 | 469 | pe->dos_message[7] = 0x6f6e6e61; | 285 | 469 | pe->dos_message[8] = 0x65622074; | 286 | 469 | pe->dos_message[9] = 0x6e757220; | 287 | 469 | pe->dos_message[10] = 0x206e6920; | 288 | 469 | pe->dos_message[11] = 0x20534f44; | 289 | 469 | pe->dos_message[12] = 0x65646f6d; | 290 | 469 | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 469 | pe->dos_message[14] = 0x24; | 292 | 469 | pe->dos_message[15] = 0x0; | 293 | | | 294 | 469 | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 469 | bfd_coff_long_section_names (abfd) | 297 | 469 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 469 | return true; | 300 | 469 | } |
Line | Count | Source | 260 | 298 | { | 261 | 298 | pe_data_type *pe; | 262 | 298 | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 298 | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 298 | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 298 | pe = pe_data (abfd); | 270 | | | 271 | 298 | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 298 | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 298 | pe->dos_message[0] = 0x0eba1f0e; | 278 | 298 | pe->dos_message[1] = 0xcd09b400; | 279 | 298 | pe->dos_message[2] = 0x4c01b821; | 280 | 298 | pe->dos_message[3] = 0x685421cd; | 281 | 298 | pe->dos_message[4] = 0x70207369; | 282 | 298 | pe->dos_message[5] = 0x72676f72; | 283 | 298 | pe->dos_message[6] = 0x63206d61; | 284 | 298 | pe->dos_message[7] = 0x6f6e6e61; | 285 | 298 | pe->dos_message[8] = 0x65622074; | 286 | 298 | pe->dos_message[9] = 0x6e757220; | 287 | 298 | pe->dos_message[10] = 0x206e6920; | 288 | 298 | pe->dos_message[11] = 0x20534f44; | 289 | 298 | pe->dos_message[12] = 0x65646f6d; | 290 | 298 | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 298 | pe->dos_message[14] = 0x24; | 292 | 298 | pe->dos_message[15] = 0x0; | 293 | | | 294 | 298 | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 298 | bfd_coff_long_section_names (abfd) | 297 | 298 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 298 | return true; | 300 | 298 | } |
Line | Count | Source | 260 | 342 | { | 261 | 342 | pe_data_type *pe; | 262 | 342 | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 342 | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 342 | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 342 | pe = pe_data (abfd); | 270 | | | 271 | 342 | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 342 | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 342 | pe->dos_message[0] = 0x0eba1f0e; | 278 | 342 | pe->dos_message[1] = 0xcd09b400; | 279 | 342 | pe->dos_message[2] = 0x4c01b821; | 280 | 342 | pe->dos_message[3] = 0x685421cd; | 281 | 342 | pe->dos_message[4] = 0x70207369; | 282 | 342 | pe->dos_message[5] = 0x72676f72; | 283 | 342 | pe->dos_message[6] = 0x63206d61; | 284 | 342 | pe->dos_message[7] = 0x6f6e6e61; | 285 | 342 | pe->dos_message[8] = 0x65622074; | 286 | 342 | pe->dos_message[9] = 0x6e757220; | 287 | 342 | pe->dos_message[10] = 0x206e6920; | 288 | 342 | pe->dos_message[11] = 0x20534f44; | 289 | 342 | pe->dos_message[12] = 0x65646f6d; | 290 | 342 | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 342 | pe->dos_message[14] = 0x24; | 292 | 342 | pe->dos_message[15] = 0x0; | 293 | | | 294 | 342 | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 342 | bfd_coff_long_section_names (abfd) | 297 | 342 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 342 | return true; | 300 | 342 | } |
|
301 | | |
302 | | /* Create the COFF backend specific information. */ |
303 | | |
304 | | static void * |
305 | | pe_mkobject_hook (bfd * abfd, |
306 | | void * filehdr, |
307 | | void * aouthdr ATTRIBUTE_UNUSED) |
308 | 7.61k | { |
309 | 7.61k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; |
310 | 7.61k | pe_data_type *pe; |
311 | | |
312 | 7.61k | if (! pe_mkobject (abfd)) |
313 | 0 | return NULL; |
314 | | |
315 | 7.61k | pe = pe_data (abfd); |
316 | 7.61k | pe->coff.sym_filepos = internal_f->f_symptr; |
317 | | /* These members communicate important constants about the symbol |
318 | | table to GDB's symbol-reading code. These `constants' |
319 | | unfortunately vary among coff implementations... */ |
320 | 7.61k | pe->coff.local_n_btmask = N_BTMASK; |
321 | 7.61k | pe->coff.local_n_btshft = N_BTSHFT; |
322 | 7.61k | pe->coff.local_n_tmask = N_TMASK; |
323 | 7.61k | pe->coff.local_n_tshift = N_TSHIFT; |
324 | 7.61k | pe->coff.local_symesz = SYMESZ; |
325 | 7.61k | pe->coff.local_auxesz = AUXESZ; |
326 | 7.61k | pe->coff.local_linesz = LINESZ; |
327 | | |
328 | 7.61k | pe->coff.timestamp = internal_f->f_timdat; |
329 | | |
330 | 7.61k | obj_raw_syment_count (abfd) = |
331 | 7.61k | obj_conv_table_size (abfd) = |
332 | 7.61k | internal_f->f_nsyms; |
333 | | |
334 | 7.61k | pe->real_flags = internal_f->f_flags; |
335 | | |
336 | 7.61k | if ((internal_f->f_flags & F_DLL) != 0) |
337 | 1.51k | pe->dll = 1; |
338 | | |
339 | 7.61k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) |
340 | 5.69k | abfd->flags |= HAS_DEBUG; |
341 | | |
342 | | #ifdef COFF_IMAGE_WITH_PE |
343 | 3.60k | if (aouthdr) |
344 | 2.65k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; |
345 | | #endif |
346 | | |
347 | | #ifdef ARM |
348 | 1.21k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) |
349 | 0 | coff_data (abfd) ->flags = 0; |
350 | | #endif |
351 | | |
352 | 7.61k | memcpy (pe->dos_message, internal_f->pe.dos_message, |
353 | 7.61k | sizeof (pe->dos_message)); |
354 | | |
355 | 7.61k | return (void *) pe; |
356 | 7.61k | } pei-i386.c:pe_mkobject_hook Line | Count | Source | 308 | 570 | { | 309 | 570 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 570 | pe_data_type *pe; | 311 | | | 312 | 570 | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 570 | pe = pe_data (abfd); | 316 | 570 | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 570 | pe->coff.local_n_btmask = N_BTMASK; | 321 | 570 | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 570 | pe->coff.local_n_tmask = N_TMASK; | 323 | 570 | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 570 | pe->coff.local_symesz = SYMESZ; | 325 | 570 | pe->coff.local_auxesz = AUXESZ; | 326 | 570 | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 570 | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 570 | obj_raw_syment_count (abfd) = | 331 | 570 | obj_conv_table_size (abfd) = | 332 | 570 | internal_f->f_nsyms; | 333 | | | 334 | 570 | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 570 | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 111 | pe->dll = 1; | 338 | | | 339 | 570 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 450 | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | 570 | #ifdef COFF_IMAGE_WITH_PE | 343 | 570 | if (aouthdr) | 344 | 521 | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | 570 | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 570 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 570 | sizeof (pe->dos_message)); | 354 | | | 355 | 570 | return (void *) pe; | 356 | 570 | } |
pe-x86_64.c:pe_mkobject_hook Line | Count | Source | 308 | 1.44k | { | 309 | 1.44k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 1.44k | pe_data_type *pe; | 311 | | | 312 | 1.44k | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 1.44k | pe = pe_data (abfd); | 316 | 1.44k | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 1.44k | pe->coff.local_n_btmask = N_BTMASK; | 321 | 1.44k | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 1.44k | pe->coff.local_n_tmask = N_TMASK; | 323 | 1.44k | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 1.44k | pe->coff.local_symesz = SYMESZ; | 325 | 1.44k | pe->coff.local_auxesz = AUXESZ; | 326 | 1.44k | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 1.44k | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 1.44k | obj_raw_syment_count (abfd) = | 331 | 1.44k | obj_conv_table_size (abfd) = | 332 | 1.44k | internal_f->f_nsyms; | 333 | | | 334 | 1.44k | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 1.44k | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 248 | pe->dll = 1; | 338 | | | 339 | 1.44k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 1.15k | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | | #ifdef COFF_IMAGE_WITH_PE | 343 | | if (aouthdr) | 344 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 1.44k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 1.44k | sizeof (pe->dos_message)); | 354 | | | 355 | 1.44k | return (void *) pe; | 356 | 1.44k | } |
pei-x86_64.c:pe_mkobject_hook Line | Count | Source | 308 | 484 | { | 309 | 484 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 484 | pe_data_type *pe; | 311 | | | 312 | 484 | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 484 | pe = pe_data (abfd); | 316 | 484 | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 484 | pe->coff.local_n_btmask = N_BTMASK; | 321 | 484 | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 484 | pe->coff.local_n_tmask = N_TMASK; | 323 | 484 | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 484 | pe->coff.local_symesz = SYMESZ; | 325 | 484 | pe->coff.local_auxesz = AUXESZ; | 326 | 484 | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 484 | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 484 | obj_raw_syment_count (abfd) = | 331 | 484 | obj_conv_table_size (abfd) = | 332 | 484 | internal_f->f_nsyms; | 333 | | | 334 | 484 | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 484 | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 27 | pe->dll = 1; | 338 | | | 339 | 484 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 226 | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | 484 | #ifdef COFF_IMAGE_WITH_PE | 343 | 484 | if (aouthdr) | 344 | 366 | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | 484 | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 484 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 484 | sizeof (pe->dos_message)); | 354 | | | 355 | 484 | return (void *) pe; | 356 | 484 | } |
pei-aarch64.c:pe_mkobject_hook Line | Count | Source | 308 | 321 | { | 309 | 321 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 321 | pe_data_type *pe; | 311 | | | 312 | 321 | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 321 | pe = pe_data (abfd); | 316 | 321 | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 321 | pe->coff.local_n_btmask = N_BTMASK; | 321 | 321 | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 321 | pe->coff.local_n_tmask = N_TMASK; | 323 | 321 | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 321 | pe->coff.local_symesz = SYMESZ; | 325 | 321 | pe->coff.local_auxesz = AUXESZ; | 326 | 321 | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 321 | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 321 | obj_raw_syment_count (abfd) = | 331 | 321 | obj_conv_table_size (abfd) = | 332 | 321 | internal_f->f_nsyms; | 333 | | | 334 | 321 | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 321 | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 53 | pe->dll = 1; | 338 | | | 339 | 321 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 239 | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | 321 | #ifdef COFF_IMAGE_WITH_PE | 343 | 321 | if (aouthdr) | 344 | 236 | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | 321 | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 321 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 321 | sizeof (pe->dos_message)); | 354 | | | 355 | 321 | return (void *) pe; | 356 | 321 | } |
pe-aarch64.c:pe_mkobject_hook Line | Count | Source | 308 | 509 | { | 309 | 509 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 509 | pe_data_type *pe; | 311 | | | 312 | 509 | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 509 | pe = pe_data (abfd); | 316 | 509 | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 509 | pe->coff.local_n_btmask = N_BTMASK; | 321 | 509 | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 509 | pe->coff.local_n_tmask = N_TMASK; | 323 | 509 | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 509 | pe->coff.local_symesz = SYMESZ; | 325 | 509 | pe->coff.local_auxesz = AUXESZ; | 326 | 509 | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 509 | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 509 | obj_raw_syment_count (abfd) = | 331 | 509 | obj_conv_table_size (abfd) = | 332 | 509 | internal_f->f_nsyms; | 333 | | | 334 | 509 | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 509 | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 45 | pe->dll = 1; | 338 | | | 339 | 509 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 456 | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | | #ifdef COFF_IMAGE_WITH_PE | 343 | | if (aouthdr) | 344 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 509 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 509 | sizeof (pe->dos_message)); | 354 | | | 355 | 509 | return (void *) pe; | 356 | 509 | } |
pei-ia64.c:pe_mkobject_hook Line | Count | Source | 308 | 382 | { | 309 | 382 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 382 | pe_data_type *pe; | 311 | | | 312 | 382 | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 382 | pe = pe_data (abfd); | 316 | 382 | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 382 | pe->coff.local_n_btmask = N_BTMASK; | 321 | 382 | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 382 | pe->coff.local_n_tmask = N_TMASK; | 323 | 382 | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 382 | pe->coff.local_symesz = SYMESZ; | 325 | 382 | pe->coff.local_auxesz = AUXESZ; | 326 | 382 | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 382 | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 382 | obj_raw_syment_count (abfd) = | 331 | 382 | obj_conv_table_size (abfd) = | 332 | 382 | internal_f->f_nsyms; | 333 | | | 334 | 382 | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 382 | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 93 | pe->dll = 1; | 338 | | | 339 | 382 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 330 | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | 382 | #ifdef COFF_IMAGE_WITH_PE | 343 | 382 | if (aouthdr) | 344 | 270 | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | 382 | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 382 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 382 | sizeof (pe->dos_message)); | 354 | | | 355 | 382 | return (void *) pe; | 356 | 382 | } |
pei-loongarch64.c:pe_mkobject_hook Line | Count | Source | 308 | 455 | { | 309 | 455 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 455 | pe_data_type *pe; | 311 | | | 312 | 455 | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 455 | pe = pe_data (abfd); | 316 | 455 | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 455 | pe->coff.local_n_btmask = N_BTMASK; | 321 | 455 | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 455 | pe->coff.local_n_tmask = N_TMASK; | 323 | 455 | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 455 | pe->coff.local_symesz = SYMESZ; | 325 | 455 | pe->coff.local_auxesz = AUXESZ; | 326 | 455 | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 455 | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 455 | obj_raw_syment_count (abfd) = | 331 | 455 | obj_conv_table_size (abfd) = | 332 | 455 | internal_f->f_nsyms; | 333 | | | 334 | 455 | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 455 | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 26 | pe->dll = 1; | 338 | | | 339 | 455 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 423 | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | 455 | #ifdef COFF_IMAGE_WITH_PE | 343 | 455 | if (aouthdr) | 344 | 352 | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | 455 | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 455 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 455 | sizeof (pe->dos_message)); | 354 | | | 355 | 455 | return (void *) pe; | 356 | 455 | } |
pe-arm-wince.c:pe_mkobject_hook Line | Count | Source | 308 | 229 | { | 309 | 229 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 229 | pe_data_type *pe; | 311 | | | 312 | 229 | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 229 | pe = pe_data (abfd); | 316 | 229 | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 229 | pe->coff.local_n_btmask = N_BTMASK; | 321 | 229 | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 229 | pe->coff.local_n_tmask = N_TMASK; | 323 | 229 | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 229 | pe->coff.local_symesz = SYMESZ; | 325 | 229 | pe->coff.local_auxesz = AUXESZ; | 326 | 229 | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 229 | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 229 | obj_raw_syment_count (abfd) = | 331 | 229 | obj_conv_table_size (abfd) = | 332 | 229 | internal_f->f_nsyms; | 333 | | | 334 | 229 | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 229 | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 53 | pe->dll = 1; | 338 | | | 339 | 229 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 169 | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | | #ifdef COFF_IMAGE_WITH_PE | 343 | | if (aouthdr) | 344 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | | #endif | 346 | | | 347 | 229 | #ifdef ARM | 348 | 229 | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | 0 | coff_data (abfd) ->flags = 0; | 350 | 229 | #endif | 351 | | | 352 | 229 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 229 | sizeof (pe->dos_message)); | 354 | | | 355 | 229 | return (void *) pe; | 356 | 229 | } |
pe-arm.c:pe_mkobject_hook Line | Count | Source | 308 | 229 | { | 309 | 229 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 229 | pe_data_type *pe; | 311 | | | 312 | 229 | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 229 | pe = pe_data (abfd); | 316 | 229 | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 229 | pe->coff.local_n_btmask = N_BTMASK; | 321 | 229 | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 229 | pe->coff.local_n_tmask = N_TMASK; | 323 | 229 | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 229 | pe->coff.local_symesz = SYMESZ; | 325 | 229 | pe->coff.local_auxesz = AUXESZ; | 326 | 229 | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 229 | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 229 | obj_raw_syment_count (abfd) = | 331 | 229 | obj_conv_table_size (abfd) = | 332 | 229 | internal_f->f_nsyms; | 333 | | | 334 | 229 | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 229 | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 53 | pe->dll = 1; | 338 | | | 339 | 229 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 169 | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | | #ifdef COFF_IMAGE_WITH_PE | 343 | | if (aouthdr) | 344 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | | #endif | 346 | | | 347 | 229 | #ifdef ARM | 348 | 229 | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | 0 | coff_data (abfd) ->flags = 0; | 350 | 229 | #endif | 351 | | | 352 | 229 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 229 | sizeof (pe->dos_message)); | 354 | | | 355 | 229 | return (void *) pe; | 356 | 229 | } |
pe-i386.c:pe_mkobject_hook Line | Count | Source | 308 | 725 | { | 309 | 725 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 725 | pe_data_type *pe; | 311 | | | 312 | 725 | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 725 | pe = pe_data (abfd); | 316 | 725 | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 725 | pe->coff.local_n_btmask = N_BTMASK; | 321 | 725 | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 725 | pe->coff.local_n_tmask = N_TMASK; | 323 | 725 | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 725 | pe->coff.local_symesz = SYMESZ; | 325 | 725 | pe->coff.local_auxesz = AUXESZ; | 326 | 725 | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 725 | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 725 | obj_raw_syment_count (abfd) = | 331 | 725 | obj_conv_table_size (abfd) = | 332 | 725 | internal_f->f_nsyms; | 333 | | | 334 | 725 | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 725 | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 247 | pe->dll = 1; | 338 | | | 339 | 725 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 559 | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | | #ifdef COFF_IMAGE_WITH_PE | 343 | | if (aouthdr) | 344 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 725 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 725 | sizeof (pe->dos_message)); | 354 | | | 355 | 725 | return (void *) pe; | 356 | 725 | } |
pe-mcore.c:pe_mkobject_hook Line | Count | Source | 308 | 399 | { | 309 | 399 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 399 | pe_data_type *pe; | 311 | | | 312 | 399 | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 399 | pe = pe_data (abfd); | 316 | 399 | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 399 | pe->coff.local_n_btmask = N_BTMASK; | 321 | 399 | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 399 | pe->coff.local_n_tmask = N_TMASK; | 323 | 399 | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 399 | pe->coff.local_symesz = SYMESZ; | 325 | 399 | pe->coff.local_auxesz = AUXESZ; | 326 | 399 | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 399 | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 399 | obj_raw_syment_count (abfd) = | 331 | 399 | obj_conv_table_size (abfd) = | 332 | 399 | internal_f->f_nsyms; | 333 | | | 334 | 399 | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 399 | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 56 | pe->dll = 1; | 338 | | | 339 | 399 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 306 | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | | #ifdef COFF_IMAGE_WITH_PE | 343 | | if (aouthdr) | 344 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 399 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 399 | sizeof (pe->dos_message)); | 354 | | | 355 | 399 | return (void *) pe; | 356 | 399 | } |
Line | Count | Source | 308 | 479 | { | 309 | 479 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 479 | pe_data_type *pe; | 311 | | | 312 | 479 | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 479 | pe = pe_data (abfd); | 316 | 479 | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 479 | pe->coff.local_n_btmask = N_BTMASK; | 321 | 479 | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 479 | pe->coff.local_n_tmask = N_TMASK; | 323 | 479 | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 479 | pe->coff.local_symesz = SYMESZ; | 325 | 479 | pe->coff.local_auxesz = AUXESZ; | 326 | 479 | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 479 | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 479 | obj_raw_syment_count (abfd) = | 331 | 479 | obj_conv_table_size (abfd) = | 332 | 479 | internal_f->f_nsyms; | 333 | | | 334 | 479 | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 479 | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 156 | pe->dll = 1; | 338 | | | 339 | 479 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 250 | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | | #ifdef COFF_IMAGE_WITH_PE | 343 | | if (aouthdr) | 344 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 479 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 479 | sizeof (pe->dos_message)); | 354 | | | 355 | 479 | return (void *) pe; | 356 | 479 | } |
pei-arm-wince.c:pe_mkobject_hook Line | Count | Source | 308 | 284 | { | 309 | 284 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 284 | pe_data_type *pe; | 311 | | | 312 | 284 | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 284 | pe = pe_data (abfd); | 316 | 284 | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 284 | pe->coff.local_n_btmask = N_BTMASK; | 321 | 284 | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 284 | pe->coff.local_n_tmask = N_TMASK; | 323 | 284 | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 284 | pe->coff.local_symesz = SYMESZ; | 325 | 284 | pe->coff.local_auxesz = AUXESZ; | 326 | 284 | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 284 | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 284 | obj_raw_syment_count (abfd) = | 331 | 284 | obj_conv_table_size (abfd) = | 332 | 284 | internal_f->f_nsyms; | 333 | | | 334 | 284 | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 284 | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 61 | pe->dll = 1; | 338 | | | 339 | 284 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 131 | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | 284 | #ifdef COFF_IMAGE_WITH_PE | 343 | 284 | if (aouthdr) | 344 | 171 | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | 284 | #endif | 346 | | | 347 | 284 | #ifdef ARM | 348 | 284 | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | 0 | coff_data (abfd) ->flags = 0; | 350 | 284 | #endif | 351 | | | 352 | 284 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 284 | sizeof (pe->dos_message)); | 354 | | | 355 | 284 | return (void *) pe; | 356 | 284 | } |
pei-arm.c:pe_mkobject_hook Line | Count | Source | 308 | 469 | { | 309 | 469 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 469 | pe_data_type *pe; | 311 | | | 312 | 469 | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 469 | pe = pe_data (abfd); | 316 | 469 | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 469 | pe->coff.local_n_btmask = N_BTMASK; | 321 | 469 | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 469 | pe->coff.local_n_tmask = N_TMASK; | 323 | 469 | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 469 | pe->coff.local_symesz = SYMESZ; | 325 | 469 | pe->coff.local_auxesz = AUXESZ; | 326 | 469 | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 469 | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 469 | obj_raw_syment_count (abfd) = | 331 | 469 | obj_conv_table_size (abfd) = | 332 | 469 | internal_f->f_nsyms; | 333 | | | 334 | 469 | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 469 | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 130 | pe->dll = 1; | 338 | | | 339 | 469 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 258 | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | 469 | #ifdef COFF_IMAGE_WITH_PE | 343 | 469 | if (aouthdr) | 344 | 352 | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | 469 | #endif | 346 | | | 347 | 469 | #ifdef ARM | 348 | 469 | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | 0 | coff_data (abfd) ->flags = 0; | 350 | 469 | #endif | 351 | | | 352 | 469 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 469 | sizeof (pe->dos_message)); | 354 | | | 355 | 469 | return (void *) pe; | 356 | 469 | } |
pei-mcore.c:pe_mkobject_hook Line | Count | Source | 308 | 298 | { | 309 | 298 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 298 | pe_data_type *pe; | 311 | | | 312 | 298 | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 298 | pe = pe_data (abfd); | 316 | 298 | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 298 | pe->coff.local_n_btmask = N_BTMASK; | 321 | 298 | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 298 | pe->coff.local_n_tmask = N_TMASK; | 323 | 298 | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 298 | pe->coff.local_symesz = SYMESZ; | 325 | 298 | pe->coff.local_auxesz = AUXESZ; | 326 | 298 | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 298 | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 298 | obj_raw_syment_count (abfd) = | 331 | 298 | obj_conv_table_size (abfd) = | 332 | 298 | internal_f->f_nsyms; | 333 | | | 334 | 298 | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 298 | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 113 | pe->dll = 1; | 338 | | | 339 | 298 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 264 | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | 298 | #ifdef COFF_IMAGE_WITH_PE | 343 | 298 | if (aouthdr) | 344 | 171 | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | 298 | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 298 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 298 | sizeof (pe->dos_message)); | 354 | | | 355 | 298 | return (void *) pe; | 356 | 298 | } |
pei-sh.c:pe_mkobject_hook Line | Count | Source | 308 | 342 | { | 309 | 342 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 342 | pe_data_type *pe; | 311 | | | 312 | 342 | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 342 | pe = pe_data (abfd); | 316 | 342 | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 342 | pe->coff.local_n_btmask = N_BTMASK; | 321 | 342 | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 342 | pe->coff.local_n_tmask = N_TMASK; | 323 | 342 | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 342 | pe->coff.local_symesz = SYMESZ; | 325 | 342 | pe->coff.local_auxesz = AUXESZ; | 326 | 342 | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 342 | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 342 | obj_raw_syment_count (abfd) = | 331 | 342 | obj_conv_table_size (abfd) = | 332 | 342 | internal_f->f_nsyms; | 333 | | | 334 | 342 | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 342 | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 41 | pe->dll = 1; | 338 | | | 339 | 342 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 306 | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | 342 | #ifdef COFF_IMAGE_WITH_PE | 343 | 342 | if (aouthdr) | 344 | 220 | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | 342 | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 342 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 342 | sizeof (pe->dos_message)); | 354 | | | 355 | 342 | return (void *) pe; | 356 | 342 | } |
|
357 | | |
358 | | static bool |
359 | | pe_print_private_bfd_data (bfd *abfd, void * vfile) |
360 | 0 | { |
361 | 0 | FILE *file = (FILE *) vfile; |
362 | |
|
363 | 0 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) |
364 | 0 | return false; |
365 | | |
366 | 0 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) |
367 | 0 | return true; |
368 | | |
369 | 0 | fputc ('\n', file); |
370 | |
|
371 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); |
372 | 0 | } Unexecuted instantiation: pei-i386.c:pe_print_private_bfd_data Unexecuted instantiation: pe-x86_64.c:pe_print_private_bfd_data Unexecuted instantiation: pei-x86_64.c:pe_print_private_bfd_data Unexecuted instantiation: pei-aarch64.c:pe_print_private_bfd_data Unexecuted instantiation: pe-aarch64.c:pe_print_private_bfd_data Unexecuted instantiation: pei-ia64.c:pe_print_private_bfd_data Unexecuted instantiation: pei-loongarch64.c:pe_print_private_bfd_data Unexecuted instantiation: pe-arm-wince.c:pe_print_private_bfd_data Unexecuted instantiation: pe-arm.c:pe_print_private_bfd_data Unexecuted instantiation: pe-i386.c:pe_print_private_bfd_data Unexecuted instantiation: pe-mcore.c:pe_print_private_bfd_data Unexecuted instantiation: pe-sh.c:pe_print_private_bfd_data Unexecuted instantiation: pei-arm-wince.c:pe_print_private_bfd_data Unexecuted instantiation: pei-arm.c:pe_print_private_bfd_data Unexecuted instantiation: pei-mcore.c:pe_print_private_bfd_data Unexecuted instantiation: pei-sh.c:pe_print_private_bfd_data |
373 | | |
374 | | /* Copy any private info we understand from the input bfd |
375 | | to the output bfd. */ |
376 | | |
377 | | static bool |
378 | | pe_bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd) |
379 | 0 | { |
380 | | /* PR binutils/716: Copy the large address aware flag. |
381 | | XXX: Should we be copying other flags or other fields in the pe_data() |
382 | | structure ? */ |
383 | 0 | if (pe_data (obfd) != NULL |
384 | 0 | && pe_data (ibfd) != NULL |
385 | 0 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) |
386 | 0 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; |
387 | |
|
388 | 0 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) |
389 | 0 | return false; |
390 | | |
391 | 0 | if (pe_saved_coff_bfd_copy_private_bfd_data) |
392 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); |
393 | | |
394 | 0 | return true; |
395 | 0 | } Unexecuted instantiation: pei-i386.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pe-x86_64.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-x86_64.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-aarch64.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pe-aarch64.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-ia64.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-loongarch64.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pe-arm-wince.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pe-arm.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pe-i386.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pe-mcore.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pe-sh.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-arm-wince.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-arm.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-mcore.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-sh.c:pe_bfd_copy_private_bfd_data |
396 | | |
397 | | #define coff_bfd_copy_private_section_data \ |
398 | | _bfd_XX_bfd_copy_private_section_data |
399 | | |
400 | | #define coff_get_symbol_info _bfd_XX_get_symbol_info |
401 | | |
402 | | #ifdef COFF_IMAGE_WITH_PE |
403 | | |
404 | | /* Code to handle Microsoft's Import Library Format. |
405 | | Also known as LINK6 format. |
406 | | Documentation about this format can be found at: |
407 | | |
408 | | https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#import-library-format */ |
409 | | |
410 | | /* The following constants specify the sizes of the various data |
411 | | structures that we have to create in order to build a bfd describing |
412 | | an ILF object file. The final "+ 1" in the definitions of SIZEOF_IDATA6 |
413 | | and SIZEOF_IDATA7 below is to allow for the possibility that we might |
414 | | need a padding byte in order to ensure 16 bit alignment for the section's |
415 | | contents. |
416 | | |
417 | | The value for SIZEOF_ILF_STRINGS is computed as follows: |
418 | | |
419 | | There will be NUM_ILF_SECTIONS section symbols. Allow 9 characters |
420 | | per symbol for their names (longest section name is .idata$x). |
421 | | |
422 | | There will be two symbols for the imported value, one the symbol name |
423 | | and one with _imp__ prefixed. Allowing for the terminating nul's this |
424 | | is strlen (symbol_name) * 2 + 8 + 21 + strlen (source_dll). |
425 | | |
426 | | The strings in the string table must start STRING__SIZE_SIZE bytes into |
427 | | the table in order to for the string lookup code in coffgen/coffcode to |
428 | | work. */ |
429 | 732 | #define NUM_ILF_RELOCS 8 |
430 | 2.44k | #define NUM_ILF_SECTIONS 6 |
431 | 1.83k | #define NUM_ILF_SYMS (2 + NUM_ILF_SECTIONS) |
432 | | |
433 | 366 | #define SIZEOF_ILF_SYMS (NUM_ILF_SYMS * sizeof (* vars.sym_cache)) |
434 | 366 | #define SIZEOF_ILF_SYM_TABLE (NUM_ILF_SYMS * sizeof (* vars.sym_table)) |
435 | 366 | #define SIZEOF_ILF_NATIVE_SYMS (NUM_ILF_SYMS * sizeof (* vars.native_syms)) |
436 | 366 | #define SIZEOF_ILF_SYM_PTR_TABLE (NUM_ILF_SYMS * sizeof (* vars.sym_ptr_table)) |
437 | 366 | #define SIZEOF_ILF_EXT_SYMS (NUM_ILF_SYMS * sizeof (* vars.esym_table)) |
438 | 366 | #define SIZEOF_ILF_RELOCS (NUM_ILF_RELOCS * sizeof (* vars.reltab)) |
439 | 366 | #define SIZEOF_ILF_INT_RELOCS (NUM_ILF_RELOCS * sizeof (* vars.int_reltab)) |
440 | 366 | #define SIZEOF_ILF_STRINGS (strlen (symbol_name) * 2 + 8 \ |
441 | 366 | + 21 + strlen (source_dll) \ |
442 | 366 | + NUM_ILF_SECTIONS * 9 \ |
443 | 366 | + STRING_SIZE_SIZE) |
444 | 244 | #define SIZEOF_IDATA2 (5 * 4) |
445 | | |
446 | | /* For PEx64 idata4 & 5 have thumb size of 8 bytes. */ |
447 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) |
448 | 51 | #define SIZEOF_IDATA4 (2 * 4) |
449 | 51 | #define SIZEOF_IDATA5 (2 * 4) |
450 | | #else |
451 | 315 | #define SIZEOF_IDATA4 (1 * 4) |
452 | 315 | #define SIZEOF_IDATA5 (1 * 4) |
453 | | #endif |
454 | | |
455 | 308 | #define SIZEOF_IDATA6 (2 + strlen (symbol_name) + 1 + 1) |
456 | 244 | #define SIZEOF_IDATA7 (strlen (source_dll) + 1 + 1) |
457 | 244 | #define SIZEOF_ILF_SECTIONS (NUM_ILF_SECTIONS * sizeof (struct coff_section_tdata)) |
458 | | |
459 | | #define ILF_DATA_SIZE \ |
460 | 244 | + SIZEOF_ILF_SYMS \ |
461 | 244 | + SIZEOF_ILF_SYM_TABLE \ |
462 | 244 | + SIZEOF_ILF_NATIVE_SYMS \ |
463 | 244 | + SIZEOF_ILF_SYM_PTR_TABLE \ |
464 | 244 | + SIZEOF_ILF_EXT_SYMS \ |
465 | 244 | + SIZEOF_ILF_RELOCS \ |
466 | 244 | + SIZEOF_ILF_INT_RELOCS \ |
467 | 244 | + SIZEOF_ILF_STRINGS \ |
468 | 244 | + SIZEOF_IDATA2 \ |
469 | 244 | + SIZEOF_IDATA4 \ |
470 | 244 | + SIZEOF_IDATA5 \ |
471 | 244 | + SIZEOF_IDATA6 \ |
472 | 244 | + SIZEOF_IDATA7 \ |
473 | 244 | + SIZEOF_ILF_SECTIONS \ |
474 | 244 | + MAX_TEXT_SECTION_SIZE |
475 | | |
476 | | /* Create an empty relocation against the given symbol. */ |
477 | | |
478 | | static void |
479 | | pe_ILF_make_a_symbol_reloc (pe_ILF_vars * vars, |
480 | | bfd_vma address, |
481 | | bfd_reloc_code_real_type reloc, |
482 | | struct bfd_symbol ** sym, |
483 | | unsigned int sym_index) |
484 | 193 | { |
485 | 193 | arelent * entry; |
486 | 193 | struct internal_reloc * internal; |
487 | | |
488 | 193 | entry = vars->reltab + vars->relcount; |
489 | 193 | internal = vars->int_reltab + vars->relcount; |
490 | | |
491 | 193 | entry->address = address; |
492 | 193 | entry->addend = 0; |
493 | 193 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); |
494 | 193 | entry->sym_ptr_ptr = sym; |
495 | | |
496 | 193 | internal->r_vaddr = address; |
497 | 193 | internal->r_symndx = sym_index; |
498 | 193 | internal->r_type = entry->howto ? entry->howto->type : 0; |
499 | | |
500 | 193 | vars->relcount ++; |
501 | | |
502 | 193 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); |
503 | 193 | } pei-i386.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 484 | 23 | { | 485 | 23 | arelent * entry; | 486 | 23 | struct internal_reloc * internal; | 487 | | | 488 | 23 | entry = vars->reltab + vars->relcount; | 489 | 23 | internal = vars->int_reltab + vars->relcount; | 490 | | | 491 | 23 | entry->address = address; | 492 | 23 | entry->addend = 0; | 493 | 23 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 494 | 23 | entry->sym_ptr_ptr = sym; | 495 | | | 496 | 23 | internal->r_vaddr = address; | 497 | 23 | internal->r_symndx = sym_index; | 498 | 23 | internal->r_type = entry->howto ? entry->howto->type : 0; | 499 | | | 500 | 23 | vars->relcount ++; | 501 | | | 502 | 23 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 503 | 23 | } |
pei-x86_64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 484 | 17 | { | 485 | 17 | arelent * entry; | 486 | 17 | struct internal_reloc * internal; | 487 | | | 488 | 17 | entry = vars->reltab + vars->relcount; | 489 | 17 | internal = vars->int_reltab + vars->relcount; | 490 | | | 491 | 17 | entry->address = address; | 492 | 17 | entry->addend = 0; | 493 | 17 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 494 | 17 | entry->sym_ptr_ptr = sym; | 495 | | | 496 | 17 | internal->r_vaddr = address; | 497 | 17 | internal->r_symndx = sym_index; | 498 | 17 | internal->r_type = entry->howto ? entry->howto->type : 0; | 499 | | | 500 | 17 | vars->relcount ++; | 501 | | | 502 | 17 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 503 | 17 | } |
pei-aarch64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 484 | 15 | { | 485 | 15 | arelent * entry; | 486 | 15 | struct internal_reloc * internal; | 487 | | | 488 | 15 | entry = vars->reltab + vars->relcount; | 489 | 15 | internal = vars->int_reltab + vars->relcount; | 490 | | | 491 | 15 | entry->address = address; | 492 | 15 | entry->addend = 0; | 493 | 15 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 494 | 15 | entry->sym_ptr_ptr = sym; | 495 | | | 496 | 15 | internal->r_vaddr = address; | 497 | 15 | internal->r_symndx = sym_index; | 498 | 15 | internal->r_type = entry->howto ? entry->howto->type : 0; | 499 | | | 500 | 15 | vars->relcount ++; | 501 | | | 502 | 15 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 503 | 15 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_symbol_reloc pei-loongarch64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 484 | 12 | { | 485 | 12 | arelent * entry; | 486 | 12 | struct internal_reloc * internal; | 487 | | | 488 | 12 | entry = vars->reltab + vars->relcount; | 489 | 12 | internal = vars->int_reltab + vars->relcount; | 490 | | | 491 | 12 | entry->address = address; | 492 | 12 | entry->addend = 0; | 493 | 12 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 494 | 12 | entry->sym_ptr_ptr = sym; | 495 | | | 496 | 12 | internal->r_vaddr = address; | 497 | 12 | internal->r_symndx = sym_index; | 498 | 12 | internal->r_type = entry->howto ? entry->howto->type : 0; | 499 | | | 500 | 12 | vars->relcount ++; | 501 | | | 502 | 12 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 503 | 12 | } |
pei-arm-wince.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 484 | 24 | { | 485 | 24 | arelent * entry; | 486 | 24 | struct internal_reloc * internal; | 487 | | | 488 | 24 | entry = vars->reltab + vars->relcount; | 489 | 24 | internal = vars->int_reltab + vars->relcount; | 490 | | | 491 | 24 | entry->address = address; | 492 | 24 | entry->addend = 0; | 493 | 24 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 494 | 24 | entry->sym_ptr_ptr = sym; | 495 | | | 496 | 24 | internal->r_vaddr = address; | 497 | 24 | internal->r_symndx = sym_index; | 498 | 24 | internal->r_type = entry->howto ? entry->howto->type : 0; | 499 | | | 500 | 24 | vars->relcount ++; | 501 | | | 502 | 24 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 503 | 24 | } |
pei-arm.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 484 | 32 | { | 485 | 32 | arelent * entry; | 486 | 32 | struct internal_reloc * internal; | 487 | | | 488 | 32 | entry = vars->reltab + vars->relcount; | 489 | 32 | internal = vars->int_reltab + vars->relcount; | 490 | | | 491 | 32 | entry->address = address; | 492 | 32 | entry->addend = 0; | 493 | 32 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 494 | 32 | entry->sym_ptr_ptr = sym; | 495 | | | 496 | 32 | internal->r_vaddr = address; | 497 | 32 | internal->r_symndx = sym_index; | 498 | 32 | internal->r_type = entry->howto ? entry->howto->type : 0; | 499 | | | 500 | 32 | vars->relcount ++; | 501 | | | 502 | 32 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 503 | 32 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_symbol_reloc pei-sh.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 484 | 70 | { | 485 | 70 | arelent * entry; | 486 | 70 | struct internal_reloc * internal; | 487 | | | 488 | 70 | entry = vars->reltab + vars->relcount; | 489 | 70 | internal = vars->int_reltab + vars->relcount; | 490 | | | 491 | 70 | entry->address = address; | 492 | 70 | entry->addend = 0; | 493 | 70 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 494 | 70 | entry->sym_ptr_ptr = sym; | 495 | | | 496 | 70 | internal->r_vaddr = address; | 497 | 70 | internal->r_symndx = sym_index; | 498 | 70 | internal->r_type = entry->howto ? entry->howto->type : 0; | 499 | | | 500 | 70 | vars->relcount ++; | 501 | | | 502 | 70 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 503 | 70 | } |
|
504 | | |
505 | | /* Create an empty relocation against the given section. */ |
506 | | |
507 | | static void |
508 | | pe_ILF_make_a_reloc (pe_ILF_vars * vars, |
509 | | bfd_vma address, |
510 | | bfd_reloc_code_real_type reloc, |
511 | | asection_ptr sec) |
512 | 128 | { |
513 | 128 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, |
514 | 128 | coff_section_data (vars->abfd, sec)->i); |
515 | 128 | } pei-i386.c:pe_ILF_make_a_reloc Line | Count | Source | 512 | 16 | { | 513 | 16 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 514 | 16 | coff_section_data (vars->abfd, sec)->i); | 515 | 16 | } |
pei-x86_64.c:pe_ILF_make_a_reloc Line | Count | Source | 512 | 12 | { | 513 | 12 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 514 | 12 | coff_section_data (vars->abfd, sec)->i); | 515 | 12 | } |
pei-aarch64.c:pe_ILF_make_a_reloc Line | Count | Source | 512 | 10 | { | 513 | 10 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 514 | 10 | coff_section_data (vars->abfd, sec)->i); | 515 | 10 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_reloc pei-loongarch64.c:pe_ILF_make_a_reloc Line | Count | Source | 512 | 10 | { | 513 | 10 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 514 | 10 | coff_section_data (vars->abfd, sec)->i); | 515 | 10 | } |
pei-arm-wince.c:pe_ILF_make_a_reloc Line | Count | Source | 512 | 16 | { | 513 | 16 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 514 | 16 | coff_section_data (vars->abfd, sec)->i); | 515 | 16 | } |
pei-arm.c:pe_ILF_make_a_reloc Line | Count | Source | 512 | 22 | { | 513 | 22 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 514 | 22 | coff_section_data (vars->abfd, sec)->i); | 515 | 22 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_reloc pei-sh.c:pe_ILF_make_a_reloc Line | Count | Source | 512 | 42 | { | 513 | 42 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 514 | 42 | coff_section_data (vars->abfd, sec)->i); | 515 | 42 | } |
|
516 | | |
517 | | /* Move the queued relocs into the given section. */ |
518 | | |
519 | | static void |
520 | | pe_ILF_save_relocs (pe_ILF_vars * vars, |
521 | | asection_ptr sec) |
522 | 193 | { |
523 | | /* Make sure that there is somewhere to store the internal relocs. */ |
524 | 193 | if (coff_section_data (vars->abfd, sec) == NULL) |
525 | | /* We should probably return an error indication here. */ |
526 | 0 | abort (); |
527 | | |
528 | 193 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; |
529 | | |
530 | 193 | sec->relocation = vars->reltab; |
531 | 193 | sec->reloc_count = vars->relcount; |
532 | 193 | sec->flags |= SEC_RELOC; |
533 | | |
534 | 193 | vars->reltab += vars->relcount; |
535 | 193 | vars->int_reltab += vars->relcount; |
536 | 193 | vars->relcount = 0; |
537 | | |
538 | 193 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); |
539 | 193 | } pei-i386.c:pe_ILF_save_relocs Line | Count | Source | 522 | 23 | { | 523 | | /* Make sure that there is somewhere to store the internal relocs. */ | 524 | 23 | if (coff_section_data (vars->abfd, sec) == NULL) | 525 | | /* We should probably return an error indication here. */ | 526 | 0 | abort (); | 527 | | | 528 | 23 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 529 | | | 530 | 23 | sec->relocation = vars->reltab; | 531 | 23 | sec->reloc_count = vars->relcount; | 532 | 23 | sec->flags |= SEC_RELOC; | 533 | | | 534 | 23 | vars->reltab += vars->relcount; | 535 | 23 | vars->int_reltab += vars->relcount; | 536 | 23 | vars->relcount = 0; | 537 | | | 538 | 23 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 539 | 23 | } |
pei-x86_64.c:pe_ILF_save_relocs Line | Count | Source | 522 | 17 | { | 523 | | /* Make sure that there is somewhere to store the internal relocs. */ | 524 | 17 | if (coff_section_data (vars->abfd, sec) == NULL) | 525 | | /* We should probably return an error indication here. */ | 526 | 0 | abort (); | 527 | | | 528 | 17 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 529 | | | 530 | 17 | sec->relocation = vars->reltab; | 531 | 17 | sec->reloc_count = vars->relcount; | 532 | 17 | sec->flags |= SEC_RELOC; | 533 | | | 534 | 17 | vars->reltab += vars->relcount; | 535 | 17 | vars->int_reltab += vars->relcount; | 536 | 17 | vars->relcount = 0; | 537 | | | 538 | 17 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 539 | 17 | } |
pei-aarch64.c:pe_ILF_save_relocs Line | Count | Source | 522 | 15 | { | 523 | | /* Make sure that there is somewhere to store the internal relocs. */ | 524 | 15 | if (coff_section_data (vars->abfd, sec) == NULL) | 525 | | /* We should probably return an error indication here. */ | 526 | 0 | abort (); | 527 | | | 528 | 15 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 529 | | | 530 | 15 | sec->relocation = vars->reltab; | 531 | 15 | sec->reloc_count = vars->relcount; | 532 | 15 | sec->flags |= SEC_RELOC; | 533 | | | 534 | 15 | vars->reltab += vars->relcount; | 535 | 15 | vars->int_reltab += vars->relcount; | 536 | 15 | vars->relcount = 0; | 537 | | | 538 | 15 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 539 | 15 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_save_relocs pei-loongarch64.c:pe_ILF_save_relocs Line | Count | Source | 522 | 12 | { | 523 | | /* Make sure that there is somewhere to store the internal relocs. */ | 524 | 12 | if (coff_section_data (vars->abfd, sec) == NULL) | 525 | | /* We should probably return an error indication here. */ | 526 | 0 | abort (); | 527 | | | 528 | 12 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 529 | | | 530 | 12 | sec->relocation = vars->reltab; | 531 | 12 | sec->reloc_count = vars->relcount; | 532 | 12 | sec->flags |= SEC_RELOC; | 533 | | | 534 | 12 | vars->reltab += vars->relcount; | 535 | 12 | vars->int_reltab += vars->relcount; | 536 | 12 | vars->relcount = 0; | 537 | | | 538 | 12 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 539 | 12 | } |
pei-arm-wince.c:pe_ILF_save_relocs Line | Count | Source | 522 | 24 | { | 523 | | /* Make sure that there is somewhere to store the internal relocs. */ | 524 | 24 | if (coff_section_data (vars->abfd, sec) == NULL) | 525 | | /* We should probably return an error indication here. */ | 526 | 0 | abort (); | 527 | | | 528 | 24 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 529 | | | 530 | 24 | sec->relocation = vars->reltab; | 531 | 24 | sec->reloc_count = vars->relcount; | 532 | 24 | sec->flags |= SEC_RELOC; | 533 | | | 534 | 24 | vars->reltab += vars->relcount; | 535 | 24 | vars->int_reltab += vars->relcount; | 536 | 24 | vars->relcount = 0; | 537 | | | 538 | 24 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 539 | 24 | } |
pei-arm.c:pe_ILF_save_relocs Line | Count | Source | 522 | 32 | { | 523 | | /* Make sure that there is somewhere to store the internal relocs. */ | 524 | 32 | if (coff_section_data (vars->abfd, sec) == NULL) | 525 | | /* We should probably return an error indication here. */ | 526 | 0 | abort (); | 527 | | | 528 | 32 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 529 | | | 530 | 32 | sec->relocation = vars->reltab; | 531 | 32 | sec->reloc_count = vars->relcount; | 532 | 32 | sec->flags |= SEC_RELOC; | 533 | | | 534 | 32 | vars->reltab += vars->relcount; | 535 | 32 | vars->int_reltab += vars->relcount; | 536 | 32 | vars->relcount = 0; | 537 | | | 538 | 32 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 539 | 32 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_save_relocs pei-sh.c:pe_ILF_save_relocs Line | Count | Source | 522 | 70 | { | 523 | | /* Make sure that there is somewhere to store the internal relocs. */ | 524 | 70 | if (coff_section_data (vars->abfd, sec) == NULL) | 525 | | /* We should probably return an error indication here. */ | 526 | 0 | abort (); | 527 | | | 528 | 70 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 529 | | | 530 | 70 | sec->relocation = vars->reltab; | 531 | 70 | sec->reloc_count = vars->relcount; | 532 | 70 | sec->flags |= SEC_RELOC; | 533 | | | 534 | 70 | vars->reltab += vars->relcount; | 535 | 70 | vars->int_reltab += vars->relcount; | 536 | 70 | vars->relcount = 0; | 537 | | | 538 | 70 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 539 | 70 | } |
|
540 | | |
541 | | /* Create a global symbol and add it to the relevant tables. */ |
542 | | |
543 | | static void |
544 | | pe_ILF_make_a_symbol (pe_ILF_vars * vars, |
545 | | const char * prefix, |
546 | | const char * symbol_name, |
547 | | asection_ptr section, |
548 | | flagword extra_flags) |
549 | 650 | { |
550 | 650 | coff_symbol_type * sym; |
551 | 650 | combined_entry_type * ent; |
552 | 650 | SYMENT * esym; |
553 | 650 | unsigned short sclass; |
554 | | |
555 | 650 | if (extra_flags & BSF_LOCAL) |
556 | 373 | sclass = C_STAT; |
557 | 277 | else |
558 | 277 | sclass = C_EXT; |
559 | | |
560 | | #ifdef THUMBPEMAGIC |
561 | 175 | if (vars->magic == THUMBPEMAGIC) |
562 | 95 | { |
563 | 95 | if (extra_flags & BSF_FUNCTION) |
564 | 12 | sclass = C_THUMBEXTFUNC; |
565 | 83 | else if (extra_flags & BSF_LOCAL) |
566 | 55 | sclass = C_THUMBSTAT; |
567 | 28 | else |
568 | 28 | sclass = C_THUMBEXT; |
569 | 95 | } |
570 | | #endif |
571 | | |
572 | 650 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); |
573 | | |
574 | 650 | sym = vars->sym_ptr; |
575 | 650 | ent = vars->native_ptr; |
576 | 650 | esym = vars->esym_ptr; |
577 | | |
578 | | /* Copy the symbol's name into the string table. */ |
579 | 650 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); |
580 | | |
581 | 650 | if (section == NULL) |
582 | 106 | section = bfd_und_section_ptr; |
583 | | |
584 | | /* Initialise the external symbol. */ |
585 | 650 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, |
586 | 650 | esym->e.e.e_offset); |
587 | 650 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); |
588 | 650 | esym->e_sclass[0] = sclass; |
589 | | |
590 | | /* The following initialisations are unnecessary - the memory is |
591 | | zero initialised. They are just kept here as reminders. */ |
592 | | |
593 | | /* Initialise the internal symbol structure. */ |
594 | 650 | ent->u.syment.n_sclass = sclass; |
595 | 650 | ent->u.syment.n_scnum = section->target_index; |
596 | 650 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; |
597 | 650 | ent->is_sym = true; |
598 | | |
599 | 650 | sym->symbol.the_bfd = vars->abfd; |
600 | 650 | sym->symbol.name = vars->string_ptr; |
601 | 650 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; |
602 | 650 | sym->symbol.section = section; |
603 | 650 | sym->native = ent; |
604 | | |
605 | 650 | * vars->table_ptr = vars->sym_index; |
606 | 650 | * vars->sym_ptr_ptr = sym; |
607 | | |
608 | | /* Adjust pointers for the next symbol. */ |
609 | 650 | vars->sym_index ++; |
610 | 650 | vars->sym_ptr ++; |
611 | 650 | vars->sym_ptr_ptr ++; |
612 | 650 | vars->table_ptr ++; |
613 | 650 | vars->native_ptr ++; |
614 | 650 | vars->esym_ptr ++; |
615 | 650 | vars->string_ptr += len + 1; |
616 | | |
617 | 650 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); |
618 | 650 | } pei-i386.c:pe_ILF_make_a_symbol Line | Count | Source | 549 | 68 | { | 550 | 68 | coff_symbol_type * sym; | 551 | 68 | combined_entry_type * ent; | 552 | 68 | SYMENT * esym; | 553 | 68 | unsigned short sclass; | 554 | | | 555 | 68 | if (extra_flags & BSF_LOCAL) | 556 | 39 | sclass = C_STAT; | 557 | 29 | else | 558 | 29 | sclass = C_EXT; | 559 | | | 560 | | #ifdef THUMBPEMAGIC | 561 | | if (vars->magic == THUMBPEMAGIC) | 562 | | { | 563 | | if (extra_flags & BSF_FUNCTION) | 564 | | sclass = C_THUMBEXTFUNC; | 565 | | else if (extra_flags & BSF_LOCAL) | 566 | | sclass = C_THUMBSTAT; | 567 | | else | 568 | | sclass = C_THUMBEXT; | 569 | | } | 570 | | #endif | 571 | | | 572 | 68 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 573 | | | 574 | 68 | sym = vars->sym_ptr; | 575 | 68 | ent = vars->native_ptr; | 576 | 68 | esym = vars->esym_ptr; | 577 | | | 578 | | /* Copy the symbol's name into the string table. */ | 579 | 68 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 580 | | | 581 | 68 | if (section == NULL) | 582 | 11 | section = bfd_und_section_ptr; | 583 | | | 584 | | /* Initialise the external symbol. */ | 585 | 68 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 586 | 68 | esym->e.e.e_offset); | 587 | 68 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 588 | 68 | esym->e_sclass[0] = sclass; | 589 | | | 590 | | /* The following initialisations are unnecessary - the memory is | 591 | | zero initialised. They are just kept here as reminders. */ | 592 | | | 593 | | /* Initialise the internal symbol structure. */ | 594 | 68 | ent->u.syment.n_sclass = sclass; | 595 | 68 | ent->u.syment.n_scnum = section->target_index; | 596 | 68 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 597 | 68 | ent->is_sym = true; | 598 | | | 599 | 68 | sym->symbol.the_bfd = vars->abfd; | 600 | 68 | sym->symbol.name = vars->string_ptr; | 601 | 68 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 602 | 68 | sym->symbol.section = section; | 603 | 68 | sym->native = ent; | 604 | | | 605 | 68 | * vars->table_ptr = vars->sym_index; | 606 | 68 | * vars->sym_ptr_ptr = sym; | 607 | | | 608 | | /* Adjust pointers for the next symbol. */ | 609 | 68 | vars->sym_index ++; | 610 | 68 | vars->sym_ptr ++; | 611 | 68 | vars->sym_ptr_ptr ++; | 612 | 68 | vars->table_ptr ++; | 613 | 68 | vars->native_ptr ++; | 614 | 68 | vars->esym_ptr ++; | 615 | 68 | vars->string_ptr += len + 1; | 616 | | | 617 | 68 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 618 | 68 | } |
pei-x86_64.c:pe_ILF_make_a_symbol Line | Count | Source | 549 | 50 | { | 550 | 50 | coff_symbol_type * sym; | 551 | 50 | combined_entry_type * ent; | 552 | 50 | SYMENT * esym; | 553 | 50 | unsigned short sclass; | 554 | | | 555 | 50 | if (extra_flags & BSF_LOCAL) | 556 | 29 | sclass = C_STAT; | 557 | 21 | else | 558 | 21 | sclass = C_EXT; | 559 | | | 560 | | #ifdef THUMBPEMAGIC | 561 | | if (vars->magic == THUMBPEMAGIC) | 562 | | { | 563 | | if (extra_flags & BSF_FUNCTION) | 564 | | sclass = C_THUMBEXTFUNC; | 565 | | else if (extra_flags & BSF_LOCAL) | 566 | | sclass = C_THUMBSTAT; | 567 | | else | 568 | | sclass = C_THUMBEXT; | 569 | | } | 570 | | #endif | 571 | | | 572 | 50 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 573 | | | 574 | 50 | sym = vars->sym_ptr; | 575 | 50 | ent = vars->native_ptr; | 576 | 50 | esym = vars->esym_ptr; | 577 | | | 578 | | /* Copy the symbol's name into the string table. */ | 579 | 50 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 580 | | | 581 | 50 | if (section == NULL) | 582 | 8 | section = bfd_und_section_ptr; | 583 | | | 584 | | /* Initialise the external symbol. */ | 585 | 50 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 586 | 50 | esym->e.e.e_offset); | 587 | 50 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 588 | 50 | esym->e_sclass[0] = sclass; | 589 | | | 590 | | /* The following initialisations are unnecessary - the memory is | 591 | | zero initialised. They are just kept here as reminders. */ | 592 | | | 593 | | /* Initialise the internal symbol structure. */ | 594 | 50 | ent->u.syment.n_sclass = sclass; | 595 | 50 | ent->u.syment.n_scnum = section->target_index; | 596 | 50 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 597 | 50 | ent->is_sym = true; | 598 | | | 599 | 50 | sym->symbol.the_bfd = vars->abfd; | 600 | 50 | sym->symbol.name = vars->string_ptr; | 601 | 50 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 602 | 50 | sym->symbol.section = section; | 603 | 50 | sym->native = ent; | 604 | | | 605 | 50 | * vars->table_ptr = vars->sym_index; | 606 | 50 | * vars->sym_ptr_ptr = sym; | 607 | | | 608 | | /* Adjust pointers for the next symbol. */ | 609 | 50 | vars->sym_index ++; | 610 | 50 | vars->sym_ptr ++; | 611 | 50 | vars->sym_ptr_ptr ++; | 612 | 50 | vars->table_ptr ++; | 613 | 50 | vars->native_ptr ++; | 614 | 50 | vars->esym_ptr ++; | 615 | 50 | vars->string_ptr += len + 1; | 616 | | | 617 | 50 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 618 | 50 | } |
pei-aarch64.c:pe_ILF_make_a_symbol Line | Count | Source | 549 | 45 | { | 550 | 45 | coff_symbol_type * sym; | 551 | 45 | combined_entry_type * ent; | 552 | 45 | SYMENT * esym; | 553 | 45 | unsigned short sclass; | 554 | | | 555 | 45 | if (extra_flags & BSF_LOCAL) | 556 | 26 | sclass = C_STAT; | 557 | 19 | else | 558 | 19 | sclass = C_EXT; | 559 | | | 560 | | #ifdef THUMBPEMAGIC | 561 | | if (vars->magic == THUMBPEMAGIC) | 562 | | { | 563 | | if (extra_flags & BSF_FUNCTION) | 564 | | sclass = C_THUMBEXTFUNC; | 565 | | else if (extra_flags & BSF_LOCAL) | 566 | | sclass = C_THUMBSTAT; | 567 | | else | 568 | | sclass = C_THUMBEXT; | 569 | | } | 570 | | #endif | 571 | | | 572 | 45 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 573 | | | 574 | 45 | sym = vars->sym_ptr; | 575 | 45 | ent = vars->native_ptr; | 576 | 45 | esym = vars->esym_ptr; | 577 | | | 578 | | /* Copy the symbol's name into the string table. */ | 579 | 45 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 580 | | | 581 | 45 | if (section == NULL) | 582 | 7 | section = bfd_und_section_ptr; | 583 | | | 584 | | /* Initialise the external symbol. */ | 585 | 45 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 586 | 45 | esym->e.e.e_offset); | 587 | 45 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 588 | 45 | esym->e_sclass[0] = sclass; | 589 | | | 590 | | /* The following initialisations are unnecessary - the memory is | 591 | | zero initialised. They are just kept here as reminders. */ | 592 | | | 593 | | /* Initialise the internal symbol structure. */ | 594 | 45 | ent->u.syment.n_sclass = sclass; | 595 | 45 | ent->u.syment.n_scnum = section->target_index; | 596 | 45 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 597 | 45 | ent->is_sym = true; | 598 | | | 599 | 45 | sym->symbol.the_bfd = vars->abfd; | 600 | 45 | sym->symbol.name = vars->string_ptr; | 601 | 45 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 602 | 45 | sym->symbol.section = section; | 603 | 45 | sym->native = ent; | 604 | | | 605 | 45 | * vars->table_ptr = vars->sym_index; | 606 | 45 | * vars->sym_ptr_ptr = sym; | 607 | | | 608 | | /* Adjust pointers for the next symbol. */ | 609 | 45 | vars->sym_index ++; | 610 | 45 | vars->sym_ptr ++; | 611 | 45 | vars->sym_ptr_ptr ++; | 612 | 45 | vars->table_ptr ++; | 613 | 45 | vars->native_ptr ++; | 614 | 45 | vars->esym_ptr ++; | 615 | 45 | vars->string_ptr += len + 1; | 616 | | | 617 | 45 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 618 | 45 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_symbol pei-loongarch64.c:pe_ILF_make_a_symbol Line | Count | Source | 549 | 39 | { | 550 | 39 | coff_symbol_type * sym; | 551 | 39 | combined_entry_type * ent; | 552 | 39 | SYMENT * esym; | 553 | 39 | unsigned short sclass; | 554 | | | 555 | 39 | if (extra_flags & BSF_LOCAL) | 556 | 23 | sclass = C_STAT; | 557 | 16 | else | 558 | 16 | sclass = C_EXT; | 559 | | | 560 | | #ifdef THUMBPEMAGIC | 561 | | if (vars->magic == THUMBPEMAGIC) | 562 | | { | 563 | | if (extra_flags & BSF_FUNCTION) | 564 | | sclass = C_THUMBEXTFUNC; | 565 | | else if (extra_flags & BSF_LOCAL) | 566 | | sclass = C_THUMBSTAT; | 567 | | else | 568 | | sclass = C_THUMBEXT; | 569 | | } | 570 | | #endif | 571 | | | 572 | 39 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 573 | | | 574 | 39 | sym = vars->sym_ptr; | 575 | 39 | ent = vars->native_ptr; | 576 | 39 | esym = vars->esym_ptr; | 577 | | | 578 | | /* Copy the symbol's name into the string table. */ | 579 | 39 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 580 | | | 581 | 39 | if (section == NULL) | 582 | 7 | section = bfd_und_section_ptr; | 583 | | | 584 | | /* Initialise the external symbol. */ | 585 | 39 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 586 | 39 | esym->e.e.e_offset); | 587 | 39 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 588 | 39 | esym->e_sclass[0] = sclass; | 589 | | | 590 | | /* The following initialisations are unnecessary - the memory is | 591 | | zero initialised. They are just kept here as reminders. */ | 592 | | | 593 | | /* Initialise the internal symbol structure. */ | 594 | 39 | ent->u.syment.n_sclass = sclass; | 595 | 39 | ent->u.syment.n_scnum = section->target_index; | 596 | 39 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 597 | 39 | ent->is_sym = true; | 598 | | | 599 | 39 | sym->symbol.the_bfd = vars->abfd; | 600 | 39 | sym->symbol.name = vars->string_ptr; | 601 | 39 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 602 | 39 | sym->symbol.section = section; | 603 | 39 | sym->native = ent; | 604 | | | 605 | 39 | * vars->table_ptr = vars->sym_index; | 606 | 39 | * vars->sym_ptr_ptr = sym; | 607 | | | 608 | | /* Adjust pointers for the next symbol. */ | 609 | 39 | vars->sym_index ++; | 610 | 39 | vars->sym_ptr ++; | 611 | 39 | vars->sym_ptr_ptr ++; | 612 | 39 | vars->table_ptr ++; | 613 | 39 | vars->native_ptr ++; | 614 | 39 | vars->esym_ptr ++; | 615 | 39 | vars->string_ptr += len + 1; | 616 | | | 617 | 39 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 618 | 39 | } |
pei-arm-wince.c:pe_ILF_make_a_symbol Line | Count | Source | 549 | 76 | { | 550 | 76 | coff_symbol_type * sym; | 551 | 76 | combined_entry_type * ent; | 552 | 76 | SYMENT * esym; | 553 | 76 | unsigned short sclass; | 554 | | | 555 | 76 | if (extra_flags & BSF_LOCAL) | 556 | 44 | sclass = C_STAT; | 557 | 32 | else | 558 | 32 | sclass = C_EXT; | 559 | | | 560 | 76 | #ifdef THUMBPEMAGIC | 561 | 76 | if (vars->magic == THUMBPEMAGIC) | 562 | 36 | { | 563 | 36 | if (extra_flags & BSF_FUNCTION) | 564 | 5 | sclass = C_THUMBEXTFUNC; | 565 | 31 | else if (extra_flags & BSF_LOCAL) | 566 | 21 | sclass = C_THUMBSTAT; | 567 | 10 | else | 568 | 10 | sclass = C_THUMBEXT; | 569 | 36 | } | 570 | 76 | #endif | 571 | | | 572 | 76 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 573 | | | 574 | 76 | sym = vars->sym_ptr; | 575 | 76 | ent = vars->native_ptr; | 576 | 76 | esym = vars->esym_ptr; | 577 | | | 578 | | /* Copy the symbol's name into the string table. */ | 579 | 76 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 580 | | | 581 | 76 | if (section == NULL) | 582 | 12 | section = bfd_und_section_ptr; | 583 | | | 584 | | /* Initialise the external symbol. */ | 585 | 76 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 586 | 76 | esym->e.e.e_offset); | 587 | 76 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 588 | 76 | esym->e_sclass[0] = sclass; | 589 | | | 590 | | /* The following initialisations are unnecessary - the memory is | 591 | | zero initialised. They are just kept here as reminders. */ | 592 | | | 593 | | /* Initialise the internal symbol structure. */ | 594 | 76 | ent->u.syment.n_sclass = sclass; | 595 | 76 | ent->u.syment.n_scnum = section->target_index; | 596 | 76 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 597 | 76 | ent->is_sym = true; | 598 | | | 599 | 76 | sym->symbol.the_bfd = vars->abfd; | 600 | 76 | sym->symbol.name = vars->string_ptr; | 601 | 76 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 602 | 76 | sym->symbol.section = section; | 603 | 76 | sym->native = ent; | 604 | | | 605 | 76 | * vars->table_ptr = vars->sym_index; | 606 | 76 | * vars->sym_ptr_ptr = sym; | 607 | | | 608 | | /* Adjust pointers for the next symbol. */ | 609 | 76 | vars->sym_index ++; | 610 | 76 | vars->sym_ptr ++; | 611 | 76 | vars->sym_ptr_ptr ++; | 612 | 76 | vars->table_ptr ++; | 613 | 76 | vars->native_ptr ++; | 614 | 76 | vars->esym_ptr ++; | 615 | 76 | vars->string_ptr += len + 1; | 616 | | | 617 | 76 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 618 | 76 | } |
pei-arm.c:pe_ILF_make_a_symbol Line | Count | Source | 549 | 99 | { | 550 | 99 | coff_symbol_type * sym; | 551 | 99 | combined_entry_type * ent; | 552 | 99 | SYMENT * esym; | 553 | 99 | unsigned short sclass; | 554 | | | 555 | 99 | if (extra_flags & BSF_LOCAL) | 556 | 57 | sclass = C_STAT; | 557 | 42 | else | 558 | 42 | sclass = C_EXT; | 559 | | | 560 | 99 | #ifdef THUMBPEMAGIC | 561 | 99 | if (vars->magic == THUMBPEMAGIC) | 562 | 59 | { | 563 | 59 | if (extra_flags & BSF_FUNCTION) | 564 | 7 | sclass = C_THUMBEXTFUNC; | 565 | 52 | else if (extra_flags & BSF_LOCAL) | 566 | 34 | sclass = C_THUMBSTAT; | 567 | 18 | else | 568 | 18 | sclass = C_THUMBEXT; | 569 | 59 | } | 570 | 99 | #endif | 571 | | | 572 | 99 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 573 | | | 574 | 99 | sym = vars->sym_ptr; | 575 | 99 | ent = vars->native_ptr; | 576 | 99 | esym = vars->esym_ptr; | 577 | | | 578 | | /* Copy the symbol's name into the string table. */ | 579 | 99 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 580 | | | 581 | 99 | if (section == NULL) | 582 | 16 | section = bfd_und_section_ptr; | 583 | | | 584 | | /* Initialise the external symbol. */ | 585 | 99 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 586 | 99 | esym->e.e.e_offset); | 587 | 99 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 588 | 99 | esym->e_sclass[0] = sclass; | 589 | | | 590 | | /* The following initialisations are unnecessary - the memory is | 591 | | zero initialised. They are just kept here as reminders. */ | 592 | | | 593 | | /* Initialise the internal symbol structure. */ | 594 | 99 | ent->u.syment.n_sclass = sclass; | 595 | 99 | ent->u.syment.n_scnum = section->target_index; | 596 | 99 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 597 | 99 | ent->is_sym = true; | 598 | | | 599 | 99 | sym->symbol.the_bfd = vars->abfd; | 600 | 99 | sym->symbol.name = vars->string_ptr; | 601 | 99 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 602 | 99 | sym->symbol.section = section; | 603 | 99 | sym->native = ent; | 604 | | | 605 | 99 | * vars->table_ptr = vars->sym_index; | 606 | 99 | * vars->sym_ptr_ptr = sym; | 607 | | | 608 | | /* Adjust pointers for the next symbol. */ | 609 | 99 | vars->sym_index ++; | 610 | 99 | vars->sym_ptr ++; | 611 | 99 | vars->sym_ptr_ptr ++; | 612 | 99 | vars->table_ptr ++; | 613 | 99 | vars->native_ptr ++; | 614 | 99 | vars->esym_ptr ++; | 615 | 99 | vars->string_ptr += len + 1; | 616 | | | 617 | 99 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 618 | 99 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_symbol pei-sh.c:pe_ILF_make_a_symbol Line | Count | Source | 549 | 273 | { | 550 | 273 | coff_symbol_type * sym; | 551 | 273 | combined_entry_type * ent; | 552 | 273 | SYMENT * esym; | 553 | 273 | unsigned short sclass; | 554 | | | 555 | 273 | if (extra_flags & BSF_LOCAL) | 556 | 155 | sclass = C_STAT; | 557 | 118 | else | 558 | 118 | sclass = C_EXT; | 559 | | | 560 | | #ifdef THUMBPEMAGIC | 561 | | if (vars->magic == THUMBPEMAGIC) | 562 | | { | 563 | | if (extra_flags & BSF_FUNCTION) | 564 | | sclass = C_THUMBEXTFUNC; | 565 | | else if (extra_flags & BSF_LOCAL) | 566 | | sclass = C_THUMBSTAT; | 567 | | else | 568 | | sclass = C_THUMBEXT; | 569 | | } | 570 | | #endif | 571 | | | 572 | 273 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 573 | | | 574 | 273 | sym = vars->sym_ptr; | 575 | 273 | ent = vars->native_ptr; | 576 | 273 | esym = vars->esym_ptr; | 577 | | | 578 | | /* Copy the symbol's name into the string table. */ | 579 | 273 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 580 | | | 581 | 273 | if (section == NULL) | 582 | 45 | section = bfd_und_section_ptr; | 583 | | | 584 | | /* Initialise the external symbol. */ | 585 | 273 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 586 | 273 | esym->e.e.e_offset); | 587 | 273 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 588 | 273 | esym->e_sclass[0] = sclass; | 589 | | | 590 | | /* The following initialisations are unnecessary - the memory is | 591 | | zero initialised. They are just kept here as reminders. */ | 592 | | | 593 | | /* Initialise the internal symbol structure. */ | 594 | 273 | ent->u.syment.n_sclass = sclass; | 595 | 273 | ent->u.syment.n_scnum = section->target_index; | 596 | 273 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 597 | 273 | ent->is_sym = true; | 598 | | | 599 | 273 | sym->symbol.the_bfd = vars->abfd; | 600 | 273 | sym->symbol.name = vars->string_ptr; | 601 | 273 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 602 | 273 | sym->symbol.section = section; | 603 | 273 | sym->native = ent; | 604 | | | 605 | 273 | * vars->table_ptr = vars->sym_index; | 606 | 273 | * vars->sym_ptr_ptr = sym; | 607 | | | 608 | | /* Adjust pointers for the next symbol. */ | 609 | 273 | vars->sym_index ++; | 610 | 273 | vars->sym_ptr ++; | 611 | 273 | vars->sym_ptr_ptr ++; | 612 | 273 | vars->table_ptr ++; | 613 | 273 | vars->native_ptr ++; | 614 | 273 | vars->esym_ptr ++; | 615 | 273 | vars->string_ptr += len + 1; | 616 | | | 617 | 273 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 618 | 273 | } |
|
619 | | |
620 | | /* Create a section. */ |
621 | | |
622 | | static asection_ptr |
623 | | pe_ILF_make_a_section (pe_ILF_vars * vars, |
624 | | const char * name, |
625 | | unsigned int size, |
626 | | flagword extra_flags) |
627 | 373 | { |
628 | 373 | asection_ptr sec; |
629 | 373 | flagword flags; |
630 | 373 | intptr_t alignment; |
631 | | |
632 | 373 | sec = bfd_make_section_old_way (vars->abfd, name); |
633 | 373 | if (sec == NULL) |
634 | 0 | return NULL; |
635 | | |
636 | 373 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; |
637 | | |
638 | 373 | bfd_set_section_flags (sec, flags | extra_flags); |
639 | | |
640 | 373 | bfd_set_section_alignment (sec, 2); |
641 | | |
642 | | /* Check that we will not run out of space. */ |
643 | 373 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); |
644 | | |
645 | | /* Set the section size and contents. The actual |
646 | | contents are filled in by our parent. */ |
647 | 373 | bfd_set_section_size (sec, (bfd_size_type) size); |
648 | 373 | sec->contents = vars->data; |
649 | 373 | sec->target_index = vars->sec_index ++; |
650 | | |
651 | | /* Advance data pointer in the vars structure. */ |
652 | 373 | vars->data += size; |
653 | | |
654 | | /* Skip the padding byte if it was not needed. |
655 | | The logic here is that if the string length is odd, |
656 | | then the entire string length, including the null byte, |
657 | | is even and so the extra, padding byte, is not needed. */ |
658 | 373 | if (size & 1) |
659 | 16 | vars->data --; |
660 | | |
661 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we |
662 | | preserve host alignment requirements. The BFD_ASSERTs in this |
663 | | functions will warn us if we run out of room, but we should |
664 | | already have enough padding built in to ILF_DATA_SIZE. */ |
665 | 373 | #if GCC_VERSION >= 3000 |
666 | 373 | alignment = __alignof__ (struct coff_section_tdata); |
667 | | #else |
668 | | alignment = 8; |
669 | | #endif |
670 | 373 | vars->data |
671 | 373 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); |
672 | | |
673 | | /* Create a coff_section_tdata structure for our use. */ |
674 | 373 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; |
675 | 373 | vars->data += sizeof (struct coff_section_tdata); |
676 | | |
677 | 373 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); |
678 | | |
679 | | /* Create a symbol to refer to this section. */ |
680 | 373 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); |
681 | | |
682 | | /* Cache the index to the symbol in the coff_section_data structure. */ |
683 | 373 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; |
684 | | |
685 | 373 | return sec; |
686 | 373 | } pei-i386.c:pe_ILF_make_a_section Line | Count | Source | 627 | 39 | { | 628 | 39 | asection_ptr sec; | 629 | 39 | flagword flags; | 630 | 39 | intptr_t alignment; | 631 | | | 632 | 39 | sec = bfd_make_section_old_way (vars->abfd, name); | 633 | 39 | if (sec == NULL) | 634 | 0 | return NULL; | 635 | | | 636 | 39 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 637 | | | 638 | 39 | bfd_set_section_flags (sec, flags | extra_flags); | 639 | | | 640 | 39 | bfd_set_section_alignment (sec, 2); | 641 | | | 642 | | /* Check that we will not run out of space. */ | 643 | 39 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 644 | | | 645 | | /* Set the section size and contents. The actual | 646 | | contents are filled in by our parent. */ | 647 | 39 | bfd_set_section_size (sec, (bfd_size_type) size); | 648 | 39 | sec->contents = vars->data; | 649 | 39 | sec->target_index = vars->sec_index ++; | 650 | | | 651 | | /* Advance data pointer in the vars structure. */ | 652 | 39 | vars->data += size; | 653 | | | 654 | | /* Skip the padding byte if it was not needed. | 655 | | The logic here is that if the string length is odd, | 656 | | then the entire string length, including the null byte, | 657 | | is even and so the extra, padding byte, is not needed. */ | 658 | 39 | if (size & 1) | 659 | 4 | vars->data --; | 660 | | | 661 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 662 | | preserve host alignment requirements. The BFD_ASSERTs in this | 663 | | functions will warn us if we run out of room, but we should | 664 | | already have enough padding built in to ILF_DATA_SIZE. */ | 665 | 39 | #if GCC_VERSION >= 3000 | 666 | 39 | alignment = __alignof__ (struct coff_section_tdata); | 667 | | #else | 668 | | alignment = 8; | 669 | | #endif | 670 | 39 | vars->data | 671 | 39 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 672 | | | 673 | | /* Create a coff_section_tdata structure for our use. */ | 674 | 39 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 675 | 39 | vars->data += sizeof (struct coff_section_tdata); | 676 | | | 677 | 39 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 678 | | | 679 | | /* Create a symbol to refer to this section. */ | 680 | 39 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 681 | | | 682 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 683 | 39 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 684 | | | 685 | 39 | return sec; | 686 | 39 | } |
pei-x86_64.c:pe_ILF_make_a_section Line | Count | Source | 627 | 29 | { | 628 | 29 | asection_ptr sec; | 629 | 29 | flagword flags; | 630 | 29 | intptr_t alignment; | 631 | | | 632 | 29 | sec = bfd_make_section_old_way (vars->abfd, name); | 633 | 29 | if (sec == NULL) | 634 | 0 | return NULL; | 635 | | | 636 | 29 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 637 | | | 638 | 29 | bfd_set_section_flags (sec, flags | extra_flags); | 639 | | | 640 | 29 | bfd_set_section_alignment (sec, 2); | 641 | | | 642 | | /* Check that we will not run out of space. */ | 643 | 29 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 644 | | | 645 | | /* Set the section size and contents. The actual | 646 | | contents are filled in by our parent. */ | 647 | 29 | bfd_set_section_size (sec, (bfd_size_type) size); | 648 | 29 | sec->contents = vars->data; | 649 | 29 | sec->target_index = vars->sec_index ++; | 650 | | | 651 | | /* Advance data pointer in the vars structure. */ | 652 | 29 | vars->data += size; | 653 | | | 654 | | /* Skip the padding byte if it was not needed. | 655 | | The logic here is that if the string length is odd, | 656 | | then the entire string length, including the null byte, | 657 | | is even and so the extra, padding byte, is not needed. */ | 658 | 29 | if (size & 1) | 659 | 4 | vars->data --; | 660 | | | 661 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 662 | | preserve host alignment requirements. The BFD_ASSERTs in this | 663 | | functions will warn us if we run out of room, but we should | 664 | | already have enough padding built in to ILF_DATA_SIZE. */ | 665 | 29 | #if GCC_VERSION >= 3000 | 666 | 29 | alignment = __alignof__ (struct coff_section_tdata); | 667 | | #else | 668 | | alignment = 8; | 669 | | #endif | 670 | 29 | vars->data | 671 | 29 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 672 | | | 673 | | /* Create a coff_section_tdata structure for our use. */ | 674 | 29 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 675 | 29 | vars->data += sizeof (struct coff_section_tdata); | 676 | | | 677 | 29 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 678 | | | 679 | | /* Create a symbol to refer to this section. */ | 680 | 29 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 681 | | | 682 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 683 | 29 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 684 | | | 685 | 29 | return sec; | 686 | 29 | } |
pei-aarch64.c:pe_ILF_make_a_section Line | Count | Source | 627 | 26 | { | 628 | 26 | asection_ptr sec; | 629 | 26 | flagword flags; | 630 | 26 | intptr_t alignment; | 631 | | | 632 | 26 | sec = bfd_make_section_old_way (vars->abfd, name); | 633 | 26 | if (sec == NULL) | 634 | 0 | return NULL; | 635 | | | 636 | 26 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 637 | | | 638 | 26 | bfd_set_section_flags (sec, flags | extra_flags); | 639 | | | 640 | 26 | bfd_set_section_alignment (sec, 2); | 641 | | | 642 | | /* Check that we will not run out of space. */ | 643 | 26 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 644 | | | 645 | | /* Set the section size and contents. The actual | 646 | | contents are filled in by our parent. */ | 647 | 26 | bfd_set_section_size (sec, (bfd_size_type) size); | 648 | 26 | sec->contents = vars->data; | 649 | 26 | sec->target_index = vars->sec_index ++; | 650 | | | 651 | | /* Advance data pointer in the vars structure. */ | 652 | 26 | vars->data += size; | 653 | | | 654 | | /* Skip the padding byte if it was not needed. | 655 | | The logic here is that if the string length is odd, | 656 | | then the entire string length, including the null byte, | 657 | | is even and so the extra, padding byte, is not needed. */ | 658 | 26 | if (size & 1) | 659 | 3 | vars->data --; | 660 | | | 661 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 662 | | preserve host alignment requirements. The BFD_ASSERTs in this | 663 | | functions will warn us if we run out of room, but we should | 664 | | already have enough padding built in to ILF_DATA_SIZE. */ | 665 | 26 | #if GCC_VERSION >= 3000 | 666 | 26 | alignment = __alignof__ (struct coff_section_tdata); | 667 | | #else | 668 | | alignment = 8; | 669 | | #endif | 670 | 26 | vars->data | 671 | 26 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 672 | | | 673 | | /* Create a coff_section_tdata structure for our use. */ | 674 | 26 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 675 | 26 | vars->data += sizeof (struct coff_section_tdata); | 676 | | | 677 | 26 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 678 | | | 679 | | /* Create a symbol to refer to this section. */ | 680 | 26 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 681 | | | 682 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 683 | 26 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 684 | | | 685 | 26 | return sec; | 686 | 26 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_section pei-loongarch64.c:pe_ILF_make_a_section Line | Count | Source | 627 | 23 | { | 628 | 23 | asection_ptr sec; | 629 | 23 | flagword flags; | 630 | 23 | intptr_t alignment; | 631 | | | 632 | 23 | sec = bfd_make_section_old_way (vars->abfd, name); | 633 | 23 | if (sec == NULL) | 634 | 0 | return NULL; | 635 | | | 636 | 23 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 637 | | | 638 | 23 | bfd_set_section_flags (sec, flags | extra_flags); | 639 | | | 640 | 23 | bfd_set_section_alignment (sec, 2); | 641 | | | 642 | | /* Check that we will not run out of space. */ | 643 | 23 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 644 | | | 645 | | /* Set the section size and contents. The actual | 646 | | contents are filled in by our parent. */ | 647 | 23 | bfd_set_section_size (sec, (bfd_size_type) size); | 648 | 23 | sec->contents = vars->data; | 649 | 23 | sec->target_index = vars->sec_index ++; | 650 | | | 651 | | /* Advance data pointer in the vars structure. */ | 652 | 23 | vars->data += size; | 653 | | | 654 | | /* Skip the padding byte if it was not needed. | 655 | | The logic here is that if the string length is odd, | 656 | | then the entire string length, including the null byte, | 657 | | is even and so the extra, padding byte, is not needed. */ | 658 | 23 | if (size & 1) | 659 | 1 | vars->data --; | 660 | | | 661 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 662 | | preserve host alignment requirements. The BFD_ASSERTs in this | 663 | | functions will warn us if we run out of room, but we should | 664 | | already have enough padding built in to ILF_DATA_SIZE. */ | 665 | 23 | #if GCC_VERSION >= 3000 | 666 | 23 | alignment = __alignof__ (struct coff_section_tdata); | 667 | | #else | 668 | | alignment = 8; | 669 | | #endif | 670 | 23 | vars->data | 671 | 23 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 672 | | | 673 | | /* Create a coff_section_tdata structure for our use. */ | 674 | 23 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 675 | 23 | vars->data += sizeof (struct coff_section_tdata); | 676 | | | 677 | 23 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 678 | | | 679 | | /* Create a symbol to refer to this section. */ | 680 | 23 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 681 | | | 682 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 683 | 23 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 684 | | | 685 | 23 | return sec; | 686 | 23 | } |
pei-arm-wince.c:pe_ILF_make_a_section Line | Count | Source | 627 | 44 | { | 628 | 44 | asection_ptr sec; | 629 | 44 | flagword flags; | 630 | 44 | intptr_t alignment; | 631 | | | 632 | 44 | sec = bfd_make_section_old_way (vars->abfd, name); | 633 | 44 | if (sec == NULL) | 634 | 0 | return NULL; | 635 | | | 636 | 44 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 637 | | | 638 | 44 | bfd_set_section_flags (sec, flags | extra_flags); | 639 | | | 640 | 44 | bfd_set_section_alignment (sec, 2); | 641 | | | 642 | | /* Check that we will not run out of space. */ | 643 | 44 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 644 | | | 645 | | /* Set the section size and contents. The actual | 646 | | contents are filled in by our parent. */ | 647 | 44 | bfd_set_section_size (sec, (bfd_size_type) size); | 648 | 44 | sec->contents = vars->data; | 649 | 44 | sec->target_index = vars->sec_index ++; | 650 | | | 651 | | /* Advance data pointer in the vars structure. */ | 652 | 44 | vars->data += size; | 653 | | | 654 | | /* Skip the padding byte if it was not needed. | 655 | | The logic here is that if the string length is odd, | 656 | | then the entire string length, including the null byte, | 657 | | is even and so the extra, padding byte, is not needed. */ | 658 | 44 | if (size & 1) | 659 | 2 | vars->data --; | 660 | | | 661 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 662 | | preserve host alignment requirements. The BFD_ASSERTs in this | 663 | | functions will warn us if we run out of room, but we should | 664 | | already have enough padding built in to ILF_DATA_SIZE. */ | 665 | 44 | #if GCC_VERSION >= 3000 | 666 | 44 | alignment = __alignof__ (struct coff_section_tdata); | 667 | | #else | 668 | | alignment = 8; | 669 | | #endif | 670 | 44 | vars->data | 671 | 44 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 672 | | | 673 | | /* Create a coff_section_tdata structure for our use. */ | 674 | 44 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 675 | 44 | vars->data += sizeof (struct coff_section_tdata); | 676 | | | 677 | 44 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 678 | | | 679 | | /* Create a symbol to refer to this section. */ | 680 | 44 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 681 | | | 682 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 683 | 44 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 684 | | | 685 | 44 | return sec; | 686 | 44 | } |
pei-arm.c:pe_ILF_make_a_section Line | Count | Source | 627 | 57 | { | 628 | 57 | asection_ptr sec; | 629 | 57 | flagword flags; | 630 | 57 | intptr_t alignment; | 631 | | | 632 | 57 | sec = bfd_make_section_old_way (vars->abfd, name); | 633 | 57 | if (sec == NULL) | 634 | 0 | return NULL; | 635 | | | 636 | 57 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 637 | | | 638 | 57 | bfd_set_section_flags (sec, flags | extra_flags); | 639 | | | 640 | 57 | bfd_set_section_alignment (sec, 2); | 641 | | | 642 | | /* Check that we will not run out of space. */ | 643 | 57 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 644 | | | 645 | | /* Set the section size and contents. The actual | 646 | | contents are filled in by our parent. */ | 647 | 57 | bfd_set_section_size (sec, (bfd_size_type) size); | 648 | 57 | sec->contents = vars->data; | 649 | 57 | sec->target_index = vars->sec_index ++; | 650 | | | 651 | | /* Advance data pointer in the vars structure. */ | 652 | 57 | vars->data += size; | 653 | | | 654 | | /* Skip the padding byte if it was not needed. | 655 | | The logic here is that if the string length is odd, | 656 | | then the entire string length, including the null byte, | 657 | | is even and so the extra, padding byte, is not needed. */ | 658 | 57 | if (size & 1) | 659 | 2 | vars->data --; | 660 | | | 661 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 662 | | preserve host alignment requirements. The BFD_ASSERTs in this | 663 | | functions will warn us if we run out of room, but we should | 664 | | already have enough padding built in to ILF_DATA_SIZE. */ | 665 | 57 | #if GCC_VERSION >= 3000 | 666 | 57 | alignment = __alignof__ (struct coff_section_tdata); | 667 | | #else | 668 | | alignment = 8; | 669 | | #endif | 670 | 57 | vars->data | 671 | 57 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 672 | | | 673 | | /* Create a coff_section_tdata structure for our use. */ | 674 | 57 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 675 | 57 | vars->data += sizeof (struct coff_section_tdata); | 676 | | | 677 | 57 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 678 | | | 679 | | /* Create a symbol to refer to this section. */ | 680 | 57 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 681 | | | 682 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 683 | 57 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 684 | | | 685 | 57 | return sec; | 686 | 57 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_section pei-sh.c:pe_ILF_make_a_section Line | Count | Source | 627 | 155 | { | 628 | 155 | asection_ptr sec; | 629 | 155 | flagword flags; | 630 | 155 | intptr_t alignment; | 631 | | | 632 | 155 | sec = bfd_make_section_old_way (vars->abfd, name); | 633 | 155 | if (sec == NULL) | 634 | 0 | return NULL; | 635 | | | 636 | 155 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 637 | | | 638 | 155 | bfd_set_section_flags (sec, flags | extra_flags); | 639 | | | 640 | 155 | bfd_set_section_alignment (sec, 2); | 641 | | | 642 | | /* Check that we will not run out of space. */ | 643 | 155 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 644 | | | 645 | | /* Set the section size and contents. The actual | 646 | | contents are filled in by our parent. */ | 647 | 155 | bfd_set_section_size (sec, (bfd_size_type) size); | 648 | 155 | sec->contents = vars->data; | 649 | 155 | sec->target_index = vars->sec_index ++; | 650 | | | 651 | | /* Advance data pointer in the vars structure. */ | 652 | 155 | vars->data += size; | 653 | | | 654 | | /* Skip the padding byte if it was not needed. | 655 | | The logic here is that if the string length is odd, | 656 | | then the entire string length, including the null byte, | 657 | | is even and so the extra, padding byte, is not needed. */ | 658 | 155 | if (size & 1) | 659 | 0 | vars->data --; | 660 | | | 661 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 662 | | preserve host alignment requirements. The BFD_ASSERTs in this | 663 | | functions will warn us if we run out of room, but we should | 664 | | already have enough padding built in to ILF_DATA_SIZE. */ | 665 | 155 | #if GCC_VERSION >= 3000 | 666 | 155 | alignment = __alignof__ (struct coff_section_tdata); | 667 | | #else | 668 | | alignment = 8; | 669 | | #endif | 670 | 155 | vars->data | 671 | 155 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 672 | | | 673 | | /* Create a coff_section_tdata structure for our use. */ | 674 | 155 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 675 | 155 | vars->data += sizeof (struct coff_section_tdata); | 676 | | | 677 | 155 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 678 | | | 679 | | /* Create a symbol to refer to this section. */ | 680 | 155 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 681 | | | 682 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 683 | 155 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 684 | | | 685 | 155 | return sec; | 686 | 155 | } |
|
687 | | |
688 | | /* This structure contains the code that goes into the .text section |
689 | | in order to perform a jump into the DLL lookup table. The entries |
690 | | in the table are index by the magic number used to represent the |
691 | | machine type in the PE file. The contents of the data[] arrays in |
692 | | these entries are stolen from the jtab[] arrays in ld/pe-dll.c. |
693 | | The SIZE field says how many bytes in the DATA array are actually |
694 | | used. The OFFSET field says where in the data array the address |
695 | | of the .idata$5 section should be placed. */ |
696 | 244 | #define MAX_TEXT_SECTION_SIZE 32 |
697 | | |
698 | | typedef struct |
699 | | { |
700 | | unsigned short magic; |
701 | | unsigned char data[MAX_TEXT_SECTION_SIZE]; |
702 | | unsigned int size; |
703 | | unsigned int offset; |
704 | | } |
705 | | jump_table; |
706 | | |
707 | | static const jump_table jtab[] = |
708 | | { |
709 | | #ifdef I386MAGIC |
710 | | { I386MAGIC, |
711 | | { 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90 }, |
712 | | 8, 2 |
713 | | }, |
714 | | #endif |
715 | | |
716 | | #ifdef AMD64MAGIC |
717 | | { AMD64MAGIC, |
718 | | { 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90 }, |
719 | | 8, 2 |
720 | | }, |
721 | | #endif |
722 | | |
723 | | #ifdef MC68MAGIC |
724 | | { MC68MAGIC, |
725 | | { /* XXX fill me in */ }, |
726 | | 0, 0 |
727 | | }, |
728 | | #endif |
729 | | |
730 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
731 | | { MIPS_ARCH_MAGIC_WINCE, |
732 | | { 0x00, 0x00, 0x08, 0x3c, 0x00, 0x00, 0x08, 0x8d, |
733 | | 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }, |
734 | | 16, 0 |
735 | | }, |
736 | | #endif |
737 | | |
738 | | #ifdef SH_ARCH_MAGIC_WINCE |
739 | | { SH_ARCH_MAGIC_WINCE, |
740 | | { 0x01, 0xd0, 0x02, 0x60, 0x2b, 0x40, |
741 | | 0x09, 0x00, 0x00, 0x00, 0x00, 0x00 }, |
742 | | 12, 8 |
743 | | }, |
744 | | #endif |
745 | | |
746 | | #ifdef AARCH64MAGIC |
747 | | /* We don't currently support jumping to DLLs, so if |
748 | | someone does try emit a runtime trap. Through UDF #0. */ |
749 | | { AARCH64MAGIC, |
750 | | { 0x00, 0x00, 0x00, 0x00 }, |
751 | | 4, 0 |
752 | | }, |
753 | | |
754 | | #endif |
755 | | |
756 | | #ifdef ARMPEMAGIC |
757 | | { ARMPEMAGIC, |
758 | | { 0x00, 0xc0, 0x9f, 0xe5, 0x00, 0xf0, |
759 | | 0x9c, 0xe5, 0x00, 0x00, 0x00, 0x00}, |
760 | | 12, 8 |
761 | | }, |
762 | | #endif |
763 | | |
764 | | #ifdef THUMBPEMAGIC |
765 | | { THUMBPEMAGIC, |
766 | | { 0x40, 0xb4, 0x02, 0x4e, 0x36, 0x68, 0xb4, 0x46, |
767 | | 0x40, 0xbc, 0x60, 0x47, 0x00, 0x00, 0x00, 0x00 }, |
768 | | 16, 12 |
769 | | }, |
770 | | #endif |
771 | | |
772 | | #ifdef LOONGARCH64MAGIC |
773 | | /* We don't currently support jumping to DLLs, so if |
774 | | someone does try emit a runtime trap. Through BREAK 0. */ |
775 | | { LOONGARCH64MAGIC, |
776 | | { 0x00, 0x00, 0x2a, 0x00 }, |
777 | | 4, 0 |
778 | | }, |
779 | | |
780 | | #endif |
781 | | |
782 | | { 0, { 0 }, 0, 0 } |
783 | | }; |
784 | | |
785 | | #ifndef NUM_ENTRIES |
786 | 65 | #define NUM_ENTRIES(a) (sizeof (a) / sizeof (a)[0]) |
787 | | #endif |
788 | | |
789 | | /* Build a full BFD from the information supplied in a ILF object. */ |
790 | | |
791 | | static bool |
792 | | pe_ILF_build_a_bfd (bfd * abfd, |
793 | | unsigned int magic, |
794 | | char * symbol_name, |
795 | | char * source_dll, |
796 | | unsigned int ordinal, |
797 | | unsigned int types) |
798 | 148 | { |
799 | 148 | bfd_byte * ptr; |
800 | 148 | pe_ILF_vars vars; |
801 | 148 | struct internal_filehdr internal_f; |
802 | 148 | unsigned int import_type; |
803 | 148 | unsigned int import_name_type; |
804 | 148 | asection_ptr id4, id5, id6 = NULL, text = NULL; |
805 | 148 | coff_symbol_type ** imp_sym; |
806 | 148 | unsigned int imp_index; |
807 | 148 | intptr_t alignment; |
808 | | |
809 | | /* Decode and verify the types field of the ILF structure. */ |
810 | 148 | import_type = types & 0x3; |
811 | 148 | import_name_type = (types & 0x1c) >> 2; |
812 | | |
813 | 148 | switch (import_type) |
814 | 148 | { |
815 | 85 | case IMPORT_CODE: |
816 | 132 | case IMPORT_DATA: |
817 | 132 | break; |
818 | | |
819 | 7 | case IMPORT_CONST: |
820 | | /* XXX code yet to be written. */ |
821 | | /* xgettext:c-format */ |
822 | 7 | _bfd_error_handler (_("%pB: unhandled import type; %x"), |
823 | 7 | abfd, import_type); |
824 | 7 | return false; |
825 | | |
826 | 9 | default: |
827 | | /* xgettext:c-format */ |
828 | 9 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), |
829 | 9 | abfd, import_type); |
830 | 9 | return false; |
831 | 148 | } |
832 | | |
833 | 132 | switch (import_name_type) |
834 | 132 | { |
835 | 58 | case IMPORT_ORDINAL: |
836 | 70 | case IMPORT_NAME: |
837 | 88 | case IMPORT_NAME_NOPREFIX: |
838 | 122 | case IMPORT_NAME_UNDECORATE: |
839 | 122 | break; |
840 | | |
841 | 10 | default: |
842 | | /* xgettext:c-format */ |
843 | 10 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), |
844 | 10 | abfd, import_name_type); |
845 | 10 | return false; |
846 | 132 | } |
847 | | |
848 | | /* Initialise local variables. |
849 | | |
850 | | Note these are kept in a structure rather than being |
851 | | declared as statics since bfd frowns on global variables. |
852 | | |
853 | | We are going to construct the contents of the BFD in memory, |
854 | | so allocate all the space that we will need right now. */ |
855 | 122 | vars.bim |
856 | 122 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); |
857 | 122 | if (vars.bim == NULL) |
858 | 0 | return false; |
859 | | |
860 | 122 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); |
861 | 122 | vars.bim->buffer = ptr; |
862 | 122 | vars.bim->size = ILF_DATA_SIZE; |
863 | 122 | if (ptr == NULL) |
864 | 0 | goto error_return; |
865 | | |
866 | | /* Initialise the pointers to regions of the memory and the |
867 | | other contents of the pe_ILF_vars structure as well. */ |
868 | 122 | vars.sym_cache = (coff_symbol_type *) ptr; |
869 | 122 | vars.sym_ptr = (coff_symbol_type *) ptr; |
870 | 122 | vars.sym_index = 0; |
871 | 122 | ptr += SIZEOF_ILF_SYMS; |
872 | | |
873 | 122 | vars.sym_table = (unsigned int *) ptr; |
874 | 122 | vars.table_ptr = (unsigned int *) ptr; |
875 | 122 | ptr += SIZEOF_ILF_SYM_TABLE; |
876 | | |
877 | 122 | vars.native_syms = (combined_entry_type *) ptr; |
878 | 122 | vars.native_ptr = (combined_entry_type *) ptr; |
879 | 122 | ptr += SIZEOF_ILF_NATIVE_SYMS; |
880 | | |
881 | 122 | vars.sym_ptr_table = (coff_symbol_type **) ptr; |
882 | 122 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; |
883 | 122 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; |
884 | | |
885 | 122 | vars.esym_table = (SYMENT *) ptr; |
886 | 122 | vars.esym_ptr = (SYMENT *) ptr; |
887 | 122 | ptr += SIZEOF_ILF_EXT_SYMS; |
888 | | |
889 | 122 | vars.reltab = (arelent *) ptr; |
890 | 122 | vars.relcount = 0; |
891 | 122 | ptr += SIZEOF_ILF_RELOCS; |
892 | | |
893 | 122 | vars.int_reltab = (struct internal_reloc *) ptr; |
894 | 122 | ptr += SIZEOF_ILF_INT_RELOCS; |
895 | | |
896 | 122 | vars.string_table = (char *) ptr; |
897 | 122 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; |
898 | 122 | ptr += SIZEOF_ILF_STRINGS; |
899 | 122 | vars.end_string_ptr = (char *) ptr; |
900 | | |
901 | | /* The remaining space in bim->buffer is used |
902 | | by the pe_ILF_make_a_section() function. */ |
903 | | |
904 | | /* PR 18758: Make sure that the data area is sufficiently aligned for |
905 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence |
906 | | the test of GCC_VERSION. For other compilers we assume 8 byte |
907 | | alignment. */ |
908 | 122 | #if GCC_VERSION >= 3000 |
909 | 122 | alignment = __alignof__ (struct coff_section_tdata); |
910 | | #else |
911 | | alignment = 8; |
912 | | #endif |
913 | 122 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); |
914 | | |
915 | 122 | vars.data = ptr; |
916 | 122 | vars.abfd = abfd; |
917 | 122 | vars.sec_index = 0; |
918 | 122 | vars.magic = magic; |
919 | | |
920 | | /* Create the initial .idata$<n> sections: |
921 | | [.idata$2: Import Directory Table -- not needed] |
922 | | .idata$4: Import Lookup Table |
923 | | .idata$5: Import Address Table |
924 | | |
925 | | Note we do not create a .idata$3 section as this is |
926 | | created for us by the linker script. */ |
927 | 122 | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); |
928 | 122 | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); |
929 | 122 | if (id4 == NULL || id5 == NULL) |
930 | 0 | goto error_return; |
931 | | |
932 | | /* Fill in the contents of these sections. */ |
933 | 122 | if (import_name_type == IMPORT_ORDINAL) |
934 | 58 | { |
935 | 58 | if (ordinal == 0) |
936 | | /* See PR 20907 for a reproducer. */ |
937 | 16 | goto error_return; |
938 | | |
939 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) |
940 | 6 | ((unsigned int *) id4->contents)[0] = ordinal; |
941 | 6 | ((unsigned int *) id4->contents)[1] = 0x80000000; |
942 | 6 | ((unsigned int *) id5->contents)[0] = ordinal; |
943 | 6 | ((unsigned int *) id5->contents)[1] = 0x80000000; |
944 | | #else |
945 | 36 | * (unsigned int *) id4->contents = ordinal | 0x80000000; |
946 | 36 | * (unsigned int *) id5->contents = ordinal | 0x80000000; |
947 | 36 | #endif |
948 | 36 | } |
949 | 64 | else |
950 | 64 | { |
951 | 64 | char * symbol; |
952 | 64 | unsigned int len; |
953 | | |
954 | | /* Create .idata$6 - the Hint Name Table. */ |
955 | 64 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); |
956 | 64 | if (id6 == NULL) |
957 | 0 | goto error_return; |
958 | | |
959 | | /* If necessary, trim the import symbol name. */ |
960 | 64 | symbol = symbol_name; |
961 | | |
962 | | /* As used by MS compiler, '_', '@', and '?' are alternative |
963 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, |
964 | | '@' used for fastcall (in C), '_' everywhere else. Only one |
965 | | of these is used for a symbol. We strip this leading char for |
966 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the |
967 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ |
968 | | |
969 | 64 | if (import_name_type != IMPORT_NAME) |
970 | 52 | { |
971 | 52 | char c = symbol[0]; |
972 | | |
973 | | /* Check that we don't remove for targets with empty |
974 | | USER_LABEL_PREFIX the leading underscore. */ |
975 | 52 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) |
976 | 52 | || c == '@' || c == '?') |
977 | 15 | symbol++; |
978 | 52 | } |
979 | | |
980 | 64 | len = strlen (symbol); |
981 | 64 | if (import_name_type == IMPORT_NAME_UNDECORATE) |
982 | 34 | { |
983 | | /* Truncate at the first '@'. */ |
984 | 34 | char *at = strchr (symbol, '@'); |
985 | | |
986 | 34 | if (at != NULL) |
987 | 12 | len = at - symbol; |
988 | 34 | } |
989 | | |
990 | 64 | id6->contents[0] = ordinal & 0xff; |
991 | 64 | id6->contents[1] = ordinal >> 8; |
992 | | |
993 | 64 | memcpy ((char *) id6->contents + 2, symbol, len); |
994 | 64 | id6->contents[len + 2] = '\0'; |
995 | 64 | } |
996 | | |
997 | 106 | if (import_name_type != IMPORT_ORDINAL) |
998 | 64 | { |
999 | 64 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); |
1000 | 64 | pe_ILF_save_relocs (&vars, id4); |
1001 | | |
1002 | 64 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); |
1003 | 64 | pe_ILF_save_relocs (&vars, id5); |
1004 | 64 | } |
1005 | | |
1006 | | /* Create an import symbol. */ |
1007 | 106 | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); |
1008 | 106 | imp_sym = vars.sym_ptr_ptr - 1; |
1009 | 106 | imp_index = vars.sym_index - 1; |
1010 | | |
1011 | | /* Create extra sections depending upon the type of import we are dealing with. */ |
1012 | 106 | switch (import_type) |
1013 | 106 | { |
1014 | 0 | int i; |
1015 | | |
1016 | 65 | case IMPORT_CODE: |
1017 | | /* CODE functions are special, in that they get a trampoline that |
1018 | | jumps to the main import symbol. Create a .text section to hold it. |
1019 | | First we need to look up its contents in the jump table. */ |
1020 | 136 | for (i = NUM_ENTRIES (jtab); i--;) |
1021 | 136 | { |
1022 | 136 | if (jtab[i].size == 0) |
1023 | 65 | continue; |
1024 | 71 | if (jtab[i].magic == magic) |
1025 | 65 | break; |
1026 | 71 | } |
1027 | | /* If we did not find a matching entry something is wrong. */ |
1028 | 65 | if (i < 0) |
1029 | 0 | abort (); |
1030 | | |
1031 | | /* Create the .text section. */ |
1032 | 65 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); |
1033 | 65 | if (text == NULL) |
1034 | 0 | goto error_return; |
1035 | | |
1036 | | /* Copy in the jump code. */ |
1037 | 65 | memcpy (text->contents, jtab[i].data, jtab[i].size); |
1038 | | |
1039 | | /* Create a reloc for the data in the text section. */ |
1040 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
1041 | | if (magic == MIPS_ARCH_MAGIC_WINCE) |
1042 | | { |
1043 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, |
1044 | | (struct bfd_symbol **) imp_sym, |
1045 | | imp_index); |
1046 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); |
1047 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, |
1048 | | (struct bfd_symbol **) imp_sym, |
1049 | | imp_index); |
1050 | | } |
1051 | | else |
1052 | | #endif |
1053 | | #ifdef AMD64MAGIC |
1054 | 5 | if (magic == AMD64MAGIC) |
1055 | 5 | { |
1056 | 5 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, |
1057 | 5 | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, |
1058 | 5 | imp_index); |
1059 | 5 | } |
1060 | 0 | else |
1061 | 0 | #endif |
1062 | 0 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, |
1063 | 0 | BFD_RELOC_32, (asymbol **) imp_sym, |
1064 | 0 | imp_index); |
1065 | | |
1066 | 65 | pe_ILF_save_relocs (& vars, text); |
1067 | 65 | break; |
1068 | | |
1069 | 41 | case IMPORT_DATA: |
1070 | 41 | break; |
1071 | | |
1072 | 0 | default: |
1073 | | /* XXX code not yet written. */ |
1074 | 0 | abort (); |
1075 | 106 | } |
1076 | | |
1077 | | /* Now create a symbol describing the imported value. */ |
1078 | 106 | switch (import_type) |
1079 | 106 | { |
1080 | 65 | case IMPORT_CODE: |
1081 | 65 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, |
1082 | 65 | BSF_NOT_AT_END | BSF_FUNCTION); |
1083 | | |
1084 | 65 | break; |
1085 | | |
1086 | 41 | case IMPORT_DATA: |
1087 | | /* Nothing to do here. */ |
1088 | 41 | break; |
1089 | | |
1090 | 0 | default: |
1091 | | /* XXX code not yet written. */ |
1092 | 0 | abort (); |
1093 | 106 | } |
1094 | | |
1095 | | /* Create an import symbol for the DLL, without the .dll suffix. */ |
1096 | 106 | ptr = (bfd_byte *) strrchr (source_dll, '.'); |
1097 | 106 | if (ptr) |
1098 | 8 | * ptr = 0; |
1099 | 106 | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); |
1100 | 106 | if (ptr) |
1101 | 8 | * ptr = '.'; |
1102 | | |
1103 | | /* Initialise the bfd. */ |
1104 | 106 | memset (& internal_f, 0, sizeof (internal_f)); |
1105 | | |
1106 | 106 | internal_f.f_magic = magic; |
1107 | 106 | internal_f.f_symptr = 0; |
1108 | 106 | internal_f.f_nsyms = 0; |
1109 | 106 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ |
1110 | | |
1111 | 106 | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) |
1112 | 106 | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) |
1113 | 0 | goto error_return; |
1114 | | |
1115 | 106 | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) |
1116 | 0 | goto error_return; |
1117 | | |
1118 | 106 | obj_pe (abfd) = true; |
1119 | | #ifdef THUMBPEMAGIC |
1120 | 28 | if (vars.magic == THUMBPEMAGIC) |
1121 | | /* Stop some linker warnings about thumb code not supporting interworking. */ |
1122 | 14 | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; |
1123 | | #endif |
1124 | | |
1125 | | /* Switch from file contents to memory contents. */ |
1126 | 106 | bfd_cache_close (abfd); |
1127 | | |
1128 | 106 | abfd->iostream = (void *) vars.bim; |
1129 | 106 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; |
1130 | 106 | abfd->iovec = &_bfd_memory_iovec; |
1131 | 106 | abfd->where = 0; |
1132 | 106 | abfd->origin = 0; |
1133 | 106 | abfd->size = 0; |
1134 | 106 | obj_sym_filepos (abfd) = 0; |
1135 | | |
1136 | | /* Point the bfd at the symbol table. */ |
1137 | 106 | obj_symbols (abfd) = vars.sym_cache; |
1138 | 106 | abfd->symcount = vars.sym_index; |
1139 | | |
1140 | 106 | obj_raw_syments (abfd) = vars.native_syms; |
1141 | 106 | obj_raw_syment_count (abfd) = vars.sym_index; |
1142 | | |
1143 | 106 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; |
1144 | 106 | obj_coff_keep_syms (abfd) = true; |
1145 | | |
1146 | 106 | obj_convert (abfd) = vars.sym_table; |
1147 | 106 | obj_conv_table_size (abfd) = vars.sym_index; |
1148 | | |
1149 | 106 | obj_coff_strings (abfd) = vars.string_table; |
1150 | 106 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; |
1151 | 106 | obj_coff_keep_strings (abfd) = true; |
1152 | | |
1153 | 106 | return true; |
1154 | | |
1155 | 16 | error_return: |
1156 | 16 | free (vars.bim->buffer); |
1157 | 16 | free (vars.bim); |
1158 | 16 | return false; |
1159 | 106 | } pei-i386.c:pe_ILF_build_a_bfd Line | Count | Source | 798 | 15 | { | 799 | 15 | bfd_byte * ptr; | 800 | 15 | pe_ILF_vars vars; | 801 | 15 | struct internal_filehdr internal_f; | 802 | 15 | unsigned int import_type; | 803 | 15 | unsigned int import_name_type; | 804 | 15 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 805 | 15 | coff_symbol_type ** imp_sym; | 806 | 15 | unsigned int imp_index; | 807 | 15 | intptr_t alignment; | 808 | | | 809 | | /* Decode and verify the types field of the ILF structure. */ | 810 | 15 | import_type = types & 0x3; | 811 | 15 | import_name_type = (types & 0x1c) >> 2; | 812 | | | 813 | 15 | switch (import_type) | 814 | 15 | { | 815 | 9 | case IMPORT_CODE: | 816 | 13 | case IMPORT_DATA: | 817 | 13 | break; | 818 | | | 819 | 1 | case IMPORT_CONST: | 820 | | /* XXX code yet to be written. */ | 821 | | /* xgettext:c-format */ | 822 | 1 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 823 | 1 | abfd, import_type); | 824 | 1 | return false; | 825 | | | 826 | 1 | default: | 827 | | /* xgettext:c-format */ | 828 | 1 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 829 | 1 | abfd, import_type); | 830 | 1 | return false; | 831 | 15 | } | 832 | | | 833 | 13 | switch (import_name_type) | 834 | 13 | { | 835 | 4 | case IMPORT_ORDINAL: | 836 | 6 | case IMPORT_NAME: | 837 | 7 | case IMPORT_NAME_NOPREFIX: | 838 | 12 | case IMPORT_NAME_UNDECORATE: | 839 | 12 | break; | 840 | | | 841 | 1 | default: | 842 | | /* xgettext:c-format */ | 843 | 1 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 844 | 1 | abfd, import_name_type); | 845 | 1 | return false; | 846 | 13 | } | 847 | | | 848 | | /* Initialise local variables. | 849 | | | 850 | | Note these are kept in a structure rather than being | 851 | | declared as statics since bfd frowns on global variables. | 852 | | | 853 | | We are going to construct the contents of the BFD in memory, | 854 | | so allocate all the space that we will need right now. */ | 855 | 12 | vars.bim | 856 | 12 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 857 | 12 | if (vars.bim == NULL) | 858 | 0 | return false; | 859 | | | 860 | 12 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 861 | 12 | vars.bim->buffer = ptr; | 862 | 12 | vars.bim->size = ILF_DATA_SIZE; | 863 | 12 | if (ptr == NULL) | 864 | 0 | goto error_return; | 865 | | | 866 | | /* Initialise the pointers to regions of the memory and the | 867 | | other contents of the pe_ILF_vars structure as well. */ | 868 | 12 | vars.sym_cache = (coff_symbol_type *) ptr; | 869 | 12 | vars.sym_ptr = (coff_symbol_type *) ptr; | 870 | 12 | vars.sym_index = 0; | 871 | 12 | ptr += SIZEOF_ILF_SYMS; | 872 | | | 873 | 12 | vars.sym_table = (unsigned int *) ptr; | 874 | 12 | vars.table_ptr = (unsigned int *) ptr; | 875 | 12 | ptr += SIZEOF_ILF_SYM_TABLE; | 876 | | | 877 | 12 | vars.native_syms = (combined_entry_type *) ptr; | 878 | 12 | vars.native_ptr = (combined_entry_type *) ptr; | 879 | 12 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 880 | | | 881 | 12 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 882 | 12 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 883 | 12 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 884 | | | 885 | 12 | vars.esym_table = (SYMENT *) ptr; | 886 | 12 | vars.esym_ptr = (SYMENT *) ptr; | 887 | 12 | ptr += SIZEOF_ILF_EXT_SYMS; | 888 | | | 889 | 12 | vars.reltab = (arelent *) ptr; | 890 | 12 | vars.relcount = 0; | 891 | 12 | ptr += SIZEOF_ILF_RELOCS; | 892 | | | 893 | 12 | vars.int_reltab = (struct internal_reloc *) ptr; | 894 | 12 | ptr += SIZEOF_ILF_INT_RELOCS; | 895 | | | 896 | 12 | vars.string_table = (char *) ptr; | 897 | 12 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 898 | 12 | ptr += SIZEOF_ILF_STRINGS; | 899 | 12 | vars.end_string_ptr = (char *) ptr; | 900 | | | 901 | | /* The remaining space in bim->buffer is used | 902 | | by the pe_ILF_make_a_section() function. */ | 903 | | | 904 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 905 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 906 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 907 | | alignment. */ | 908 | 12 | #if GCC_VERSION >= 3000 | 909 | 12 | alignment = __alignof__ (struct coff_section_tdata); | 910 | | #else | 911 | | alignment = 8; | 912 | | #endif | 913 | 12 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 914 | | | 915 | 12 | vars.data = ptr; | 916 | 12 | vars.abfd = abfd; | 917 | 12 | vars.sec_index = 0; | 918 | 12 | vars.magic = magic; | 919 | | | 920 | | /* Create the initial .idata$<n> sections: | 921 | | [.idata$2: Import Directory Table -- not needed] | 922 | | .idata$4: Import Lookup Table | 923 | | .idata$5: Import Address Table | 924 | | | 925 | | Note we do not create a .idata$3 section as this is | 926 | | created for us by the linker script. */ | 927 | 12 | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 928 | 12 | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 929 | 12 | if (id4 == NULL || id5 == NULL) | 930 | 0 | goto error_return; | 931 | | | 932 | | /* Fill in the contents of these sections. */ | 933 | 12 | if (import_name_type == IMPORT_ORDINAL) | 934 | 4 | { | 935 | 4 | if (ordinal == 0) | 936 | | /* See PR 20907 for a reproducer. */ | 937 | 1 | goto error_return; | 938 | | | 939 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 940 | | ((unsigned int *) id4->contents)[0] = ordinal; | 941 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 942 | | ((unsigned int *) id5->contents)[0] = ordinal; | 943 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 944 | | #else | 945 | 3 | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 946 | 3 | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 947 | 3 | #endif | 948 | 3 | } | 949 | 8 | else | 950 | 8 | { | 951 | 8 | char * symbol; | 952 | 8 | unsigned int len; | 953 | | | 954 | | /* Create .idata$6 - the Hint Name Table. */ | 955 | 8 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 956 | 8 | if (id6 == NULL) | 957 | 0 | goto error_return; | 958 | | | 959 | | /* If necessary, trim the import symbol name. */ | 960 | 8 | symbol = symbol_name; | 961 | | | 962 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 963 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 964 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 965 | | of these is used for a symbol. We strip this leading char for | 966 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 967 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 968 | | | 969 | 8 | if (import_name_type != IMPORT_NAME) | 970 | 6 | { | 971 | 6 | char c = symbol[0]; | 972 | | | 973 | | /* Check that we don't remove for targets with empty | 974 | | USER_LABEL_PREFIX the leading underscore. */ | 975 | 6 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 976 | 6 | || c == '@' || c == '?') | 977 | 2 | symbol++; | 978 | 6 | } | 979 | | | 980 | 8 | len = strlen (symbol); | 981 | 8 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 982 | 5 | { | 983 | | /* Truncate at the first '@'. */ | 984 | 5 | char *at = strchr (symbol, '@'); | 985 | | | 986 | 5 | if (at != NULL) | 987 | 1 | len = at - symbol; | 988 | 5 | } | 989 | | | 990 | 8 | id6->contents[0] = ordinal & 0xff; | 991 | 8 | id6->contents[1] = ordinal >> 8; | 992 | | | 993 | 8 | memcpy ((char *) id6->contents + 2, symbol, len); | 994 | 8 | id6->contents[len + 2] = '\0'; | 995 | 8 | } | 996 | | | 997 | 11 | if (import_name_type != IMPORT_ORDINAL) | 998 | 8 | { | 999 | 8 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1000 | 8 | pe_ILF_save_relocs (&vars, id4); | 1001 | | | 1002 | 8 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1003 | 8 | pe_ILF_save_relocs (&vars, id5); | 1004 | 8 | } | 1005 | | | 1006 | | /* Create an import symbol. */ | 1007 | 11 | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 1008 | 11 | imp_sym = vars.sym_ptr_ptr - 1; | 1009 | 11 | imp_index = vars.sym_index - 1; | 1010 | | | 1011 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1012 | 11 | switch (import_type) | 1013 | 11 | { | 1014 | 0 | int i; | 1015 | | | 1016 | 7 | case IMPORT_CODE: | 1017 | | /* CODE functions are special, in that they get a trampoline that | 1018 | | jumps to the main import symbol. Create a .text section to hold it. | 1019 | | First we need to look up its contents in the jump table. */ | 1020 | 14 | for (i = NUM_ENTRIES (jtab); i--;) | 1021 | 14 | { | 1022 | 14 | if (jtab[i].size == 0) | 1023 | 7 | continue; | 1024 | 7 | if (jtab[i].magic == magic) | 1025 | 7 | break; | 1026 | 7 | } | 1027 | | /* If we did not find a matching entry something is wrong. */ | 1028 | 7 | if (i < 0) | 1029 | 0 | abort (); | 1030 | | | 1031 | | /* Create the .text section. */ | 1032 | 7 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1033 | 7 | if (text == NULL) | 1034 | 0 | goto error_return; | 1035 | | | 1036 | | /* Copy in the jump code. */ | 1037 | 7 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1038 | | | 1039 | | /* Create a reloc for the data in the text section. */ | 1040 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1041 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1042 | | { | 1043 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1044 | | (struct bfd_symbol **) imp_sym, | 1045 | | imp_index); | 1046 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1047 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1048 | | (struct bfd_symbol **) imp_sym, | 1049 | | imp_index); | 1050 | | } | 1051 | | else | 1052 | | #endif | 1053 | | #ifdef AMD64MAGIC | 1054 | | if (magic == AMD64MAGIC) | 1055 | | { | 1056 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1057 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1058 | | imp_index); | 1059 | | } | 1060 | | else | 1061 | | #endif | 1062 | 7 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1063 | 7 | BFD_RELOC_32, (asymbol **) imp_sym, | 1064 | 7 | imp_index); | 1065 | | | 1066 | 7 | pe_ILF_save_relocs (& vars, text); | 1067 | 7 | break; | 1068 | | | 1069 | 4 | case IMPORT_DATA: | 1070 | 4 | break; | 1071 | | | 1072 | 0 | default: | 1073 | | /* XXX code not yet written. */ | 1074 | 0 | abort (); | 1075 | 11 | } | 1076 | | | 1077 | | /* Now create a symbol describing the imported value. */ | 1078 | 11 | switch (import_type) | 1079 | 11 | { | 1080 | 7 | case IMPORT_CODE: | 1081 | 7 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1082 | 7 | BSF_NOT_AT_END | BSF_FUNCTION); | 1083 | | | 1084 | 7 | break; | 1085 | | | 1086 | 4 | case IMPORT_DATA: | 1087 | | /* Nothing to do here. */ | 1088 | 4 | break; | 1089 | | | 1090 | 0 | default: | 1091 | | /* XXX code not yet written. */ | 1092 | 0 | abort (); | 1093 | 11 | } | 1094 | | | 1095 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1096 | 11 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1097 | 11 | if (ptr) | 1098 | 1 | * ptr = 0; | 1099 | 11 | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1100 | 11 | if (ptr) | 1101 | 1 | * ptr = '.'; | 1102 | | | 1103 | | /* Initialise the bfd. */ | 1104 | 11 | memset (& internal_f, 0, sizeof (internal_f)); | 1105 | | | 1106 | 11 | internal_f.f_magic = magic; | 1107 | 11 | internal_f.f_symptr = 0; | 1108 | 11 | internal_f.f_nsyms = 0; | 1109 | 11 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1110 | | | 1111 | 11 | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1112 | 11 | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1113 | 0 | goto error_return; | 1114 | | | 1115 | 11 | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1116 | 0 | goto error_return; | 1117 | | | 1118 | 11 | obj_pe (abfd) = true; | 1119 | | #ifdef THUMBPEMAGIC | 1120 | | if (vars.magic == THUMBPEMAGIC) | 1121 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1122 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1123 | | #endif | 1124 | | | 1125 | | /* Switch from file contents to memory contents. */ | 1126 | 11 | bfd_cache_close (abfd); | 1127 | | | 1128 | 11 | abfd->iostream = (void *) vars.bim; | 1129 | 11 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1130 | 11 | abfd->iovec = &_bfd_memory_iovec; | 1131 | 11 | abfd->where = 0; | 1132 | 11 | abfd->origin = 0; | 1133 | 11 | abfd->size = 0; | 1134 | 11 | obj_sym_filepos (abfd) = 0; | 1135 | | | 1136 | | /* Point the bfd at the symbol table. */ | 1137 | 11 | obj_symbols (abfd) = vars.sym_cache; | 1138 | 11 | abfd->symcount = vars.sym_index; | 1139 | | | 1140 | 11 | obj_raw_syments (abfd) = vars.native_syms; | 1141 | 11 | obj_raw_syment_count (abfd) = vars.sym_index; | 1142 | | | 1143 | 11 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1144 | 11 | obj_coff_keep_syms (abfd) = true; | 1145 | | | 1146 | 11 | obj_convert (abfd) = vars.sym_table; | 1147 | 11 | obj_conv_table_size (abfd) = vars.sym_index; | 1148 | | | 1149 | 11 | obj_coff_strings (abfd) = vars.string_table; | 1150 | 11 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1151 | 11 | obj_coff_keep_strings (abfd) = true; | 1152 | | | 1153 | 11 | return true; | 1154 | | | 1155 | 1 | error_return: | 1156 | 1 | free (vars.bim->buffer); | 1157 | 1 | free (vars.bim); | 1158 | 1 | return false; | 1159 | 11 | } |
pei-x86_64.c:pe_ILF_build_a_bfd Line | Count | Source | 798 | 12 | { | 799 | 12 | bfd_byte * ptr; | 800 | 12 | pe_ILF_vars vars; | 801 | 12 | struct internal_filehdr internal_f; | 802 | 12 | unsigned int import_type; | 803 | 12 | unsigned int import_name_type; | 804 | 12 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 805 | 12 | coff_symbol_type ** imp_sym; | 806 | 12 | unsigned int imp_index; | 807 | 12 | intptr_t alignment; | 808 | | | 809 | | /* Decode and verify the types field of the ILF structure. */ | 810 | 12 | import_type = types & 0x3; | 811 | 12 | import_name_type = (types & 0x1c) >> 2; | 812 | | | 813 | 12 | switch (import_type) | 814 | 12 | { | 815 | 7 | case IMPORT_CODE: | 816 | 10 | case IMPORT_DATA: | 817 | 10 | break; | 818 | | | 819 | 1 | case IMPORT_CONST: | 820 | | /* XXX code yet to be written. */ | 821 | | /* xgettext:c-format */ | 822 | 1 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 823 | 1 | abfd, import_type); | 824 | 1 | return false; | 825 | | | 826 | 1 | default: | 827 | | /* xgettext:c-format */ | 828 | 1 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 829 | 1 | abfd, import_type); | 830 | 1 | return false; | 831 | 12 | } | 832 | | | 833 | 10 | switch (import_name_type) | 834 | 10 | { | 835 | 3 | case IMPORT_ORDINAL: | 836 | 4 | case IMPORT_NAME: | 837 | 6 | case IMPORT_NAME_NOPREFIX: | 838 | 9 | case IMPORT_NAME_UNDECORATE: | 839 | 9 | break; | 840 | | | 841 | 1 | default: | 842 | | /* xgettext:c-format */ | 843 | 1 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 844 | 1 | abfd, import_name_type); | 845 | 1 | return false; | 846 | 10 | } | 847 | | | 848 | | /* Initialise local variables. | 849 | | | 850 | | Note these are kept in a structure rather than being | 851 | | declared as statics since bfd frowns on global variables. | 852 | | | 853 | | We are going to construct the contents of the BFD in memory, | 854 | | so allocate all the space that we will need right now. */ | 855 | 9 | vars.bim | 856 | 9 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 857 | 9 | if (vars.bim == NULL) | 858 | 0 | return false; | 859 | | | 860 | 9 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 861 | 9 | vars.bim->buffer = ptr; | 862 | 9 | vars.bim->size = ILF_DATA_SIZE; | 863 | 9 | if (ptr == NULL) | 864 | 0 | goto error_return; | 865 | | | 866 | | /* Initialise the pointers to regions of the memory and the | 867 | | other contents of the pe_ILF_vars structure as well. */ | 868 | 9 | vars.sym_cache = (coff_symbol_type *) ptr; | 869 | 9 | vars.sym_ptr = (coff_symbol_type *) ptr; | 870 | 9 | vars.sym_index = 0; | 871 | 9 | ptr += SIZEOF_ILF_SYMS; | 872 | | | 873 | 9 | vars.sym_table = (unsigned int *) ptr; | 874 | 9 | vars.table_ptr = (unsigned int *) ptr; | 875 | 9 | ptr += SIZEOF_ILF_SYM_TABLE; | 876 | | | 877 | 9 | vars.native_syms = (combined_entry_type *) ptr; | 878 | 9 | vars.native_ptr = (combined_entry_type *) ptr; | 879 | 9 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 880 | | | 881 | 9 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 882 | 9 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 883 | 9 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 884 | | | 885 | 9 | vars.esym_table = (SYMENT *) ptr; | 886 | 9 | vars.esym_ptr = (SYMENT *) ptr; | 887 | 9 | ptr += SIZEOF_ILF_EXT_SYMS; | 888 | | | 889 | 9 | vars.reltab = (arelent *) ptr; | 890 | 9 | vars.relcount = 0; | 891 | 9 | ptr += SIZEOF_ILF_RELOCS; | 892 | | | 893 | 9 | vars.int_reltab = (struct internal_reloc *) ptr; | 894 | 9 | ptr += SIZEOF_ILF_INT_RELOCS; | 895 | | | 896 | 9 | vars.string_table = (char *) ptr; | 897 | 9 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 898 | 9 | ptr += SIZEOF_ILF_STRINGS; | 899 | 9 | vars.end_string_ptr = (char *) ptr; | 900 | | | 901 | | /* The remaining space in bim->buffer is used | 902 | | by the pe_ILF_make_a_section() function. */ | 903 | | | 904 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 905 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 906 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 907 | | alignment. */ | 908 | 9 | #if GCC_VERSION >= 3000 | 909 | 9 | alignment = __alignof__ (struct coff_section_tdata); | 910 | | #else | 911 | | alignment = 8; | 912 | | #endif | 913 | 9 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 914 | | | 915 | 9 | vars.data = ptr; | 916 | 9 | vars.abfd = abfd; | 917 | 9 | vars.sec_index = 0; | 918 | 9 | vars.magic = magic; | 919 | | | 920 | | /* Create the initial .idata$<n> sections: | 921 | | [.idata$2: Import Directory Table -- not needed] | 922 | | .idata$4: Import Lookup Table | 923 | | .idata$5: Import Address Table | 924 | | | 925 | | Note we do not create a .idata$3 section as this is | 926 | | created for us by the linker script. */ | 927 | 9 | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 928 | 9 | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 929 | 9 | if (id4 == NULL || id5 == NULL) | 930 | 0 | goto error_return; | 931 | | | 932 | | /* Fill in the contents of these sections. */ | 933 | 9 | if (import_name_type == IMPORT_ORDINAL) | 934 | 3 | { | 935 | 3 | if (ordinal == 0) | 936 | | /* See PR 20907 for a reproducer. */ | 937 | 1 | goto error_return; | 938 | | | 939 | 2 | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 940 | 2 | ((unsigned int *) id4->contents)[0] = ordinal; | 941 | 2 | ((unsigned int *) id4->contents)[1] = 0x80000000; | 942 | 2 | ((unsigned int *) id5->contents)[0] = ordinal; | 943 | 2 | ((unsigned int *) id5->contents)[1] = 0x80000000; | 944 | | #else | 945 | | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 946 | | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 947 | | #endif | 948 | 2 | } | 949 | 6 | else | 950 | 6 | { | 951 | 6 | char * symbol; | 952 | 6 | unsigned int len; | 953 | | | 954 | | /* Create .idata$6 - the Hint Name Table. */ | 955 | 6 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 956 | 6 | if (id6 == NULL) | 957 | 0 | goto error_return; | 958 | | | 959 | | /* If necessary, trim the import symbol name. */ | 960 | 6 | symbol = symbol_name; | 961 | | | 962 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 963 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 964 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 965 | | of these is used for a symbol. We strip this leading char for | 966 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 967 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 968 | | | 969 | 6 | if (import_name_type != IMPORT_NAME) | 970 | 5 | { | 971 | 5 | char c = symbol[0]; | 972 | | | 973 | | /* Check that we don't remove for targets with empty | 974 | | USER_LABEL_PREFIX the leading underscore. */ | 975 | 5 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 976 | 5 | || c == '@' || c == '?') | 977 | 2 | symbol++; | 978 | 5 | } | 979 | | | 980 | 6 | len = strlen (symbol); | 981 | 6 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 982 | 3 | { | 983 | | /* Truncate at the first '@'. */ | 984 | 3 | char *at = strchr (symbol, '@'); | 985 | | | 986 | 3 | if (at != NULL) | 987 | 1 | len = at - symbol; | 988 | 3 | } | 989 | | | 990 | 6 | id6->contents[0] = ordinal & 0xff; | 991 | 6 | id6->contents[1] = ordinal >> 8; | 992 | | | 993 | 6 | memcpy ((char *) id6->contents + 2, symbol, len); | 994 | 6 | id6->contents[len + 2] = '\0'; | 995 | 6 | } | 996 | | | 997 | 8 | if (import_name_type != IMPORT_ORDINAL) | 998 | 6 | { | 999 | 6 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1000 | 6 | pe_ILF_save_relocs (&vars, id4); | 1001 | | | 1002 | 6 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1003 | 6 | pe_ILF_save_relocs (&vars, id5); | 1004 | 6 | } | 1005 | | | 1006 | | /* Create an import symbol. */ | 1007 | 8 | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 1008 | 8 | imp_sym = vars.sym_ptr_ptr - 1; | 1009 | 8 | imp_index = vars.sym_index - 1; | 1010 | | | 1011 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1012 | 8 | switch (import_type) | 1013 | 8 | { | 1014 | 0 | int i; | 1015 | | | 1016 | 5 | case IMPORT_CODE: | 1017 | | /* CODE functions are special, in that they get a trampoline that | 1018 | | jumps to the main import symbol. Create a .text section to hold it. | 1019 | | First we need to look up its contents in the jump table. */ | 1020 | 10 | for (i = NUM_ENTRIES (jtab); i--;) | 1021 | 10 | { | 1022 | 10 | if (jtab[i].size == 0) | 1023 | 5 | continue; | 1024 | 5 | if (jtab[i].magic == magic) | 1025 | 5 | break; | 1026 | 5 | } | 1027 | | /* If we did not find a matching entry something is wrong. */ | 1028 | 5 | if (i < 0) | 1029 | 0 | abort (); | 1030 | | | 1031 | | /* Create the .text section. */ | 1032 | 5 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1033 | 5 | if (text == NULL) | 1034 | 0 | goto error_return; | 1035 | | | 1036 | | /* Copy in the jump code. */ | 1037 | 5 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1038 | | | 1039 | | /* Create a reloc for the data in the text section. */ | 1040 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1041 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1042 | | { | 1043 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1044 | | (struct bfd_symbol **) imp_sym, | 1045 | | imp_index); | 1046 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1047 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1048 | | (struct bfd_symbol **) imp_sym, | 1049 | | imp_index); | 1050 | | } | 1051 | | else | 1052 | | #endif | 1053 | 5 | #ifdef AMD64MAGIC | 1054 | 5 | if (magic == AMD64MAGIC) | 1055 | 5 | { | 1056 | 5 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1057 | 5 | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1058 | 5 | imp_index); | 1059 | 5 | } | 1060 | 0 | else | 1061 | 0 | #endif | 1062 | 0 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1063 | 0 | BFD_RELOC_32, (asymbol **) imp_sym, | 1064 | 0 | imp_index); | 1065 | | | 1066 | 5 | pe_ILF_save_relocs (& vars, text); | 1067 | 5 | break; | 1068 | | | 1069 | 3 | case IMPORT_DATA: | 1070 | 3 | break; | 1071 | | | 1072 | 0 | default: | 1073 | | /* XXX code not yet written. */ | 1074 | 0 | abort (); | 1075 | 8 | } | 1076 | | | 1077 | | /* Now create a symbol describing the imported value. */ | 1078 | 8 | switch (import_type) | 1079 | 8 | { | 1080 | 5 | case IMPORT_CODE: | 1081 | 5 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1082 | 5 | BSF_NOT_AT_END | BSF_FUNCTION); | 1083 | | | 1084 | 5 | break; | 1085 | | | 1086 | 3 | case IMPORT_DATA: | 1087 | | /* Nothing to do here. */ | 1088 | 3 | break; | 1089 | | | 1090 | 0 | default: | 1091 | | /* XXX code not yet written. */ | 1092 | 0 | abort (); | 1093 | 8 | } | 1094 | | | 1095 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1096 | 8 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1097 | 8 | if (ptr) | 1098 | 1 | * ptr = 0; | 1099 | 8 | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1100 | 8 | if (ptr) | 1101 | 1 | * ptr = '.'; | 1102 | | | 1103 | | /* Initialise the bfd. */ | 1104 | 8 | memset (& internal_f, 0, sizeof (internal_f)); | 1105 | | | 1106 | 8 | internal_f.f_magic = magic; | 1107 | 8 | internal_f.f_symptr = 0; | 1108 | 8 | internal_f.f_nsyms = 0; | 1109 | 8 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1110 | | | 1111 | 8 | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1112 | 8 | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1113 | 0 | goto error_return; | 1114 | | | 1115 | 8 | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1116 | 0 | goto error_return; | 1117 | | | 1118 | 8 | obj_pe (abfd) = true; | 1119 | | #ifdef THUMBPEMAGIC | 1120 | | if (vars.magic == THUMBPEMAGIC) | 1121 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1122 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1123 | | #endif | 1124 | | | 1125 | | /* Switch from file contents to memory contents. */ | 1126 | 8 | bfd_cache_close (abfd); | 1127 | | | 1128 | 8 | abfd->iostream = (void *) vars.bim; | 1129 | 8 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1130 | 8 | abfd->iovec = &_bfd_memory_iovec; | 1131 | 8 | abfd->where = 0; | 1132 | 8 | abfd->origin = 0; | 1133 | 8 | abfd->size = 0; | 1134 | 8 | obj_sym_filepos (abfd) = 0; | 1135 | | | 1136 | | /* Point the bfd at the symbol table. */ | 1137 | 8 | obj_symbols (abfd) = vars.sym_cache; | 1138 | 8 | abfd->symcount = vars.sym_index; | 1139 | | | 1140 | 8 | obj_raw_syments (abfd) = vars.native_syms; | 1141 | 8 | obj_raw_syment_count (abfd) = vars.sym_index; | 1142 | | | 1143 | 8 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1144 | 8 | obj_coff_keep_syms (abfd) = true; | 1145 | | | 1146 | 8 | obj_convert (abfd) = vars.sym_table; | 1147 | 8 | obj_conv_table_size (abfd) = vars.sym_index; | 1148 | | | 1149 | 8 | obj_coff_strings (abfd) = vars.string_table; | 1150 | 8 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1151 | 8 | obj_coff_keep_strings (abfd) = true; | 1152 | | | 1153 | 8 | return true; | 1154 | | | 1155 | 1 | error_return: | 1156 | 1 | free (vars.bim->buffer); | 1157 | 1 | free (vars.bim); | 1158 | 1 | return false; | 1159 | 8 | } |
pei-aarch64.c:pe_ILF_build_a_bfd Line | Count | Source | 798 | 11 | { | 799 | 11 | bfd_byte * ptr; | 800 | 11 | pe_ILF_vars vars; | 801 | 11 | struct internal_filehdr internal_f; | 802 | 11 | unsigned int import_type; | 803 | 11 | unsigned int import_name_type; | 804 | 11 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 805 | 11 | coff_symbol_type ** imp_sym; | 806 | 11 | unsigned int imp_index; | 807 | 11 | intptr_t alignment; | 808 | | | 809 | | /* Decode and verify the types field of the ILF structure. */ | 810 | 11 | import_type = types & 0x3; | 811 | 11 | import_name_type = (types & 0x1c) >> 2; | 812 | | | 813 | 11 | switch (import_type) | 814 | 11 | { | 815 | 7 | case IMPORT_CODE: | 816 | 9 | case IMPORT_DATA: | 817 | 9 | break; | 818 | | | 819 | 1 | case IMPORT_CONST: | 820 | | /* XXX code yet to be written. */ | 821 | | /* xgettext:c-format */ | 822 | 1 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 823 | 1 | abfd, import_type); | 824 | 1 | return false; | 825 | | | 826 | 1 | default: | 827 | | /* xgettext:c-format */ | 828 | 1 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 829 | 1 | abfd, import_type); | 830 | 1 | return false; | 831 | 11 | } | 832 | | | 833 | 9 | switch (import_name_type) | 834 | 9 | { | 835 | 3 | case IMPORT_ORDINAL: | 836 | 4 | case IMPORT_NAME: | 837 | 4 | case IMPORT_NAME_NOPREFIX: | 838 | 8 | case IMPORT_NAME_UNDECORATE: | 839 | 8 | break; | 840 | | | 841 | 1 | default: | 842 | | /* xgettext:c-format */ | 843 | 1 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 844 | 1 | abfd, import_name_type); | 845 | 1 | return false; | 846 | 9 | } | 847 | | | 848 | | /* Initialise local variables. | 849 | | | 850 | | Note these are kept in a structure rather than being | 851 | | declared as statics since bfd frowns on global variables. | 852 | | | 853 | | We are going to construct the contents of the BFD in memory, | 854 | | so allocate all the space that we will need right now. */ | 855 | 8 | vars.bim | 856 | 8 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 857 | 8 | if (vars.bim == NULL) | 858 | 0 | return false; | 859 | | | 860 | 8 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 861 | 8 | vars.bim->buffer = ptr; | 862 | 8 | vars.bim->size = ILF_DATA_SIZE; | 863 | 8 | if (ptr == NULL) | 864 | 0 | goto error_return; | 865 | | | 866 | | /* Initialise the pointers to regions of the memory and the | 867 | | other contents of the pe_ILF_vars structure as well. */ | 868 | 8 | vars.sym_cache = (coff_symbol_type *) ptr; | 869 | 8 | vars.sym_ptr = (coff_symbol_type *) ptr; | 870 | 8 | vars.sym_index = 0; | 871 | 8 | ptr += SIZEOF_ILF_SYMS; | 872 | | | 873 | 8 | vars.sym_table = (unsigned int *) ptr; | 874 | 8 | vars.table_ptr = (unsigned int *) ptr; | 875 | 8 | ptr += SIZEOF_ILF_SYM_TABLE; | 876 | | | 877 | 8 | vars.native_syms = (combined_entry_type *) ptr; | 878 | 8 | vars.native_ptr = (combined_entry_type *) ptr; | 879 | 8 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 880 | | | 881 | 8 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 882 | 8 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 883 | 8 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 884 | | | 885 | 8 | vars.esym_table = (SYMENT *) ptr; | 886 | 8 | vars.esym_ptr = (SYMENT *) ptr; | 887 | 8 | ptr += SIZEOF_ILF_EXT_SYMS; | 888 | | | 889 | 8 | vars.reltab = (arelent *) ptr; | 890 | 8 | vars.relcount = 0; | 891 | 8 | ptr += SIZEOF_ILF_RELOCS; | 892 | | | 893 | 8 | vars.int_reltab = (struct internal_reloc *) ptr; | 894 | 8 | ptr += SIZEOF_ILF_INT_RELOCS; | 895 | | | 896 | 8 | vars.string_table = (char *) ptr; | 897 | 8 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 898 | 8 | ptr += SIZEOF_ILF_STRINGS; | 899 | 8 | vars.end_string_ptr = (char *) ptr; | 900 | | | 901 | | /* The remaining space in bim->buffer is used | 902 | | by the pe_ILF_make_a_section() function. */ | 903 | | | 904 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 905 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 906 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 907 | | alignment. */ | 908 | 8 | #if GCC_VERSION >= 3000 | 909 | 8 | alignment = __alignof__ (struct coff_section_tdata); | 910 | | #else | 911 | | alignment = 8; | 912 | | #endif | 913 | 8 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 914 | | | 915 | 8 | vars.data = ptr; | 916 | 8 | vars.abfd = abfd; | 917 | 8 | vars.sec_index = 0; | 918 | 8 | vars.magic = magic; | 919 | | | 920 | | /* Create the initial .idata$<n> sections: | 921 | | [.idata$2: Import Directory Table -- not needed] | 922 | | .idata$4: Import Lookup Table | 923 | | .idata$5: Import Address Table | 924 | | | 925 | | Note we do not create a .idata$3 section as this is | 926 | | created for us by the linker script. */ | 927 | 8 | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 928 | 8 | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 929 | 8 | if (id4 == NULL || id5 == NULL) | 930 | 0 | goto error_return; | 931 | | | 932 | | /* Fill in the contents of these sections. */ | 933 | 8 | if (import_name_type == IMPORT_ORDINAL) | 934 | 3 | { | 935 | 3 | if (ordinal == 0) | 936 | | /* See PR 20907 for a reproducer. */ | 937 | 1 | goto error_return; | 938 | | | 939 | 2 | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 940 | 2 | ((unsigned int *) id4->contents)[0] = ordinal; | 941 | 2 | ((unsigned int *) id4->contents)[1] = 0x80000000; | 942 | 2 | ((unsigned int *) id5->contents)[0] = ordinal; | 943 | 2 | ((unsigned int *) id5->contents)[1] = 0x80000000; | 944 | | #else | 945 | | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 946 | | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 947 | | #endif | 948 | 2 | } | 949 | 5 | else | 950 | 5 | { | 951 | 5 | char * symbol; | 952 | 5 | unsigned int len; | 953 | | | 954 | | /* Create .idata$6 - the Hint Name Table. */ | 955 | 5 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 956 | 5 | if (id6 == NULL) | 957 | 0 | goto error_return; | 958 | | | 959 | | /* If necessary, trim the import symbol name. */ | 960 | 5 | symbol = symbol_name; | 961 | | | 962 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 963 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 964 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 965 | | of these is used for a symbol. We strip this leading char for | 966 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 967 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 968 | | | 969 | 5 | if (import_name_type != IMPORT_NAME) | 970 | 4 | { | 971 | 4 | char c = symbol[0]; | 972 | | | 973 | | /* Check that we don't remove for targets with empty | 974 | | USER_LABEL_PREFIX the leading underscore. */ | 975 | 4 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 976 | 4 | || c == '@' || c == '?') | 977 | 3 | symbol++; | 978 | 4 | } | 979 | | | 980 | 5 | len = strlen (symbol); | 981 | 5 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 982 | 4 | { | 983 | | /* Truncate at the first '@'. */ | 984 | 4 | char *at = strchr (symbol, '@'); | 985 | | | 986 | 4 | if (at != NULL) | 987 | 1 | len = at - symbol; | 988 | 4 | } | 989 | | | 990 | 5 | id6->contents[0] = ordinal & 0xff; | 991 | 5 | id6->contents[1] = ordinal >> 8; | 992 | | | 993 | 5 | memcpy ((char *) id6->contents + 2, symbol, len); | 994 | 5 | id6->contents[len + 2] = '\0'; | 995 | 5 | } | 996 | | | 997 | 7 | if (import_name_type != IMPORT_ORDINAL) | 998 | 5 | { | 999 | 5 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1000 | 5 | pe_ILF_save_relocs (&vars, id4); | 1001 | | | 1002 | 5 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1003 | 5 | pe_ILF_save_relocs (&vars, id5); | 1004 | 5 | } | 1005 | | | 1006 | | /* Create an import symbol. */ | 1007 | 7 | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 1008 | 7 | imp_sym = vars.sym_ptr_ptr - 1; | 1009 | 7 | imp_index = vars.sym_index - 1; | 1010 | | | 1011 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1012 | 7 | switch (import_type) | 1013 | 7 | { | 1014 | 0 | int i; | 1015 | | | 1016 | 5 | case IMPORT_CODE: | 1017 | | /* CODE functions are special, in that they get a trampoline that | 1018 | | jumps to the main import symbol. Create a .text section to hold it. | 1019 | | First we need to look up its contents in the jump table. */ | 1020 | 10 | for (i = NUM_ENTRIES (jtab); i--;) | 1021 | 10 | { | 1022 | 10 | if (jtab[i].size == 0) | 1023 | 5 | continue; | 1024 | 5 | if (jtab[i].magic == magic) | 1025 | 5 | break; | 1026 | 5 | } | 1027 | | /* If we did not find a matching entry something is wrong. */ | 1028 | 5 | if (i < 0) | 1029 | 0 | abort (); | 1030 | | | 1031 | | /* Create the .text section. */ | 1032 | 5 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1033 | 5 | if (text == NULL) | 1034 | 0 | goto error_return; | 1035 | | | 1036 | | /* Copy in the jump code. */ | 1037 | 5 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1038 | | | 1039 | | /* Create a reloc for the data in the text section. */ | 1040 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1041 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1042 | | { | 1043 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1044 | | (struct bfd_symbol **) imp_sym, | 1045 | | imp_index); | 1046 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1047 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1048 | | (struct bfd_symbol **) imp_sym, | 1049 | | imp_index); | 1050 | | } | 1051 | | else | 1052 | | #endif | 1053 | | #ifdef AMD64MAGIC | 1054 | | if (magic == AMD64MAGIC) | 1055 | | { | 1056 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1057 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1058 | | imp_index); | 1059 | | } | 1060 | | else | 1061 | | #endif | 1062 | 5 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1063 | 5 | BFD_RELOC_32, (asymbol **) imp_sym, | 1064 | 5 | imp_index); | 1065 | | | 1066 | 5 | pe_ILF_save_relocs (& vars, text); | 1067 | 5 | break; | 1068 | | | 1069 | 2 | case IMPORT_DATA: | 1070 | 2 | break; | 1071 | | | 1072 | 0 | default: | 1073 | | /* XXX code not yet written. */ | 1074 | 0 | abort (); | 1075 | 7 | } | 1076 | | | 1077 | | /* Now create a symbol describing the imported value. */ | 1078 | 7 | switch (import_type) | 1079 | 7 | { | 1080 | 5 | case IMPORT_CODE: | 1081 | 5 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1082 | 5 | BSF_NOT_AT_END | BSF_FUNCTION); | 1083 | | | 1084 | 5 | break; | 1085 | | | 1086 | 2 | case IMPORT_DATA: | 1087 | | /* Nothing to do here. */ | 1088 | 2 | break; | 1089 | | | 1090 | 0 | default: | 1091 | | /* XXX code not yet written. */ | 1092 | 0 | abort (); | 1093 | 7 | } | 1094 | | | 1095 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1096 | 7 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1097 | 7 | if (ptr) | 1098 | 1 | * ptr = 0; | 1099 | 7 | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1100 | 7 | if (ptr) | 1101 | 1 | * ptr = '.'; | 1102 | | | 1103 | | /* Initialise the bfd. */ | 1104 | 7 | memset (& internal_f, 0, sizeof (internal_f)); | 1105 | | | 1106 | 7 | internal_f.f_magic = magic; | 1107 | 7 | internal_f.f_symptr = 0; | 1108 | 7 | internal_f.f_nsyms = 0; | 1109 | 7 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1110 | | | 1111 | 7 | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1112 | 7 | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1113 | 0 | goto error_return; | 1114 | | | 1115 | 7 | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1116 | 0 | goto error_return; | 1117 | | | 1118 | 7 | obj_pe (abfd) = true; | 1119 | | #ifdef THUMBPEMAGIC | 1120 | | if (vars.magic == THUMBPEMAGIC) | 1121 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1122 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1123 | | #endif | 1124 | | | 1125 | | /* Switch from file contents to memory contents. */ | 1126 | 7 | bfd_cache_close (abfd); | 1127 | | | 1128 | 7 | abfd->iostream = (void *) vars.bim; | 1129 | 7 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1130 | 7 | abfd->iovec = &_bfd_memory_iovec; | 1131 | 7 | abfd->where = 0; | 1132 | 7 | abfd->origin = 0; | 1133 | 7 | abfd->size = 0; | 1134 | 7 | obj_sym_filepos (abfd) = 0; | 1135 | | | 1136 | | /* Point the bfd at the symbol table. */ | 1137 | 7 | obj_symbols (abfd) = vars.sym_cache; | 1138 | 7 | abfd->symcount = vars.sym_index; | 1139 | | | 1140 | 7 | obj_raw_syments (abfd) = vars.native_syms; | 1141 | 7 | obj_raw_syment_count (abfd) = vars.sym_index; | 1142 | | | 1143 | 7 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1144 | 7 | obj_coff_keep_syms (abfd) = true; | 1145 | | | 1146 | 7 | obj_convert (abfd) = vars.sym_table; | 1147 | 7 | obj_conv_table_size (abfd) = vars.sym_index; | 1148 | | | 1149 | 7 | obj_coff_strings (abfd) = vars.string_table; | 1150 | 7 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1151 | 7 | obj_coff_keep_strings (abfd) = true; | 1152 | | | 1153 | 7 | return true; | 1154 | | | 1155 | 1 | error_return: | 1156 | 1 | free (vars.bim->buffer); | 1157 | 1 | free (vars.bim); | 1158 | 1 | return false; | 1159 | 7 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_build_a_bfd pei-loongarch64.c:pe_ILF_build_a_bfd Line | Count | Source | 798 | 16 | { | 799 | 16 | bfd_byte * ptr; | 800 | 16 | pe_ILF_vars vars; | 801 | 16 | struct internal_filehdr internal_f; | 802 | 16 | unsigned int import_type; | 803 | 16 | unsigned int import_name_type; | 804 | 16 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 805 | 16 | coff_symbol_type ** imp_sym; | 806 | 16 | unsigned int imp_index; | 807 | 16 | intptr_t alignment; | 808 | | | 809 | | /* Decode and verify the types field of the ILF structure. */ | 810 | 16 | import_type = types & 0x3; | 811 | 16 | import_name_type = (types & 0x1c) >> 2; | 812 | | | 813 | 16 | switch (import_type) | 814 | 16 | { | 815 | 3 | case IMPORT_CODE: | 816 | 12 | case IMPORT_DATA: | 817 | 12 | break; | 818 | | | 819 | 1 | case IMPORT_CONST: | 820 | | /* XXX code yet to be written. */ | 821 | | /* xgettext:c-format */ | 822 | 1 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 823 | 1 | abfd, import_type); | 824 | 1 | return false; | 825 | | | 826 | 3 | default: | 827 | | /* xgettext:c-format */ | 828 | 3 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 829 | 3 | abfd, import_type); | 830 | 3 | return false; | 831 | 16 | } | 832 | | | 833 | 12 | switch (import_name_type) | 834 | 12 | { | 835 | 3 | case IMPORT_ORDINAL: | 836 | 4 | case IMPORT_NAME: | 837 | 4 | case IMPORT_NAME_NOPREFIX: | 838 | 8 | case IMPORT_NAME_UNDECORATE: | 839 | 8 | break; | 840 | | | 841 | 4 | default: | 842 | | /* xgettext:c-format */ | 843 | 4 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 844 | 4 | abfd, import_name_type); | 845 | 4 | return false; | 846 | 12 | } | 847 | | | 848 | | /* Initialise local variables. | 849 | | | 850 | | Note these are kept in a structure rather than being | 851 | | declared as statics since bfd frowns on global variables. | 852 | | | 853 | | We are going to construct the contents of the BFD in memory, | 854 | | so allocate all the space that we will need right now. */ | 855 | 8 | vars.bim | 856 | 8 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 857 | 8 | if (vars.bim == NULL) | 858 | 0 | return false; | 859 | | | 860 | 8 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 861 | 8 | vars.bim->buffer = ptr; | 862 | 8 | vars.bim->size = ILF_DATA_SIZE; | 863 | 8 | if (ptr == NULL) | 864 | 0 | goto error_return; | 865 | | | 866 | | /* Initialise the pointers to regions of the memory and the | 867 | | other contents of the pe_ILF_vars structure as well. */ | 868 | 8 | vars.sym_cache = (coff_symbol_type *) ptr; | 869 | 8 | vars.sym_ptr = (coff_symbol_type *) ptr; | 870 | 8 | vars.sym_index = 0; | 871 | 8 | ptr += SIZEOF_ILF_SYMS; | 872 | | | 873 | 8 | vars.sym_table = (unsigned int *) ptr; | 874 | 8 | vars.table_ptr = (unsigned int *) ptr; | 875 | 8 | ptr += SIZEOF_ILF_SYM_TABLE; | 876 | | | 877 | 8 | vars.native_syms = (combined_entry_type *) ptr; | 878 | 8 | vars.native_ptr = (combined_entry_type *) ptr; | 879 | 8 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 880 | | | 881 | 8 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 882 | 8 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 883 | 8 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 884 | | | 885 | 8 | vars.esym_table = (SYMENT *) ptr; | 886 | 8 | vars.esym_ptr = (SYMENT *) ptr; | 887 | 8 | ptr += SIZEOF_ILF_EXT_SYMS; | 888 | | | 889 | 8 | vars.reltab = (arelent *) ptr; | 890 | 8 | vars.relcount = 0; | 891 | 8 | ptr += SIZEOF_ILF_RELOCS; | 892 | | | 893 | 8 | vars.int_reltab = (struct internal_reloc *) ptr; | 894 | 8 | ptr += SIZEOF_ILF_INT_RELOCS; | 895 | | | 896 | 8 | vars.string_table = (char *) ptr; | 897 | 8 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 898 | 8 | ptr += SIZEOF_ILF_STRINGS; | 899 | 8 | vars.end_string_ptr = (char *) ptr; | 900 | | | 901 | | /* The remaining space in bim->buffer is used | 902 | | by the pe_ILF_make_a_section() function. */ | 903 | | | 904 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 905 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 906 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 907 | | alignment. */ | 908 | 8 | #if GCC_VERSION >= 3000 | 909 | 8 | alignment = __alignof__ (struct coff_section_tdata); | 910 | | #else | 911 | | alignment = 8; | 912 | | #endif | 913 | 8 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 914 | | | 915 | 8 | vars.data = ptr; | 916 | 8 | vars.abfd = abfd; | 917 | 8 | vars.sec_index = 0; | 918 | 8 | vars.magic = magic; | 919 | | | 920 | | /* Create the initial .idata$<n> sections: | 921 | | [.idata$2: Import Directory Table -- not needed] | 922 | | .idata$4: Import Lookup Table | 923 | | .idata$5: Import Address Table | 924 | | | 925 | | Note we do not create a .idata$3 section as this is | 926 | | created for us by the linker script. */ | 927 | 8 | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 928 | 8 | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 929 | 8 | if (id4 == NULL || id5 == NULL) | 930 | 0 | goto error_return; | 931 | | | 932 | | /* Fill in the contents of these sections. */ | 933 | 8 | if (import_name_type == IMPORT_ORDINAL) | 934 | 3 | { | 935 | 3 | if (ordinal == 0) | 936 | | /* See PR 20907 for a reproducer. */ | 937 | 1 | goto error_return; | 938 | | | 939 | 2 | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 940 | 2 | ((unsigned int *) id4->contents)[0] = ordinal; | 941 | 2 | ((unsigned int *) id4->contents)[1] = 0x80000000; | 942 | 2 | ((unsigned int *) id5->contents)[0] = ordinal; | 943 | 2 | ((unsigned int *) id5->contents)[1] = 0x80000000; | 944 | | #else | 945 | | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 946 | | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 947 | | #endif | 948 | 2 | } | 949 | 5 | else | 950 | 5 | { | 951 | 5 | char * symbol; | 952 | 5 | unsigned int len; | 953 | | | 954 | | /* Create .idata$6 - the Hint Name Table. */ | 955 | 5 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 956 | 5 | if (id6 == NULL) | 957 | 0 | goto error_return; | 958 | | | 959 | | /* If necessary, trim the import symbol name. */ | 960 | 5 | symbol = symbol_name; | 961 | | | 962 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 963 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 964 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 965 | | of these is used for a symbol. We strip this leading char for | 966 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 967 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 968 | | | 969 | 5 | if (import_name_type != IMPORT_NAME) | 970 | 4 | { | 971 | 4 | char c = symbol[0]; | 972 | | | 973 | | /* Check that we don't remove for targets with empty | 974 | | USER_LABEL_PREFIX the leading underscore. */ | 975 | 4 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 976 | 4 | || c == '@' || c == '?') | 977 | 2 | symbol++; | 978 | 4 | } | 979 | | | 980 | 5 | len = strlen (symbol); | 981 | 5 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 982 | 4 | { | 983 | | /* Truncate at the first '@'. */ | 984 | 4 | char *at = strchr (symbol, '@'); | 985 | | | 986 | 4 | if (at != NULL) | 987 | 1 | len = at - symbol; | 988 | 4 | } | 989 | | | 990 | 5 | id6->contents[0] = ordinal & 0xff; | 991 | 5 | id6->contents[1] = ordinal >> 8; | 992 | | | 993 | 5 | memcpy ((char *) id6->contents + 2, symbol, len); | 994 | 5 | id6->contents[len + 2] = '\0'; | 995 | 5 | } | 996 | | | 997 | 7 | if (import_name_type != IMPORT_ORDINAL) | 998 | 5 | { | 999 | 5 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1000 | 5 | pe_ILF_save_relocs (&vars, id4); | 1001 | | | 1002 | 5 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1003 | 5 | pe_ILF_save_relocs (&vars, id5); | 1004 | 5 | } | 1005 | | | 1006 | | /* Create an import symbol. */ | 1007 | 7 | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 1008 | 7 | imp_sym = vars.sym_ptr_ptr - 1; | 1009 | 7 | imp_index = vars.sym_index - 1; | 1010 | | | 1011 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1012 | 7 | switch (import_type) | 1013 | 7 | { | 1014 | 0 | int i; | 1015 | | | 1016 | 2 | case IMPORT_CODE: | 1017 | | /* CODE functions are special, in that they get a trampoline that | 1018 | | jumps to the main import symbol. Create a .text section to hold it. | 1019 | | First we need to look up its contents in the jump table. */ | 1020 | 4 | for (i = NUM_ENTRIES (jtab); i--;) | 1021 | 4 | { | 1022 | 4 | if (jtab[i].size == 0) | 1023 | 2 | continue; | 1024 | 2 | if (jtab[i].magic == magic) | 1025 | 2 | break; | 1026 | 2 | } | 1027 | | /* If we did not find a matching entry something is wrong. */ | 1028 | 2 | if (i < 0) | 1029 | 0 | abort (); | 1030 | | | 1031 | | /* Create the .text section. */ | 1032 | 2 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1033 | 2 | if (text == NULL) | 1034 | 0 | goto error_return; | 1035 | | | 1036 | | /* Copy in the jump code. */ | 1037 | 2 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1038 | | | 1039 | | /* Create a reloc for the data in the text section. */ | 1040 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1041 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1042 | | { | 1043 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1044 | | (struct bfd_symbol **) imp_sym, | 1045 | | imp_index); | 1046 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1047 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1048 | | (struct bfd_symbol **) imp_sym, | 1049 | | imp_index); | 1050 | | } | 1051 | | else | 1052 | | #endif | 1053 | | #ifdef AMD64MAGIC | 1054 | | if (magic == AMD64MAGIC) | 1055 | | { | 1056 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1057 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1058 | | imp_index); | 1059 | | } | 1060 | | else | 1061 | | #endif | 1062 | 2 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1063 | 2 | BFD_RELOC_32, (asymbol **) imp_sym, | 1064 | 2 | imp_index); | 1065 | | | 1066 | 2 | pe_ILF_save_relocs (& vars, text); | 1067 | 2 | break; | 1068 | | | 1069 | 5 | case IMPORT_DATA: | 1070 | 5 | break; | 1071 | | | 1072 | 0 | default: | 1073 | | /* XXX code not yet written. */ | 1074 | 0 | abort (); | 1075 | 7 | } | 1076 | | | 1077 | | /* Now create a symbol describing the imported value. */ | 1078 | 7 | switch (import_type) | 1079 | 7 | { | 1080 | 2 | case IMPORT_CODE: | 1081 | 2 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1082 | 2 | BSF_NOT_AT_END | BSF_FUNCTION); | 1083 | | | 1084 | 2 | break; | 1085 | | | 1086 | 5 | case IMPORT_DATA: | 1087 | | /* Nothing to do here. */ | 1088 | 5 | break; | 1089 | | | 1090 | 0 | default: | 1091 | | /* XXX code not yet written. */ | 1092 | 0 | abort (); | 1093 | 7 | } | 1094 | | | 1095 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1096 | 7 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1097 | 7 | if (ptr) | 1098 | 1 | * ptr = 0; | 1099 | 7 | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1100 | 7 | if (ptr) | 1101 | 1 | * ptr = '.'; | 1102 | | | 1103 | | /* Initialise the bfd. */ | 1104 | 7 | memset (& internal_f, 0, sizeof (internal_f)); | 1105 | | | 1106 | 7 | internal_f.f_magic = magic; | 1107 | 7 | internal_f.f_symptr = 0; | 1108 | 7 | internal_f.f_nsyms = 0; | 1109 | 7 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1110 | | | 1111 | 7 | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1112 | 7 | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1113 | 0 | goto error_return; | 1114 | | | 1115 | 7 | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1116 | 0 | goto error_return; | 1117 | | | 1118 | 7 | obj_pe (abfd) = true; | 1119 | | #ifdef THUMBPEMAGIC | 1120 | | if (vars.magic == THUMBPEMAGIC) | 1121 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1122 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1123 | | #endif | 1124 | | | 1125 | | /* Switch from file contents to memory contents. */ | 1126 | 7 | bfd_cache_close (abfd); | 1127 | | | 1128 | 7 | abfd->iostream = (void *) vars.bim; | 1129 | 7 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1130 | 7 | abfd->iovec = &_bfd_memory_iovec; | 1131 | 7 | abfd->where = 0; | 1132 | 7 | abfd->origin = 0; | 1133 | 7 | abfd->size = 0; | 1134 | 7 | obj_sym_filepos (abfd) = 0; | 1135 | | | 1136 | | /* Point the bfd at the symbol table. */ | 1137 | 7 | obj_symbols (abfd) = vars.sym_cache; | 1138 | 7 | abfd->symcount = vars.sym_index; | 1139 | | | 1140 | 7 | obj_raw_syments (abfd) = vars.native_syms; | 1141 | 7 | obj_raw_syment_count (abfd) = vars.sym_index; | 1142 | | | 1143 | 7 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1144 | 7 | obj_coff_keep_syms (abfd) = true; | 1145 | | | 1146 | 7 | obj_convert (abfd) = vars.sym_table; | 1147 | 7 | obj_conv_table_size (abfd) = vars.sym_index; | 1148 | | | 1149 | 7 | obj_coff_strings (abfd) = vars.string_table; | 1150 | 7 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1151 | 7 | obj_coff_keep_strings (abfd) = true; | 1152 | | | 1153 | 7 | return true; | 1154 | | | 1155 | 1 | error_return: | 1156 | 1 | free (vars.bim->buffer); | 1157 | 1 | free (vars.bim); | 1158 | 1 | return false; | 1159 | 7 | } |
pei-arm-wince.c:pe_ILF_build_a_bfd Line | Count | Source | 798 | 17 | { | 799 | 17 | bfd_byte * ptr; | 800 | 17 | pe_ILF_vars vars; | 801 | 17 | struct internal_filehdr internal_f; | 802 | 17 | unsigned int import_type; | 803 | 17 | unsigned int import_name_type; | 804 | 17 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 805 | 17 | coff_symbol_type ** imp_sym; | 806 | 17 | unsigned int imp_index; | 807 | 17 | intptr_t alignment; | 808 | | | 809 | | /* Decode and verify the types field of the ILF structure. */ | 810 | 17 | import_type = types & 0x3; | 811 | 17 | import_name_type = (types & 0x1c) >> 2; | 812 | | | 813 | 17 | switch (import_type) | 814 | 17 | { | 815 | 10 | case IMPORT_CODE: | 816 | 15 | case IMPORT_DATA: | 817 | 15 | break; | 818 | | | 819 | 1 | case IMPORT_CONST: | 820 | | /* XXX code yet to be written. */ | 821 | | /* xgettext:c-format */ | 822 | 1 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 823 | 1 | abfd, import_type); | 824 | 1 | return false; | 825 | | | 826 | 1 | default: | 827 | | /* xgettext:c-format */ | 828 | 1 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 829 | 1 | abfd, import_type); | 830 | 1 | return false; | 831 | 17 | } | 832 | | | 833 | 15 | switch (import_name_type) | 834 | 15 | { | 835 | 6 | case IMPORT_ORDINAL: | 836 | 7 | case IMPORT_NAME: | 837 | 9 | case IMPORT_NAME_NOPREFIX: | 838 | 14 | case IMPORT_NAME_UNDECORATE: | 839 | 14 | break; | 840 | | | 841 | 1 | default: | 842 | | /* xgettext:c-format */ | 843 | 1 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 844 | 1 | abfd, import_name_type); | 845 | 1 | return false; | 846 | 15 | } | 847 | | | 848 | | /* Initialise local variables. | 849 | | | 850 | | Note these are kept in a structure rather than being | 851 | | declared as statics since bfd frowns on global variables. | 852 | | | 853 | | We are going to construct the contents of the BFD in memory, | 854 | | so allocate all the space that we will need right now. */ | 855 | 14 | vars.bim | 856 | 14 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 857 | 14 | if (vars.bim == NULL) | 858 | 0 | return false; | 859 | | | 860 | 14 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 861 | 14 | vars.bim->buffer = ptr; | 862 | 14 | vars.bim->size = ILF_DATA_SIZE; | 863 | 14 | if (ptr == NULL) | 864 | 0 | goto error_return; | 865 | | | 866 | | /* Initialise the pointers to regions of the memory and the | 867 | | other contents of the pe_ILF_vars structure as well. */ | 868 | 14 | vars.sym_cache = (coff_symbol_type *) ptr; | 869 | 14 | vars.sym_ptr = (coff_symbol_type *) ptr; | 870 | 14 | vars.sym_index = 0; | 871 | 14 | ptr += SIZEOF_ILF_SYMS; | 872 | | | 873 | 14 | vars.sym_table = (unsigned int *) ptr; | 874 | 14 | vars.table_ptr = (unsigned int *) ptr; | 875 | 14 | ptr += SIZEOF_ILF_SYM_TABLE; | 876 | | | 877 | 14 | vars.native_syms = (combined_entry_type *) ptr; | 878 | 14 | vars.native_ptr = (combined_entry_type *) ptr; | 879 | 14 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 880 | | | 881 | 14 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 882 | 14 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 883 | 14 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 884 | | | 885 | 14 | vars.esym_table = (SYMENT *) ptr; | 886 | 14 | vars.esym_ptr = (SYMENT *) ptr; | 887 | 14 | ptr += SIZEOF_ILF_EXT_SYMS; | 888 | | | 889 | 14 | vars.reltab = (arelent *) ptr; | 890 | 14 | vars.relcount = 0; | 891 | 14 | ptr += SIZEOF_ILF_RELOCS; | 892 | | | 893 | 14 | vars.int_reltab = (struct internal_reloc *) ptr; | 894 | 14 | ptr += SIZEOF_ILF_INT_RELOCS; | 895 | | | 896 | 14 | vars.string_table = (char *) ptr; | 897 | 14 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 898 | 14 | ptr += SIZEOF_ILF_STRINGS; | 899 | 14 | vars.end_string_ptr = (char *) ptr; | 900 | | | 901 | | /* The remaining space in bim->buffer is used | 902 | | by the pe_ILF_make_a_section() function. */ | 903 | | | 904 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 905 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 906 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 907 | | alignment. */ | 908 | 14 | #if GCC_VERSION >= 3000 | 909 | 14 | alignment = __alignof__ (struct coff_section_tdata); | 910 | | #else | 911 | | alignment = 8; | 912 | | #endif | 913 | 14 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 914 | | | 915 | 14 | vars.data = ptr; | 916 | 14 | vars.abfd = abfd; | 917 | 14 | vars.sec_index = 0; | 918 | 14 | vars.magic = magic; | 919 | | | 920 | | /* Create the initial .idata$<n> sections: | 921 | | [.idata$2: Import Directory Table -- not needed] | 922 | | .idata$4: Import Lookup Table | 923 | | .idata$5: Import Address Table | 924 | | | 925 | | Note we do not create a .idata$3 section as this is | 926 | | created for us by the linker script. */ | 927 | 14 | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 928 | 14 | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 929 | 14 | if (id4 == NULL || id5 == NULL) | 930 | 0 | goto error_return; | 931 | | | 932 | | /* Fill in the contents of these sections. */ | 933 | 14 | if (import_name_type == IMPORT_ORDINAL) | 934 | 6 | { | 935 | 6 | if (ordinal == 0) | 936 | | /* See PR 20907 for a reproducer. */ | 937 | 2 | goto error_return; | 938 | | | 939 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 940 | | ((unsigned int *) id4->contents)[0] = ordinal; | 941 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 942 | | ((unsigned int *) id5->contents)[0] = ordinal; | 943 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 944 | | #else | 945 | 4 | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 946 | 4 | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 947 | 4 | #endif | 948 | 4 | } | 949 | 8 | else | 950 | 8 | { | 951 | 8 | char * symbol; | 952 | 8 | unsigned int len; | 953 | | | 954 | | /* Create .idata$6 - the Hint Name Table. */ | 955 | 8 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 956 | 8 | if (id6 == NULL) | 957 | 0 | goto error_return; | 958 | | | 959 | | /* If necessary, trim the import symbol name. */ | 960 | 8 | symbol = symbol_name; | 961 | | | 962 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 963 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 964 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 965 | | of these is used for a symbol. We strip this leading char for | 966 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 967 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 968 | | | 969 | 8 | if (import_name_type != IMPORT_NAME) | 970 | 7 | { | 971 | 7 | char c = symbol[0]; | 972 | | | 973 | | /* Check that we don't remove for targets with empty | 974 | | USER_LABEL_PREFIX the leading underscore. */ | 975 | 7 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 976 | 7 | || c == '@' || c == '?') | 977 | 1 | symbol++; | 978 | 7 | } | 979 | | | 980 | 8 | len = strlen (symbol); | 981 | 8 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 982 | 5 | { | 983 | | /* Truncate at the first '@'. */ | 984 | 5 | char *at = strchr (symbol, '@'); | 985 | | | 986 | 5 | if (at != NULL) | 987 | 3 | len = at - symbol; | 988 | 5 | } | 989 | | | 990 | 8 | id6->contents[0] = ordinal & 0xff; | 991 | 8 | id6->contents[1] = ordinal >> 8; | 992 | | | 993 | 8 | memcpy ((char *) id6->contents + 2, symbol, len); | 994 | 8 | id6->contents[len + 2] = '\0'; | 995 | 8 | } | 996 | | | 997 | 12 | if (import_name_type != IMPORT_ORDINAL) | 998 | 8 | { | 999 | 8 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1000 | 8 | pe_ILF_save_relocs (&vars, id4); | 1001 | | | 1002 | 8 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1003 | 8 | pe_ILF_save_relocs (&vars, id5); | 1004 | 8 | } | 1005 | | | 1006 | | /* Create an import symbol. */ | 1007 | 12 | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 1008 | 12 | imp_sym = vars.sym_ptr_ptr - 1; | 1009 | 12 | imp_index = vars.sym_index - 1; | 1010 | | | 1011 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1012 | 12 | switch (import_type) | 1013 | 12 | { | 1014 | 0 | int i; | 1015 | | | 1016 | 8 | case IMPORT_CODE: | 1017 | | /* CODE functions are special, in that they get a trampoline that | 1018 | | jumps to the main import symbol. Create a .text section to hold it. | 1019 | | First we need to look up its contents in the jump table. */ | 1020 | 19 | for (i = NUM_ENTRIES (jtab); i--;) | 1021 | 19 | { | 1022 | 19 | if (jtab[i].size == 0) | 1023 | 8 | continue; | 1024 | 11 | if (jtab[i].magic == magic) | 1025 | 8 | break; | 1026 | 11 | } | 1027 | | /* If we did not find a matching entry something is wrong. */ | 1028 | 8 | if (i < 0) | 1029 | 0 | abort (); | 1030 | | | 1031 | | /* Create the .text section. */ | 1032 | 8 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1033 | 8 | if (text == NULL) | 1034 | 0 | goto error_return; | 1035 | | | 1036 | | /* Copy in the jump code. */ | 1037 | 8 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1038 | | | 1039 | | /* Create a reloc for the data in the text section. */ | 1040 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1041 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1042 | | { | 1043 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1044 | | (struct bfd_symbol **) imp_sym, | 1045 | | imp_index); | 1046 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1047 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1048 | | (struct bfd_symbol **) imp_sym, | 1049 | | imp_index); | 1050 | | } | 1051 | | else | 1052 | | #endif | 1053 | | #ifdef AMD64MAGIC | 1054 | | if (magic == AMD64MAGIC) | 1055 | | { | 1056 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1057 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1058 | | imp_index); | 1059 | | } | 1060 | | else | 1061 | | #endif | 1062 | 8 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1063 | 8 | BFD_RELOC_32, (asymbol **) imp_sym, | 1064 | 8 | imp_index); | 1065 | | | 1066 | 8 | pe_ILF_save_relocs (& vars, text); | 1067 | 8 | break; | 1068 | | | 1069 | 4 | case IMPORT_DATA: | 1070 | 4 | break; | 1071 | | | 1072 | 0 | default: | 1073 | | /* XXX code not yet written. */ | 1074 | 0 | abort (); | 1075 | 12 | } | 1076 | | | 1077 | | /* Now create a symbol describing the imported value. */ | 1078 | 12 | switch (import_type) | 1079 | 12 | { | 1080 | 8 | case IMPORT_CODE: | 1081 | 8 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1082 | 8 | BSF_NOT_AT_END | BSF_FUNCTION); | 1083 | | | 1084 | 8 | break; | 1085 | | | 1086 | 4 | case IMPORT_DATA: | 1087 | | /* Nothing to do here. */ | 1088 | 4 | break; | 1089 | | | 1090 | 0 | default: | 1091 | | /* XXX code not yet written. */ | 1092 | 0 | abort (); | 1093 | 12 | } | 1094 | | | 1095 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1096 | 12 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1097 | 12 | if (ptr) | 1098 | 1 | * ptr = 0; | 1099 | 12 | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1100 | 12 | if (ptr) | 1101 | 1 | * ptr = '.'; | 1102 | | | 1103 | | /* Initialise the bfd. */ | 1104 | 12 | memset (& internal_f, 0, sizeof (internal_f)); | 1105 | | | 1106 | 12 | internal_f.f_magic = magic; | 1107 | 12 | internal_f.f_symptr = 0; | 1108 | 12 | internal_f.f_nsyms = 0; | 1109 | 12 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1110 | | | 1111 | 12 | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1112 | 12 | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1113 | 0 | goto error_return; | 1114 | | | 1115 | 12 | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1116 | 0 | goto error_return; | 1117 | | | 1118 | 12 | obj_pe (abfd) = true; | 1119 | 12 | #ifdef THUMBPEMAGIC | 1120 | 12 | if (vars.magic == THUMBPEMAGIC) | 1121 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1122 | 5 | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1123 | 12 | #endif | 1124 | | | 1125 | | /* Switch from file contents to memory contents. */ | 1126 | 12 | bfd_cache_close (abfd); | 1127 | | | 1128 | 12 | abfd->iostream = (void *) vars.bim; | 1129 | 12 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1130 | 12 | abfd->iovec = &_bfd_memory_iovec; | 1131 | 12 | abfd->where = 0; | 1132 | 12 | abfd->origin = 0; | 1133 | 12 | abfd->size = 0; | 1134 | 12 | obj_sym_filepos (abfd) = 0; | 1135 | | | 1136 | | /* Point the bfd at the symbol table. */ | 1137 | 12 | obj_symbols (abfd) = vars.sym_cache; | 1138 | 12 | abfd->symcount = vars.sym_index; | 1139 | | | 1140 | 12 | obj_raw_syments (abfd) = vars.native_syms; | 1141 | 12 | obj_raw_syment_count (abfd) = vars.sym_index; | 1142 | | | 1143 | 12 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1144 | 12 | obj_coff_keep_syms (abfd) = true; | 1145 | | | 1146 | 12 | obj_convert (abfd) = vars.sym_table; | 1147 | 12 | obj_conv_table_size (abfd) = vars.sym_index; | 1148 | | | 1149 | 12 | obj_coff_strings (abfd) = vars.string_table; | 1150 | 12 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1151 | 12 | obj_coff_keep_strings (abfd) = true; | 1152 | | | 1153 | 12 | return true; | 1154 | | | 1155 | 2 | error_return: | 1156 | 2 | free (vars.bim->buffer); | 1157 | 2 | free (vars.bim); | 1158 | 2 | return false; | 1159 | 12 | } |
pei-arm.c:pe_ILF_build_a_bfd Line | Count | Source | 798 | 21 | { | 799 | 21 | bfd_byte * ptr; | 800 | 21 | pe_ILF_vars vars; | 801 | 21 | struct internal_filehdr internal_f; | 802 | 21 | unsigned int import_type; | 803 | 21 | unsigned int import_name_type; | 804 | 21 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 805 | 21 | coff_symbol_type ** imp_sym; | 806 | 21 | unsigned int imp_index; | 807 | 21 | intptr_t alignment; | 808 | | | 809 | | /* Decode and verify the types field of the ILF structure. */ | 810 | 21 | import_type = types & 0x3; | 811 | 21 | import_name_type = (types & 0x1c) >> 2; | 812 | | | 813 | 21 | switch (import_type) | 814 | 21 | { | 815 | 12 | case IMPORT_CODE: | 816 | 19 | case IMPORT_DATA: | 817 | 19 | break; | 818 | | | 819 | 1 | case IMPORT_CONST: | 820 | | /* XXX code yet to be written. */ | 821 | | /* xgettext:c-format */ | 822 | 1 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 823 | 1 | abfd, import_type); | 824 | 1 | return false; | 825 | | | 826 | 1 | default: | 827 | | /* xgettext:c-format */ | 828 | 1 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 829 | 1 | abfd, import_type); | 830 | 1 | return false; | 831 | 21 | } | 832 | | | 833 | 19 | switch (import_name_type) | 834 | 19 | { | 835 | 7 | case IMPORT_ORDINAL: | 836 | 8 | case IMPORT_NAME: | 837 | 10 | case IMPORT_NAME_NOPREFIX: | 838 | 18 | case IMPORT_NAME_UNDECORATE: | 839 | 18 | break; | 840 | | | 841 | 1 | default: | 842 | | /* xgettext:c-format */ | 843 | 1 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 844 | 1 | abfd, import_name_type); | 845 | 1 | return false; | 846 | 19 | } | 847 | | | 848 | | /* Initialise local variables. | 849 | | | 850 | | Note these are kept in a structure rather than being | 851 | | declared as statics since bfd frowns on global variables. | 852 | | | 853 | | We are going to construct the contents of the BFD in memory, | 854 | | so allocate all the space that we will need right now. */ | 855 | 18 | vars.bim | 856 | 18 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 857 | 18 | if (vars.bim == NULL) | 858 | 0 | return false; | 859 | | | 860 | 18 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 861 | 18 | vars.bim->buffer = ptr; | 862 | 18 | vars.bim->size = ILF_DATA_SIZE; | 863 | 18 | if (ptr == NULL) | 864 | 0 | goto error_return; | 865 | | | 866 | | /* Initialise the pointers to regions of the memory and the | 867 | | other contents of the pe_ILF_vars structure as well. */ | 868 | 18 | vars.sym_cache = (coff_symbol_type *) ptr; | 869 | 18 | vars.sym_ptr = (coff_symbol_type *) ptr; | 870 | 18 | vars.sym_index = 0; | 871 | 18 | ptr += SIZEOF_ILF_SYMS; | 872 | | | 873 | 18 | vars.sym_table = (unsigned int *) ptr; | 874 | 18 | vars.table_ptr = (unsigned int *) ptr; | 875 | 18 | ptr += SIZEOF_ILF_SYM_TABLE; | 876 | | | 877 | 18 | vars.native_syms = (combined_entry_type *) ptr; | 878 | 18 | vars.native_ptr = (combined_entry_type *) ptr; | 879 | 18 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 880 | | | 881 | 18 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 882 | 18 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 883 | 18 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 884 | | | 885 | 18 | vars.esym_table = (SYMENT *) ptr; | 886 | 18 | vars.esym_ptr = (SYMENT *) ptr; | 887 | 18 | ptr += SIZEOF_ILF_EXT_SYMS; | 888 | | | 889 | 18 | vars.reltab = (arelent *) ptr; | 890 | 18 | vars.relcount = 0; | 891 | 18 | ptr += SIZEOF_ILF_RELOCS; | 892 | | | 893 | 18 | vars.int_reltab = (struct internal_reloc *) ptr; | 894 | 18 | ptr += SIZEOF_ILF_INT_RELOCS; | 895 | | | 896 | 18 | vars.string_table = (char *) ptr; | 897 | 18 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 898 | 18 | ptr += SIZEOF_ILF_STRINGS; | 899 | 18 | vars.end_string_ptr = (char *) ptr; | 900 | | | 901 | | /* The remaining space in bim->buffer is used | 902 | | by the pe_ILF_make_a_section() function. */ | 903 | | | 904 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 905 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 906 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 907 | | alignment. */ | 908 | 18 | #if GCC_VERSION >= 3000 | 909 | 18 | alignment = __alignof__ (struct coff_section_tdata); | 910 | | #else | 911 | | alignment = 8; | 912 | | #endif | 913 | 18 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 914 | | | 915 | 18 | vars.data = ptr; | 916 | 18 | vars.abfd = abfd; | 917 | 18 | vars.sec_index = 0; | 918 | 18 | vars.magic = magic; | 919 | | | 920 | | /* Create the initial .idata$<n> sections: | 921 | | [.idata$2: Import Directory Table -- not needed] | 922 | | .idata$4: Import Lookup Table | 923 | | .idata$5: Import Address Table | 924 | | | 925 | | Note we do not create a .idata$3 section as this is | 926 | | created for us by the linker script. */ | 927 | 18 | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 928 | 18 | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 929 | 18 | if (id4 == NULL || id5 == NULL) | 930 | 0 | goto error_return; | 931 | | | 932 | | /* Fill in the contents of these sections. */ | 933 | 18 | if (import_name_type == IMPORT_ORDINAL) | 934 | 7 | { | 935 | 7 | if (ordinal == 0) | 936 | | /* See PR 20907 for a reproducer. */ | 937 | 2 | goto error_return; | 938 | | | 939 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 940 | | ((unsigned int *) id4->contents)[0] = ordinal; | 941 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 942 | | ((unsigned int *) id5->contents)[0] = ordinal; | 943 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 944 | | #else | 945 | 5 | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 946 | 5 | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 947 | 5 | #endif | 948 | 5 | } | 949 | 11 | else | 950 | 11 | { | 951 | 11 | char * symbol; | 952 | 11 | unsigned int len; | 953 | | | 954 | | /* Create .idata$6 - the Hint Name Table. */ | 955 | 11 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 956 | 11 | if (id6 == NULL) | 957 | 0 | goto error_return; | 958 | | | 959 | | /* If necessary, trim the import symbol name. */ | 960 | 11 | symbol = symbol_name; | 961 | | | 962 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 963 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 964 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 965 | | of these is used for a symbol. We strip this leading char for | 966 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 967 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 968 | | | 969 | 11 | if (import_name_type != IMPORT_NAME) | 970 | 10 | { | 971 | 10 | char c = symbol[0]; | 972 | | | 973 | | /* Check that we don't remove for targets with empty | 974 | | USER_LABEL_PREFIX the leading underscore. */ | 975 | 10 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 976 | 10 | || c == '@' || c == '?') | 977 | 3 | symbol++; | 978 | 10 | } | 979 | | | 980 | 11 | len = strlen (symbol); | 981 | 11 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 982 | 8 | { | 983 | | /* Truncate at the first '@'. */ | 984 | 8 | char *at = strchr (symbol, '@'); | 985 | | | 986 | 8 | if (at != NULL) | 987 | 3 | len = at - symbol; | 988 | 8 | } | 989 | | | 990 | 11 | id6->contents[0] = ordinal & 0xff; | 991 | 11 | id6->contents[1] = ordinal >> 8; | 992 | | | 993 | 11 | memcpy ((char *) id6->contents + 2, symbol, len); | 994 | 11 | id6->contents[len + 2] = '\0'; | 995 | 11 | } | 996 | | | 997 | 16 | if (import_name_type != IMPORT_ORDINAL) | 998 | 11 | { | 999 | 11 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1000 | 11 | pe_ILF_save_relocs (&vars, id4); | 1001 | | | 1002 | 11 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1003 | 11 | pe_ILF_save_relocs (&vars, id5); | 1004 | 11 | } | 1005 | | | 1006 | | /* Create an import symbol. */ | 1007 | 16 | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 1008 | 16 | imp_sym = vars.sym_ptr_ptr - 1; | 1009 | 16 | imp_index = vars.sym_index - 1; | 1010 | | | 1011 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1012 | 16 | switch (import_type) | 1013 | 16 | { | 1014 | 0 | int i; | 1015 | | | 1016 | 10 | case IMPORT_CODE: | 1017 | | /* CODE functions are special, in that they get a trampoline that | 1018 | | jumps to the main import symbol. Create a .text section to hold it. | 1019 | | First we need to look up its contents in the jump table. */ | 1020 | 23 | for (i = NUM_ENTRIES (jtab); i--;) | 1021 | 23 | { | 1022 | 23 | if (jtab[i].size == 0) | 1023 | 10 | continue; | 1024 | 13 | if (jtab[i].magic == magic) | 1025 | 10 | break; | 1026 | 13 | } | 1027 | | /* If we did not find a matching entry something is wrong. */ | 1028 | 10 | if (i < 0) | 1029 | 0 | abort (); | 1030 | | | 1031 | | /* Create the .text section. */ | 1032 | 10 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1033 | 10 | if (text == NULL) | 1034 | 0 | goto error_return; | 1035 | | | 1036 | | /* Copy in the jump code. */ | 1037 | 10 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1038 | | | 1039 | | /* Create a reloc for the data in the text section. */ | 1040 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1041 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1042 | | { | 1043 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1044 | | (struct bfd_symbol **) imp_sym, | 1045 | | imp_index); | 1046 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1047 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1048 | | (struct bfd_symbol **) imp_sym, | 1049 | | imp_index); | 1050 | | } | 1051 | | else | 1052 | | #endif | 1053 | | #ifdef AMD64MAGIC | 1054 | | if (magic == AMD64MAGIC) | 1055 | | { | 1056 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1057 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1058 | | imp_index); | 1059 | | } | 1060 | | else | 1061 | | #endif | 1062 | 10 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1063 | 10 | BFD_RELOC_32, (asymbol **) imp_sym, | 1064 | 10 | imp_index); | 1065 | | | 1066 | 10 | pe_ILF_save_relocs (& vars, text); | 1067 | 10 | break; | 1068 | | | 1069 | 6 | case IMPORT_DATA: | 1070 | 6 | break; | 1071 | | | 1072 | 0 | default: | 1073 | | /* XXX code not yet written. */ | 1074 | 0 | abort (); | 1075 | 16 | } | 1076 | | | 1077 | | /* Now create a symbol describing the imported value. */ | 1078 | 16 | switch (import_type) | 1079 | 16 | { | 1080 | 10 | case IMPORT_CODE: | 1081 | 10 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1082 | 10 | BSF_NOT_AT_END | BSF_FUNCTION); | 1083 | | | 1084 | 10 | break; | 1085 | | | 1086 | 6 | case IMPORT_DATA: | 1087 | | /* Nothing to do here. */ | 1088 | 6 | break; | 1089 | | | 1090 | 0 | default: | 1091 | | /* XXX code not yet written. */ | 1092 | 0 | abort (); | 1093 | 16 | } | 1094 | | | 1095 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1096 | 16 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1097 | 16 | if (ptr) | 1098 | 2 | * ptr = 0; | 1099 | 16 | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1100 | 16 | if (ptr) | 1101 | 2 | * ptr = '.'; | 1102 | | | 1103 | | /* Initialise the bfd. */ | 1104 | 16 | memset (& internal_f, 0, sizeof (internal_f)); | 1105 | | | 1106 | 16 | internal_f.f_magic = magic; | 1107 | 16 | internal_f.f_symptr = 0; | 1108 | 16 | internal_f.f_nsyms = 0; | 1109 | 16 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1110 | | | 1111 | 16 | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1112 | 16 | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1113 | 0 | goto error_return; | 1114 | | | 1115 | 16 | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1116 | 0 | goto error_return; | 1117 | | | 1118 | 16 | obj_pe (abfd) = true; | 1119 | 16 | #ifdef THUMBPEMAGIC | 1120 | 16 | if (vars.magic == THUMBPEMAGIC) | 1121 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1122 | 9 | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1123 | 16 | #endif | 1124 | | | 1125 | | /* Switch from file contents to memory contents. */ | 1126 | 16 | bfd_cache_close (abfd); | 1127 | | | 1128 | 16 | abfd->iostream = (void *) vars.bim; | 1129 | 16 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1130 | 16 | abfd->iovec = &_bfd_memory_iovec; | 1131 | 16 | abfd->where = 0; | 1132 | 16 | abfd->origin = 0; | 1133 | 16 | abfd->size = 0; | 1134 | 16 | obj_sym_filepos (abfd) = 0; | 1135 | | | 1136 | | /* Point the bfd at the symbol table. */ | 1137 | 16 | obj_symbols (abfd) = vars.sym_cache; | 1138 | 16 | abfd->symcount = vars.sym_index; | 1139 | | | 1140 | 16 | obj_raw_syments (abfd) = vars.native_syms; | 1141 | 16 | obj_raw_syment_count (abfd) = vars.sym_index; | 1142 | | | 1143 | 16 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1144 | 16 | obj_coff_keep_syms (abfd) = true; | 1145 | | | 1146 | 16 | obj_convert (abfd) = vars.sym_table; | 1147 | 16 | obj_conv_table_size (abfd) = vars.sym_index; | 1148 | | | 1149 | 16 | obj_coff_strings (abfd) = vars.string_table; | 1150 | 16 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1151 | 16 | obj_coff_keep_strings (abfd) = true; | 1152 | | | 1153 | 16 | return true; | 1154 | | | 1155 | 2 | error_return: | 1156 | 2 | free (vars.bim->buffer); | 1157 | 2 | free (vars.bim); | 1158 | 2 | return false; | 1159 | 16 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_build_a_bfd pei-sh.c:pe_ILF_build_a_bfd Line | Count | Source | 798 | 56 | { | 799 | 56 | bfd_byte * ptr; | 800 | 56 | pe_ILF_vars vars; | 801 | 56 | struct internal_filehdr internal_f; | 802 | 56 | unsigned int import_type; | 803 | 56 | unsigned int import_name_type; | 804 | 56 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 805 | 56 | coff_symbol_type ** imp_sym; | 806 | 56 | unsigned int imp_index; | 807 | 56 | intptr_t alignment; | 808 | | | 809 | | /* Decode and verify the types field of the ILF structure. */ | 810 | 56 | import_type = types & 0x3; | 811 | 56 | import_name_type = (types & 0x1c) >> 2; | 812 | | | 813 | 56 | switch (import_type) | 814 | 56 | { | 815 | 37 | case IMPORT_CODE: | 816 | 54 | case IMPORT_DATA: | 817 | 54 | break; | 818 | | | 819 | 1 | case IMPORT_CONST: | 820 | | /* XXX code yet to be written. */ | 821 | | /* xgettext:c-format */ | 822 | 1 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 823 | 1 | abfd, import_type); | 824 | 1 | return false; | 825 | | | 826 | 1 | default: | 827 | | /* xgettext:c-format */ | 828 | 1 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 829 | 1 | abfd, import_type); | 830 | 1 | return false; | 831 | 56 | } | 832 | | | 833 | 54 | switch (import_name_type) | 834 | 54 | { | 835 | 32 | case IMPORT_ORDINAL: | 836 | 37 | case IMPORT_NAME: | 837 | 48 | case IMPORT_NAME_NOPREFIX: | 838 | 53 | case IMPORT_NAME_UNDECORATE: | 839 | 53 | break; | 840 | | | 841 | 1 | default: | 842 | | /* xgettext:c-format */ | 843 | 1 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 844 | 1 | abfd, import_name_type); | 845 | 1 | return false; | 846 | 54 | } | 847 | | | 848 | | /* Initialise local variables. | 849 | | | 850 | | Note these are kept in a structure rather than being | 851 | | declared as statics since bfd frowns on global variables. | 852 | | | 853 | | We are going to construct the contents of the BFD in memory, | 854 | | so allocate all the space that we will need right now. */ | 855 | 53 | vars.bim | 856 | 53 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 857 | 53 | if (vars.bim == NULL) | 858 | 0 | return false; | 859 | | | 860 | 53 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 861 | 53 | vars.bim->buffer = ptr; | 862 | 53 | vars.bim->size = ILF_DATA_SIZE; | 863 | 53 | if (ptr == NULL) | 864 | 0 | goto error_return; | 865 | | | 866 | | /* Initialise the pointers to regions of the memory and the | 867 | | other contents of the pe_ILF_vars structure as well. */ | 868 | 53 | vars.sym_cache = (coff_symbol_type *) ptr; | 869 | 53 | vars.sym_ptr = (coff_symbol_type *) ptr; | 870 | 53 | vars.sym_index = 0; | 871 | 53 | ptr += SIZEOF_ILF_SYMS; | 872 | | | 873 | 53 | vars.sym_table = (unsigned int *) ptr; | 874 | 53 | vars.table_ptr = (unsigned int *) ptr; | 875 | 53 | ptr += SIZEOF_ILF_SYM_TABLE; | 876 | | | 877 | 53 | vars.native_syms = (combined_entry_type *) ptr; | 878 | 53 | vars.native_ptr = (combined_entry_type *) ptr; | 879 | 53 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 880 | | | 881 | 53 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 882 | 53 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 883 | 53 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 884 | | | 885 | 53 | vars.esym_table = (SYMENT *) ptr; | 886 | 53 | vars.esym_ptr = (SYMENT *) ptr; | 887 | 53 | ptr += SIZEOF_ILF_EXT_SYMS; | 888 | | | 889 | 53 | vars.reltab = (arelent *) ptr; | 890 | 53 | vars.relcount = 0; | 891 | 53 | ptr += SIZEOF_ILF_RELOCS; | 892 | | | 893 | 53 | vars.int_reltab = (struct internal_reloc *) ptr; | 894 | 53 | ptr += SIZEOF_ILF_INT_RELOCS; | 895 | | | 896 | 53 | vars.string_table = (char *) ptr; | 897 | 53 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 898 | 53 | ptr += SIZEOF_ILF_STRINGS; | 899 | 53 | vars.end_string_ptr = (char *) ptr; | 900 | | | 901 | | /* The remaining space in bim->buffer is used | 902 | | by the pe_ILF_make_a_section() function. */ | 903 | | | 904 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 905 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 906 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 907 | | alignment. */ | 908 | 53 | #if GCC_VERSION >= 3000 | 909 | 53 | alignment = __alignof__ (struct coff_section_tdata); | 910 | | #else | 911 | | alignment = 8; | 912 | | #endif | 913 | 53 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 914 | | | 915 | 53 | vars.data = ptr; | 916 | 53 | vars.abfd = abfd; | 917 | 53 | vars.sec_index = 0; | 918 | 53 | vars.magic = magic; | 919 | | | 920 | | /* Create the initial .idata$<n> sections: | 921 | | [.idata$2: Import Directory Table -- not needed] | 922 | | .idata$4: Import Lookup Table | 923 | | .idata$5: Import Address Table | 924 | | | 925 | | Note we do not create a .idata$3 section as this is | 926 | | created for us by the linker script. */ | 927 | 53 | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 928 | 53 | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 929 | 53 | if (id4 == NULL || id5 == NULL) | 930 | 0 | goto error_return; | 931 | | | 932 | | /* Fill in the contents of these sections. */ | 933 | 53 | if (import_name_type == IMPORT_ORDINAL) | 934 | 32 | { | 935 | 32 | if (ordinal == 0) | 936 | | /* See PR 20907 for a reproducer. */ | 937 | 8 | goto error_return; | 938 | | | 939 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 940 | | ((unsigned int *) id4->contents)[0] = ordinal; | 941 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 942 | | ((unsigned int *) id5->contents)[0] = ordinal; | 943 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 944 | | #else | 945 | 24 | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 946 | 24 | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 947 | 24 | #endif | 948 | 24 | } | 949 | 21 | else | 950 | 21 | { | 951 | 21 | char * symbol; | 952 | 21 | unsigned int len; | 953 | | | 954 | | /* Create .idata$6 - the Hint Name Table. */ | 955 | 21 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 956 | 21 | if (id6 == NULL) | 957 | 0 | goto error_return; | 958 | | | 959 | | /* If necessary, trim the import symbol name. */ | 960 | 21 | symbol = symbol_name; | 961 | | | 962 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 963 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 964 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 965 | | of these is used for a symbol. We strip this leading char for | 966 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 967 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 968 | | | 969 | 21 | if (import_name_type != IMPORT_NAME) | 970 | 16 | { | 971 | 16 | char c = symbol[0]; | 972 | | | 973 | | /* Check that we don't remove for targets with empty | 974 | | USER_LABEL_PREFIX the leading underscore. */ | 975 | 16 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 976 | 16 | || c == '@' || c == '?') | 977 | 2 | symbol++; | 978 | 16 | } | 979 | | | 980 | 21 | len = strlen (symbol); | 981 | 21 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 982 | 5 | { | 983 | | /* Truncate at the first '@'. */ | 984 | 5 | char *at = strchr (symbol, '@'); | 985 | | | 986 | 5 | if (at != NULL) | 987 | 2 | len = at - symbol; | 988 | 5 | } | 989 | | | 990 | 21 | id6->contents[0] = ordinal & 0xff; | 991 | 21 | id6->contents[1] = ordinal >> 8; | 992 | | | 993 | 21 | memcpy ((char *) id6->contents + 2, symbol, len); | 994 | 21 | id6->contents[len + 2] = '\0'; | 995 | 21 | } | 996 | | | 997 | 45 | if (import_name_type != IMPORT_ORDINAL) | 998 | 21 | { | 999 | 21 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1000 | 21 | pe_ILF_save_relocs (&vars, id4); | 1001 | | | 1002 | 21 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1003 | 21 | pe_ILF_save_relocs (&vars, id5); | 1004 | 21 | } | 1005 | | | 1006 | | /* Create an import symbol. */ | 1007 | 45 | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 1008 | 45 | imp_sym = vars.sym_ptr_ptr - 1; | 1009 | 45 | imp_index = vars.sym_index - 1; | 1010 | | | 1011 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1012 | 45 | switch (import_type) | 1013 | 45 | { | 1014 | 0 | int i; | 1015 | | | 1016 | 28 | case IMPORT_CODE: | 1017 | | /* CODE functions are special, in that they get a trampoline that | 1018 | | jumps to the main import symbol. Create a .text section to hold it. | 1019 | | First we need to look up its contents in the jump table. */ | 1020 | 56 | for (i = NUM_ENTRIES (jtab); i--;) | 1021 | 56 | { | 1022 | 56 | if (jtab[i].size == 0) | 1023 | 28 | continue; | 1024 | 28 | if (jtab[i].magic == magic) | 1025 | 28 | break; | 1026 | 28 | } | 1027 | | /* If we did not find a matching entry something is wrong. */ | 1028 | 28 | if (i < 0) | 1029 | 0 | abort (); | 1030 | | | 1031 | | /* Create the .text section. */ | 1032 | 28 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1033 | 28 | if (text == NULL) | 1034 | 0 | goto error_return; | 1035 | | | 1036 | | /* Copy in the jump code. */ | 1037 | 28 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1038 | | | 1039 | | /* Create a reloc for the data in the text section. */ | 1040 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1041 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1042 | | { | 1043 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1044 | | (struct bfd_symbol **) imp_sym, | 1045 | | imp_index); | 1046 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1047 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1048 | | (struct bfd_symbol **) imp_sym, | 1049 | | imp_index); | 1050 | | } | 1051 | | else | 1052 | | #endif | 1053 | | #ifdef AMD64MAGIC | 1054 | | if (magic == AMD64MAGIC) | 1055 | | { | 1056 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1057 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1058 | | imp_index); | 1059 | | } | 1060 | | else | 1061 | | #endif | 1062 | 28 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1063 | 28 | BFD_RELOC_32, (asymbol **) imp_sym, | 1064 | 28 | imp_index); | 1065 | | | 1066 | 28 | pe_ILF_save_relocs (& vars, text); | 1067 | 28 | break; | 1068 | | | 1069 | 17 | case IMPORT_DATA: | 1070 | 17 | break; | 1071 | | | 1072 | 0 | default: | 1073 | | /* XXX code not yet written. */ | 1074 | 0 | abort (); | 1075 | 45 | } | 1076 | | | 1077 | | /* Now create a symbol describing the imported value. */ | 1078 | 45 | switch (import_type) | 1079 | 45 | { | 1080 | 28 | case IMPORT_CODE: | 1081 | 28 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1082 | 28 | BSF_NOT_AT_END | BSF_FUNCTION); | 1083 | | | 1084 | 28 | break; | 1085 | | | 1086 | 17 | case IMPORT_DATA: | 1087 | | /* Nothing to do here. */ | 1088 | 17 | break; | 1089 | | | 1090 | 0 | default: | 1091 | | /* XXX code not yet written. */ | 1092 | 0 | abort (); | 1093 | 45 | } | 1094 | | | 1095 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1096 | 45 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1097 | 45 | if (ptr) | 1098 | 1 | * ptr = 0; | 1099 | 45 | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1100 | 45 | if (ptr) | 1101 | 1 | * ptr = '.'; | 1102 | | | 1103 | | /* Initialise the bfd. */ | 1104 | 45 | memset (& internal_f, 0, sizeof (internal_f)); | 1105 | | | 1106 | 45 | internal_f.f_magic = magic; | 1107 | 45 | internal_f.f_symptr = 0; | 1108 | 45 | internal_f.f_nsyms = 0; | 1109 | 45 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1110 | | | 1111 | 45 | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1112 | 45 | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1113 | 0 | goto error_return; | 1114 | | | 1115 | 45 | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1116 | 0 | goto error_return; | 1117 | | | 1118 | 45 | obj_pe (abfd) = true; | 1119 | | #ifdef THUMBPEMAGIC | 1120 | | if (vars.magic == THUMBPEMAGIC) | 1121 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1122 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1123 | | #endif | 1124 | | | 1125 | | /* Switch from file contents to memory contents. */ | 1126 | 45 | bfd_cache_close (abfd); | 1127 | | | 1128 | 45 | abfd->iostream = (void *) vars.bim; | 1129 | 45 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1130 | 45 | abfd->iovec = &_bfd_memory_iovec; | 1131 | 45 | abfd->where = 0; | 1132 | 45 | abfd->origin = 0; | 1133 | 45 | abfd->size = 0; | 1134 | 45 | obj_sym_filepos (abfd) = 0; | 1135 | | | 1136 | | /* Point the bfd at the symbol table. */ | 1137 | 45 | obj_symbols (abfd) = vars.sym_cache; | 1138 | 45 | abfd->symcount = vars.sym_index; | 1139 | | | 1140 | 45 | obj_raw_syments (abfd) = vars.native_syms; | 1141 | 45 | obj_raw_syment_count (abfd) = vars.sym_index; | 1142 | | | 1143 | 45 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1144 | 45 | obj_coff_keep_syms (abfd) = true; | 1145 | | | 1146 | 45 | obj_convert (abfd) = vars.sym_table; | 1147 | 45 | obj_conv_table_size (abfd) = vars.sym_index; | 1148 | | | 1149 | 45 | obj_coff_strings (abfd) = vars.string_table; | 1150 | 45 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1151 | 45 | obj_coff_keep_strings (abfd) = true; | 1152 | | | 1153 | 45 | return true; | 1154 | | | 1155 | 8 | error_return: | 1156 | 8 | free (vars.bim->buffer); | 1157 | 8 | free (vars.bim); | 1158 | 8 | return false; | 1159 | 45 | } |
|
1160 | | |
1161 | | /* Cleanup function, returned from check_format hook. */ |
1162 | | |
1163 | | static void |
1164 | | pe_ILF_cleanup (bfd *abfd) |
1165 | 24 | { |
1166 | 24 | struct bfd_in_memory *bim = abfd->iostream; |
1167 | 24 | free (bim->buffer); |
1168 | 24 | free (bim); |
1169 | 24 | abfd->iostream = NULL; |
1170 | 24 | } Unexecuted instantiation: pei-i386.c:pe_ILF_cleanup Unexecuted instantiation: pei-x86_64.c:pe_ILF_cleanup Unexecuted instantiation: pei-aarch64.c:pe_ILF_cleanup Unexecuted instantiation: pei-ia64.c:pe_ILF_cleanup Unexecuted instantiation: pei-loongarch64.c:pe_ILF_cleanup pei-arm-wince.c:pe_ILF_cleanup Line | Count | Source | 1165 | 12 | { | 1166 | 12 | struct bfd_in_memory *bim = abfd->iostream; | 1167 | 12 | free (bim->buffer); | 1168 | 12 | free (bim); | 1169 | 12 | abfd->iostream = NULL; | 1170 | 12 | } |
Line | Count | Source | 1165 | 12 | { | 1166 | 12 | struct bfd_in_memory *bim = abfd->iostream; | 1167 | 12 | free (bim->buffer); | 1168 | 12 | free (bim); | 1169 | 12 | abfd->iostream = NULL; | 1170 | 12 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_cleanup Unexecuted instantiation: pei-sh.c:pe_ILF_cleanup |
1171 | | |
1172 | | /* We have detected an Import Library Format archive element. |
1173 | | Decode the element and return the appropriate target. */ |
1174 | | |
1175 | | static bfd_cleanup |
1176 | | pe_ILF_object_p (bfd * abfd) |
1177 | 2.21k | { |
1178 | 2.21k | bfd_byte buffer[14]; |
1179 | 2.21k | bfd_byte * ptr; |
1180 | 2.21k | char * symbol_name; |
1181 | 2.21k | char * source_dll; |
1182 | 2.21k | unsigned int machine; |
1183 | 2.21k | bfd_size_type size; |
1184 | 2.21k | unsigned int ordinal; |
1185 | 2.21k | unsigned int types; |
1186 | 2.21k | unsigned int magic; |
1187 | | |
1188 | | /* Upon entry the first six bytes of the ILF header have |
1189 | | already been read. Now read the rest of the header. */ |
1190 | 2.21k | if (bfd_bread (buffer, (bfd_size_type) 14, abfd) != 14) |
1191 | 56 | return NULL; |
1192 | | |
1193 | 2.16k | ptr = buffer; |
1194 | | |
1195 | 2.16k | machine = H_GET_16 (abfd, ptr); |
1196 | 2.16k | ptr += 2; |
1197 | | |
1198 | | /* Check that the machine type is recognised. */ |
1199 | 2.16k | magic = 0; |
1200 | | |
1201 | 2.16k | switch (machine) |
1202 | 2.16k | { |
1203 | 120 | case IMAGE_FILE_MACHINE_UNKNOWN: |
1204 | 128 | case IMAGE_FILE_MACHINE_ALPHA: |
1205 | 136 | case IMAGE_FILE_MACHINE_ALPHA64: |
1206 | 147 | case IMAGE_FILE_MACHINE_IA64: |
1207 | 147 | break; |
1208 | | |
1209 | 200 | case IMAGE_FILE_MACHINE_I386: |
1210 | | #ifdef I386MAGIC |
1211 | 25 | magic = I386MAGIC; |
1212 | | #endif |
1213 | 200 | break; |
1214 | | |
1215 | 136 | case IMAGE_FILE_MACHINE_AMD64: |
1216 | | #ifdef AMD64MAGIC |
1217 | 17 | magic = AMD64MAGIC; |
1218 | | #endif |
1219 | 136 | break; |
1220 | | |
1221 | 8 | case IMAGE_FILE_MACHINE_R3000: |
1222 | 16 | case IMAGE_FILE_MACHINE_R4000: |
1223 | 24 | case IMAGE_FILE_MACHINE_R10000: |
1224 | | |
1225 | 32 | case IMAGE_FILE_MACHINE_MIPS16: |
1226 | 40 | case IMAGE_FILE_MACHINE_MIPSFPU: |
1227 | 48 | case IMAGE_FILE_MACHINE_MIPSFPU16: |
1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
1229 | | magic = MIPS_ARCH_MAGIC_WINCE; |
1230 | | #endif |
1231 | 48 | break; |
1232 | | |
1233 | 580 | case IMAGE_FILE_MACHINE_SH3: |
1234 | 626 | case IMAGE_FILE_MACHINE_SH4: |
1235 | | #ifdef SH_ARCH_MAGIC_WINCE |
1236 | 88 | magic = SH_ARCH_MAGIC_WINCE; |
1237 | | #endif |
1238 | 626 | break; |
1239 | | |
1240 | 75 | case IMAGE_FILE_MACHINE_ARM: |
1241 | | #ifdef ARMPEMAGIC |
1242 | 40 | magic = ARMPEMAGIC; |
1243 | | #endif |
1244 | 75 | break; |
1245 | | |
1246 | 160 | case IMAGE_FILE_MACHINE_ARM64: |
1247 | | #ifdef AARCH64MAGIC |
1248 | 20 | magic = AARCH64MAGIC; |
1249 | | #endif |
1250 | 160 | break; |
1251 | | |
1252 | 208 | case IMAGE_FILE_MACHINE_LOONGARCH64: |
1253 | | #ifdef LOONGARCH64MAGIC |
1254 | 26 | magic = LOONGARCH64MAGIC; |
1255 | | #endif |
1256 | 208 | break; |
1257 | | |
1258 | 179 | case IMAGE_FILE_MACHINE_THUMB: |
1259 | | #ifdef THUMBPEMAGIC |
1260 | | { |
1261 | | extern const bfd_target TARGET_LITTLE_SYM; |
1262 | | |
1263 | 48 | if (abfd->xvec == & TARGET_LITTLE_SYM) |
1264 | 46 | magic = THUMBPEMAGIC; |
1265 | | } |
1266 | | #endif |
1267 | 179 | break; |
1268 | | |
1269 | 0 | case IMAGE_FILE_MACHINE_POWERPC: |
1270 | | /* We no longer support PowerPC. */ |
1271 | 383 | default: |
1272 | 383 | _bfd_error_handler |
1273 | | /* xgettext:c-format */ |
1274 | 383 | (_("%pB: unrecognised machine type (0x%x)" |
1275 | 383 | " in Import Library Format archive"), |
1276 | 383 | abfd, machine); |
1277 | 383 | bfd_set_error (bfd_error_malformed_archive); |
1278 | | |
1279 | 383 | return NULL; |
1280 | 0 | break; |
1281 | 2.16k | } |
1282 | | |
1283 | 1.77k | if (magic == 0) |
1284 | 1.51k | { |
1285 | 1.51k | _bfd_error_handler |
1286 | | /* xgettext:c-format */ |
1287 | 1.51k | (_("%pB: recognised but unhandled machine type (0x%x)" |
1288 | 1.51k | " in Import Library Format archive"), |
1289 | 1.51k | abfd, machine); |
1290 | 1.51k | bfd_set_error (bfd_error_wrong_format); |
1291 | | |
1292 | 1.51k | return NULL; |
1293 | 1.51k | } |
1294 | | |
1295 | | /* We do not bother to check the date. |
1296 | | date = H_GET_32 (abfd, ptr); */ |
1297 | 262 | ptr += 4; |
1298 | | |
1299 | 262 | size = H_GET_32 (abfd, ptr); |
1300 | 262 | ptr += 4; |
1301 | | |
1302 | 262 | if (size == 0) |
1303 | 13 | { |
1304 | 13 | _bfd_error_handler |
1305 | 13 | (_("%pB: size field is zero in Import Library Format header"), abfd); |
1306 | 13 | bfd_set_error (bfd_error_malformed_archive); |
1307 | | |
1308 | 13 | return NULL; |
1309 | 13 | } |
1310 | | |
1311 | 249 | ordinal = H_GET_16 (abfd, ptr); |
1312 | 249 | ptr += 2; |
1313 | | |
1314 | 249 | types = H_GET_16 (abfd, ptr); |
1315 | | /* ptr += 2; */ |
1316 | | |
1317 | | /* Now read in the two strings that follow. */ |
1318 | 249 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); |
1319 | 249 | if (ptr == NULL) |
1320 | 68 | return NULL; |
1321 | | |
1322 | 181 | symbol_name = (char *) ptr; |
1323 | | /* See PR 20905 for an example of where the strnlen is necessary. */ |
1324 | 181 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; |
1325 | | |
1326 | | /* Verify that the strings are null terminated. */ |
1327 | 181 | if (ptr[size - 1] != 0 |
1328 | 181 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) |
1329 | 33 | { |
1330 | 33 | _bfd_error_handler |
1331 | 33 | (_("%pB: string not null terminated in ILF object file"), abfd); |
1332 | 33 | bfd_set_error (bfd_error_malformed_archive); |
1333 | 33 | bfd_release (abfd, ptr); |
1334 | 33 | return NULL; |
1335 | 33 | } |
1336 | | |
1337 | | /* Now construct the bfd. */ |
1338 | 148 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, |
1339 | 148 | source_dll, ordinal, types)) |
1340 | 42 | { |
1341 | 42 | bfd_release (abfd, ptr); |
1342 | 42 | return NULL; |
1343 | 42 | } |
1344 | | |
1345 | 106 | return pe_ILF_cleanup; |
1346 | 148 | } pei-i386.c:pe_ILF_object_p Line | Count | Source | 1177 | 277 | { | 1178 | 277 | bfd_byte buffer[14]; | 1179 | 277 | bfd_byte * ptr; | 1180 | 277 | char * symbol_name; | 1181 | 277 | char * source_dll; | 1182 | 277 | unsigned int machine; | 1183 | 277 | bfd_size_type size; | 1184 | 277 | unsigned int ordinal; | 1185 | 277 | unsigned int types; | 1186 | 277 | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 277 | if (bfd_bread (buffer, (bfd_size_type) 14, abfd) != 14) | 1191 | 7 | return NULL; | 1192 | | | 1193 | 270 | ptr = buffer; | 1194 | | | 1195 | 270 | machine = H_GET_16 (abfd, ptr); | 1196 | 270 | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 270 | magic = 0; | 1200 | | | 1201 | 270 | switch (machine) | 1202 | 270 | { | 1203 | 15 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 16 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 17 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 18 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 18 | break; | 1208 | | | 1209 | 25 | case IMAGE_FILE_MACHINE_I386: | 1210 | 25 | #ifdef I386MAGIC | 1211 | 25 | magic = I386MAGIC; | 1212 | 25 | #endif | 1213 | 25 | break; | 1214 | | | 1215 | 17 | case IMAGE_FILE_MACHINE_AMD64: | 1216 | | #ifdef AMD64MAGIC | 1217 | | magic = AMD64MAGIC; | 1218 | | #endif | 1219 | 17 | break; | 1220 | | | 1221 | 1 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 2 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 3 | case IMAGE_FILE_MACHINE_R10000: | 1224 | | | 1225 | 4 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 5 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 6 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 6 | break; | 1232 | | | 1233 | 82 | case IMAGE_FILE_MACHINE_SH3: | 1234 | 88 | case IMAGE_FILE_MACHINE_SH4: | 1235 | | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | | magic = SH_ARCH_MAGIC_WINCE; | 1237 | | #endif | 1238 | 88 | break; | 1239 | | | 1240 | 3 | case IMAGE_FILE_MACHINE_ARM: | 1241 | | #ifdef ARMPEMAGIC | 1242 | | magic = ARMPEMAGIC; | 1243 | | #endif | 1244 | 3 | break; | 1245 | | | 1246 | 20 | case IMAGE_FILE_MACHINE_ARM64: | 1247 | | #ifdef AARCH64MAGIC | 1248 | | magic = AARCH64MAGIC; | 1249 | | #endif | 1250 | 20 | break; | 1251 | | | 1252 | 26 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | | #ifdef LOONGARCH64MAGIC | 1254 | | magic = LOONGARCH64MAGIC; | 1255 | | #endif | 1256 | 26 | break; | 1257 | | | 1258 | 21 | case IMAGE_FILE_MACHINE_THUMB: | 1259 | | #ifdef THUMBPEMAGIC | 1260 | | { | 1261 | | extern const bfd_target TARGET_LITTLE_SYM; | 1262 | | | 1263 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1264 | | magic = THUMBPEMAGIC; | 1265 | | } | 1266 | | #endif | 1267 | 21 | break; | 1268 | | | 1269 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1270 | | /* We no longer support PowerPC. */ | 1271 | 46 | default: | 1272 | 46 | _bfd_error_handler | 1273 | | /* xgettext:c-format */ | 1274 | 46 | (_("%pB: unrecognised machine type (0x%x)" | 1275 | 46 | " in Import Library Format archive"), | 1276 | 46 | abfd, machine); | 1277 | 46 | bfd_set_error (bfd_error_malformed_archive); | 1278 | | | 1279 | 46 | return NULL; | 1280 | 0 | break; | 1281 | 270 | } | 1282 | | | 1283 | 224 | if (magic == 0) | 1284 | 199 | { | 1285 | 199 | _bfd_error_handler | 1286 | | /* xgettext:c-format */ | 1287 | 199 | (_("%pB: recognised but unhandled machine type (0x%x)" | 1288 | 199 | " in Import Library Format archive"), | 1289 | 199 | abfd, machine); | 1290 | 199 | bfd_set_error (bfd_error_wrong_format); | 1291 | | | 1292 | 199 | return NULL; | 1293 | 199 | } | 1294 | | | 1295 | | /* We do not bother to check the date. | 1296 | | date = H_GET_32 (abfd, ptr); */ | 1297 | 25 | ptr += 4; | 1298 | | | 1299 | 25 | size = H_GET_32 (abfd, ptr); | 1300 | 25 | ptr += 4; | 1301 | | | 1302 | 25 | if (size == 0) | 1303 | 1 | { | 1304 | 1 | _bfd_error_handler | 1305 | 1 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1306 | 1 | bfd_set_error (bfd_error_malformed_archive); | 1307 | | | 1308 | 1 | return NULL; | 1309 | 1 | } | 1310 | | | 1311 | 24 | ordinal = H_GET_16 (abfd, ptr); | 1312 | 24 | ptr += 2; | 1313 | | | 1314 | 24 | types = H_GET_16 (abfd, ptr); | 1315 | | /* ptr += 2; */ | 1316 | | | 1317 | | /* Now read in the two strings that follow. */ | 1318 | 24 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1319 | 24 | if (ptr == NULL) | 1320 | 6 | return NULL; | 1321 | | | 1322 | 18 | symbol_name = (char *) ptr; | 1323 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1324 | 18 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1325 | | | 1326 | | /* Verify that the strings are null terminated. */ | 1327 | 18 | if (ptr[size - 1] != 0 | 1328 | 18 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1329 | 3 | { | 1330 | 3 | _bfd_error_handler | 1331 | 3 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1332 | 3 | bfd_set_error (bfd_error_malformed_archive); | 1333 | 3 | bfd_release (abfd, ptr); | 1334 | 3 | return NULL; | 1335 | 3 | } | 1336 | | | 1337 | | /* Now construct the bfd. */ | 1338 | 15 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1339 | 15 | source_dll, ordinal, types)) | 1340 | 4 | { | 1341 | 4 | bfd_release (abfd, ptr); | 1342 | 4 | return NULL; | 1343 | 4 | } | 1344 | | | 1345 | 11 | return pe_ILF_cleanup; | 1346 | 15 | } |
pei-x86_64.c:pe_ILF_object_p Line | Count | Source | 1177 | 238 | { | 1178 | 238 | bfd_byte buffer[14]; | 1179 | 238 | bfd_byte * ptr; | 1180 | 238 | char * symbol_name; | 1181 | 238 | char * source_dll; | 1182 | 238 | unsigned int machine; | 1183 | 238 | bfd_size_type size; | 1184 | 238 | unsigned int ordinal; | 1185 | 238 | unsigned int types; | 1186 | 238 | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 238 | if (bfd_bread (buffer, (bfd_size_type) 14, abfd) != 14) | 1191 | 7 | return NULL; | 1192 | | | 1193 | 231 | ptr = buffer; | 1194 | | | 1195 | 231 | machine = H_GET_16 (abfd, ptr); | 1196 | 231 | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 231 | magic = 0; | 1200 | | | 1201 | 231 | switch (machine) | 1202 | 231 | { | 1203 | 15 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 16 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 17 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 18 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 18 | break; | 1208 | | | 1209 | 25 | case IMAGE_FILE_MACHINE_I386: | 1210 | | #ifdef I386MAGIC | 1211 | | magic = I386MAGIC; | 1212 | | #endif | 1213 | 25 | break; | 1214 | | | 1215 | 17 | case IMAGE_FILE_MACHINE_AMD64: | 1216 | 17 | #ifdef AMD64MAGIC | 1217 | 17 | magic = AMD64MAGIC; | 1218 | 17 | #endif | 1219 | 17 | break; | 1220 | | | 1221 | 1 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 2 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 3 | case IMAGE_FILE_MACHINE_R10000: | 1224 | | | 1225 | 4 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 5 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 6 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 6 | break; | 1232 | | | 1233 | 44 | case IMAGE_FILE_MACHINE_SH3: | 1234 | 49 | case IMAGE_FILE_MACHINE_SH4: | 1235 | | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | | magic = SH_ARCH_MAGIC_WINCE; | 1237 | | #endif | 1238 | 49 | break; | 1239 | | | 1240 | 3 | case IMAGE_FILE_MACHINE_ARM: | 1241 | | #ifdef ARMPEMAGIC | 1242 | | magic = ARMPEMAGIC; | 1243 | | #endif | 1244 | 3 | break; | 1245 | | | 1246 | 20 | case IMAGE_FILE_MACHINE_ARM64: | 1247 | | #ifdef AARCH64MAGIC | 1248 | | magic = AARCH64MAGIC; | 1249 | | #endif | 1250 | 20 | break; | 1251 | | | 1252 | 26 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | | #ifdef LOONGARCH64MAGIC | 1254 | | magic = LOONGARCH64MAGIC; | 1255 | | #endif | 1256 | 26 | break; | 1257 | | | 1258 | 21 | case IMAGE_FILE_MACHINE_THUMB: | 1259 | | #ifdef THUMBPEMAGIC | 1260 | | { | 1261 | | extern const bfd_target TARGET_LITTLE_SYM; | 1262 | | | 1263 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1264 | | magic = THUMBPEMAGIC; | 1265 | | } | 1266 | | #endif | 1267 | 21 | break; | 1268 | | | 1269 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1270 | | /* We no longer support PowerPC. */ | 1271 | 46 | default: | 1272 | 46 | _bfd_error_handler | 1273 | | /* xgettext:c-format */ | 1274 | 46 | (_("%pB: unrecognised machine type (0x%x)" | 1275 | 46 | " in Import Library Format archive"), | 1276 | 46 | abfd, machine); | 1277 | 46 | bfd_set_error (bfd_error_malformed_archive); | 1278 | | | 1279 | 46 | return NULL; | 1280 | 0 | break; | 1281 | 231 | } | 1282 | | | 1283 | 185 | if (magic == 0) | 1284 | 168 | { | 1285 | 168 | _bfd_error_handler | 1286 | | /* xgettext:c-format */ | 1287 | 168 | (_("%pB: recognised but unhandled machine type (0x%x)" | 1288 | 168 | " in Import Library Format archive"), | 1289 | 168 | abfd, machine); | 1290 | 168 | bfd_set_error (bfd_error_wrong_format); | 1291 | | | 1292 | 168 | return NULL; | 1293 | 168 | } | 1294 | | | 1295 | | /* We do not bother to check the date. | 1296 | | date = H_GET_32 (abfd, ptr); */ | 1297 | 17 | ptr += 4; | 1298 | | | 1299 | 17 | size = H_GET_32 (abfd, ptr); | 1300 | 17 | ptr += 4; | 1301 | | | 1302 | 17 | if (size == 0) | 1303 | 1 | { | 1304 | 1 | _bfd_error_handler | 1305 | 1 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1306 | 1 | bfd_set_error (bfd_error_malformed_archive); | 1307 | | | 1308 | 1 | return NULL; | 1309 | 1 | } | 1310 | | | 1311 | 16 | ordinal = H_GET_16 (abfd, ptr); | 1312 | 16 | ptr += 2; | 1313 | | | 1314 | 16 | types = H_GET_16 (abfd, ptr); | 1315 | | /* ptr += 2; */ | 1316 | | | 1317 | | /* Now read in the two strings that follow. */ | 1318 | 16 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1319 | 16 | if (ptr == NULL) | 1320 | 2 | return NULL; | 1321 | | | 1322 | 14 | symbol_name = (char *) ptr; | 1323 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1324 | 14 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1325 | | | 1326 | | /* Verify that the strings are null terminated. */ | 1327 | 14 | if (ptr[size - 1] != 0 | 1328 | 14 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1329 | 2 | { | 1330 | 2 | _bfd_error_handler | 1331 | 2 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1332 | 2 | bfd_set_error (bfd_error_malformed_archive); | 1333 | 2 | bfd_release (abfd, ptr); | 1334 | 2 | return NULL; | 1335 | 2 | } | 1336 | | | 1337 | | /* Now construct the bfd. */ | 1338 | 12 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1339 | 12 | source_dll, ordinal, types)) | 1340 | 4 | { | 1341 | 4 | bfd_release (abfd, ptr); | 1342 | 4 | return NULL; | 1343 | 4 | } | 1344 | | | 1345 | 8 | return pe_ILF_cleanup; | 1346 | 12 | } |
pei-aarch64.c:pe_ILF_object_p Line | Count | Source | 1177 | 281 | { | 1178 | 281 | bfd_byte buffer[14]; | 1179 | 281 | bfd_byte * ptr; | 1180 | 281 | char * symbol_name; | 1181 | 281 | char * source_dll; | 1182 | 281 | unsigned int machine; | 1183 | 281 | bfd_size_type size; | 1184 | 281 | unsigned int ordinal; | 1185 | 281 | unsigned int types; | 1186 | 281 | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 281 | if (bfd_bread (buffer, (bfd_size_type) 14, abfd) != 14) | 1191 | 7 | return NULL; | 1192 | | | 1193 | 274 | ptr = buffer; | 1194 | | | 1195 | 274 | machine = H_GET_16 (abfd, ptr); | 1196 | 274 | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 274 | magic = 0; | 1200 | | | 1201 | 274 | switch (machine) | 1202 | 274 | { | 1203 | 15 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 16 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 17 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 18 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 18 | break; | 1208 | | | 1209 | 25 | case IMAGE_FILE_MACHINE_I386: | 1210 | | #ifdef I386MAGIC | 1211 | | magic = I386MAGIC; | 1212 | | #endif | 1213 | 25 | break; | 1214 | | | 1215 | 17 | case IMAGE_FILE_MACHINE_AMD64: | 1216 | | #ifdef AMD64MAGIC | 1217 | | magic = AMD64MAGIC; | 1218 | | #endif | 1219 | 17 | break; | 1220 | | | 1221 | 1 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 2 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 3 | case IMAGE_FILE_MACHINE_R10000: | 1224 | | | 1225 | 4 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 5 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 6 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 6 | break; | 1232 | | | 1233 | 82 | case IMAGE_FILE_MACHINE_SH3: | 1234 | 88 | case IMAGE_FILE_MACHINE_SH4: | 1235 | | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | | magic = SH_ARCH_MAGIC_WINCE; | 1237 | | #endif | 1238 | 88 | break; | 1239 | | | 1240 | 3 | case IMAGE_FILE_MACHINE_ARM: | 1241 | | #ifdef ARMPEMAGIC | 1242 | | magic = ARMPEMAGIC; | 1243 | | #endif | 1244 | 3 | break; | 1245 | | | 1246 | 20 | case IMAGE_FILE_MACHINE_ARM64: | 1247 | 20 | #ifdef AARCH64MAGIC | 1248 | 20 | magic = AARCH64MAGIC; | 1249 | 20 | #endif | 1250 | 20 | break; | 1251 | | | 1252 | 26 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | | #ifdef LOONGARCH64MAGIC | 1254 | | magic = LOONGARCH64MAGIC; | 1255 | | #endif | 1256 | 26 | break; | 1257 | | | 1258 | 25 | case IMAGE_FILE_MACHINE_THUMB: | 1259 | | #ifdef THUMBPEMAGIC | 1260 | | { | 1261 | | extern const bfd_target TARGET_LITTLE_SYM; | 1262 | | | 1263 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1264 | | magic = THUMBPEMAGIC; | 1265 | | } | 1266 | | #endif | 1267 | 25 | break; | 1268 | | | 1269 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1270 | | /* We no longer support PowerPC. */ | 1271 | 46 | default: | 1272 | 46 | _bfd_error_handler | 1273 | | /* xgettext:c-format */ | 1274 | 46 | (_("%pB: unrecognised machine type (0x%x)" | 1275 | 46 | " in Import Library Format archive"), | 1276 | 46 | abfd, machine); | 1277 | 46 | bfd_set_error (bfd_error_malformed_archive); | 1278 | | | 1279 | 46 | return NULL; | 1280 | 0 | break; | 1281 | 274 | } | 1282 | | | 1283 | 228 | if (magic == 0) | 1284 | 208 | { | 1285 | 208 | _bfd_error_handler | 1286 | | /* xgettext:c-format */ | 1287 | 208 | (_("%pB: recognised but unhandled machine type (0x%x)" | 1288 | 208 | " in Import Library Format archive"), | 1289 | 208 | abfd, machine); | 1290 | 208 | bfd_set_error (bfd_error_wrong_format); | 1291 | | | 1292 | 208 | return NULL; | 1293 | 208 | } | 1294 | | | 1295 | | /* We do not bother to check the date. | 1296 | | date = H_GET_32 (abfd, ptr); */ | 1297 | 20 | ptr += 4; | 1298 | | | 1299 | 20 | size = H_GET_32 (abfd, ptr); | 1300 | 20 | ptr += 4; | 1301 | | | 1302 | 20 | if (size == 0) | 1303 | 2 | { | 1304 | 2 | _bfd_error_handler | 1305 | 2 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1306 | 2 | bfd_set_error (bfd_error_malformed_archive); | 1307 | | | 1308 | 2 | return NULL; | 1309 | 2 | } | 1310 | | | 1311 | 18 | ordinal = H_GET_16 (abfd, ptr); | 1312 | 18 | ptr += 2; | 1313 | | | 1314 | 18 | types = H_GET_16 (abfd, ptr); | 1315 | | /* ptr += 2; */ | 1316 | | | 1317 | | /* Now read in the two strings that follow. */ | 1318 | 18 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1319 | 18 | if (ptr == NULL) | 1320 | 4 | return NULL; | 1321 | | | 1322 | 14 | symbol_name = (char *) ptr; | 1323 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1324 | 14 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1325 | | | 1326 | | /* Verify that the strings are null terminated. */ | 1327 | 14 | if (ptr[size - 1] != 0 | 1328 | 14 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1329 | 3 | { | 1330 | 3 | _bfd_error_handler | 1331 | 3 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1332 | 3 | bfd_set_error (bfd_error_malformed_archive); | 1333 | 3 | bfd_release (abfd, ptr); | 1334 | 3 | return NULL; | 1335 | 3 | } | 1336 | | | 1337 | | /* Now construct the bfd. */ | 1338 | 11 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1339 | 11 | source_dll, ordinal, types)) | 1340 | 4 | { | 1341 | 4 | bfd_release (abfd, ptr); | 1342 | 4 | return NULL; | 1343 | 4 | } | 1344 | | | 1345 | 7 | return pe_ILF_cleanup; | 1346 | 11 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_object_p pei-loongarch64.c:pe_ILF_object_p Line | Count | Source | 1177 | 238 | { | 1178 | 238 | bfd_byte buffer[14]; | 1179 | 238 | bfd_byte * ptr; | 1180 | 238 | char * symbol_name; | 1181 | 238 | char * source_dll; | 1182 | 238 | unsigned int machine; | 1183 | 238 | bfd_size_type size; | 1184 | 238 | unsigned int ordinal; | 1185 | 238 | unsigned int types; | 1186 | 238 | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 238 | if (bfd_bread (buffer, (bfd_size_type) 14, abfd) != 14) | 1191 | 7 | return NULL; | 1192 | | | 1193 | 231 | ptr = buffer; | 1194 | | | 1195 | 231 | machine = H_GET_16 (abfd, ptr); | 1196 | 231 | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 231 | magic = 0; | 1200 | | | 1201 | 231 | switch (machine) | 1202 | 231 | { | 1203 | 15 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 16 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 17 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 18 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 18 | break; | 1208 | | | 1209 | 25 | case IMAGE_FILE_MACHINE_I386: | 1210 | | #ifdef I386MAGIC | 1211 | | magic = I386MAGIC; | 1212 | | #endif | 1213 | 25 | break; | 1214 | | | 1215 | 17 | case IMAGE_FILE_MACHINE_AMD64: | 1216 | | #ifdef AMD64MAGIC | 1217 | | magic = AMD64MAGIC; | 1218 | | #endif | 1219 | 17 | break; | 1220 | | | 1221 | 1 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 2 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 3 | case IMAGE_FILE_MACHINE_R10000: | 1224 | | | 1225 | 4 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 5 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 6 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 6 | break; | 1232 | | | 1233 | 44 | case IMAGE_FILE_MACHINE_SH3: | 1234 | 49 | case IMAGE_FILE_MACHINE_SH4: | 1235 | | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | | magic = SH_ARCH_MAGIC_WINCE; | 1237 | | #endif | 1238 | 49 | break; | 1239 | | | 1240 | 3 | case IMAGE_FILE_MACHINE_ARM: | 1241 | | #ifdef ARMPEMAGIC | 1242 | | magic = ARMPEMAGIC; | 1243 | | #endif | 1244 | 3 | break; | 1245 | | | 1246 | 20 | case IMAGE_FILE_MACHINE_ARM64: | 1247 | | #ifdef AARCH64MAGIC | 1248 | | magic = AARCH64MAGIC; | 1249 | | #endif | 1250 | 20 | break; | 1251 | | | 1252 | 26 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | 26 | #ifdef LOONGARCH64MAGIC | 1254 | 26 | magic = LOONGARCH64MAGIC; | 1255 | 26 | #endif | 1256 | 26 | break; | 1257 | | | 1258 | 21 | case IMAGE_FILE_MACHINE_THUMB: | 1259 | | #ifdef THUMBPEMAGIC | 1260 | | { | 1261 | | extern const bfd_target TARGET_LITTLE_SYM; | 1262 | | | 1263 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1264 | | magic = THUMBPEMAGIC; | 1265 | | } | 1266 | | #endif | 1267 | 21 | break; | 1268 | | | 1269 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1270 | | /* We no longer support PowerPC. */ | 1271 | 46 | default: | 1272 | 46 | _bfd_error_handler | 1273 | | /* xgettext:c-format */ | 1274 | 46 | (_("%pB: unrecognised machine type (0x%x)" | 1275 | 46 | " in Import Library Format archive"), | 1276 | 46 | abfd, machine); | 1277 | 46 | bfd_set_error (bfd_error_malformed_archive); | 1278 | | | 1279 | 46 | return NULL; | 1280 | 0 | break; | 1281 | 231 | } | 1282 | | | 1283 | 185 | if (magic == 0) | 1284 | 159 | { | 1285 | 159 | _bfd_error_handler | 1286 | | /* xgettext:c-format */ | 1287 | 159 | (_("%pB: recognised but unhandled machine type (0x%x)" | 1288 | 159 | " in Import Library Format archive"), | 1289 | 159 | abfd, machine); | 1290 | 159 | bfd_set_error (bfd_error_wrong_format); | 1291 | | | 1292 | 159 | return NULL; | 1293 | 159 | } | 1294 | | | 1295 | | /* We do not bother to check the date. | 1296 | | date = H_GET_32 (abfd, ptr); */ | 1297 | 26 | ptr += 4; | 1298 | | | 1299 | 26 | size = H_GET_32 (abfd, ptr); | 1300 | 26 | ptr += 4; | 1301 | | | 1302 | 26 | if (size == 0) | 1303 | 1 | { | 1304 | 1 | _bfd_error_handler | 1305 | 1 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1306 | 1 | bfd_set_error (bfd_error_malformed_archive); | 1307 | | | 1308 | 1 | return NULL; | 1309 | 1 | } | 1310 | | | 1311 | 25 | ordinal = H_GET_16 (abfd, ptr); | 1312 | 25 | ptr += 2; | 1313 | | | 1314 | 25 | types = H_GET_16 (abfd, ptr); | 1315 | | /* ptr += 2; */ | 1316 | | | 1317 | | /* Now read in the two strings that follow. */ | 1318 | 25 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1319 | 25 | if (ptr == NULL) | 1320 | 7 | return NULL; | 1321 | | | 1322 | 18 | symbol_name = (char *) ptr; | 1323 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1324 | 18 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1325 | | | 1326 | | /* Verify that the strings are null terminated. */ | 1327 | 18 | if (ptr[size - 1] != 0 | 1328 | 18 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1329 | 2 | { | 1330 | 2 | _bfd_error_handler | 1331 | 2 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1332 | 2 | bfd_set_error (bfd_error_malformed_archive); | 1333 | 2 | bfd_release (abfd, ptr); | 1334 | 2 | return NULL; | 1335 | 2 | } | 1336 | | | 1337 | | /* Now construct the bfd. */ | 1338 | 16 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1339 | 16 | source_dll, ordinal, types)) | 1340 | 9 | { | 1341 | 9 | bfd_release (abfd, ptr); | 1342 | 9 | return NULL; | 1343 | 9 | } | 1344 | | | 1345 | 7 | return pe_ILF_cleanup; | 1346 | 16 | } |
pei-arm-wince.c:pe_ILF_object_p Line | Count | Source | 1177 | 301 | { | 1178 | 301 | bfd_byte buffer[14]; | 1179 | 301 | bfd_byte * ptr; | 1180 | 301 | char * symbol_name; | 1181 | 301 | char * source_dll; | 1182 | 301 | unsigned int machine; | 1183 | 301 | bfd_size_type size; | 1184 | 301 | unsigned int ordinal; | 1185 | 301 | unsigned int types; | 1186 | 301 | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 301 | if (bfd_bread (buffer, (bfd_size_type) 14, abfd) != 14) | 1191 | 7 | return NULL; | 1192 | | | 1193 | 294 | ptr = buffer; | 1194 | | | 1195 | 294 | machine = H_GET_16 (abfd, ptr); | 1196 | 294 | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 294 | magic = 0; | 1200 | | | 1201 | 294 | switch (machine) | 1202 | 294 | { | 1203 | 15 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 16 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 17 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 19 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 19 | break; | 1208 | | | 1209 | 25 | case IMAGE_FILE_MACHINE_I386: | 1210 | | #ifdef I386MAGIC | 1211 | | magic = I386MAGIC; | 1212 | | #endif | 1213 | 25 | break; | 1214 | | | 1215 | 17 | case IMAGE_FILE_MACHINE_AMD64: | 1216 | | #ifdef AMD64MAGIC | 1217 | | magic = AMD64MAGIC; | 1218 | | #endif | 1219 | 17 | break; | 1220 | | | 1221 | 1 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 2 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 3 | case IMAGE_FILE_MACHINE_R10000: | 1224 | | | 1225 | 4 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 5 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 6 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 6 | break; | 1232 | | | 1233 | 82 | case IMAGE_FILE_MACHINE_SH3: | 1234 | 88 | case IMAGE_FILE_MACHINE_SH4: | 1235 | | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | | magic = SH_ARCH_MAGIC_WINCE; | 1237 | | #endif | 1238 | 88 | break; | 1239 | | | 1240 | 20 | case IMAGE_FILE_MACHINE_ARM: | 1241 | 20 | #ifdef ARMPEMAGIC | 1242 | 20 | magic = ARMPEMAGIC; | 1243 | 20 | #endif | 1244 | 20 | break; | 1245 | | | 1246 | 20 | case IMAGE_FILE_MACHINE_ARM64: | 1247 | | #ifdef AARCH64MAGIC | 1248 | | magic = AARCH64MAGIC; | 1249 | | #endif | 1250 | 20 | break; | 1251 | | | 1252 | 26 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | | #ifdef LOONGARCH64MAGIC | 1254 | | magic = LOONGARCH64MAGIC; | 1255 | | #endif | 1256 | 26 | break; | 1257 | | | 1258 | 22 | case IMAGE_FILE_MACHINE_THUMB: | 1259 | 22 | #ifdef THUMBPEMAGIC | 1260 | 22 | { | 1261 | 22 | extern const bfd_target TARGET_LITTLE_SYM; | 1262 | | | 1263 | 22 | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1264 | 21 | magic = THUMBPEMAGIC; | 1265 | 22 | } | 1266 | 22 | #endif | 1267 | 22 | break; | 1268 | | | 1269 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1270 | | /* We no longer support PowerPC. */ | 1271 | 51 | default: | 1272 | 51 | _bfd_error_handler | 1273 | | /* xgettext:c-format */ | 1274 | 51 | (_("%pB: unrecognised machine type (0x%x)" | 1275 | 51 | " in Import Library Format archive"), | 1276 | 51 | abfd, machine); | 1277 | 51 | bfd_set_error (bfd_error_malformed_archive); | 1278 | | | 1279 | 51 | return NULL; | 1280 | 0 | break; | 1281 | 294 | } | 1282 | | | 1283 | 243 | if (magic == 0) | 1284 | 202 | { | 1285 | 202 | _bfd_error_handler | 1286 | | /* xgettext:c-format */ | 1287 | 202 | (_("%pB: recognised but unhandled machine type (0x%x)" | 1288 | 202 | " in Import Library Format archive"), | 1289 | 202 | abfd, machine); | 1290 | 202 | bfd_set_error (bfd_error_wrong_format); | 1291 | | | 1292 | 202 | return NULL; | 1293 | 202 | } | 1294 | | | 1295 | | /* We do not bother to check the date. | 1296 | | date = H_GET_32 (abfd, ptr); */ | 1297 | 41 | ptr += 4; | 1298 | | | 1299 | 41 | size = H_GET_32 (abfd, ptr); | 1300 | 41 | ptr += 4; | 1301 | | | 1302 | 41 | if (size == 0) | 1303 | 3 | { | 1304 | 3 | _bfd_error_handler | 1305 | 3 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1306 | 3 | bfd_set_error (bfd_error_malformed_archive); | 1307 | | | 1308 | 3 | return NULL; | 1309 | 3 | } | 1310 | | | 1311 | 38 | ordinal = H_GET_16 (abfd, ptr); | 1312 | 38 | ptr += 2; | 1313 | | | 1314 | 38 | types = H_GET_16 (abfd, ptr); | 1315 | | /* ptr += 2; */ | 1316 | | | 1317 | | /* Now read in the two strings that follow. */ | 1318 | 38 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1319 | 38 | if (ptr == NULL) | 1320 | 17 | return NULL; | 1321 | | | 1322 | 21 | symbol_name = (char *) ptr; | 1323 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1324 | 21 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1325 | | | 1326 | | /* Verify that the strings are null terminated. */ | 1327 | 21 | if (ptr[size - 1] != 0 | 1328 | 21 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1329 | 4 | { | 1330 | 4 | _bfd_error_handler | 1331 | 4 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1332 | 4 | bfd_set_error (bfd_error_malformed_archive); | 1333 | 4 | bfd_release (abfd, ptr); | 1334 | 4 | return NULL; | 1335 | 4 | } | 1336 | | | 1337 | | /* Now construct the bfd. */ | 1338 | 17 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1339 | 17 | source_dll, ordinal, types)) | 1340 | 5 | { | 1341 | 5 | bfd_release (abfd, ptr); | 1342 | 5 | return NULL; | 1343 | 5 | } | 1344 | | | 1345 | 12 | return pe_ILF_cleanup; | 1346 | 17 | } |
pei-arm.c:pe_ILF_object_p Line | Count | Source | 1177 | 305 | { | 1178 | 305 | bfd_byte buffer[14]; | 1179 | 305 | bfd_byte * ptr; | 1180 | 305 | char * symbol_name; | 1181 | 305 | char * source_dll; | 1182 | 305 | unsigned int machine; | 1183 | 305 | bfd_size_type size; | 1184 | 305 | unsigned int ordinal; | 1185 | 305 | unsigned int types; | 1186 | 305 | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 305 | if (bfd_bread (buffer, (bfd_size_type) 14, abfd) != 14) | 1191 | 7 | return NULL; | 1192 | | | 1193 | 298 | ptr = buffer; | 1194 | | | 1195 | 298 | machine = H_GET_16 (abfd, ptr); | 1196 | 298 | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 298 | magic = 0; | 1200 | | | 1201 | 298 | switch (machine) | 1202 | 298 | { | 1203 | 15 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 16 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 17 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 19 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 19 | break; | 1208 | | | 1209 | 25 | case IMAGE_FILE_MACHINE_I386: | 1210 | | #ifdef I386MAGIC | 1211 | | magic = I386MAGIC; | 1212 | | #endif | 1213 | 25 | break; | 1214 | | | 1215 | 17 | case IMAGE_FILE_MACHINE_AMD64: | 1216 | | #ifdef AMD64MAGIC | 1217 | | magic = AMD64MAGIC; | 1218 | | #endif | 1219 | 17 | break; | 1220 | | | 1221 | 1 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 2 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 3 | case IMAGE_FILE_MACHINE_R10000: | 1224 | | | 1225 | 4 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 5 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 6 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 6 | break; | 1232 | | | 1233 | 82 | case IMAGE_FILE_MACHINE_SH3: | 1234 | 88 | case IMAGE_FILE_MACHINE_SH4: | 1235 | | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | | magic = SH_ARCH_MAGIC_WINCE; | 1237 | | #endif | 1238 | 88 | break; | 1239 | | | 1240 | 20 | case IMAGE_FILE_MACHINE_ARM: | 1241 | 20 | #ifdef ARMPEMAGIC | 1242 | 20 | magic = ARMPEMAGIC; | 1243 | 20 | #endif | 1244 | 20 | break; | 1245 | | | 1246 | 20 | case IMAGE_FILE_MACHINE_ARM64: | 1247 | | #ifdef AARCH64MAGIC | 1248 | | magic = AARCH64MAGIC; | 1249 | | #endif | 1250 | 20 | break; | 1251 | | | 1252 | 26 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | | #ifdef LOONGARCH64MAGIC | 1254 | | magic = LOONGARCH64MAGIC; | 1255 | | #endif | 1256 | 26 | break; | 1257 | | | 1258 | 26 | case IMAGE_FILE_MACHINE_THUMB: | 1259 | 26 | #ifdef THUMBPEMAGIC | 1260 | 26 | { | 1261 | 26 | extern const bfd_target TARGET_LITTLE_SYM; | 1262 | | | 1263 | 26 | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1264 | 25 | magic = THUMBPEMAGIC; | 1265 | 26 | } | 1266 | 26 | #endif | 1267 | 26 | break; | 1268 | | | 1269 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1270 | | /* We no longer support PowerPC. */ | 1271 | 51 | default: | 1272 | 51 | _bfd_error_handler | 1273 | | /* xgettext:c-format */ | 1274 | 51 | (_("%pB: unrecognised machine type (0x%x)" | 1275 | 51 | " in Import Library Format archive"), | 1276 | 51 | abfd, machine); | 1277 | 51 | bfd_set_error (bfd_error_malformed_archive); | 1278 | | | 1279 | 51 | return NULL; | 1280 | 0 | break; | 1281 | 298 | } | 1282 | | | 1283 | 247 | if (magic == 0) | 1284 | 202 | { | 1285 | 202 | _bfd_error_handler | 1286 | | /* xgettext:c-format */ | 1287 | 202 | (_("%pB: recognised but unhandled machine type (0x%x)" | 1288 | 202 | " in Import Library Format archive"), | 1289 | 202 | abfd, machine); | 1290 | 202 | bfd_set_error (bfd_error_wrong_format); | 1291 | | | 1292 | 202 | return NULL; | 1293 | 202 | } | 1294 | | | 1295 | | /* We do not bother to check the date. | 1296 | | date = H_GET_32 (abfd, ptr); */ | 1297 | 45 | ptr += 4; | 1298 | | | 1299 | 45 | size = H_GET_32 (abfd, ptr); | 1300 | 45 | ptr += 4; | 1301 | | | 1302 | 45 | if (size == 0) | 1303 | 3 | { | 1304 | 3 | _bfd_error_handler | 1305 | 3 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1306 | 3 | bfd_set_error (bfd_error_malformed_archive); | 1307 | | | 1308 | 3 | return NULL; | 1309 | 3 | } | 1310 | | | 1311 | 42 | ordinal = H_GET_16 (abfd, ptr); | 1312 | 42 | ptr += 2; | 1313 | | | 1314 | 42 | types = H_GET_16 (abfd, ptr); | 1315 | | /* ptr += 2; */ | 1316 | | | 1317 | | /* Now read in the two strings that follow. */ | 1318 | 42 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1319 | 42 | if (ptr == NULL) | 1320 | 17 | return NULL; | 1321 | | | 1322 | 25 | symbol_name = (char *) ptr; | 1323 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1324 | 25 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1325 | | | 1326 | | /* Verify that the strings are null terminated. */ | 1327 | 25 | if (ptr[size - 1] != 0 | 1328 | 25 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1329 | 4 | { | 1330 | 4 | _bfd_error_handler | 1331 | 4 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1332 | 4 | bfd_set_error (bfd_error_malformed_archive); | 1333 | 4 | bfd_release (abfd, ptr); | 1334 | 4 | return NULL; | 1335 | 4 | } | 1336 | | | 1337 | | /* Now construct the bfd. */ | 1338 | 21 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1339 | 21 | source_dll, ordinal, types)) | 1340 | 5 | { | 1341 | 5 | bfd_release (abfd, ptr); | 1342 | 5 | return NULL; | 1343 | 5 | } | 1344 | | | 1345 | 16 | return pe_ILF_cleanup; | 1346 | 21 | } |
pei-mcore.c:pe_ILF_object_p Line | Count | Source | 1177 | 301 | { | 1178 | 301 | bfd_byte buffer[14]; | 1179 | 301 | bfd_byte * ptr; | 1180 | 301 | char * symbol_name; | 1181 | 301 | char * source_dll; | 1182 | 301 | unsigned int machine; | 1183 | 301 | bfd_size_type size; | 1184 | 301 | unsigned int ordinal; | 1185 | 301 | unsigned int types; | 1186 | 301 | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 301 | if (bfd_bread (buffer, (bfd_size_type) 14, abfd) != 14) | 1191 | 7 | return NULL; | 1192 | | | 1193 | 294 | ptr = buffer; | 1194 | | | 1195 | 294 | machine = H_GET_16 (abfd, ptr); | 1196 | 294 | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 294 | magic = 0; | 1200 | | | 1201 | 294 | switch (machine) | 1202 | 294 | { | 1203 | 15 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 16 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 17 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 19 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 19 | break; | 1208 | | | 1209 | 25 | case IMAGE_FILE_MACHINE_I386: | 1210 | | #ifdef I386MAGIC | 1211 | | magic = I386MAGIC; | 1212 | | #endif | 1213 | 25 | break; | 1214 | | | 1215 | 17 | case IMAGE_FILE_MACHINE_AMD64: | 1216 | | #ifdef AMD64MAGIC | 1217 | | magic = AMD64MAGIC; | 1218 | | #endif | 1219 | 17 | break; | 1220 | | | 1221 | 1 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 2 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 3 | case IMAGE_FILE_MACHINE_R10000: | 1224 | | | 1225 | 4 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 5 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 6 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 6 | break; | 1232 | | | 1233 | 82 | case IMAGE_FILE_MACHINE_SH3: | 1234 | 88 | case IMAGE_FILE_MACHINE_SH4: | 1235 | | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | | magic = SH_ARCH_MAGIC_WINCE; | 1237 | | #endif | 1238 | 88 | break; | 1239 | | | 1240 | 20 | case IMAGE_FILE_MACHINE_ARM: | 1241 | | #ifdef ARMPEMAGIC | 1242 | | magic = ARMPEMAGIC; | 1243 | | #endif | 1244 | 20 | break; | 1245 | | | 1246 | 20 | case IMAGE_FILE_MACHINE_ARM64: | 1247 | | #ifdef AARCH64MAGIC | 1248 | | magic = AARCH64MAGIC; | 1249 | | #endif | 1250 | 20 | break; | 1251 | | | 1252 | 26 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | | #ifdef LOONGARCH64MAGIC | 1254 | | magic = LOONGARCH64MAGIC; | 1255 | | #endif | 1256 | 26 | break; | 1257 | | | 1258 | 22 | case IMAGE_FILE_MACHINE_THUMB: | 1259 | | #ifdef THUMBPEMAGIC | 1260 | | { | 1261 | | extern const bfd_target TARGET_LITTLE_SYM; | 1262 | | | 1263 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1264 | | magic = THUMBPEMAGIC; | 1265 | | } | 1266 | | #endif | 1267 | 22 | break; | 1268 | | | 1269 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1270 | | /* We no longer support PowerPC. */ | 1271 | 51 | default: | 1272 | 51 | _bfd_error_handler | 1273 | | /* xgettext:c-format */ | 1274 | 51 | (_("%pB: unrecognised machine type (0x%x)" | 1275 | 51 | " in Import Library Format archive"), | 1276 | 51 | abfd, machine); | 1277 | 51 | bfd_set_error (bfd_error_malformed_archive); | 1278 | | | 1279 | 51 | return NULL; | 1280 | 0 | break; | 1281 | 294 | } | 1282 | | | 1283 | 243 | if (magic == 0) | 1284 | 243 | { | 1285 | 243 | _bfd_error_handler | 1286 | | /* xgettext:c-format */ | 1287 | 243 | (_("%pB: recognised but unhandled machine type (0x%x)" | 1288 | 243 | " in Import Library Format archive"), | 1289 | 243 | abfd, machine); | 1290 | 243 | bfd_set_error (bfd_error_wrong_format); | 1291 | | | 1292 | 243 | return NULL; | 1293 | 243 | } | 1294 | | | 1295 | | /* We do not bother to check the date. | 1296 | | date = H_GET_32 (abfd, ptr); */ | 1297 | 0 | ptr += 4; | 1298 | |
| 1299 | 0 | size = H_GET_32 (abfd, ptr); | 1300 | 0 | ptr += 4; | 1301 | |
| 1302 | 0 | if (size == 0) | 1303 | 0 | { | 1304 | 0 | _bfd_error_handler | 1305 | 0 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1306 | 0 | bfd_set_error (bfd_error_malformed_archive); | 1307 | |
| 1308 | 0 | return NULL; | 1309 | 0 | } | 1310 | | | 1311 | 0 | ordinal = H_GET_16 (abfd, ptr); | 1312 | 0 | ptr += 2; | 1313 | |
| 1314 | 0 | types = H_GET_16 (abfd, ptr); | 1315 | | /* ptr += 2; */ | 1316 | | | 1317 | | /* Now read in the two strings that follow. */ | 1318 | 0 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1319 | 0 | if (ptr == NULL) | 1320 | 0 | return NULL; | 1321 | | | 1322 | 0 | symbol_name = (char *) ptr; | 1323 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1324 | 0 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1325 | | | 1326 | | /* Verify that the strings are null terminated. */ | 1327 | 0 | if (ptr[size - 1] != 0 | 1328 | 0 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1329 | 0 | { | 1330 | 0 | _bfd_error_handler | 1331 | 0 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1332 | 0 | bfd_set_error (bfd_error_malformed_archive); | 1333 | 0 | bfd_release (abfd, ptr); | 1334 | 0 | return NULL; | 1335 | 0 | } | 1336 | | | 1337 | | /* Now construct the bfd. */ | 1338 | 0 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1339 | 0 | source_dll, ordinal, types)) | 1340 | 0 | { | 1341 | 0 | bfd_release (abfd, ptr); | 1342 | 0 | return NULL; | 1343 | 0 | } | 1344 | | | 1345 | 0 | return pe_ILF_cleanup; | 1346 | 0 | } |
Line | Count | Source | 1177 | 277 | { | 1178 | 277 | bfd_byte buffer[14]; | 1179 | 277 | bfd_byte * ptr; | 1180 | 277 | char * symbol_name; | 1181 | 277 | char * source_dll; | 1182 | 277 | unsigned int machine; | 1183 | 277 | bfd_size_type size; | 1184 | 277 | unsigned int ordinal; | 1185 | 277 | unsigned int types; | 1186 | 277 | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 277 | if (bfd_bread (buffer, (bfd_size_type) 14, abfd) != 14) | 1191 | 7 | return NULL; | 1192 | | | 1193 | 270 | ptr = buffer; | 1194 | | | 1195 | 270 | machine = H_GET_16 (abfd, ptr); | 1196 | 270 | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 270 | magic = 0; | 1200 | | | 1201 | 270 | switch (machine) | 1202 | 270 | { | 1203 | 15 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 16 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 17 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 18 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 18 | break; | 1208 | | | 1209 | 25 | case IMAGE_FILE_MACHINE_I386: | 1210 | | #ifdef I386MAGIC | 1211 | | magic = I386MAGIC; | 1212 | | #endif | 1213 | 25 | break; | 1214 | | | 1215 | 17 | case IMAGE_FILE_MACHINE_AMD64: | 1216 | | #ifdef AMD64MAGIC | 1217 | | magic = AMD64MAGIC; | 1218 | | #endif | 1219 | 17 | break; | 1220 | | | 1221 | 1 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 2 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 3 | case IMAGE_FILE_MACHINE_R10000: | 1224 | | | 1225 | 4 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 5 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 6 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 6 | break; | 1232 | | | 1233 | 82 | case IMAGE_FILE_MACHINE_SH3: | 1234 | 88 | case IMAGE_FILE_MACHINE_SH4: | 1235 | 88 | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | 88 | magic = SH_ARCH_MAGIC_WINCE; | 1237 | 88 | #endif | 1238 | 88 | break; | 1239 | | | 1240 | 3 | case IMAGE_FILE_MACHINE_ARM: | 1241 | | #ifdef ARMPEMAGIC | 1242 | | magic = ARMPEMAGIC; | 1243 | | #endif | 1244 | 3 | break; | 1245 | | | 1246 | 20 | case IMAGE_FILE_MACHINE_ARM64: | 1247 | | #ifdef AARCH64MAGIC | 1248 | | magic = AARCH64MAGIC; | 1249 | | #endif | 1250 | 20 | break; | 1251 | | | 1252 | 26 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | | #ifdef LOONGARCH64MAGIC | 1254 | | magic = LOONGARCH64MAGIC; | 1255 | | #endif | 1256 | 26 | break; | 1257 | | | 1258 | 21 | case IMAGE_FILE_MACHINE_THUMB: | 1259 | | #ifdef THUMBPEMAGIC | 1260 | | { | 1261 | | extern const bfd_target TARGET_LITTLE_SYM; | 1262 | | | 1263 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1264 | | magic = THUMBPEMAGIC; | 1265 | | } | 1266 | | #endif | 1267 | 21 | break; | 1268 | | | 1269 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1270 | | /* We no longer support PowerPC. */ | 1271 | 46 | default: | 1272 | 46 | _bfd_error_handler | 1273 | | /* xgettext:c-format */ | 1274 | 46 | (_("%pB: unrecognised machine type (0x%x)" | 1275 | 46 | " in Import Library Format archive"), | 1276 | 46 | abfd, machine); | 1277 | 46 | bfd_set_error (bfd_error_malformed_archive); | 1278 | | | 1279 | 46 | return NULL; | 1280 | 0 | break; | 1281 | 270 | } | 1282 | | | 1283 | 224 | if (magic == 0) | 1284 | 136 | { | 1285 | 136 | _bfd_error_handler | 1286 | | /* xgettext:c-format */ | 1287 | 136 | (_("%pB: recognised but unhandled machine type (0x%x)" | 1288 | 136 | " in Import Library Format archive"), | 1289 | 136 | abfd, machine); | 1290 | 136 | bfd_set_error (bfd_error_wrong_format); | 1291 | | | 1292 | 136 | return NULL; | 1293 | 136 | } | 1294 | | | 1295 | | /* We do not bother to check the date. | 1296 | | date = H_GET_32 (abfd, ptr); */ | 1297 | 88 | ptr += 4; | 1298 | | | 1299 | 88 | size = H_GET_32 (abfd, ptr); | 1300 | 88 | ptr += 4; | 1301 | | | 1302 | 88 | if (size == 0) | 1303 | 2 | { | 1304 | 2 | _bfd_error_handler | 1305 | 2 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1306 | 2 | bfd_set_error (bfd_error_malformed_archive); | 1307 | | | 1308 | 2 | return NULL; | 1309 | 2 | } | 1310 | | | 1311 | 86 | ordinal = H_GET_16 (abfd, ptr); | 1312 | 86 | ptr += 2; | 1313 | | | 1314 | 86 | types = H_GET_16 (abfd, ptr); | 1315 | | /* ptr += 2; */ | 1316 | | | 1317 | | /* Now read in the two strings that follow. */ | 1318 | 86 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1319 | 86 | if (ptr == NULL) | 1320 | 15 | return NULL; | 1321 | | | 1322 | 71 | symbol_name = (char *) ptr; | 1323 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1324 | 71 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1325 | | | 1326 | | /* Verify that the strings are null terminated. */ | 1327 | 71 | if (ptr[size - 1] != 0 | 1328 | 71 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1329 | 15 | { | 1330 | 15 | _bfd_error_handler | 1331 | 15 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1332 | 15 | bfd_set_error (bfd_error_malformed_archive); | 1333 | 15 | bfd_release (abfd, ptr); | 1334 | 15 | return NULL; | 1335 | 15 | } | 1336 | | | 1337 | | /* Now construct the bfd. */ | 1338 | 56 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1339 | 56 | source_dll, ordinal, types)) | 1340 | 11 | { | 1341 | 11 | bfd_release (abfd, ptr); | 1342 | 11 | return NULL; | 1343 | 11 | } | 1344 | | | 1345 | 45 | return pe_ILF_cleanup; | 1346 | 56 | } |
|
1347 | | |
1348 | | static void |
1349 | | pe_bfd_read_buildid (bfd *abfd) |
1350 | 2.55k | { |
1351 | 2.55k | pe_data_type *pe = pe_data (abfd); |
1352 | 2.55k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; |
1353 | 2.55k | asection *section; |
1354 | 2.55k | bfd_byte *data = 0; |
1355 | 2.55k | bfd_size_type dataoff; |
1356 | 2.55k | unsigned int i; |
1357 | 2.55k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; |
1358 | 2.55k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; |
1359 | | |
1360 | 2.55k | if (size == 0) |
1361 | 1.33k | return; |
1362 | | |
1363 | 1.21k | addr += extra->ImageBase; |
1364 | | |
1365 | | /* Search for the section containing the DebugDirectory. */ |
1366 | 5.40k | for (section = abfd->sections; section != NULL; section = section->next) |
1367 | 4.64k | { |
1368 | 4.64k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) |
1369 | 462 | break; |
1370 | 4.64k | } |
1371 | | |
1372 | 1.21k | if (section == NULL) |
1373 | 756 | return; |
1374 | | |
1375 | 462 | if (!(section->flags & SEC_HAS_CONTENTS)) |
1376 | 60 | return; |
1377 | | |
1378 | 402 | dataoff = addr - section->vma; |
1379 | | |
1380 | | /* PR 20605 and 22373: Make sure that the data is really there. |
1381 | | Note - since we are dealing with unsigned quantities we have |
1382 | | to be careful to check for potential overflows. */ |
1383 | 402 | if (dataoff >= section->size |
1384 | 402 | || size > section->size - dataoff) |
1385 | 115 | { |
1386 | 115 | _bfd_error_handler |
1387 | 115 | (_("%pB: error: debug data ends beyond end of debug directory"), |
1388 | 115 | abfd); |
1389 | 115 | return; |
1390 | 115 | } |
1391 | | |
1392 | | /* Read the whole section. */ |
1393 | 287 | if (!bfd_malloc_and_get_section (abfd, section, &data)) |
1394 | 208 | { |
1395 | 208 | free (data); |
1396 | 208 | return; |
1397 | 208 | } |
1398 | | |
1399 | | /* Search for a CodeView entry in the DebugDirectory */ |
1400 | 315 | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) |
1401 | 282 | { |
1402 | 282 | struct external_IMAGE_DEBUG_DIRECTORY *ext |
1403 | 282 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; |
1404 | 282 | struct internal_IMAGE_DEBUG_DIRECTORY idd; |
1405 | | |
1406 | 282 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); |
1407 | | |
1408 | 282 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) |
1409 | 46 | { |
1410 | 46 | char buffer[256 + 1]; |
1411 | 46 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; |
1412 | | |
1413 | | /* |
1414 | | The debug entry doesn't have to have to be in a section, in which |
1415 | | case AddressOfRawData is 0, so always use PointerToRawData. |
1416 | | */ |
1417 | 46 | if (_bfd_XXi_slurp_codeview_record (abfd, |
1418 | 46 | (file_ptr) idd.PointerToRawData, |
1419 | 46 | idd.SizeOfData, cvinfo, NULL)) |
1420 | 4 | { |
1421 | 4 | struct bfd_build_id* build_id = bfd_alloc (abfd, |
1422 | 4 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); |
1423 | 4 | if (build_id) |
1424 | 4 | { |
1425 | 4 | build_id->size = cvinfo->SignatureLength; |
1426 | 4 | memcpy(build_id->data, cvinfo->Signature, |
1427 | 4 | cvinfo->SignatureLength); |
1428 | 4 | abfd->build_id = build_id; |
1429 | 4 | } |
1430 | 4 | } |
1431 | 46 | break; |
1432 | 46 | } |
1433 | 282 | } |
1434 | | |
1435 | 79 | free (data); |
1436 | 79 | } pei-i386.c:pe_bfd_read_buildid Line | Count | Source | 1350 | 475 | { | 1351 | 475 | pe_data_type *pe = pe_data (abfd); | 1352 | 475 | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1353 | 475 | asection *section; | 1354 | 475 | bfd_byte *data = 0; | 1355 | 475 | bfd_size_type dataoff; | 1356 | 475 | unsigned int i; | 1357 | 475 | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1358 | 475 | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1359 | | | 1360 | 475 | if (size == 0) | 1361 | 277 | return; | 1362 | | | 1363 | 198 | addr += extra->ImageBase; | 1364 | | | 1365 | | /* Search for the section containing the DebugDirectory. */ | 1366 | 1.08k | for (section = abfd->sections; section != NULL; section = section->next) | 1367 | 981 | { | 1368 | 981 | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1369 | 97 | break; | 1370 | 981 | } | 1371 | | | 1372 | 198 | if (section == NULL) | 1373 | 101 | return; | 1374 | | | 1375 | 97 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1376 | 13 | return; | 1377 | | | 1378 | 84 | dataoff = addr - section->vma; | 1379 | | | 1380 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1381 | | Note - since we are dealing with unsigned quantities we have | 1382 | | to be careful to check for potential overflows. */ | 1383 | 84 | if (dataoff >= section->size | 1384 | 84 | || size > section->size - dataoff) | 1385 | 34 | { | 1386 | 34 | _bfd_error_handler | 1387 | 34 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1388 | 34 | abfd); | 1389 | 34 | return; | 1390 | 34 | } | 1391 | | | 1392 | | /* Read the whole section. */ | 1393 | 50 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1394 | 33 | { | 1395 | 33 | free (data); | 1396 | 33 | return; | 1397 | 33 | } | 1398 | | | 1399 | | /* Search for a CodeView entry in the DebugDirectory */ | 1400 | 64 | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1401 | 56 | { | 1402 | 56 | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1403 | 56 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1404 | 56 | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1405 | | | 1406 | 56 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1407 | | | 1408 | 56 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1409 | 9 | { | 1410 | 9 | char buffer[256 + 1]; | 1411 | 9 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1412 | | | 1413 | | /* | 1414 | | The debug entry doesn't have to have to be in a section, in which | 1415 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1416 | | */ | 1417 | 9 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1418 | 9 | (file_ptr) idd.PointerToRawData, | 1419 | 9 | idd.SizeOfData, cvinfo, NULL)) | 1420 | 1 | { | 1421 | 1 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1422 | 1 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1423 | 1 | if (build_id) | 1424 | 1 | { | 1425 | 1 | build_id->size = cvinfo->SignatureLength; | 1426 | 1 | memcpy(build_id->data, cvinfo->Signature, | 1427 | 1 | cvinfo->SignatureLength); | 1428 | 1 | abfd->build_id = build_id; | 1429 | 1 | } | 1430 | 1 | } | 1431 | 9 | break; | 1432 | 9 | } | 1433 | 56 | } | 1434 | | | 1435 | 17 | free (data); | 1436 | 17 | } |
pei-x86_64.c:pe_bfd_read_buildid Line | Count | Source | 1350 | 393 | { | 1351 | 393 | pe_data_type *pe = pe_data (abfd); | 1352 | 393 | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1353 | 393 | asection *section; | 1354 | 393 | bfd_byte *data = 0; | 1355 | 393 | bfd_size_type dataoff; | 1356 | 393 | unsigned int i; | 1357 | 393 | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1358 | 393 | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1359 | | | 1360 | 393 | if (size == 0) | 1361 | 187 | return; | 1362 | | | 1363 | 206 | addr += extra->ImageBase; | 1364 | | | 1365 | | /* Search for the section containing the DebugDirectory. */ | 1366 | 1.10k | for (section = abfd->sections; section != NULL; section = section->next) | 1367 | 945 | { | 1368 | 945 | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1369 | 49 | break; | 1370 | 945 | } | 1371 | | | 1372 | 206 | if (section == NULL) | 1373 | 157 | return; | 1374 | | | 1375 | 49 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1376 | 5 | return; | 1377 | | | 1378 | 44 | dataoff = addr - section->vma; | 1379 | | | 1380 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1381 | | Note - since we are dealing with unsigned quantities we have | 1382 | | to be careful to check for potential overflows. */ | 1383 | 44 | if (dataoff >= section->size | 1384 | 44 | || size > section->size - dataoff) | 1385 | 17 | { | 1386 | 17 | _bfd_error_handler | 1387 | 17 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1388 | 17 | abfd); | 1389 | 17 | return; | 1390 | 17 | } | 1391 | | | 1392 | | /* Read the whole section. */ | 1393 | 27 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1394 | 23 | { | 1395 | 23 | free (data); | 1396 | 23 | return; | 1397 | 23 | } | 1398 | | | 1399 | | /* Search for a CodeView entry in the DebugDirectory */ | 1400 | 8 | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1401 | 7 | { | 1402 | 7 | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1403 | 7 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1404 | 7 | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1405 | | | 1406 | 7 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1407 | | | 1408 | 7 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1409 | 3 | { | 1410 | 3 | char buffer[256 + 1]; | 1411 | 3 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1412 | | | 1413 | | /* | 1414 | | The debug entry doesn't have to have to be in a section, in which | 1415 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1416 | | */ | 1417 | 3 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1418 | 3 | (file_ptr) idd.PointerToRawData, | 1419 | 3 | idd.SizeOfData, cvinfo, NULL)) | 1420 | 1 | { | 1421 | 1 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1422 | 1 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1423 | 1 | if (build_id) | 1424 | 1 | { | 1425 | 1 | build_id->size = cvinfo->SignatureLength; | 1426 | 1 | memcpy(build_id->data, cvinfo->Signature, | 1427 | 1 | cvinfo->SignatureLength); | 1428 | 1 | abfd->build_id = build_id; | 1429 | 1 | } | 1430 | 1 | } | 1431 | 3 | break; | 1432 | 3 | } | 1433 | 7 | } | 1434 | | | 1435 | 4 | free (data); | 1436 | 4 | } |
pei-aarch64.c:pe_bfd_read_buildid Line | Count | Source | 1350 | 217 | { | 1351 | 217 | pe_data_type *pe = pe_data (abfd); | 1352 | 217 | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1353 | 217 | asection *section; | 1354 | 217 | bfd_byte *data = 0; | 1355 | 217 | bfd_size_type dataoff; | 1356 | 217 | unsigned int i; | 1357 | 217 | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1358 | 217 | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1359 | | | 1360 | 217 | if (size == 0) | 1361 | 89 | return; | 1362 | | | 1363 | 128 | addr += extra->ImageBase; | 1364 | | | 1365 | | /* Search for the section containing the DebugDirectory. */ | 1366 | 936 | for (section = abfd->sections; section != NULL; section = section->next) | 1367 | 835 | { | 1368 | 835 | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1369 | 27 | break; | 1370 | 835 | } | 1371 | | | 1372 | 128 | if (section == NULL) | 1373 | 101 | return; | 1374 | | | 1375 | 27 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1376 | 3 | return; | 1377 | | | 1378 | 24 | dataoff = addr - section->vma; | 1379 | | | 1380 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1381 | | Note - since we are dealing with unsigned quantities we have | 1382 | | to be careful to check for potential overflows. */ | 1383 | 24 | if (dataoff >= section->size | 1384 | 24 | || size > section->size - dataoff) | 1385 | 6 | { | 1386 | 6 | _bfd_error_handler | 1387 | 6 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1388 | 6 | abfd); | 1389 | 6 | return; | 1390 | 6 | } | 1391 | | | 1392 | | /* Read the whole section. */ | 1393 | 18 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1394 | 9 | { | 1395 | 9 | free (data); | 1396 | 9 | return; | 1397 | 9 | } | 1398 | | | 1399 | | /* Search for a CodeView entry in the DebugDirectory */ | 1400 | 34 | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1401 | 31 | { | 1402 | 31 | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1403 | 31 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1404 | 31 | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1405 | | | 1406 | 31 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1407 | | | 1408 | 31 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1409 | 6 | { | 1410 | 6 | char buffer[256 + 1]; | 1411 | 6 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1412 | | | 1413 | | /* | 1414 | | The debug entry doesn't have to have to be in a section, in which | 1415 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1416 | | */ | 1417 | 6 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1418 | 6 | (file_ptr) idd.PointerToRawData, | 1419 | 6 | idd.SizeOfData, cvinfo, NULL)) | 1420 | 0 | { | 1421 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1422 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1423 | 0 | if (build_id) | 1424 | 0 | { | 1425 | 0 | build_id->size = cvinfo->SignatureLength; | 1426 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1427 | 0 | cvinfo->SignatureLength); | 1428 | 0 | abfd->build_id = build_id; | 1429 | 0 | } | 1430 | 0 | } | 1431 | 6 | break; | 1432 | 6 | } | 1433 | 31 | } | 1434 | | | 1435 | 9 | free (data); | 1436 | 9 | } |
pei-ia64.c:pe_bfd_read_buildid Line | Count | Source | 1350 | 295 | { | 1351 | 295 | pe_data_type *pe = pe_data (abfd); | 1352 | 295 | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1353 | 295 | asection *section; | 1354 | 295 | bfd_byte *data = 0; | 1355 | 295 | bfd_size_type dataoff; | 1356 | 295 | unsigned int i; | 1357 | 295 | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1358 | 295 | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1359 | | | 1360 | 295 | if (size == 0) | 1361 | 182 | return; | 1362 | | | 1363 | 113 | addr += extra->ImageBase; | 1364 | | | 1365 | | /* Search for the section containing the DebugDirectory. */ | 1366 | 326 | for (section = abfd->sections; section != NULL; section = section->next) | 1367 | 231 | { | 1368 | 231 | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1369 | 18 | break; | 1370 | 231 | } | 1371 | | | 1372 | 113 | if (section == NULL) | 1373 | 95 | return; | 1374 | | | 1375 | 18 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1376 | 2 | return; | 1377 | | | 1378 | 16 | dataoff = addr - section->vma; | 1379 | | | 1380 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1381 | | Note - since we are dealing with unsigned quantities we have | 1382 | | to be careful to check for potential overflows. */ | 1383 | 16 | if (dataoff >= section->size | 1384 | 16 | || size > section->size - dataoff) | 1385 | 5 | { | 1386 | 5 | _bfd_error_handler | 1387 | 5 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1388 | 5 | abfd); | 1389 | 5 | return; | 1390 | 5 | } | 1391 | | | 1392 | | /* Read the whole section. */ | 1393 | 11 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1394 | 2 | { | 1395 | 2 | free (data); | 1396 | 2 | return; | 1397 | 2 | } | 1398 | | | 1399 | | /* Search for a CodeView entry in the DebugDirectory */ | 1400 | 43 | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1401 | 41 | { | 1402 | 41 | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1403 | 41 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1404 | 41 | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1405 | | | 1406 | 41 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1407 | | | 1408 | 41 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1409 | 7 | { | 1410 | 7 | char buffer[256 + 1]; | 1411 | 7 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1412 | | | 1413 | | /* | 1414 | | The debug entry doesn't have to have to be in a section, in which | 1415 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1416 | | */ | 1417 | 7 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1418 | 7 | (file_ptr) idd.PointerToRawData, | 1419 | 7 | idd.SizeOfData, cvinfo, NULL)) | 1420 | 0 | { | 1421 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1422 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1423 | 0 | if (build_id) | 1424 | 0 | { | 1425 | 0 | build_id->size = cvinfo->SignatureLength; | 1426 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1427 | 0 | cvinfo->SignatureLength); | 1428 | 0 | abfd->build_id = build_id; | 1429 | 0 | } | 1430 | 0 | } | 1431 | 7 | break; | 1432 | 7 | } | 1433 | 41 | } | 1434 | | | 1435 | 9 | free (data); | 1436 | 9 | } |
pei-loongarch64.c:pe_bfd_read_buildid Line | Count | Source | 1350 | 315 | { | 1351 | 315 | pe_data_type *pe = pe_data (abfd); | 1352 | 315 | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1353 | 315 | asection *section; | 1354 | 315 | bfd_byte *data = 0; | 1355 | 315 | bfd_size_type dataoff; | 1356 | 315 | unsigned int i; | 1357 | 315 | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1358 | 315 | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1359 | | | 1360 | 315 | if (size == 0) | 1361 | 216 | return; | 1362 | | | 1363 | 99 | addr += extra->ImageBase; | 1364 | | | 1365 | | /* Search for the section containing the DebugDirectory. */ | 1366 | 497 | for (section = abfd->sections; section != NULL; section = section->next) | 1367 | 429 | { | 1368 | 429 | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1369 | 31 | break; | 1370 | 429 | } | 1371 | | | 1372 | 99 | if (section == NULL) | 1373 | 68 | return; | 1374 | | | 1375 | 31 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1376 | 4 | return; | 1377 | | | 1378 | 27 | dataoff = addr - section->vma; | 1379 | | | 1380 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1381 | | Note - since we are dealing with unsigned quantities we have | 1382 | | to be careful to check for potential overflows. */ | 1383 | 27 | if (dataoff >= section->size | 1384 | 27 | || size > section->size - dataoff) | 1385 | 7 | { | 1386 | 7 | _bfd_error_handler | 1387 | 7 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1388 | 7 | abfd); | 1389 | 7 | return; | 1390 | 7 | } | 1391 | | | 1392 | | /* Read the whole section. */ | 1393 | 20 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1394 | 9 | { | 1395 | 9 | free (data); | 1396 | 9 | return; | 1397 | 9 | } | 1398 | | | 1399 | | /* Search for a CodeView entry in the DebugDirectory */ | 1400 | 50 | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1401 | 47 | { | 1402 | 47 | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1403 | 47 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1404 | 47 | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1405 | | | 1406 | 47 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1407 | | | 1408 | 47 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1409 | 8 | { | 1410 | 8 | char buffer[256 + 1]; | 1411 | 8 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1412 | | | 1413 | | /* | 1414 | | The debug entry doesn't have to have to be in a section, in which | 1415 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1416 | | */ | 1417 | 8 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1418 | 8 | (file_ptr) idd.PointerToRawData, | 1419 | 8 | idd.SizeOfData, cvinfo, NULL)) | 1420 | 0 | { | 1421 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1422 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1423 | 0 | if (build_id) | 1424 | 0 | { | 1425 | 0 | build_id->size = cvinfo->SignatureLength; | 1426 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1427 | 0 | cvinfo->SignatureLength); | 1428 | 0 | abfd->build_id = build_id; | 1429 | 0 | } | 1430 | 0 | } | 1431 | 8 | break; | 1432 | 8 | } | 1433 | 47 | } | 1434 | | | 1435 | 11 | free (data); | 1436 | 11 | } |
pei-arm-wince.c:pe_bfd_read_buildid Line | Count | Source | 1350 | 179 | { | 1351 | 179 | pe_data_type *pe = pe_data (abfd); | 1352 | 179 | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1353 | 179 | asection *section; | 1354 | 179 | bfd_byte *data = 0; | 1355 | 179 | bfd_size_type dataoff; | 1356 | 179 | unsigned int i; | 1357 | 179 | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1358 | 179 | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1359 | | | 1360 | 179 | if (size == 0) | 1361 | 50 | return; | 1362 | | | 1363 | 129 | addr += extra->ImageBase; | 1364 | | | 1365 | | /* Search for the section containing the DebugDirectory. */ | 1366 | 296 | for (section = abfd->sections; section != NULL; section = section->next) | 1367 | 250 | { | 1368 | 250 | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1369 | 83 | break; | 1370 | 250 | } | 1371 | | | 1372 | 129 | if (section == NULL) | 1373 | 46 | return; | 1374 | | | 1375 | 83 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1376 | 5 | return; | 1377 | | | 1378 | 78 | dataoff = addr - section->vma; | 1379 | | | 1380 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1381 | | Note - since we are dealing with unsigned quantities we have | 1382 | | to be careful to check for potential overflows. */ | 1383 | 78 | if (dataoff >= section->size | 1384 | 78 | || size > section->size - dataoff) | 1385 | 5 | { | 1386 | 5 | _bfd_error_handler | 1387 | 5 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1388 | 5 | abfd); | 1389 | 5 | return; | 1390 | 5 | } | 1391 | | | 1392 | | /* Read the whole section. */ | 1393 | 73 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1394 | 65 | { | 1395 | 65 | free (data); | 1396 | 65 | return; | 1397 | 65 | } | 1398 | | | 1399 | | /* Search for a CodeView entry in the DebugDirectory */ | 1400 | 20 | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1401 | 14 | { | 1402 | 14 | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1403 | 14 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1404 | 14 | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1405 | | | 1406 | 14 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1407 | | | 1408 | 14 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1409 | 2 | { | 1410 | 2 | char buffer[256 + 1]; | 1411 | 2 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1412 | | | 1413 | | /* | 1414 | | The debug entry doesn't have to have to be in a section, in which | 1415 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1416 | | */ | 1417 | 2 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1418 | 2 | (file_ptr) idd.PointerToRawData, | 1419 | 2 | idd.SizeOfData, cvinfo, NULL)) | 1420 | 1 | { | 1421 | 1 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1422 | 1 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1423 | 1 | if (build_id) | 1424 | 1 | { | 1425 | 1 | build_id->size = cvinfo->SignatureLength; | 1426 | 1 | memcpy(build_id->data, cvinfo->Signature, | 1427 | 1 | cvinfo->SignatureLength); | 1428 | 1 | abfd->build_id = build_id; | 1429 | 1 | } | 1430 | 1 | } | 1431 | 2 | break; | 1432 | 2 | } | 1433 | 14 | } | 1434 | | | 1435 | 8 | free (data); | 1436 | 8 | } |
pei-arm.c:pe_bfd_read_buildid Line | Count | Source | 1350 | 295 | { | 1351 | 295 | pe_data_type *pe = pe_data (abfd); | 1352 | 295 | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1353 | 295 | asection *section; | 1354 | 295 | bfd_byte *data = 0; | 1355 | 295 | bfd_size_type dataoff; | 1356 | 295 | unsigned int i; | 1357 | 295 | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1358 | 295 | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1359 | | | 1360 | 295 | if (size == 0) | 1361 | 132 | return; | 1362 | | | 1363 | 163 | addr += extra->ImageBase; | 1364 | | | 1365 | | /* Search for the section containing the DebugDirectory. */ | 1366 | 464 | for (section = abfd->sections; section != NULL; section = section->next) | 1367 | 381 | { | 1368 | 381 | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1369 | 80 | break; | 1370 | 381 | } | 1371 | | | 1372 | 163 | if (section == NULL) | 1373 | 83 | return; | 1374 | | | 1375 | 80 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1376 | 2 | return; | 1377 | | | 1378 | 78 | dataoff = addr - section->vma; | 1379 | | | 1380 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1381 | | Note - since we are dealing with unsigned quantities we have | 1382 | | to be careful to check for potential overflows. */ | 1383 | 78 | if (dataoff >= section->size | 1384 | 78 | || size > section->size - dataoff) | 1385 | 19 | { | 1386 | 19 | _bfd_error_handler | 1387 | 19 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1388 | 19 | abfd); | 1389 | 19 | return; | 1390 | 19 | } | 1391 | | | 1392 | | /* Read the whole section. */ | 1393 | 59 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1394 | 51 | { | 1395 | 51 | free (data); | 1396 | 51 | return; | 1397 | 51 | } | 1398 | | | 1399 | | /* Search for a CodeView entry in the DebugDirectory */ | 1400 | 30 | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1401 | 26 | { | 1402 | 26 | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1403 | 26 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1404 | 26 | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1405 | | | 1406 | 26 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1407 | | | 1408 | 26 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1409 | 4 | { | 1410 | 4 | char buffer[256 + 1]; | 1411 | 4 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1412 | | | 1413 | | /* | 1414 | | The debug entry doesn't have to have to be in a section, in which | 1415 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1416 | | */ | 1417 | 4 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1418 | 4 | (file_ptr) idd.PointerToRawData, | 1419 | 4 | idd.SizeOfData, cvinfo, NULL)) | 1420 | 1 | { | 1421 | 1 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1422 | 1 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1423 | 1 | if (build_id) | 1424 | 1 | { | 1425 | 1 | build_id->size = cvinfo->SignatureLength; | 1426 | 1 | memcpy(build_id->data, cvinfo->Signature, | 1427 | 1 | cvinfo->SignatureLength); | 1428 | 1 | abfd->build_id = build_id; | 1429 | 1 | } | 1430 | 1 | } | 1431 | 4 | break; | 1432 | 4 | } | 1433 | 26 | } | 1434 | | | 1435 | 8 | free (data); | 1436 | 8 | } |
pei-mcore.c:pe_bfd_read_buildid Line | Count | Source | 1350 | 197 | { | 1351 | 197 | pe_data_type *pe = pe_data (abfd); | 1352 | 197 | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1353 | 197 | asection *section; | 1354 | 197 | bfd_byte *data = 0; | 1355 | 197 | bfd_size_type dataoff; | 1356 | 197 | unsigned int i; | 1357 | 197 | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1358 | 197 | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1359 | | | 1360 | 197 | if (size == 0) | 1361 | 100 | return; | 1362 | | | 1363 | 97 | addr += extra->ImageBase; | 1364 | | | 1365 | | /* Search for the section containing the DebugDirectory. */ | 1366 | 311 | for (section = abfd->sections; section != NULL; section = section->next) | 1367 | 252 | { | 1368 | 252 | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1369 | 38 | break; | 1370 | 252 | } | 1371 | | | 1372 | 97 | if (section == NULL) | 1373 | 59 | return; | 1374 | | | 1375 | 38 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1376 | 1 | return; | 1377 | | | 1378 | 37 | dataoff = addr - section->vma; | 1379 | | | 1380 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1381 | | Note - since we are dealing with unsigned quantities we have | 1382 | | to be careful to check for potential overflows. */ | 1383 | 37 | if (dataoff >= section->size | 1384 | 37 | || size > section->size - dataoff) | 1385 | 19 | { | 1386 | 19 | _bfd_error_handler | 1387 | 19 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1388 | 19 | abfd); | 1389 | 19 | return; | 1390 | 19 | } | 1391 | | | 1392 | | /* Read the whole section. */ | 1393 | 18 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1394 | 11 | { | 1395 | 11 | free (data); | 1396 | 11 | return; | 1397 | 11 | } | 1398 | | | 1399 | | /* Search for a CodeView entry in the DebugDirectory */ | 1400 | 37 | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1401 | 34 | { | 1402 | 34 | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1403 | 34 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1404 | 34 | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1405 | | | 1406 | 34 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1407 | | | 1408 | 34 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1409 | 4 | { | 1410 | 4 | char buffer[256 + 1]; | 1411 | 4 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1412 | | | 1413 | | /* | 1414 | | The debug entry doesn't have to have to be in a section, in which | 1415 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1416 | | */ | 1417 | 4 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1418 | 4 | (file_ptr) idd.PointerToRawData, | 1419 | 4 | idd.SizeOfData, cvinfo, NULL)) | 1420 | 0 | { | 1421 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1422 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1423 | 0 | if (build_id) | 1424 | 0 | { | 1425 | 0 | build_id->size = cvinfo->SignatureLength; | 1426 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1427 | 0 | cvinfo->SignatureLength); | 1428 | 0 | abfd->build_id = build_id; | 1429 | 0 | } | 1430 | 0 | } | 1431 | 4 | break; | 1432 | 4 | } | 1433 | 34 | } | 1434 | | | 1435 | 7 | free (data); | 1436 | 7 | } |
pei-sh.c:pe_bfd_read_buildid Line | Count | Source | 1350 | 185 | { | 1351 | 185 | pe_data_type *pe = pe_data (abfd); | 1352 | 185 | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1353 | 185 | asection *section; | 1354 | 185 | bfd_byte *data = 0; | 1355 | 185 | bfd_size_type dataoff; | 1356 | 185 | unsigned int i; | 1357 | 185 | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1358 | 185 | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1359 | | | 1360 | 185 | if (size == 0) | 1361 | 100 | return; | 1362 | | | 1363 | 85 | addr += extra->ImageBase; | 1364 | | | 1365 | | /* Search for the section containing the DebugDirectory. */ | 1366 | 390 | for (section = abfd->sections; section != NULL; section = section->next) | 1367 | 344 | { | 1368 | 344 | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1369 | 39 | break; | 1370 | 344 | } | 1371 | | | 1372 | 85 | if (section == NULL) | 1373 | 46 | return; | 1374 | | | 1375 | 39 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1376 | 25 | return; | 1377 | | | 1378 | 14 | dataoff = addr - section->vma; | 1379 | | | 1380 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1381 | | Note - since we are dealing with unsigned quantities we have | 1382 | | to be careful to check for potential overflows. */ | 1383 | 14 | if (dataoff >= section->size | 1384 | 14 | || size > section->size - dataoff) | 1385 | 3 | { | 1386 | 3 | _bfd_error_handler | 1387 | 3 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1388 | 3 | abfd); | 1389 | 3 | return; | 1390 | 3 | } | 1391 | | | 1392 | | /* Read the whole section. */ | 1393 | 11 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1394 | 5 | { | 1395 | 5 | free (data); | 1396 | 5 | return; | 1397 | 5 | } | 1398 | | | 1399 | | /* Search for a CodeView entry in the DebugDirectory */ | 1400 | 29 | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1401 | 26 | { | 1402 | 26 | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1403 | 26 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1404 | 26 | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1405 | | | 1406 | 26 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1407 | | | 1408 | 26 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1409 | 3 | { | 1410 | 3 | char buffer[256 + 1]; | 1411 | 3 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1412 | | | 1413 | | /* | 1414 | | The debug entry doesn't have to have to be in a section, in which | 1415 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1416 | | */ | 1417 | 3 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1418 | 3 | (file_ptr) idd.PointerToRawData, | 1419 | 3 | idd.SizeOfData, cvinfo, NULL)) | 1420 | 0 | { | 1421 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1422 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1423 | 0 | if (build_id) | 1424 | 0 | { | 1425 | 0 | build_id->size = cvinfo->SignatureLength; | 1426 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1427 | 0 | cvinfo->SignatureLength); | 1428 | 0 | abfd->build_id = build_id; | 1429 | 0 | } | 1430 | 0 | } | 1431 | 3 | break; | 1432 | 3 | } | 1433 | 26 | } | 1434 | | | 1435 | 6 | free (data); | 1436 | 6 | } |
|
1437 | | |
1438 | | static bfd_cleanup |
1439 | | pe_bfd_object_p (bfd * abfd) |
1440 | 248k | { |
1441 | 248k | bfd_byte buffer[6]; |
1442 | 248k | struct external_DOS_hdr dos_hdr; |
1443 | 248k | struct external_PEI_IMAGE_hdr image_hdr; |
1444 | 248k | struct internal_filehdr internal_f; |
1445 | 248k | struct internal_aouthdr internal_a; |
1446 | 248k | bfd_size_type opt_hdr_size; |
1447 | 248k | file_ptr offset; |
1448 | 248k | bfd_cleanup result; |
1449 | | |
1450 | | /* Detect if this a Microsoft Import Library Format element. */ |
1451 | | /* First read the beginning of the header. */ |
1452 | 248k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 |
1453 | 248k | || bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) |
1454 | 1.72k | { |
1455 | 1.72k | if (bfd_get_error () != bfd_error_system_call) |
1456 | 1.69k | bfd_set_error (bfd_error_wrong_format); |
1457 | 1.72k | return NULL; |
1458 | 1.72k | } |
1459 | | |
1460 | | /* Then check the magic and the version (only 0 is supported). */ |
1461 | 246k | if (H_GET_32 (abfd, buffer) == 0xffff0000 |
1462 | 246k | && H_GET_16 (abfd, buffer + 4) == 0) |
1463 | 2.21k | return pe_ILF_object_p (abfd); |
1464 | | |
1465 | 244k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 |
1466 | 244k | || bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd) |
1467 | 244k | != sizeof (dos_hdr)) |
1468 | 85.4k | { |
1469 | 85.4k | if (bfd_get_error () != bfd_error_system_call) |
1470 | 85.4k | bfd_set_error (bfd_error_wrong_format); |
1471 | 85.4k | return NULL; |
1472 | 85.4k | } |
1473 | | |
1474 | | /* There are really two magic numbers involved; the magic number |
1475 | | that says this is a NT executable (PEI) and the magic number that |
1476 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in |
1477 | | the e_magic field. The latter is stored in the f_magic field. |
1478 | | If the NT magic number isn't valid, the architecture magic number |
1479 | | could be mimicked by some other field (specifically, the number |
1480 | | of relocs in section 3). Since this routine can only be called |
1481 | | correctly for a PEI file, check the e_magic number here, and, if |
1482 | | it doesn't match, clobber the f_magic number so that we don't get |
1483 | | a false match. */ |
1484 | 159k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) |
1485 | 131k | { |
1486 | 131k | bfd_set_error (bfd_error_wrong_format); |
1487 | 131k | return NULL; |
1488 | 131k | } |
1489 | | |
1490 | 28.1k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); |
1491 | 28.1k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 |
1492 | 28.1k | || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd) |
1493 | 28.1k | != sizeof (image_hdr))) |
1494 | 176 | { |
1495 | 176 | if (bfd_get_error () != bfd_error_system_call) |
1496 | 176 | bfd_set_error (bfd_error_wrong_format); |
1497 | 176 | return NULL; |
1498 | 176 | } |
1499 | | |
1500 | 27.9k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) |
1501 | 640 | { |
1502 | 640 | bfd_set_error (bfd_error_wrong_format); |
1503 | 640 | return NULL; |
1504 | 640 | } |
1505 | | |
1506 | | /* Swap file header, so that we get the location for calling |
1507 | | real_object_p. */ |
1508 | 27.2k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); |
1509 | | |
1510 | 27.2k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) |
1511 | 27.2k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) |
1512 | 23.2k | { |
1513 | 23.2k | bfd_set_error (bfd_error_wrong_format); |
1514 | 23.2k | return NULL; |
1515 | 23.2k | } |
1516 | | |
1517 | 4.06k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, |
1518 | 4.06k | sizeof (internal_f.pe.dos_message)); |
1519 | | |
1520 | | /* Read the optional header, which has variable size. */ |
1521 | 4.06k | opt_hdr_size = internal_f.f_opthdr; |
1522 | | |
1523 | 4.06k | if (opt_hdr_size != 0) |
1524 | 3.22k | { |
1525 | 3.22k | bfd_size_type amt = opt_hdr_size; |
1526 | 3.22k | bfd_byte * opthdr; |
1527 | | |
1528 | | /* PR 17521 file: 230-131433-0.004. */ |
1529 | 3.22k | if (amt < sizeof (PEAOUTHDR)) |
1530 | 2.37k | amt = sizeof (PEAOUTHDR); |
1531 | | |
1532 | 3.22k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); |
1533 | 3.22k | if (opthdr == NULL) |
1534 | 40 | return NULL; |
1535 | 3.18k | if (amt > opt_hdr_size) |
1536 | 2.34k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); |
1537 | | |
1538 | 3.18k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); |
1539 | | |
1540 | 3.18k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; |
1541 | | |
1542 | | #ifdef ARM |
1543 | | /* Use Subsystem to distinguish between pei-arm-little and |
1544 | | pei-arm-wince-little. */ |
1545 | | #ifdef WINCE |
1546 | 523 | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) |
1547 | | #else |
1548 | 523 | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) |
1549 | 171 | #endif |
1550 | 523 | { |
1551 | 523 | bfd_set_error (bfd_error_wrong_format); |
1552 | 523 | return NULL; |
1553 | 523 | } |
1554 | 523 | #endif |
1555 | | |
1556 | 2.65k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment |
1557 | 2.65k | || a->SectionAlignment >= 0x80000000) |
1558 | 1.66k | { |
1559 | 1.66k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), |
1560 | 1.66k | abfd); |
1561 | 1.66k | a->SectionAlignment &= -a->SectionAlignment; |
1562 | 1.66k | if (a->SectionAlignment >= 0x80000000) |
1563 | 44 | a->SectionAlignment = 0x40000000; |
1564 | 1.66k | } |
1565 | | |
1566 | 2.65k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment |
1567 | 2.65k | || a->FileAlignment > a->SectionAlignment) |
1568 | 1.63k | { |
1569 | 1.63k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), |
1570 | 1.63k | abfd); |
1571 | 1.63k | a->FileAlignment &= -a->FileAlignment; |
1572 | 1.63k | if (a->FileAlignment > a->SectionAlignment) |
1573 | 891 | a->FileAlignment = a->SectionAlignment; |
1574 | 1.63k | } |
1575 | | |
1576 | 2.65k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) |
1577 | 1.50k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); |
1578 | 523 | } |
1579 | | |
1580 | 3.49k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, |
1581 | 3.49k | (opt_hdr_size != 0 |
1582 | 3.49k | ? &internal_a |
1583 | 3.49k | : (struct internal_aouthdr *) NULL)); |
1584 | | |
1585 | 3.49k | if (result) |
1586 | 2.55k | { |
1587 | | /* Now the whole header has been processed, see if there is a build-id */ |
1588 | 2.55k | pe_bfd_read_buildid(abfd); |
1589 | 2.55k | } |
1590 | | |
1591 | 3.49k | return result; |
1592 | 4.06k | } pei-i386.c:pe_bfd_object_p Line | Count | Source | 1440 | 22.5k | { | 1441 | 22.5k | bfd_byte buffer[6]; | 1442 | 22.5k | struct external_DOS_hdr dos_hdr; | 1443 | 22.5k | struct external_PEI_IMAGE_hdr image_hdr; | 1444 | 22.5k | struct internal_filehdr internal_f; | 1445 | 22.5k | struct internal_aouthdr internal_a; | 1446 | 22.5k | bfd_size_type opt_hdr_size; | 1447 | 22.5k | file_ptr offset; | 1448 | 22.5k | bfd_cleanup result; | 1449 | | | 1450 | | /* Detect if this a Microsoft Import Library Format element. */ | 1451 | | /* First read the beginning of the header. */ | 1452 | 22.5k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1453 | 22.5k | || bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) | 1454 | 157 | { | 1455 | 157 | if (bfd_get_error () != bfd_error_system_call) | 1456 | 154 | bfd_set_error (bfd_error_wrong_format); | 1457 | 157 | return NULL; | 1458 | 157 | } | 1459 | | | 1460 | | /* Then check the magic and the version (only 0 is supported). */ | 1461 | 22.3k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1462 | 22.3k | && H_GET_16 (abfd, buffer + 4) == 0) | 1463 | 277 | return pe_ILF_object_p (abfd); | 1464 | | | 1465 | 22.1k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1466 | 22.1k | || bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd) | 1467 | 22.1k | != sizeof (dos_hdr)) | 1468 | 7.71k | { | 1469 | 7.71k | if (bfd_get_error () != bfd_error_system_call) | 1470 | 7.71k | bfd_set_error (bfd_error_wrong_format); | 1471 | 7.71k | return NULL; | 1472 | 7.71k | } | 1473 | | | 1474 | | /* There are really two magic numbers involved; the magic number | 1475 | | that says this is a NT executable (PEI) and the magic number that | 1476 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1477 | | the e_magic field. The latter is stored in the f_magic field. | 1478 | | If the NT magic number isn't valid, the architecture magic number | 1479 | | could be mimicked by some other field (specifically, the number | 1480 | | of relocs in section 3). Since this routine can only be called | 1481 | | correctly for a PEI file, check the e_magic number here, and, if | 1482 | | it doesn't match, clobber the f_magic number so that we don't get | 1483 | | a false match. */ | 1484 | 14.3k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1485 | 11.1k | { | 1486 | 11.1k | bfd_set_error (bfd_error_wrong_format); | 1487 | 11.1k | return NULL; | 1488 | 11.1k | } | 1489 | | | 1490 | 3.26k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1491 | 3.26k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1492 | 3.26k | || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd) | 1493 | 3.26k | != sizeof (image_hdr))) | 1494 | 19 | { | 1495 | 19 | if (bfd_get_error () != bfd_error_system_call) | 1496 | 19 | bfd_set_error (bfd_error_wrong_format); | 1497 | 19 | return NULL; | 1498 | 19 | } | 1499 | | | 1500 | 3.24k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1501 | 53 | { | 1502 | 53 | bfd_set_error (bfd_error_wrong_format); | 1503 | 53 | return NULL; | 1504 | 53 | } | 1505 | | | 1506 | | /* Swap file header, so that we get the location for calling | 1507 | | real_object_p. */ | 1508 | 3.19k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1509 | | | 1510 | 3.19k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1511 | 3.19k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1512 | 2.63k | { | 1513 | 2.63k | bfd_set_error (bfd_error_wrong_format); | 1514 | 2.63k | return NULL; | 1515 | 2.63k | } | 1516 | | | 1517 | 563 | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1518 | 563 | sizeof (internal_f.pe.dos_message)); | 1519 | | | 1520 | | /* Read the optional header, which has variable size. */ | 1521 | 563 | opt_hdr_size = internal_f.f_opthdr; | 1522 | | | 1523 | 563 | if (opt_hdr_size != 0) | 1524 | 525 | { | 1525 | 525 | bfd_size_type amt = opt_hdr_size; | 1526 | 525 | bfd_byte * opthdr; | 1527 | | | 1528 | | /* PR 17521 file: 230-131433-0.004. */ | 1529 | 525 | if (amt < sizeof (PEAOUTHDR)) | 1530 | 313 | amt = sizeof (PEAOUTHDR); | 1531 | | | 1532 | 525 | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1533 | 525 | if (opthdr == NULL) | 1534 | 4 | return NULL; | 1535 | 521 | if (amt > opt_hdr_size) | 1536 | 310 | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1537 | | | 1538 | 521 | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1539 | | | 1540 | 521 | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1541 | | | 1542 | | #ifdef ARM | 1543 | | /* Use Subsystem to distinguish between pei-arm-little and | 1544 | | pei-arm-wince-little. */ | 1545 | | #ifdef WINCE | 1546 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1547 | | #else | 1548 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1549 | | #endif | 1550 | | { | 1551 | | bfd_set_error (bfd_error_wrong_format); | 1552 | | return NULL; | 1553 | | } | 1554 | | #endif | 1555 | | | 1556 | 521 | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1557 | 521 | || a->SectionAlignment >= 0x80000000) | 1558 | 277 | { | 1559 | 277 | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1560 | 277 | abfd); | 1561 | 277 | a->SectionAlignment &= -a->SectionAlignment; | 1562 | 277 | if (a->SectionAlignment >= 0x80000000) | 1563 | 1 | a->SectionAlignment = 0x40000000; | 1564 | 277 | } | 1565 | | | 1566 | 521 | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1567 | 521 | || a->FileAlignment > a->SectionAlignment) | 1568 | 291 | { | 1569 | 291 | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1570 | 291 | abfd); | 1571 | 291 | a->FileAlignment &= -a->FileAlignment; | 1572 | 291 | if (a->FileAlignment > a->SectionAlignment) | 1573 | 146 | a->FileAlignment = a->SectionAlignment; | 1574 | 291 | } | 1575 | | | 1576 | 521 | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1577 | 263 | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1578 | 521 | } | 1579 | | | 1580 | 559 | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1581 | 559 | (opt_hdr_size != 0 | 1582 | 559 | ? &internal_a | 1583 | 559 | : (struct internal_aouthdr *) NULL)); | 1584 | | | 1585 | 559 | if (result) | 1586 | 475 | { | 1587 | | /* Now the whole header has been processed, see if there is a build-id */ | 1588 | 475 | pe_bfd_read_buildid(abfd); | 1589 | 475 | } | 1590 | | | 1591 | 559 | return result; | 1592 | 563 | } |
pei-x86_64.c:pe_bfd_object_p Line | Count | Source | 1440 | 22.4k | { | 1441 | 22.4k | bfd_byte buffer[6]; | 1442 | 22.4k | struct external_DOS_hdr dos_hdr; | 1443 | 22.4k | struct external_PEI_IMAGE_hdr image_hdr; | 1444 | 22.4k | struct internal_filehdr internal_f; | 1445 | 22.4k | struct internal_aouthdr internal_a; | 1446 | 22.4k | bfd_size_type opt_hdr_size; | 1447 | 22.4k | file_ptr offset; | 1448 | 22.4k | bfd_cleanup result; | 1449 | | | 1450 | | /* Detect if this a Microsoft Import Library Format element. */ | 1451 | | /* First read the beginning of the header. */ | 1452 | 22.4k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1453 | 22.4k | || bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) | 1454 | 157 | { | 1455 | 157 | if (bfd_get_error () != bfd_error_system_call) | 1456 | 154 | bfd_set_error (bfd_error_wrong_format); | 1457 | 157 | return NULL; | 1458 | 157 | } | 1459 | | | 1460 | | /* Then check the magic and the version (only 0 is supported). */ | 1461 | 22.3k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1462 | 22.3k | && H_GET_16 (abfd, buffer + 4) == 0) | 1463 | 238 | return pe_ILF_object_p (abfd); | 1464 | | | 1465 | 22.0k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1466 | 22.0k | || bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd) | 1467 | 22.0k | != sizeof (dos_hdr)) | 1468 | 7.71k | { | 1469 | 7.71k | if (bfd_get_error () != bfd_error_system_call) | 1470 | 7.71k | bfd_set_error (bfd_error_wrong_format); | 1471 | 7.71k | return NULL; | 1472 | 7.71k | } | 1473 | | | 1474 | | /* There are really two magic numbers involved; the magic number | 1475 | | that says this is a NT executable (PEI) and the magic number that | 1476 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1477 | | the e_magic field. The latter is stored in the f_magic field. | 1478 | | If the NT magic number isn't valid, the architecture magic number | 1479 | | could be mimicked by some other field (specifically, the number | 1480 | | of relocs in section 3). Since this routine can only be called | 1481 | | correctly for a PEI file, check the e_magic number here, and, if | 1482 | | it doesn't match, clobber the f_magic number so that we don't get | 1483 | | a false match. */ | 1484 | 14.3k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1485 | 11.1k | { | 1486 | 11.1k | bfd_set_error (bfd_error_wrong_format); | 1487 | 11.1k | return NULL; | 1488 | 11.1k | } | 1489 | | | 1490 | 3.19k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1491 | 3.19k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1492 | 3.19k | || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd) | 1493 | 3.19k | != sizeof (image_hdr))) | 1494 | 19 | { | 1495 | 19 | if (bfd_get_error () != bfd_error_system_call) | 1496 | 19 | bfd_set_error (bfd_error_wrong_format); | 1497 | 19 | return NULL; | 1498 | 19 | } | 1499 | | | 1500 | 3.18k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1501 | 53 | { | 1502 | 53 | bfd_set_error (bfd_error_wrong_format); | 1503 | 53 | return NULL; | 1504 | 53 | } | 1505 | | | 1506 | | /* Swap file header, so that we get the location for calling | 1507 | | real_object_p. */ | 1508 | 3.12k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1509 | | | 1510 | 3.12k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1511 | 3.12k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1512 | 2.64k | { | 1513 | 2.64k | bfd_set_error (bfd_error_wrong_format); | 1514 | 2.64k | return NULL; | 1515 | 2.64k | } | 1516 | | | 1517 | 481 | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1518 | 481 | sizeof (internal_f.pe.dos_message)); | 1519 | | | 1520 | | /* Read the optional header, which has variable size. */ | 1521 | 481 | opt_hdr_size = internal_f.f_opthdr; | 1522 | | | 1523 | 481 | if (opt_hdr_size != 0) | 1524 | 371 | { | 1525 | 371 | bfd_size_type amt = opt_hdr_size; | 1526 | 371 | bfd_byte * opthdr; | 1527 | | | 1528 | | /* PR 17521 file: 230-131433-0.004. */ | 1529 | 371 | if (amt < sizeof (PEAOUTHDR)) | 1530 | 256 | amt = sizeof (PEAOUTHDR); | 1531 | | | 1532 | 371 | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1533 | 371 | if (opthdr == NULL) | 1534 | 5 | return NULL; | 1535 | 366 | if (amt > opt_hdr_size) | 1536 | 252 | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1537 | | | 1538 | 366 | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1539 | | | 1540 | 366 | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1541 | | | 1542 | | #ifdef ARM | 1543 | | /* Use Subsystem to distinguish between pei-arm-little and | 1544 | | pei-arm-wince-little. */ | 1545 | | #ifdef WINCE | 1546 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1547 | | #else | 1548 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1549 | | #endif | 1550 | | { | 1551 | | bfd_set_error (bfd_error_wrong_format); | 1552 | | return NULL; | 1553 | | } | 1554 | | #endif | 1555 | | | 1556 | 366 | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1557 | 366 | || a->SectionAlignment >= 0x80000000) | 1558 | 299 | { | 1559 | 299 | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1560 | 299 | abfd); | 1561 | 299 | a->SectionAlignment &= -a->SectionAlignment; | 1562 | 299 | if (a->SectionAlignment >= 0x80000000) | 1563 | 31 | a->SectionAlignment = 0x40000000; | 1564 | 299 | } | 1565 | | | 1566 | 366 | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1567 | 366 | || a->FileAlignment > a->SectionAlignment) | 1568 | 287 | { | 1569 | 287 | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1570 | 287 | abfd); | 1571 | 287 | a->FileAlignment &= -a->FileAlignment; | 1572 | 287 | if (a->FileAlignment > a->SectionAlignment) | 1573 | 136 | a->FileAlignment = a->SectionAlignment; | 1574 | 287 | } | 1575 | | | 1576 | 366 | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1577 | 234 | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1578 | 366 | } | 1579 | | | 1580 | 476 | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1581 | 476 | (opt_hdr_size != 0 | 1582 | 476 | ? &internal_a | 1583 | 476 | : (struct internal_aouthdr *) NULL)); | 1584 | | | 1585 | 476 | if (result) | 1586 | 393 | { | 1587 | | /* Now the whole header has been processed, see if there is a build-id */ | 1588 | 393 | pe_bfd_read_buildid(abfd); | 1589 | 393 | } | 1590 | | | 1591 | 476 | return result; | 1592 | 481 | } |
pei-aarch64.c:pe_bfd_object_p Line | Count | Source | 1440 | 22.3k | { | 1441 | 22.3k | bfd_byte buffer[6]; | 1442 | 22.3k | struct external_DOS_hdr dos_hdr; | 1443 | 22.3k | struct external_PEI_IMAGE_hdr image_hdr; | 1444 | 22.3k | struct internal_filehdr internal_f; | 1445 | 22.3k | struct internal_aouthdr internal_a; | 1446 | 22.3k | bfd_size_type opt_hdr_size; | 1447 | 22.3k | file_ptr offset; | 1448 | 22.3k | bfd_cleanup result; | 1449 | | | 1450 | | /* Detect if this a Microsoft Import Library Format element. */ | 1451 | | /* First read the beginning of the header. */ | 1452 | 22.3k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1453 | 22.3k | || bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) | 1454 | 157 | { | 1455 | 157 | if (bfd_get_error () != bfd_error_system_call) | 1456 | 154 | bfd_set_error (bfd_error_wrong_format); | 1457 | 157 | return NULL; | 1458 | 157 | } | 1459 | | | 1460 | | /* Then check the magic and the version (only 0 is supported). */ | 1461 | 22.1k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1462 | 22.1k | && H_GET_16 (abfd, buffer + 4) == 0) | 1463 | 281 | return pe_ILF_object_p (abfd); | 1464 | | | 1465 | 21.8k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1466 | 21.8k | || bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd) | 1467 | 21.8k | != sizeof (dos_hdr)) | 1468 | 7.71k | { | 1469 | 7.71k | if (bfd_get_error () != bfd_error_system_call) | 1470 | 7.71k | bfd_set_error (bfd_error_wrong_format); | 1471 | 7.71k | return NULL; | 1472 | 7.71k | } | 1473 | | | 1474 | | /* There are really two magic numbers involved; the magic number | 1475 | | that says this is a NT executable (PEI) and the magic number that | 1476 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1477 | | the e_magic field. The latter is stored in the f_magic field. | 1478 | | If the NT magic number isn't valid, the architecture magic number | 1479 | | could be mimicked by some other field (specifically, the number | 1480 | | of relocs in section 3). Since this routine can only be called | 1481 | | correctly for a PEI file, check the e_magic number here, and, if | 1482 | | it doesn't match, clobber the f_magic number so that we don't get | 1483 | | a false match. */ | 1484 | 14.1k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1485 | 11.0k | { | 1486 | 11.0k | bfd_set_error (bfd_error_wrong_format); | 1487 | 11.0k | return NULL; | 1488 | 11.0k | } | 1489 | | | 1490 | 3.14k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1491 | 3.14k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1492 | 3.14k | || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd) | 1493 | 3.14k | != sizeof (image_hdr))) | 1494 | 27 | { | 1495 | 27 | if (bfd_get_error () != bfd_error_system_call) | 1496 | 27 | bfd_set_error (bfd_error_wrong_format); | 1497 | 27 | return NULL; | 1498 | 27 | } | 1499 | | | 1500 | 3.11k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1501 | 124 | { | 1502 | 124 | bfd_set_error (bfd_error_wrong_format); | 1503 | 124 | return NULL; | 1504 | 124 | } | 1505 | | | 1506 | | /* Swap file header, so that we get the location for calling | 1507 | | real_object_p. */ | 1508 | 2.99k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1509 | | | 1510 | 2.99k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1511 | 2.99k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1512 | 2.67k | { | 1513 | 2.67k | bfd_set_error (bfd_error_wrong_format); | 1514 | 2.67k | return NULL; | 1515 | 2.67k | } | 1516 | | | 1517 | 318 | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1518 | 318 | sizeof (internal_f.pe.dos_message)); | 1519 | | | 1520 | | /* Read the optional header, which has variable size. */ | 1521 | 318 | opt_hdr_size = internal_f.f_opthdr; | 1522 | | | 1523 | 318 | if (opt_hdr_size != 0) | 1524 | 240 | { | 1525 | 240 | bfd_size_type amt = opt_hdr_size; | 1526 | 240 | bfd_byte * opthdr; | 1527 | | | 1528 | | /* PR 17521 file: 230-131433-0.004. */ | 1529 | 240 | if (amt < sizeof (PEAOUTHDR)) | 1530 | 68 | amt = sizeof (PEAOUTHDR); | 1531 | | | 1532 | 240 | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1533 | 240 | if (opthdr == NULL) | 1534 | 4 | return NULL; | 1535 | 236 | if (amt > opt_hdr_size) | 1536 | 65 | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1537 | | | 1538 | 236 | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1539 | | | 1540 | 236 | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1541 | | | 1542 | | #ifdef ARM | 1543 | | /* Use Subsystem to distinguish between pei-arm-little and | 1544 | | pei-arm-wince-little. */ | 1545 | | #ifdef WINCE | 1546 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1547 | | #else | 1548 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1549 | | #endif | 1550 | | { | 1551 | | bfd_set_error (bfd_error_wrong_format); | 1552 | | return NULL; | 1553 | | } | 1554 | | #endif | 1555 | | | 1556 | 236 | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1557 | 236 | || a->SectionAlignment >= 0x80000000) | 1558 | 185 | { | 1559 | 185 | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1560 | 185 | abfd); | 1561 | 185 | a->SectionAlignment &= -a->SectionAlignment; | 1562 | 185 | if (a->SectionAlignment >= 0x80000000) | 1563 | 1 | a->SectionAlignment = 0x40000000; | 1564 | 185 | } | 1565 | | | 1566 | 236 | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1567 | 236 | || a->FileAlignment > a->SectionAlignment) | 1568 | 200 | { | 1569 | 200 | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1570 | 200 | abfd); | 1571 | 200 | a->FileAlignment &= -a->FileAlignment; | 1572 | 200 | if (a->FileAlignment > a->SectionAlignment) | 1573 | 148 | a->FileAlignment = a->SectionAlignment; | 1574 | 200 | } | 1575 | | | 1576 | 236 | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1577 | 139 | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1578 | 236 | } | 1579 | | | 1580 | 314 | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1581 | 314 | (opt_hdr_size != 0 | 1582 | 314 | ? &internal_a | 1583 | 314 | : (struct internal_aouthdr *) NULL)); | 1584 | | | 1585 | 314 | if (result) | 1586 | 217 | { | 1587 | | /* Now the whole header has been processed, see if there is a build-id */ | 1588 | 217 | pe_bfd_read_buildid(abfd); | 1589 | 217 | } | 1590 | | | 1591 | 314 | return result; | 1592 | 318 | } |
pei-ia64.c:pe_bfd_object_p Line | Count | Source | 1440 | 2.57k | { | 1441 | 2.57k | bfd_byte buffer[6]; | 1442 | 2.57k | struct external_DOS_hdr dos_hdr; | 1443 | 2.57k | struct external_PEI_IMAGE_hdr image_hdr; | 1444 | 2.57k | struct internal_filehdr internal_f; | 1445 | 2.57k | struct internal_aouthdr internal_a; | 1446 | 2.57k | bfd_size_type opt_hdr_size; | 1447 | 2.57k | file_ptr offset; | 1448 | 2.57k | bfd_cleanup result; | 1449 | | | 1450 | | /* Detect if this a Microsoft Import Library Format element. */ | 1451 | | /* First read the beginning of the header. */ | 1452 | 2.57k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1453 | 2.57k | || bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) | 1454 | 0 | { | 1455 | 0 | if (bfd_get_error () != bfd_error_system_call) | 1456 | 0 | bfd_set_error (bfd_error_wrong_format); | 1457 | 0 | return NULL; | 1458 | 0 | } | 1459 | | | 1460 | | /* Then check the magic and the version (only 0 is supported). */ | 1461 | 2.57k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1462 | 2.57k | && H_GET_16 (abfd, buffer + 4) == 0) | 1463 | 0 | return pe_ILF_object_p (abfd); | 1464 | | | 1465 | 2.57k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1466 | 2.57k | || bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd) | 1467 | 2.57k | != sizeof (dos_hdr)) | 1468 | 0 | { | 1469 | 0 | if (bfd_get_error () != bfd_error_system_call) | 1470 | 0 | bfd_set_error (bfd_error_wrong_format); | 1471 | 0 | return NULL; | 1472 | 0 | } | 1473 | | | 1474 | | /* There are really two magic numbers involved; the magic number | 1475 | | that says this is a NT executable (PEI) and the magic number that | 1476 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1477 | | the e_magic field. The latter is stored in the f_magic field. | 1478 | | If the NT magic number isn't valid, the architecture magic number | 1479 | | could be mimicked by some other field (specifically, the number | 1480 | | of relocs in section 3). Since this routine can only be called | 1481 | | correctly for a PEI file, check the e_magic number here, and, if | 1482 | | it doesn't match, clobber the f_magic number so that we don't get | 1483 | | a false match. */ | 1484 | 2.57k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1485 | 0 | { | 1486 | 0 | bfd_set_error (bfd_error_wrong_format); | 1487 | 0 | return NULL; | 1488 | 0 | } | 1489 | | | 1490 | 2.57k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1491 | 2.57k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1492 | 2.57k | || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd) | 1493 | 2.57k | != sizeof (image_hdr))) | 1494 | 0 | { | 1495 | 0 | if (bfd_get_error () != bfd_error_system_call) | 1496 | 0 | bfd_set_error (bfd_error_wrong_format); | 1497 | 0 | return NULL; | 1498 | 0 | } | 1499 | | | 1500 | 2.57k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1501 | 0 | { | 1502 | 0 | bfd_set_error (bfd_error_wrong_format); | 1503 | 0 | return NULL; | 1504 | 0 | } | 1505 | | | 1506 | | /* Swap file header, so that we get the location for calling | 1507 | | real_object_p. */ | 1508 | 2.57k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1509 | | | 1510 | 2.57k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1511 | 2.57k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1512 | 2.18k | { | 1513 | 2.18k | bfd_set_error (bfd_error_wrong_format); | 1514 | 2.18k | return NULL; | 1515 | 2.18k | } | 1516 | | | 1517 | 385 | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1518 | 385 | sizeof (internal_f.pe.dos_message)); | 1519 | | | 1520 | | /* Read the optional header, which has variable size. */ | 1521 | 385 | opt_hdr_size = internal_f.f_opthdr; | 1522 | | | 1523 | 385 | if (opt_hdr_size != 0) | 1524 | 273 | { | 1525 | 273 | bfd_size_type amt = opt_hdr_size; | 1526 | 273 | bfd_byte * opthdr; | 1527 | | | 1528 | | /* PR 17521 file: 230-131433-0.004. */ | 1529 | 273 | if (amt < sizeof (PEAOUTHDR)) | 1530 | 198 | amt = sizeof (PEAOUTHDR); | 1531 | | | 1532 | 273 | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1533 | 273 | if (opthdr == NULL) | 1534 | 3 | return NULL; | 1535 | 270 | if (amt > opt_hdr_size) | 1536 | 196 | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1537 | | | 1538 | 270 | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1539 | | | 1540 | 270 | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1541 | | | 1542 | | #ifdef ARM | 1543 | | /* Use Subsystem to distinguish between pei-arm-little and | 1544 | | pei-arm-wince-little. */ | 1545 | | #ifdef WINCE | 1546 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1547 | | #else | 1548 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1549 | | #endif | 1550 | | { | 1551 | | bfd_set_error (bfd_error_wrong_format); | 1552 | | return NULL; | 1553 | | } | 1554 | | #endif | 1555 | | | 1556 | 270 | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1557 | 270 | || a->SectionAlignment >= 0x80000000) | 1558 | 146 | { | 1559 | 146 | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1560 | 146 | abfd); | 1561 | 146 | a->SectionAlignment &= -a->SectionAlignment; | 1562 | 146 | if (a->SectionAlignment >= 0x80000000) | 1563 | 1 | a->SectionAlignment = 0x40000000; | 1564 | 146 | } | 1565 | | | 1566 | 270 | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1567 | 270 | || a->FileAlignment > a->SectionAlignment) | 1568 | 140 | { | 1569 | 140 | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1570 | 140 | abfd); | 1571 | 140 | a->FileAlignment &= -a->FileAlignment; | 1572 | 140 | if (a->FileAlignment > a->SectionAlignment) | 1573 | 54 | a->FileAlignment = a->SectionAlignment; | 1574 | 140 | } | 1575 | | | 1576 | 270 | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1577 | 113 | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1578 | 270 | } | 1579 | | | 1580 | 382 | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1581 | 382 | (opt_hdr_size != 0 | 1582 | 382 | ? &internal_a | 1583 | 382 | : (struct internal_aouthdr *) NULL)); | 1584 | | | 1585 | 382 | if (result) | 1586 | 295 | { | 1587 | | /* Now the whole header has been processed, see if there is a build-id */ | 1588 | 295 | pe_bfd_read_buildid(abfd); | 1589 | 295 | } | 1590 | | | 1591 | 382 | return result; | 1592 | 385 | } |
pei-loongarch64.c:pe_bfd_object_p Line | Count | Source | 1440 | 22.3k | { | 1441 | 22.3k | bfd_byte buffer[6]; | 1442 | 22.3k | struct external_DOS_hdr dos_hdr; | 1443 | 22.3k | struct external_PEI_IMAGE_hdr image_hdr; | 1444 | 22.3k | struct internal_filehdr internal_f; | 1445 | 22.3k | struct internal_aouthdr internal_a; | 1446 | 22.3k | bfd_size_type opt_hdr_size; | 1447 | 22.3k | file_ptr offset; | 1448 | 22.3k | bfd_cleanup result; | 1449 | | | 1450 | | /* Detect if this a Microsoft Import Library Format element. */ | 1451 | | /* First read the beginning of the header. */ | 1452 | 22.3k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1453 | 22.3k | || bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) | 1454 | 157 | { | 1455 | 157 | if (bfd_get_error () != bfd_error_system_call) | 1456 | 154 | bfd_set_error (bfd_error_wrong_format); | 1457 | 157 | return NULL; | 1458 | 157 | } | 1459 | | | 1460 | | /* Then check the magic and the version (only 0 is supported). */ | 1461 | 22.1k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1462 | 22.1k | && H_GET_16 (abfd, buffer + 4) == 0) | 1463 | 238 | return pe_ILF_object_p (abfd); | 1464 | | | 1465 | 21.9k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1466 | 21.9k | || bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd) | 1467 | 21.9k | != sizeof (dos_hdr)) | 1468 | 7.71k | { | 1469 | 7.71k | if (bfd_get_error () != bfd_error_system_call) | 1470 | 7.71k | bfd_set_error (bfd_error_wrong_format); | 1471 | 7.71k | return NULL; | 1472 | 7.71k | } | 1473 | | | 1474 | | /* There are really two magic numbers involved; the magic number | 1475 | | that says this is a NT executable (PEI) and the magic number that | 1476 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1477 | | the e_magic field. The latter is stored in the f_magic field. | 1478 | | If the NT magic number isn't valid, the architecture magic number | 1479 | | could be mimicked by some other field (specifically, the number | 1480 | | of relocs in section 3). Since this routine can only be called | 1481 | | correctly for a PEI file, check the e_magic number here, and, if | 1482 | | it doesn't match, clobber the f_magic number so that we don't get | 1483 | | a false match. */ | 1484 | 14.2k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1485 | 11.1k | { | 1486 | 11.1k | bfd_set_error (bfd_error_wrong_format); | 1487 | 11.1k | return NULL; | 1488 | 11.1k | } | 1489 | | | 1490 | 3.06k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1491 | 3.06k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1492 | 3.06k | || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd) | 1493 | 3.06k | != sizeof (image_hdr))) | 1494 | 19 | { | 1495 | 19 | if (bfd_get_error () != bfd_error_system_call) | 1496 | 19 | bfd_set_error (bfd_error_wrong_format); | 1497 | 19 | return NULL; | 1498 | 19 | } | 1499 | | | 1500 | 3.04k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1501 | 53 | { | 1502 | 53 | bfd_set_error (bfd_error_wrong_format); | 1503 | 53 | return NULL; | 1504 | 53 | } | 1505 | | | 1506 | | /* Swap file header, so that we get the location for calling | 1507 | | real_object_p. */ | 1508 | 2.99k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1509 | | | 1510 | 2.99k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1511 | 2.99k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1512 | 2.53k | { | 1513 | 2.53k | bfd_set_error (bfd_error_wrong_format); | 1514 | 2.53k | return NULL; | 1515 | 2.53k | } | 1516 | | | 1517 | 454 | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1518 | 454 | sizeof (internal_f.pe.dos_message)); | 1519 | | | 1520 | | /* Read the optional header, which has variable size. */ | 1521 | 454 | opt_hdr_size = internal_f.f_opthdr; | 1522 | | | 1523 | 454 | if (opt_hdr_size != 0) | 1524 | 358 | { | 1525 | 358 | bfd_size_type amt = opt_hdr_size; | 1526 | 358 | bfd_byte * opthdr; | 1527 | | | 1528 | | /* PR 17521 file: 230-131433-0.004. */ | 1529 | 358 | if (amt < sizeof (PEAOUTHDR)) | 1530 | 189 | amt = sizeof (PEAOUTHDR); | 1531 | | | 1532 | 358 | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1533 | 358 | if (opthdr == NULL) | 1534 | 6 | return NULL; | 1535 | 352 | if (amt > opt_hdr_size) | 1536 | 186 | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1537 | | | 1538 | 352 | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1539 | | | 1540 | 352 | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1541 | | | 1542 | | #ifdef ARM | 1543 | | /* Use Subsystem to distinguish between pei-arm-little and | 1544 | | pei-arm-wince-little. */ | 1545 | | #ifdef WINCE | 1546 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1547 | | #else | 1548 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1549 | | #endif | 1550 | | { | 1551 | | bfd_set_error (bfd_error_wrong_format); | 1552 | | return NULL; | 1553 | | } | 1554 | | #endif | 1555 | | | 1556 | 352 | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1557 | 352 | || a->SectionAlignment >= 0x80000000) | 1558 | 249 | { | 1559 | 249 | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1560 | 249 | abfd); | 1561 | 249 | a->SectionAlignment &= -a->SectionAlignment; | 1562 | 249 | if (a->SectionAlignment >= 0x80000000) | 1563 | 1 | a->SectionAlignment = 0x40000000; | 1564 | 249 | } | 1565 | | | 1566 | 352 | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1567 | 352 | || a->FileAlignment > a->SectionAlignment) | 1568 | 159 | { | 1569 | 159 | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1570 | 159 | abfd); | 1571 | 159 | a->FileAlignment &= -a->FileAlignment; | 1572 | 159 | if (a->FileAlignment > a->SectionAlignment) | 1573 | 87 | a->FileAlignment = a->SectionAlignment; | 1574 | 159 | } | 1575 | | | 1576 | 352 | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1577 | 173 | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1578 | 352 | } | 1579 | | | 1580 | 448 | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1581 | 448 | (opt_hdr_size != 0 | 1582 | 448 | ? &internal_a | 1583 | 448 | : (struct internal_aouthdr *) NULL)); | 1584 | | | 1585 | 448 | if (result) | 1586 | 315 | { | 1587 | | /* Now the whole header has been processed, see if there is a build-id */ | 1588 | 315 | pe_bfd_read_buildid(abfd); | 1589 | 315 | } | 1590 | | | 1591 | 448 | return result; | 1592 | 454 | } |
pei-arm-wince.c:pe_bfd_object_p Line | Count | Source | 1440 | 44.6k | { | 1441 | 44.6k | bfd_byte buffer[6]; | 1442 | 44.6k | struct external_DOS_hdr dos_hdr; | 1443 | 44.6k | struct external_PEI_IMAGE_hdr image_hdr; | 1444 | 44.6k | struct internal_filehdr internal_f; | 1445 | 44.6k | struct internal_aouthdr internal_a; | 1446 | 44.6k | bfd_size_type opt_hdr_size; | 1447 | 44.6k | file_ptr offset; | 1448 | 44.6k | bfd_cleanup result; | 1449 | | | 1450 | | /* Detect if this a Microsoft Import Library Format element. */ | 1451 | | /* First read the beginning of the header. */ | 1452 | 44.6k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1453 | 44.6k | || bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) | 1454 | 314 | { | 1455 | 314 | if (bfd_get_error () != bfd_error_system_call) | 1456 | 308 | bfd_set_error (bfd_error_wrong_format); | 1457 | 314 | return NULL; | 1458 | 314 | } | 1459 | | | 1460 | | /* Then check the magic and the version (only 0 is supported). */ | 1461 | 44.3k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1462 | 44.3k | && H_GET_16 (abfd, buffer + 4) == 0) | 1463 | 301 | return pe_ILF_object_p (abfd); | 1464 | | | 1465 | 44.0k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1466 | 44.0k | || bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd) | 1467 | 44.0k | != sizeof (dos_hdr)) | 1468 | 15.6k | { | 1469 | 15.6k | if (bfd_get_error () != bfd_error_system_call) | 1470 | 15.6k | bfd_set_error (bfd_error_wrong_format); | 1471 | 15.6k | return NULL; | 1472 | 15.6k | } | 1473 | | | 1474 | | /* There are really two magic numbers involved; the magic number | 1475 | | that says this is a NT executable (PEI) and the magic number that | 1476 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1477 | | the e_magic field. The latter is stored in the f_magic field. | 1478 | | If the NT magic number isn't valid, the architecture magic number | 1479 | | could be mimicked by some other field (specifically, the number | 1480 | | of relocs in section 3). Since this routine can only be called | 1481 | | correctly for a PEI file, check the e_magic number here, and, if | 1482 | | it doesn't match, clobber the f_magic number so that we don't get | 1483 | | a false match. */ | 1484 | 28.4k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1485 | 25.1k | { | 1486 | 25.1k | bfd_set_error (bfd_error_wrong_format); | 1487 | 25.1k | return NULL; | 1488 | 25.1k | } | 1489 | | | 1490 | 3.29k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1491 | 3.29k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1492 | 3.29k | || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd) | 1493 | 3.29k | != sizeof (image_hdr))) | 1494 | 27 | { | 1495 | 27 | if (bfd_get_error () != bfd_error_system_call) | 1496 | 27 | bfd_set_error (bfd_error_wrong_format); | 1497 | 27 | return NULL; | 1498 | 27 | } | 1499 | | | 1500 | 3.26k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1501 | 125 | { | 1502 | 125 | bfd_set_error (bfd_error_wrong_format); | 1503 | 125 | return NULL; | 1504 | 125 | } | 1505 | | | 1506 | | /* Swap file header, so that we get the location for calling | 1507 | | real_object_p. */ | 1508 | 3.13k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1509 | | | 1510 | 3.13k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1511 | 3.13k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1512 | 2.51k | { | 1513 | 2.51k | bfd_set_error (bfd_error_wrong_format); | 1514 | 2.51k | return NULL; | 1515 | 2.51k | } | 1516 | | | 1517 | 629 | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1518 | 629 | sizeof (internal_f.pe.dos_message)); | 1519 | | | 1520 | | /* Read the optional header, which has variable size. */ | 1521 | 629 | opt_hdr_size = internal_f.f_opthdr; | 1522 | | | 1523 | 629 | if (opt_hdr_size != 0) | 1524 | 528 | { | 1525 | 528 | bfd_size_type amt = opt_hdr_size; | 1526 | 528 | bfd_byte * opthdr; | 1527 | | | 1528 | | /* PR 17521 file: 230-131433-0.004. */ | 1529 | 528 | if (amt < sizeof (PEAOUTHDR)) | 1530 | 477 | amt = sizeof (PEAOUTHDR); | 1531 | | | 1532 | 528 | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1533 | 528 | if (opthdr == NULL) | 1534 | 5 | return NULL; | 1535 | 523 | if (amt > opt_hdr_size) | 1536 | 473 | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1537 | | | 1538 | 523 | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1539 | | | 1540 | 523 | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1541 | | | 1542 | 523 | #ifdef ARM | 1543 | | /* Use Subsystem to distinguish between pei-arm-little and | 1544 | | pei-arm-wince-little. */ | 1545 | 523 | #ifdef WINCE | 1546 | 523 | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1547 | | #else | 1548 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1549 | | #endif | 1550 | 352 | { | 1551 | 352 | bfd_set_error (bfd_error_wrong_format); | 1552 | 352 | return NULL; | 1553 | 352 | } | 1554 | 171 | #endif | 1555 | | | 1556 | 171 | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1557 | 171 | || a->SectionAlignment >= 0x80000000) | 1558 | 83 | { | 1559 | 83 | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1560 | 83 | abfd); | 1561 | 83 | a->SectionAlignment &= -a->SectionAlignment; | 1562 | 83 | if (a->SectionAlignment >= 0x80000000) | 1563 | 1 | a->SectionAlignment = 0x40000000; | 1564 | 83 | } | 1565 | | | 1566 | 171 | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1567 | 171 | || a->FileAlignment > a->SectionAlignment) | 1568 | 81 | { | 1569 | 81 | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1570 | 81 | abfd); | 1571 | 81 | a->FileAlignment &= -a->FileAlignment; | 1572 | 81 | if (a->FileAlignment > a->SectionAlignment) | 1573 | 60 | a->FileAlignment = a->SectionAlignment; | 1574 | 81 | } | 1575 | | | 1576 | 171 | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1577 | 121 | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1578 | 171 | } | 1579 | | | 1580 | 272 | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1581 | 272 | (opt_hdr_size != 0 | 1582 | 272 | ? &internal_a | 1583 | 272 | : (struct internal_aouthdr *) NULL)); | 1584 | | | 1585 | 272 | if (result) | 1586 | 179 | { | 1587 | | /* Now the whole header has been processed, see if there is a build-id */ | 1588 | 179 | pe_bfd_read_buildid(abfd); | 1589 | 179 | } | 1590 | | | 1591 | 272 | return result; | 1592 | 629 | } |
pei-arm.c:pe_bfd_object_p Line | Count | Source | 1440 | 44.6k | { | 1441 | 44.6k | bfd_byte buffer[6]; | 1442 | 44.6k | struct external_DOS_hdr dos_hdr; | 1443 | 44.6k | struct external_PEI_IMAGE_hdr image_hdr; | 1444 | 44.6k | struct internal_filehdr internal_f; | 1445 | 44.6k | struct internal_aouthdr internal_a; | 1446 | 44.6k | bfd_size_type opt_hdr_size; | 1447 | 44.6k | file_ptr offset; | 1448 | 44.6k | bfd_cleanup result; | 1449 | | | 1450 | | /* Detect if this a Microsoft Import Library Format element. */ | 1451 | | /* First read the beginning of the header. */ | 1452 | 44.6k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1453 | 44.6k | || bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) | 1454 | 314 | { | 1455 | 314 | if (bfd_get_error () != bfd_error_system_call) | 1456 | 308 | bfd_set_error (bfd_error_wrong_format); | 1457 | 314 | return NULL; | 1458 | 314 | } | 1459 | | | 1460 | | /* Then check the magic and the version (only 0 is supported). */ | 1461 | 44.3k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1462 | 44.3k | && H_GET_16 (abfd, buffer + 4) == 0) | 1463 | 305 | return pe_ILF_object_p (abfd); | 1464 | | | 1465 | 44.0k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1466 | 44.0k | || bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd) | 1467 | 44.0k | != sizeof (dos_hdr)) | 1468 | 15.6k | { | 1469 | 15.6k | if (bfd_get_error () != bfd_error_system_call) | 1470 | 15.6k | bfd_set_error (bfd_error_wrong_format); | 1471 | 15.6k | return NULL; | 1472 | 15.6k | } | 1473 | | | 1474 | | /* There are really two magic numbers involved; the magic number | 1475 | | that says this is a NT executable (PEI) and the magic number that | 1476 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1477 | | the e_magic field. The latter is stored in the f_magic field. | 1478 | | If the NT magic number isn't valid, the architecture magic number | 1479 | | could be mimicked by some other field (specifically, the number | 1480 | | of relocs in section 3). Since this routine can only be called | 1481 | | correctly for a PEI file, check the e_magic number here, and, if | 1482 | | it doesn't match, clobber the f_magic number so that we don't get | 1483 | | a false match. */ | 1484 | 28.4k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1485 | 25.1k | { | 1486 | 25.1k | bfd_set_error (bfd_error_wrong_format); | 1487 | 25.1k | return NULL; | 1488 | 25.1k | } | 1489 | | | 1490 | 3.29k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1491 | 3.29k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1492 | 3.29k | || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd) | 1493 | 3.29k | != sizeof (image_hdr))) | 1494 | 27 | { | 1495 | 27 | if (bfd_get_error () != bfd_error_system_call) | 1496 | 27 | bfd_set_error (bfd_error_wrong_format); | 1497 | 27 | return NULL; | 1498 | 27 | } | 1499 | | | 1500 | 3.26k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1501 | 125 | { | 1502 | 125 | bfd_set_error (bfd_error_wrong_format); | 1503 | 125 | return NULL; | 1504 | 125 | } | 1505 | | | 1506 | | /* Swap file header, so that we get the location for calling | 1507 | | real_object_p. */ | 1508 | 3.13k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1509 | | | 1510 | 3.13k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1511 | 3.13k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1512 | 2.51k | { | 1513 | 2.51k | bfd_set_error (bfd_error_wrong_format); | 1514 | 2.51k | return NULL; | 1515 | 2.51k | } | 1516 | | | 1517 | 629 | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1518 | 629 | sizeof (internal_f.pe.dos_message)); | 1519 | | | 1520 | | /* Read the optional header, which has variable size. */ | 1521 | 629 | opt_hdr_size = internal_f.f_opthdr; | 1522 | | | 1523 | 629 | if (opt_hdr_size != 0) | 1524 | 528 | { | 1525 | 528 | bfd_size_type amt = opt_hdr_size; | 1526 | 528 | bfd_byte * opthdr; | 1527 | | | 1528 | | /* PR 17521 file: 230-131433-0.004. */ | 1529 | 528 | if (amt < sizeof (PEAOUTHDR)) | 1530 | 477 | amt = sizeof (PEAOUTHDR); | 1531 | | | 1532 | 528 | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1533 | 528 | if (opthdr == NULL) | 1534 | 5 | return NULL; | 1535 | 523 | if (amt > opt_hdr_size) | 1536 | 473 | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1537 | | | 1538 | 523 | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1539 | | | 1540 | 523 | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1541 | | | 1542 | 523 | #ifdef ARM | 1543 | | /* Use Subsystem to distinguish between pei-arm-little and | 1544 | | pei-arm-wince-little. */ | 1545 | | #ifdef WINCE | 1546 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1547 | | #else | 1548 | 523 | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1549 | 171 | #endif | 1550 | 171 | { | 1551 | 171 | bfd_set_error (bfd_error_wrong_format); | 1552 | 171 | return NULL; | 1553 | 171 | } | 1554 | 352 | #endif | 1555 | | | 1556 | 352 | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1557 | 352 | || a->SectionAlignment >= 0x80000000) | 1558 | 176 | { | 1559 | 176 | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1560 | 176 | abfd); | 1561 | 176 | a->SectionAlignment &= -a->SectionAlignment; | 1562 | 176 | if (a->SectionAlignment >= 0x80000000) | 1563 | 1 | a->SectionAlignment = 0x40000000; | 1564 | 176 | } | 1565 | | | 1566 | 352 | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1567 | 352 | || a->FileAlignment > a->SectionAlignment) | 1568 | 192 | { | 1569 | 192 | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1570 | 192 | abfd); | 1571 | 192 | a->FileAlignment &= -a->FileAlignment; | 1572 | 192 | if (a->FileAlignment > a->SectionAlignment) | 1573 | 121 | a->FileAlignment = a->SectionAlignment; | 1574 | 192 | } | 1575 | | | 1576 | 352 | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1577 | 191 | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1578 | 352 | } | 1579 | | | 1580 | 453 | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1581 | 453 | (opt_hdr_size != 0 | 1582 | 453 | ? &internal_a | 1583 | 453 | : (struct internal_aouthdr *) NULL)); | 1584 | | | 1585 | 453 | if (result) | 1586 | 295 | { | 1587 | | /* Now the whole header has been processed, see if there is a build-id */ | 1588 | 295 | pe_bfd_read_buildid(abfd); | 1589 | 295 | } | 1590 | | | 1591 | 453 | return result; | 1592 | 629 | } |
pei-mcore.c:pe_bfd_object_p Line | Count | Source | 1440 | 44.6k | { | 1441 | 44.6k | bfd_byte buffer[6]; | 1442 | 44.6k | struct external_DOS_hdr dos_hdr; | 1443 | 44.6k | struct external_PEI_IMAGE_hdr image_hdr; | 1444 | 44.6k | struct internal_filehdr internal_f; | 1445 | 44.6k | struct internal_aouthdr internal_a; | 1446 | 44.6k | bfd_size_type opt_hdr_size; | 1447 | 44.6k | file_ptr offset; | 1448 | 44.6k | bfd_cleanup result; | 1449 | | | 1450 | | /* Detect if this a Microsoft Import Library Format element. */ | 1451 | | /* First read the beginning of the header. */ | 1452 | 44.6k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1453 | 44.6k | || bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) | 1454 | 314 | { | 1455 | 314 | if (bfd_get_error () != bfd_error_system_call) | 1456 | 308 | bfd_set_error (bfd_error_wrong_format); | 1457 | 314 | return NULL; | 1458 | 314 | } | 1459 | | | 1460 | | /* Then check the magic and the version (only 0 is supported). */ | 1461 | 44.3k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1462 | 44.3k | && H_GET_16 (abfd, buffer + 4) == 0) | 1463 | 301 | return pe_ILF_object_p (abfd); | 1464 | | | 1465 | 44.0k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1466 | 44.0k | || bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd) | 1467 | 44.0k | != sizeof (dos_hdr)) | 1468 | 15.6k | { | 1469 | 15.6k | if (bfd_get_error () != bfd_error_system_call) | 1470 | 15.6k | bfd_set_error (bfd_error_wrong_format); | 1471 | 15.6k | return NULL; | 1472 | 15.6k | } | 1473 | | | 1474 | | /* There are really two magic numbers involved; the magic number | 1475 | | that says this is a NT executable (PEI) and the magic number that | 1476 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1477 | | the e_magic field. The latter is stored in the f_magic field. | 1478 | | If the NT magic number isn't valid, the architecture magic number | 1479 | | could be mimicked by some other field (specifically, the number | 1480 | | of relocs in section 3). Since this routine can only be called | 1481 | | correctly for a PEI file, check the e_magic number here, and, if | 1482 | | it doesn't match, clobber the f_magic number so that we don't get | 1483 | | a false match. */ | 1484 | 28.4k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1485 | 25.2k | { | 1486 | 25.2k | bfd_set_error (bfd_error_wrong_format); | 1487 | 25.2k | return NULL; | 1488 | 25.2k | } | 1489 | | | 1490 | 3.21k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1491 | 3.21k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1492 | 3.21k | || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd) | 1493 | 3.21k | != sizeof (image_hdr))) | 1494 | 19 | { | 1495 | 19 | if (bfd_get_error () != bfd_error_system_call) | 1496 | 19 | bfd_set_error (bfd_error_wrong_format); | 1497 | 19 | return NULL; | 1498 | 19 | } | 1499 | | | 1500 | 3.19k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1501 | 54 | { | 1502 | 54 | bfd_set_error (bfd_error_wrong_format); | 1503 | 54 | return NULL; | 1504 | 54 | } | 1505 | | | 1506 | | /* Swap file header, so that we get the location for calling | 1507 | | real_object_p. */ | 1508 | 3.13k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1509 | | | 1510 | 3.13k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1511 | 3.13k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1512 | 2.83k | { | 1513 | 2.83k | bfd_set_error (bfd_error_wrong_format); | 1514 | 2.83k | return NULL; | 1515 | 2.83k | } | 1516 | | | 1517 | 302 | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1518 | 302 | sizeof (internal_f.pe.dos_message)); | 1519 | | | 1520 | | /* Read the optional header, which has variable size. */ | 1521 | 302 | opt_hdr_size = internal_f.f_opthdr; | 1522 | | | 1523 | 302 | if (opt_hdr_size != 0) | 1524 | 175 | { | 1525 | 175 | bfd_size_type amt = opt_hdr_size; | 1526 | 175 | bfd_byte * opthdr; | 1527 | | | 1528 | | /* PR 17521 file: 230-131433-0.004. */ | 1529 | 175 | if (amt < sizeof (PEAOUTHDR)) | 1530 | 173 | amt = sizeof (PEAOUTHDR); | 1531 | | | 1532 | 175 | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1533 | 175 | if (opthdr == NULL) | 1534 | 4 | return NULL; | 1535 | 171 | if (amt > opt_hdr_size) | 1536 | 170 | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1537 | | | 1538 | 171 | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1539 | | | 1540 | 171 | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1541 | | | 1542 | | #ifdef ARM | 1543 | | /* Use Subsystem to distinguish between pei-arm-little and | 1544 | | pei-arm-wince-little. */ | 1545 | | #ifdef WINCE | 1546 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1547 | | #else | 1548 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1549 | | #endif | 1550 | | { | 1551 | | bfd_set_error (bfd_error_wrong_format); | 1552 | | return NULL; | 1553 | | } | 1554 | | #endif | 1555 | | | 1556 | 171 | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1557 | 171 | || a->SectionAlignment >= 0x80000000) | 1558 | 128 | { | 1559 | 128 | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1560 | 128 | abfd); | 1561 | 128 | a->SectionAlignment &= -a->SectionAlignment; | 1562 | 128 | if (a->SectionAlignment >= 0x80000000) | 1563 | 1 | a->SectionAlignment = 0x40000000; | 1564 | 128 | } | 1565 | | | 1566 | 171 | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1567 | 171 | || a->FileAlignment > a->SectionAlignment) | 1568 | 145 | { | 1569 | 145 | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1570 | 145 | abfd); | 1571 | 145 | a->FileAlignment &= -a->FileAlignment; | 1572 | 145 | if (a->FileAlignment > a->SectionAlignment) | 1573 | 100 | a->FileAlignment = a->SectionAlignment; | 1574 | 145 | } | 1575 | | | 1576 | 171 | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1577 | 144 | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1578 | 171 | } | 1579 | | | 1580 | 298 | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1581 | 298 | (opt_hdr_size != 0 | 1582 | 298 | ? &internal_a | 1583 | 298 | : (struct internal_aouthdr *) NULL)); | 1584 | | | 1585 | 298 | if (result) | 1586 | 197 | { | 1587 | | /* Now the whole header has been processed, see if there is a build-id */ | 1588 | 197 | pe_bfd_read_buildid(abfd); | 1589 | 197 | } | 1590 | | | 1591 | 298 | return result; | 1592 | 302 | } |
Line | Count | Source | 1440 | 22.3k | { | 1441 | 22.3k | bfd_byte buffer[6]; | 1442 | 22.3k | struct external_DOS_hdr dos_hdr; | 1443 | 22.3k | struct external_PEI_IMAGE_hdr image_hdr; | 1444 | 22.3k | struct internal_filehdr internal_f; | 1445 | 22.3k | struct internal_aouthdr internal_a; | 1446 | 22.3k | bfd_size_type opt_hdr_size; | 1447 | 22.3k | file_ptr offset; | 1448 | 22.3k | bfd_cleanup result; | 1449 | | | 1450 | | /* Detect if this a Microsoft Import Library Format element. */ | 1451 | | /* First read the beginning of the header. */ | 1452 | 22.3k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1453 | 22.3k | || bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) | 1454 | 157 | { | 1455 | 157 | if (bfd_get_error () != bfd_error_system_call) | 1456 | 154 | bfd_set_error (bfd_error_wrong_format); | 1457 | 157 | return NULL; | 1458 | 157 | } | 1459 | | | 1460 | | /* Then check the magic and the version (only 0 is supported). */ | 1461 | 22.1k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1462 | 22.1k | && H_GET_16 (abfd, buffer + 4) == 0) | 1463 | 277 | return pe_ILF_object_p (abfd); | 1464 | | | 1465 | 21.9k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1466 | 21.9k | || bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd) | 1467 | 21.9k | != sizeof (dos_hdr)) | 1468 | 7.71k | { | 1469 | 7.71k | if (bfd_get_error () != bfd_error_system_call) | 1470 | 7.71k | bfd_set_error (bfd_error_wrong_format); | 1471 | 7.71k | return NULL; | 1472 | 7.71k | } | 1473 | | | 1474 | | /* There are really two magic numbers involved; the magic number | 1475 | | that says this is a NT executable (PEI) and the magic number that | 1476 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1477 | | the e_magic field. The latter is stored in the f_magic field. | 1478 | | If the NT magic number isn't valid, the architecture magic number | 1479 | | could be mimicked by some other field (specifically, the number | 1480 | | of relocs in section 3). Since this routine can only be called | 1481 | | correctly for a PEI file, check the e_magic number here, and, if | 1482 | | it doesn't match, clobber the f_magic number so that we don't get | 1483 | | a false match. */ | 1484 | 14.1k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1485 | 11.1k | { | 1486 | 11.1k | bfd_set_error (bfd_error_wrong_format); | 1487 | 11.1k | return NULL; | 1488 | 11.1k | } | 1489 | | | 1490 | 3.06k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1491 | 3.06k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1492 | 3.06k | || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd) | 1493 | 3.06k | != sizeof (image_hdr))) | 1494 | 19 | { | 1495 | 19 | if (bfd_get_error () != bfd_error_system_call) | 1496 | 19 | bfd_set_error (bfd_error_wrong_format); | 1497 | 19 | return NULL; | 1498 | 19 | } | 1499 | | | 1500 | 3.04k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1501 | 53 | { | 1502 | 53 | bfd_set_error (bfd_error_wrong_format); | 1503 | 53 | return NULL; | 1504 | 53 | } | 1505 | | | 1506 | | /* Swap file header, so that we get the location for calling | 1507 | | real_object_p. */ | 1508 | 2.99k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1509 | | | 1510 | 2.99k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1511 | 2.99k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1512 | 2.69k | { | 1513 | 2.69k | bfd_set_error (bfd_error_wrong_format); | 1514 | 2.69k | return NULL; | 1515 | 2.69k | } | 1516 | | | 1517 | 301 | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1518 | 301 | sizeof (internal_f.pe.dos_message)); | 1519 | | | 1520 | | /* Read the optional header, which has variable size. */ | 1521 | 301 | opt_hdr_size = internal_f.f_opthdr; | 1522 | | | 1523 | 301 | if (opt_hdr_size != 0) | 1524 | 224 | { | 1525 | 224 | bfd_size_type amt = opt_hdr_size; | 1526 | 224 | bfd_byte * opthdr; | 1527 | | | 1528 | | /* PR 17521 file: 230-131433-0.004. */ | 1529 | 224 | if (amt < sizeof (PEAOUTHDR)) | 1530 | 222 | amt = sizeof (PEAOUTHDR); | 1531 | | | 1532 | 224 | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1533 | 224 | if (opthdr == NULL) | 1534 | 4 | return NULL; | 1535 | 220 | if (amt > opt_hdr_size) | 1536 | 218 | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1537 | | | 1538 | 220 | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1539 | | | 1540 | 220 | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1541 | | | 1542 | | #ifdef ARM | 1543 | | /* Use Subsystem to distinguish between pei-arm-little and | 1544 | | pei-arm-wince-little. */ | 1545 | | #ifdef WINCE | 1546 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1547 | | #else | 1548 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1549 | | #endif | 1550 | | { | 1551 | | bfd_set_error (bfd_error_wrong_format); | 1552 | | return NULL; | 1553 | | } | 1554 | | #endif | 1555 | | | 1556 | 220 | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1557 | 220 | || a->SectionAlignment >= 0x80000000) | 1558 | 125 | { | 1559 | 125 | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1560 | 125 | abfd); | 1561 | 125 | a->SectionAlignment &= -a->SectionAlignment; | 1562 | 125 | if (a->SectionAlignment >= 0x80000000) | 1563 | 6 | a->SectionAlignment = 0x40000000; | 1564 | 125 | } | 1565 | | | 1566 | 220 | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1567 | 220 | || a->FileAlignment > a->SectionAlignment) | 1568 | 144 | { | 1569 | 144 | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1570 | 144 | abfd); | 1571 | 144 | a->FileAlignment &= -a->FileAlignment; | 1572 | 144 | if (a->FileAlignment > a->SectionAlignment) | 1573 | 39 | a->FileAlignment = a->SectionAlignment; | 1574 | 144 | } | 1575 | | | 1576 | 220 | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1577 | 127 | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1578 | 220 | } | 1579 | | | 1580 | 297 | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1581 | 297 | (opt_hdr_size != 0 | 1582 | 297 | ? &internal_a | 1583 | 297 | : (struct internal_aouthdr *) NULL)); | 1584 | | | 1585 | 297 | if (result) | 1586 | 185 | { | 1587 | | /* Now the whole header has been processed, see if there is a build-id */ | 1588 | 185 | pe_bfd_read_buildid(abfd); | 1589 | 185 | } | 1590 | | | 1591 | 297 | return result; | 1592 | 301 | } |
|
1593 | | |
1594 | 2.57k | #define coff_object_p pe_bfd_object_p |
1595 | | #endif /* COFF_IMAGE_WITH_PE */ |