/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 | 287k | { |
132 | 287k | RELOC *reloc_src = (RELOC *) src; |
133 | 287k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; |
134 | | |
135 | 287k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); |
136 | 287k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); |
137 | 287k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); |
138 | | #ifdef SWAP_IN_RELOC_OFFSET |
139 | 76.1k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); |
140 | | #endif |
141 | 287k | } pei-i386.c:coff_swap_reloc_in Line | Count | Source | 131 | 12.7k | { | 132 | 12.7k | RELOC *reloc_src = (RELOC *) src; | 133 | 12.7k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 12.7k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 12.7k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 12.7k | 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 | 12.7k | } |
pe-x86_64.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-x86_64.c:coff_swap_reloc_in Line | Count | Source | 131 | 7.61k | { | 132 | 7.61k | RELOC *reloc_src = (RELOC *) src; | 133 | 7.61k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 7.61k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 7.61k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 7.61k | 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 | 7.61k | } |
pe-aarch64.c:coff_swap_reloc_in Line | Count | Source | 131 | 12.8k | { | 132 | 12.8k | RELOC *reloc_src = (RELOC *) src; | 133 | 12.8k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 12.8k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 12.8k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 12.8k | 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 | 12.8k | } |
pei-aarch64.c:coff_swap_reloc_in Line | Count | Source | 131 | 11.5k | { | 132 | 11.5k | RELOC *reloc_src = (RELOC *) src; | 133 | 11.5k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 11.5k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 11.5k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 11.5k | 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.5k | } |
pei-ia64.c:coff_swap_reloc_in Line | Count | Source | 131 | 15.3k | { | 132 | 15.3k | RELOC *reloc_src = (RELOC *) src; | 133 | 15.3k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 15.3k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 15.3k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 15.3k | 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 | 15.3k | } |
pei-loongarch64.c:coff_swap_reloc_in Line | Count | Source | 131 | 7.70k | { | 132 | 7.70k | RELOC *reloc_src = (RELOC *) src; | 133 | 7.70k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 7.70k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 7.70k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 7.70k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 7.70k | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 7.70k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 7.70k | #endif | 141 | 7.70k | } |
pe-arm-wince.c:coff_swap_reloc_in Line | Count | Source | 131 | 2.64k | { | 132 | 2.64k | RELOC *reloc_src = (RELOC *) src; | 133 | 2.64k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 2.64k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 2.64k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 2.64k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 2.64k | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 2.64k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 2.64k | #endif | 141 | 2.64k | } |
pe-arm.c:coff_swap_reloc_in Line | Count | Source | 131 | 2.64k | { | 132 | 2.64k | RELOC *reloc_src = (RELOC *) src; | 133 | 2.64k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 2.64k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 2.64k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 2.64k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 2.64k | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 2.64k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 2.64k | #endif | 141 | 2.64k | } |
pe-i386.c:coff_swap_reloc_in Line | Count | Source | 131 | 105k | { | 132 | 105k | RELOC *reloc_src = (RELOC *) src; | 133 | 105k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 105k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 105k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 105k | 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 | 105k | } |
pe-mcore.c:coff_swap_reloc_in Line | Count | Source | 131 | 7.99k | { | 132 | 7.99k | RELOC *reloc_src = (RELOC *) src; | 133 | 7.99k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 7.99k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 7.99k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 7.99k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 7.99k | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 7.99k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 7.99k | #endif | 141 | 7.99k | } |
pe-sh.c:coff_swap_reloc_in Line | Count | Source | 131 | 20.5k | { | 132 | 20.5k | RELOC *reloc_src = (RELOC *) src; | 133 | 20.5k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 20.5k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 20.5k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 20.5k | 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 | 20.5k | } |
pei-arm-wince.c:coff_swap_reloc_in Line | Count | Source | 131 | 22.1k | { | 132 | 22.1k | RELOC *reloc_src = (RELOC *) src; | 133 | 22.1k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 22.1k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 22.1k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 22.1k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 22.1k | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 22.1k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 22.1k | #endif | 141 | 22.1k | } |
pei-arm.c:coff_swap_reloc_in Line | Count | Source | 131 | 19.3k | { | 132 | 19.3k | RELOC *reloc_src = (RELOC *) src; | 133 | 19.3k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 19.3k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 19.3k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 19.3k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 19.3k | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 19.3k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 19.3k | #endif | 141 | 19.3k | } |
pei-mcore.c:coff_swap_reloc_in Line | Count | Source | 131 | 13.7k | { | 132 | 13.7k | RELOC *reloc_src = (RELOC *) src; | 133 | 13.7k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 13.7k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 13.7k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 13.7k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 13.7k | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 13.7k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 13.7k | #endif | 141 | 13.7k | } |
pei-sh.c:coff_swap_reloc_in Line | Count | Source | 131 | 14.3k | { | 132 | 14.3k | RELOC *reloc_src = (RELOC *) src; | 133 | 14.3k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 14.3k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 14.3k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 14.3k | 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 | 14.3k | } |
|
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: pe-aarch64.c:coff_swap_reloc_out Unexecuted instantiation: pei-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 | 5.06M | #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 | 21.5M | { |
171 | 21.5M | FILHDR *filehdr_src = (FILHDR *) src; |
172 | 21.5M | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; |
173 | | |
174 | 21.5M | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); |
175 | 21.5M | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); |
176 | 21.5M | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); |
177 | 21.5M | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); |
178 | 21.5M | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); |
179 | 21.5M | 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.5M | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) |
184 | 2.38M | { |
185 | 2.38M | filehdr_dst->f_nsyms = 0; |
186 | 2.38M | filehdr_dst->f_flags |= F_LSYMS; |
187 | 2.38M | } |
188 | | |
189 | 21.5M | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); |
190 | 21.5M | } pei-i386.c:coff_swap_filehdr_in Line | Count | Source | 170 | 572k | { | 171 | 572k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 572k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 572k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 572k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 572k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 572k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 572k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 572k | 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 | 572k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 65.1k | { | 185 | 65.1k | filehdr_dst->f_nsyms = 0; | 186 | 65.1k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 65.1k | } | 188 | | | 189 | 572k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 572k | } |
pe-x86_64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 1.66M | { | 171 | 1.66M | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 1.66M | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 1.66M | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 1.66M | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 1.66M | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 1.66M | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 1.66M | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 1.66M | 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 | 1.66M | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 184k | { | 185 | 184k | filehdr_dst->f_nsyms = 0; | 186 | 184k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 184k | } | 188 | | | 189 | 1.66M | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 1.66M | } |
pei-x86_64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 581k | { | 171 | 581k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 581k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 581k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 581k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 581k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 581k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 581k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 581k | 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 | 581k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 65.3k | { | 185 | 65.3k | filehdr_dst->f_nsyms = 0; | 186 | 65.3k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 65.3k | } | 188 | | | 189 | 581k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 581k | } |
pe-aarch64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 1.65M | { | 171 | 1.65M | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 1.65M | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 1.65M | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 1.65M | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 1.65M | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 1.65M | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 1.65M | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 1.65M | 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 | 1.65M | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 183k | { | 185 | 183k | filehdr_dst->f_nsyms = 0; | 186 | 183k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 183k | } | 188 | | | 189 | 1.65M | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 1.65M | } |
pei-aarch64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 561k | { | 171 | 561k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 561k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 561k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 561k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 561k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 561k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 561k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 561k | 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 | 561k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 64.1k | { | 185 | 64.1k | filehdr_dst->f_nsyms = 0; | 186 | 64.1k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 64.1k | } | 188 | | | 189 | 561k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 561k | } |
pei-ia64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 546k | { | 171 | 546k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 546k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 546k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 546k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 546k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 546k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 546k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 546k | 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 | 546k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 60.0k | { | 185 | 60.0k | filehdr_dst->f_nsyms = 0; | 186 | 60.0k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 60.0k | } | 188 | | | 189 | 546k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 546k | } |
pei-loongarch64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 561k | { | 171 | 561k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 561k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 561k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 561k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 561k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 561k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 561k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 561k | 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 | 561k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 64.1k | { | 185 | 64.1k | filehdr_dst->f_nsyms = 0; | 186 | 64.1k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 64.1k | } | 188 | | | 189 | 561k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 561k | } |
pe-arm-wince.c:coff_swap_filehdr_in Line | Count | Source | 170 | 3.27M | { | 171 | 3.27M | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 3.27M | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 3.27M | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 3.27M | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 3.27M | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 3.27M | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 3.27M | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 3.27M | 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.27M | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 359k | { | 185 | 359k | filehdr_dst->f_nsyms = 0; | 186 | 359k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 359k | } | 188 | | | 189 | 3.27M | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 3.27M | } |
pe-arm.c:coff_swap_filehdr_in Line | Count | Source | 170 | 3.27M | { | 171 | 3.27M | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 3.27M | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 3.27M | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 3.27M | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 3.27M | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 3.27M | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 3.27M | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 3.27M | 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.27M | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 359k | { | 185 | 359k | filehdr_dst->f_nsyms = 0; | 186 | 359k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 359k | } | 188 | | | 189 | 3.27M | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 3.27M | } |
pe-i386.c:coff_swap_filehdr_in Line | Count | Source | 170 | 1.65M | { | 171 | 1.65M | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 1.65M | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 1.65M | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 1.65M | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 1.65M | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 1.65M | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 1.65M | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 1.65M | 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 | 1.65M | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 183k | { | 185 | 183k | filehdr_dst->f_nsyms = 0; | 186 | 183k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 183k | } | 188 | | | 189 | 1.65M | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 1.65M | } |
pe-mcore.c:coff_swap_filehdr_in Line | Count | Source | 170 | 3.27M | { | 171 | 3.27M | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 3.27M | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 3.27M | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 3.27M | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 3.27M | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 3.27M | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 3.27M | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 3.27M | 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.27M | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 359k | { | 185 | 359k | filehdr_dst->f_nsyms = 0; | 186 | 359k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 359k | } | 188 | | | 189 | 3.27M | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 3.27M | } |
pe-sh.c:coff_swap_filehdr_in Line | Count | Source | 170 | 1.63M | { | 171 | 1.63M | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 1.63M | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 1.63M | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 1.63M | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 1.63M | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 1.63M | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 1.63M | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 1.63M | 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 | 1.63M | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 179k | { | 185 | 179k | filehdr_dst->f_nsyms = 0; | 186 | 179k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 179k | } | 188 | | | 189 | 1.63M | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 1.63M | } |
pei-arm-wince.c:coff_swap_filehdr_in Line | Count | Source | 170 | 561k | { | 171 | 561k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 561k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 561k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 561k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 561k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 561k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 561k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 561k | 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 | 561k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 64.0k | { | 185 | 64.0k | filehdr_dst->f_nsyms = 0; | 186 | 64.0k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 64.0k | } | 188 | | | 189 | 561k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 561k | } |
pei-arm.c:coff_swap_filehdr_in Line | Count | Source | 170 | 561k | { | 171 | 561k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 561k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 561k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 561k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 561k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 561k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 561k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 561k | 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 | 561k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 64.0k | { | 185 | 64.0k | filehdr_dst->f_nsyms = 0; | 186 | 64.0k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 64.0k | } | 188 | | | 189 | 561k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 561k | } |
pei-mcore.c:coff_swap_filehdr_in Line | Count | Source | 170 | 561k | { | 171 | 561k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 561k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 561k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 561k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 561k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 561k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 561k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 561k | 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 | 561k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 63.9k | { | 185 | 63.9k | filehdr_dst->f_nsyms = 0; | 186 | 63.9k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 63.9k | } | 188 | | | 189 | 561k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 561k | } |
pei-sh.c:coff_swap_filehdr_in Line | Count | Source | 170 | 560k | { | 171 | 560k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 560k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 560k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 560k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 560k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 560k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 560k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 560k | 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 | 560k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 63.9k | { | 185 | 63.9k | filehdr_dst->f_nsyms = 0; | 186 | 63.9k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 63.9k | } | 188 | | | 189 | 560k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 560k | } |
|
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 | 3.99M | { |
207 | 3.99M | SCNHDR *scnhdr_ext = (SCNHDR *) ext; |
208 | 3.99M | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; |
209 | | |
210 | 3.99M | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); |
211 | | |
212 | 3.99M | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); |
213 | 3.99M | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); |
214 | 3.99M | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); |
215 | 3.99M | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); |
216 | 3.99M | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); |
217 | 3.99M | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); |
218 | 3.99M | 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 | 2.45M | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) |
225 | 2.45M | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); |
226 | | scnhdr_int->s_nreloc = 0; |
227 | | #else |
228 | 1.53M | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); |
229 | 1.53M | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); |
230 | | #endif |
231 | | |
232 | 3.99M | if (scnhdr_int->s_vaddr != 0) |
233 | 1.79M | { |
234 | 1.79M | 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.79M | } |
240 | | |
241 | 3.99M | #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.99M | if (scnhdr_int->s_paddr > 0 |
247 | 3.99M | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 |
248 | 1.85M | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) |
249 | 1.85M | || (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 | 608k | scnhdr_int->s_size = scnhdr_int->s_paddr; |
255 | 3.99M | #endif |
256 | 3.99M | } pei-i386.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 283k | { | 207 | 283k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 283k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 283k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 283k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 283k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 283k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 283k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 283k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 283k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 283k | 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 | 283k | #ifdef COFF_IMAGE_WITH_PE | 224 | 283k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 283k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 283k | 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 | 283k | if (scnhdr_int->s_vaddr != 0) | 233 | 142k | { | 234 | 142k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 142k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 142k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 142k | #endif | 239 | 142k | } | 240 | | | 241 | 283k | #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 | 283k | if (scnhdr_int->s_paddr > 0 | 247 | 283k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 210k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 210k | || (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 | 92.2k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 283k | #endif | 256 | 283k | } |
pe-x86_64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 318k | { | 207 | 318k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 318k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 318k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 318k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 318k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 318k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 318k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 318k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 318k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 318k | 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 | 318k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 318k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 318k | #endif | 231 | | | 232 | 318k | if (scnhdr_int->s_vaddr != 0) | 233 | 190k | { | 234 | 190k | 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 | 190k | } | 240 | | | 241 | 318k | #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 | 318k | if (scnhdr_int->s_paddr > 0 | 247 | 318k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 187k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 187k | || (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 | 28.6k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 318k | #endif | 256 | 318k | } |
pei-x86_64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 213k | { | 207 | 213k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 213k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 213k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 213k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 213k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 213k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 213k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 213k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 213k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 213k | 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 | 213k | #ifdef COFF_IMAGE_WITH_PE | 224 | 213k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 213k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 213k | 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 | 213k | if (scnhdr_int->s_vaddr != 0) | 233 | 142k | { | 234 | 142k | 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 | 142k | } | 240 | | | 241 | 213k | #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 | 213k | if (scnhdr_int->s_paddr > 0 | 247 | 213k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 134k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 134k | || (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 | 65.5k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 213k | #endif | 256 | 213k | } |
pe-aarch64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 123k | { | 207 | 123k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 123k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 123k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 123k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 123k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 123k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 123k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 123k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 123k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 123k | 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 | 123k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 123k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 123k | #endif | 231 | | | 232 | 123k | if (scnhdr_int->s_vaddr != 0) | 233 | 62.4k | { | 234 | 62.4k | 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 | 62.4k | } | 240 | | | 241 | 123k | #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 | 123k | if (scnhdr_int->s_paddr > 0 | 247 | 123k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 62.8k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 62.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 | 16.9k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 123k | #endif | 256 | 123k | } |
pei-aarch64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 156k | { | 207 | 156k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 156k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 156k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 156k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 156k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 156k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 156k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 156k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 156k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 156k | 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 | 156k | #ifdef COFF_IMAGE_WITH_PE | 224 | 156k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 156k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 156k | 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 | 156k | if (scnhdr_int->s_vaddr != 0) | 233 | 118k | { | 234 | 118k | 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 | 118k | } | 240 | | | 241 | 156k | #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 | 156k | if (scnhdr_int->s_paddr > 0 | 247 | 156k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 118k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 118k | || (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 | 43.1k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 156k | #endif | 256 | 156k | } |
pei-ia64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 222k | { | 207 | 222k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 222k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 222k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 222k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 222k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 222k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 222k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 222k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 222k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 222k | 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 | 222k | #ifdef COFF_IMAGE_WITH_PE | 224 | 222k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 222k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 222k | 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 | 222k | if (scnhdr_int->s_vaddr != 0) | 233 | 142k | { | 234 | 142k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 142k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 142k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 142k | #endif | 239 | 142k | } | 240 | | | 241 | 222k | #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 | 222k | if (scnhdr_int->s_paddr > 0 | 247 | 222k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 143k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 143k | || (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 | 56.3k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 222k | #endif | 256 | 222k | } |
pei-loongarch64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 168k | { | 207 | 168k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 168k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 168k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 168k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 168k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 168k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 168k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 168k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 168k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 168k | 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 | 168k | #ifdef COFF_IMAGE_WITH_PE | 224 | 168k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 168k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 168k | 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 | 168k | if (scnhdr_int->s_vaddr != 0) | 233 | 106k | { | 234 | 106k | 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 | 106k | } | 240 | | | 241 | 168k | #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 | 168k | if (scnhdr_int->s_paddr > 0 | 247 | 168k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 106k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 106k | || (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 | 36.6k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 168k | #endif | 256 | 168k | } |
pe-arm-wince.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 40.7k | { | 207 | 40.7k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 40.7k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 40.7k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 40.7k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 40.7k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 40.7k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 40.7k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 40.7k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 40.7k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 40.7k | 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 | 40.7k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 40.7k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 40.7k | #endif | 231 | | | 232 | 40.7k | if (scnhdr_int->s_vaddr != 0) | 233 | 26.0k | { | 234 | 26.0k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 26.0k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 26.0k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 26.0k | #endif | 239 | 26.0k | } | 240 | | | 241 | 40.7k | #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 | 40.7k | if (scnhdr_int->s_paddr > 0 | 247 | 40.7k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 26.2k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 26.2k | || (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 | 5.49k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 40.7k | #endif | 256 | 40.7k | } |
pe-arm.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 40.7k | { | 207 | 40.7k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 40.7k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 40.7k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 40.7k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 40.7k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 40.7k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 40.7k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 40.7k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 40.7k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 40.7k | 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 | 40.7k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 40.7k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 40.7k | #endif | 231 | | | 232 | 40.7k | if (scnhdr_int->s_vaddr != 0) | 233 | 26.0k | { | 234 | 26.0k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 26.0k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 26.0k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 26.0k | #endif | 239 | 26.0k | } | 240 | | | 241 | 40.7k | #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 | 40.7k | if (scnhdr_int->s_paddr > 0 | 247 | 40.7k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 26.2k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 26.2k | || (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 | 5.49k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 40.7k | #endif | 256 | 40.7k | } |
pe-i386.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 112k | { | 207 | 112k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 112k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 112k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 112k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 112k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 112k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 112k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 112k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 112k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 112k | 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 | 112k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 112k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 112k | #endif | 231 | | | 232 | 112k | if (scnhdr_int->s_vaddr != 0) | 233 | 80.5k | { | 234 | 80.5k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 80.5k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 80.5k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 80.5k | #endif | 239 | 80.5k | } | 240 | | | 241 | 112k | #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 | 112k | if (scnhdr_int->s_paddr > 0 | 247 | 112k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 83.4k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 83.4k | || (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 | 17.2k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 112k | #endif | 256 | 112k | } |
pe-mcore.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 806k | { | 207 | 806k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 806k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 806k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 806k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 806k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 806k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 806k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 806k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 806k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 806k | 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 | 806k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 806k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 806k | #endif | 231 | | | 232 | 806k | if (scnhdr_int->s_vaddr != 0) | 233 | 76.1k | { | 234 | 76.1k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 76.1k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 76.1k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 76.1k | #endif | 239 | 76.1k | } | 240 | | | 241 | 806k | #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 | 806k | if (scnhdr_int->s_paddr > 0 | 247 | 806k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 74.1k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 74.1k | || (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 | 14.8k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 806k | #endif | 256 | 806k | } |
pe-sh.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 96.0k | { | 207 | 96.0k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 96.0k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 96.0k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 96.0k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 96.0k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 96.0k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 96.0k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 96.0k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 96.0k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 96.0k | 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 | 96.0k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 96.0k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 96.0k | #endif | 231 | | | 232 | 96.0k | if (scnhdr_int->s_vaddr != 0) | 233 | 66.4k | { | 234 | 66.4k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 66.4k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 66.4k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 66.4k | #endif | 239 | 66.4k | } | 240 | | | 241 | 96.0k | #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 | 96.0k | if (scnhdr_int->s_paddr > 0 | 247 | 96.0k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 67.8k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 67.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 | 10.1k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 96.0k | #endif | 256 | 96.0k | } |
pei-arm-wince.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 197k | { | 207 | 197k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 197k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 197k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 197k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 197k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 197k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 197k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 197k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 197k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 197k | 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 | 197k | #ifdef COFF_IMAGE_WITH_PE | 224 | 197k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 197k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 197k | 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 | 197k | if (scnhdr_int->s_vaddr != 0) | 233 | 130k | { | 234 | 130k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 130k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 130k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 130k | #endif | 239 | 130k | } | 240 | | | 241 | 197k | #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 | 197k | if (scnhdr_int->s_paddr > 0 | 247 | 197k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 131k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 131k | || (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 | 54.3k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 197k | #endif | 256 | 197k | } |
pei-arm.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 779k | { | 207 | 779k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 779k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 779k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 779k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 779k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 779k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 779k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 779k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 779k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 779k | 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 | 779k | #ifdef COFF_IMAGE_WITH_PE | 224 | 779k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 779k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 779k | 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 | 779k | if (scnhdr_int->s_vaddr != 0) | 233 | 230k | { | 234 | 230k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 230k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 230k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 230k | #endif | 239 | 230k | } | 240 | | | 241 | 779k | #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 | 779k | if (scnhdr_int->s_paddr > 0 | 247 | 779k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 226k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 226k | || (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 | 65.3k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 779k | #endif | 256 | 779k | } |
pei-mcore.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 209k | { | 207 | 209k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 209k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 209k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 209k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 209k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 209k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 209k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 209k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 209k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 209k | 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 | 209k | #ifdef COFF_IMAGE_WITH_PE | 224 | 209k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 209k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 209k | 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 | 209k | if (scnhdr_int->s_vaddr != 0) | 233 | 128k | { | 234 | 128k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 128k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 128k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 128k | #endif | 239 | 128k | } | 240 | | | 241 | 209k | #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 | 209k | if (scnhdr_int->s_paddr > 0 | 247 | 209k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 129k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 129k | || (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 | 45.3k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 209k | #endif | 256 | 209k | } |
pei-sh.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 226k | { | 207 | 226k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 226k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 226k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 226k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 226k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 226k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 226k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 226k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 226k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 226k | 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 | 226k | #ifdef COFF_IMAGE_WITH_PE | 224 | 226k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 226k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 226k | 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 | 226k | if (scnhdr_int->s_vaddr != 0) | 233 | 125k | { | 234 | 125k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 125k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 125k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 125k | #endif | 239 | 125k | } | 240 | | | 241 | 226k | #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 | 226k | if (scnhdr_int->s_paddr > 0 | 247 | 226k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 130k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 130k | || (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 | 50.8k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 226k | #endif | 256 | 226k | } |
|
257 | | |
258 | | static bool |
259 | | pe_mkobject (bfd * abfd) |
260 | 873k | { |
261 | | /* Some x86 code followed by an ascii string. */ |
262 | 873k | static const char default_dos_message[64] = { |
263 | 873k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, |
264 | 873k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, |
265 | 873k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, |
266 | 873k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, |
267 | 873k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, |
268 | 873k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, |
269 | 873k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, |
270 | 873k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
271 | | |
272 | 873k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); |
273 | 873k | abfd->tdata.pe_obj_data = pe; |
274 | 873k | if (pe == NULL) |
275 | 0 | return false; |
276 | | |
277 | 873k | pe->coff.pe = 1; |
278 | | |
279 | | /* in_reloc_p is architecture dependent. */ |
280 | 873k | pe->in_reloc_p = in_reloc_p; |
281 | | |
282 | 873k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); |
283 | | |
284 | 873k | bfd_coff_long_section_names (abfd) |
285 | 873k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; |
286 | | |
287 | 873k | return true; |
288 | 873k | } Line | Count | Source | 260 | 67.0k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 67.0k | static const char default_dos_message[64] = { | 263 | 67.0k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 67.0k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 67.0k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 67.0k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 67.0k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 67.0k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 67.0k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 67.0k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 67.0k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 67.0k | abfd->tdata.pe_obj_data = pe; | 274 | 67.0k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 67.0k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 67.0k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 67.0k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 67.0k | bfd_coff_long_section_names (abfd) | 285 | 67.0k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 67.0k | return true; | 288 | 67.0k | } |
Line | Count | Source | 260 | 92.5k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 92.5k | static const char default_dos_message[64] = { | 263 | 92.5k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 92.5k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 92.5k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 92.5k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 92.5k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 92.5k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 92.5k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 92.5k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 92.5k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 92.5k | abfd->tdata.pe_obj_data = pe; | 274 | 92.5k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 92.5k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 92.5k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 92.5k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 92.5k | bfd_coff_long_section_names (abfd) | 285 | 92.5k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 92.5k | return true; | 288 | 92.5k | } |
Line | Count | Source | 260 | 81.1k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 81.1k | static const char default_dos_message[64] = { | 263 | 81.1k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 81.1k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 81.1k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 81.1k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 81.1k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 81.1k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 81.1k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 81.1k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 81.1k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 81.1k | abfd->tdata.pe_obj_data = pe; | 274 | 81.1k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 81.1k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 81.1k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 81.1k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 81.1k | bfd_coff_long_section_names (abfd) | 285 | 81.1k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 81.1k | return true; | 288 | 81.1k | } |
Line | Count | Source | 260 | 29.1k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 29.1k | static const char default_dos_message[64] = { | 263 | 29.1k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 29.1k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 29.1k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 29.1k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 29.1k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 29.1k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 29.1k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 29.1k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 29.1k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 29.1k | abfd->tdata.pe_obj_data = pe; | 274 | 29.1k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 29.1k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 29.1k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 29.1k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 29.1k | bfd_coff_long_section_names (abfd) | 285 | 29.1k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 29.1k | return true; | 288 | 29.1k | } |
pei-aarch64.c:pe_mkobject Line | Count | Source | 260 | 62.4k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 62.4k | static const char default_dos_message[64] = { | 263 | 62.4k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 62.4k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 62.4k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 62.4k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 62.4k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 62.4k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 62.4k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 62.4k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 62.4k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 62.4k | abfd->tdata.pe_obj_data = pe; | 274 | 62.4k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 62.4k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 62.4k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 62.4k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 62.4k | bfd_coff_long_section_names (abfd) | 285 | 62.4k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 62.4k | return true; | 288 | 62.4k | } |
Line | Count | Source | 260 | 73.5k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 73.5k | static const char default_dos_message[64] = { | 263 | 73.5k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 73.5k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 73.5k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 73.5k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 73.5k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 73.5k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 73.5k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 73.5k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 73.5k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 73.5k | abfd->tdata.pe_obj_data = pe; | 274 | 73.5k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 73.5k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 73.5k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 73.5k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 73.5k | bfd_coff_long_section_names (abfd) | 285 | 73.5k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 73.5k | return true; | 288 | 73.5k | } |
pei-loongarch64.c:pe_mkobject Line | Count | Source | 260 | 53.1k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 53.1k | static const char default_dos_message[64] = { | 263 | 53.1k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 53.1k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 53.1k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 53.1k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 53.1k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 53.1k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 53.1k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 53.1k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 53.1k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 53.1k | abfd->tdata.pe_obj_data = pe; | 274 | 53.1k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 53.1k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 53.1k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 53.1k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 53.1k | bfd_coff_long_section_names (abfd) | 285 | 53.1k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 53.1k | return true; | 288 | 53.1k | } |
pe-arm-wince.c:pe_mkobject Line | Count | Source | 260 | 12.5k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 12.5k | static const char default_dos_message[64] = { | 263 | 12.5k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 12.5k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 12.5k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 12.5k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 12.5k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 12.5k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 12.5k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 12.5k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 12.5k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 12.5k | abfd->tdata.pe_obj_data = pe; | 274 | 12.5k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 12.5k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 12.5k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 12.5k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 12.5k | bfd_coff_long_section_names (abfd) | 285 | 12.5k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 12.5k | return true; | 288 | 12.5k | } |
Line | Count | Source | 260 | 12.5k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 12.5k | static const char default_dos_message[64] = { | 263 | 12.5k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 12.5k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 12.5k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 12.5k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 12.5k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 12.5k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 12.5k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 12.5k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 12.5k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 12.5k | abfd->tdata.pe_obj_data = pe; | 274 | 12.5k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 12.5k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 12.5k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 12.5k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 12.5k | bfd_coff_long_section_names (abfd) | 285 | 12.5k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 12.5k | return true; | 288 | 12.5k | } |
Line | Count | Source | 260 | 41.5k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 41.5k | static const char default_dos_message[64] = { | 263 | 41.5k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 41.5k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 41.5k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 41.5k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 41.5k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 41.5k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 41.5k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 41.5k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 41.5k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 41.5k | abfd->tdata.pe_obj_data = pe; | 274 | 41.5k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 41.5k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 41.5k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 41.5k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 41.5k | bfd_coff_long_section_names (abfd) | 285 | 41.5k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 41.5k | return true; | 288 | 41.5k | } |
Line | Count | Source | 260 | 30.5k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 30.5k | static const char default_dos_message[64] = { | 263 | 30.5k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 30.5k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 30.5k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 30.5k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 30.5k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 30.5k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 30.5k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 30.5k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 30.5k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 30.5k | abfd->tdata.pe_obj_data = pe; | 274 | 30.5k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 30.5k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 30.5k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 30.5k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 30.5k | bfd_coff_long_section_names (abfd) | 285 | 30.5k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 30.5k | return true; | 288 | 30.5k | } |
Line | Count | Source | 260 | 34.8k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 34.8k | static const char default_dos_message[64] = { | 263 | 34.8k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 34.8k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 34.8k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 34.8k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 34.8k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 34.8k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 34.8k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 34.8k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 34.8k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 34.8k | abfd->tdata.pe_obj_data = pe; | 274 | 34.8k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 34.8k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 34.8k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 34.8k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 34.8k | bfd_coff_long_section_names (abfd) | 285 | 34.8k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 34.8k | return true; | 288 | 34.8k | } |
pei-arm-wince.c:pe_mkobject Line | Count | Source | 260 | 67.1k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 67.1k | static const char default_dos_message[64] = { | 263 | 67.1k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 67.1k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 67.1k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 67.1k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 67.1k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 67.1k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 67.1k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 67.1k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 67.1k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 67.1k | abfd->tdata.pe_obj_data = pe; | 274 | 67.1k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 67.1k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 67.1k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 67.1k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 67.1k | bfd_coff_long_section_names (abfd) | 285 | 67.1k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 67.1k | return true; | 288 | 67.1k | } |
Line | Count | Source | 260 | 85.3k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 85.3k | static const char default_dos_message[64] = { | 263 | 85.3k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 85.3k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 85.3k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 85.3k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 85.3k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 85.3k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 85.3k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 85.3k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 85.3k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 85.3k | abfd->tdata.pe_obj_data = pe; | 274 | 85.3k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 85.3k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 85.3k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 85.3k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 85.3k | bfd_coff_long_section_names (abfd) | 285 | 85.3k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 85.3k | return true; | 288 | 85.3k | } |
Line | Count | Source | 260 | 68.1k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 68.1k | static const char default_dos_message[64] = { | 263 | 68.1k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 68.1k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 68.1k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 68.1k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 68.1k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 68.1k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 68.1k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 68.1k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 68.1k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 68.1k | abfd->tdata.pe_obj_data = pe; | 274 | 68.1k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 68.1k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 68.1k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 68.1k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 68.1k | bfd_coff_long_section_names (abfd) | 285 | 68.1k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 68.1k | return true; | 288 | 68.1k | } |
Line | Count | Source | 260 | 61.7k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 61.7k | static const char default_dos_message[64] = { | 263 | 61.7k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 61.7k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 61.7k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 61.7k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 61.7k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 61.7k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 61.7k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 61.7k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 61.7k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 61.7k | abfd->tdata.pe_obj_data = pe; | 274 | 61.7k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 61.7k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 61.7k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 61.7k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 61.7k | bfd_coff_long_section_names (abfd) | 285 | 61.7k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 61.7k | return true; | 288 | 61.7k | } |
|
289 | | |
290 | | /* Create the COFF backend specific information. */ |
291 | | |
292 | | static void * |
293 | | pe_mkobject_hook (bfd * abfd, |
294 | | void * filehdr, |
295 | | void * aouthdr ATTRIBUTE_UNUSED) |
296 | 872k | { |
297 | 872k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; |
298 | 872k | pe_data_type *pe; |
299 | | |
300 | 872k | if (! pe_mkobject (abfd)) |
301 | 0 | return NULL; |
302 | | |
303 | 872k | pe = pe_data (abfd); |
304 | 872k | pe->coff.sym_filepos = internal_f->f_symptr; |
305 | | /* These members communicate important constants about the symbol |
306 | | table to GDB's symbol-reading code. These `constants' |
307 | | unfortunately vary among coff implementations... */ |
308 | 872k | pe->coff.local_n_btmask = N_BTMASK; |
309 | 872k | pe->coff.local_n_btshft = N_BTSHFT; |
310 | 872k | pe->coff.local_n_tmask = N_TMASK; |
311 | 872k | pe->coff.local_n_tshift = N_TSHIFT; |
312 | 872k | pe->coff.local_symesz = SYMESZ; |
313 | 872k | pe->coff.local_auxesz = AUXESZ; |
314 | 872k | pe->coff.local_linesz = LINESZ; |
315 | | |
316 | 872k | pe->coff.timestamp = internal_f->f_timdat; |
317 | | |
318 | 872k | obj_raw_syment_count (abfd) = |
319 | 872k | obj_conv_table_size (abfd) = |
320 | 872k | internal_f->f_nsyms; |
321 | | |
322 | 872k | pe->real_flags = internal_f->f_flags; |
323 | | |
324 | 872k | if ((internal_f->f_flags & F_DLL) != 0) |
325 | 264k | pe->dll = 1; |
326 | | |
327 | 872k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) |
328 | 633k | abfd->flags |= HAS_DEBUG; |
329 | | |
330 | | #ifdef COFF_IMAGE_WITH_PE |
331 | 619k | if (aouthdr) |
332 | 392k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; |
333 | | #endif |
334 | | |
335 | | #ifdef ARM |
336 | 177k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) |
337 | 0 | coff_data (abfd) ->flags = 0; |
338 | | #endif |
339 | | |
340 | 872k | memcpy (pe->dos_message, internal_f->pe.dos_message, |
341 | 872k | sizeof (pe->dos_message)); |
342 | | |
343 | 872k | return (void *) pe; |
344 | 872k | } pei-i386.c:pe_mkobject_hook Line | Count | Source | 296 | 67.0k | { | 297 | 67.0k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 67.0k | pe_data_type *pe; | 299 | | | 300 | 67.0k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 67.0k | pe = pe_data (abfd); | 304 | 67.0k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 67.0k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 67.0k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 67.0k | pe->coff.local_n_tmask = N_TMASK; | 311 | 67.0k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 67.0k | pe->coff.local_symesz = SYMESZ; | 313 | 67.0k | pe->coff.local_auxesz = AUXESZ; | 314 | 67.0k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 67.0k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 67.0k | obj_raw_syment_count (abfd) = | 319 | 67.0k | obj_conv_table_size (abfd) = | 320 | 67.0k | internal_f->f_nsyms; | 321 | | | 322 | 67.0k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 67.0k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 20.0k | pe->dll = 1; | 326 | | | 327 | 67.0k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 53.0k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 67.0k | #ifdef COFF_IMAGE_WITH_PE | 331 | 67.0k | if (aouthdr) | 332 | 48.7k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 67.0k | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 67.0k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 67.0k | sizeof (pe->dos_message)); | 342 | | | 343 | 67.0k | return (void *) pe; | 344 | 67.0k | } |
pe-x86_64.c:pe_mkobject_hook Line | Count | Source | 296 | 92.4k | { | 297 | 92.4k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 92.4k | pe_data_type *pe; | 299 | | | 300 | 92.4k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 92.4k | pe = pe_data (abfd); | 304 | 92.4k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 92.4k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 92.4k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 92.4k | pe->coff.local_n_tmask = N_TMASK; | 311 | 92.4k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 92.4k | pe->coff.local_symesz = SYMESZ; | 313 | 92.4k | pe->coff.local_auxesz = AUXESZ; | 314 | 92.4k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 92.4k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 92.4k | obj_raw_syment_count (abfd) = | 319 | 92.4k | obj_conv_table_size (abfd) = | 320 | 92.4k | internal_f->f_nsyms; | 321 | | | 322 | 92.4k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 92.4k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 23.2k | pe->dll = 1; | 326 | | | 327 | 92.4k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 72.5k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | | #ifdef COFF_IMAGE_WITH_PE | 331 | | if (aouthdr) | 332 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 92.4k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 92.4k | sizeof (pe->dos_message)); | 342 | | | 343 | 92.4k | return (void *) pe; | 344 | 92.4k | } |
pei-x86_64.c:pe_mkobject_hook Line | Count | Source | 296 | 81.0k | { | 297 | 81.0k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 81.0k | pe_data_type *pe; | 299 | | | 300 | 81.0k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 81.0k | pe = pe_data (abfd); | 304 | 81.0k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 81.0k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 81.0k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 81.0k | pe->coff.local_n_tmask = N_TMASK; | 311 | 81.0k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 81.0k | pe->coff.local_symesz = SYMESZ; | 313 | 81.0k | pe->coff.local_auxesz = AUXESZ; | 314 | 81.0k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 81.0k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 81.0k | obj_raw_syment_count (abfd) = | 319 | 81.0k | obj_conv_table_size (abfd) = | 320 | 81.0k | internal_f->f_nsyms; | 321 | | | 322 | 81.0k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 81.0k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 34.1k | pe->dll = 1; | 326 | | | 327 | 81.0k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 57.5k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 81.0k | #ifdef COFF_IMAGE_WITH_PE | 331 | 81.0k | if (aouthdr) | 332 | 50.7k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 81.0k | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 81.0k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 81.0k | sizeof (pe->dos_message)); | 342 | | | 343 | 81.0k | return (void *) pe; | 344 | 81.0k | } |
pe-aarch64.c:pe_mkobject_hook Line | Count | Source | 296 | 29.1k | { | 297 | 29.1k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 29.1k | pe_data_type *pe; | 299 | | | 300 | 29.1k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 29.1k | pe = pe_data (abfd); | 304 | 29.1k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 29.1k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 29.1k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 29.1k | pe->coff.local_n_tmask = N_TMASK; | 311 | 29.1k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 29.1k | pe->coff.local_symesz = SYMESZ; | 313 | 29.1k | pe->coff.local_auxesz = AUXESZ; | 314 | 29.1k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 29.1k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 29.1k | obj_raw_syment_count (abfd) = | 319 | 29.1k | obj_conv_table_size (abfd) = | 320 | 29.1k | internal_f->f_nsyms; | 321 | | | 322 | 29.1k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 29.1k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 9.51k | pe->dll = 1; | 326 | | | 327 | 29.1k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 19.5k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | | #ifdef COFF_IMAGE_WITH_PE | 331 | | if (aouthdr) | 332 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 29.1k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 29.1k | sizeof (pe->dos_message)); | 342 | | | 343 | 29.1k | return (void *) pe; | 344 | 29.1k | } |
pei-aarch64.c:pe_mkobject_hook Line | Count | Source | 296 | 62.3k | { | 297 | 62.3k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 62.3k | pe_data_type *pe; | 299 | | | 300 | 62.3k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 62.3k | pe = pe_data (abfd); | 304 | 62.3k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 62.3k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 62.3k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 62.3k | pe->coff.local_n_tmask = N_TMASK; | 311 | 62.3k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 62.3k | pe->coff.local_symesz = SYMESZ; | 313 | 62.3k | pe->coff.local_auxesz = AUXESZ; | 314 | 62.3k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 62.3k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 62.3k | obj_raw_syment_count (abfd) = | 319 | 62.3k | obj_conv_table_size (abfd) = | 320 | 62.3k | internal_f->f_nsyms; | 321 | | | 322 | 62.3k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 62.3k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 20.0k | pe->dll = 1; | 326 | | | 327 | 62.3k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 42.2k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 62.3k | #ifdef COFF_IMAGE_WITH_PE | 331 | 62.3k | if (aouthdr) | 332 | 50.5k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 62.3k | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 62.3k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 62.3k | sizeof (pe->dos_message)); | 342 | | | 343 | 62.3k | return (void *) pe; | 344 | 62.3k | } |
pei-ia64.c:pe_mkobject_hook Line | Count | Source | 296 | 73.4k | { | 297 | 73.4k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 73.4k | pe_data_type *pe; | 299 | | | 300 | 73.4k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 73.4k | pe = pe_data (abfd); | 304 | 73.4k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 73.4k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 73.4k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 73.4k | pe->coff.local_n_tmask = N_TMASK; | 311 | 73.4k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 73.4k | pe->coff.local_symesz = SYMESZ; | 313 | 73.4k | pe->coff.local_auxesz = AUXESZ; | 314 | 73.4k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 73.4k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 73.4k | obj_raw_syment_count (abfd) = | 319 | 73.4k | obj_conv_table_size (abfd) = | 320 | 73.4k | internal_f->f_nsyms; | 321 | | | 322 | 73.4k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 73.4k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 27.9k | pe->dll = 1; | 326 | | | 327 | 73.4k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 48.2k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 73.4k | #ifdef COFF_IMAGE_WITH_PE | 331 | 73.4k | if (aouthdr) | 332 | 46.3k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 73.4k | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 73.4k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 73.4k | sizeof (pe->dos_message)); | 342 | | | 343 | 73.4k | return (void *) pe; | 344 | 73.4k | } |
pei-loongarch64.c:pe_mkobject_hook Line | Count | Source | 296 | 53.0k | { | 297 | 53.0k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 53.0k | pe_data_type *pe; | 299 | | | 300 | 53.0k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 53.0k | pe = pe_data (abfd); | 304 | 53.0k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 53.0k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 53.0k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 53.0k | pe->coff.local_n_tmask = N_TMASK; | 311 | 53.0k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 53.0k | pe->coff.local_symesz = SYMESZ; | 313 | 53.0k | pe->coff.local_auxesz = AUXESZ; | 314 | 53.0k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 53.0k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 53.0k | obj_raw_syment_count (abfd) = | 319 | 53.0k | obj_conv_table_size (abfd) = | 320 | 53.0k | internal_f->f_nsyms; | 321 | | | 322 | 53.0k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 53.0k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 14.8k | pe->dll = 1; | 326 | | | 327 | 53.0k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 37.7k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 53.0k | #ifdef COFF_IMAGE_WITH_PE | 331 | 53.0k | if (aouthdr) | 332 | 36.9k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 53.0k | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 53.0k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 53.0k | sizeof (pe->dos_message)); | 342 | | | 343 | 53.0k | return (void *) pe; | 344 | 53.0k | } |
pe-arm-wince.c:pe_mkobject_hook Line | Count | Source | 296 | 12.5k | { | 297 | 12.5k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 12.5k | pe_data_type *pe; | 299 | | | 300 | 12.5k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 12.5k | pe = pe_data (abfd); | 304 | 12.5k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 12.5k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 12.5k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 12.5k | pe->coff.local_n_tmask = N_TMASK; | 311 | 12.5k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 12.5k | pe->coff.local_symesz = SYMESZ; | 313 | 12.5k | pe->coff.local_auxesz = AUXESZ; | 314 | 12.5k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 12.5k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 12.5k | obj_raw_syment_count (abfd) = | 319 | 12.5k | obj_conv_table_size (abfd) = | 320 | 12.5k | internal_f->f_nsyms; | 321 | | | 322 | 12.5k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 12.5k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 4.02k | pe->dll = 1; | 326 | | | 327 | 12.5k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 10.9k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | | #ifdef COFF_IMAGE_WITH_PE | 331 | | if (aouthdr) | 332 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | | #endif | 334 | | | 335 | 12.5k | #ifdef ARM | 336 | 12.5k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | 0 | coff_data (abfd) ->flags = 0; | 338 | 12.5k | #endif | 339 | | | 340 | 12.5k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 12.5k | sizeof (pe->dos_message)); | 342 | | | 343 | 12.5k | return (void *) pe; | 344 | 12.5k | } |
pe-arm.c:pe_mkobject_hook Line | Count | Source | 296 | 12.5k | { | 297 | 12.5k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 12.5k | pe_data_type *pe; | 299 | | | 300 | 12.5k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 12.5k | pe = pe_data (abfd); | 304 | 12.5k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 12.5k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 12.5k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 12.5k | pe->coff.local_n_tmask = N_TMASK; | 311 | 12.5k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 12.5k | pe->coff.local_symesz = SYMESZ; | 313 | 12.5k | pe->coff.local_auxesz = AUXESZ; | 314 | 12.5k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 12.5k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 12.5k | obj_raw_syment_count (abfd) = | 319 | 12.5k | obj_conv_table_size (abfd) = | 320 | 12.5k | internal_f->f_nsyms; | 321 | | | 322 | 12.5k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 12.5k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 4.02k | pe->dll = 1; | 326 | | | 327 | 12.5k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 10.9k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | | #ifdef COFF_IMAGE_WITH_PE | 331 | | if (aouthdr) | 332 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | | #endif | 334 | | | 335 | 12.5k | #ifdef ARM | 336 | 12.5k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | 0 | coff_data (abfd) ->flags = 0; | 338 | 12.5k | #endif | 339 | | | 340 | 12.5k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 12.5k | sizeof (pe->dos_message)); | 342 | | | 343 | 12.5k | return (void *) pe; | 344 | 12.5k | } |
pe-i386.c:pe_mkobject_hook Line | Count | Source | 296 | 41.4k | { | 297 | 41.4k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 41.4k | pe_data_type *pe; | 299 | | | 300 | 41.4k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 41.4k | pe = pe_data (abfd); | 304 | 41.4k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 41.4k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 41.4k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 41.4k | pe->coff.local_n_tmask = N_TMASK; | 311 | 41.4k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 41.4k | pe->coff.local_symesz = SYMESZ; | 313 | 41.4k | pe->coff.local_auxesz = AUXESZ; | 314 | 41.4k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 41.4k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 41.4k | obj_raw_syment_count (abfd) = | 319 | 41.4k | obj_conv_table_size (abfd) = | 320 | 41.4k | internal_f->f_nsyms; | 321 | | | 322 | 41.4k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 41.4k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 10.9k | pe->dll = 1; | 326 | | | 327 | 41.4k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 30.3k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | | #ifdef COFF_IMAGE_WITH_PE | 331 | | if (aouthdr) | 332 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 41.4k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 41.4k | sizeof (pe->dos_message)); | 342 | | | 343 | 41.4k | return (void *) pe; | 344 | 41.4k | } |
pe-mcore.c:pe_mkobject_hook Line | Count | Source | 296 | 30.5k | { | 297 | 30.5k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 30.5k | pe_data_type *pe; | 299 | | | 300 | 30.5k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 30.5k | pe = pe_data (abfd); | 304 | 30.5k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 30.5k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 30.5k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 30.5k | pe->coff.local_n_tmask = N_TMASK; | 311 | 30.5k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 30.5k | pe->coff.local_symesz = SYMESZ; | 313 | 30.5k | pe->coff.local_auxesz = AUXESZ; | 314 | 30.5k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 30.5k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 30.5k | obj_raw_syment_count (abfd) = | 319 | 30.5k | obj_conv_table_size (abfd) = | 320 | 30.5k | internal_f->f_nsyms; | 321 | | | 322 | 30.5k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 30.5k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 8.87k | pe->dll = 1; | 326 | | | 327 | 30.5k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 24.3k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | | #ifdef COFF_IMAGE_WITH_PE | 331 | | if (aouthdr) | 332 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 30.5k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 30.5k | sizeof (pe->dos_message)); | 342 | | | 343 | 30.5k | return (void *) pe; | 344 | 30.5k | } |
Line | Count | Source | 296 | 34.7k | { | 297 | 34.7k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 34.7k | pe_data_type *pe; | 299 | | | 300 | 34.7k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 34.7k | pe = pe_data (abfd); | 304 | 34.7k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 34.7k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 34.7k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 34.7k | pe->coff.local_n_tmask = N_TMASK; | 311 | 34.7k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 34.7k | pe->coff.local_symesz = SYMESZ; | 313 | 34.7k | pe->coff.local_auxesz = AUXESZ; | 314 | 34.7k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 34.7k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 34.7k | obj_raw_syment_count (abfd) = | 319 | 34.7k | obj_conv_table_size (abfd) = | 320 | 34.7k | internal_f->f_nsyms; | 321 | | | 322 | 34.7k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 34.7k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 12.8k | pe->dll = 1; | 326 | | | 327 | 34.7k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 28.6k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | | #ifdef COFF_IMAGE_WITH_PE | 331 | | if (aouthdr) | 332 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 34.7k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 34.7k | sizeof (pe->dos_message)); | 342 | | | 343 | 34.7k | return (void *) pe; | 344 | 34.7k | } |
pei-arm-wince.c:pe_mkobject_hook Line | Count | Source | 296 | 67.0k | { | 297 | 67.0k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 67.0k | pe_data_type *pe; | 299 | | | 300 | 67.0k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 67.0k | pe = pe_data (abfd); | 304 | 67.0k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 67.0k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 67.0k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 67.0k | pe->coff.local_n_tmask = N_TMASK; | 311 | 67.0k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 67.0k | pe->coff.local_symesz = SYMESZ; | 313 | 67.0k | pe->coff.local_auxesz = AUXESZ; | 314 | 67.0k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 67.0k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 67.0k | obj_raw_syment_count (abfd) = | 319 | 67.0k | obj_conv_table_size (abfd) = | 320 | 67.0k | internal_f->f_nsyms; | 321 | | | 322 | 67.0k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 67.0k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 16.4k | pe->dll = 1; | 326 | | | 327 | 67.0k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 45.0k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 67.0k | #ifdef COFF_IMAGE_WITH_PE | 331 | 67.0k | if (aouthdr) | 332 | 28.7k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 67.0k | #endif | 334 | | | 335 | 67.0k | #ifdef ARM | 336 | 67.0k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | 0 | coff_data (abfd) ->flags = 0; | 338 | 67.0k | #endif | 339 | | | 340 | 67.0k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 67.0k | sizeof (pe->dos_message)); | 342 | | | 343 | 67.0k | return (void *) pe; | 344 | 67.0k | } |
pei-arm.c:pe_mkobject_hook Line | Count | Source | 296 | 85.3k | { | 297 | 85.3k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 85.3k | pe_data_type *pe; | 299 | | | 300 | 85.3k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 85.3k | pe = pe_data (abfd); | 304 | 85.3k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 85.3k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 85.3k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 85.3k | pe->coff.local_n_tmask = N_TMASK; | 311 | 85.3k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 85.3k | pe->coff.local_symesz = SYMESZ; | 313 | 85.3k | pe->coff.local_auxesz = AUXESZ; | 314 | 85.3k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 85.3k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 85.3k | obj_raw_syment_count (abfd) = | 319 | 85.3k | obj_conv_table_size (abfd) = | 320 | 85.3k | internal_f->f_nsyms; | 321 | | | 322 | 85.3k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 85.3k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 25.0k | pe->dll = 1; | 326 | | | 327 | 85.3k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 55.4k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 85.3k | #ifdef COFF_IMAGE_WITH_PE | 331 | 85.3k | if (aouthdr) | 332 | 43.7k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 85.3k | #endif | 334 | | | 335 | 85.3k | #ifdef ARM | 336 | 85.3k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | 0 | coff_data (abfd) ->flags = 0; | 338 | 85.3k | #endif | 339 | | | 340 | 85.3k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 85.3k | sizeof (pe->dos_message)); | 342 | | | 343 | 85.3k | return (void *) pe; | 344 | 85.3k | } |
pei-mcore.c:pe_mkobject_hook Line | Count | Source | 296 | 68.1k | { | 297 | 68.1k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 68.1k | pe_data_type *pe; | 299 | | | 300 | 68.1k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 68.1k | pe = pe_data (abfd); | 304 | 68.1k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 68.1k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 68.1k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 68.1k | pe->coff.local_n_tmask = N_TMASK; | 311 | 68.1k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 68.1k | pe->coff.local_symesz = SYMESZ; | 313 | 68.1k | pe->coff.local_auxesz = AUXESZ; | 314 | 68.1k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 68.1k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 68.1k | obj_raw_syment_count (abfd) = | 319 | 68.1k | obj_conv_table_size (abfd) = | 320 | 68.1k | internal_f->f_nsyms; | 321 | | | 322 | 68.1k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 68.1k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 18.1k | pe->dll = 1; | 326 | | | 327 | 68.1k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 47.8k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 68.1k | #ifdef COFF_IMAGE_WITH_PE | 331 | 68.1k | if (aouthdr) | 332 | 49.8k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 68.1k | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 68.1k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 68.1k | sizeof (pe->dos_message)); | 342 | | | 343 | 68.1k | return (void *) pe; | 344 | 68.1k | } |
pei-sh.c:pe_mkobject_hook Line | Count | Source | 296 | 61.7k | { | 297 | 61.7k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 61.7k | pe_data_type *pe; | 299 | | | 300 | 61.7k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 61.7k | pe = pe_data (abfd); | 304 | 61.7k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 61.7k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 61.7k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 61.7k | pe->coff.local_n_tmask = N_TMASK; | 311 | 61.7k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 61.7k | pe->coff.local_symesz = SYMESZ; | 313 | 61.7k | pe->coff.local_auxesz = AUXESZ; | 314 | 61.7k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 61.7k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 61.7k | obj_raw_syment_count (abfd) = | 319 | 61.7k | obj_conv_table_size (abfd) = | 320 | 61.7k | internal_f->f_nsyms; | 321 | | | 322 | 61.7k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 61.7k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 14.2k | pe->dll = 1; | 326 | | | 327 | 61.7k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 48.4k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 61.7k | #ifdef COFF_IMAGE_WITH_PE | 331 | 61.7k | if (aouthdr) | 332 | 37.1k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 61.7k | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 61.7k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 61.7k | sizeof (pe->dos_message)); | 342 | | | 343 | 61.7k | return (void *) pe; | 344 | 61.7k | } |
|
345 | | |
346 | | static bool |
347 | | pe_print_private_bfd_data (bfd *abfd, void * vfile) |
348 | 8.75k | { |
349 | 8.75k | FILE *file = (FILE *) vfile; |
350 | | |
351 | 8.75k | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) |
352 | 0 | return false; |
353 | | |
354 | 8.75k | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) |
355 | 8.53k | return true; |
356 | | |
357 | 218 | fputc ('\n', file); |
358 | | |
359 | 218 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); |
360 | 8.75k | } pei-i386.c:pe_print_private_bfd_data Line | Count | Source | 348 | 290 | { | 349 | 290 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 290 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 290 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 290 | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 290 | } |
pe-x86_64.c:pe_print_private_bfd_data Line | Count | Source | 348 | 542 | { | 349 | 542 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 542 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 542 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 542 | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 542 | } |
pei-x86_64.c:pe_print_private_bfd_data Line | Count | Source | 348 | 393 | { | 349 | 393 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 393 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 393 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 393 | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 393 | } |
pe-aarch64.c:pe_print_private_bfd_data Line | Count | Source | 348 | 1.99k | { | 349 | 1.99k | FILE *file = (FILE *) vfile; | 350 | | | 351 | 1.99k | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 1.99k | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 1.99k | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 1.99k | } |
pei-aarch64.c:pe_print_private_bfd_data Line | Count | Source | 348 | 3.11k | { | 349 | 3.11k | FILE *file = (FILE *) vfile; | 350 | | | 351 | 3.11k | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 3.11k | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 3.11k | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 3.11k | } |
pei-ia64.c:pe_print_private_bfd_data Line | Count | Source | 348 | 533 | { | 349 | 533 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 533 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 533 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 533 | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 533 | } |
pei-loongarch64.c:pe_print_private_bfd_data Line | Count | Source | 348 | 467 | { | 349 | 467 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 467 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 467 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 467 | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 467 | } |
Unexecuted instantiation: pe-arm-wince.c:pe_print_private_bfd_data Unexecuted instantiation: pe-arm.c:pe_print_private_bfd_data pe-i386.c:pe_print_private_bfd_data Line | Count | Source | 348 | 159 | { | 349 | 159 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 159 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 159 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 159 | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 159 | } |
pe-mcore.c:pe_print_private_bfd_data Line | Count | Source | 348 | 354 | { | 349 | 354 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 354 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 354 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 354 | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 354 | } |
pe-sh.c:pe_print_private_bfd_data Line | Count | Source | 348 | 224 | { | 349 | 224 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 224 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 224 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 224 | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 224 | } |
pei-arm-wince.c:pe_print_private_bfd_data Line | Count | Source | 348 | 73 | { | 349 | 73 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 73 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 73 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 0 | return true; | 356 | | | 357 | 73 | fputc ('\n', file); | 358 | | | 359 | 73 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 73 | } |
pei-arm.c:pe_print_private_bfd_data Line | Count | Source | 348 | 145 | { | 349 | 145 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 145 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 145 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 0 | return true; | 356 | | | 357 | 145 | fputc ('\n', file); | 358 | | | 359 | 145 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 145 | } |
pei-mcore.c:pe_print_private_bfd_data Line | Count | Source | 348 | 137 | { | 349 | 137 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 137 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 137 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 137 | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 137 | } |
pei-sh.c:pe_print_private_bfd_data Line | Count | Source | 348 | 328 | { | 349 | 328 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 328 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 328 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 328 | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 328 | } |
|
361 | | |
362 | | /* Copy any private info we understand from the input bfd |
363 | | to the output bfd. */ |
364 | | |
365 | | static bool |
366 | | pe_bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd) |
367 | 22 | { |
368 | | /* PR binutils/716: Copy the large address aware flag. |
369 | | XXX: Should we be copying other flags or other fields in the pe_data() |
370 | | structure ? */ |
371 | 22 | if (pe_data (obfd) != NULL |
372 | 22 | && pe_data (ibfd) != NULL |
373 | 22 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) |
374 | 12 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; |
375 | | |
376 | 22 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) |
377 | 0 | return false; |
378 | | |
379 | 22 | if (pe_saved_coff_bfd_copy_private_bfd_data) |
380 | 1 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); |
381 | | |
382 | 21 | return true; |
383 | 22 | } pei-i386.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 367 | 3 | { | 368 | | /* PR binutils/716: Copy the large address aware flag. | 369 | | XXX: Should we be copying other flags or other fields in the pe_data() | 370 | | structure ? */ | 371 | 3 | if (pe_data (obfd) != NULL | 372 | 3 | && pe_data (ibfd) != NULL | 373 | 3 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 374 | 1 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 375 | | | 376 | 3 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 377 | 0 | return false; | 378 | | | 379 | 3 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 380 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 381 | | | 382 | 3 | return true; | 383 | 3 | } |
pe-x86_64.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 367 | 1 | { | 368 | | /* PR binutils/716: Copy the large address aware flag. | 369 | | XXX: Should we be copying other flags or other fields in the pe_data() | 370 | | structure ? */ | 371 | 1 | if (pe_data (obfd) != NULL | 372 | 1 | && pe_data (ibfd) != NULL | 373 | 1 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 374 | 0 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 375 | | | 376 | 1 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 377 | 0 | return false; | 378 | | | 379 | 1 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 380 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 381 | | | 382 | 1 | return true; | 383 | 1 | } |
pei-x86_64.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 367 | 8 | { | 368 | | /* PR binutils/716: Copy the large address aware flag. | 369 | | XXX: Should we be copying other flags or other fields in the pe_data() | 370 | | structure ? */ | 371 | 8 | if (pe_data (obfd) != NULL | 372 | 8 | && pe_data (ibfd) != NULL | 373 | 8 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 374 | 8 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 375 | | | 376 | 8 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 377 | 0 | return false; | 378 | | | 379 | 8 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 380 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 381 | | | 382 | 8 | return true; | 383 | 8 | } |
pe-aarch64.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 367 | 1 | { | 368 | | /* PR binutils/716: Copy the large address aware flag. | 369 | | XXX: Should we be copying other flags or other fields in the pe_data() | 370 | | structure ? */ | 371 | 1 | if (pe_data (obfd) != NULL | 372 | 1 | && pe_data (ibfd) != NULL | 373 | 1 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 374 | 0 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 375 | | | 376 | 1 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 377 | 0 | return false; | 378 | | | 379 | 1 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 380 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 381 | | | 382 | 1 | return true; | 383 | 1 | } |
pei-aarch64.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 367 | 2 | { | 368 | | /* PR binutils/716: Copy the large address aware flag. | 369 | | XXX: Should we be copying other flags or other fields in the pe_data() | 370 | | structure ? */ | 371 | 2 | if (pe_data (obfd) != NULL | 372 | 2 | && pe_data (ibfd) != NULL | 373 | 2 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 374 | 0 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 375 | | | 376 | 2 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 377 | 0 | return false; | 378 | | | 379 | 2 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 380 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 381 | | | 382 | 2 | return true; | 383 | 2 | } |
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 pe-i386.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 367 | 3 | { | 368 | | /* PR binutils/716: Copy the large address aware flag. | 369 | | XXX: Should we be copying other flags or other fields in the pe_data() | 370 | | structure ? */ | 371 | 3 | if (pe_data (obfd) != NULL | 372 | 3 | && pe_data (ibfd) != NULL | 373 | 3 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 374 | 1 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 375 | | | 376 | 3 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 377 | 0 | return false; | 378 | | | 379 | 3 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 380 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 381 | | | 382 | 3 | return true; | 383 | 3 | } |
pe-mcore.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 367 | 2 | { | 368 | | /* PR binutils/716: Copy the large address aware flag. | 369 | | XXX: Should we be copying other flags or other fields in the pe_data() | 370 | | structure ? */ | 371 | 2 | if (pe_data (obfd) != NULL | 372 | 2 | && pe_data (ibfd) != NULL | 373 | 2 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 374 | 1 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 375 | | | 376 | 2 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 377 | 0 | return false; | 378 | | | 379 | 2 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 380 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 381 | | | 382 | 2 | return true; | 383 | 2 | } |
Unexecuted instantiation: pe-sh.c:pe_bfd_copy_private_bfd_data pei-arm-wince.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 367 | 1 | { | 368 | | /* PR binutils/716: Copy the large address aware flag. | 369 | | XXX: Should we be copying other flags or other fields in the pe_data() | 370 | | structure ? */ | 371 | 1 | if (pe_data (obfd) != NULL | 372 | 1 | && pe_data (ibfd) != NULL | 373 | 1 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 374 | 0 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 375 | | | 376 | 1 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 377 | 0 | return false; | 378 | | | 379 | 1 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 380 | 1 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 381 | | | 382 | 0 | return true; | 383 | 1 | } |
Unexecuted instantiation: pei-arm.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-mcore.c:pe_bfd_copy_private_bfd_data pei-sh.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 367 | 1 | { | 368 | | /* PR binutils/716: Copy the large address aware flag. | 369 | | XXX: Should we be copying other flags or other fields in the pe_data() | 370 | | structure ? */ | 371 | 1 | if (pe_data (obfd) != NULL | 372 | 1 | && pe_data (ibfd) != NULL | 373 | 1 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 374 | 1 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 375 | | | 376 | 1 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 377 | 0 | return false; | 378 | | | 379 | 1 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 380 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 381 | | | 382 | 1 | return true; | 383 | 1 | } |
|
384 | | |
385 | | #define coff_bfd_copy_private_section_data \ |
386 | | _bfd_XX_bfd_copy_private_section_data |
387 | | |
388 | | #define coff_get_symbol_info _bfd_XX_get_symbol_info |
389 | | |
390 | | #ifdef COFF_IMAGE_WITH_PE |
391 | | |
392 | | /* Code to handle Microsoft's Import Library Format. |
393 | | Also known as LINK6 format. |
394 | | Documentation about this format can be found at: |
395 | | |
396 | | https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#import-library-format */ |
397 | | |
398 | | /* The following constants specify the sizes of the various data |
399 | | structures that we have to create in order to build a bfd describing |
400 | | an ILF object file. The final "+ 1" in the definitions of SIZEOF_IDATA6 |
401 | | and SIZEOF_IDATA7 below is to allow for the possibility that we might |
402 | | need a padding byte in order to ensure 16 bit alignment for the section's |
403 | | contents. |
404 | | |
405 | | The value for SIZEOF_ILF_STRINGS is computed as follows: |
406 | | |
407 | | There will be NUM_ILF_SECTIONS section symbols. Allow 9 characters |
408 | | per symbol for their names (longest section name is .idata$x). |
409 | | |
410 | | There will be two symbols for the imported value, one the symbol name |
411 | | and one with _imp__ prefixed. Allowing for the terminating nul's this |
412 | | is strlen (symbol_name) * 2 + 8 + 21 + strlen (source_dll). |
413 | | |
414 | | The strings in the string table must start STRING__SIZE_SIZE bytes into |
415 | | the table in order to for the string lookup code in coffgen/coffcode to |
416 | | work. */ |
417 | 103k | #define NUM_ILF_RELOCS 8 |
418 | 343k | #define NUM_ILF_SECTIONS 6 |
419 | 257k | #define NUM_ILF_SYMS (2 + NUM_ILF_SECTIONS) |
420 | | |
421 | 51.5k | #define SIZEOF_ILF_SYMS (NUM_ILF_SYMS * sizeof (* vars.sym_cache)) |
422 | 51.5k | #define SIZEOF_ILF_SYM_TABLE (NUM_ILF_SYMS * sizeof (* vars.sym_table)) |
423 | 51.5k | #define SIZEOF_ILF_NATIVE_SYMS (NUM_ILF_SYMS * sizeof (* vars.native_syms)) |
424 | 51.5k | #define SIZEOF_ILF_SYM_PTR_TABLE (NUM_ILF_SYMS * sizeof (* vars.sym_ptr_table)) |
425 | 51.5k | #define SIZEOF_ILF_EXT_SYMS (NUM_ILF_SYMS * sizeof (* vars.esym_table)) |
426 | 51.5k | #define SIZEOF_ILF_RELOCS (NUM_ILF_RELOCS * sizeof (* vars.reltab)) |
427 | 51.5k | #define SIZEOF_ILF_INT_RELOCS (NUM_ILF_RELOCS * sizeof (* vars.int_reltab)) |
428 | 51.5k | #define SIZEOF_ILF_STRINGS (strlen (symbol_name) * 2 + 8 \ |
429 | 51.5k | + 21 + strlen (source_dll) \ |
430 | 51.5k | + NUM_ILF_SECTIONS * 9 \ |
431 | 51.5k | + STRING_SIZE_SIZE) |
432 | 34.3k | #define SIZEOF_IDATA2 (5 * 4) |
433 | | |
434 | | /* For PEx64 idata4 & 5 have thumb size of 8 bytes. */ |
435 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) |
436 | 19.5k | #define SIZEOF_IDATA4 (2 * 4) |
437 | 19.5k | #define SIZEOF_IDATA5 (2 * 4) |
438 | | #else |
439 | 32.0k | #define SIZEOF_IDATA4 (1 * 4) |
440 | 32.0k | #define SIZEOF_IDATA5 (1 * 4) |
441 | | #endif |
442 | | |
443 | 43.2k | #define SIZEOF_IDATA6 (2 + strlen (symbol_name) + 1 + 1) |
444 | 34.3k | #define SIZEOF_IDATA7 (strlen (source_dll) + 1 + 1) |
445 | 34.3k | #define SIZEOF_ILF_SECTIONS (NUM_ILF_SECTIONS * sizeof (struct coff_section_tdata)) |
446 | | |
447 | | #define ILF_DATA_SIZE \ |
448 | 34.3k | + SIZEOF_ILF_SYMS \ |
449 | 34.3k | + SIZEOF_ILF_SYM_TABLE \ |
450 | 34.3k | + SIZEOF_ILF_NATIVE_SYMS \ |
451 | 34.3k | + SIZEOF_ILF_SYM_PTR_TABLE \ |
452 | 34.3k | + SIZEOF_ILF_EXT_SYMS \ |
453 | 34.3k | + SIZEOF_ILF_RELOCS \ |
454 | 34.3k | + SIZEOF_ILF_INT_RELOCS \ |
455 | 34.3k | + SIZEOF_ILF_STRINGS \ |
456 | 34.3k | + SIZEOF_IDATA2 \ |
457 | 34.3k | + SIZEOF_IDATA4 \ |
458 | 34.3k | + SIZEOF_IDATA5 \ |
459 | 34.3k | + SIZEOF_IDATA6 \ |
460 | 34.3k | + SIZEOF_IDATA7 \ |
461 | 34.3k | + SIZEOF_ILF_SECTIONS \ |
462 | 34.3k | + MAX_TEXT_SECTION_SIZE |
463 | | |
464 | | /* Create an empty relocation against the given symbol. */ |
465 | | |
466 | | static void |
467 | | pe_ILF_make_a_symbol_reloc (pe_ILF_vars * vars, |
468 | | bfd_vma address, |
469 | | bfd_reloc_code_real_type reloc, |
470 | | struct bfd_symbol ** sym, |
471 | | unsigned int sym_index) |
472 | 27.2k | { |
473 | 27.2k | arelent * entry; |
474 | 27.2k | struct internal_reloc * internal; |
475 | | |
476 | 27.2k | entry = vars->reltab + vars->relcount; |
477 | 27.2k | internal = vars->int_reltab + vars->relcount; |
478 | | |
479 | 27.2k | entry->address = address; |
480 | 27.2k | entry->addend = 0; |
481 | 27.2k | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); |
482 | 27.2k | entry->sym_ptr_ptr = sym; |
483 | | |
484 | 27.2k | internal->r_vaddr = address; |
485 | 27.2k | internal->r_symndx = sym_index; |
486 | 27.2k | internal->r_type = entry->howto ? entry->howto->type : 0; |
487 | | |
488 | 27.2k | vars->relcount ++; |
489 | | |
490 | 27.2k | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); |
491 | 27.2k | } pei-i386.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 472 | 2.96k | { | 473 | 2.96k | arelent * entry; | 474 | 2.96k | struct internal_reloc * internal; | 475 | | | 476 | 2.96k | entry = vars->reltab + vars->relcount; | 477 | 2.96k | internal = vars->int_reltab + vars->relcount; | 478 | | | 479 | 2.96k | entry->address = address; | 480 | 2.96k | entry->addend = 0; | 481 | 2.96k | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 482 | 2.96k | entry->sym_ptr_ptr = sym; | 483 | | | 484 | 2.96k | internal->r_vaddr = address; | 485 | 2.96k | internal->r_symndx = sym_index; | 486 | 2.96k | internal->r_type = entry->howto ? entry->howto->type : 0; | 487 | | | 488 | 2.96k | vars->relcount ++; | 489 | | | 490 | 2.96k | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 491 | 2.96k | } |
pei-x86_64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 472 | 6.88k | { | 473 | 6.88k | arelent * entry; | 474 | 6.88k | struct internal_reloc * internal; | 475 | | | 476 | 6.88k | entry = vars->reltab + vars->relcount; | 477 | 6.88k | internal = vars->int_reltab + vars->relcount; | 478 | | | 479 | 6.88k | entry->address = address; | 480 | 6.88k | entry->addend = 0; | 481 | 6.88k | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 482 | 6.88k | entry->sym_ptr_ptr = sym; | 483 | | | 484 | 6.88k | internal->r_vaddr = address; | 485 | 6.88k | internal->r_symndx = sym_index; | 486 | 6.88k | internal->r_type = entry->howto ? entry->howto->type : 0; | 487 | | | 488 | 6.88k | vars->relcount ++; | 489 | | | 490 | 6.88k | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 491 | 6.88k | } |
pei-aarch64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 472 | 3.39k | { | 473 | 3.39k | arelent * entry; | 474 | 3.39k | struct internal_reloc * internal; | 475 | | | 476 | 3.39k | entry = vars->reltab + vars->relcount; | 477 | 3.39k | internal = vars->int_reltab + vars->relcount; | 478 | | | 479 | 3.39k | entry->address = address; | 480 | 3.39k | entry->addend = 0; | 481 | 3.39k | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 482 | 3.39k | entry->sym_ptr_ptr = sym; | 483 | | | 484 | 3.39k | internal->r_vaddr = address; | 485 | 3.39k | internal->r_symndx = sym_index; | 486 | 3.39k | internal->r_type = entry->howto ? entry->howto->type : 0; | 487 | | | 488 | 3.39k | vars->relcount ++; | 489 | | | 490 | 3.39k | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 491 | 3.39k | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_symbol_reloc pei-loongarch64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 472 | 2.28k | { | 473 | 2.28k | arelent * entry; | 474 | 2.28k | struct internal_reloc * internal; | 475 | | | 476 | 2.28k | entry = vars->reltab + vars->relcount; | 477 | 2.28k | internal = vars->int_reltab + vars->relcount; | 478 | | | 479 | 2.28k | entry->address = address; | 480 | 2.28k | entry->addend = 0; | 481 | 2.28k | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 482 | 2.28k | entry->sym_ptr_ptr = sym; | 483 | | | 484 | 2.28k | internal->r_vaddr = address; | 485 | 2.28k | internal->r_symndx = sym_index; | 486 | 2.28k | internal->r_type = entry->howto ? entry->howto->type : 0; | 487 | | | 488 | 2.28k | vars->relcount ++; | 489 | | | 490 | 2.28k | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 491 | 2.28k | } |
pei-arm-wince.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 472 | 154 | { | 473 | 154 | arelent * entry; | 474 | 154 | struct internal_reloc * internal; | 475 | | | 476 | 154 | entry = vars->reltab + vars->relcount; | 477 | 154 | internal = vars->int_reltab + vars->relcount; | 478 | | | 479 | 154 | entry->address = address; | 480 | 154 | entry->addend = 0; | 481 | 154 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 482 | 154 | entry->sym_ptr_ptr = sym; | 483 | | | 484 | 154 | internal->r_vaddr = address; | 485 | 154 | internal->r_symndx = sym_index; | 486 | 154 | internal->r_type = entry->howto ? entry->howto->type : 0; | 487 | | | 488 | 154 | vars->relcount ++; | 489 | | | 490 | 154 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 491 | 154 | } |
pei-arm.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 472 | 5.67k | { | 473 | 5.67k | arelent * entry; | 474 | 5.67k | struct internal_reloc * internal; | 475 | | | 476 | 5.67k | entry = vars->reltab + vars->relcount; | 477 | 5.67k | internal = vars->int_reltab + vars->relcount; | 478 | | | 479 | 5.67k | entry->address = address; | 480 | 5.67k | entry->addend = 0; | 481 | 5.67k | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 482 | 5.67k | entry->sym_ptr_ptr = sym; | 483 | | | 484 | 5.67k | internal->r_vaddr = address; | 485 | 5.67k | internal->r_symndx = sym_index; | 486 | 5.67k | internal->r_type = entry->howto ? entry->howto->type : 0; | 487 | | | 488 | 5.67k | vars->relcount ++; | 489 | | | 490 | 5.67k | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 491 | 5.67k | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_symbol_reloc pei-sh.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 472 | 5.86k | { | 473 | 5.86k | arelent * entry; | 474 | 5.86k | struct internal_reloc * internal; | 475 | | | 476 | 5.86k | entry = vars->reltab + vars->relcount; | 477 | 5.86k | internal = vars->int_reltab + vars->relcount; | 478 | | | 479 | 5.86k | entry->address = address; | 480 | 5.86k | entry->addend = 0; | 481 | 5.86k | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 482 | 5.86k | entry->sym_ptr_ptr = sym; | 483 | | | 484 | 5.86k | internal->r_vaddr = address; | 485 | 5.86k | internal->r_symndx = sym_index; | 486 | 5.86k | internal->r_type = entry->howto ? entry->howto->type : 0; | 487 | | | 488 | 5.86k | vars->relcount ++; | 489 | | | 490 | 5.86k | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 491 | 5.86k | } |
|
492 | | |
493 | | /* Create an empty relocation against the given section. */ |
494 | | |
495 | | static void |
496 | | pe_ILF_make_a_reloc (pe_ILF_vars * vars, |
497 | | bfd_vma address, |
498 | | bfd_reloc_code_real_type reloc, |
499 | | asection_ptr sec) |
500 | 17.6k | { |
501 | 17.6k | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, |
502 | 17.6k | coff_section_data (vars->abfd, sec)->i); |
503 | 17.6k | } pei-i386.c:pe_ILF_make_a_reloc Line | Count | Source | 500 | 1.35k | { | 501 | 1.35k | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 502 | 1.35k | coff_section_data (vars->abfd, sec)->i); | 503 | 1.35k | } |
pei-x86_64.c:pe_ILF_make_a_reloc Line | Count | Source | 500 | 4.57k | { | 501 | 4.57k | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 502 | 4.57k | coff_section_data (vars->abfd, sec)->i); | 503 | 4.57k | } |
pei-aarch64.c:pe_ILF_make_a_reloc Line | Count | Source | 500 | 2.68k | { | 501 | 2.68k | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 502 | 2.68k | coff_section_data (vars->abfd, sec)->i); | 503 | 2.68k | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_reloc pei-loongarch64.c:pe_ILF_make_a_reloc Line | Count | Source | 500 | 1.68k | { | 501 | 1.68k | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 502 | 1.68k | coff_section_data (vars->abfd, sec)->i); | 503 | 1.68k | } |
pei-arm-wince.c:pe_ILF_make_a_reloc Line | Count | Source | 500 | 104 | { | 501 | 104 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 502 | 104 | coff_section_data (vars->abfd, sec)->i); | 503 | 104 | } |
pei-arm.c:pe_ILF_make_a_reloc Line | Count | Source | 500 | 3.42k | { | 501 | 3.42k | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 502 | 3.42k | coff_section_data (vars->abfd, sec)->i); | 503 | 3.42k | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_reloc pei-sh.c:pe_ILF_make_a_reloc Line | Count | Source | 500 | 3.86k | { | 501 | 3.86k | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 502 | 3.86k | coff_section_data (vars->abfd, sec)->i); | 503 | 3.86k | } |
|
504 | | |
505 | | /* Move the queued relocs into the given section. */ |
506 | | |
507 | | static void |
508 | | pe_ILF_save_relocs (pe_ILF_vars * vars, |
509 | | asection_ptr sec) |
510 | 27.2k | { |
511 | | /* Make sure that there is somewhere to store the internal relocs. */ |
512 | 27.2k | if (coff_section_data (vars->abfd, sec) == NULL) |
513 | | /* We should probably return an error indication here. */ |
514 | 0 | abort (); |
515 | | |
516 | 27.2k | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; |
517 | | |
518 | 27.2k | sec->relocation = vars->reltab; |
519 | 27.2k | sec->reloc_count = vars->relcount; |
520 | 27.2k | sec->flags |= SEC_RELOC; |
521 | | |
522 | 27.2k | vars->reltab += vars->relcount; |
523 | 27.2k | vars->int_reltab += vars->relcount; |
524 | 27.2k | vars->relcount = 0; |
525 | | |
526 | 27.2k | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); |
527 | 27.2k | } pei-i386.c:pe_ILF_save_relocs Line | Count | Source | 510 | 2.96k | { | 511 | | /* Make sure that there is somewhere to store the internal relocs. */ | 512 | 2.96k | if (coff_section_data (vars->abfd, sec) == NULL) | 513 | | /* We should probably return an error indication here. */ | 514 | 0 | abort (); | 515 | | | 516 | 2.96k | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 517 | | | 518 | 2.96k | sec->relocation = vars->reltab; | 519 | 2.96k | sec->reloc_count = vars->relcount; | 520 | 2.96k | sec->flags |= SEC_RELOC; | 521 | | | 522 | 2.96k | vars->reltab += vars->relcount; | 523 | 2.96k | vars->int_reltab += vars->relcount; | 524 | 2.96k | vars->relcount = 0; | 525 | | | 526 | 2.96k | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 527 | 2.96k | } |
pei-x86_64.c:pe_ILF_save_relocs Line | Count | Source | 510 | 6.88k | { | 511 | | /* Make sure that there is somewhere to store the internal relocs. */ | 512 | 6.88k | if (coff_section_data (vars->abfd, sec) == NULL) | 513 | | /* We should probably return an error indication here. */ | 514 | 0 | abort (); | 515 | | | 516 | 6.88k | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 517 | | | 518 | 6.88k | sec->relocation = vars->reltab; | 519 | 6.88k | sec->reloc_count = vars->relcount; | 520 | 6.88k | sec->flags |= SEC_RELOC; | 521 | | | 522 | 6.88k | vars->reltab += vars->relcount; | 523 | 6.88k | vars->int_reltab += vars->relcount; | 524 | 6.88k | vars->relcount = 0; | 525 | | | 526 | 6.88k | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 527 | 6.88k | } |
pei-aarch64.c:pe_ILF_save_relocs Line | Count | Source | 510 | 3.39k | { | 511 | | /* Make sure that there is somewhere to store the internal relocs. */ | 512 | 3.39k | if (coff_section_data (vars->abfd, sec) == NULL) | 513 | | /* We should probably return an error indication here. */ | 514 | 0 | abort (); | 515 | | | 516 | 3.39k | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 517 | | | 518 | 3.39k | sec->relocation = vars->reltab; | 519 | 3.39k | sec->reloc_count = vars->relcount; | 520 | 3.39k | sec->flags |= SEC_RELOC; | 521 | | | 522 | 3.39k | vars->reltab += vars->relcount; | 523 | 3.39k | vars->int_reltab += vars->relcount; | 524 | 3.39k | vars->relcount = 0; | 525 | | | 526 | 3.39k | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 527 | 3.39k | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_save_relocs pei-loongarch64.c:pe_ILF_save_relocs Line | Count | Source | 510 | 2.28k | { | 511 | | /* Make sure that there is somewhere to store the internal relocs. */ | 512 | 2.28k | if (coff_section_data (vars->abfd, sec) == NULL) | 513 | | /* We should probably return an error indication here. */ | 514 | 0 | abort (); | 515 | | | 516 | 2.28k | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 517 | | | 518 | 2.28k | sec->relocation = vars->reltab; | 519 | 2.28k | sec->reloc_count = vars->relcount; | 520 | 2.28k | sec->flags |= SEC_RELOC; | 521 | | | 522 | 2.28k | vars->reltab += vars->relcount; | 523 | 2.28k | vars->int_reltab += vars->relcount; | 524 | 2.28k | vars->relcount = 0; | 525 | | | 526 | 2.28k | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 527 | 2.28k | } |
pei-arm-wince.c:pe_ILF_save_relocs Line | Count | Source | 510 | 154 | { | 511 | | /* Make sure that there is somewhere to store the internal relocs. */ | 512 | 154 | if (coff_section_data (vars->abfd, sec) == NULL) | 513 | | /* We should probably return an error indication here. */ | 514 | 0 | abort (); | 515 | | | 516 | 154 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 517 | | | 518 | 154 | sec->relocation = vars->reltab; | 519 | 154 | sec->reloc_count = vars->relcount; | 520 | 154 | sec->flags |= SEC_RELOC; | 521 | | | 522 | 154 | vars->reltab += vars->relcount; | 523 | 154 | vars->int_reltab += vars->relcount; | 524 | 154 | vars->relcount = 0; | 525 | | | 526 | 154 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 527 | 154 | } |
pei-arm.c:pe_ILF_save_relocs Line | Count | Source | 510 | 5.67k | { | 511 | | /* Make sure that there is somewhere to store the internal relocs. */ | 512 | 5.67k | if (coff_section_data (vars->abfd, sec) == NULL) | 513 | | /* We should probably return an error indication here. */ | 514 | 0 | abort (); | 515 | | | 516 | 5.67k | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 517 | | | 518 | 5.67k | sec->relocation = vars->reltab; | 519 | 5.67k | sec->reloc_count = vars->relcount; | 520 | 5.67k | sec->flags |= SEC_RELOC; | 521 | | | 522 | 5.67k | vars->reltab += vars->relcount; | 523 | 5.67k | vars->int_reltab += vars->relcount; | 524 | 5.67k | vars->relcount = 0; | 525 | | | 526 | 5.67k | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 527 | 5.67k | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_save_relocs pei-sh.c:pe_ILF_save_relocs Line | Count | Source | 510 | 5.86k | { | 511 | | /* Make sure that there is somewhere to store the internal relocs. */ | 512 | 5.86k | if (coff_section_data (vars->abfd, sec) == NULL) | 513 | | /* We should probably return an error indication here. */ | 514 | 0 | abort (); | 515 | | | 516 | 5.86k | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 517 | | | 518 | 5.86k | sec->relocation = vars->reltab; | 519 | 5.86k | sec->reloc_count = vars->relcount; | 520 | 5.86k | sec->flags |= SEC_RELOC; | 521 | | | 522 | 5.86k | vars->reltab += vars->relcount; | 523 | 5.86k | vars->int_reltab += vars->relcount; | 524 | 5.86k | vars->relcount = 0; | 525 | | | 526 | 5.86k | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 527 | 5.86k | } |
|
528 | | |
529 | | /* Create a global symbol and add it to the relevant tables. */ |
530 | | |
531 | | static void |
532 | | pe_ILF_make_a_symbol (pe_ILF_vars * vars, |
533 | | const char * prefix, |
534 | | const char * symbol_name, |
535 | | asection_ptr section, |
536 | | flagword extra_flags) |
537 | 93.8k | { |
538 | 93.8k | coff_symbol_type * sym; |
539 | 93.8k | combined_entry_type * ent; |
540 | 93.8k | SYMENT * esym; |
541 | 93.8k | unsigned short sclass; |
542 | | |
543 | 93.8k | if (extra_flags & BSF_LOCAL) |
544 | 52.7k | sclass = C_STAT; |
545 | 41.0k | else |
546 | 41.0k | sclass = C_EXT; |
547 | | |
548 | | #ifdef THUMBPEMAGIC |
549 | 20.8k | if (vars->magic == THUMBPEMAGIC) |
550 | 5.42k | { |
551 | 5.42k | if (extra_flags & BSF_FUNCTION) |
552 | 519 | sclass = C_THUMBEXTFUNC; |
553 | 4.90k | else if (extra_flags & BSF_LOCAL) |
554 | 3.06k | sclass = C_THUMBSTAT; |
555 | 1.83k | else |
556 | 1.83k | sclass = C_THUMBEXT; |
557 | 5.42k | } |
558 | | #endif |
559 | | |
560 | 93.8k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); |
561 | | |
562 | 93.8k | sym = vars->sym_ptr; |
563 | 93.8k | ent = vars->native_ptr; |
564 | 93.8k | esym = vars->esym_ptr; |
565 | | |
566 | | /* Copy the symbol's name into the string table. */ |
567 | 93.8k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); |
568 | | |
569 | 93.8k | if (section == NULL) |
570 | 15.7k | section = bfd_und_section_ptr; |
571 | | |
572 | | /* Initialise the external symbol. */ |
573 | 93.8k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, |
574 | 93.8k | esym->e.e.e_offset); |
575 | 93.8k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); |
576 | 93.8k | esym->e_sclass[0] = sclass; |
577 | | |
578 | | /* The following initialisations are unnecessary - the memory is |
579 | | zero initialised. They are just kept here as reminders. */ |
580 | | |
581 | | /* Initialise the internal symbol structure. */ |
582 | 93.8k | ent->u.syment.n_sclass = sclass; |
583 | 93.8k | ent->u.syment.n_scnum = section->target_index; |
584 | 93.8k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; |
585 | 93.8k | ent->is_sym = true; |
586 | | |
587 | 93.8k | sym->symbol.the_bfd = vars->abfd; |
588 | 93.8k | sym->symbol.name = vars->string_ptr; |
589 | 93.8k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; |
590 | 93.8k | sym->symbol.section = section; |
591 | 93.8k | sym->native = ent; |
592 | | |
593 | 93.8k | * vars->table_ptr = vars->sym_index; |
594 | 93.8k | * vars->sym_ptr_ptr = sym; |
595 | | |
596 | | /* Adjust pointers for the next symbol. */ |
597 | 93.8k | vars->sym_index ++; |
598 | 93.8k | vars->sym_ptr ++; |
599 | 93.8k | vars->sym_ptr_ptr ++; |
600 | 93.8k | vars->table_ptr ++; |
601 | 93.8k | vars->native_ptr ++; |
602 | 93.8k | vars->esym_ptr ++; |
603 | 93.8k | vars->string_ptr += len + 1; |
604 | | |
605 | 93.8k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); |
606 | 93.8k | } pei-i386.c:pe_ILF_make_a_symbol Line | Count | Source | 537 | 12.6k | { | 538 | 12.6k | coff_symbol_type * sym; | 539 | 12.6k | combined_entry_type * ent; | 540 | 12.6k | SYMENT * esym; | 541 | 12.6k | unsigned short sclass; | 542 | | | 543 | 12.6k | if (extra_flags & BSF_LOCAL) | 544 | 6.86k | sclass = C_STAT; | 545 | 5.75k | else | 546 | 5.75k | sclass = C_EXT; | 547 | | | 548 | | #ifdef THUMBPEMAGIC | 549 | | if (vars->magic == THUMBPEMAGIC) | 550 | | { | 551 | | if (extra_flags & BSF_FUNCTION) | 552 | | sclass = C_THUMBEXTFUNC; | 553 | | else if (extra_flags & BSF_LOCAL) | 554 | | sclass = C_THUMBSTAT; | 555 | | else | 556 | | sclass = C_THUMBEXT; | 557 | | } | 558 | | #endif | 559 | | | 560 | 12.6k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 561 | | | 562 | 12.6k | sym = vars->sym_ptr; | 563 | 12.6k | ent = vars->native_ptr; | 564 | 12.6k | esym = vars->esym_ptr; | 565 | | | 566 | | /* Copy the symbol's name into the string table. */ | 567 | 12.6k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 568 | | | 569 | 12.6k | if (section == NULL) | 570 | 2.07k | section = bfd_und_section_ptr; | 571 | | | 572 | | /* Initialise the external symbol. */ | 573 | 12.6k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 574 | 12.6k | esym->e.e.e_offset); | 575 | 12.6k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 576 | 12.6k | esym->e_sclass[0] = sclass; | 577 | | | 578 | | /* The following initialisations are unnecessary - the memory is | 579 | | zero initialised. They are just kept here as reminders. */ | 580 | | | 581 | | /* Initialise the internal symbol structure. */ | 582 | 12.6k | ent->u.syment.n_sclass = sclass; | 583 | 12.6k | ent->u.syment.n_scnum = section->target_index; | 584 | 12.6k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 585 | 12.6k | ent->is_sym = true; | 586 | | | 587 | 12.6k | sym->symbol.the_bfd = vars->abfd; | 588 | 12.6k | sym->symbol.name = vars->string_ptr; | 589 | 12.6k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 590 | 12.6k | sym->symbol.section = section; | 591 | 12.6k | sym->native = ent; | 592 | | | 593 | 12.6k | * vars->table_ptr = vars->sym_index; | 594 | 12.6k | * vars->sym_ptr_ptr = sym; | 595 | | | 596 | | /* Adjust pointers for the next symbol. */ | 597 | 12.6k | vars->sym_index ++; | 598 | 12.6k | vars->sym_ptr ++; | 599 | 12.6k | vars->sym_ptr_ptr ++; | 600 | 12.6k | vars->table_ptr ++; | 601 | 12.6k | vars->native_ptr ++; | 602 | 12.6k | vars->esym_ptr ++; | 603 | 12.6k | vars->string_ptr += len + 1; | 604 | | | 605 | 12.6k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 606 | 12.6k | } |
pei-x86_64.c:pe_ILF_make_a_symbol Line | Count | Source | 537 | 22.7k | { | 538 | 22.7k | coff_symbol_type * sym; | 539 | 22.7k | combined_entry_type * ent; | 540 | 22.7k | SYMENT * esym; | 541 | 22.7k | unsigned short sclass; | 542 | | | 543 | 22.7k | if (extra_flags & BSF_LOCAL) | 544 | 12.8k | sclass = C_STAT; | 545 | 9.93k | else | 546 | 9.93k | sclass = C_EXT; | 547 | | | 548 | | #ifdef THUMBPEMAGIC | 549 | | if (vars->magic == THUMBPEMAGIC) | 550 | | { | 551 | | if (extra_flags & BSF_FUNCTION) | 552 | | sclass = C_THUMBEXTFUNC; | 553 | | else if (extra_flags & BSF_LOCAL) | 554 | | sclass = C_THUMBSTAT; | 555 | | else | 556 | | sclass = C_THUMBEXT; | 557 | | } | 558 | | #endif | 559 | | | 560 | 22.7k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 561 | | | 562 | 22.7k | sym = vars->sym_ptr; | 563 | 22.7k | ent = vars->native_ptr; | 564 | 22.7k | esym = vars->esym_ptr; | 565 | | | 566 | | /* Copy the symbol's name into the string table. */ | 567 | 22.7k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 568 | | | 569 | 22.7k | if (section == NULL) | 570 | 3.81k | section = bfd_und_section_ptr; | 571 | | | 572 | | /* Initialise the external symbol. */ | 573 | 22.7k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 574 | 22.7k | esym->e.e.e_offset); | 575 | 22.7k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 576 | 22.7k | esym->e_sclass[0] = sclass; | 577 | | | 578 | | /* The following initialisations are unnecessary - the memory is | 579 | | zero initialised. They are just kept here as reminders. */ | 580 | | | 581 | | /* Initialise the internal symbol structure. */ | 582 | 22.7k | ent->u.syment.n_sclass = sclass; | 583 | 22.7k | ent->u.syment.n_scnum = section->target_index; | 584 | 22.7k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 585 | 22.7k | ent->is_sym = true; | 586 | | | 587 | 22.7k | sym->symbol.the_bfd = vars->abfd; | 588 | 22.7k | sym->symbol.name = vars->string_ptr; | 589 | 22.7k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 590 | 22.7k | sym->symbol.section = section; | 591 | 22.7k | sym->native = ent; | 592 | | | 593 | 22.7k | * vars->table_ptr = vars->sym_index; | 594 | 22.7k | * vars->sym_ptr_ptr = sym; | 595 | | | 596 | | /* Adjust pointers for the next symbol. */ | 597 | 22.7k | vars->sym_index ++; | 598 | 22.7k | vars->sym_ptr ++; | 599 | 22.7k | vars->sym_ptr_ptr ++; | 600 | 22.7k | vars->table_ptr ++; | 601 | 22.7k | vars->native_ptr ++; | 602 | 22.7k | vars->esym_ptr ++; | 603 | 22.7k | vars->string_ptr += len + 1; | 604 | | | 605 | 22.7k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 606 | 22.7k | } |
pei-aarch64.c:pe_ILF_make_a_symbol Line | Count | Source | 537 | 12.0k | { | 538 | 12.0k | coff_symbol_type * sym; | 539 | 12.0k | combined_entry_type * ent; | 540 | 12.0k | SYMENT * esym; | 541 | 12.0k | unsigned short sclass; | 542 | | | 543 | 12.0k | if (extra_flags & BSF_LOCAL) | 544 | 6.83k | sclass = C_STAT; | 545 | 5.25k | else | 546 | 5.25k | sclass = C_EXT; | 547 | | | 548 | | #ifdef THUMBPEMAGIC | 549 | | if (vars->magic == THUMBPEMAGIC) | 550 | | { | 551 | | if (extra_flags & BSF_FUNCTION) | 552 | | sclass = C_THUMBEXTFUNC; | 553 | | else if (extra_flags & BSF_LOCAL) | 554 | | sclass = C_THUMBSTAT; | 555 | | else | 556 | | sclass = C_THUMBEXT; | 557 | | } | 558 | | #endif | 559 | | | 560 | 12.0k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 561 | | | 562 | 12.0k | sym = vars->sym_ptr; | 563 | 12.0k | ent = vars->native_ptr; | 564 | 12.0k | esym = vars->esym_ptr; | 565 | | | 566 | | /* Copy the symbol's name into the string table. */ | 567 | 12.0k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 568 | | | 569 | 12.0k | if (section == NULL) | 570 | 2.27k | section = bfd_und_section_ptr; | 571 | | | 572 | | /* Initialise the external symbol. */ | 573 | 12.0k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 574 | 12.0k | esym->e.e.e_offset); | 575 | 12.0k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 576 | 12.0k | esym->e_sclass[0] = sclass; | 577 | | | 578 | | /* The following initialisations are unnecessary - the memory is | 579 | | zero initialised. They are just kept here as reminders. */ | 580 | | | 581 | | /* Initialise the internal symbol structure. */ | 582 | 12.0k | ent->u.syment.n_sclass = sclass; | 583 | 12.0k | ent->u.syment.n_scnum = section->target_index; | 584 | 12.0k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 585 | 12.0k | ent->is_sym = true; | 586 | | | 587 | 12.0k | sym->symbol.the_bfd = vars->abfd; | 588 | 12.0k | sym->symbol.name = vars->string_ptr; | 589 | 12.0k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 590 | 12.0k | sym->symbol.section = section; | 591 | 12.0k | sym->native = ent; | 592 | | | 593 | 12.0k | * vars->table_ptr = vars->sym_index; | 594 | 12.0k | * vars->sym_ptr_ptr = sym; | 595 | | | 596 | | /* Adjust pointers for the next symbol. */ | 597 | 12.0k | vars->sym_index ++; | 598 | 12.0k | vars->sym_ptr ++; | 599 | 12.0k | vars->sym_ptr_ptr ++; | 600 | 12.0k | vars->table_ptr ++; | 601 | 12.0k | vars->native_ptr ++; | 602 | 12.0k | vars->esym_ptr ++; | 603 | 12.0k | vars->string_ptr += len + 1; | 604 | | | 605 | 12.0k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 606 | 12.0k | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_symbol pei-loongarch64.c:pe_ILF_make_a_symbol Line | Count | Source | 537 | 7.80k | { | 538 | 7.80k | coff_symbol_type * sym; | 539 | 7.80k | combined_entry_type * ent; | 540 | 7.80k | SYMENT * esym; | 541 | 7.80k | unsigned short sclass; | 542 | | | 543 | 7.80k | if (extra_flags & BSF_LOCAL) | 544 | 4.53k | sclass = C_STAT; | 545 | 3.26k | else | 546 | 3.26k | sclass = C_EXT; | 547 | | | 548 | | #ifdef THUMBPEMAGIC | 549 | | if (vars->magic == THUMBPEMAGIC) | 550 | | { | 551 | | if (extra_flags & BSF_FUNCTION) | 552 | | sclass = C_THUMBEXTFUNC; | 553 | | else if (extra_flags & BSF_LOCAL) | 554 | | sclass = C_THUMBSTAT; | 555 | | else | 556 | | sclass = C_THUMBEXT; | 557 | | } | 558 | | #endif | 559 | | | 560 | 7.80k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 561 | | | 562 | 7.80k | sym = vars->sym_ptr; | 563 | 7.80k | ent = vars->native_ptr; | 564 | 7.80k | esym = vars->esym_ptr; | 565 | | | 566 | | /* Copy the symbol's name into the string table. */ | 567 | 7.80k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 568 | | | 569 | 7.80k | if (section == NULL) | 570 | 1.33k | section = bfd_und_section_ptr; | 571 | | | 572 | | /* Initialise the external symbol. */ | 573 | 7.80k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 574 | 7.80k | esym->e.e.e_offset); | 575 | 7.80k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 576 | 7.80k | esym->e_sclass[0] = sclass; | 577 | | | 578 | | /* The following initialisations are unnecessary - the memory is | 579 | | zero initialised. They are just kept here as reminders. */ | 580 | | | 581 | | /* Initialise the internal symbol structure. */ | 582 | 7.80k | ent->u.syment.n_sclass = sclass; | 583 | 7.80k | ent->u.syment.n_scnum = section->target_index; | 584 | 7.80k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 585 | 7.80k | ent->is_sym = true; | 586 | | | 587 | 7.80k | sym->symbol.the_bfd = vars->abfd; | 588 | 7.80k | sym->symbol.name = vars->string_ptr; | 589 | 7.80k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 590 | 7.80k | sym->symbol.section = section; | 591 | 7.80k | sym->native = ent; | 592 | | | 593 | 7.80k | * vars->table_ptr = vars->sym_index; | 594 | 7.80k | * vars->sym_ptr_ptr = sym; | 595 | | | 596 | | /* Adjust pointers for the next symbol. */ | 597 | 7.80k | vars->sym_index ++; | 598 | 7.80k | vars->sym_ptr ++; | 599 | 7.80k | vars->sym_ptr_ptr ++; | 600 | 7.80k | vars->table_ptr ++; | 601 | 7.80k | vars->native_ptr ++; | 602 | 7.80k | vars->esym_ptr ++; | 603 | 7.80k | vars->string_ptr += len + 1; | 604 | | | 605 | 7.80k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 606 | 7.80k | } |
pei-arm-wince.c:pe_ILF_make_a_symbol Line | Count | Source | 537 | 920 | { | 538 | 920 | coff_symbol_type * sym; | 539 | 920 | combined_entry_type * ent; | 540 | 920 | SYMENT * esym; | 541 | 920 | unsigned short sclass; | 542 | | | 543 | 920 | if (extra_flags & BSF_LOCAL) | 544 | 710 | sclass = C_STAT; | 545 | 210 | else | 546 | 210 | sclass = C_EXT; | 547 | | | 548 | 920 | #ifdef THUMBPEMAGIC | 549 | 920 | if (vars->magic == THUMBPEMAGIC) | 550 | 230 | { | 551 | 230 | if (extra_flags & BSF_FUNCTION) | 552 | 21 | sclass = C_THUMBEXTFUNC; | 553 | 209 | else if (extra_flags & BSF_LOCAL) | 554 | 139 | sclass = C_THUMBSTAT; | 555 | 70 | else | 556 | 70 | sclass = C_THUMBEXT; | 557 | 230 | } | 558 | 920 | #endif | 559 | | | 560 | 920 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 561 | | | 562 | 920 | sym = vars->sym_ptr; | 563 | 920 | ent = vars->native_ptr; | 564 | 920 | esym = vars->esym_ptr; | 565 | | | 566 | | /* Copy the symbol's name into the string table. */ | 567 | 920 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 568 | | | 569 | 920 | if (section == NULL) | 570 | 80 | section = bfd_und_section_ptr; | 571 | | | 572 | | /* Initialise the external symbol. */ | 573 | 920 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 574 | 920 | esym->e.e.e_offset); | 575 | 920 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 576 | 920 | esym->e_sclass[0] = sclass; | 577 | | | 578 | | /* The following initialisations are unnecessary - the memory is | 579 | | zero initialised. They are just kept here as reminders. */ | 580 | | | 581 | | /* Initialise the internal symbol structure. */ | 582 | 920 | ent->u.syment.n_sclass = sclass; | 583 | 920 | ent->u.syment.n_scnum = section->target_index; | 584 | 920 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 585 | 920 | ent->is_sym = true; | 586 | | | 587 | 920 | sym->symbol.the_bfd = vars->abfd; | 588 | 920 | sym->symbol.name = vars->string_ptr; | 589 | 920 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 590 | 920 | sym->symbol.section = section; | 591 | 920 | sym->native = ent; | 592 | | | 593 | 920 | * vars->table_ptr = vars->sym_index; | 594 | 920 | * vars->sym_ptr_ptr = sym; | 595 | | | 596 | | /* Adjust pointers for the next symbol. */ | 597 | 920 | vars->sym_index ++; | 598 | 920 | vars->sym_ptr ++; | 599 | 920 | vars->sym_ptr_ptr ++; | 600 | 920 | vars->table_ptr ++; | 601 | 920 | vars->native_ptr ++; | 602 | 920 | vars->esym_ptr ++; | 603 | 920 | vars->string_ptr += len + 1; | 604 | | | 605 | 920 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 606 | 920 | } |
pei-arm.c:pe_ILF_make_a_symbol Line | Count | Source | 537 | 19.9k | { | 538 | 19.9k | coff_symbol_type * sym; | 539 | 19.9k | combined_entry_type * ent; | 540 | 19.9k | SYMENT * esym; | 541 | 19.9k | unsigned short sclass; | 542 | | | 543 | 19.9k | if (extra_flags & BSF_LOCAL) | 544 | 11.0k | sclass = C_STAT; | 545 | 8.89k | else | 546 | 8.89k | sclass = C_EXT; | 547 | | | 548 | 19.9k | #ifdef THUMBPEMAGIC | 549 | 19.9k | if (vars->magic == THUMBPEMAGIC) | 550 | 5.19k | { | 551 | 5.19k | if (extra_flags & BSF_FUNCTION) | 552 | 498 | sclass = C_THUMBEXTFUNC; | 553 | 4.69k | else if (extra_flags & BSF_LOCAL) | 554 | 2.92k | sclass = C_THUMBSTAT; | 555 | 1.76k | else | 556 | 1.76k | sclass = C_THUMBEXT; | 557 | 5.19k | } | 558 | 19.9k | #endif | 559 | | | 560 | 19.9k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 561 | | | 562 | 19.9k | sym = vars->sym_ptr; | 563 | 19.9k | ent = vars->native_ptr; | 564 | 19.9k | esym = vars->esym_ptr; | 565 | | | 566 | | /* Copy the symbol's name into the string table. */ | 567 | 19.9k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 568 | | | 569 | 19.9k | if (section == NULL) | 570 | 3.32k | section = bfd_und_section_ptr; | 571 | | | 572 | | /* Initialise the external symbol. */ | 573 | 19.9k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 574 | 19.9k | esym->e.e.e_offset); | 575 | 19.9k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 576 | 19.9k | esym->e_sclass[0] = sclass; | 577 | | | 578 | | /* The following initialisations are unnecessary - the memory is | 579 | | zero initialised. They are just kept here as reminders. */ | 580 | | | 581 | | /* Initialise the internal symbol structure. */ | 582 | 19.9k | ent->u.syment.n_sclass = sclass; | 583 | 19.9k | ent->u.syment.n_scnum = section->target_index; | 584 | 19.9k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 585 | 19.9k | ent->is_sym = true; | 586 | | | 587 | 19.9k | sym->symbol.the_bfd = vars->abfd; | 588 | 19.9k | sym->symbol.name = vars->string_ptr; | 589 | 19.9k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 590 | 19.9k | sym->symbol.section = section; | 591 | 19.9k | sym->native = ent; | 592 | | | 593 | 19.9k | * vars->table_ptr = vars->sym_index; | 594 | 19.9k | * vars->sym_ptr_ptr = sym; | 595 | | | 596 | | /* Adjust pointers for the next symbol. */ | 597 | 19.9k | vars->sym_index ++; | 598 | 19.9k | vars->sym_ptr ++; | 599 | 19.9k | vars->sym_ptr_ptr ++; | 600 | 19.9k | vars->table_ptr ++; | 601 | 19.9k | vars->native_ptr ++; | 602 | 19.9k | vars->esym_ptr ++; | 603 | 19.9k | vars->string_ptr += len + 1; | 604 | | | 605 | 19.9k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 606 | 19.9k | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_symbol pei-sh.c:pe_ILF_make_a_symbol Line | Count | Source | 537 | 17.6k | { | 538 | 17.6k | coff_symbol_type * sym; | 539 | 17.6k | combined_entry_type * ent; | 540 | 17.6k | SYMENT * esym; | 541 | 17.6k | unsigned short sclass; | 542 | | | 543 | 17.6k | if (extra_flags & BSF_LOCAL) | 544 | 9.90k | sclass = C_STAT; | 545 | 7.74k | else | 546 | 7.74k | sclass = C_EXT; | 547 | | | 548 | | #ifdef THUMBPEMAGIC | 549 | | if (vars->magic == THUMBPEMAGIC) | 550 | | { | 551 | | if (extra_flags & BSF_FUNCTION) | 552 | | sclass = C_THUMBEXTFUNC; | 553 | | else if (extra_flags & BSF_LOCAL) | 554 | | sclass = C_THUMBSTAT; | 555 | | else | 556 | | sclass = C_THUMBEXT; | 557 | | } | 558 | | #endif | 559 | | | 560 | 17.6k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 561 | | | 562 | 17.6k | sym = vars->sym_ptr; | 563 | 17.6k | ent = vars->native_ptr; | 564 | 17.6k | esym = vars->esym_ptr; | 565 | | | 566 | | /* Copy the symbol's name into the string table. */ | 567 | 17.6k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 568 | | | 569 | 17.6k | if (section == NULL) | 570 | 2.86k | section = bfd_und_section_ptr; | 571 | | | 572 | | /* Initialise the external symbol. */ | 573 | 17.6k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 574 | 17.6k | esym->e.e.e_offset); | 575 | 17.6k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 576 | 17.6k | esym->e_sclass[0] = sclass; | 577 | | | 578 | | /* The following initialisations are unnecessary - the memory is | 579 | | zero initialised. They are just kept here as reminders. */ | 580 | | | 581 | | /* Initialise the internal symbol structure. */ | 582 | 17.6k | ent->u.syment.n_sclass = sclass; | 583 | 17.6k | ent->u.syment.n_scnum = section->target_index; | 584 | 17.6k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 585 | 17.6k | ent->is_sym = true; | 586 | | | 587 | 17.6k | sym->symbol.the_bfd = vars->abfd; | 588 | 17.6k | sym->symbol.name = vars->string_ptr; | 589 | 17.6k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 590 | 17.6k | sym->symbol.section = section; | 591 | 17.6k | sym->native = ent; | 592 | | | 593 | 17.6k | * vars->table_ptr = vars->sym_index; | 594 | 17.6k | * vars->sym_ptr_ptr = sym; | 595 | | | 596 | | /* Adjust pointers for the next symbol. */ | 597 | 17.6k | vars->sym_index ++; | 598 | 17.6k | vars->sym_ptr ++; | 599 | 17.6k | vars->sym_ptr_ptr ++; | 600 | 17.6k | vars->table_ptr ++; | 601 | 17.6k | vars->native_ptr ++; | 602 | 17.6k | vars->esym_ptr ++; | 603 | 17.6k | vars->string_ptr += len + 1; | 604 | | | 605 | 17.6k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 606 | 17.6k | } |
|
607 | | |
608 | | /* Create a section. */ |
609 | | |
610 | | static asection_ptr |
611 | | pe_ILF_make_a_section (pe_ILF_vars * vars, |
612 | | const char * name, |
613 | | unsigned int size, |
614 | | flagword extra_flags) |
615 | 52.7k | { |
616 | 52.7k | asection_ptr sec; |
617 | 52.7k | flagword flags; |
618 | 52.7k | intptr_t alignment; |
619 | | |
620 | 52.7k | sec = bfd_make_section_old_way (vars->abfd, name); |
621 | 52.7k | if (sec == NULL) |
622 | 0 | return NULL; |
623 | | |
624 | 52.7k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; |
625 | | |
626 | 52.7k | bfd_set_section_flags (sec, flags | extra_flags); |
627 | | |
628 | 52.7k | bfd_set_section_alignment (sec, 2); |
629 | | |
630 | | /* Check that we will not run out of space. */ |
631 | 52.7k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); |
632 | | |
633 | | /* Set the section size and contents. The actual |
634 | | contents are filled in by our parent. */ |
635 | 52.7k | bfd_set_section_size (sec, (bfd_size_type) size); |
636 | 52.7k | sec->contents = vars->data; |
637 | 52.7k | sec->target_index = vars->sec_index ++; |
638 | | |
639 | | /* Advance data pointer in the vars structure. */ |
640 | 52.7k | vars->data += size; |
641 | | |
642 | | /* Skip the padding byte if it was not needed. |
643 | | The logic here is that if the string length is odd, |
644 | | then the entire string length, including the null byte, |
645 | | is even and so the extra, padding byte, is not needed. */ |
646 | 52.7k | if (size & 1) |
647 | 5.18k | vars->data --; |
648 | | |
649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we |
650 | | preserve host alignment requirements. The BFD_ASSERTs in this |
651 | | functions will warn us if we run out of room, but we should |
652 | | already have enough padding built in to ILF_DATA_SIZE. */ |
653 | 52.7k | #if GCC_VERSION >= 3000 |
654 | 52.7k | alignment = __alignof__ (struct coff_section_tdata); |
655 | | #else |
656 | | alignment = 8; |
657 | | #endif |
658 | 52.7k | vars->data |
659 | 52.7k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); |
660 | | |
661 | | /* Create a coff_section_tdata structure for our use. */ |
662 | 52.7k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; |
663 | 52.7k | vars->data += sizeof (struct coff_section_tdata); |
664 | | |
665 | 52.7k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); |
666 | | |
667 | | /* Create a symbol to refer to this section. */ |
668 | 52.7k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); |
669 | | |
670 | | /* Cache the index to the symbol in the coff_section_data structure. */ |
671 | 52.7k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; |
672 | | |
673 | 52.7k | return sec; |
674 | 52.7k | } pei-i386.c:pe_ILF_make_a_section Line | Count | Source | 615 | 6.86k | { | 616 | 6.86k | asection_ptr sec; | 617 | 6.86k | flagword flags; | 618 | 6.86k | intptr_t alignment; | 619 | | | 620 | 6.86k | sec = bfd_make_section_old_way (vars->abfd, name); | 621 | 6.86k | if (sec == NULL) | 622 | 0 | return NULL; | 623 | | | 624 | 6.86k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 625 | | | 626 | 6.86k | bfd_set_section_flags (sec, flags | extra_flags); | 627 | | | 628 | 6.86k | bfd_set_section_alignment (sec, 2); | 629 | | | 630 | | /* Check that we will not run out of space. */ | 631 | 6.86k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 632 | | | 633 | | /* Set the section size and contents. The actual | 634 | | contents are filled in by our parent. */ | 635 | 6.86k | bfd_set_section_size (sec, (bfd_size_type) size); | 636 | 6.86k | sec->contents = vars->data; | 637 | 6.86k | sec->target_index = vars->sec_index ++; | 638 | | | 639 | | /* Advance data pointer in the vars structure. */ | 640 | 6.86k | vars->data += size; | 641 | | | 642 | | /* Skip the padding byte if it was not needed. | 643 | | The logic here is that if the string length is odd, | 644 | | then the entire string length, including the null byte, | 645 | | is even and so the extra, padding byte, is not needed. */ | 646 | 6.86k | if (size & 1) | 647 | 658 | vars->data --; | 648 | | | 649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 650 | | preserve host alignment requirements. The BFD_ASSERTs in this | 651 | | functions will warn us if we run out of room, but we should | 652 | | already have enough padding built in to ILF_DATA_SIZE. */ | 653 | 6.86k | #if GCC_VERSION >= 3000 | 654 | 6.86k | alignment = __alignof__ (struct coff_section_tdata); | 655 | | #else | 656 | | alignment = 8; | 657 | | #endif | 658 | 6.86k | vars->data | 659 | 6.86k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 660 | | | 661 | | /* Create a coff_section_tdata structure for our use. */ | 662 | 6.86k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 663 | 6.86k | vars->data += sizeof (struct coff_section_tdata); | 664 | | | 665 | 6.86k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 666 | | | 667 | | /* Create a symbol to refer to this section. */ | 668 | 6.86k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 669 | | | 670 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 671 | 6.86k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 672 | | | 673 | 6.86k | return sec; | 674 | 6.86k | } |
pei-x86_64.c:pe_ILF_make_a_section Line | Count | Source | 615 | 12.8k | { | 616 | 12.8k | asection_ptr sec; | 617 | 12.8k | flagword flags; | 618 | 12.8k | intptr_t alignment; | 619 | | | 620 | 12.8k | sec = bfd_make_section_old_way (vars->abfd, name); | 621 | 12.8k | if (sec == NULL) | 622 | 0 | return NULL; | 623 | | | 624 | 12.8k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 625 | | | 626 | 12.8k | bfd_set_section_flags (sec, flags | extra_flags); | 627 | | | 628 | 12.8k | bfd_set_section_alignment (sec, 2); | 629 | | | 630 | | /* Check that we will not run out of space. */ | 631 | 12.8k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 632 | | | 633 | | /* Set the section size and contents. The actual | 634 | | contents are filled in by our parent. */ | 635 | 12.8k | bfd_set_section_size (sec, (bfd_size_type) size); | 636 | 12.8k | sec->contents = vars->data; | 637 | 12.8k | sec->target_index = vars->sec_index ++; | 638 | | | 639 | | /* Advance data pointer in the vars structure. */ | 640 | 12.8k | vars->data += size; | 641 | | | 642 | | /* Skip the padding byte if it was not needed. | 643 | | The logic here is that if the string length is odd, | 644 | | then the entire string length, including the null byte, | 645 | | is even and so the extra, padding byte, is not needed. */ | 646 | 12.8k | if (size & 1) | 647 | 1.13k | vars->data --; | 648 | | | 649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 650 | | preserve host alignment requirements. The BFD_ASSERTs in this | 651 | | functions will warn us if we run out of room, but we should | 652 | | already have enough padding built in to ILF_DATA_SIZE. */ | 653 | 12.8k | #if GCC_VERSION >= 3000 | 654 | 12.8k | alignment = __alignof__ (struct coff_section_tdata); | 655 | | #else | 656 | | alignment = 8; | 657 | | #endif | 658 | 12.8k | vars->data | 659 | 12.8k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 660 | | | 661 | | /* Create a coff_section_tdata structure for our use. */ | 662 | 12.8k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 663 | 12.8k | vars->data += sizeof (struct coff_section_tdata); | 664 | | | 665 | 12.8k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 666 | | | 667 | | /* Create a symbol to refer to this section. */ | 668 | 12.8k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 669 | | | 670 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 671 | 12.8k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 672 | | | 673 | 12.8k | return sec; | 674 | 12.8k | } |
pei-aarch64.c:pe_ILF_make_a_section Line | Count | Source | 615 | 6.83k | { | 616 | 6.83k | asection_ptr sec; | 617 | 6.83k | flagword flags; | 618 | 6.83k | intptr_t alignment; | 619 | | | 620 | 6.83k | sec = bfd_make_section_old_way (vars->abfd, name); | 621 | 6.83k | if (sec == NULL) | 622 | 0 | return NULL; | 623 | | | 624 | 6.83k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 625 | | | 626 | 6.83k | bfd_set_section_flags (sec, flags | extra_flags); | 627 | | | 628 | 6.83k | bfd_set_section_alignment (sec, 2); | 629 | | | 630 | | /* Check that we will not run out of space. */ | 631 | 6.83k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 632 | | | 633 | | /* Set the section size and contents. The actual | 634 | | contents are filled in by our parent. */ | 635 | 6.83k | bfd_set_section_size (sec, (bfd_size_type) size); | 636 | 6.83k | sec->contents = vars->data; | 637 | 6.83k | sec->target_index = vars->sec_index ++; | 638 | | | 639 | | /* Advance data pointer in the vars structure. */ | 640 | 6.83k | vars->data += size; | 641 | | | 642 | | /* Skip the padding byte if it was not needed. | 643 | | The logic here is that if the string length is odd, | 644 | | then the entire string length, including the null byte, | 645 | | is even and so the extra, padding byte, is not needed. */ | 646 | 6.83k | if (size & 1) | 647 | 1.09k | vars->data --; | 648 | | | 649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 650 | | preserve host alignment requirements. The BFD_ASSERTs in this | 651 | | functions will warn us if we run out of room, but we should | 652 | | already have enough padding built in to ILF_DATA_SIZE. */ | 653 | 6.83k | #if GCC_VERSION >= 3000 | 654 | 6.83k | alignment = __alignof__ (struct coff_section_tdata); | 655 | | #else | 656 | | alignment = 8; | 657 | | #endif | 658 | 6.83k | vars->data | 659 | 6.83k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 660 | | | 661 | | /* Create a coff_section_tdata structure for our use. */ | 662 | 6.83k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 663 | 6.83k | vars->data += sizeof (struct coff_section_tdata); | 664 | | | 665 | 6.83k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 666 | | | 667 | | /* Create a symbol to refer to this section. */ | 668 | 6.83k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 669 | | | 670 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 671 | 6.83k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 672 | | | 673 | 6.83k | return sec; | 674 | 6.83k | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_section pei-loongarch64.c:pe_ILF_make_a_section Line | Count | Source | 615 | 4.53k | { | 616 | 4.53k | asection_ptr sec; | 617 | 4.53k | flagword flags; | 618 | 4.53k | intptr_t alignment; | 619 | | | 620 | 4.53k | sec = bfd_make_section_old_way (vars->abfd, name); | 621 | 4.53k | if (sec == NULL) | 622 | 0 | return NULL; | 623 | | | 624 | 4.53k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 625 | | | 626 | 4.53k | bfd_set_section_flags (sec, flags | extra_flags); | 627 | | | 628 | 4.53k | bfd_set_section_alignment (sec, 2); | 629 | | | 630 | | /* Check that we will not run out of space. */ | 631 | 4.53k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 632 | | | 633 | | /* Set the section size and contents. The actual | 634 | | contents are filled in by our parent. */ | 635 | 4.53k | bfd_set_section_size (sec, (bfd_size_type) size); | 636 | 4.53k | sec->contents = vars->data; | 637 | 4.53k | sec->target_index = vars->sec_index ++; | 638 | | | 639 | | /* Advance data pointer in the vars structure. */ | 640 | 4.53k | vars->data += size; | 641 | | | 642 | | /* Skip the padding byte if it was not needed. | 643 | | The logic here is that if the string length is odd, | 644 | | then the entire string length, including the null byte, | 645 | | is even and so the extra, padding byte, is not needed. */ | 646 | 4.53k | if (size & 1) | 647 | 219 | vars->data --; | 648 | | | 649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 650 | | preserve host alignment requirements. The BFD_ASSERTs in this | 651 | | functions will warn us if we run out of room, but we should | 652 | | already have enough padding built in to ILF_DATA_SIZE. */ | 653 | 4.53k | #if GCC_VERSION >= 3000 | 654 | 4.53k | alignment = __alignof__ (struct coff_section_tdata); | 655 | | #else | 656 | | alignment = 8; | 657 | | #endif | 658 | 4.53k | vars->data | 659 | 4.53k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 660 | | | 661 | | /* Create a coff_section_tdata structure for our use. */ | 662 | 4.53k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 663 | 4.53k | vars->data += sizeof (struct coff_section_tdata); | 664 | | | 665 | 4.53k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 666 | | | 667 | | /* Create a symbol to refer to this section. */ | 668 | 4.53k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 669 | | | 670 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 671 | 4.53k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 672 | | | 673 | 4.53k | return sec; | 674 | 4.53k | } |
pei-arm-wince.c:pe_ILF_make_a_section Line | Count | Source | 615 | 710 | { | 616 | 710 | asection_ptr sec; | 617 | 710 | flagword flags; | 618 | 710 | intptr_t alignment; | 619 | | | 620 | 710 | sec = bfd_make_section_old_way (vars->abfd, name); | 621 | 710 | if (sec == NULL) | 622 | 0 | return NULL; | 623 | | | 624 | 710 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 625 | | | 626 | 710 | bfd_set_section_flags (sec, flags | extra_flags); | 627 | | | 628 | 710 | bfd_set_section_alignment (sec, 2); | 629 | | | 630 | | /* Check that we will not run out of space. */ | 631 | 710 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 632 | | | 633 | | /* Set the section size and contents. The actual | 634 | | contents are filled in by our parent. */ | 635 | 710 | bfd_set_section_size (sec, (bfd_size_type) size); | 636 | 710 | sec->contents = vars->data; | 637 | 710 | sec->target_index = vars->sec_index ++; | 638 | | | 639 | | /* Advance data pointer in the vars structure. */ | 640 | 710 | vars->data += size; | 641 | | | 642 | | /* Skip the padding byte if it was not needed. | 643 | | The logic here is that if the string length is odd, | 644 | | then the entire string length, including the null byte, | 645 | | is even and so the extra, padding byte, is not needed. */ | 646 | 710 | if (size & 1) | 647 | 30 | vars->data --; | 648 | | | 649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 650 | | preserve host alignment requirements. The BFD_ASSERTs in this | 651 | | functions will warn us if we run out of room, but we should | 652 | | already have enough padding built in to ILF_DATA_SIZE. */ | 653 | 710 | #if GCC_VERSION >= 3000 | 654 | 710 | alignment = __alignof__ (struct coff_section_tdata); | 655 | | #else | 656 | | alignment = 8; | 657 | | #endif | 658 | 710 | vars->data | 659 | 710 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 660 | | | 661 | | /* Create a coff_section_tdata structure for our use. */ | 662 | 710 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 663 | 710 | vars->data += sizeof (struct coff_section_tdata); | 664 | | | 665 | 710 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 666 | | | 667 | | /* Create a symbol to refer to this section. */ | 668 | 710 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 669 | | | 670 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 671 | 710 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 672 | | | 673 | 710 | return sec; | 674 | 710 | } |
pei-arm.c:pe_ILF_make_a_section Line | Count | Source | 615 | 11.0k | { | 616 | 11.0k | asection_ptr sec; | 617 | 11.0k | flagword flags; | 618 | 11.0k | intptr_t alignment; | 619 | | | 620 | 11.0k | sec = bfd_make_section_old_way (vars->abfd, name); | 621 | 11.0k | if (sec == NULL) | 622 | 0 | return NULL; | 623 | | | 624 | 11.0k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 625 | | | 626 | 11.0k | bfd_set_section_flags (sec, flags | extra_flags); | 627 | | | 628 | 11.0k | bfd_set_section_alignment (sec, 2); | 629 | | | 630 | | /* Check that we will not run out of space. */ | 631 | 11.0k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 632 | | | 633 | | /* Set the section size and contents. The actual | 634 | | contents are filled in by our parent. */ | 635 | 11.0k | bfd_set_section_size (sec, (bfd_size_type) size); | 636 | 11.0k | sec->contents = vars->data; | 637 | 11.0k | sec->target_index = vars->sec_index ++; | 638 | | | 639 | | /* Advance data pointer in the vars structure. */ | 640 | 11.0k | vars->data += size; | 641 | | | 642 | | /* Skip the padding byte if it was not needed. | 643 | | The logic here is that if the string length is odd, | 644 | | then the entire string length, including the null byte, | 645 | | is even and so the extra, padding byte, is not needed. */ | 646 | 11.0k | if (size & 1) | 647 | 1.21k | vars->data --; | 648 | | | 649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 650 | | preserve host alignment requirements. The BFD_ASSERTs in this | 651 | | functions will warn us if we run out of room, but we should | 652 | | already have enough padding built in to ILF_DATA_SIZE. */ | 653 | 11.0k | #if GCC_VERSION >= 3000 | 654 | 11.0k | alignment = __alignof__ (struct coff_section_tdata); | 655 | | #else | 656 | | alignment = 8; | 657 | | #endif | 658 | 11.0k | vars->data | 659 | 11.0k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 660 | | | 661 | | /* Create a coff_section_tdata structure for our use. */ | 662 | 11.0k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 663 | 11.0k | vars->data += sizeof (struct coff_section_tdata); | 664 | | | 665 | 11.0k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 666 | | | 667 | | /* Create a symbol to refer to this section. */ | 668 | 11.0k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 669 | | | 670 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 671 | 11.0k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 672 | | | 673 | 11.0k | return sec; | 674 | 11.0k | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_section pei-sh.c:pe_ILF_make_a_section Line | Count | Source | 615 | 9.90k | { | 616 | 9.90k | asection_ptr sec; | 617 | 9.90k | flagword flags; | 618 | 9.90k | intptr_t alignment; | 619 | | | 620 | 9.90k | sec = bfd_make_section_old_way (vars->abfd, name); | 621 | 9.90k | if (sec == NULL) | 622 | 0 | return NULL; | 623 | | | 624 | 9.90k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 625 | | | 626 | 9.90k | bfd_set_section_flags (sec, flags | extra_flags); | 627 | | | 628 | 9.90k | bfd_set_section_alignment (sec, 2); | 629 | | | 630 | | /* Check that we will not run out of space. */ | 631 | 9.90k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 632 | | | 633 | | /* Set the section size and contents. The actual | 634 | | contents are filled in by our parent. */ | 635 | 9.90k | bfd_set_section_size (sec, (bfd_size_type) size); | 636 | 9.90k | sec->contents = vars->data; | 637 | 9.90k | sec->target_index = vars->sec_index ++; | 638 | | | 639 | | /* Advance data pointer in the vars structure. */ | 640 | 9.90k | vars->data += size; | 641 | | | 642 | | /* Skip the padding byte if it was not needed. | 643 | | The logic here is that if the string length is odd, | 644 | | then the entire string length, including the null byte, | 645 | | is even and so the extra, padding byte, is not needed. */ | 646 | 9.90k | if (size & 1) | 647 | 848 | vars->data --; | 648 | | | 649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 650 | | preserve host alignment requirements. The BFD_ASSERTs in this | 651 | | functions will warn us if we run out of room, but we should | 652 | | already have enough padding built in to ILF_DATA_SIZE. */ | 653 | 9.90k | #if GCC_VERSION >= 3000 | 654 | 9.90k | alignment = __alignof__ (struct coff_section_tdata); | 655 | | #else | 656 | | alignment = 8; | 657 | | #endif | 658 | 9.90k | vars->data | 659 | 9.90k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 660 | | | 661 | | /* Create a coff_section_tdata structure for our use. */ | 662 | 9.90k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 663 | 9.90k | vars->data += sizeof (struct coff_section_tdata); | 664 | | | 665 | 9.90k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 666 | | | 667 | | /* Create a symbol to refer to this section. */ | 668 | 9.90k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 669 | | | 670 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 671 | 9.90k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 672 | | | 673 | 9.90k | return sec; | 674 | 9.90k | } |
|
675 | | |
676 | | /* This structure contains the code that goes into the .text section |
677 | | in order to perform a jump into the DLL lookup table. The entries |
678 | | in the table are index by the magic number used to represent the |
679 | | machine type in the PE file. The contents of the data[] arrays in |
680 | | these entries are stolen from the jtab[] arrays in ld/pe-dll.c. |
681 | | The SIZE field says how many bytes in the DATA array are actually |
682 | | used. The OFFSET field says where in the data array the address |
683 | | of the .idata$5 section should be placed. */ |
684 | 34.3k | #define MAX_TEXT_SECTION_SIZE 32 |
685 | | |
686 | | typedef struct |
687 | | { |
688 | | unsigned short magic; |
689 | | unsigned char data[MAX_TEXT_SECTION_SIZE]; |
690 | | unsigned int size; |
691 | | unsigned int offset; |
692 | | } |
693 | | jump_table; |
694 | | |
695 | | static const jump_table jtab[] = |
696 | | { |
697 | | #ifdef I386MAGIC |
698 | | { I386MAGIC, |
699 | | { 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90 }, |
700 | | 8, 2 |
701 | | }, |
702 | | #endif |
703 | | |
704 | | #ifdef AMD64MAGIC |
705 | | { AMD64MAGIC, |
706 | | { 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90 }, |
707 | | 8, 2 |
708 | | }, |
709 | | #endif |
710 | | |
711 | | #ifdef MC68MAGIC |
712 | | { MC68MAGIC, |
713 | | { /* XXX fill me in */ }, |
714 | | 0, 0 |
715 | | }, |
716 | | #endif |
717 | | |
718 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
719 | | { MIPS_ARCH_MAGIC_WINCE, |
720 | | { 0x00, 0x00, 0x08, 0x3c, 0x00, 0x00, 0x08, 0x8d, |
721 | | 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }, |
722 | | 16, 0 |
723 | | }, |
724 | | #endif |
725 | | |
726 | | #ifdef SH_ARCH_MAGIC_WINCE |
727 | | { SH_ARCH_MAGIC_WINCE, |
728 | | { 0x01, 0xd0, 0x02, 0x60, 0x2b, 0x40, |
729 | | 0x09, 0x00, 0x00, 0x00, 0x00, 0x00 }, |
730 | | 12, 8 |
731 | | }, |
732 | | #endif |
733 | | |
734 | | #ifdef AARCH64MAGIC |
735 | | /* We don't currently support jumping to DLLs, so if |
736 | | someone does try emit a runtime trap. Through UDF #0. */ |
737 | | { AARCH64MAGIC, |
738 | | { 0x00, 0x00, 0x00, 0x00 }, |
739 | | 4, 0 |
740 | | }, |
741 | | |
742 | | #endif |
743 | | |
744 | | #ifdef ARMPEMAGIC |
745 | | { ARMPEMAGIC, |
746 | | { 0x00, 0xc0, 0x9f, 0xe5, 0x00, 0xf0, |
747 | | 0x9c, 0xe5, 0x00, 0x00, 0x00, 0x00}, |
748 | | 12, 8 |
749 | | }, |
750 | | #endif |
751 | | |
752 | | #ifdef THUMBPEMAGIC |
753 | | { THUMBPEMAGIC, |
754 | | { 0x40, 0xb4, 0x02, 0x4e, 0x36, 0x68, 0xb4, 0x46, |
755 | | 0x40, 0xbc, 0x60, 0x47, 0x00, 0x00, 0x00, 0x00 }, |
756 | | 16, 12 |
757 | | }, |
758 | | #endif |
759 | | |
760 | | #ifdef LOONGARCH64MAGIC |
761 | | /* We don't currently support jumping to DLLs, so if |
762 | | someone does try emit a runtime trap. Through BREAK 0. */ |
763 | | { LOONGARCH64MAGIC, |
764 | | { 0x00, 0x00, 0x2a, 0x00 }, |
765 | | 4, 0 |
766 | | }, |
767 | | |
768 | | #endif |
769 | | |
770 | | { 0, { 0 }, 0, 0 } |
771 | | }; |
772 | | |
773 | | #ifndef NUM_ENTRIES |
774 | 9.53k | #define NUM_ENTRIES(a) (sizeof (a) / sizeof (a)[0]) |
775 | | #endif |
776 | | |
777 | | /* Build a full BFD from the information supplied in a ILF object. */ |
778 | | |
779 | | static bool |
780 | | pe_ILF_build_a_bfd (bfd * abfd, |
781 | | unsigned int magic, |
782 | | char * symbol_name, |
783 | | char * source_dll, |
784 | | unsigned int ordinal, |
785 | | unsigned int types) |
786 | 21.8k | { |
787 | 21.8k | bfd_byte * ptr; |
788 | 21.8k | pe_ILF_vars vars; |
789 | 21.8k | struct internal_filehdr internal_f; |
790 | 21.8k | unsigned int import_type; |
791 | 21.8k | unsigned int import_name_type; |
792 | 21.8k | asection_ptr id4, id5, id6 = NULL, text = NULL; |
793 | 21.8k | coff_symbol_type ** imp_sym; |
794 | 21.8k | unsigned int imp_index; |
795 | 21.8k | intptr_t alignment; |
796 | | |
797 | | /* Decode and verify the types field of the ILF structure. */ |
798 | 21.8k | import_type = types & 0x3; |
799 | 21.8k | import_name_type = (types & 0x1c) >> 2; |
800 | | |
801 | 21.8k | switch (import_type) |
802 | 21.8k | { |
803 | 11.5k | case IMPORT_CODE: |
804 | 18.6k | case IMPORT_DATA: |
805 | 18.6k | break; |
806 | | |
807 | 1.91k | case IMPORT_CONST: |
808 | | /* XXX code yet to be written. */ |
809 | | /* xgettext:c-format */ |
810 | 1.91k | _bfd_error_handler (_("%pB: unhandled import type; %x"), |
811 | 1.91k | abfd, import_type); |
812 | 1.91k | return false; |
813 | | |
814 | 1.30k | default: |
815 | | /* xgettext:c-format */ |
816 | 1.30k | _bfd_error_handler (_("%pB: unrecognized import type; %x"), |
817 | 1.30k | abfd, import_type); |
818 | 1.30k | return false; |
819 | 21.8k | } |
820 | | |
821 | 18.6k | switch (import_name_type) |
822 | 18.6k | { |
823 | 8.34k | case IMPORT_ORDINAL: |
824 | 11.4k | case IMPORT_NAME: |
825 | 13.9k | case IMPORT_NAME_NOPREFIX: |
826 | 17.1k | case IMPORT_NAME_UNDECORATE: |
827 | 17.1k | break; |
828 | | |
829 | 1.41k | default: |
830 | | /* xgettext:c-format */ |
831 | 1.41k | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), |
832 | 1.41k | abfd, import_name_type); |
833 | 1.41k | return false; |
834 | 18.6k | } |
835 | | |
836 | | /* Initialise local variables. |
837 | | |
838 | | Note these are kept in a structure rather than being |
839 | | declared as statics since bfd frowns on global variables. |
840 | | |
841 | | We are going to construct the contents of the BFD in memory, |
842 | | so allocate all the space that we will need right now. */ |
843 | 17.1k | vars.bim |
844 | 17.1k | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); |
845 | 17.1k | if (vars.bim == NULL) |
846 | 0 | return false; |
847 | | |
848 | 17.1k | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); |
849 | 17.1k | vars.bim->buffer = ptr; |
850 | 17.1k | vars.bim->size = ILF_DATA_SIZE; |
851 | 17.1k | if (ptr == NULL) |
852 | 0 | goto error_return; |
853 | | |
854 | | /* Initialise the pointers to regions of the memory and the |
855 | | other contents of the pe_ILF_vars structure as well. */ |
856 | 17.1k | vars.sym_cache = (coff_symbol_type *) ptr; |
857 | 17.1k | vars.sym_ptr = (coff_symbol_type *) ptr; |
858 | 17.1k | vars.sym_index = 0; |
859 | 17.1k | ptr += SIZEOF_ILF_SYMS; |
860 | | |
861 | 17.1k | vars.sym_table = (unsigned int *) ptr; |
862 | 17.1k | vars.table_ptr = (unsigned int *) ptr; |
863 | 17.1k | ptr += SIZEOF_ILF_SYM_TABLE; |
864 | | |
865 | 17.1k | vars.native_syms = (combined_entry_type *) ptr; |
866 | 17.1k | vars.native_ptr = (combined_entry_type *) ptr; |
867 | 17.1k | ptr += SIZEOF_ILF_NATIVE_SYMS; |
868 | | |
869 | 17.1k | vars.sym_ptr_table = (coff_symbol_type **) ptr; |
870 | 17.1k | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; |
871 | 17.1k | ptr += SIZEOF_ILF_SYM_PTR_TABLE; |
872 | | |
873 | 17.1k | vars.esym_table = (SYMENT *) ptr; |
874 | 17.1k | vars.esym_ptr = (SYMENT *) ptr; |
875 | 17.1k | ptr += SIZEOF_ILF_EXT_SYMS; |
876 | | |
877 | 17.1k | vars.reltab = (arelent *) ptr; |
878 | 17.1k | vars.relcount = 0; |
879 | 17.1k | ptr += SIZEOF_ILF_RELOCS; |
880 | | |
881 | 17.1k | vars.int_reltab = (struct internal_reloc *) ptr; |
882 | 17.1k | ptr += SIZEOF_ILF_INT_RELOCS; |
883 | | |
884 | 17.1k | vars.string_table = (char *) ptr; |
885 | 17.1k | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; |
886 | 17.1k | ptr += SIZEOF_ILF_STRINGS; |
887 | 17.1k | vars.end_string_ptr = (char *) ptr; |
888 | | |
889 | | /* The remaining space in bim->buffer is used |
890 | | by the pe_ILF_make_a_section() function. */ |
891 | | |
892 | | /* PR 18758: Make sure that the data area is sufficiently aligned for |
893 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence |
894 | | the test of GCC_VERSION. For other compilers we assume 8 byte |
895 | | alignment. */ |
896 | 17.1k | #if GCC_VERSION >= 3000 |
897 | 17.1k | alignment = __alignof__ (struct coff_section_tdata); |
898 | | #else |
899 | | alignment = 8; |
900 | | #endif |
901 | 17.1k | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); |
902 | | |
903 | 17.1k | vars.data = ptr; |
904 | 17.1k | vars.abfd = abfd; |
905 | 17.1k | vars.sec_index = 0; |
906 | 17.1k | vars.magic = magic; |
907 | | |
908 | | /* Create the initial .idata$<n> sections: |
909 | | [.idata$2: Import Directory Table -- not needed] |
910 | | .idata$4: Import Lookup Table |
911 | | .idata$5: Import Address Table |
912 | | |
913 | | Note we do not create a .idata$3 section as this is |
914 | | created for us by the linker script. */ |
915 | 17.1k | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); |
916 | 17.1k | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); |
917 | 17.1k | if (id4 == NULL || id5 == NULL) |
918 | 0 | goto error_return; |
919 | | |
920 | | /* Fill in the contents of these sections. */ |
921 | 17.1k | if (import_name_type == IMPORT_ORDINAL) |
922 | 8.34k | { |
923 | 8.34k | if (ordinal == 0) |
924 | | /* See PR 20907 for a reproducer. */ |
925 | 1.42k | goto error_return; |
926 | | |
927 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) |
928 | 2.94k | ((unsigned int *) id4->contents)[0] = ordinal; |
929 | 2.94k | ((unsigned int *) id4->contents)[1] = 0x80000000; |
930 | 2.94k | ((unsigned int *) id5->contents)[0] = ordinal; |
931 | 2.94k | ((unsigned int *) id5->contents)[1] = 0x80000000; |
932 | | #else |
933 | 3.97k | * (unsigned int *) id4->contents = ordinal | 0x80000000; |
934 | 3.97k | * (unsigned int *) id5->contents = ordinal | 0x80000000; |
935 | 3.97k | #endif |
936 | 3.97k | } |
937 | 8.84k | else |
938 | 8.84k | { |
939 | 8.84k | char * symbol; |
940 | 8.84k | unsigned int len; |
941 | | |
942 | | /* Create .idata$6 - the Hint Name Table. */ |
943 | 8.84k | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); |
944 | 8.84k | if (id6 == NULL) |
945 | 0 | goto error_return; |
946 | | |
947 | | /* If necessary, trim the import symbol name. */ |
948 | 8.84k | symbol = symbol_name; |
949 | | |
950 | | /* As used by MS compiler, '_', '@', and '?' are alternative |
951 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, |
952 | | '@' used for fastcall (in C), '_' everywhere else. Only one |
953 | | of these is used for a symbol. We strip this leading char for |
954 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the |
955 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ |
956 | | |
957 | 8.84k | if (import_name_type != IMPORT_NAME) |
958 | 5.70k | { |
959 | 5.70k | char c = symbol[0]; |
960 | | |
961 | | /* Check that we don't remove for targets with empty |
962 | | USER_LABEL_PREFIX the leading underscore. */ |
963 | 5.70k | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) |
964 | 5.70k | || c == '@' || c == '?') |
965 | 1.23k | symbol++; |
966 | 5.70k | } |
967 | | |
968 | 8.84k | len = strlen (symbol); |
969 | 8.84k | if (import_name_type == IMPORT_NAME_UNDECORATE) |
970 | 3.27k | { |
971 | | /* Truncate at the first '@'. */ |
972 | 3.27k | char *at = strchr (symbol, '@'); |
973 | | |
974 | 3.27k | if (at != NULL) |
975 | 492 | len = at - symbol; |
976 | 3.27k | } |
977 | | |
978 | 8.84k | id6->contents[0] = ordinal & 0xff; |
979 | 8.84k | id6->contents[1] = ordinal >> 8; |
980 | | |
981 | 8.84k | memcpy ((char *) id6->contents + 2, symbol, len); |
982 | 8.84k | id6->contents[len + 2] = '\0'; |
983 | 8.84k | } |
984 | | |
985 | 15.7k | if (import_name_type != IMPORT_ORDINAL) |
986 | 8.84k | { |
987 | 8.84k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); |
988 | 8.84k | pe_ILF_save_relocs (&vars, id4); |
989 | | |
990 | 8.84k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); |
991 | 8.84k | pe_ILF_save_relocs (&vars, id5); |
992 | 8.84k | } |
993 | | |
994 | | /* Create an import symbol. */ |
995 | 15.7k | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); |
996 | 15.7k | imp_sym = vars.sym_ptr_ptr - 1; |
997 | 15.7k | imp_index = vars.sym_index - 1; |
998 | | |
999 | | /* Create extra sections depending upon the type of import we are dealing with. */ |
1000 | 15.7k | switch (import_type) |
1001 | 15.7k | { |
1002 | 0 | int i; |
1003 | | |
1004 | 9.53k | case IMPORT_CODE: |
1005 | | /* CODE functions are special, in that they get a trampoline that |
1006 | | jumps to the main import symbol. Create a .text section to hold it. |
1007 | | First we need to look up its contents in the jump table. */ |
1008 | 20.8k | for (i = NUM_ENTRIES (jtab); i--;) |
1009 | 20.8k | { |
1010 | 20.8k | if (jtab[i].size == 0) |
1011 | 9.53k | continue; |
1012 | 11.3k | if (jtab[i].magic == magic) |
1013 | 9.53k | break; |
1014 | 11.3k | } |
1015 | | /* If we did not find a matching entry something is wrong. */ |
1016 | 9.53k | if (i < 0) |
1017 | 0 | abort (); |
1018 | | |
1019 | | /* Create the .text section. */ |
1020 | 9.53k | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); |
1021 | 9.53k | if (text == NULL) |
1022 | 0 | goto error_return; |
1023 | | |
1024 | | /* Copy in the jump code. */ |
1025 | 9.53k | memcpy (text->contents, jtab[i].data, jtab[i].size); |
1026 | | |
1027 | | /* Create a reloc for the data in the text section. */ |
1028 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
1029 | | if (magic == MIPS_ARCH_MAGIC_WINCE) |
1030 | | { |
1031 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, |
1032 | | (struct bfd_symbol **) imp_sym, |
1033 | | imp_index); |
1034 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); |
1035 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, |
1036 | | (struct bfd_symbol **) imp_sym, |
1037 | | imp_index); |
1038 | | } |
1039 | | else |
1040 | | #endif |
1041 | | #ifdef AMD64MAGIC |
1042 | 2.31k | if (magic == AMD64MAGIC) |
1043 | 2.31k | { |
1044 | 2.31k | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, |
1045 | 2.31k | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, |
1046 | 2.31k | imp_index); |
1047 | 2.31k | } |
1048 | 0 | else |
1049 | 0 | #endif |
1050 | 0 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, |
1051 | 0 | BFD_RELOC_32, (asymbol **) imp_sym, |
1052 | 0 | imp_index); |
1053 | | |
1054 | 9.53k | pe_ILF_save_relocs (& vars, text); |
1055 | 9.53k | break; |
1056 | | |
1057 | 6.22k | case IMPORT_DATA: |
1058 | 6.22k | break; |
1059 | | |
1060 | 0 | default: |
1061 | | /* XXX code not yet written. */ |
1062 | 0 | abort (); |
1063 | 15.7k | } |
1064 | | |
1065 | | /* Now create a symbol describing the imported value. */ |
1066 | 15.7k | switch (import_type) |
1067 | 15.7k | { |
1068 | 9.53k | case IMPORT_CODE: |
1069 | 9.53k | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, |
1070 | 9.53k | BSF_NOT_AT_END | BSF_FUNCTION); |
1071 | | |
1072 | 9.53k | break; |
1073 | | |
1074 | 6.22k | case IMPORT_DATA: |
1075 | | /* Nothing to do here. */ |
1076 | 6.22k | break; |
1077 | | |
1078 | 0 | default: |
1079 | | /* XXX code not yet written. */ |
1080 | 0 | abort (); |
1081 | 15.7k | } |
1082 | | |
1083 | | /* Create an import symbol for the DLL, without the .dll suffix. */ |
1084 | 15.7k | ptr = (bfd_byte *) strrchr (source_dll, '.'); |
1085 | 15.7k | if (ptr) |
1086 | 2.75k | * ptr = 0; |
1087 | 15.7k | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); |
1088 | 15.7k | if (ptr) |
1089 | 2.75k | * ptr = '.'; |
1090 | | |
1091 | | /* Initialise the bfd. */ |
1092 | 15.7k | memset (& internal_f, 0, sizeof (internal_f)); |
1093 | | |
1094 | 15.7k | internal_f.f_magic = magic; |
1095 | 15.7k | internal_f.f_symptr = 0; |
1096 | 15.7k | internal_f.f_nsyms = 0; |
1097 | 15.7k | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ |
1098 | | |
1099 | 15.7k | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) |
1100 | 15.7k | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) |
1101 | 0 | goto error_return; |
1102 | | |
1103 | 15.7k | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) |
1104 | 0 | goto error_return; |
1105 | | |
1106 | 15.7k | obj_pe (abfd) = true; |
1107 | | #ifdef THUMBPEMAGIC |
1108 | 3.40k | if (vars.magic == THUMBPEMAGIC) |
1109 | | /* Stop some linker warnings about thumb code not supporting interworking. */ |
1110 | 919 | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; |
1111 | | #endif |
1112 | | |
1113 | | /* Switch from file contents to memory contents. */ |
1114 | 15.7k | bfd_cache_close (abfd); |
1115 | | |
1116 | 15.7k | abfd->iostream = (void *) vars.bim; |
1117 | 15.7k | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; |
1118 | 15.7k | abfd->iovec = &_bfd_memory_iovec; |
1119 | 15.7k | abfd->where = 0; |
1120 | 15.7k | abfd->origin = 0; |
1121 | 15.7k | abfd->size = 0; |
1122 | 15.7k | obj_sym_filepos (abfd) = 0; |
1123 | | |
1124 | | /* Point the bfd at the symbol table. */ |
1125 | 15.7k | obj_symbols (abfd) = vars.sym_cache; |
1126 | 15.7k | abfd->symcount = vars.sym_index; |
1127 | | |
1128 | 15.7k | obj_raw_syments (abfd) = vars.native_syms; |
1129 | 15.7k | obj_raw_syment_count (abfd) = vars.sym_index; |
1130 | | |
1131 | 15.7k | obj_coff_external_syms (abfd) = (void *) vars.esym_table; |
1132 | 15.7k | obj_coff_keep_syms (abfd) = true; |
1133 | | |
1134 | 15.7k | obj_convert (abfd) = vars.sym_table; |
1135 | 15.7k | obj_conv_table_size (abfd) = vars.sym_index; |
1136 | | |
1137 | 15.7k | obj_coff_strings (abfd) = vars.string_table; |
1138 | 15.7k | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; |
1139 | 15.7k | obj_coff_keep_strings (abfd) = true; |
1140 | | |
1141 | 15.7k | return true; |
1142 | | |
1143 | 1.42k | error_return: |
1144 | 1.42k | free (vars.bim->buffer); |
1145 | 1.42k | free (vars.bim); |
1146 | 1.42k | return false; |
1147 | 15.7k | } pei-i386.c:pe_ILF_build_a_bfd Line | Count | Source | 786 | 2.63k | { | 787 | 2.63k | bfd_byte * ptr; | 788 | 2.63k | pe_ILF_vars vars; | 789 | 2.63k | struct internal_filehdr internal_f; | 790 | 2.63k | unsigned int import_type; | 791 | 2.63k | unsigned int import_name_type; | 792 | 2.63k | asection_ptr id4, id5, id6 = NULL, text = NULL; | 793 | 2.63k | coff_symbol_type ** imp_sym; | 794 | 2.63k | unsigned int imp_index; | 795 | 2.63k | intptr_t alignment; | 796 | | | 797 | | /* Decode and verify the types field of the ILF structure. */ | 798 | 2.63k | import_type = types & 0x3; | 799 | 2.63k | import_name_type = (types & 0x1c) >> 2; | 800 | | | 801 | 2.63k | switch (import_type) | 802 | 2.63k | { | 803 | 1.93k | case IMPORT_CODE: | 804 | 2.40k | case IMPORT_DATA: | 805 | 2.40k | break; | 806 | | | 807 | 118 | case IMPORT_CONST: | 808 | | /* XXX code yet to be written. */ | 809 | | /* xgettext:c-format */ | 810 | 118 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 811 | 118 | abfd, import_type); | 812 | 118 | return false; | 813 | | | 814 | 117 | default: | 815 | | /* xgettext:c-format */ | 816 | 117 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 817 | 117 | abfd, import_type); | 818 | 117 | return false; | 819 | 2.63k | } | 820 | | | 821 | 2.40k | switch (import_name_type) | 822 | 2.40k | { | 823 | 1.61k | case IMPORT_ORDINAL: | 824 | 1.72k | case IMPORT_NAME: | 825 | 1.96k | case IMPORT_NAME_NOPREFIX: | 826 | 2.28k | case IMPORT_NAME_UNDECORATE: | 827 | 2.28k | break; | 828 | | | 829 | 118 | default: | 830 | | /* xgettext:c-format */ | 831 | 118 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 832 | 118 | abfd, import_name_type); | 833 | 118 | return false; | 834 | 2.40k | } | 835 | | | 836 | | /* Initialise local variables. | 837 | | | 838 | | Note these are kept in a structure rather than being | 839 | | declared as statics since bfd frowns on global variables. | 840 | | | 841 | | We are going to construct the contents of the BFD in memory, | 842 | | so allocate all the space that we will need right now. */ | 843 | 2.28k | vars.bim | 844 | 2.28k | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 845 | 2.28k | if (vars.bim == NULL) | 846 | 0 | return false; | 847 | | | 848 | 2.28k | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 849 | 2.28k | vars.bim->buffer = ptr; | 850 | 2.28k | vars.bim->size = ILF_DATA_SIZE; | 851 | 2.28k | if (ptr == NULL) | 852 | 0 | goto error_return; | 853 | | | 854 | | /* Initialise the pointers to regions of the memory and the | 855 | | other contents of the pe_ILF_vars structure as well. */ | 856 | 2.28k | vars.sym_cache = (coff_symbol_type *) ptr; | 857 | 2.28k | vars.sym_ptr = (coff_symbol_type *) ptr; | 858 | 2.28k | vars.sym_index = 0; | 859 | 2.28k | ptr += SIZEOF_ILF_SYMS; | 860 | | | 861 | 2.28k | vars.sym_table = (unsigned int *) ptr; | 862 | 2.28k | vars.table_ptr = (unsigned int *) ptr; | 863 | 2.28k | ptr += SIZEOF_ILF_SYM_TABLE; | 864 | | | 865 | 2.28k | vars.native_syms = (combined_entry_type *) ptr; | 866 | 2.28k | vars.native_ptr = (combined_entry_type *) ptr; | 867 | 2.28k | ptr += SIZEOF_ILF_NATIVE_SYMS; | 868 | | | 869 | 2.28k | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 870 | 2.28k | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 871 | 2.28k | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 872 | | | 873 | 2.28k | vars.esym_table = (SYMENT *) ptr; | 874 | 2.28k | vars.esym_ptr = (SYMENT *) ptr; | 875 | 2.28k | ptr += SIZEOF_ILF_EXT_SYMS; | 876 | | | 877 | 2.28k | vars.reltab = (arelent *) ptr; | 878 | 2.28k | vars.relcount = 0; | 879 | 2.28k | ptr += SIZEOF_ILF_RELOCS; | 880 | | | 881 | 2.28k | vars.int_reltab = (struct internal_reloc *) ptr; | 882 | 2.28k | ptr += SIZEOF_ILF_INT_RELOCS; | 883 | | | 884 | 2.28k | vars.string_table = (char *) ptr; | 885 | 2.28k | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 886 | 2.28k | ptr += SIZEOF_ILF_STRINGS; | 887 | 2.28k | vars.end_string_ptr = (char *) ptr; | 888 | | | 889 | | /* The remaining space in bim->buffer is used | 890 | | by the pe_ILF_make_a_section() function. */ | 891 | | | 892 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 893 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 894 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 895 | | alignment. */ | 896 | 2.28k | #if GCC_VERSION >= 3000 | 897 | 2.28k | alignment = __alignof__ (struct coff_section_tdata); | 898 | | #else | 899 | | alignment = 8; | 900 | | #endif | 901 | 2.28k | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 902 | | | 903 | 2.28k | vars.data = ptr; | 904 | 2.28k | vars.abfd = abfd; | 905 | 2.28k | vars.sec_index = 0; | 906 | 2.28k | vars.magic = magic; | 907 | | | 908 | | /* Create the initial .idata$<n> sections: | 909 | | [.idata$2: Import Directory Table -- not needed] | 910 | | .idata$4: Import Lookup Table | 911 | | .idata$5: Import Address Table | 912 | | | 913 | | Note we do not create a .idata$3 section as this is | 914 | | created for us by the linker script. */ | 915 | 2.28k | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 916 | 2.28k | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 917 | 2.28k | if (id4 == NULL || id5 == NULL) | 918 | 0 | goto error_return; | 919 | | | 920 | | /* Fill in the contents of these sections. */ | 921 | 2.28k | if (import_name_type == IMPORT_ORDINAL) | 922 | 1.61k | { | 923 | 1.61k | if (ordinal == 0) | 924 | | /* See PR 20907 for a reproducer. */ | 925 | 214 | goto error_return; | 926 | | | 927 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 928 | | ((unsigned int *) id4->contents)[0] = ordinal; | 929 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 930 | | ((unsigned int *) id5->contents)[0] = ordinal; | 931 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 932 | | #else | 933 | 1.39k | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 934 | 1.39k | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 935 | 1.39k | #endif | 936 | 1.39k | } | 937 | 676 | else | 938 | 676 | { | 939 | 676 | char * symbol; | 940 | 676 | unsigned int len; | 941 | | | 942 | | /* Create .idata$6 - the Hint Name Table. */ | 943 | 676 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 944 | 676 | if (id6 == NULL) | 945 | 0 | goto error_return; | 946 | | | 947 | | /* If necessary, trim the import symbol name. */ | 948 | 676 | symbol = symbol_name; | 949 | | | 950 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 951 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 952 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 953 | | of these is used for a symbol. We strip this leading char for | 954 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 955 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 956 | | | 957 | 676 | if (import_name_type != IMPORT_NAME) | 958 | 566 | { | 959 | 566 | char c = symbol[0]; | 960 | | | 961 | | /* Check that we don't remove for targets with empty | 962 | | USER_LABEL_PREFIX the leading underscore. */ | 963 | 566 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 964 | 566 | || c == '@' || c == '?') | 965 | 111 | symbol++; | 966 | 566 | } | 967 | | | 968 | 676 | len = strlen (symbol); | 969 | 676 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 970 | 321 | { | 971 | | /* Truncate at the first '@'. */ | 972 | 321 | char *at = strchr (symbol, '@'); | 973 | | | 974 | 321 | if (at != NULL) | 975 | 3 | len = at - symbol; | 976 | 321 | } | 977 | | | 978 | 676 | id6->contents[0] = ordinal & 0xff; | 979 | 676 | id6->contents[1] = ordinal >> 8; | 980 | | | 981 | 676 | memcpy ((char *) id6->contents + 2, symbol, len); | 982 | 676 | id6->contents[len + 2] = '\0'; | 983 | 676 | } | 984 | | | 985 | 2.07k | if (import_name_type != IMPORT_ORDINAL) | 986 | 676 | { | 987 | 676 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 988 | 676 | pe_ILF_save_relocs (&vars, id4); | 989 | | | 990 | 676 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 991 | 676 | pe_ILF_save_relocs (&vars, id5); | 992 | 676 | } | 993 | | | 994 | | /* Create an import symbol. */ | 995 | 2.07k | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 996 | 2.07k | imp_sym = vars.sym_ptr_ptr - 1; | 997 | 2.07k | imp_index = vars.sym_index - 1; | 998 | | | 999 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1000 | 2.07k | switch (import_type) | 1001 | 2.07k | { | 1002 | 0 | int i; | 1003 | | | 1004 | 1.61k | case IMPORT_CODE: | 1005 | | /* CODE functions are special, in that they get a trampoline that | 1006 | | jumps to the main import symbol. Create a .text section to hold it. | 1007 | | First we need to look up its contents in the jump table. */ | 1008 | 3.22k | for (i = NUM_ENTRIES (jtab); i--;) | 1009 | 3.22k | { | 1010 | 3.22k | if (jtab[i].size == 0) | 1011 | 1.61k | continue; | 1012 | 1.61k | if (jtab[i].magic == magic) | 1013 | 1.61k | break; | 1014 | 1.61k | } | 1015 | | /* If we did not find a matching entry something is wrong. */ | 1016 | 1.61k | if (i < 0) | 1017 | 0 | abort (); | 1018 | | | 1019 | | /* Create the .text section. */ | 1020 | 1.61k | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1021 | 1.61k | if (text == NULL) | 1022 | 0 | goto error_return; | 1023 | | | 1024 | | /* Copy in the jump code. */ | 1025 | 1.61k | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1026 | | | 1027 | | /* Create a reloc for the data in the text section. */ | 1028 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1029 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1030 | | { | 1031 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1032 | | (struct bfd_symbol **) imp_sym, | 1033 | | imp_index); | 1034 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1035 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1036 | | (struct bfd_symbol **) imp_sym, | 1037 | | imp_index); | 1038 | | } | 1039 | | else | 1040 | | #endif | 1041 | | #ifdef AMD64MAGIC | 1042 | | if (magic == AMD64MAGIC) | 1043 | | { | 1044 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1045 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1046 | | imp_index); | 1047 | | } | 1048 | | else | 1049 | | #endif | 1050 | 1.61k | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1051 | 1.61k | BFD_RELOC_32, (asymbol **) imp_sym, | 1052 | 1.61k | imp_index); | 1053 | | | 1054 | 1.61k | pe_ILF_save_relocs (& vars, text); | 1055 | 1.61k | break; | 1056 | | | 1057 | 460 | case IMPORT_DATA: | 1058 | 460 | break; | 1059 | | | 1060 | 0 | default: | 1061 | | /* XXX code not yet written. */ | 1062 | 0 | abort (); | 1063 | 2.07k | } | 1064 | | | 1065 | | /* Now create a symbol describing the imported value. */ | 1066 | 2.07k | switch (import_type) | 1067 | 2.07k | { | 1068 | 1.61k | case IMPORT_CODE: | 1069 | 1.61k | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1070 | 1.61k | BSF_NOT_AT_END | BSF_FUNCTION); | 1071 | | | 1072 | 1.61k | break; | 1073 | | | 1074 | 460 | case IMPORT_DATA: | 1075 | | /* Nothing to do here. */ | 1076 | 460 | break; | 1077 | | | 1078 | 0 | default: | 1079 | | /* XXX code not yet written. */ | 1080 | 0 | abort (); | 1081 | 2.07k | } | 1082 | | | 1083 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1084 | 2.07k | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1085 | 2.07k | if (ptr) | 1086 | 107 | * ptr = 0; | 1087 | 2.07k | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1088 | 2.07k | if (ptr) | 1089 | 107 | * ptr = '.'; | 1090 | | | 1091 | | /* Initialise the bfd. */ | 1092 | 2.07k | memset (& internal_f, 0, sizeof (internal_f)); | 1093 | | | 1094 | 2.07k | internal_f.f_magic = magic; | 1095 | 2.07k | internal_f.f_symptr = 0; | 1096 | 2.07k | internal_f.f_nsyms = 0; | 1097 | 2.07k | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1098 | | | 1099 | 2.07k | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1100 | 2.07k | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1101 | 0 | goto error_return; | 1102 | | | 1103 | 2.07k | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1104 | 0 | goto error_return; | 1105 | | | 1106 | 2.07k | obj_pe (abfd) = true; | 1107 | | #ifdef THUMBPEMAGIC | 1108 | | if (vars.magic == THUMBPEMAGIC) | 1109 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1110 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1111 | | #endif | 1112 | | | 1113 | | /* Switch from file contents to memory contents. */ | 1114 | 2.07k | bfd_cache_close (abfd); | 1115 | | | 1116 | 2.07k | abfd->iostream = (void *) vars.bim; | 1117 | 2.07k | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1118 | 2.07k | abfd->iovec = &_bfd_memory_iovec; | 1119 | 2.07k | abfd->where = 0; | 1120 | 2.07k | abfd->origin = 0; | 1121 | 2.07k | abfd->size = 0; | 1122 | 2.07k | obj_sym_filepos (abfd) = 0; | 1123 | | | 1124 | | /* Point the bfd at the symbol table. */ | 1125 | 2.07k | obj_symbols (abfd) = vars.sym_cache; | 1126 | 2.07k | abfd->symcount = vars.sym_index; | 1127 | | | 1128 | 2.07k | obj_raw_syments (abfd) = vars.native_syms; | 1129 | 2.07k | obj_raw_syment_count (abfd) = vars.sym_index; | 1130 | | | 1131 | 2.07k | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1132 | 2.07k | obj_coff_keep_syms (abfd) = true; | 1133 | | | 1134 | 2.07k | obj_convert (abfd) = vars.sym_table; | 1135 | 2.07k | obj_conv_table_size (abfd) = vars.sym_index; | 1136 | | | 1137 | 2.07k | obj_coff_strings (abfd) = vars.string_table; | 1138 | 2.07k | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1139 | 2.07k | obj_coff_keep_strings (abfd) = true; | 1140 | | | 1141 | 2.07k | return true; | 1142 | | | 1143 | 214 | error_return: | 1144 | 214 | free (vars.bim->buffer); | 1145 | 214 | free (vars.bim); | 1146 | 214 | return false; | 1147 | 2.07k | } |
pei-x86_64.c:pe_ILF_build_a_bfd Line | Count | Source | 786 | 4.77k | { | 787 | 4.77k | bfd_byte * ptr; | 788 | 4.77k | pe_ILF_vars vars; | 789 | 4.77k | struct internal_filehdr internal_f; | 790 | 4.77k | unsigned int import_type; | 791 | 4.77k | unsigned int import_name_type; | 792 | 4.77k | asection_ptr id4, id5, id6 = NULL, text = NULL; | 793 | 4.77k | coff_symbol_type ** imp_sym; | 794 | 4.77k | unsigned int imp_index; | 795 | 4.77k | intptr_t alignment; | 796 | | | 797 | | /* Decode and verify the types field of the ILF structure. */ | 798 | 4.77k | import_type = types & 0x3; | 799 | 4.77k | import_name_type = (types & 0x1c) >> 2; | 800 | | | 801 | 4.77k | switch (import_type) | 802 | 4.77k | { | 803 | 2.73k | case IMPORT_CODE: | 804 | 4.44k | case IMPORT_DATA: | 805 | 4.44k | break; | 806 | | | 807 | 214 | case IMPORT_CONST: | 808 | | /* XXX code yet to be written. */ | 809 | | /* xgettext:c-format */ | 810 | 214 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 811 | 214 | abfd, import_type); | 812 | 214 | return false; | 813 | | | 814 | 115 | default: | 815 | | /* xgettext:c-format */ | 816 | 115 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 817 | 115 | abfd, import_type); | 818 | 115 | return false; | 819 | 4.77k | } | 820 | | | 821 | 4.44k | switch (import_name_type) | 822 | 4.44k | { | 823 | 1.84k | case IMPORT_ORDINAL: | 824 | 2.05k | case IMPORT_NAME: | 825 | 3.31k | case IMPORT_NAME_NOPREFIX: | 826 | 4.13k | case IMPORT_NAME_UNDECORATE: | 827 | 4.13k | break; | 828 | | | 829 | 314 | default: | 830 | | /* xgettext:c-format */ | 831 | 314 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 832 | 314 | abfd, import_name_type); | 833 | 314 | return false; | 834 | 4.44k | } | 835 | | | 836 | | /* Initialise local variables. | 837 | | | 838 | | Note these are kept in a structure rather than being | 839 | | declared as statics since bfd frowns on global variables. | 840 | | | 841 | | We are going to construct the contents of the BFD in memory, | 842 | | so allocate all the space that we will need right now. */ | 843 | 4.13k | vars.bim | 844 | 4.13k | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 845 | 4.13k | if (vars.bim == NULL) | 846 | 0 | return false; | 847 | | | 848 | 4.13k | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 849 | 4.13k | vars.bim->buffer = ptr; | 850 | 4.13k | vars.bim->size = ILF_DATA_SIZE; | 851 | 4.13k | if (ptr == NULL) | 852 | 0 | goto error_return; | 853 | | | 854 | | /* Initialise the pointers to regions of the memory and the | 855 | | other contents of the pe_ILF_vars structure as well. */ | 856 | 4.13k | vars.sym_cache = (coff_symbol_type *) ptr; | 857 | 4.13k | vars.sym_ptr = (coff_symbol_type *) ptr; | 858 | 4.13k | vars.sym_index = 0; | 859 | 4.13k | ptr += SIZEOF_ILF_SYMS; | 860 | | | 861 | 4.13k | vars.sym_table = (unsigned int *) ptr; | 862 | 4.13k | vars.table_ptr = (unsigned int *) ptr; | 863 | 4.13k | ptr += SIZEOF_ILF_SYM_TABLE; | 864 | | | 865 | 4.13k | vars.native_syms = (combined_entry_type *) ptr; | 866 | 4.13k | vars.native_ptr = (combined_entry_type *) ptr; | 867 | 4.13k | ptr += SIZEOF_ILF_NATIVE_SYMS; | 868 | | | 869 | 4.13k | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 870 | 4.13k | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 871 | 4.13k | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 872 | | | 873 | 4.13k | vars.esym_table = (SYMENT *) ptr; | 874 | 4.13k | vars.esym_ptr = (SYMENT *) ptr; | 875 | 4.13k | ptr += SIZEOF_ILF_EXT_SYMS; | 876 | | | 877 | 4.13k | vars.reltab = (arelent *) ptr; | 878 | 4.13k | vars.relcount = 0; | 879 | 4.13k | ptr += SIZEOF_ILF_RELOCS; | 880 | | | 881 | 4.13k | vars.int_reltab = (struct internal_reloc *) ptr; | 882 | 4.13k | ptr += SIZEOF_ILF_INT_RELOCS; | 883 | | | 884 | 4.13k | vars.string_table = (char *) ptr; | 885 | 4.13k | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 886 | 4.13k | ptr += SIZEOF_ILF_STRINGS; | 887 | 4.13k | vars.end_string_ptr = (char *) ptr; | 888 | | | 889 | | /* The remaining space in bim->buffer is used | 890 | | by the pe_ILF_make_a_section() function. */ | 891 | | | 892 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 893 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 894 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 895 | | alignment. */ | 896 | 4.13k | #if GCC_VERSION >= 3000 | 897 | 4.13k | alignment = __alignof__ (struct coff_section_tdata); | 898 | | #else | 899 | | alignment = 8; | 900 | | #endif | 901 | 4.13k | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 902 | | | 903 | 4.13k | vars.data = ptr; | 904 | 4.13k | vars.abfd = abfd; | 905 | 4.13k | vars.sec_index = 0; | 906 | 4.13k | vars.magic = magic; | 907 | | | 908 | | /* Create the initial .idata$<n> sections: | 909 | | [.idata$2: Import Directory Table -- not needed] | 910 | | .idata$4: Import Lookup Table | 911 | | .idata$5: Import Address Table | 912 | | | 913 | | Note we do not create a .idata$3 section as this is | 914 | | created for us by the linker script. */ | 915 | 4.13k | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 916 | 4.13k | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 917 | 4.13k | if (id4 == NULL || id5 == NULL) | 918 | 0 | goto error_return; | 919 | | | 920 | | /* Fill in the contents of these sections. */ | 921 | 4.13k | if (import_name_type == IMPORT_ORDINAL) | 922 | 1.84k | { | 923 | 1.84k | if (ordinal == 0) | 924 | | /* See PR 20907 for a reproducer. */ | 925 | 318 | goto error_return; | 926 | | | 927 | 1.52k | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 928 | 1.52k | ((unsigned int *) id4->contents)[0] = ordinal; | 929 | 1.52k | ((unsigned int *) id4->contents)[1] = 0x80000000; | 930 | 1.52k | ((unsigned int *) id5->contents)[0] = ordinal; | 931 | 1.52k | ((unsigned int *) id5->contents)[1] = 0x80000000; | 932 | | #else | 933 | | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 934 | | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 935 | | #endif | 936 | 1.52k | } | 937 | 2.28k | else | 938 | 2.28k | { | 939 | 2.28k | char * symbol; | 940 | 2.28k | unsigned int len; | 941 | | | 942 | | /* Create .idata$6 - the Hint Name Table. */ | 943 | 2.28k | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 944 | 2.28k | if (id6 == NULL) | 945 | 0 | goto error_return; | 946 | | | 947 | | /* If necessary, trim the import symbol name. */ | 948 | 2.28k | symbol = symbol_name; | 949 | | | 950 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 951 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 952 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 953 | | of these is used for a symbol. We strip this leading char for | 954 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 955 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 956 | | | 957 | 2.28k | if (import_name_type != IMPORT_NAME) | 958 | 2.07k | { | 959 | 2.07k | char c = symbol[0]; | 960 | | | 961 | | /* Check that we don't remove for targets with empty | 962 | | USER_LABEL_PREFIX the leading underscore. */ | 963 | 2.07k | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 964 | 2.07k | || c == '@' || c == '?') | 965 | 578 | symbol++; | 966 | 2.07k | } | 967 | | | 968 | 2.28k | len = strlen (symbol); | 969 | 2.28k | if (import_name_type == IMPORT_NAME_UNDECORATE) | 970 | 818 | { | 971 | | /* Truncate at the first '@'. */ | 972 | 818 | char *at = strchr (symbol, '@'); | 973 | | | 974 | 818 | if (at != NULL) | 975 | 236 | len = at - symbol; | 976 | 818 | } | 977 | | | 978 | 2.28k | id6->contents[0] = ordinal & 0xff; | 979 | 2.28k | id6->contents[1] = ordinal >> 8; | 980 | | | 981 | 2.28k | memcpy ((char *) id6->contents + 2, symbol, len); | 982 | 2.28k | id6->contents[len + 2] = '\0'; | 983 | 2.28k | } | 984 | | | 985 | 3.81k | if (import_name_type != IMPORT_ORDINAL) | 986 | 2.28k | { | 987 | 2.28k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 988 | 2.28k | pe_ILF_save_relocs (&vars, id4); | 989 | | | 990 | 2.28k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 991 | 2.28k | pe_ILF_save_relocs (&vars, id5); | 992 | 2.28k | } | 993 | | | 994 | | /* Create an import symbol. */ | 995 | 3.81k | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 996 | 3.81k | imp_sym = vars.sym_ptr_ptr - 1; | 997 | 3.81k | imp_index = vars.sym_index - 1; | 998 | | | 999 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1000 | 3.81k | switch (import_type) | 1001 | 3.81k | { | 1002 | 0 | int i; | 1003 | | | 1004 | 2.31k | case IMPORT_CODE: | 1005 | | /* CODE functions are special, in that they get a trampoline that | 1006 | | jumps to the main import symbol. Create a .text section to hold it. | 1007 | | First we need to look up its contents in the jump table. */ | 1008 | 4.62k | for (i = NUM_ENTRIES (jtab); i--;) | 1009 | 4.62k | { | 1010 | 4.62k | if (jtab[i].size == 0) | 1011 | 2.31k | continue; | 1012 | 2.31k | if (jtab[i].magic == magic) | 1013 | 2.31k | break; | 1014 | 2.31k | } | 1015 | | /* If we did not find a matching entry something is wrong. */ | 1016 | 2.31k | if (i < 0) | 1017 | 0 | abort (); | 1018 | | | 1019 | | /* Create the .text section. */ | 1020 | 2.31k | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1021 | 2.31k | if (text == NULL) | 1022 | 0 | goto error_return; | 1023 | | | 1024 | | /* Copy in the jump code. */ | 1025 | 2.31k | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1026 | | | 1027 | | /* Create a reloc for the data in the text section. */ | 1028 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1029 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1030 | | { | 1031 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1032 | | (struct bfd_symbol **) imp_sym, | 1033 | | imp_index); | 1034 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1035 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1036 | | (struct bfd_symbol **) imp_sym, | 1037 | | imp_index); | 1038 | | } | 1039 | | else | 1040 | | #endif | 1041 | 2.31k | #ifdef AMD64MAGIC | 1042 | 2.31k | if (magic == AMD64MAGIC) | 1043 | 2.31k | { | 1044 | 2.31k | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1045 | 2.31k | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1046 | 2.31k | imp_index); | 1047 | 2.31k | } | 1048 | 0 | else | 1049 | 0 | #endif | 1050 | 0 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1051 | 0 | BFD_RELOC_32, (asymbol **) imp_sym, | 1052 | 0 | imp_index); | 1053 | | | 1054 | 2.31k | pe_ILF_save_relocs (& vars, text); | 1055 | 2.31k | break; | 1056 | | | 1057 | 1.50k | case IMPORT_DATA: | 1058 | 1.50k | break; | 1059 | | | 1060 | 0 | default: | 1061 | | /* XXX code not yet written. */ | 1062 | 0 | abort (); | 1063 | 3.81k | } | 1064 | | | 1065 | | /* Now create a symbol describing the imported value. */ | 1066 | 3.81k | switch (import_type) | 1067 | 3.81k | { | 1068 | 2.31k | case IMPORT_CODE: | 1069 | 2.31k | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1070 | 2.31k | BSF_NOT_AT_END | BSF_FUNCTION); | 1071 | | | 1072 | 2.31k | break; | 1073 | | | 1074 | 1.50k | case IMPORT_DATA: | 1075 | | /* Nothing to do here. */ | 1076 | 1.50k | break; | 1077 | | | 1078 | 0 | default: | 1079 | | /* XXX code not yet written. */ | 1080 | 0 | abort (); | 1081 | 3.81k | } | 1082 | | | 1083 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1084 | 3.81k | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1085 | 3.81k | if (ptr) | 1086 | 1.01k | * ptr = 0; | 1087 | 3.81k | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1088 | 3.81k | if (ptr) | 1089 | 1.01k | * ptr = '.'; | 1090 | | | 1091 | | /* Initialise the bfd. */ | 1092 | 3.81k | memset (& internal_f, 0, sizeof (internal_f)); | 1093 | | | 1094 | 3.81k | internal_f.f_magic = magic; | 1095 | 3.81k | internal_f.f_symptr = 0; | 1096 | 3.81k | internal_f.f_nsyms = 0; | 1097 | 3.81k | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1098 | | | 1099 | 3.81k | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1100 | 3.81k | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1101 | 0 | goto error_return; | 1102 | | | 1103 | 3.81k | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1104 | 0 | goto error_return; | 1105 | | | 1106 | 3.81k | obj_pe (abfd) = true; | 1107 | | #ifdef THUMBPEMAGIC | 1108 | | if (vars.magic == THUMBPEMAGIC) | 1109 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1110 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1111 | | #endif | 1112 | | | 1113 | | /* Switch from file contents to memory contents. */ | 1114 | 3.81k | bfd_cache_close (abfd); | 1115 | | | 1116 | 3.81k | abfd->iostream = (void *) vars.bim; | 1117 | 3.81k | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1118 | 3.81k | abfd->iovec = &_bfd_memory_iovec; | 1119 | 3.81k | abfd->where = 0; | 1120 | 3.81k | abfd->origin = 0; | 1121 | 3.81k | abfd->size = 0; | 1122 | 3.81k | obj_sym_filepos (abfd) = 0; | 1123 | | | 1124 | | /* Point the bfd at the symbol table. */ | 1125 | 3.81k | obj_symbols (abfd) = vars.sym_cache; | 1126 | 3.81k | abfd->symcount = vars.sym_index; | 1127 | | | 1128 | 3.81k | obj_raw_syments (abfd) = vars.native_syms; | 1129 | 3.81k | obj_raw_syment_count (abfd) = vars.sym_index; | 1130 | | | 1131 | 3.81k | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1132 | 3.81k | obj_coff_keep_syms (abfd) = true; | 1133 | | | 1134 | 3.81k | obj_convert (abfd) = vars.sym_table; | 1135 | 3.81k | obj_conv_table_size (abfd) = vars.sym_index; | 1136 | | | 1137 | 3.81k | obj_coff_strings (abfd) = vars.string_table; | 1138 | 3.81k | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1139 | 3.81k | obj_coff_keep_strings (abfd) = true; | 1140 | | | 1141 | 3.81k | return true; | 1142 | | | 1143 | 318 | error_return: | 1144 | 318 | free (vars.bim->buffer); | 1145 | 318 | free (vars.bim); | 1146 | 318 | return false; | 1147 | 3.81k | } |
pei-aarch64.c:pe_ILF_build_a_bfd Line | Count | Source | 786 | 2.62k | { | 787 | 2.62k | bfd_byte * ptr; | 788 | 2.62k | pe_ILF_vars vars; | 789 | 2.62k | struct internal_filehdr internal_f; | 790 | 2.62k | unsigned int import_type; | 791 | 2.62k | unsigned int import_name_type; | 792 | 2.62k | asection_ptr id4, id5, id6 = NULL, text = NULL; | 793 | 2.62k | coff_symbol_type ** imp_sym; | 794 | 2.62k | unsigned int imp_index; | 795 | 2.62k | intptr_t alignment; | 796 | | | 797 | | /* Decode and verify the types field of the ILF structure. */ | 798 | 2.62k | import_type = types & 0x3; | 799 | 2.62k | import_name_type = (types & 0x1c) >> 2; | 800 | | | 801 | 2.62k | switch (import_type) | 802 | 2.62k | { | 803 | 833 | case IMPORT_CODE: | 804 | 2.50k | case IMPORT_DATA: | 805 | 2.50k | break; | 806 | | | 807 | 117 | case IMPORT_CONST: | 808 | | /* XXX code yet to be written. */ | 809 | | /* xgettext:c-format */ | 810 | 117 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 811 | 117 | abfd, import_type); | 812 | 117 | return false; | 813 | | | 814 | 8 | default: | 815 | | /* xgettext:c-format */ | 816 | 8 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 817 | 8 | abfd, import_type); | 818 | 8 | return false; | 819 | 2.62k | } | 820 | | | 821 | 2.50k | switch (import_name_type) | 822 | 2.50k | { | 823 | 1.04k | case IMPORT_ORDINAL: | 824 | 1.62k | case IMPORT_NAME: | 825 | 1.63k | case IMPORT_NAME_NOPREFIX: | 826 | 2.38k | case IMPORT_NAME_UNDECORATE: | 827 | 2.38k | break; | 828 | | | 829 | 115 | default: | 830 | | /* xgettext:c-format */ | 831 | 115 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 832 | 115 | abfd, import_name_type); | 833 | 115 | return false; | 834 | 2.50k | } | 835 | | | 836 | | /* Initialise local variables. | 837 | | | 838 | | Note these are kept in a structure rather than being | 839 | | declared as statics since bfd frowns on global variables. | 840 | | | 841 | | We are going to construct the contents of the BFD in memory, | 842 | | so allocate all the space that we will need right now. */ | 843 | 2.38k | vars.bim | 844 | 2.38k | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 845 | 2.38k | if (vars.bim == NULL) | 846 | 0 | return false; | 847 | | | 848 | 2.38k | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 849 | 2.38k | vars.bim->buffer = ptr; | 850 | 2.38k | vars.bim->size = ILF_DATA_SIZE; | 851 | 2.38k | if (ptr == NULL) | 852 | 0 | goto error_return; | 853 | | | 854 | | /* Initialise the pointers to regions of the memory and the | 855 | | other contents of the pe_ILF_vars structure as well. */ | 856 | 2.38k | vars.sym_cache = (coff_symbol_type *) ptr; | 857 | 2.38k | vars.sym_ptr = (coff_symbol_type *) ptr; | 858 | 2.38k | vars.sym_index = 0; | 859 | 2.38k | ptr += SIZEOF_ILF_SYMS; | 860 | | | 861 | 2.38k | vars.sym_table = (unsigned int *) ptr; | 862 | 2.38k | vars.table_ptr = (unsigned int *) ptr; | 863 | 2.38k | ptr += SIZEOF_ILF_SYM_TABLE; | 864 | | | 865 | 2.38k | vars.native_syms = (combined_entry_type *) ptr; | 866 | 2.38k | vars.native_ptr = (combined_entry_type *) ptr; | 867 | 2.38k | ptr += SIZEOF_ILF_NATIVE_SYMS; | 868 | | | 869 | 2.38k | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 870 | 2.38k | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 871 | 2.38k | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 872 | | | 873 | 2.38k | vars.esym_table = (SYMENT *) ptr; | 874 | 2.38k | vars.esym_ptr = (SYMENT *) ptr; | 875 | 2.38k | ptr += SIZEOF_ILF_EXT_SYMS; | 876 | | | 877 | 2.38k | vars.reltab = (arelent *) ptr; | 878 | 2.38k | vars.relcount = 0; | 879 | 2.38k | ptr += SIZEOF_ILF_RELOCS; | 880 | | | 881 | 2.38k | vars.int_reltab = (struct internal_reloc *) ptr; | 882 | 2.38k | ptr += SIZEOF_ILF_INT_RELOCS; | 883 | | | 884 | 2.38k | vars.string_table = (char *) ptr; | 885 | 2.38k | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 886 | 2.38k | ptr += SIZEOF_ILF_STRINGS; | 887 | 2.38k | vars.end_string_ptr = (char *) ptr; | 888 | | | 889 | | /* The remaining space in bim->buffer is used | 890 | | by the pe_ILF_make_a_section() function. */ | 891 | | | 892 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 893 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 894 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 895 | | alignment. */ | 896 | 2.38k | #if GCC_VERSION >= 3000 | 897 | 2.38k | alignment = __alignof__ (struct coff_section_tdata); | 898 | | #else | 899 | | alignment = 8; | 900 | | #endif | 901 | 2.38k | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 902 | | | 903 | 2.38k | vars.data = ptr; | 904 | 2.38k | vars.abfd = abfd; | 905 | 2.38k | vars.sec_index = 0; | 906 | 2.38k | vars.magic = magic; | 907 | | | 908 | | /* Create the initial .idata$<n> sections: | 909 | | [.idata$2: Import Directory Table -- not needed] | 910 | | .idata$4: Import Lookup Table | 911 | | .idata$5: Import Address Table | 912 | | | 913 | | Note we do not create a .idata$3 section as this is | 914 | | created for us by the linker script. */ | 915 | 2.38k | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 916 | 2.38k | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 917 | 2.38k | if (id4 == NULL || id5 == NULL) | 918 | 0 | goto error_return; | 919 | | | 920 | | /* Fill in the contents of these sections. */ | 921 | 2.38k | if (import_name_type == IMPORT_ORDINAL) | 922 | 1.04k | { | 923 | 1.04k | if (ordinal == 0) | 924 | | /* See PR 20907 for a reproducer. */ | 925 | 114 | goto error_return; | 926 | | | 927 | 930 | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 928 | 930 | ((unsigned int *) id4->contents)[0] = ordinal; | 929 | 930 | ((unsigned int *) id4->contents)[1] = 0x80000000; | 930 | 930 | ((unsigned int *) id5->contents)[0] = ordinal; | 931 | 930 | ((unsigned int *) id5->contents)[1] = 0x80000000; | 932 | | #else | 933 | | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 934 | | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 935 | | #endif | 936 | 930 | } | 937 | 1.34k | else | 938 | 1.34k | { | 939 | 1.34k | char * symbol; | 940 | 1.34k | unsigned int len; | 941 | | | 942 | | /* Create .idata$6 - the Hint Name Table. */ | 943 | 1.34k | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 944 | 1.34k | if (id6 == NULL) | 945 | 0 | goto error_return; | 946 | | | 947 | | /* If necessary, trim the import symbol name. */ | 948 | 1.34k | symbol = symbol_name; | 949 | | | 950 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 951 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 952 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 953 | | of these is used for a symbol. We strip this leading char for | 954 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 955 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 956 | | | 957 | 1.34k | if (import_name_type != IMPORT_NAME) | 958 | 763 | { | 959 | 763 | char c = symbol[0]; | 960 | | | 961 | | /* Check that we don't remove for targets with empty | 962 | | USER_LABEL_PREFIX the leading underscore. */ | 963 | 763 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 964 | 763 | || c == '@' || c == '?') | 965 | 240 | symbol++; | 966 | 763 | } | 967 | | | 968 | 1.34k | len = strlen (symbol); | 969 | 1.34k | if (import_name_type == IMPORT_NAME_UNDECORATE) | 970 | 755 | { | 971 | | /* Truncate at the first '@'. */ | 972 | 755 | char *at = strchr (symbol, '@'); | 973 | | | 974 | 755 | if (at != NULL) | 975 | 2 | len = at - symbol; | 976 | 755 | } | 977 | | | 978 | 1.34k | id6->contents[0] = ordinal & 0xff; | 979 | 1.34k | id6->contents[1] = ordinal >> 8; | 980 | | | 981 | 1.34k | memcpy ((char *) id6->contents + 2, symbol, len); | 982 | 1.34k | id6->contents[len + 2] = '\0'; | 983 | 1.34k | } | 984 | | | 985 | 2.27k | if (import_name_type != IMPORT_ORDINAL) | 986 | 1.34k | { | 987 | 1.34k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 988 | 1.34k | pe_ILF_save_relocs (&vars, id4); | 989 | | | 990 | 1.34k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 991 | 1.34k | pe_ILF_save_relocs (&vars, id5); | 992 | 1.34k | } | 993 | | | 994 | | /* Create an import symbol. */ | 995 | 2.27k | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 996 | 2.27k | imp_sym = vars.sym_ptr_ptr - 1; | 997 | 2.27k | imp_index = vars.sym_index - 1; | 998 | | | 999 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1000 | 2.27k | switch (import_type) | 1001 | 2.27k | { | 1002 | 0 | int i; | 1003 | | | 1004 | 711 | case IMPORT_CODE: | 1005 | | /* CODE functions are special, in that they get a trampoline that | 1006 | | jumps to the main import symbol. Create a .text section to hold it. | 1007 | | First we need to look up its contents in the jump table. */ | 1008 | 1.42k | for (i = NUM_ENTRIES (jtab); i--;) | 1009 | 1.42k | { | 1010 | 1.42k | if (jtab[i].size == 0) | 1011 | 711 | continue; | 1012 | 711 | if (jtab[i].magic == magic) | 1013 | 711 | break; | 1014 | 711 | } | 1015 | | /* If we did not find a matching entry something is wrong. */ | 1016 | 711 | if (i < 0) | 1017 | 0 | abort (); | 1018 | | | 1019 | | /* Create the .text section. */ | 1020 | 711 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1021 | 711 | if (text == NULL) | 1022 | 0 | goto error_return; | 1023 | | | 1024 | | /* Copy in the jump code. */ | 1025 | 711 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1026 | | | 1027 | | /* Create a reloc for the data in the text section. */ | 1028 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1029 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1030 | | { | 1031 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1032 | | (struct bfd_symbol **) imp_sym, | 1033 | | imp_index); | 1034 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1035 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1036 | | (struct bfd_symbol **) imp_sym, | 1037 | | imp_index); | 1038 | | } | 1039 | | else | 1040 | | #endif | 1041 | | #ifdef AMD64MAGIC | 1042 | | if (magic == AMD64MAGIC) | 1043 | | { | 1044 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1045 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1046 | | imp_index); | 1047 | | } | 1048 | | else | 1049 | | #endif | 1050 | 711 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1051 | 711 | BFD_RELOC_32, (asymbol **) imp_sym, | 1052 | 711 | imp_index); | 1053 | | | 1054 | 711 | pe_ILF_save_relocs (& vars, text); | 1055 | 711 | break; | 1056 | | | 1057 | 1.56k | case IMPORT_DATA: | 1058 | 1.56k | break; | 1059 | | | 1060 | 0 | default: | 1061 | | /* XXX code not yet written. */ | 1062 | 0 | abort (); | 1063 | 2.27k | } | 1064 | | | 1065 | | /* Now create a symbol describing the imported value. */ | 1066 | 2.27k | switch (import_type) | 1067 | 2.27k | { | 1068 | 711 | case IMPORT_CODE: | 1069 | 711 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1070 | 711 | BSF_NOT_AT_END | BSF_FUNCTION); | 1071 | | | 1072 | 711 | break; | 1073 | | | 1074 | 1.56k | case IMPORT_DATA: | 1075 | | /* Nothing to do here. */ | 1076 | 1.56k | break; | 1077 | | | 1078 | 0 | default: | 1079 | | /* XXX code not yet written. */ | 1080 | 0 | abort (); | 1081 | 2.27k | } | 1082 | | | 1083 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1084 | 2.27k | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1085 | 2.27k | if (ptr) | 1086 | 477 | * ptr = 0; | 1087 | 2.27k | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1088 | 2.27k | if (ptr) | 1089 | 477 | * ptr = '.'; | 1090 | | | 1091 | | /* Initialise the bfd. */ | 1092 | 2.27k | memset (& internal_f, 0, sizeof (internal_f)); | 1093 | | | 1094 | 2.27k | internal_f.f_magic = magic; | 1095 | 2.27k | internal_f.f_symptr = 0; | 1096 | 2.27k | internal_f.f_nsyms = 0; | 1097 | 2.27k | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1098 | | | 1099 | 2.27k | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1100 | 2.27k | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1101 | 0 | goto error_return; | 1102 | | | 1103 | 2.27k | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1104 | 0 | goto error_return; | 1105 | | | 1106 | 2.27k | obj_pe (abfd) = true; | 1107 | | #ifdef THUMBPEMAGIC | 1108 | | if (vars.magic == THUMBPEMAGIC) | 1109 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1110 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1111 | | #endif | 1112 | | | 1113 | | /* Switch from file contents to memory contents. */ | 1114 | 2.27k | bfd_cache_close (abfd); | 1115 | | | 1116 | 2.27k | abfd->iostream = (void *) vars.bim; | 1117 | 2.27k | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1118 | 2.27k | abfd->iovec = &_bfd_memory_iovec; | 1119 | 2.27k | abfd->where = 0; | 1120 | 2.27k | abfd->origin = 0; | 1121 | 2.27k | abfd->size = 0; | 1122 | 2.27k | obj_sym_filepos (abfd) = 0; | 1123 | | | 1124 | | /* Point the bfd at the symbol table. */ | 1125 | 2.27k | obj_symbols (abfd) = vars.sym_cache; | 1126 | 2.27k | abfd->symcount = vars.sym_index; | 1127 | | | 1128 | 2.27k | obj_raw_syments (abfd) = vars.native_syms; | 1129 | 2.27k | obj_raw_syment_count (abfd) = vars.sym_index; | 1130 | | | 1131 | 2.27k | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1132 | 2.27k | obj_coff_keep_syms (abfd) = true; | 1133 | | | 1134 | 2.27k | obj_convert (abfd) = vars.sym_table; | 1135 | 2.27k | obj_conv_table_size (abfd) = vars.sym_index; | 1136 | | | 1137 | 2.27k | obj_coff_strings (abfd) = vars.string_table; | 1138 | 2.27k | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1139 | 2.27k | obj_coff_keep_strings (abfd) = true; | 1140 | | | 1141 | 2.27k | return true; | 1142 | | | 1143 | 114 | error_return: | 1144 | 114 | free (vars.bim->buffer); | 1145 | 114 | free (vars.bim); | 1146 | 114 | return false; | 1147 | 2.27k | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_build_a_bfd pei-loongarch64.c:pe_ILF_build_a_bfd Line | Count | Source | 786 | 2.29k | { | 787 | 2.29k | bfd_byte * ptr; | 788 | 2.29k | pe_ILF_vars vars; | 789 | 2.29k | struct internal_filehdr internal_f; | 790 | 2.29k | unsigned int import_type; | 791 | 2.29k | unsigned int import_name_type; | 792 | 2.29k | asection_ptr id4, id5, id6 = NULL, text = NULL; | 793 | 2.29k | coff_symbol_type ** imp_sym; | 794 | 2.29k | unsigned int imp_index; | 795 | 2.29k | intptr_t alignment; | 796 | | | 797 | | /* Decode and verify the types field of the ILF structure. */ | 798 | 2.29k | import_type = types & 0x3; | 799 | 2.29k | import_name_type = (types & 0x1c) >> 2; | 800 | | | 801 | 2.29k | switch (import_type) | 802 | 2.29k | { | 803 | 924 | case IMPORT_CODE: | 804 | 1.76k | case IMPORT_DATA: | 805 | 1.76k | break; | 806 | | | 807 | 316 | case IMPORT_CONST: | 808 | | /* XXX code yet to be written. */ | 809 | | /* xgettext:c-format */ | 810 | 316 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 811 | 316 | abfd, import_type); | 812 | 316 | return false; | 813 | | | 814 | 215 | default: | 815 | | /* xgettext:c-format */ | 816 | 215 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 817 | 215 | abfd, import_type); | 818 | 215 | return false; | 819 | 2.29k | } | 820 | | | 821 | 1.76k | switch (import_name_type) | 822 | 1.76k | { | 823 | 703 | case IMPORT_ORDINAL: | 824 | 1.05k | case IMPORT_NAME: | 825 | 1.05k | case IMPORT_NAME_NOPREFIX: | 826 | 1.54k | case IMPORT_NAME_UNDECORATE: | 827 | 1.54k | break; | 828 | | | 829 | 219 | default: | 830 | | /* xgettext:c-format */ | 831 | 219 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 832 | 219 | abfd, import_name_type); | 833 | 219 | return false; | 834 | 1.76k | } | 835 | | | 836 | | /* Initialise local variables. | 837 | | | 838 | | Note these are kept in a structure rather than being | 839 | | declared as statics since bfd frowns on global variables. | 840 | | | 841 | | We are going to construct the contents of the BFD in memory, | 842 | | so allocate all the space that we will need right now. */ | 843 | 1.54k | vars.bim | 844 | 1.54k | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 845 | 1.54k | if (vars.bim == NULL) | 846 | 0 | return false; | 847 | | | 848 | 1.54k | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 849 | 1.54k | vars.bim->buffer = ptr; | 850 | 1.54k | vars.bim->size = ILF_DATA_SIZE; | 851 | 1.54k | if (ptr == NULL) | 852 | 0 | goto error_return; | 853 | | | 854 | | /* Initialise the pointers to regions of the memory and the | 855 | | other contents of the pe_ILF_vars structure as well. */ | 856 | 1.54k | vars.sym_cache = (coff_symbol_type *) ptr; | 857 | 1.54k | vars.sym_ptr = (coff_symbol_type *) ptr; | 858 | 1.54k | vars.sym_index = 0; | 859 | 1.54k | ptr += SIZEOF_ILF_SYMS; | 860 | | | 861 | 1.54k | vars.sym_table = (unsigned int *) ptr; | 862 | 1.54k | vars.table_ptr = (unsigned int *) ptr; | 863 | 1.54k | ptr += SIZEOF_ILF_SYM_TABLE; | 864 | | | 865 | 1.54k | vars.native_syms = (combined_entry_type *) ptr; | 866 | 1.54k | vars.native_ptr = (combined_entry_type *) ptr; | 867 | 1.54k | ptr += SIZEOF_ILF_NATIVE_SYMS; | 868 | | | 869 | 1.54k | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 870 | 1.54k | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 871 | 1.54k | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 872 | | | 873 | 1.54k | vars.esym_table = (SYMENT *) ptr; | 874 | 1.54k | vars.esym_ptr = (SYMENT *) ptr; | 875 | 1.54k | ptr += SIZEOF_ILF_EXT_SYMS; | 876 | | | 877 | 1.54k | vars.reltab = (arelent *) ptr; | 878 | 1.54k | vars.relcount = 0; | 879 | 1.54k | ptr += SIZEOF_ILF_RELOCS; | 880 | | | 881 | 1.54k | vars.int_reltab = (struct internal_reloc *) ptr; | 882 | 1.54k | ptr += SIZEOF_ILF_INT_RELOCS; | 883 | | | 884 | 1.54k | vars.string_table = (char *) ptr; | 885 | 1.54k | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 886 | 1.54k | ptr += SIZEOF_ILF_STRINGS; | 887 | 1.54k | vars.end_string_ptr = (char *) ptr; | 888 | | | 889 | | /* The remaining space in bim->buffer is used | 890 | | by the pe_ILF_make_a_section() function. */ | 891 | | | 892 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 893 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 894 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 895 | | alignment. */ | 896 | 1.54k | #if GCC_VERSION >= 3000 | 897 | 1.54k | alignment = __alignof__ (struct coff_section_tdata); | 898 | | #else | 899 | | alignment = 8; | 900 | | #endif | 901 | 1.54k | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 902 | | | 903 | 1.54k | vars.data = ptr; | 904 | 1.54k | vars.abfd = abfd; | 905 | 1.54k | vars.sec_index = 0; | 906 | 1.54k | vars.magic = magic; | 907 | | | 908 | | /* Create the initial .idata$<n> sections: | 909 | | [.idata$2: Import Directory Table -- not needed] | 910 | | .idata$4: Import Lookup Table | 911 | | .idata$5: Import Address Table | 912 | | | 913 | | Note we do not create a .idata$3 section as this is | 914 | | created for us by the linker script. */ | 915 | 1.54k | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 916 | 1.54k | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 917 | 1.54k | if (id4 == NULL || id5 == NULL) | 918 | 0 | goto error_return; | 919 | | | 920 | | /* Fill in the contents of these sections. */ | 921 | 1.54k | if (import_name_type == IMPORT_ORDINAL) | 922 | 703 | { | 923 | 703 | if (ordinal == 0) | 924 | | /* See PR 20907 for a reproducer. */ | 925 | 215 | goto error_return; | 926 | | | 927 | 488 | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 928 | 488 | ((unsigned int *) id4->contents)[0] = ordinal; | 929 | 488 | ((unsigned int *) id4->contents)[1] = 0x80000000; | 930 | 488 | ((unsigned int *) id5->contents)[0] = ordinal; | 931 | 488 | ((unsigned int *) id5->contents)[1] = 0x80000000; | 932 | | #else | 933 | | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 934 | | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 935 | | #endif | 936 | 488 | } | 937 | 843 | else | 938 | 843 | { | 939 | 843 | char * symbol; | 940 | 843 | unsigned int len; | 941 | | | 942 | | /* Create .idata$6 - the Hint Name Table. */ | 943 | 843 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 944 | 843 | if (id6 == NULL) | 945 | 0 | goto error_return; | 946 | | | 947 | | /* If necessary, trim the import symbol name. */ | 948 | 843 | symbol = symbol_name; | 949 | | | 950 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 951 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 952 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 953 | | of these is used for a symbol. We strip this leading char for | 954 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 955 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 956 | | | 957 | 843 | if (import_name_type != IMPORT_NAME) | 958 | 493 | { | 959 | 493 | char c = symbol[0]; | 960 | | | 961 | | /* Check that we don't remove for targets with empty | 962 | | USER_LABEL_PREFIX the leading underscore. */ | 963 | 493 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 964 | 493 | || c == '@' || c == '?') | 965 | 275 | symbol++; | 966 | 493 | } | 967 | | | 968 | 843 | len = strlen (symbol); | 969 | 843 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 970 | 487 | { | 971 | | /* Truncate at the first '@'. */ | 972 | 487 | char *at = strchr (symbol, '@'); | 973 | | | 974 | 487 | if (at != NULL) | 975 | 2 | len = at - symbol; | 976 | 487 | } | 977 | | | 978 | 843 | id6->contents[0] = ordinal & 0xff; | 979 | 843 | id6->contents[1] = ordinal >> 8; | 980 | | | 981 | 843 | memcpy ((char *) id6->contents + 2, symbol, len); | 982 | 843 | id6->contents[len + 2] = '\0'; | 983 | 843 | } | 984 | | | 985 | 1.33k | if (import_name_type != IMPORT_ORDINAL) | 986 | 843 | { | 987 | 843 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 988 | 843 | pe_ILF_save_relocs (&vars, id4); | 989 | | | 990 | 843 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 991 | 843 | pe_ILF_save_relocs (&vars, id5); | 992 | 843 | } | 993 | | | 994 | | /* Create an import symbol. */ | 995 | 1.33k | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 996 | 1.33k | imp_sym = vars.sym_ptr_ptr - 1; | 997 | 1.33k | imp_index = vars.sym_index - 1; | 998 | | | 999 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1000 | 1.33k | switch (import_type) | 1001 | 1.33k | { | 1002 | 0 | int i; | 1003 | | | 1004 | 603 | case IMPORT_CODE: | 1005 | | /* CODE functions are special, in that they get a trampoline that | 1006 | | jumps to the main import symbol. Create a .text section to hold it. | 1007 | | First we need to look up its contents in the jump table. */ | 1008 | 1.20k | for (i = NUM_ENTRIES (jtab); i--;) | 1009 | 1.20k | { | 1010 | 1.20k | if (jtab[i].size == 0) | 1011 | 603 | continue; | 1012 | 603 | if (jtab[i].magic == magic) | 1013 | 603 | break; | 1014 | 603 | } | 1015 | | /* If we did not find a matching entry something is wrong. */ | 1016 | 603 | if (i < 0) | 1017 | 0 | abort (); | 1018 | | | 1019 | | /* Create the .text section. */ | 1020 | 603 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1021 | 603 | if (text == NULL) | 1022 | 0 | goto error_return; | 1023 | | | 1024 | | /* Copy in the jump code. */ | 1025 | 603 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1026 | | | 1027 | | /* Create a reloc for the data in the text section. */ | 1028 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1029 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1030 | | { | 1031 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1032 | | (struct bfd_symbol **) imp_sym, | 1033 | | imp_index); | 1034 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1035 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1036 | | (struct bfd_symbol **) imp_sym, | 1037 | | imp_index); | 1038 | | } | 1039 | | else | 1040 | | #endif | 1041 | | #ifdef AMD64MAGIC | 1042 | | if (magic == AMD64MAGIC) | 1043 | | { | 1044 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1045 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1046 | | imp_index); | 1047 | | } | 1048 | | else | 1049 | | #endif | 1050 | 603 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1051 | 603 | BFD_RELOC_32, (asymbol **) imp_sym, | 1052 | 603 | imp_index); | 1053 | | | 1054 | 603 | pe_ILF_save_relocs (& vars, text); | 1055 | 603 | break; | 1056 | | | 1057 | 728 | case IMPORT_DATA: | 1058 | 728 | break; | 1059 | | | 1060 | 0 | default: | 1061 | | /* XXX code not yet written. */ | 1062 | 0 | abort (); | 1063 | 1.33k | } | 1064 | | | 1065 | | /* Now create a symbol describing the imported value. */ | 1066 | 1.33k | switch (import_type) | 1067 | 1.33k | { | 1068 | 603 | case IMPORT_CODE: | 1069 | 603 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1070 | 603 | BSF_NOT_AT_END | BSF_FUNCTION); | 1071 | | | 1072 | 603 | break; | 1073 | | | 1074 | 728 | case IMPORT_DATA: | 1075 | | /* Nothing to do here. */ | 1076 | 728 | break; | 1077 | | | 1078 | 0 | default: | 1079 | | /* XXX code not yet written. */ | 1080 | 0 | abort (); | 1081 | 1.33k | } | 1082 | | | 1083 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1084 | 1.33k | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1085 | 1.33k | if (ptr) | 1086 | 274 | * ptr = 0; | 1087 | 1.33k | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1088 | 1.33k | if (ptr) | 1089 | 274 | * ptr = '.'; | 1090 | | | 1091 | | /* Initialise the bfd. */ | 1092 | 1.33k | memset (& internal_f, 0, sizeof (internal_f)); | 1093 | | | 1094 | 1.33k | internal_f.f_magic = magic; | 1095 | 1.33k | internal_f.f_symptr = 0; | 1096 | 1.33k | internal_f.f_nsyms = 0; | 1097 | 1.33k | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1098 | | | 1099 | 1.33k | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1100 | 1.33k | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1101 | 0 | goto error_return; | 1102 | | | 1103 | 1.33k | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1104 | 0 | goto error_return; | 1105 | | | 1106 | 1.33k | obj_pe (abfd) = true; | 1107 | | #ifdef THUMBPEMAGIC | 1108 | | if (vars.magic == THUMBPEMAGIC) | 1109 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1110 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1111 | | #endif | 1112 | | | 1113 | | /* Switch from file contents to memory contents. */ | 1114 | 1.33k | bfd_cache_close (abfd); | 1115 | | | 1116 | 1.33k | abfd->iostream = (void *) vars.bim; | 1117 | 1.33k | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1118 | 1.33k | abfd->iovec = &_bfd_memory_iovec; | 1119 | 1.33k | abfd->where = 0; | 1120 | 1.33k | abfd->origin = 0; | 1121 | 1.33k | abfd->size = 0; | 1122 | 1.33k | obj_sym_filepos (abfd) = 0; | 1123 | | | 1124 | | /* Point the bfd at the symbol table. */ | 1125 | 1.33k | obj_symbols (abfd) = vars.sym_cache; | 1126 | 1.33k | abfd->symcount = vars.sym_index; | 1127 | | | 1128 | 1.33k | obj_raw_syments (abfd) = vars.native_syms; | 1129 | 1.33k | obj_raw_syment_count (abfd) = vars.sym_index; | 1130 | | | 1131 | 1.33k | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1132 | 1.33k | obj_coff_keep_syms (abfd) = true; | 1133 | | | 1134 | 1.33k | obj_convert (abfd) = vars.sym_table; | 1135 | 1.33k | obj_conv_table_size (abfd) = vars.sym_index; | 1136 | | | 1137 | 1.33k | obj_coff_strings (abfd) = vars.string_table; | 1138 | 1.33k | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1139 | 1.33k | obj_coff_keep_strings (abfd) = true; | 1140 | | | 1141 | 1.33k | return true; | 1142 | | | 1143 | 215 | error_return: | 1144 | 215 | free (vars.bim->buffer); | 1145 | 215 | free (vars.bim); | 1146 | 215 | return false; | 1147 | 1.33k | } |
pei-arm-wince.c:pe_ILF_build_a_bfd Line | Count | Source | 786 | 1.35k | { | 787 | 1.35k | bfd_byte * ptr; | 788 | 1.35k | pe_ILF_vars vars; | 789 | 1.35k | struct internal_filehdr internal_f; | 790 | 1.35k | unsigned int import_type; | 791 | 1.35k | unsigned int import_name_type; | 792 | 1.35k | asection_ptr id4, id5, id6 = NULL, text = NULL; | 793 | 1.35k | coff_symbol_type ** imp_sym; | 794 | 1.35k | unsigned int imp_index; | 795 | 1.35k | intptr_t alignment; | 796 | | | 797 | | /* Decode and verify the types field of the ILF structure. */ | 798 | 1.35k | import_type = types & 0x3; | 799 | 1.35k | import_name_type = (types & 0x1c) >> 2; | 800 | | | 801 | 1.35k | switch (import_type) | 802 | 1.35k | { | 803 | 281 | case IMPORT_CODE: | 804 | 519 | case IMPORT_DATA: | 805 | 519 | break; | 806 | | | 807 | 519 | case IMPORT_CONST: | 808 | | /* XXX code yet to be written. */ | 809 | | /* xgettext:c-format */ | 810 | 519 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 811 | 519 | abfd, import_type); | 812 | 519 | return false; | 813 | | | 814 | 319 | default: | 815 | | /* xgettext:c-format */ | 816 | 319 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 817 | 319 | abfd, import_type); | 818 | 319 | return false; | 819 | 1.35k | } | 820 | | | 821 | 519 | switch (import_name_type) | 822 | 519 | { | 823 | 252 | case IMPORT_ORDINAL: | 824 | 263 | case IMPORT_NAME: | 825 | 284 | case IMPORT_NAME_NOPREFIX: | 826 | 304 | case IMPORT_NAME_UNDECORATE: | 827 | 304 | break; | 828 | | | 829 | 215 | default: | 830 | | /* xgettext:c-format */ | 831 | 215 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 832 | 215 | abfd, import_name_type); | 833 | 215 | return false; | 834 | 519 | } | 835 | | | 836 | | /* Initialise local variables. | 837 | | | 838 | | Note these are kept in a structure rather than being | 839 | | declared as statics since bfd frowns on global variables. | 840 | | | 841 | | We are going to construct the contents of the BFD in memory, | 842 | | so allocate all the space that we will need right now. */ | 843 | 304 | vars.bim | 844 | 304 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 845 | 304 | if (vars.bim == NULL) | 846 | 0 | return false; | 847 | | | 848 | 304 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 849 | 304 | vars.bim->buffer = ptr; | 850 | 304 | vars.bim->size = ILF_DATA_SIZE; | 851 | 304 | if (ptr == NULL) | 852 | 0 | goto error_return; | 853 | | | 854 | | /* Initialise the pointers to regions of the memory and the | 855 | | other contents of the pe_ILF_vars structure as well. */ | 856 | 304 | vars.sym_cache = (coff_symbol_type *) ptr; | 857 | 304 | vars.sym_ptr = (coff_symbol_type *) ptr; | 858 | 304 | vars.sym_index = 0; | 859 | 304 | ptr += SIZEOF_ILF_SYMS; | 860 | | | 861 | 304 | vars.sym_table = (unsigned int *) ptr; | 862 | 304 | vars.table_ptr = (unsigned int *) ptr; | 863 | 304 | ptr += SIZEOF_ILF_SYM_TABLE; | 864 | | | 865 | 304 | vars.native_syms = (combined_entry_type *) ptr; | 866 | 304 | vars.native_ptr = (combined_entry_type *) ptr; | 867 | 304 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 868 | | | 869 | 304 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 870 | 304 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 871 | 304 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 872 | | | 873 | 304 | vars.esym_table = (SYMENT *) ptr; | 874 | 304 | vars.esym_ptr = (SYMENT *) ptr; | 875 | 304 | ptr += SIZEOF_ILF_EXT_SYMS; | 876 | | | 877 | 304 | vars.reltab = (arelent *) ptr; | 878 | 304 | vars.relcount = 0; | 879 | 304 | ptr += SIZEOF_ILF_RELOCS; | 880 | | | 881 | 304 | vars.int_reltab = (struct internal_reloc *) ptr; | 882 | 304 | ptr += SIZEOF_ILF_INT_RELOCS; | 883 | | | 884 | 304 | vars.string_table = (char *) ptr; | 885 | 304 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 886 | 304 | ptr += SIZEOF_ILF_STRINGS; | 887 | 304 | vars.end_string_ptr = (char *) ptr; | 888 | | | 889 | | /* The remaining space in bim->buffer is used | 890 | | by the pe_ILF_make_a_section() function. */ | 891 | | | 892 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 893 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 894 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 895 | | alignment. */ | 896 | 304 | #if GCC_VERSION >= 3000 | 897 | 304 | alignment = __alignof__ (struct coff_section_tdata); | 898 | | #else | 899 | | alignment = 8; | 900 | | #endif | 901 | 304 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 902 | | | 903 | 304 | vars.data = ptr; | 904 | 304 | vars.abfd = abfd; | 905 | 304 | vars.sec_index = 0; | 906 | 304 | vars.magic = magic; | 907 | | | 908 | | /* Create the initial .idata$<n> sections: | 909 | | [.idata$2: Import Directory Table -- not needed] | 910 | | .idata$4: Import Lookup Table | 911 | | .idata$5: Import Address Table | 912 | | | 913 | | Note we do not create a .idata$3 section as this is | 914 | | created for us by the linker script. */ | 915 | 304 | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 916 | 304 | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 917 | 304 | if (id4 == NULL || id5 == NULL) | 918 | 0 | goto error_return; | 919 | | | 920 | | /* Fill in the contents of these sections. */ | 921 | 304 | if (import_name_type == IMPORT_ORDINAL) | 922 | 252 | { | 923 | 252 | if (ordinal == 0) | 924 | | /* See PR 20907 for a reproducer. */ | 925 | 224 | goto error_return; | 926 | | | 927 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 928 | | ((unsigned int *) id4->contents)[0] = ordinal; | 929 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 930 | | ((unsigned int *) id5->contents)[0] = ordinal; | 931 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 932 | | #else | 933 | 28 | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 934 | 28 | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 935 | 28 | #endif | 936 | 28 | } | 937 | 52 | else | 938 | 52 | { | 939 | 52 | char * symbol; | 940 | 52 | unsigned int len; | 941 | | | 942 | | /* Create .idata$6 - the Hint Name Table. */ | 943 | 52 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 944 | 52 | if (id6 == NULL) | 945 | 0 | goto error_return; | 946 | | | 947 | | /* If necessary, trim the import symbol name. */ | 948 | 52 | symbol = symbol_name; | 949 | | | 950 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 951 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 952 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 953 | | of these is used for a symbol. We strip this leading char for | 954 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 955 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 956 | | | 957 | 52 | if (import_name_type != IMPORT_NAME) | 958 | 41 | { | 959 | 41 | char c = symbol[0]; | 960 | | | 961 | | /* Check that we don't remove for targets with empty | 962 | | USER_LABEL_PREFIX the leading underscore. */ | 963 | 41 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 964 | 41 | || c == '@' || c == '?') | 965 | 5 | symbol++; | 966 | 41 | } | 967 | | | 968 | 52 | len = strlen (symbol); | 969 | 52 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 970 | 20 | { | 971 | | /* Truncate at the first '@'. */ | 972 | 20 | char *at = strchr (symbol, '@'); | 973 | | | 974 | 20 | if (at != NULL) | 975 | 4 | len = at - symbol; | 976 | 20 | } | 977 | | | 978 | 52 | id6->contents[0] = ordinal & 0xff; | 979 | 52 | id6->contents[1] = ordinal >> 8; | 980 | | | 981 | 52 | memcpy ((char *) id6->contents + 2, symbol, len); | 982 | 52 | id6->contents[len + 2] = '\0'; | 983 | 52 | } | 984 | | | 985 | 80 | if (import_name_type != IMPORT_ORDINAL) | 986 | 52 | { | 987 | 52 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 988 | 52 | pe_ILF_save_relocs (&vars, id4); | 989 | | | 990 | 52 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 991 | 52 | pe_ILF_save_relocs (&vars, id5); | 992 | 52 | } | 993 | | | 994 | | /* Create an import symbol. */ | 995 | 80 | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 996 | 80 | imp_sym = vars.sym_ptr_ptr - 1; | 997 | 80 | imp_index = vars.sym_index - 1; | 998 | | | 999 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1000 | 80 | switch (import_type) | 1001 | 80 | { | 1002 | 0 | int i; | 1003 | | | 1004 | 50 | case IMPORT_CODE: | 1005 | | /* CODE functions are special, in that they get a trampoline that | 1006 | | jumps to the main import symbol. Create a .text section to hold it. | 1007 | | First we need to look up its contents in the jump table. */ | 1008 | 129 | for (i = NUM_ENTRIES (jtab); i--;) | 1009 | 129 | { | 1010 | 129 | if (jtab[i].size == 0) | 1011 | 50 | continue; | 1012 | 79 | if (jtab[i].magic == magic) | 1013 | 50 | break; | 1014 | 79 | } | 1015 | | /* If we did not find a matching entry something is wrong. */ | 1016 | 50 | if (i < 0) | 1017 | 0 | abort (); | 1018 | | | 1019 | | /* Create the .text section. */ | 1020 | 50 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1021 | 50 | if (text == NULL) | 1022 | 0 | goto error_return; | 1023 | | | 1024 | | /* Copy in the jump code. */ | 1025 | 50 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1026 | | | 1027 | | /* Create a reloc for the data in the text section. */ | 1028 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1029 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1030 | | { | 1031 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1032 | | (struct bfd_symbol **) imp_sym, | 1033 | | imp_index); | 1034 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1035 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1036 | | (struct bfd_symbol **) imp_sym, | 1037 | | imp_index); | 1038 | | } | 1039 | | else | 1040 | | #endif | 1041 | | #ifdef AMD64MAGIC | 1042 | | if (magic == AMD64MAGIC) | 1043 | | { | 1044 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1045 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1046 | | imp_index); | 1047 | | } | 1048 | | else | 1049 | | #endif | 1050 | 50 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1051 | 50 | BFD_RELOC_32, (asymbol **) imp_sym, | 1052 | 50 | imp_index); | 1053 | | | 1054 | 50 | pe_ILF_save_relocs (& vars, text); | 1055 | 50 | break; | 1056 | | | 1057 | 30 | case IMPORT_DATA: | 1058 | 30 | break; | 1059 | | | 1060 | 0 | default: | 1061 | | /* XXX code not yet written. */ | 1062 | 0 | abort (); | 1063 | 80 | } | 1064 | | | 1065 | | /* Now create a symbol describing the imported value. */ | 1066 | 80 | switch (import_type) | 1067 | 80 | { | 1068 | 50 | case IMPORT_CODE: | 1069 | 50 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1070 | 50 | BSF_NOT_AT_END | BSF_FUNCTION); | 1071 | | | 1072 | 50 | break; | 1073 | | | 1074 | 30 | case IMPORT_DATA: | 1075 | | /* Nothing to do here. */ | 1076 | 30 | break; | 1077 | | | 1078 | 0 | default: | 1079 | | /* XXX code not yet written. */ | 1080 | 0 | abort (); | 1081 | 80 | } | 1082 | | | 1083 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1084 | 80 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1085 | 80 | if (ptr) | 1086 | 12 | * ptr = 0; | 1087 | 80 | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1088 | 80 | if (ptr) | 1089 | 12 | * ptr = '.'; | 1090 | | | 1091 | | /* Initialise the bfd. */ | 1092 | 80 | memset (& internal_f, 0, sizeof (internal_f)); | 1093 | | | 1094 | 80 | internal_f.f_magic = magic; | 1095 | 80 | internal_f.f_symptr = 0; | 1096 | 80 | internal_f.f_nsyms = 0; | 1097 | 80 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1098 | | | 1099 | 80 | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1100 | 80 | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1101 | 0 | goto error_return; | 1102 | | | 1103 | 80 | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1104 | 0 | goto error_return; | 1105 | | | 1106 | 80 | obj_pe (abfd) = true; | 1107 | 80 | #ifdef THUMBPEMAGIC | 1108 | 80 | if (vars.magic == THUMBPEMAGIC) | 1109 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1110 | 35 | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1111 | 80 | #endif | 1112 | | | 1113 | | /* Switch from file contents to memory contents. */ | 1114 | 80 | bfd_cache_close (abfd); | 1115 | | | 1116 | 80 | abfd->iostream = (void *) vars.bim; | 1117 | 80 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1118 | 80 | abfd->iovec = &_bfd_memory_iovec; | 1119 | 80 | abfd->where = 0; | 1120 | 80 | abfd->origin = 0; | 1121 | 80 | abfd->size = 0; | 1122 | 80 | obj_sym_filepos (abfd) = 0; | 1123 | | | 1124 | | /* Point the bfd at the symbol table. */ | 1125 | 80 | obj_symbols (abfd) = vars.sym_cache; | 1126 | 80 | abfd->symcount = vars.sym_index; | 1127 | | | 1128 | 80 | obj_raw_syments (abfd) = vars.native_syms; | 1129 | 80 | obj_raw_syment_count (abfd) = vars.sym_index; | 1130 | | | 1131 | 80 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1132 | 80 | obj_coff_keep_syms (abfd) = true; | 1133 | | | 1134 | 80 | obj_convert (abfd) = vars.sym_table; | 1135 | 80 | obj_conv_table_size (abfd) = vars.sym_index; | 1136 | | | 1137 | 80 | obj_coff_strings (abfd) = vars.string_table; | 1138 | 80 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1139 | 80 | obj_coff_keep_strings (abfd) = true; | 1140 | | | 1141 | 80 | return true; | 1142 | | | 1143 | 224 | error_return: | 1144 | 224 | free (vars.bim->buffer); | 1145 | 224 | free (vars.bim); | 1146 | 224 | return false; | 1147 | 80 | } |
pei-arm.c:pe_ILF_build_a_bfd Line | Count | Source | 786 | 4.60k | { | 787 | 4.60k | bfd_byte * ptr; | 788 | 4.60k | pe_ILF_vars vars; | 789 | 4.60k | struct internal_filehdr internal_f; | 790 | 4.60k | unsigned int import_type; | 791 | 4.60k | unsigned int import_name_type; | 792 | 4.60k | asection_ptr id4, id5, id6 = NULL, text = NULL; | 793 | 4.60k | coff_symbol_type ** imp_sym; | 794 | 4.60k | unsigned int imp_index; | 795 | 4.60k | intptr_t alignment; | 796 | | | 797 | | /* Decode and verify the types field of the ILF structure. */ | 798 | 4.60k | import_type = types & 0x3; | 799 | 4.60k | import_name_type = (types & 0x1c) >> 2; | 800 | | | 801 | 4.60k | switch (import_type) | 802 | 4.60k | { | 803 | 2.47k | case IMPORT_CODE: | 804 | 3.76k | case IMPORT_DATA: | 805 | 3.76k | break; | 806 | | | 807 | 519 | case IMPORT_CONST: | 808 | | /* XXX code yet to be written. */ | 809 | | /* xgettext:c-format */ | 810 | 519 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 811 | 519 | abfd, import_type); | 812 | 519 | return false; | 813 | | | 814 | 319 | default: | 815 | | /* xgettext:c-format */ | 816 | 319 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 817 | 319 | abfd, import_type); | 818 | 319 | return false; | 819 | 4.60k | } | 820 | | | 821 | 3.76k | switch (import_name_type) | 822 | 3.76k | { | 823 | 1.83k | case IMPORT_ORDINAL: | 824 | 2.65k | case IMPORT_NAME: | 825 | 3.28k | case IMPORT_NAME_NOPREFIX: | 826 | 3.54k | case IMPORT_NAME_UNDECORATE: | 827 | 3.54k | break; | 828 | | | 829 | 215 | default: | 830 | | /* xgettext:c-format */ | 831 | 215 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 832 | 215 | abfd, import_name_type); | 833 | 215 | return false; | 834 | 3.76k | } | 835 | | | 836 | | /* Initialise local variables. | 837 | | | 838 | | Note these are kept in a structure rather than being | 839 | | declared as statics since bfd frowns on global variables. | 840 | | | 841 | | We are going to construct the contents of the BFD in memory, | 842 | | so allocate all the space that we will need right now. */ | 843 | 3.54k | vars.bim | 844 | 3.54k | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 845 | 3.54k | if (vars.bim == NULL) | 846 | 0 | return false; | 847 | | | 848 | 3.54k | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 849 | 3.54k | vars.bim->buffer = ptr; | 850 | 3.54k | vars.bim->size = ILF_DATA_SIZE; | 851 | 3.54k | if (ptr == NULL) | 852 | 0 | goto error_return; | 853 | | | 854 | | /* Initialise the pointers to regions of the memory and the | 855 | | other contents of the pe_ILF_vars structure as well. */ | 856 | 3.54k | vars.sym_cache = (coff_symbol_type *) ptr; | 857 | 3.54k | vars.sym_ptr = (coff_symbol_type *) ptr; | 858 | 3.54k | vars.sym_index = 0; | 859 | 3.54k | ptr += SIZEOF_ILF_SYMS; | 860 | | | 861 | 3.54k | vars.sym_table = (unsigned int *) ptr; | 862 | 3.54k | vars.table_ptr = (unsigned int *) ptr; | 863 | 3.54k | ptr += SIZEOF_ILF_SYM_TABLE; | 864 | | | 865 | 3.54k | vars.native_syms = (combined_entry_type *) ptr; | 866 | 3.54k | vars.native_ptr = (combined_entry_type *) ptr; | 867 | 3.54k | ptr += SIZEOF_ILF_NATIVE_SYMS; | 868 | | | 869 | 3.54k | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 870 | 3.54k | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 871 | 3.54k | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 872 | | | 873 | 3.54k | vars.esym_table = (SYMENT *) ptr; | 874 | 3.54k | vars.esym_ptr = (SYMENT *) ptr; | 875 | 3.54k | ptr += SIZEOF_ILF_EXT_SYMS; | 876 | | | 877 | 3.54k | vars.reltab = (arelent *) ptr; | 878 | 3.54k | vars.relcount = 0; | 879 | 3.54k | ptr += SIZEOF_ILF_RELOCS; | 880 | | | 881 | 3.54k | vars.int_reltab = (struct internal_reloc *) ptr; | 882 | 3.54k | ptr += SIZEOF_ILF_INT_RELOCS; | 883 | | | 884 | 3.54k | vars.string_table = (char *) ptr; | 885 | 3.54k | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 886 | 3.54k | ptr += SIZEOF_ILF_STRINGS; | 887 | 3.54k | vars.end_string_ptr = (char *) ptr; | 888 | | | 889 | | /* The remaining space in bim->buffer is used | 890 | | by the pe_ILF_make_a_section() function. */ | 891 | | | 892 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 893 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 894 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 895 | | alignment. */ | 896 | 3.54k | #if GCC_VERSION >= 3000 | 897 | 3.54k | alignment = __alignof__ (struct coff_section_tdata); | 898 | | #else | 899 | | alignment = 8; | 900 | | #endif | 901 | 3.54k | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 902 | | | 903 | 3.54k | vars.data = ptr; | 904 | 3.54k | vars.abfd = abfd; | 905 | 3.54k | vars.sec_index = 0; | 906 | 3.54k | vars.magic = magic; | 907 | | | 908 | | /* Create the initial .idata$<n> sections: | 909 | | [.idata$2: Import Directory Table -- not needed] | 910 | | .idata$4: Import Lookup Table | 911 | | .idata$5: Import Address Table | 912 | | | 913 | | Note we do not create a .idata$3 section as this is | 914 | | created for us by the linker script. */ | 915 | 3.54k | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 916 | 3.54k | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 917 | 3.54k | if (id4 == NULL || id5 == NULL) | 918 | 0 | goto error_return; | 919 | | | 920 | | /* Fill in the contents of these sections. */ | 921 | 3.54k | if (import_name_type == IMPORT_ORDINAL) | 922 | 1.83k | { | 923 | 1.83k | if (ordinal == 0) | 924 | | /* See PR 20907 for a reproducer. */ | 925 | 224 | goto error_return; | 926 | | | 927 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 928 | | ((unsigned int *) id4->contents)[0] = ordinal; | 929 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 930 | | ((unsigned int *) id5->contents)[0] = ordinal; | 931 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 932 | | #else | 933 | 1.61k | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 934 | 1.61k | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 935 | 1.61k | #endif | 936 | 1.61k | } | 937 | 1.71k | else | 938 | 1.71k | { | 939 | 1.71k | char * symbol; | 940 | 1.71k | unsigned int len; | 941 | | | 942 | | /* Create .idata$6 - the Hint Name Table. */ | 943 | 1.71k | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 944 | 1.71k | if (id6 == NULL) | 945 | 0 | goto error_return; | 946 | | | 947 | | /* If necessary, trim the import symbol name. */ | 948 | 1.71k | symbol = symbol_name; | 949 | | | 950 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 951 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 952 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 953 | | of these is used for a symbol. We strip this leading char for | 954 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 955 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 956 | | | 957 | 1.71k | if (import_name_type != IMPORT_NAME) | 958 | 895 | { | 959 | 895 | char c = symbol[0]; | 960 | | | 961 | | /* Check that we don't remove for targets with empty | 962 | | USER_LABEL_PREFIX the leading underscore. */ | 963 | 895 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 964 | 895 | || c == '@' || c == '?') | 965 | 13 | symbol++; | 966 | 895 | } | 967 | | | 968 | 1.71k | len = strlen (symbol); | 969 | 1.71k | if (import_name_type == IMPORT_NAME_UNDECORATE) | 970 | 266 | { | 971 | | /* Truncate at the first '@'. */ | 972 | 266 | char *at = strchr (symbol, '@'); | 973 | | | 974 | 266 | if (at != NULL) | 975 | 5 | len = at - symbol; | 976 | 266 | } | 977 | | | 978 | 1.71k | id6->contents[0] = ordinal & 0xff; | 979 | 1.71k | id6->contents[1] = ordinal >> 8; | 980 | | | 981 | 1.71k | memcpy ((char *) id6->contents + 2, symbol, len); | 982 | 1.71k | id6->contents[len + 2] = '\0'; | 983 | 1.71k | } | 984 | | | 985 | 3.32k | if (import_name_type != IMPORT_ORDINAL) | 986 | 1.71k | { | 987 | 1.71k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 988 | 1.71k | pe_ILF_save_relocs (&vars, id4); | 989 | | | 990 | 1.71k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 991 | 1.71k | pe_ILF_save_relocs (&vars, id5); | 992 | 1.71k | } | 993 | | | 994 | | /* Create an import symbol. */ | 995 | 3.32k | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 996 | 3.32k | imp_sym = vars.sym_ptr_ptr - 1; | 997 | 3.32k | imp_index = vars.sym_index - 1; | 998 | | | 999 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1000 | 3.32k | switch (import_type) | 1001 | 3.32k | { | 1002 | 0 | int i; | 1003 | | | 1004 | 2.24k | case IMPORT_CODE: | 1005 | | /* CODE functions are special, in that they get a trampoline that | 1006 | | jumps to the main import symbol. Create a .text section to hold it. | 1007 | | First we need to look up its contents in the jump table. */ | 1008 | 6.24k | for (i = NUM_ENTRIES (jtab); i--;) | 1009 | 6.24k | { | 1010 | 6.24k | if (jtab[i].size == 0) | 1011 | 2.24k | continue; | 1012 | 3.99k | if (jtab[i].magic == magic) | 1013 | 2.24k | break; | 1014 | 3.99k | } | 1015 | | /* If we did not find a matching entry something is wrong. */ | 1016 | 2.24k | if (i < 0) | 1017 | 0 | abort (); | 1018 | | | 1019 | | /* Create the .text section. */ | 1020 | 2.24k | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1021 | 2.24k | if (text == NULL) | 1022 | 0 | goto error_return; | 1023 | | | 1024 | | /* Copy in the jump code. */ | 1025 | 2.24k | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1026 | | | 1027 | | /* Create a reloc for the data in the text section. */ | 1028 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1029 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1030 | | { | 1031 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1032 | | (struct bfd_symbol **) imp_sym, | 1033 | | imp_index); | 1034 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1035 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1036 | | (struct bfd_symbol **) imp_sym, | 1037 | | imp_index); | 1038 | | } | 1039 | | else | 1040 | | #endif | 1041 | | #ifdef AMD64MAGIC | 1042 | | if (magic == AMD64MAGIC) | 1043 | | { | 1044 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1045 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1046 | | imp_index); | 1047 | | } | 1048 | | else | 1049 | | #endif | 1050 | 2.24k | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1051 | 2.24k | BFD_RELOC_32, (asymbol **) imp_sym, | 1052 | 2.24k | imp_index); | 1053 | | | 1054 | 2.24k | pe_ILF_save_relocs (& vars, text); | 1055 | 2.24k | break; | 1056 | | | 1057 | 1.07k | case IMPORT_DATA: | 1058 | 1.07k | break; | 1059 | | | 1060 | 0 | default: | 1061 | | /* XXX code not yet written. */ | 1062 | 0 | abort (); | 1063 | 3.32k | } | 1064 | | | 1065 | | /* Now create a symbol describing the imported value. */ | 1066 | 3.32k | switch (import_type) | 1067 | 3.32k | { | 1068 | 2.24k | case IMPORT_CODE: | 1069 | 2.24k | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1070 | 2.24k | BSF_NOT_AT_END | BSF_FUNCTION); | 1071 | | | 1072 | 2.24k | break; | 1073 | | | 1074 | 1.07k | case IMPORT_DATA: | 1075 | | /* Nothing to do here. */ | 1076 | 1.07k | break; | 1077 | | | 1078 | 0 | default: | 1079 | | /* XXX code not yet written. */ | 1080 | 0 | abort (); | 1081 | 3.32k | } | 1082 | | | 1083 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1084 | 3.32k | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1085 | 3.32k | if (ptr) | 1086 | 856 | * ptr = 0; | 1087 | 3.32k | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1088 | 3.32k | if (ptr) | 1089 | 856 | * ptr = '.'; | 1090 | | | 1091 | | /* Initialise the bfd. */ | 1092 | 3.32k | memset (& internal_f, 0, sizeof (internal_f)); | 1093 | | | 1094 | 3.32k | internal_f.f_magic = magic; | 1095 | 3.32k | internal_f.f_symptr = 0; | 1096 | 3.32k | internal_f.f_nsyms = 0; | 1097 | 3.32k | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1098 | | | 1099 | 3.32k | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1100 | 3.32k | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1101 | 0 | goto error_return; | 1102 | | | 1103 | 3.32k | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1104 | 0 | goto error_return; | 1105 | | | 1106 | 3.32k | obj_pe (abfd) = true; | 1107 | 3.32k | #ifdef THUMBPEMAGIC | 1108 | 3.32k | if (vars.magic == THUMBPEMAGIC) | 1109 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1110 | 884 | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1111 | 3.32k | #endif | 1112 | | | 1113 | | /* Switch from file contents to memory contents. */ | 1114 | 3.32k | bfd_cache_close (abfd); | 1115 | | | 1116 | 3.32k | abfd->iostream = (void *) vars.bim; | 1117 | 3.32k | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1118 | 3.32k | abfd->iovec = &_bfd_memory_iovec; | 1119 | 3.32k | abfd->where = 0; | 1120 | 3.32k | abfd->origin = 0; | 1121 | 3.32k | abfd->size = 0; | 1122 | 3.32k | obj_sym_filepos (abfd) = 0; | 1123 | | | 1124 | | /* Point the bfd at the symbol table. */ | 1125 | 3.32k | obj_symbols (abfd) = vars.sym_cache; | 1126 | 3.32k | abfd->symcount = vars.sym_index; | 1127 | | | 1128 | 3.32k | obj_raw_syments (abfd) = vars.native_syms; | 1129 | 3.32k | obj_raw_syment_count (abfd) = vars.sym_index; | 1130 | | | 1131 | 3.32k | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1132 | 3.32k | obj_coff_keep_syms (abfd) = true; | 1133 | | | 1134 | 3.32k | obj_convert (abfd) = vars.sym_table; | 1135 | 3.32k | obj_conv_table_size (abfd) = vars.sym_index; | 1136 | | | 1137 | 3.32k | obj_coff_strings (abfd) = vars.string_table; | 1138 | 3.32k | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1139 | 3.32k | obj_coff_keep_strings (abfd) = true; | 1140 | | | 1141 | 3.32k | return true; | 1142 | | | 1143 | 224 | error_return: | 1144 | 224 | free (vars.bim->buffer); | 1145 | 224 | free (vars.bim); | 1146 | 224 | return false; | 1147 | 3.32k | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_build_a_bfd pei-sh.c:pe_ILF_build_a_bfd Line | Count | Source | 786 | 3.53k | { | 787 | 3.53k | bfd_byte * ptr; | 788 | 3.53k | pe_ILF_vars vars; | 789 | 3.53k | struct internal_filehdr internal_f; | 790 | 3.53k | unsigned int import_type; | 791 | 3.53k | unsigned int import_name_type; | 792 | 3.53k | asection_ptr id4, id5, id6 = NULL, text = NULL; | 793 | 3.53k | coff_symbol_type ** imp_sym; | 794 | 3.53k | unsigned int imp_index; | 795 | 3.53k | intptr_t alignment; | 796 | | | 797 | | /* Decode and verify the types field of the ILF structure. */ | 798 | 3.53k | import_type = types & 0x3; | 799 | 3.53k | import_name_type = (types & 0x1c) >> 2; | 800 | | | 801 | 3.53k | switch (import_type) | 802 | 3.53k | { | 803 | 2.32k | case IMPORT_CODE: | 804 | 3.20k | case IMPORT_DATA: | 805 | 3.20k | break; | 806 | | | 807 | 114 | case IMPORT_CONST: | 808 | | /* XXX code yet to be written. */ | 809 | | /* xgettext:c-format */ | 810 | 114 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 811 | 114 | abfd, import_type); | 812 | 114 | return false; | 813 | | | 814 | 215 | default: | 815 | | /* xgettext:c-format */ | 816 | 215 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 817 | 215 | abfd, import_type); | 818 | 215 | return false; | 819 | 3.53k | } | 820 | | | 821 | 3.20k | switch (import_name_type) | 822 | 3.20k | { | 823 | 1.05k | case IMPORT_ORDINAL: | 824 | 2.11k | case IMPORT_NAME: | 825 | 2.38k | case IMPORT_NAME_NOPREFIX: | 826 | 2.98k | case IMPORT_NAME_UNDECORATE: | 827 | 2.98k | break; | 828 | | | 829 | 218 | default: | 830 | | /* xgettext:c-format */ | 831 | 218 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 832 | 218 | abfd, import_name_type); | 833 | 218 | return false; | 834 | 3.20k | } | 835 | | | 836 | | /* Initialise local variables. | 837 | | | 838 | | Note these are kept in a structure rather than being | 839 | | declared as statics since bfd frowns on global variables. | 840 | | | 841 | | We are going to construct the contents of the BFD in memory, | 842 | | so allocate all the space that we will need right now. */ | 843 | 2.98k | vars.bim | 844 | 2.98k | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 845 | 2.98k | if (vars.bim == NULL) | 846 | 0 | return false; | 847 | | | 848 | 2.98k | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 849 | 2.98k | vars.bim->buffer = ptr; | 850 | 2.98k | vars.bim->size = ILF_DATA_SIZE; | 851 | 2.98k | if (ptr == NULL) | 852 | 0 | goto error_return; | 853 | | | 854 | | /* Initialise the pointers to regions of the memory and the | 855 | | other contents of the pe_ILF_vars structure as well. */ | 856 | 2.98k | vars.sym_cache = (coff_symbol_type *) ptr; | 857 | 2.98k | vars.sym_ptr = (coff_symbol_type *) ptr; | 858 | 2.98k | vars.sym_index = 0; | 859 | 2.98k | ptr += SIZEOF_ILF_SYMS; | 860 | | | 861 | 2.98k | vars.sym_table = (unsigned int *) ptr; | 862 | 2.98k | vars.table_ptr = (unsigned int *) ptr; | 863 | 2.98k | ptr += SIZEOF_ILF_SYM_TABLE; | 864 | | | 865 | 2.98k | vars.native_syms = (combined_entry_type *) ptr; | 866 | 2.98k | vars.native_ptr = (combined_entry_type *) ptr; | 867 | 2.98k | ptr += SIZEOF_ILF_NATIVE_SYMS; | 868 | | | 869 | 2.98k | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 870 | 2.98k | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 871 | 2.98k | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 872 | | | 873 | 2.98k | vars.esym_table = (SYMENT *) ptr; | 874 | 2.98k | vars.esym_ptr = (SYMENT *) ptr; | 875 | 2.98k | ptr += SIZEOF_ILF_EXT_SYMS; | 876 | | | 877 | 2.98k | vars.reltab = (arelent *) ptr; | 878 | 2.98k | vars.relcount = 0; | 879 | 2.98k | ptr += SIZEOF_ILF_RELOCS; | 880 | | | 881 | 2.98k | vars.int_reltab = (struct internal_reloc *) ptr; | 882 | 2.98k | ptr += SIZEOF_ILF_INT_RELOCS; | 883 | | | 884 | 2.98k | vars.string_table = (char *) ptr; | 885 | 2.98k | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 886 | 2.98k | ptr += SIZEOF_ILF_STRINGS; | 887 | 2.98k | vars.end_string_ptr = (char *) ptr; | 888 | | | 889 | | /* The remaining space in bim->buffer is used | 890 | | by the pe_ILF_make_a_section() function. */ | 891 | | | 892 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 893 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 894 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 895 | | alignment. */ | 896 | 2.98k | #if GCC_VERSION >= 3000 | 897 | 2.98k | alignment = __alignof__ (struct coff_section_tdata); | 898 | | #else | 899 | | alignment = 8; | 900 | | #endif | 901 | 2.98k | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 902 | | | 903 | 2.98k | vars.data = ptr; | 904 | 2.98k | vars.abfd = abfd; | 905 | 2.98k | vars.sec_index = 0; | 906 | 2.98k | vars.magic = magic; | 907 | | | 908 | | /* Create the initial .idata$<n> sections: | 909 | | [.idata$2: Import Directory Table -- not needed] | 910 | | .idata$4: Import Lookup Table | 911 | | .idata$5: Import Address Table | 912 | | | 913 | | Note we do not create a .idata$3 section as this is | 914 | | created for us by the linker script. */ | 915 | 2.98k | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 916 | 2.98k | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 917 | 2.98k | if (id4 == NULL || id5 == NULL) | 918 | 0 | goto error_return; | 919 | | | 920 | | /* Fill in the contents of these sections. */ | 921 | 2.98k | if (import_name_type == IMPORT_ORDINAL) | 922 | 1.05k | { | 923 | 1.05k | if (ordinal == 0) | 924 | | /* See PR 20907 for a reproducer. */ | 925 | 117 | goto error_return; | 926 | | | 927 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 928 | | ((unsigned int *) id4->contents)[0] = ordinal; | 929 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 930 | | ((unsigned int *) id5->contents)[0] = ordinal; | 931 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 932 | | #else | 933 | 937 | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 934 | 937 | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 935 | 937 | #endif | 936 | 937 | } | 937 | 1.93k | else | 938 | 1.93k | { | 939 | 1.93k | char * symbol; | 940 | 1.93k | unsigned int len; | 941 | | | 942 | | /* Create .idata$6 - the Hint Name Table. */ | 943 | 1.93k | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 944 | 1.93k | if (id6 == NULL) | 945 | 0 | goto error_return; | 946 | | | 947 | | /* If necessary, trim the import symbol name. */ | 948 | 1.93k | symbol = symbol_name; | 949 | | | 950 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 951 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 952 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 953 | | of these is used for a symbol. We strip this leading char for | 954 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 955 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 956 | | | 957 | 1.93k | if (import_name_type != IMPORT_NAME) | 958 | 871 | { | 959 | 871 | char c = symbol[0]; | 960 | | | 961 | | /* Check that we don't remove for targets with empty | 962 | | USER_LABEL_PREFIX the leading underscore. */ | 963 | 871 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 964 | 871 | || c == '@' || c == '?') | 965 | 12 | symbol++; | 966 | 871 | } | 967 | | | 968 | 1.93k | len = strlen (symbol); | 969 | 1.93k | if (import_name_type == IMPORT_NAME_UNDECORATE) | 970 | 605 | { | 971 | | /* Truncate at the first '@'. */ | 972 | 605 | char *at = strchr (symbol, '@'); | 973 | | | 974 | 605 | if (at != NULL) | 975 | 240 | len = at - symbol; | 976 | 605 | } | 977 | | | 978 | 1.93k | id6->contents[0] = ordinal & 0xff; | 979 | 1.93k | id6->contents[1] = ordinal >> 8; | 980 | | | 981 | 1.93k | memcpy ((char *) id6->contents + 2, symbol, len); | 982 | 1.93k | id6->contents[len + 2] = '\0'; | 983 | 1.93k | } | 984 | | | 985 | 2.86k | if (import_name_type != IMPORT_ORDINAL) | 986 | 1.93k | { | 987 | 1.93k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 988 | 1.93k | pe_ILF_save_relocs (&vars, id4); | 989 | | | 990 | 1.93k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 991 | 1.93k | pe_ILF_save_relocs (&vars, id5); | 992 | 1.93k | } | 993 | | | 994 | | /* Create an import symbol. */ | 995 | 2.86k | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 996 | 2.86k | imp_sym = vars.sym_ptr_ptr - 1; | 997 | 2.86k | imp_index = vars.sym_index - 1; | 998 | | | 999 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1000 | 2.86k | switch (import_type) | 1001 | 2.86k | { | 1002 | 0 | int i; | 1003 | | | 1004 | 2.00k | case IMPORT_CODE: | 1005 | | /* CODE functions are special, in that they get a trampoline that | 1006 | | jumps to the main import symbol. Create a .text section to hold it. | 1007 | | First we need to look up its contents in the jump table. */ | 1008 | 4.00k | for (i = NUM_ENTRIES (jtab); i--;) | 1009 | 4.00k | { | 1010 | 4.00k | if (jtab[i].size == 0) | 1011 | 2.00k | continue; | 1012 | 2.00k | if (jtab[i].magic == magic) | 1013 | 2.00k | break; | 1014 | 2.00k | } | 1015 | | /* If we did not find a matching entry something is wrong. */ | 1016 | 2.00k | if (i < 0) | 1017 | 0 | abort (); | 1018 | | | 1019 | | /* Create the .text section. */ | 1020 | 2.00k | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1021 | 2.00k | if (text == NULL) | 1022 | 0 | goto error_return; | 1023 | | | 1024 | | /* Copy in the jump code. */ | 1025 | 2.00k | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1026 | | | 1027 | | /* Create a reloc for the data in the text section. */ | 1028 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1029 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1030 | | { | 1031 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1032 | | (struct bfd_symbol **) imp_sym, | 1033 | | imp_index); | 1034 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1035 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1036 | | (struct bfd_symbol **) imp_sym, | 1037 | | imp_index); | 1038 | | } | 1039 | | else | 1040 | | #endif | 1041 | | #ifdef AMD64MAGIC | 1042 | | if (magic == AMD64MAGIC) | 1043 | | { | 1044 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1045 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1046 | | imp_index); | 1047 | | } | 1048 | | else | 1049 | | #endif | 1050 | 2.00k | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1051 | 2.00k | BFD_RELOC_32, (asymbol **) imp_sym, | 1052 | 2.00k | imp_index); | 1053 | | | 1054 | 2.00k | pe_ILF_save_relocs (& vars, text); | 1055 | 2.00k | break; | 1056 | | | 1057 | 866 | case IMPORT_DATA: | 1058 | 866 | break; | 1059 | | | 1060 | 0 | default: | 1061 | | /* XXX code not yet written. */ | 1062 | 0 | abort (); | 1063 | 2.86k | } | 1064 | | | 1065 | | /* Now create a symbol describing the imported value. */ | 1066 | 2.86k | switch (import_type) | 1067 | 2.86k | { | 1068 | 2.00k | case IMPORT_CODE: | 1069 | 2.00k | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1070 | 2.00k | BSF_NOT_AT_END | BSF_FUNCTION); | 1071 | | | 1072 | 2.00k | break; | 1073 | | | 1074 | 866 | case IMPORT_DATA: | 1075 | | /* Nothing to do here. */ | 1076 | 866 | break; | 1077 | | | 1078 | 0 | default: | 1079 | | /* XXX code not yet written. */ | 1080 | 0 | abort (); | 1081 | 2.86k | } | 1082 | | | 1083 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1084 | 2.86k | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1085 | 2.86k | if (ptr) | 1086 | 12 | * ptr = 0; | 1087 | 2.86k | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1088 | 2.86k | if (ptr) | 1089 | 12 | * ptr = '.'; | 1090 | | | 1091 | | /* Initialise the bfd. */ | 1092 | 2.86k | memset (& internal_f, 0, sizeof (internal_f)); | 1093 | | | 1094 | 2.86k | internal_f.f_magic = magic; | 1095 | 2.86k | internal_f.f_symptr = 0; | 1096 | 2.86k | internal_f.f_nsyms = 0; | 1097 | 2.86k | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1098 | | | 1099 | 2.86k | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1100 | 2.86k | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1101 | 0 | goto error_return; | 1102 | | | 1103 | 2.86k | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1104 | 0 | goto error_return; | 1105 | | | 1106 | 2.86k | obj_pe (abfd) = true; | 1107 | | #ifdef THUMBPEMAGIC | 1108 | | if (vars.magic == THUMBPEMAGIC) | 1109 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1110 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1111 | | #endif | 1112 | | | 1113 | | /* Switch from file contents to memory contents. */ | 1114 | 2.86k | bfd_cache_close (abfd); | 1115 | | | 1116 | 2.86k | abfd->iostream = (void *) vars.bim; | 1117 | 2.86k | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1118 | 2.86k | abfd->iovec = &_bfd_memory_iovec; | 1119 | 2.86k | abfd->where = 0; | 1120 | 2.86k | abfd->origin = 0; | 1121 | 2.86k | abfd->size = 0; | 1122 | 2.86k | obj_sym_filepos (abfd) = 0; | 1123 | | | 1124 | | /* Point the bfd at the symbol table. */ | 1125 | 2.86k | obj_symbols (abfd) = vars.sym_cache; | 1126 | 2.86k | abfd->symcount = vars.sym_index; | 1127 | | | 1128 | 2.86k | obj_raw_syments (abfd) = vars.native_syms; | 1129 | 2.86k | obj_raw_syment_count (abfd) = vars.sym_index; | 1130 | | | 1131 | 2.86k | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1132 | 2.86k | obj_coff_keep_syms (abfd) = true; | 1133 | | | 1134 | 2.86k | obj_convert (abfd) = vars.sym_table; | 1135 | 2.86k | obj_conv_table_size (abfd) = vars.sym_index; | 1136 | | | 1137 | 2.86k | obj_coff_strings (abfd) = vars.string_table; | 1138 | 2.86k | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1139 | 2.86k | obj_coff_keep_strings (abfd) = true; | 1140 | | | 1141 | 2.86k | return true; | 1142 | | | 1143 | 117 | error_return: | 1144 | 117 | free (vars.bim->buffer); | 1145 | 117 | free (vars.bim); | 1146 | 117 | return false; | 1147 | 2.86k | } |
|
1148 | | |
1149 | | /* Cleanup function, returned from check_format hook. */ |
1150 | | |
1151 | | static void |
1152 | | pe_ILF_cleanup (bfd *abfd) |
1153 | 136 | { |
1154 | 136 | coff_object_cleanup (abfd); |
1155 | | |
1156 | 136 | struct bfd_in_memory *bim = abfd->iostream; |
1157 | 136 | free (bim->buffer); |
1158 | 136 | free (bim); |
1159 | 136 | abfd->iostream = NULL; |
1160 | 136 | } 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 | 1153 | 68 | { | 1154 | 68 | coff_object_cleanup (abfd); | 1155 | | | 1156 | 68 | struct bfd_in_memory *bim = abfd->iostream; | 1157 | 68 | free (bim->buffer); | 1158 | 68 | free (bim); | 1159 | 68 | abfd->iostream = NULL; | 1160 | 68 | } |
Line | Count | Source | 1153 | 68 | { | 1154 | 68 | coff_object_cleanup (abfd); | 1155 | | | 1156 | 68 | struct bfd_in_memory *bim = abfd->iostream; | 1157 | 68 | free (bim->buffer); | 1158 | 68 | free (bim); | 1159 | 68 | abfd->iostream = NULL; | 1160 | 68 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_cleanup Unexecuted instantiation: pei-sh.c:pe_ILF_cleanup |
1161 | | |
1162 | | /* We have detected an Import Library Format archive element. |
1163 | | Decode the element and return the appropriate target. */ |
1164 | | |
1165 | | static bfd_cleanup |
1166 | | pe_ILF_object_p (bfd * abfd) |
1167 | 222k | { |
1168 | 222k | bfd_byte buffer[14]; |
1169 | 222k | bfd_byte * ptr; |
1170 | 222k | char * symbol_name; |
1171 | 222k | char * source_dll; |
1172 | 222k | unsigned int machine; |
1173 | 222k | bfd_size_type size; |
1174 | 222k | unsigned int ordinal; |
1175 | 222k | unsigned int types; |
1176 | 222k | unsigned int magic; |
1177 | | |
1178 | | /* Upon entry the first six bytes of the ILF header have |
1179 | | already been read. Now read the rest of the header. */ |
1180 | 222k | if (bfd_read (buffer, 14, abfd) != 14) |
1181 | 1.98k | return NULL; |
1182 | | |
1183 | 220k | ptr = buffer; |
1184 | | |
1185 | 220k | machine = H_GET_16 (abfd, ptr); |
1186 | 220k | ptr += 2; |
1187 | | |
1188 | | /* Check that the machine type is recognised. */ |
1189 | 220k | magic = 0; |
1190 | | |
1191 | 220k | switch (machine) |
1192 | 220k | { |
1193 | 2.73k | case IMAGE_FILE_MACHINE_UNKNOWN: |
1194 | 2.78k | case IMAGE_FILE_MACHINE_ALPHA: |
1195 | 2.80k | case IMAGE_FILE_MACHINE_ALPHA64: |
1196 | 2.90k | case IMAGE_FILE_MACHINE_IA64: |
1197 | 2.90k | break; |
1198 | | |
1199 | 24.3k | case IMAGE_FILE_MACHINE_I386: |
1200 | | #ifdef I386MAGIC |
1201 | 4.06k | magic = I386MAGIC; |
1202 | | #endif |
1203 | 24.3k | break; |
1204 | | |
1205 | 48.1k | case IMAGE_FILE_MACHINE_AMD64: |
1206 | | #ifdef AMD64MAGIC |
1207 | 6.50k | magic = AMD64MAGIC; |
1208 | | #endif |
1209 | 48.1k | break; |
1210 | | |
1211 | 48 | case IMAGE_FILE_MACHINE_R3000: |
1212 | 87 | case IMAGE_FILE_MACHINE_R4000: |
1213 | 143 | case IMAGE_FILE_MACHINE_R10000: |
1214 | | |
1215 | 176 | case IMAGE_FILE_MACHINE_MIPS16: |
1216 | 187 | case IMAGE_FILE_MACHINE_MIPSFPU: |
1217 | 203 | case IMAGE_FILE_MACHINE_MIPSFPU16: |
1218 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
1219 | | magic = MIPS_ARCH_MAGIC_WINCE; |
1220 | | #endif |
1221 | 203 | break; |
1222 | | |
1223 | 8.78k | case IMAGE_FILE_MACHINE_SH3: |
1224 | 31.9k | case IMAGE_FILE_MACHINE_SH4: |
1225 | | #ifdef SH_ARCH_MAGIC_WINCE |
1226 | 4.67k | magic = SH_ARCH_MAGIC_WINCE; |
1227 | | #endif |
1228 | 31.9k | break; |
1229 | | |
1230 | 30.2k | case IMAGE_FILE_MACHINE_ARM: |
1231 | | #ifdef ARMPEMAGIC |
1232 | 8.82k | magic = ARMPEMAGIC; |
1233 | | #endif |
1234 | 30.2k | break; |
1235 | | |
1236 | 15.1k | case IMAGE_FILE_MACHINE_ARM64: |
1237 | | #ifdef AARCH64MAGIC |
1238 | 3.84k | magic = AARCH64MAGIC; |
1239 | | #endif |
1240 | 15.1k | break; |
1241 | | |
1242 | 36.0k | case IMAGE_FILE_MACHINE_LOONGARCH64: |
1243 | | #ifdef LOONGARCH64MAGIC |
1244 | 4.51k | magic = LOONGARCH64MAGIC; |
1245 | | #endif |
1246 | 36.0k | break; |
1247 | | |
1248 | 7.86k | case IMAGE_FILE_MACHINE_THUMB: |
1249 | | #ifdef THUMBPEMAGIC |
1250 | | { |
1251 | | extern const bfd_target TARGET_LITTLE_SYM; |
1252 | | |
1253 | 2.37k | if (abfd->xvec == & TARGET_LITTLE_SYM) |
1254 | 2.36k | magic = THUMBPEMAGIC; |
1255 | | } |
1256 | | #endif |
1257 | 7.86k | break; |
1258 | | |
1259 | 0 | case IMAGE_FILE_MACHINE_POWERPC: |
1260 | | /* We no longer support PowerPC. */ |
1261 | 24.1k | default: |
1262 | 24.1k | _bfd_error_handler |
1263 | | /* xgettext:c-format */ |
1264 | 24.1k | (_("%pB: unrecognised machine type (0x%x)" |
1265 | 24.1k | " in Import Library Format archive"), |
1266 | 24.1k | abfd, machine); |
1267 | 24.1k | bfd_set_error (bfd_error_malformed_archive); |
1268 | | |
1269 | 24.1k | return NULL; |
1270 | 0 | break; |
1271 | 220k | } |
1272 | | |
1273 | 196k | if (magic == 0) |
1274 | 161k | { |
1275 | 161k | _bfd_error_handler |
1276 | | /* xgettext:c-format */ |
1277 | 161k | (_("%pB: recognised but unhandled machine type (0x%x)" |
1278 | 161k | " in Import Library Format archive"), |
1279 | 161k | abfd, machine); |
1280 | 161k | bfd_set_error (bfd_error_wrong_format); |
1281 | | |
1282 | 161k | return NULL; |
1283 | 161k | } |
1284 | | |
1285 | | /* We do not bother to check the date. |
1286 | | date = H_GET_32 (abfd, ptr); */ |
1287 | 34.8k | ptr += 4; |
1288 | | |
1289 | 34.8k | size = H_GET_32 (abfd, ptr); |
1290 | 34.8k | ptr += 4; |
1291 | | |
1292 | 34.8k | if (size == 0) |
1293 | 1.72k | { |
1294 | 1.72k | _bfd_error_handler |
1295 | 1.72k | (_("%pB: size field is zero in Import Library Format header"), abfd); |
1296 | 1.72k | bfd_set_error (bfd_error_malformed_archive); |
1297 | | |
1298 | 1.72k | return NULL; |
1299 | 1.72k | } |
1300 | | |
1301 | 33.0k | ordinal = H_GET_16 (abfd, ptr); |
1302 | 33.0k | ptr += 2; |
1303 | | |
1304 | 33.0k | types = H_GET_16 (abfd, ptr); |
1305 | | /* ptr += 2; */ |
1306 | | |
1307 | | /* Now read in the two strings that follow. */ |
1308 | 33.0k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); |
1309 | 33.0k | if (ptr == NULL) |
1310 | 8.59k | return NULL; |
1311 | | |
1312 | 24.4k | symbol_name = (char *) ptr; |
1313 | | /* See PR 20905 for an example of where the strnlen is necessary. */ |
1314 | 24.4k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; |
1315 | | |
1316 | | /* Verify that the strings are null terminated. */ |
1317 | 24.4k | if (ptr[size - 1] != 0 |
1318 | 24.4k | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) |
1319 | 2.65k | { |
1320 | 2.65k | _bfd_error_handler |
1321 | 2.65k | (_("%pB: string not null terminated in ILF object file"), abfd); |
1322 | 2.65k | bfd_set_error (bfd_error_malformed_archive); |
1323 | 2.65k | bfd_release (abfd, ptr); |
1324 | 2.65k | return NULL; |
1325 | 2.65k | } |
1326 | | |
1327 | | /* Now construct the bfd. */ |
1328 | 21.8k | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, |
1329 | 21.8k | source_dll, ordinal, types)) |
1330 | 6.06k | { |
1331 | 6.06k | bfd_release (abfd, ptr); |
1332 | 6.06k | return NULL; |
1333 | 6.06k | } |
1334 | | |
1335 | 15.7k | return pe_ILF_cleanup; |
1336 | 21.8k | } pei-i386.c:pe_ILF_object_p Line | Count | Source | 1167 | 28.9k | { | 1168 | 28.9k | bfd_byte buffer[14]; | 1169 | 28.9k | bfd_byte * ptr; | 1170 | 28.9k | char * symbol_name; | 1171 | 28.9k | char * source_dll; | 1172 | 28.9k | unsigned int machine; | 1173 | 28.9k | bfd_size_type size; | 1174 | 28.9k | unsigned int ordinal; | 1175 | 28.9k | unsigned int types; | 1176 | 28.9k | unsigned int magic; | 1177 | | | 1178 | | /* Upon entry the first six bytes of the ILF header have | 1179 | | already been read. Now read the rest of the header. */ | 1180 | 28.9k | if (bfd_read (buffer, 14, abfd) != 14) | 1181 | 249 | return NULL; | 1182 | | | 1183 | 28.7k | ptr = buffer; | 1184 | | | 1185 | 28.7k | machine = H_GET_16 (abfd, ptr); | 1186 | 28.7k | ptr += 2; | 1187 | | | 1188 | | /* Check that the machine type is recognised. */ | 1189 | 28.7k | magic = 0; | 1190 | | | 1191 | 28.7k | switch (machine) | 1192 | 28.7k | { | 1193 | 340 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1194 | 347 | case IMAGE_FILE_MACHINE_ALPHA: | 1195 | 350 | case IMAGE_FILE_MACHINE_ALPHA64: | 1196 | 364 | case IMAGE_FILE_MACHINE_IA64: | 1197 | 364 | break; | 1198 | | | 1199 | 4.06k | case IMAGE_FILE_MACHINE_I386: | 1200 | 4.06k | #ifdef I386MAGIC | 1201 | 4.06k | magic = I386MAGIC; | 1202 | 4.06k | #endif | 1203 | 4.06k | break; | 1204 | | | 1205 | 6.49k | case IMAGE_FILE_MACHINE_AMD64: | 1206 | | #ifdef AMD64MAGIC | 1207 | | magic = AMD64MAGIC; | 1208 | | #endif | 1209 | 6.49k | break; | 1210 | | | 1211 | 7 | case IMAGE_FILE_MACHINE_R3000: | 1212 | 12 | case IMAGE_FILE_MACHINE_R4000: | 1213 | 20 | case IMAGE_FILE_MACHINE_R10000: | 1214 | | | 1215 | 23 | case IMAGE_FILE_MACHINE_MIPS16: | 1216 | 24 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1217 | 26 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1218 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1219 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1220 | | #endif | 1221 | 26 | break; | 1222 | | | 1223 | 1.40k | case IMAGE_FILE_MACHINE_SH3: | 1224 | 4.69k | case IMAGE_FILE_MACHINE_SH4: | 1225 | | #ifdef SH_ARCH_MAGIC_WINCE | 1226 | | magic = SH_ARCH_MAGIC_WINCE; | 1227 | | #endif | 1228 | 4.69k | break; | 1229 | | | 1230 | 3.16k | case IMAGE_FILE_MACHINE_ARM: | 1231 | | #ifdef ARMPEMAGIC | 1232 | | magic = ARMPEMAGIC; | 1233 | | #endif | 1234 | 3.16k | break; | 1235 | | | 1236 | 1.62k | case IMAGE_FILE_MACHINE_ARM64: | 1237 | | #ifdef AARCH64MAGIC | 1238 | | magic = AARCH64MAGIC; | 1239 | | #endif | 1240 | 1.62k | break; | 1241 | | | 1242 | 4.50k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1243 | | #ifdef LOONGARCH64MAGIC | 1244 | | magic = LOONGARCH64MAGIC; | 1245 | | #endif | 1246 | 4.50k | break; | 1247 | | | 1248 | 781 | case IMAGE_FILE_MACHINE_THUMB: | 1249 | | #ifdef THUMBPEMAGIC | 1250 | | { | 1251 | | extern const bfd_target TARGET_LITTLE_SYM; | 1252 | | | 1253 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1254 | | magic = THUMBPEMAGIC; | 1255 | | } | 1256 | | #endif | 1257 | 781 | break; | 1258 | | | 1259 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1260 | | /* We no longer support PowerPC. */ | 1261 | 3.01k | default: | 1262 | 3.01k | _bfd_error_handler | 1263 | | /* xgettext:c-format */ | 1264 | 3.01k | (_("%pB: unrecognised machine type (0x%x)" | 1265 | 3.01k | " in Import Library Format archive"), | 1266 | 3.01k | abfd, machine); | 1267 | 3.01k | bfd_set_error (bfd_error_malformed_archive); | 1268 | | | 1269 | 3.01k | return NULL; | 1270 | 0 | break; | 1271 | 28.7k | } | 1272 | | | 1273 | 25.7k | if (magic == 0) | 1274 | 21.6k | { | 1275 | 21.6k | _bfd_error_handler | 1276 | | /* xgettext:c-format */ | 1277 | 21.6k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1278 | 21.6k | " in Import Library Format archive"), | 1279 | 21.6k | abfd, machine); | 1280 | 21.6k | bfd_set_error (bfd_error_wrong_format); | 1281 | | | 1282 | 21.6k | return NULL; | 1283 | 21.6k | } | 1284 | | | 1285 | | /* We do not bother to check the date. | 1286 | | date = H_GET_32 (abfd, ptr); */ | 1287 | 4.06k | ptr += 4; | 1288 | | | 1289 | 4.06k | size = H_GET_32 (abfd, ptr); | 1290 | 4.06k | ptr += 4; | 1291 | | | 1292 | 4.06k | if (size == 0) | 1293 | 320 | { | 1294 | 320 | _bfd_error_handler | 1295 | 320 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1296 | 320 | bfd_set_error (bfd_error_malformed_archive); | 1297 | | | 1298 | 320 | return NULL; | 1299 | 320 | } | 1300 | | | 1301 | 3.74k | ordinal = H_GET_16 (abfd, ptr); | 1302 | 3.74k | ptr += 2; | 1303 | | | 1304 | 3.74k | types = H_GET_16 (abfd, ptr); | 1305 | | /* ptr += 2; */ | 1306 | | | 1307 | | /* Now read in the two strings that follow. */ | 1308 | 3.74k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1309 | 3.74k | if (ptr == NULL) | 1310 | 776 | return NULL; | 1311 | | | 1312 | 2.97k | symbol_name = (char *) ptr; | 1313 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1314 | 2.97k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1315 | | | 1316 | | /* Verify that the strings are null terminated. */ | 1317 | 2.97k | if (ptr[size - 1] != 0 | 1318 | 2.97k | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1319 | 334 | { | 1320 | 334 | _bfd_error_handler | 1321 | 334 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1322 | 334 | bfd_set_error (bfd_error_malformed_archive); | 1323 | 334 | bfd_release (abfd, ptr); | 1324 | 334 | return NULL; | 1325 | 334 | } | 1326 | | | 1327 | | /* Now construct the bfd. */ | 1328 | 2.63k | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1329 | 2.63k | source_dll, ordinal, types)) | 1330 | 567 | { | 1331 | 567 | bfd_release (abfd, ptr); | 1332 | 567 | return NULL; | 1333 | 567 | } | 1334 | | | 1335 | 2.07k | return pe_ILF_cleanup; | 1336 | 2.63k | } |
pei-x86_64.c:pe_ILF_object_p Line | Count | Source | 1167 | 24.2k | { | 1168 | 24.2k | bfd_byte buffer[14]; | 1169 | 24.2k | bfd_byte * ptr; | 1170 | 24.2k | char * symbol_name; | 1171 | 24.2k | char * source_dll; | 1172 | 24.2k | unsigned int machine; | 1173 | 24.2k | bfd_size_type size; | 1174 | 24.2k | unsigned int ordinal; | 1175 | 24.2k | unsigned int types; | 1176 | 24.2k | unsigned int magic; | 1177 | | | 1178 | | /* Upon entry the first six bytes of the ILF header have | 1179 | | already been read. Now read the rest of the header. */ | 1180 | 24.2k | if (bfd_read (buffer, 14, abfd) != 14) | 1181 | 249 | return NULL; | 1182 | | | 1183 | 23.9k | ptr = buffer; | 1184 | | | 1185 | 23.9k | machine = H_GET_16 (abfd, ptr); | 1186 | 23.9k | ptr += 2; | 1187 | | | 1188 | | /* Check that the machine type is recognised. */ | 1189 | 23.9k | magic = 0; | 1190 | | | 1191 | 23.9k | switch (machine) | 1192 | 23.9k | { | 1193 | 340 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1194 | 347 | case IMAGE_FILE_MACHINE_ALPHA: | 1195 | 350 | case IMAGE_FILE_MACHINE_ALPHA64: | 1196 | 364 | case IMAGE_FILE_MACHINE_IA64: | 1197 | 364 | break; | 1198 | | | 1199 | 2.05k | case IMAGE_FILE_MACHINE_I386: | 1200 | | #ifdef I386MAGIC | 1201 | | magic = I386MAGIC; | 1202 | | #endif | 1203 | 2.05k | break; | 1204 | | | 1205 | 6.50k | case IMAGE_FILE_MACHINE_AMD64: | 1206 | 6.50k | #ifdef AMD64MAGIC | 1207 | 6.50k | magic = AMD64MAGIC; | 1208 | 6.50k | #endif | 1209 | 6.50k | break; | 1210 | | | 1211 | 7 | case IMAGE_FILE_MACHINE_R3000: | 1212 | 12 | case IMAGE_FILE_MACHINE_R4000: | 1213 | 20 | case IMAGE_FILE_MACHINE_R10000: | 1214 | | | 1215 | 23 | case IMAGE_FILE_MACHINE_MIPS16: | 1216 | 24 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1217 | 26 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1218 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1219 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1220 | | #endif | 1221 | 26 | break; | 1222 | | | 1223 | 217 | case IMAGE_FILE_MACHINE_SH3: | 1224 | 1.92k | case IMAGE_FILE_MACHINE_SH4: | 1225 | | #ifdef SH_ARCH_MAGIC_WINCE | 1226 | | magic = SH_ARCH_MAGIC_WINCE; | 1227 | | #endif | 1228 | 1.92k | break; | 1229 | | | 1230 | 3.16k | case IMAGE_FILE_MACHINE_ARM: | 1231 | | #ifdef ARMPEMAGIC | 1232 | | magic = ARMPEMAGIC; | 1233 | | #endif | 1234 | 3.16k | break; | 1235 | | | 1236 | 1.62k | case IMAGE_FILE_MACHINE_ARM64: | 1237 | | #ifdef AARCH64MAGIC | 1238 | | magic = AARCH64MAGIC; | 1239 | | #endif | 1240 | 1.62k | break; | 1241 | | | 1242 | 4.50k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1243 | | #ifdef LOONGARCH64MAGIC | 1244 | | magic = LOONGARCH64MAGIC; | 1245 | | #endif | 1246 | 4.50k | break; | 1247 | | | 1248 | 781 | case IMAGE_FILE_MACHINE_THUMB: | 1249 | | #ifdef THUMBPEMAGIC | 1250 | | { | 1251 | | extern const bfd_target TARGET_LITTLE_SYM; | 1252 | | | 1253 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1254 | | magic = THUMBPEMAGIC; | 1255 | | } | 1256 | | #endif | 1257 | 781 | break; | 1258 | | | 1259 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1260 | | /* We no longer support PowerPC. */ | 1261 | 3.01k | default: | 1262 | 3.01k | _bfd_error_handler | 1263 | | /* xgettext:c-format */ | 1264 | 3.01k | (_("%pB: unrecognised machine type (0x%x)" | 1265 | 3.01k | " in Import Library Format archive"), | 1266 | 3.01k | abfd, machine); | 1267 | 3.01k | bfd_set_error (bfd_error_malformed_archive); | 1268 | | | 1269 | 3.01k | return NULL; | 1270 | 0 | break; | 1271 | 23.9k | } | 1272 | | | 1273 | 20.9k | if (magic == 0) | 1274 | 14.4k | { | 1275 | 14.4k | _bfd_error_handler | 1276 | | /* xgettext:c-format */ | 1277 | 14.4k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1278 | 14.4k | " in Import Library Format archive"), | 1279 | 14.4k | abfd, machine); | 1280 | 14.4k | bfd_set_error (bfd_error_wrong_format); | 1281 | | | 1282 | 14.4k | return NULL; | 1283 | 14.4k | } | 1284 | | | 1285 | | /* We do not bother to check the date. | 1286 | | date = H_GET_32 (abfd, ptr); */ | 1287 | 6.50k | ptr += 4; | 1288 | | | 1289 | 6.50k | size = H_GET_32 (abfd, ptr); | 1290 | 6.50k | ptr += 4; | 1291 | | | 1292 | 6.50k | if (size == 0) | 1293 | 321 | { | 1294 | 321 | _bfd_error_handler | 1295 | 321 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1296 | 321 | bfd_set_error (bfd_error_malformed_archive); | 1297 | | | 1298 | 321 | return NULL; | 1299 | 321 | } | 1300 | | | 1301 | 6.18k | ordinal = H_GET_16 (abfd, ptr); | 1302 | 6.18k | ptr += 2; | 1303 | | | 1304 | 6.18k | types = H_GET_16 (abfd, ptr); | 1305 | | /* ptr += 2; */ | 1306 | | | 1307 | | /* Now read in the two strings that follow. */ | 1308 | 6.18k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1309 | 6.18k | if (ptr == NULL) | 1310 | 880 | return NULL; | 1311 | | | 1312 | 5.30k | symbol_name = (char *) ptr; | 1313 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1314 | 5.30k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1315 | | | 1316 | | /* Verify that the strings are null terminated. */ | 1317 | 5.30k | if (ptr[size - 1] != 0 | 1318 | 5.30k | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1319 | 531 | { | 1320 | 531 | _bfd_error_handler | 1321 | 531 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1322 | 531 | bfd_set_error (bfd_error_malformed_archive); | 1323 | 531 | bfd_release (abfd, ptr); | 1324 | 531 | return NULL; | 1325 | 531 | } | 1326 | | | 1327 | | /* Now construct the bfd. */ | 1328 | 4.77k | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1329 | 4.77k | source_dll, ordinal, types)) | 1330 | 961 | { | 1331 | 961 | bfd_release (abfd, ptr); | 1332 | 961 | return NULL; | 1333 | 961 | } | 1334 | | | 1335 | 3.81k | return pe_ILF_cleanup; | 1336 | 4.77k | } |
pei-aarch64.c:pe_ILF_object_p Line | Count | Source | 1167 | 34.4k | { | 1168 | 34.4k | bfd_byte buffer[14]; | 1169 | 34.4k | bfd_byte * ptr; | 1170 | 34.4k | char * symbol_name; | 1171 | 34.4k | char * source_dll; | 1172 | 34.4k | unsigned int machine; | 1173 | 34.4k | bfd_size_type size; | 1174 | 34.4k | unsigned int ordinal; | 1175 | 34.4k | unsigned int types; | 1176 | 34.4k | unsigned int magic; | 1177 | | | 1178 | | /* Upon entry the first six bytes of the ILF header have | 1179 | | already been read. Now read the rest of the header. */ | 1180 | 34.4k | if (bfd_read (buffer, 14, abfd) != 14) | 1181 | 249 | return NULL; | 1182 | | | 1183 | 34.1k | ptr = buffer; | 1184 | | | 1185 | 34.1k | machine = H_GET_16 (abfd, ptr); | 1186 | 34.1k | ptr += 2; | 1187 | | | 1188 | | /* Check that the machine type is recognised. */ | 1189 | 34.1k | magic = 0; | 1190 | | | 1191 | 34.1k | switch (machine) | 1192 | 34.1k | { | 1193 | 340 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1194 | 347 | case IMAGE_FILE_MACHINE_ALPHA: | 1195 | 350 | case IMAGE_FILE_MACHINE_ALPHA64: | 1196 | 364 | case IMAGE_FILE_MACHINE_IA64: | 1197 | 364 | break; | 1198 | | | 1199 | 4.06k | case IMAGE_FILE_MACHINE_I386: | 1200 | | #ifdef I386MAGIC | 1201 | | magic = I386MAGIC; | 1202 | | #endif | 1203 | 4.06k | break; | 1204 | | | 1205 | 6.49k | case IMAGE_FILE_MACHINE_AMD64: | 1206 | | #ifdef AMD64MAGIC | 1207 | | magic = AMD64MAGIC; | 1208 | | #endif | 1209 | 6.49k | break; | 1210 | | | 1211 | 7 | case IMAGE_FILE_MACHINE_R3000: | 1212 | 12 | case IMAGE_FILE_MACHINE_R4000: | 1213 | 20 | case IMAGE_FILE_MACHINE_R10000: | 1214 | | | 1215 | 23 | case IMAGE_FILE_MACHINE_MIPS16: | 1216 | 24 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1217 | 26 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1218 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1219 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1220 | | #endif | 1221 | 26 | break; | 1222 | | | 1223 | 1.40k | case IMAGE_FILE_MACHINE_SH3: | 1224 | 4.69k | case IMAGE_FILE_MACHINE_SH4: | 1225 | | #ifdef SH_ARCH_MAGIC_WINCE | 1226 | | magic = SH_ARCH_MAGIC_WINCE; | 1227 | | #endif | 1228 | 4.69k | break; | 1229 | | | 1230 | 5.54k | case IMAGE_FILE_MACHINE_ARM: | 1231 | | #ifdef ARMPEMAGIC | 1232 | | magic = ARMPEMAGIC; | 1233 | | #endif | 1234 | 5.54k | break; | 1235 | | | 1236 | 3.84k | case IMAGE_FILE_MACHINE_ARM64: | 1237 | 3.84k | #ifdef AARCH64MAGIC | 1238 | 3.84k | magic = AARCH64MAGIC; | 1239 | 3.84k | #endif | 1240 | 3.84k | break; | 1241 | | | 1242 | 4.50k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1243 | | #ifdef LOONGARCH64MAGIC | 1244 | | magic = LOONGARCH64MAGIC; | 1245 | | #endif | 1246 | 4.50k | break; | 1247 | | | 1248 | 1.62k | case IMAGE_FILE_MACHINE_THUMB: | 1249 | | #ifdef THUMBPEMAGIC | 1250 | | { | 1251 | | extern const bfd_target TARGET_LITTLE_SYM; | 1252 | | | 1253 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1254 | | magic = THUMBPEMAGIC; | 1255 | | } | 1256 | | #endif | 1257 | 1.62k | break; | 1258 | | | 1259 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1260 | | /* We no longer support PowerPC. */ | 1261 | 3.01k | default: | 1262 | 3.01k | _bfd_error_handler | 1263 | | /* xgettext:c-format */ | 1264 | 3.01k | (_("%pB: unrecognised machine type (0x%x)" | 1265 | 3.01k | " in Import Library Format archive"), | 1266 | 3.01k | abfd, machine); | 1267 | 3.01k | bfd_set_error (bfd_error_malformed_archive); | 1268 | | | 1269 | 3.01k | return NULL; | 1270 | 0 | break; | 1271 | 34.1k | } | 1272 | | | 1273 | 31.1k | if (magic == 0) | 1274 | 27.3k | { | 1275 | 27.3k | _bfd_error_handler | 1276 | | /* xgettext:c-format */ | 1277 | 27.3k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1278 | 27.3k | " in Import Library Format archive"), | 1279 | 27.3k | abfd, machine); | 1280 | 27.3k | bfd_set_error (bfd_error_wrong_format); | 1281 | | | 1282 | 27.3k | return NULL; | 1283 | 27.3k | } | 1284 | | | 1285 | | /* We do not bother to check the date. | 1286 | | date = H_GET_32 (abfd, ptr); */ | 1287 | 3.84k | ptr += 4; | 1288 | | | 1289 | 3.84k | size = H_GET_32 (abfd, ptr); | 1290 | 3.84k | ptr += 4; | 1291 | | | 1292 | 3.84k | if (size == 0) | 1293 | 118 | { | 1294 | 118 | _bfd_error_handler | 1295 | 118 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1296 | 118 | bfd_set_error (bfd_error_malformed_archive); | 1297 | | | 1298 | 118 | return NULL; | 1299 | 118 | } | 1300 | | | 1301 | 3.72k | ordinal = H_GET_16 (abfd, ptr); | 1302 | 3.72k | ptr += 2; | 1303 | | | 1304 | 3.72k | types = H_GET_16 (abfd, ptr); | 1305 | | /* ptr += 2; */ | 1306 | | | 1307 | | /* Now read in the two strings that follow. */ | 1308 | 3.72k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1309 | 3.72k | if (ptr == NULL) | 1310 | 764 | return NULL; | 1311 | | | 1312 | 2.96k | symbol_name = (char *) ptr; | 1313 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1314 | 2.96k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1315 | | | 1316 | | /* Verify that the strings are null terminated. */ | 1317 | 2.96k | if (ptr[size - 1] != 0 | 1318 | 2.96k | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1319 | 333 | { | 1320 | 333 | _bfd_error_handler | 1321 | 333 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1322 | 333 | bfd_set_error (bfd_error_malformed_archive); | 1323 | 333 | bfd_release (abfd, ptr); | 1324 | 333 | return NULL; | 1325 | 333 | } | 1326 | | | 1327 | | /* Now construct the bfd. */ | 1328 | 2.62k | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1329 | 2.62k | source_dll, ordinal, types)) | 1330 | 354 | { | 1331 | 354 | bfd_release (abfd, ptr); | 1332 | 354 | return NULL; | 1333 | 354 | } | 1334 | | | 1335 | 2.27k | return pe_ILF_cleanup; | 1336 | 2.62k | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_object_p pei-loongarch64.c:pe_ILF_object_p Line | Count | Source | 1167 | 20.4k | { | 1168 | 20.4k | bfd_byte buffer[14]; | 1169 | 20.4k | bfd_byte * ptr; | 1170 | 20.4k | char * symbol_name; | 1171 | 20.4k | char * source_dll; | 1172 | 20.4k | unsigned int machine; | 1173 | 20.4k | bfd_size_type size; | 1174 | 20.4k | unsigned int ordinal; | 1175 | 20.4k | unsigned int types; | 1176 | 20.4k | unsigned int magic; | 1177 | | | 1178 | | /* Upon entry the first six bytes of the ILF header have | 1179 | | already been read. Now read the rest of the header. */ | 1180 | 20.4k | if (bfd_read (buffer, 14, abfd) != 14) | 1181 | 249 | return NULL; | 1182 | | | 1183 | 20.2k | ptr = buffer; | 1184 | | | 1185 | 20.2k | machine = H_GET_16 (abfd, ptr); | 1186 | 20.2k | ptr += 2; | 1187 | | | 1188 | | /* Check that the machine type is recognised. */ | 1189 | 20.2k | magic = 0; | 1190 | | | 1191 | 20.2k | switch (machine) | 1192 | 20.2k | { | 1193 | 340 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1194 | 347 | case IMAGE_FILE_MACHINE_ALPHA: | 1195 | 350 | case IMAGE_FILE_MACHINE_ALPHA64: | 1196 | 364 | case IMAGE_FILE_MACHINE_IA64: | 1197 | 364 | break; | 1198 | | | 1199 | 2.05k | case IMAGE_FILE_MACHINE_I386: | 1200 | | #ifdef I386MAGIC | 1201 | | magic = I386MAGIC; | 1202 | | #endif | 1203 | 2.05k | break; | 1204 | | | 1205 | 2.75k | case IMAGE_FILE_MACHINE_AMD64: | 1206 | | #ifdef AMD64MAGIC | 1207 | | magic = AMD64MAGIC; | 1208 | | #endif | 1209 | 2.75k | break; | 1210 | | | 1211 | 7 | case IMAGE_FILE_MACHINE_R3000: | 1212 | 12 | case IMAGE_FILE_MACHINE_R4000: | 1213 | 20 | case IMAGE_FILE_MACHINE_R10000: | 1214 | | | 1215 | 23 | case IMAGE_FILE_MACHINE_MIPS16: | 1216 | 24 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1217 | 26 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1218 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1219 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1220 | | #endif | 1221 | 26 | break; | 1222 | | | 1223 | 217 | case IMAGE_FILE_MACHINE_SH3: | 1224 | 1.92k | case IMAGE_FILE_MACHINE_SH4: | 1225 | | #ifdef SH_ARCH_MAGIC_WINCE | 1226 | | magic = SH_ARCH_MAGIC_WINCE; | 1227 | | #endif | 1228 | 1.92k | break; | 1229 | | | 1230 | 3.16k | case IMAGE_FILE_MACHINE_ARM: | 1231 | | #ifdef ARMPEMAGIC | 1232 | | magic = ARMPEMAGIC; | 1233 | | #endif | 1234 | 3.16k | break; | 1235 | | | 1236 | 1.62k | case IMAGE_FILE_MACHINE_ARM64: | 1237 | | #ifdef AARCH64MAGIC | 1238 | | magic = AARCH64MAGIC; | 1239 | | #endif | 1240 | 1.62k | break; | 1241 | | | 1242 | 4.51k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1243 | 4.51k | #ifdef LOONGARCH64MAGIC | 1244 | 4.51k | magic = LOONGARCH64MAGIC; | 1245 | 4.51k | #endif | 1246 | 4.51k | break; | 1247 | | | 1248 | 781 | case IMAGE_FILE_MACHINE_THUMB: | 1249 | | #ifdef THUMBPEMAGIC | 1250 | | { | 1251 | | extern const bfd_target TARGET_LITTLE_SYM; | 1252 | | | 1253 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1254 | | magic = THUMBPEMAGIC; | 1255 | | } | 1256 | | #endif | 1257 | 781 | break; | 1258 | | | 1259 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1260 | | /* We no longer support PowerPC. */ | 1261 | 3.01k | default: | 1262 | 3.01k | _bfd_error_handler | 1263 | | /* xgettext:c-format */ | 1264 | 3.01k | (_("%pB: unrecognised machine type (0x%x)" | 1265 | 3.01k | " in Import Library Format archive"), | 1266 | 3.01k | abfd, machine); | 1267 | 3.01k | bfd_set_error (bfd_error_malformed_archive); | 1268 | | | 1269 | 3.01k | return NULL; | 1270 | 0 | break; | 1271 | 20.2k | } | 1272 | | | 1273 | 17.1k | if (magic == 0) | 1274 | 12.6k | { | 1275 | 12.6k | _bfd_error_handler | 1276 | | /* xgettext:c-format */ | 1277 | 12.6k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1278 | 12.6k | " in Import Library Format archive"), | 1279 | 12.6k | abfd, machine); | 1280 | 12.6k | bfd_set_error (bfd_error_wrong_format); | 1281 | | | 1282 | 12.6k | return NULL; | 1283 | 12.6k | } | 1284 | | | 1285 | | /* We do not bother to check the date. | 1286 | | date = H_GET_32 (abfd, ptr); */ | 1287 | 4.51k | ptr += 4; | 1288 | | | 1289 | 4.51k | size = H_GET_32 (abfd, ptr); | 1290 | 4.51k | ptr += 4; | 1291 | | | 1292 | 4.51k | if (size == 0) | 1293 | 315 | { | 1294 | 315 | _bfd_error_handler | 1295 | 315 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1296 | 315 | bfd_set_error (bfd_error_malformed_archive); | 1297 | | | 1298 | 315 | return NULL; | 1299 | 315 | } | 1300 | | | 1301 | 4.19k | ordinal = H_GET_16 (abfd, ptr); | 1302 | 4.19k | ptr += 2; | 1303 | | | 1304 | 4.19k | types = H_GET_16 (abfd, ptr); | 1305 | | /* ptr += 2; */ | 1306 | | | 1307 | | /* Now read in the two strings that follow. */ | 1308 | 4.19k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1309 | 4.19k | if (ptr == NULL) | 1310 | 1.47k | return NULL; | 1311 | | | 1312 | 2.72k | symbol_name = (char *) ptr; | 1313 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1314 | 2.72k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1315 | | | 1316 | | /* Verify that the strings are null terminated. */ | 1317 | 2.72k | if (ptr[size - 1] != 0 | 1318 | 2.72k | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1319 | 430 | { | 1320 | 430 | _bfd_error_handler | 1321 | 430 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1322 | 430 | bfd_set_error (bfd_error_malformed_archive); | 1323 | 430 | bfd_release (abfd, ptr); | 1324 | 430 | return NULL; | 1325 | 430 | } | 1326 | | | 1327 | | /* Now construct the bfd. */ | 1328 | 2.29k | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1329 | 2.29k | source_dll, ordinal, types)) | 1330 | 965 | { | 1331 | 965 | bfd_release (abfd, ptr); | 1332 | 965 | return NULL; | 1333 | 965 | } | 1334 | | | 1335 | 1.33k | return pe_ILF_cleanup; | 1336 | 2.29k | } |
pei-arm-wince.c:pe_ILF_object_p Line | Count | Source | 1167 | 28.9k | { | 1168 | 28.9k | bfd_byte buffer[14]; | 1169 | 28.9k | bfd_byte * ptr; | 1170 | 28.9k | char * symbol_name; | 1171 | 28.9k | char * source_dll; | 1172 | 28.9k | unsigned int machine; | 1173 | 28.9k | bfd_size_type size; | 1174 | 28.9k | unsigned int ordinal; | 1175 | 28.9k | unsigned int types; | 1176 | 28.9k | unsigned int magic; | 1177 | | | 1178 | | /* Upon entry the first six bytes of the ILF header have | 1179 | | already been read. Now read the rest of the header. */ | 1180 | 28.9k | if (bfd_read (buffer, 14, abfd) != 14) | 1181 | 249 | return NULL; | 1182 | | | 1183 | 28.6k | ptr = buffer; | 1184 | | | 1185 | 28.6k | machine = H_GET_16 (abfd, ptr); | 1186 | 28.6k | ptr += 2; | 1187 | | | 1188 | | /* Check that the machine type is recognised. */ | 1189 | 28.6k | magic = 0; | 1190 | | | 1191 | 28.6k | switch (machine) | 1192 | 28.6k | { | 1193 | 345 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1194 | 350 | case IMAGE_FILE_MACHINE_ALPHA: | 1195 | 352 | case IMAGE_FILE_MACHINE_ALPHA64: | 1196 | 364 | case IMAGE_FILE_MACHINE_IA64: | 1197 | 364 | break; | 1198 | | | 1199 | 4.04k | case IMAGE_FILE_MACHINE_I386: | 1200 | | #ifdef I386MAGIC | 1201 | | magic = I386MAGIC; | 1202 | | #endif | 1203 | 4.04k | break; | 1204 | | | 1205 | 6.47k | case IMAGE_FILE_MACHINE_AMD64: | 1206 | | #ifdef AMD64MAGIC | 1207 | | magic = AMD64MAGIC; | 1208 | | #endif | 1209 | 6.47k | break; | 1210 | | | 1211 | 5 | case IMAGE_FILE_MACHINE_R3000: | 1212 | 10 | case IMAGE_FILE_MACHINE_R4000: | 1213 | 16 | case IMAGE_FILE_MACHINE_R10000: | 1214 | | | 1215 | 22 | case IMAGE_FILE_MACHINE_MIPS16: | 1216 | 24 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1217 | 26 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1218 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1219 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1220 | | #endif | 1221 | 26 | break; | 1222 | | | 1223 | 1.38k | case IMAGE_FILE_MACHINE_SH3: | 1224 | 4.66k | case IMAGE_FILE_MACHINE_SH4: | 1225 | | #ifdef SH_ARCH_MAGIC_WINCE | 1226 | | magic = SH_ARCH_MAGIC_WINCE; | 1227 | | #endif | 1228 | 4.66k | break; | 1229 | | | 1230 | 3.21k | case IMAGE_FILE_MACHINE_ARM: | 1231 | 3.21k | #ifdef ARMPEMAGIC | 1232 | 3.21k | magic = ARMPEMAGIC; | 1233 | 3.21k | #endif | 1234 | 3.21k | break; | 1235 | | | 1236 | 1.60k | case IMAGE_FILE_MACHINE_ARM64: | 1237 | | #ifdef AARCH64MAGIC | 1238 | | magic = AARCH64MAGIC; | 1239 | | #endif | 1240 | 1.60k | break; | 1241 | | | 1242 | 4.49k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1243 | | #ifdef LOONGARCH64MAGIC | 1244 | | magic = LOONGARCH64MAGIC; | 1245 | | #endif | 1246 | 4.49k | break; | 1247 | | | 1248 | 764 | case IMAGE_FILE_MACHINE_THUMB: | 1249 | 764 | #ifdef THUMBPEMAGIC | 1250 | 764 | { | 1251 | 764 | extern const bfd_target TARGET_LITTLE_SYM; | 1252 | | | 1253 | 764 | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1254 | 759 | magic = THUMBPEMAGIC; | 1255 | 764 | } | 1256 | 764 | #endif | 1257 | 764 | break; | 1258 | | | 1259 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1260 | | /* We no longer support PowerPC. */ | 1261 | 3.03k | default: | 1262 | 3.03k | _bfd_error_handler | 1263 | | /* xgettext:c-format */ | 1264 | 3.03k | (_("%pB: unrecognised machine type (0x%x)" | 1265 | 3.03k | " in Import Library Format archive"), | 1266 | 3.03k | abfd, machine); | 1267 | 3.03k | bfd_set_error (bfd_error_malformed_archive); | 1268 | | | 1269 | 3.03k | return NULL; | 1270 | 0 | break; | 1271 | 28.6k | } | 1272 | | | 1273 | 25.6k | if (magic == 0) | 1274 | 21.6k | { | 1275 | 21.6k | _bfd_error_handler | 1276 | | /* xgettext:c-format */ | 1277 | 21.6k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1278 | 21.6k | " in Import Library Format archive"), | 1279 | 21.6k | abfd, machine); | 1280 | 21.6k | bfd_set_error (bfd_error_wrong_format); | 1281 | | | 1282 | 21.6k | return NULL; | 1283 | 21.6k | } | 1284 | | | 1285 | | /* We do not bother to check the date. | 1286 | | date = H_GET_32 (abfd, ptr); */ | 1287 | 3.97k | ptr += 4; | 1288 | | | 1289 | 3.97k | size = H_GET_32 (abfd, ptr); | 1290 | 3.97k | ptr += 4; | 1291 | | | 1292 | 3.97k | if (size == 0) | 1293 | 217 | { | 1294 | 217 | _bfd_error_handler | 1295 | 217 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1296 | 217 | bfd_set_error (bfd_error_malformed_archive); | 1297 | | | 1298 | 217 | return NULL; | 1299 | 217 | } | 1300 | | | 1301 | 3.75k | ordinal = H_GET_16 (abfd, ptr); | 1302 | 3.75k | ptr += 2; | 1303 | | | 1304 | 3.75k | types = H_GET_16 (abfd, ptr); | 1305 | | /* ptr += 2; */ | 1306 | | | 1307 | | /* Now read in the two strings that follow. */ | 1308 | 3.75k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1309 | 3.75k | if (ptr == NULL) | 1310 | 2.05k | return NULL; | 1311 | | | 1312 | 1.69k | symbol_name = (char *) ptr; | 1313 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1314 | 1.69k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1315 | | | 1316 | | /* Verify that the strings are null terminated. */ | 1317 | 1.69k | if (ptr[size - 1] != 0 | 1318 | 1.69k | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1319 | 342 | { | 1320 | 342 | _bfd_error_handler | 1321 | 342 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1322 | 342 | bfd_set_error (bfd_error_malformed_archive); | 1323 | 342 | bfd_release (abfd, ptr); | 1324 | 342 | return NULL; | 1325 | 342 | } | 1326 | | | 1327 | | /* Now construct the bfd. */ | 1328 | 1.35k | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1329 | 1.35k | source_dll, ordinal, types)) | 1330 | 1.27k | { | 1331 | 1.27k | bfd_release (abfd, ptr); | 1332 | 1.27k | return NULL; | 1333 | 1.27k | } | 1334 | | | 1335 | 80 | return pe_ILF_cleanup; | 1336 | 1.35k | } |
pei-arm.c:pe_ILF_object_p Line | Count | Source | 1167 | 32.1k | { | 1168 | 32.1k | bfd_byte buffer[14]; | 1169 | 32.1k | bfd_byte * ptr; | 1170 | 32.1k | char * symbol_name; | 1171 | 32.1k | char * source_dll; | 1172 | 32.1k | unsigned int machine; | 1173 | 32.1k | bfd_size_type size; | 1174 | 32.1k | unsigned int ordinal; | 1175 | 32.1k | unsigned int types; | 1176 | 32.1k | unsigned int magic; | 1177 | | | 1178 | | /* Upon entry the first six bytes of the ILF header have | 1179 | | already been read. Now read the rest of the header. */ | 1180 | 32.1k | if (bfd_read (buffer, 14, abfd) != 14) | 1181 | 249 | return NULL; | 1182 | | | 1183 | 31.9k | ptr = buffer; | 1184 | | | 1185 | 31.9k | machine = H_GET_16 (abfd, ptr); | 1186 | 31.9k | ptr += 2; | 1187 | | | 1188 | | /* Check that the machine type is recognised. */ | 1189 | 31.9k | magic = 0; | 1190 | | | 1191 | 31.9k | switch (machine) | 1192 | 31.9k | { | 1193 | 345 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1194 | 350 | case IMAGE_FILE_MACHINE_ALPHA: | 1195 | 352 | case IMAGE_FILE_MACHINE_ALPHA64: | 1196 | 364 | case IMAGE_FILE_MACHINE_IA64: | 1197 | 364 | break; | 1198 | | | 1199 | 4.04k | case IMAGE_FILE_MACHINE_I386: | 1200 | | #ifdef I386MAGIC | 1201 | | magic = I386MAGIC; | 1202 | | #endif | 1203 | 4.04k | break; | 1204 | | | 1205 | 6.47k | case IMAGE_FILE_MACHINE_AMD64: | 1206 | | #ifdef AMD64MAGIC | 1207 | | magic = AMD64MAGIC; | 1208 | | #endif | 1209 | 6.47k | break; | 1210 | | | 1211 | 5 | case IMAGE_FILE_MACHINE_R3000: | 1212 | 10 | case IMAGE_FILE_MACHINE_R4000: | 1213 | 16 | case IMAGE_FILE_MACHINE_R10000: | 1214 | | | 1215 | 22 | case IMAGE_FILE_MACHINE_MIPS16: | 1216 | 24 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1217 | 26 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1218 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1219 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1220 | | #endif | 1221 | 26 | break; | 1222 | | | 1223 | 1.38k | case IMAGE_FILE_MACHINE_SH3: | 1224 | 4.66k | case IMAGE_FILE_MACHINE_SH4: | 1225 | | #ifdef SH_ARCH_MAGIC_WINCE | 1226 | | magic = SH_ARCH_MAGIC_WINCE; | 1227 | | #endif | 1228 | 4.66k | break; | 1229 | | | 1230 | 5.61k | case IMAGE_FILE_MACHINE_ARM: | 1231 | 5.61k | #ifdef ARMPEMAGIC | 1232 | 5.61k | magic = ARMPEMAGIC; | 1233 | 5.61k | #endif | 1234 | 5.61k | break; | 1235 | | | 1236 | 1.60k | case IMAGE_FILE_MACHINE_ARM64: | 1237 | | #ifdef AARCH64MAGIC | 1238 | | magic = AARCH64MAGIC; | 1239 | | #endif | 1240 | 1.60k | break; | 1241 | | | 1242 | 4.49k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1243 | | #ifdef LOONGARCH64MAGIC | 1244 | | magic = LOONGARCH64MAGIC; | 1245 | | #endif | 1246 | 4.49k | break; | 1247 | | | 1248 | 1.61k | case IMAGE_FILE_MACHINE_THUMB: | 1249 | 1.61k | #ifdef THUMBPEMAGIC | 1250 | 1.61k | { | 1251 | 1.61k | extern const bfd_target TARGET_LITTLE_SYM; | 1252 | | | 1253 | 1.61k | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1254 | 1.60k | magic = THUMBPEMAGIC; | 1255 | 1.61k | } | 1256 | 1.61k | #endif | 1257 | 1.61k | break; | 1258 | | | 1259 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1260 | | /* We no longer support PowerPC. */ | 1261 | 3.03k | default: | 1262 | 3.03k | _bfd_error_handler | 1263 | | /* xgettext:c-format */ | 1264 | 3.03k | (_("%pB: unrecognised machine type (0x%x)" | 1265 | 3.03k | " in Import Library Format archive"), | 1266 | 3.03k | abfd, machine); | 1267 | 3.03k | bfd_set_error (bfd_error_malformed_archive); | 1268 | | | 1269 | 3.03k | return NULL; | 1270 | 0 | break; | 1271 | 31.9k | } | 1272 | | | 1273 | 28.9k | if (magic == 0) | 1274 | 21.6k | { | 1275 | 21.6k | _bfd_error_handler | 1276 | | /* xgettext:c-format */ | 1277 | 21.6k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1278 | 21.6k | " in Import Library Format archive"), | 1279 | 21.6k | abfd, machine); | 1280 | 21.6k | bfd_set_error (bfd_error_wrong_format); | 1281 | | | 1282 | 21.6k | return NULL; | 1283 | 21.6k | } | 1284 | | | 1285 | | /* We do not bother to check the date. | 1286 | | date = H_GET_32 (abfd, ptr); */ | 1287 | 7.21k | ptr += 4; | 1288 | | | 1289 | 7.21k | size = H_GET_32 (abfd, ptr); | 1290 | 7.21k | ptr += 4; | 1291 | | | 1292 | 7.21k | if (size == 0) | 1293 | 217 | { | 1294 | 217 | _bfd_error_handler | 1295 | 217 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1296 | 217 | bfd_set_error (bfd_error_malformed_archive); | 1297 | | | 1298 | 217 | return NULL; | 1299 | 217 | } | 1300 | | | 1301 | 7.00k | ordinal = H_GET_16 (abfd, ptr); | 1302 | 7.00k | ptr += 2; | 1303 | | | 1304 | 7.00k | types = H_GET_16 (abfd, ptr); | 1305 | | /* ptr += 2; */ | 1306 | | | 1307 | | /* Now read in the two strings that follow. */ | 1308 | 7.00k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1309 | 7.00k | if (ptr == NULL) | 1310 | 2.05k | return NULL; | 1311 | | | 1312 | 4.94k | symbol_name = (char *) ptr; | 1313 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1314 | 4.94k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1315 | | | 1316 | | /* Verify that the strings are null terminated. */ | 1317 | 4.94k | if (ptr[size - 1] != 0 | 1318 | 4.94k | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1319 | 342 | { | 1320 | 342 | _bfd_error_handler | 1321 | 342 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1322 | 342 | bfd_set_error (bfd_error_malformed_archive); | 1323 | 342 | bfd_release (abfd, ptr); | 1324 | 342 | return NULL; | 1325 | 342 | } | 1326 | | | 1327 | | /* Now construct the bfd. */ | 1328 | 4.60k | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1329 | 4.60k | source_dll, ordinal, types)) | 1330 | 1.27k | { | 1331 | 1.27k | bfd_release (abfd, ptr); | 1332 | 1.27k | return NULL; | 1333 | 1.27k | } | 1334 | | | 1335 | 3.32k | return pe_ILF_cleanup; | 1336 | 4.60k | } |
pei-mcore.c:pe_ILF_object_p Line | Count | Source | 1167 | 26.9k | { | 1168 | 26.9k | bfd_byte buffer[14]; | 1169 | 26.9k | bfd_byte * ptr; | 1170 | 26.9k | char * symbol_name; | 1171 | 26.9k | char * source_dll; | 1172 | 26.9k | unsigned int machine; | 1173 | 26.9k | bfd_size_type size; | 1174 | 26.9k | unsigned int ordinal; | 1175 | 26.9k | unsigned int types; | 1176 | 26.9k | unsigned int magic; | 1177 | | | 1178 | | /* Upon entry the first six bytes of the ILF header have | 1179 | | already been read. Now read the rest of the header. */ | 1180 | 26.9k | if (bfd_read (buffer, 14, abfd) != 14) | 1181 | 249 | return NULL; | 1182 | | | 1183 | 26.6k | ptr = buffer; | 1184 | | | 1185 | 26.6k | machine = H_GET_16 (abfd, ptr); | 1186 | 26.6k | ptr += 2; | 1187 | | | 1188 | | /* Check that the machine type is recognised. */ | 1189 | 26.6k | magic = 0; | 1190 | | | 1191 | 26.6k | switch (machine) | 1192 | 26.6k | { | 1193 | 345 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1194 | 350 | case IMAGE_FILE_MACHINE_ALPHA: | 1195 | 352 | case IMAGE_FILE_MACHINE_ALPHA64: | 1196 | 364 | case IMAGE_FILE_MACHINE_IA64: | 1197 | 364 | break; | 1198 | | | 1199 | 2.02k | case IMAGE_FILE_MACHINE_I386: | 1200 | | #ifdef I386MAGIC | 1201 | | magic = I386MAGIC; | 1202 | | #endif | 1203 | 2.02k | break; | 1204 | | | 1205 | 6.47k | case IMAGE_FILE_MACHINE_AMD64: | 1206 | | #ifdef AMD64MAGIC | 1207 | | magic = AMD64MAGIC; | 1208 | | #endif | 1209 | 6.47k | break; | 1210 | | | 1211 | 5 | case IMAGE_FILE_MACHINE_R3000: | 1212 | 10 | case IMAGE_FILE_MACHINE_R4000: | 1213 | 16 | case IMAGE_FILE_MACHINE_R10000: | 1214 | | | 1215 | 22 | case IMAGE_FILE_MACHINE_MIPS16: | 1216 | 24 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1217 | 26 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1218 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1219 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1220 | | #endif | 1221 | 26 | break; | 1222 | | | 1223 | 1.38k | case IMAGE_FILE_MACHINE_SH3: | 1224 | 4.66k | case IMAGE_FILE_MACHINE_SH4: | 1225 | | #ifdef SH_ARCH_MAGIC_WINCE | 1226 | | magic = SH_ARCH_MAGIC_WINCE; | 1227 | | #endif | 1228 | 4.66k | break; | 1229 | | | 1230 | 3.21k | case IMAGE_FILE_MACHINE_ARM: | 1231 | | #ifdef ARMPEMAGIC | 1232 | | magic = ARMPEMAGIC; | 1233 | | #endif | 1234 | 3.21k | break; | 1235 | | | 1236 | 1.60k | case IMAGE_FILE_MACHINE_ARM64: | 1237 | | #ifdef AARCH64MAGIC | 1238 | | magic = AARCH64MAGIC; | 1239 | | #endif | 1240 | 1.60k | break; | 1241 | | | 1242 | 4.49k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1243 | | #ifdef LOONGARCH64MAGIC | 1244 | | magic = LOONGARCH64MAGIC; | 1245 | | #endif | 1246 | 4.49k | break; | 1247 | | | 1248 | 764 | case IMAGE_FILE_MACHINE_THUMB: | 1249 | | #ifdef THUMBPEMAGIC | 1250 | | { | 1251 | | extern const bfd_target TARGET_LITTLE_SYM; | 1252 | | | 1253 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1254 | | magic = THUMBPEMAGIC; | 1255 | | } | 1256 | | #endif | 1257 | 764 | break; | 1258 | | | 1259 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1260 | | /* We no longer support PowerPC. */ | 1261 | 3.03k | default: | 1262 | 3.03k | _bfd_error_handler | 1263 | | /* xgettext:c-format */ | 1264 | 3.03k | (_("%pB: unrecognised machine type (0x%x)" | 1265 | 3.03k | " in Import Library Format archive"), | 1266 | 3.03k | abfd, machine); | 1267 | 3.03k | bfd_set_error (bfd_error_malformed_archive); | 1268 | | | 1269 | 3.03k | return NULL; | 1270 | 0 | break; | 1271 | 26.6k | } | 1272 | | | 1273 | 23.6k | if (magic == 0) | 1274 | 23.6k | { | 1275 | 23.6k | _bfd_error_handler | 1276 | | /* xgettext:c-format */ | 1277 | 23.6k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1278 | 23.6k | " in Import Library Format archive"), | 1279 | 23.6k | abfd, machine); | 1280 | 23.6k | bfd_set_error (bfd_error_wrong_format); | 1281 | | | 1282 | 23.6k | return NULL; | 1283 | 23.6k | } | 1284 | | | 1285 | | /* We do not bother to check the date. | 1286 | | date = H_GET_32 (abfd, ptr); */ | 1287 | 0 | ptr += 4; | 1288 | |
| 1289 | 0 | size = H_GET_32 (abfd, ptr); | 1290 | 0 | ptr += 4; | 1291 | |
| 1292 | 0 | if (size == 0) | 1293 | 0 | { | 1294 | 0 | _bfd_error_handler | 1295 | 0 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1296 | 0 | bfd_set_error (bfd_error_malformed_archive); | 1297 | |
| 1298 | 0 | return NULL; | 1299 | 0 | } | 1300 | | | 1301 | 0 | ordinal = H_GET_16 (abfd, ptr); | 1302 | 0 | ptr += 2; | 1303 | |
| 1304 | 0 | types = H_GET_16 (abfd, ptr); | 1305 | | /* ptr += 2; */ | 1306 | | | 1307 | | /* Now read in the two strings that follow. */ | 1308 | 0 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1309 | 0 | if (ptr == NULL) | 1310 | 0 | return NULL; | 1311 | | | 1312 | 0 | symbol_name = (char *) ptr; | 1313 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1314 | 0 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1315 | | | 1316 | | /* Verify that the strings are null terminated. */ | 1317 | 0 | if (ptr[size - 1] != 0 | 1318 | 0 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1319 | 0 | { | 1320 | 0 | _bfd_error_handler | 1321 | 0 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1322 | 0 | bfd_set_error (bfd_error_malformed_archive); | 1323 | 0 | bfd_release (abfd, ptr); | 1324 | 0 | return NULL; | 1325 | 0 | } | 1326 | | | 1327 | | /* Now construct the bfd. */ | 1328 | 0 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1329 | 0 | source_dll, ordinal, types)) | 1330 | 0 | { | 1331 | 0 | bfd_release (abfd, ptr); | 1332 | 0 | return NULL; | 1333 | 0 | } | 1334 | | | 1335 | 0 | return pe_ILF_cleanup; | 1336 | 0 | } |
Line | Count | Source | 1167 | 26.7k | { | 1168 | 26.7k | bfd_byte buffer[14]; | 1169 | 26.7k | bfd_byte * ptr; | 1170 | 26.7k | char * symbol_name; | 1171 | 26.7k | char * source_dll; | 1172 | 26.7k | unsigned int machine; | 1173 | 26.7k | bfd_size_type size; | 1174 | 26.7k | unsigned int ordinal; | 1175 | 26.7k | unsigned int types; | 1176 | 26.7k | unsigned int magic; | 1177 | | | 1178 | | /* Upon entry the first six bytes of the ILF header have | 1179 | | already been read. Now read the rest of the header. */ | 1180 | 26.7k | if (bfd_read (buffer, 14, abfd) != 14) | 1181 | 244 | return NULL; | 1182 | | | 1183 | 26.5k | ptr = buffer; | 1184 | | | 1185 | 26.5k | machine = H_GET_16 (abfd, ptr); | 1186 | 26.5k | ptr += 2; | 1187 | | | 1188 | | /* Check that the machine type is recognised. */ | 1189 | 26.5k | magic = 0; | 1190 | | | 1191 | 26.5k | switch (machine) | 1192 | 26.5k | { | 1193 | 337 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1194 | 342 | case IMAGE_FILE_MACHINE_ALPHA: | 1195 | 344 | case IMAGE_FILE_MACHINE_ALPHA64: | 1196 | 356 | case IMAGE_FILE_MACHINE_IA64: | 1197 | 356 | break; | 1198 | | | 1199 | 2.02k | case IMAGE_FILE_MACHINE_I386: | 1200 | | #ifdef I386MAGIC | 1201 | | magic = I386MAGIC; | 1202 | | #endif | 1203 | 2.02k | break; | 1204 | | | 1205 | 6.47k | case IMAGE_FILE_MACHINE_AMD64: | 1206 | | #ifdef AMD64MAGIC | 1207 | | magic = AMD64MAGIC; | 1208 | | #endif | 1209 | 6.47k | break; | 1210 | | | 1211 | 5 | case IMAGE_FILE_MACHINE_R3000: | 1212 | 9 | case IMAGE_FILE_MACHINE_R4000: | 1213 | 15 | case IMAGE_FILE_MACHINE_R10000: | 1214 | | | 1215 | 18 | case IMAGE_FILE_MACHINE_MIPS16: | 1216 | 19 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1217 | 21 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1218 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1219 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1220 | | #endif | 1221 | 21 | break; | 1222 | | | 1223 | 1.39k | case IMAGE_FILE_MACHINE_SH3: | 1224 | 4.67k | case IMAGE_FILE_MACHINE_SH4: | 1225 | 4.67k | #ifdef SH_ARCH_MAGIC_WINCE | 1226 | 4.67k | magic = SH_ARCH_MAGIC_WINCE; | 1227 | 4.67k | #endif | 1228 | 4.67k | break; | 1229 | | | 1230 | 3.15k | case IMAGE_FILE_MACHINE_ARM: | 1231 | | #ifdef ARMPEMAGIC | 1232 | | magic = ARMPEMAGIC; | 1233 | | #endif | 1234 | 3.15k | break; | 1235 | | | 1236 | 1.60k | case IMAGE_FILE_MACHINE_ARM64: | 1237 | | #ifdef AARCH64MAGIC | 1238 | | magic = AARCH64MAGIC; | 1239 | | #endif | 1240 | 1.60k | break; | 1241 | | | 1242 | 4.49k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1243 | | #ifdef LOONGARCH64MAGIC | 1244 | | magic = LOONGARCH64MAGIC; | 1245 | | #endif | 1246 | 4.49k | break; | 1247 | | | 1248 | 759 | case IMAGE_FILE_MACHINE_THUMB: | 1249 | | #ifdef THUMBPEMAGIC | 1250 | | { | 1251 | | extern const bfd_target TARGET_LITTLE_SYM; | 1252 | | | 1253 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1254 | | magic = THUMBPEMAGIC; | 1255 | | } | 1256 | | #endif | 1257 | 759 | break; | 1258 | | | 1259 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1260 | | /* We no longer support PowerPC. */ | 1261 | 2.97k | default: | 1262 | 2.97k | _bfd_error_handler | 1263 | | /* xgettext:c-format */ | 1264 | 2.97k | (_("%pB: unrecognised machine type (0x%x)" | 1265 | 2.97k | " in Import Library Format archive"), | 1266 | 2.97k | abfd, machine); | 1267 | 2.97k | bfd_set_error (bfd_error_malformed_archive); | 1268 | | | 1269 | 2.97k | return NULL; | 1270 | 0 | break; | 1271 | 26.5k | } | 1272 | | | 1273 | 23.5k | if (magic == 0) | 1274 | 18.8k | { | 1275 | 18.8k | _bfd_error_handler | 1276 | | /* xgettext:c-format */ | 1277 | 18.8k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1278 | 18.8k | " in Import Library Format archive"), | 1279 | 18.8k | abfd, machine); | 1280 | 18.8k | bfd_set_error (bfd_error_wrong_format); | 1281 | | | 1282 | 18.8k | return NULL; | 1283 | 18.8k | } | 1284 | | | 1285 | | /* We do not bother to check the date. | 1286 | | date = H_GET_32 (abfd, ptr); */ | 1287 | 4.67k | ptr += 4; | 1288 | | | 1289 | 4.67k | size = H_GET_32 (abfd, ptr); | 1290 | 4.67k | ptr += 4; | 1291 | | | 1292 | 4.67k | if (size == 0) | 1293 | 221 | { | 1294 | 221 | _bfd_error_handler | 1295 | 221 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1296 | 221 | bfd_set_error (bfd_error_malformed_archive); | 1297 | | | 1298 | 221 | return NULL; | 1299 | 221 | } | 1300 | | | 1301 | 4.45k | ordinal = H_GET_16 (abfd, ptr); | 1302 | 4.45k | ptr += 2; | 1303 | | | 1304 | 4.45k | types = H_GET_16 (abfd, ptr); | 1305 | | /* ptr += 2; */ | 1306 | | | 1307 | | /* Now read in the two strings that follow. */ | 1308 | 4.45k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1309 | 4.45k | if (ptr == NULL) | 1310 | 582 | return NULL; | 1311 | | | 1312 | 3.87k | symbol_name = (char *) ptr; | 1313 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1314 | 3.87k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1315 | | | 1316 | | /* Verify that the strings are null terminated. */ | 1317 | 3.87k | if (ptr[size - 1] != 0 | 1318 | 3.87k | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1319 | 340 | { | 1320 | 340 | _bfd_error_handler | 1321 | 340 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1322 | 340 | bfd_set_error (bfd_error_malformed_archive); | 1323 | 340 | bfd_release (abfd, ptr); | 1324 | 340 | return NULL; | 1325 | 340 | } | 1326 | | | 1327 | | /* Now construct the bfd. */ | 1328 | 3.53k | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1329 | 3.53k | source_dll, ordinal, types)) | 1330 | 664 | { | 1331 | 664 | bfd_release (abfd, ptr); | 1332 | 664 | return NULL; | 1333 | 664 | } | 1334 | | | 1335 | 2.86k | return pe_ILF_cleanup; | 1336 | 3.53k | } |
|
1337 | | |
1338 | | static void |
1339 | | pe_bfd_read_buildid (bfd *abfd) |
1340 | 308k | { |
1341 | 308k | pe_data_type *pe = pe_data (abfd); |
1342 | 308k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; |
1343 | 308k | asection *section; |
1344 | 308k | bfd_byte *data = 0; |
1345 | 308k | bfd_size_type dataoff; |
1346 | 308k | unsigned int i; |
1347 | 308k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; |
1348 | 308k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; |
1349 | | |
1350 | 308k | if (size == 0) |
1351 | 106k | return; |
1352 | | |
1353 | 201k | addr += extra->ImageBase; |
1354 | | |
1355 | | /* Search for the section containing the DebugDirectory. */ |
1356 | 1.02M | for (section = abfd->sections; section != NULL; section = section->next) |
1357 | 916k | { |
1358 | 916k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) |
1359 | 97.5k | break; |
1360 | 916k | } |
1361 | | |
1362 | 201k | if (section == NULL) |
1363 | 103k | return; |
1364 | | |
1365 | 97.5k | if (!(section->flags & SEC_HAS_CONTENTS)) |
1366 | 10.1k | return; |
1367 | | |
1368 | 87.3k | dataoff = addr - section->vma; |
1369 | | |
1370 | | /* PR 20605 and 22373: Make sure that the data is really there. |
1371 | | Note - since we are dealing with unsigned quantities we have |
1372 | | to be careful to check for potential overflows. */ |
1373 | 87.3k | if (dataoff >= section->size |
1374 | 87.3k | || size > section->size - dataoff) |
1375 | 33.4k | { |
1376 | 33.4k | _bfd_error_handler |
1377 | 33.4k | (_("%pB: error: debug data ends beyond end of debug directory"), |
1378 | 33.4k | abfd); |
1379 | 33.4k | return; |
1380 | 33.4k | } |
1381 | | |
1382 | | /* Read the whole section. */ |
1383 | 53.8k | if (!bfd_malloc_and_get_section (abfd, section, &data)) |
1384 | 28.0k | { |
1385 | 28.0k | free (data); |
1386 | 28.0k | return; |
1387 | 28.0k | } |
1388 | | |
1389 | | /* Search for a CodeView entry in the DebugDirectory */ |
1390 | 6.55M | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) |
1391 | 6.54M | { |
1392 | 6.54M | struct external_IMAGE_DEBUG_DIRECTORY *ext |
1393 | 6.54M | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; |
1394 | 6.54M | struct internal_IMAGE_DEBUG_DIRECTORY idd; |
1395 | | |
1396 | 6.54M | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); |
1397 | | |
1398 | 6.54M | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) |
1399 | 13.5k | { |
1400 | 13.5k | char buffer[256 + 1]; |
1401 | 13.5k | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; |
1402 | | |
1403 | | /* |
1404 | | The debug entry doesn't have to have to be in a section, in which |
1405 | | case AddressOfRawData is 0, so always use PointerToRawData. |
1406 | | */ |
1407 | 13.5k | if (_bfd_XXi_slurp_codeview_record (abfd, |
1408 | 13.5k | (file_ptr) idd.PointerToRawData, |
1409 | 13.5k | idd.SizeOfData, cvinfo, NULL)) |
1410 | 57 | { |
1411 | 57 | struct bfd_build_id* build_id = bfd_alloc (abfd, |
1412 | 57 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); |
1413 | 57 | if (build_id) |
1414 | 57 | { |
1415 | 57 | build_id->size = cvinfo->SignatureLength; |
1416 | 57 | memcpy(build_id->data, cvinfo->Signature, |
1417 | 57 | cvinfo->SignatureLength); |
1418 | 57 | abfd->build_id = build_id; |
1419 | 57 | } |
1420 | 57 | } |
1421 | 13.5k | break; |
1422 | 13.5k | } |
1423 | 6.54M | } |
1424 | | |
1425 | 25.8k | free (data); |
1426 | 25.8k | } pei-i386.c:pe_bfd_read_buildid Line | Count | Source | 1340 | 38.4k | { | 1341 | 38.4k | pe_data_type *pe = pe_data (abfd); | 1342 | 38.4k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1343 | 38.4k | asection *section; | 1344 | 38.4k | bfd_byte *data = 0; | 1345 | 38.4k | bfd_size_type dataoff; | 1346 | 38.4k | unsigned int i; | 1347 | 38.4k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1348 | 38.4k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1349 | | | 1350 | 38.4k | if (size == 0) | 1351 | 17.5k | return; | 1352 | | | 1353 | 20.8k | addr += extra->ImageBase; | 1354 | | | 1355 | | /* Search for the section containing the DebugDirectory. */ | 1356 | 41.0k | for (section = abfd->sections; section != NULL; section = section->next) | 1357 | 32.6k | { | 1358 | 32.6k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1359 | 12.4k | break; | 1360 | 32.6k | } | 1361 | | | 1362 | 20.8k | if (section == NULL) | 1363 | 8.48k | return; | 1364 | | | 1365 | 12.4k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1366 | 1.25k | return; | 1367 | | | 1368 | 11.1k | dataoff = addr - section->vma; | 1369 | | | 1370 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1371 | | Note - since we are dealing with unsigned quantities we have | 1372 | | to be careful to check for potential overflows. */ | 1373 | 11.1k | if (dataoff >= section->size | 1374 | 11.1k | || size > section->size - dataoff) | 1375 | 4.87k | { | 1376 | 4.87k | _bfd_error_handler | 1377 | 4.87k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1378 | 4.87k | abfd); | 1379 | 4.87k | return; | 1380 | 4.87k | } | 1381 | | | 1382 | | /* Read the whole section. */ | 1383 | 6.27k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1384 | 4.45k | { | 1385 | 4.45k | free (data); | 1386 | 4.45k | return; | 1387 | 4.45k | } | 1388 | | | 1389 | | /* Search for a CodeView entry in the DebugDirectory */ | 1390 | 6.19k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1391 | 5.15k | { | 1392 | 5.15k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1393 | 5.15k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1394 | 5.15k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1395 | | | 1396 | 5.15k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1397 | | | 1398 | 5.15k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1399 | 776 | { | 1400 | 776 | char buffer[256 + 1]; | 1401 | 776 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1402 | | | 1403 | | /* | 1404 | | The debug entry doesn't have to have to be in a section, in which | 1405 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1406 | | */ | 1407 | 776 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1408 | 776 | (file_ptr) idd.PointerToRawData, | 1409 | 776 | idd.SizeOfData, cvinfo, NULL)) | 1410 | 16 | { | 1411 | 16 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1412 | 16 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1413 | 16 | if (build_id) | 1414 | 16 | { | 1415 | 16 | build_id->size = cvinfo->SignatureLength; | 1416 | 16 | memcpy(build_id->data, cvinfo->Signature, | 1417 | 16 | cvinfo->SignatureLength); | 1418 | 16 | abfd->build_id = build_id; | 1419 | 16 | } | 1420 | 16 | } | 1421 | 776 | break; | 1422 | 776 | } | 1423 | 5.15k | } | 1424 | | | 1425 | 1.82k | free (data); | 1426 | 1.82k | } |
pei-x86_64.c:pe_bfd_read_buildid Line | Count | Source | 1340 | 51.1k | { | 1341 | 51.1k | pe_data_type *pe = pe_data (abfd); | 1342 | 51.1k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1343 | 51.1k | asection *section; | 1344 | 51.1k | bfd_byte *data = 0; | 1345 | 51.1k | bfd_size_type dataoff; | 1346 | 51.1k | unsigned int i; | 1347 | 51.1k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1348 | 51.1k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1349 | | | 1350 | 51.1k | if (size == 0) | 1351 | 23.8k | return; | 1352 | | | 1353 | 27.3k | addr += extra->ImageBase; | 1354 | | | 1355 | | /* Search for the section containing the DebugDirectory. */ | 1356 | 68.9k | for (section = abfd->sections; section != NULL; section = section->next) | 1357 | 57.3k | { | 1358 | 57.3k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1359 | 15.7k | break; | 1360 | 57.3k | } | 1361 | | | 1362 | 27.3k | if (section == NULL) | 1363 | 11.5k | return; | 1364 | | | 1365 | 15.7k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1366 | 1.25k | return; | 1367 | | | 1368 | 14.5k | dataoff = addr - section->vma; | 1369 | | | 1370 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1371 | | Note - since we are dealing with unsigned quantities we have | 1372 | | to be careful to check for potential overflows. */ | 1373 | 14.5k | if (dataoff >= section->size | 1374 | 14.5k | || size > section->size - dataoff) | 1375 | 2.33k | { | 1376 | 2.33k | _bfd_error_handler | 1377 | 2.33k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1378 | 2.33k | abfd); | 1379 | 2.33k | return; | 1380 | 2.33k | } | 1381 | | | 1382 | | /* Read the whole section. */ | 1383 | 12.1k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1384 | 3.93k | { | 1385 | 3.93k | free (data); | 1386 | 3.93k | return; | 1387 | 3.93k | } | 1388 | | | 1389 | | /* Search for a CodeView entry in the DebugDirectory */ | 1390 | 6.03M | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1391 | 6.03M | { | 1392 | 6.03M | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1393 | 6.03M | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1394 | 6.03M | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1395 | | | 1396 | 6.03M | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1397 | | | 1398 | 6.03M | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1399 | 6.03k | { | 1400 | 6.03k | char buffer[256 + 1]; | 1401 | 6.03k | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1402 | | | 1403 | | /* | 1404 | | The debug entry doesn't have to have to be in a section, in which | 1405 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1406 | | */ | 1407 | 6.03k | if (_bfd_XXi_slurp_codeview_record (abfd, | 1408 | 6.03k | (file_ptr) idd.PointerToRawData, | 1409 | 6.03k | idd.SizeOfData, cvinfo, NULL)) | 1410 | 30 | { | 1411 | 30 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1412 | 30 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1413 | 30 | if (build_id) | 1414 | 30 | { | 1415 | 30 | build_id->size = cvinfo->SignatureLength; | 1416 | 30 | memcpy(build_id->data, cvinfo->Signature, | 1417 | 30 | cvinfo->SignatureLength); | 1418 | 30 | abfd->build_id = build_id; | 1419 | 30 | } | 1420 | 30 | } | 1421 | 6.03k | break; | 1422 | 6.03k | } | 1423 | 6.03M | } | 1424 | | | 1425 | 8.25k | free (data); | 1426 | 8.25k | } |
pei-aarch64.c:pe_bfd_read_buildid Line | Count | Source | 1340 | 33.1k | { | 1341 | 33.1k | pe_data_type *pe = pe_data (abfd); | 1342 | 33.1k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1343 | 33.1k | asection *section; | 1344 | 33.1k | bfd_byte *data = 0; | 1345 | 33.1k | bfd_size_type dataoff; | 1346 | 33.1k | unsigned int i; | 1347 | 33.1k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1348 | 33.1k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1349 | | | 1350 | 33.1k | if (size == 0) | 1351 | 8.08k | return; | 1352 | | | 1353 | 25.0k | addr += extra->ImageBase; | 1354 | | | 1355 | | /* Search for the section containing the DebugDirectory. */ | 1356 | 68.0k | for (section = abfd->sections; section != NULL; section = section->next) | 1357 | 52.0k | { | 1358 | 52.0k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1359 | 9.05k | break; | 1360 | 52.0k | } | 1361 | | | 1362 | 25.0k | if (section == NULL) | 1363 | 16.0k | return; | 1364 | | | 1365 | 9.05k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1366 | 707 | return; | 1367 | | | 1368 | 8.34k | dataoff = addr - section->vma; | 1369 | | | 1370 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1371 | | Note - since we are dealing with unsigned quantities we have | 1372 | | to be careful to check for potential overflows. */ | 1373 | 8.34k | if (dataoff >= section->size | 1374 | 8.34k | || size > section->size - dataoff) | 1375 | 3.34k | { | 1376 | 3.34k | _bfd_error_handler | 1377 | 3.34k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1378 | 3.34k | abfd); | 1379 | 3.34k | return; | 1380 | 3.34k | } | 1381 | | | 1382 | | /* Read the whole section. */ | 1383 | 5.00k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1384 | 2.64k | { | 1385 | 2.64k | free (data); | 1386 | 2.64k | return; | 1387 | 2.64k | } | 1388 | | | 1389 | | /* Search for a CodeView entry in the DebugDirectory */ | 1390 | 254k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1391 | 252k | { | 1392 | 252k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1393 | 252k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1394 | 252k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1395 | | | 1396 | 252k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1397 | | | 1398 | 252k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1399 | 579 | { | 1400 | 579 | char buffer[256 + 1]; | 1401 | 579 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1402 | | | 1403 | | /* | 1404 | | The debug entry doesn't have to have to be in a section, in which | 1405 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1406 | | */ | 1407 | 579 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1408 | 579 | (file_ptr) idd.PointerToRawData, | 1409 | 579 | idd.SizeOfData, cvinfo, NULL)) | 1410 | 1 | { | 1411 | 1 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1412 | 1 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1413 | 1 | if (build_id) | 1414 | 1 | { | 1415 | 1 | build_id->size = cvinfo->SignatureLength; | 1416 | 1 | memcpy(build_id->data, cvinfo->Signature, | 1417 | 1 | cvinfo->SignatureLength); | 1418 | 1 | abfd->build_id = build_id; | 1419 | 1 | } | 1420 | 1 | } | 1421 | 579 | break; | 1422 | 579 | } | 1423 | 252k | } | 1424 | | | 1425 | 2.35k | free (data); | 1426 | 2.35k | } |
pei-ia64.c:pe_bfd_read_buildid Line | Count | Source | 1340 | 37.1k | { | 1341 | 37.1k | pe_data_type *pe = pe_data (abfd); | 1342 | 37.1k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1343 | 37.1k | asection *section; | 1344 | 37.1k | bfd_byte *data = 0; | 1345 | 37.1k | bfd_size_type dataoff; | 1346 | 37.1k | unsigned int i; | 1347 | 37.1k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1348 | 37.1k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1349 | | | 1350 | 37.1k | if (size == 0) | 1351 | 14.2k | return; | 1352 | | | 1353 | 22.8k | addr += extra->ImageBase; | 1354 | | | 1355 | | /* Search for the section containing the DebugDirectory. */ | 1356 | 74.0k | for (section = abfd->sections; section != NULL; section = section->next) | 1357 | 58.4k | { | 1358 | 58.4k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1359 | 7.25k | break; | 1360 | 58.4k | } | 1361 | | | 1362 | 22.8k | if (section == NULL) | 1363 | 15.6k | return; | 1364 | | | 1365 | 7.25k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1366 | 926 | return; | 1367 | | | 1368 | 6.33k | dataoff = addr - section->vma; | 1369 | | | 1370 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1371 | | Note - since we are dealing with unsigned quantities we have | 1372 | | to be careful to check for potential overflows. */ | 1373 | 6.33k | if (dataoff >= section->size | 1374 | 6.33k | || size > section->size - dataoff) | 1375 | 3.64k | { | 1376 | 3.64k | _bfd_error_handler | 1377 | 3.64k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1378 | 3.64k | abfd); | 1379 | 3.64k | return; | 1380 | 3.64k | } | 1381 | | | 1382 | | /* Read the whole section. */ | 1383 | 2.69k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1384 | 1.58k | { | 1385 | 1.58k | free (data); | 1386 | 1.58k | return; | 1387 | 1.58k | } | 1388 | | | 1389 | | /* Search for a CodeView entry in the DebugDirectory */ | 1390 | 29.9k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1391 | 29.7k | { | 1392 | 29.7k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1393 | 29.7k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1394 | 29.7k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1395 | | | 1396 | 29.7k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1397 | | | 1398 | 29.7k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1399 | 815 | { | 1400 | 815 | char buffer[256 + 1]; | 1401 | 815 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1402 | | | 1403 | | /* | 1404 | | The debug entry doesn't have to have to be in a section, in which | 1405 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1406 | | */ | 1407 | 815 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1408 | 815 | (file_ptr) idd.PointerToRawData, | 1409 | 815 | idd.SizeOfData, cvinfo, NULL)) | 1410 | 0 | { | 1411 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1412 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1413 | 0 | if (build_id) | 1414 | 0 | { | 1415 | 0 | build_id->size = cvinfo->SignatureLength; | 1416 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1417 | 0 | cvinfo->SignatureLength); | 1418 | 0 | abfd->build_id = build_id; | 1419 | 0 | } | 1420 | 0 | } | 1421 | 815 | break; | 1422 | 815 | } | 1423 | 29.7k | } | 1424 | | | 1425 | 1.10k | free (data); | 1426 | 1.10k | } |
pei-loongarch64.c:pe_bfd_read_buildid Line | Count | Source | 1340 | 29.4k | { | 1341 | 29.4k | pe_data_type *pe = pe_data (abfd); | 1342 | 29.4k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1343 | 29.4k | asection *section; | 1344 | 29.4k | bfd_byte *data = 0; | 1345 | 29.4k | bfd_size_type dataoff; | 1346 | 29.4k | unsigned int i; | 1347 | 29.4k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1348 | 29.4k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1349 | | | 1350 | 29.4k | if (size == 0) | 1351 | 11.6k | return; | 1352 | | | 1353 | 17.8k | addr += extra->ImageBase; | 1354 | | | 1355 | | /* Search for the section containing the DebugDirectory. */ | 1356 | 71.7k | for (section = abfd->sections; section != NULL; section = section->next) | 1357 | 60.5k | { | 1358 | 60.5k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1359 | 6.62k | break; | 1360 | 60.5k | } | 1361 | | | 1362 | 17.8k | if (section == NULL) | 1363 | 11.2k | return; | 1364 | | | 1365 | 6.62k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1366 | 494 | return; | 1367 | | | 1368 | 6.13k | dataoff = addr - section->vma; | 1369 | | | 1370 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1371 | | Note - since we are dealing with unsigned quantities we have | 1372 | | to be careful to check for potential overflows. */ | 1373 | 6.13k | if (dataoff >= section->size | 1374 | 6.13k | || size > section->size - dataoff) | 1375 | 2.12k | { | 1376 | 2.12k | _bfd_error_handler | 1377 | 2.12k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1378 | 2.12k | abfd); | 1379 | 2.12k | return; | 1380 | 2.12k | } | 1381 | | | 1382 | | /* Read the whole section. */ | 1383 | 4.00k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1384 | 1.73k | { | 1385 | 1.73k | free (data); | 1386 | 1.73k | return; | 1387 | 1.73k | } | 1388 | | | 1389 | | /* Search for a CodeView entry in the DebugDirectory */ | 1390 | 25.5k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1391 | 24.2k | { | 1392 | 24.2k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1393 | 24.2k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1394 | 24.2k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1395 | | | 1396 | 24.2k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1397 | | | 1398 | 24.2k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1399 | 897 | { | 1400 | 897 | char buffer[256 + 1]; | 1401 | 897 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1402 | | | 1403 | | /* | 1404 | | The debug entry doesn't have to have to be in a section, in which | 1405 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1406 | | */ | 1407 | 897 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1408 | 897 | (file_ptr) idd.PointerToRawData, | 1409 | 897 | idd.SizeOfData, cvinfo, NULL)) | 1410 | 1 | { | 1411 | 1 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1412 | 1 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1413 | 1 | if (build_id) | 1414 | 1 | { | 1415 | 1 | build_id->size = cvinfo->SignatureLength; | 1416 | 1 | memcpy(build_id->data, cvinfo->Signature, | 1417 | 1 | cvinfo->SignatureLength); | 1418 | 1 | abfd->build_id = build_id; | 1419 | 1 | } | 1420 | 1 | } | 1421 | 897 | break; | 1422 | 897 | } | 1423 | 24.2k | } | 1424 | | | 1425 | 2.27k | free (data); | 1426 | 2.27k | } |
pei-arm-wince.c:pe_bfd_read_buildid Line | Count | Source | 1340 | 21.4k | { | 1341 | 21.4k | pe_data_type *pe = pe_data (abfd); | 1342 | 21.4k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1343 | 21.4k | asection *section; | 1344 | 21.4k | bfd_byte *data = 0; | 1345 | 21.4k | bfd_size_type dataoff; | 1346 | 21.4k | unsigned int i; | 1347 | 21.4k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1348 | 21.4k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1349 | | | 1350 | 21.4k | if (size == 0) | 1351 | 2.84k | return; | 1352 | | | 1353 | 18.6k | addr += extra->ImageBase; | 1354 | | | 1355 | | /* Search for the section containing the DebugDirectory. */ | 1356 | 55.5k | for (section = abfd->sections; section != NULL; section = section->next) | 1357 | 46.7k | { | 1358 | 46.7k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1359 | 9.86k | break; | 1360 | 46.7k | } | 1361 | | | 1362 | 18.6k | if (section == NULL) | 1363 | 8.76k | return; | 1364 | | | 1365 | 9.86k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1366 | 978 | return; | 1367 | | | 1368 | 8.88k | dataoff = addr - section->vma; | 1369 | | | 1370 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1371 | | Note - since we are dealing with unsigned quantities we have | 1372 | | to be careful to check for potential overflows. */ | 1373 | 8.88k | if (dataoff >= section->size | 1374 | 8.88k | || size > section->size - dataoff) | 1375 | 3.43k | { | 1376 | 3.43k | _bfd_error_handler | 1377 | 3.43k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1378 | 3.43k | abfd); | 1379 | 3.43k | return; | 1380 | 3.43k | } | 1381 | | | 1382 | | /* Read the whole section. */ | 1383 | 5.45k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1384 | 2.36k | { | 1385 | 2.36k | free (data); | 1386 | 2.36k | return; | 1387 | 2.36k | } | 1388 | | | 1389 | | /* Search for a CodeView entry in the DebugDirectory */ | 1390 | 47.4k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1391 | 45.9k | { | 1392 | 45.9k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1393 | 45.9k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1394 | 45.9k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1395 | | | 1396 | 45.9k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1397 | | | 1398 | 45.9k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1399 | 1.66k | { | 1400 | 1.66k | char buffer[256 + 1]; | 1401 | 1.66k | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1402 | | | 1403 | | /* | 1404 | | The debug entry doesn't have to have to be in a section, in which | 1405 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1406 | | */ | 1407 | 1.66k | if (_bfd_XXi_slurp_codeview_record (abfd, | 1408 | 1.66k | (file_ptr) idd.PointerToRawData, | 1409 | 1.66k | idd.SizeOfData, cvinfo, NULL)) | 1410 | 1 | { | 1411 | 1 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1412 | 1 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1413 | 1 | if (build_id) | 1414 | 1 | { | 1415 | 1 | build_id->size = cvinfo->SignatureLength; | 1416 | 1 | memcpy(build_id->data, cvinfo->Signature, | 1417 | 1 | cvinfo->SignatureLength); | 1418 | 1 | abfd->build_id = build_id; | 1419 | 1 | } | 1420 | 1 | } | 1421 | 1.66k | break; | 1422 | 1.66k | } | 1423 | 45.9k | } | 1424 | | | 1425 | 3.08k | free (data); | 1426 | 3.08k | } |
pei-arm.c:pe_bfd_read_buildid Line | Count | Source | 1340 | 26.2k | { | 1341 | 26.2k | pe_data_type *pe = pe_data (abfd); | 1342 | 26.2k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1343 | 26.2k | asection *section; | 1344 | 26.2k | bfd_byte *data = 0; | 1345 | 26.2k | bfd_size_type dataoff; | 1346 | 26.2k | unsigned int i; | 1347 | 26.2k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1348 | 26.2k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1349 | | | 1350 | 26.2k | if (size == 0) | 1351 | 5.57k | return; | 1352 | | | 1353 | 20.7k | addr += extra->ImageBase; | 1354 | | | 1355 | | /* Search for the section containing the DebugDirectory. */ | 1356 | 502k | for (section = abfd->sections; section != NULL; section = section->next) | 1357 | 492k | { | 1358 | 492k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1359 | 9.97k | break; | 1360 | 492k | } | 1361 | | | 1362 | 20.7k | if (section == NULL) | 1363 | 10.7k | return; | 1364 | | | 1365 | 9.97k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1366 | 1.69k | return; | 1367 | | | 1368 | 8.28k | dataoff = addr - section->vma; | 1369 | | | 1370 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1371 | | Note - since we are dealing with unsigned quantities we have | 1372 | | to be careful to check for potential overflows. */ | 1373 | 8.28k | if (dataoff >= section->size | 1374 | 8.28k | || size > section->size - dataoff) | 1375 | 3.93k | { | 1376 | 3.93k | _bfd_error_handler | 1377 | 3.93k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1378 | 3.93k | abfd); | 1379 | 3.93k | return; | 1380 | 3.93k | } | 1381 | | | 1382 | | /* Read the whole section. */ | 1383 | 4.35k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1384 | 2.28k | { | 1385 | 2.28k | free (data); | 1386 | 2.28k | return; | 1387 | 2.28k | } | 1388 | | | 1389 | | /* Search for a CodeView entry in the DebugDirectory */ | 1390 | 50.1k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1391 | 48.8k | { | 1392 | 48.8k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1393 | 48.8k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1394 | 48.8k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1395 | | | 1396 | 48.8k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1397 | | | 1398 | 48.8k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1399 | 846 | { | 1400 | 846 | char buffer[256 + 1]; | 1401 | 846 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1402 | | | 1403 | | /* | 1404 | | The debug entry doesn't have to have to be in a section, in which | 1405 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1406 | | */ | 1407 | 846 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1408 | 846 | (file_ptr) idd.PointerToRawData, | 1409 | 846 | idd.SizeOfData, cvinfo, NULL)) | 1410 | 7 | { | 1411 | 7 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1412 | 7 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1413 | 7 | if (build_id) | 1414 | 7 | { | 1415 | 7 | build_id->size = cvinfo->SignatureLength; | 1416 | 7 | memcpy(build_id->data, cvinfo->Signature, | 1417 | 7 | cvinfo->SignatureLength); | 1418 | 7 | abfd->build_id = build_id; | 1419 | 7 | } | 1420 | 7 | } | 1421 | 846 | break; | 1422 | 846 | } | 1423 | 48.8k | } | 1424 | | | 1425 | 2.06k | free (data); | 1426 | 2.06k | } |
pei-mcore.c:pe_bfd_read_buildid Line | Count | Source | 1340 | 39.2k | { | 1341 | 39.2k | pe_data_type *pe = pe_data (abfd); | 1342 | 39.2k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1343 | 39.2k | asection *section; | 1344 | 39.2k | bfd_byte *data = 0; | 1345 | 39.2k | bfd_size_type dataoff; | 1346 | 39.2k | unsigned int i; | 1347 | 39.2k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1348 | 39.2k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1349 | | | 1350 | 39.2k | if (size == 0) | 1351 | 9.46k | return; | 1352 | | | 1353 | 29.7k | addr += extra->ImageBase; | 1354 | | | 1355 | | /* Search for the section containing the DebugDirectory. */ | 1356 | 90.5k | for (section = abfd->sections; section != NULL; section = section->next) | 1357 | 77.0k | { | 1358 | 77.0k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1359 | 16.3k | break; | 1360 | 77.0k | } | 1361 | | | 1362 | 29.7k | if (section == NULL) | 1363 | 13.4k | return; | 1364 | | | 1365 | 16.3k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1366 | 1.79k | return; | 1367 | | | 1368 | 14.5k | dataoff = addr - section->vma; | 1369 | | | 1370 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1371 | | Note - since we are dealing with unsigned quantities we have | 1372 | | to be careful to check for potential overflows. */ | 1373 | 14.5k | if (dataoff >= section->size | 1374 | 14.5k | || size > section->size - dataoff) | 1375 | 5.95k | { | 1376 | 5.95k | _bfd_error_handler | 1377 | 5.95k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1378 | 5.95k | abfd); | 1379 | 5.95k | return; | 1380 | 5.95k | } | 1381 | | | 1382 | | /* Read the whole section. */ | 1383 | 8.58k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1384 | 6.04k | { | 1385 | 6.04k | free (data); | 1386 | 6.04k | return; | 1387 | 6.04k | } | 1388 | | | 1389 | | /* Search for a CodeView entry in the DebugDirectory */ | 1390 | 75.1k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1391 | 73.8k | { | 1392 | 73.8k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1393 | 73.8k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1394 | 73.8k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1395 | | | 1396 | 73.8k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1397 | | | 1398 | 73.8k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1399 | 1.24k | { | 1400 | 1.24k | char buffer[256 + 1]; | 1401 | 1.24k | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1402 | | | 1403 | | /* | 1404 | | The debug entry doesn't have to have to be in a section, in which | 1405 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1406 | | */ | 1407 | 1.24k | if (_bfd_XXi_slurp_codeview_record (abfd, | 1408 | 1.24k | (file_ptr) idd.PointerToRawData, | 1409 | 1.24k | idd.SizeOfData, cvinfo, NULL)) | 1410 | 0 | { | 1411 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1412 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1413 | 0 | if (build_id) | 1414 | 0 | { | 1415 | 0 | build_id->size = cvinfo->SignatureLength; | 1416 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1417 | 0 | cvinfo->SignatureLength); | 1418 | 0 | abfd->build_id = build_id; | 1419 | 0 | } | 1420 | 0 | } | 1421 | 1.24k | break; | 1422 | 1.24k | } | 1423 | 73.8k | } | 1424 | | | 1425 | 2.54k | free (data); | 1426 | 2.54k | } |
pei-sh.c:pe_bfd_read_buildid Line | Count | Source | 1340 | 31.8k | { | 1341 | 31.8k | pe_data_type *pe = pe_data (abfd); | 1342 | 31.8k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1343 | 31.8k | asection *section; | 1344 | 31.8k | bfd_byte *data = 0; | 1345 | 31.8k | bfd_size_type dataoff; | 1346 | 31.8k | unsigned int i; | 1347 | 31.8k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1348 | 31.8k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1349 | | | 1350 | 31.8k | if (size == 0) | 1351 | 13.6k | return; | 1352 | | | 1353 | 18.1k | addr += extra->ImageBase; | 1354 | | | 1355 | | /* Search for the section containing the DebugDirectory. */ | 1356 | 47.3k | for (section = abfd->sections; section != NULL; section = section->next) | 1357 | 39.3k | { | 1358 | 39.3k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1359 | 10.2k | break; | 1360 | 39.3k | } | 1361 | | | 1362 | 18.1k | if (section == NULL) | 1363 | 7.96k | return; | 1364 | | | 1365 | 10.2k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1366 | 1.08k | return; | 1367 | | | 1368 | 9.13k | dataoff = addr - section->vma; | 1369 | | | 1370 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1371 | | Note - since we are dealing with unsigned quantities we have | 1372 | | to be careful to check for potential overflows. */ | 1373 | 9.13k | if (dataoff >= section->size | 1374 | 9.13k | || size > section->size - dataoff) | 1375 | 3.81k | { | 1376 | 3.81k | _bfd_error_handler | 1377 | 3.81k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1378 | 3.81k | abfd); | 1379 | 3.81k | return; | 1380 | 3.81k | } | 1381 | | | 1382 | | /* Read the whole section. */ | 1383 | 5.31k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1384 | 2.97k | { | 1385 | 2.97k | free (data); | 1386 | 2.97k | return; | 1387 | 2.97k | } | 1388 | | | 1389 | | /* Search for a CodeView entry in the DebugDirectory */ | 1390 | 33.4k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1391 | 31.8k | { | 1392 | 31.8k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1393 | 31.8k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1394 | 31.8k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1395 | | | 1396 | 31.8k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1397 | | | 1398 | 31.8k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1399 | 719 | { | 1400 | 719 | char buffer[256 + 1]; | 1401 | 719 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1402 | | | 1403 | | /* | 1404 | | The debug entry doesn't have to have to be in a section, in which | 1405 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1406 | | */ | 1407 | 719 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1408 | 719 | (file_ptr) idd.PointerToRawData, | 1409 | 719 | idd.SizeOfData, cvinfo, NULL)) | 1410 | 1 | { | 1411 | 1 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1412 | 1 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1413 | 1 | if (build_id) | 1414 | 1 | { | 1415 | 1 | build_id->size = cvinfo->SignatureLength; | 1416 | 1 | memcpy(build_id->data, cvinfo->Signature, | 1417 | 1 | cvinfo->SignatureLength); | 1418 | 1 | abfd->build_id = build_id; | 1419 | 1 | } | 1420 | 1 | } | 1421 | 719 | break; | 1422 | 719 | } | 1423 | 31.8k | } | 1424 | | | 1425 | 2.34k | free (data); | 1426 | 2.34k | } |
|
1427 | | |
1428 | | static bfd_cleanup |
1429 | | pe_bfd_object_p (bfd * abfd) |
1430 | 18.8M | { |
1431 | 18.8M | bfd_byte buffer[6]; |
1432 | 18.8M | struct external_DOS_hdr dos_hdr; |
1433 | 18.8M | struct external_PEI_IMAGE_hdr image_hdr; |
1434 | 18.8M | struct internal_filehdr internal_f; |
1435 | 18.8M | struct internal_aouthdr internal_a; |
1436 | 18.8M | bfd_size_type opt_hdr_size; |
1437 | 18.8M | file_ptr offset; |
1438 | 18.8M | bfd_cleanup result; |
1439 | | |
1440 | | /* Detect if this a Microsoft Import Library Format element. */ |
1441 | | /* First read the beginning of the header. */ |
1442 | 18.8M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 |
1443 | 18.8M | || bfd_read (buffer, 6, abfd) != 6) |
1444 | 52.2k | { |
1445 | 52.2k | if (bfd_get_error () != bfd_error_system_call) |
1446 | 47.2k | bfd_set_error (bfd_error_wrong_format); |
1447 | 52.2k | return NULL; |
1448 | 52.2k | } |
1449 | | |
1450 | | /* Then check the magic and the version (only 0 is supported). */ |
1451 | 18.8M | if (H_GET_32 (abfd, buffer) == 0xffff0000 |
1452 | 18.8M | && H_GET_16 (abfd, buffer + 4) == 0) |
1453 | 222k | return pe_ILF_object_p (abfd); |
1454 | | |
1455 | 18.6M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 |
1456 | 18.6M | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) |
1457 | 3.32M | { |
1458 | 3.32M | if (bfd_get_error () != bfd_error_system_call) |
1459 | 3.32M | bfd_set_error (bfd_error_wrong_format); |
1460 | 3.32M | return NULL; |
1461 | 3.32M | } |
1462 | | |
1463 | | /* There are really two magic numbers involved; the magic number |
1464 | | that says this is a NT executable (PEI) and the magic number that |
1465 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in |
1466 | | the e_magic field. The latter is stored in the f_magic field. |
1467 | | If the NT magic number isn't valid, the architecture magic number |
1468 | | could be mimicked by some other field (specifically, the number |
1469 | | of relocs in section 3). Since this routine can only be called |
1470 | | correctly for a PEI file, check the e_magic number here, and, if |
1471 | | it doesn't match, clobber the f_magic number so that we don't get |
1472 | | a false match. */ |
1473 | 15.2M | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) |
1474 | 10.0M | { |
1475 | 10.0M | bfd_set_error (bfd_error_wrong_format); |
1476 | 10.0M | return NULL; |
1477 | 10.0M | } |
1478 | | |
1479 | 5.23M | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); |
1480 | 5.23M | if (bfd_seek (abfd, offset, SEEK_SET) != 0 |
1481 | 5.23M | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) |
1482 | 37.4k | { |
1483 | 37.4k | if (bfd_get_error () != bfd_error_system_call) |
1484 | 37.4k | bfd_set_error (bfd_error_wrong_format); |
1485 | 37.4k | return NULL; |
1486 | 37.4k | } |
1487 | | |
1488 | 5.19M | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) |
1489 | 124k | { |
1490 | 124k | bfd_set_error (bfd_error_wrong_format); |
1491 | 124k | return NULL; |
1492 | 124k | } |
1493 | | |
1494 | | /* Swap file header, so that we get the location for calling |
1495 | | real_object_p. */ |
1496 | 5.06M | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); |
1497 | | |
1498 | 5.06M | if (! bfd_coff_bad_format_hook (abfd, &internal_f) |
1499 | 5.06M | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) |
1500 | 4.37M | { |
1501 | 4.37M | bfd_set_error (bfd_error_wrong_format); |
1502 | 4.37M | return NULL; |
1503 | 4.37M | } |
1504 | | |
1505 | 692k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, |
1506 | 692k | sizeof (internal_f.pe.dos_message)); |
1507 | | |
1508 | | /* Read the optional header, which has variable size. */ |
1509 | 692k | opt_hdr_size = internal_f.f_opthdr; |
1510 | | |
1511 | 692k | if (opt_hdr_size != 0) |
1512 | 482k | { |
1513 | 482k | bfd_size_type amt = opt_hdr_size; |
1514 | 482k | bfd_byte * opthdr; |
1515 | | |
1516 | | /* PR 17521 file: 230-131433-0.004. */ |
1517 | 482k | if (amt < sizeof (PEAOUTHDR)) |
1518 | 323k | amt = sizeof (PEAOUTHDR); |
1519 | | |
1520 | 482k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); |
1521 | 482k | if (opthdr == NULL) |
1522 | 17.0k | return NULL; |
1523 | 465k | if (amt > opt_hdr_size) |
1524 | 316k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); |
1525 | | |
1526 | 465k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); |
1527 | | |
1528 | 465k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; |
1529 | | |
1530 | | #ifdef ARM |
1531 | | /* Use Subsystem to distinguish between pei-arm-little and |
1532 | | pei-arm-wince-little. */ |
1533 | | #ifdef WINCE |
1534 | 72.3k | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) |
1535 | | #else |
1536 | 72.4k | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) |
1537 | 28.6k | #endif |
1538 | 72.2k | { |
1539 | 72.2k | bfd_set_error (bfd_error_wrong_format); |
1540 | 72.2k | return NULL; |
1541 | 72.2k | } |
1542 | 72.5k | #endif |
1543 | | |
1544 | 392k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment |
1545 | 392k | || a->SectionAlignment >= 0x80000000) |
1546 | 237k | { |
1547 | 237k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), |
1548 | 237k | abfd); |
1549 | 237k | a->SectionAlignment &= -a->SectionAlignment; |
1550 | 237k | if (a->SectionAlignment >= 0x80000000) |
1551 | 7.31k | a->SectionAlignment = 0x40000000; |
1552 | 237k | } |
1553 | | |
1554 | 392k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment |
1555 | 392k | || a->FileAlignment > a->SectionAlignment) |
1556 | 292k | { |
1557 | 292k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), |
1558 | 292k | abfd); |
1559 | 292k | a->FileAlignment &= -a->FileAlignment; |
1560 | 292k | if (a->FileAlignment > a->SectionAlignment) |
1561 | 142k | a->FileAlignment = a->SectionAlignment; |
1562 | 292k | } |
1563 | | |
1564 | 392k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) |
1565 | 280k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); |
1566 | 72.5k | } |
1567 | | |
1568 | 603k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, |
1569 | 603k | (opt_hdr_size != 0 |
1570 | 603k | ? &internal_a |
1571 | 603k | : (struct internal_aouthdr *) NULL)); |
1572 | | |
1573 | 603k | if (result) |
1574 | 308k | { |
1575 | | /* Now the whole header has been processed, see if there is a build-id */ |
1576 | 308k | pe_bfd_read_buildid(abfd); |
1577 | 308k | } |
1578 | | |
1579 | 603k | return result; |
1580 | 692k | } pei-i386.c:pe_bfd_object_p Line | Count | Source | 1430 | 1.68M | { | 1431 | 1.68M | bfd_byte buffer[6]; | 1432 | 1.68M | struct external_DOS_hdr dos_hdr; | 1433 | 1.68M | struct external_PEI_IMAGE_hdr image_hdr; | 1434 | 1.68M | struct internal_filehdr internal_f; | 1435 | 1.68M | struct internal_aouthdr internal_a; | 1436 | 1.68M | bfd_size_type opt_hdr_size; | 1437 | 1.68M | file_ptr offset; | 1438 | 1.68M | bfd_cleanup result; | 1439 | | | 1440 | | /* Detect if this a Microsoft Import Library Format element. */ | 1441 | | /* First read the beginning of the header. */ | 1442 | 1.68M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1443 | 1.68M | || bfd_read (buffer, 6, abfd) != 6) | 1444 | 4.86k | { | 1445 | 4.86k | if (bfd_get_error () != bfd_error_system_call) | 1446 | 4.40k | bfd_set_error (bfd_error_wrong_format); | 1447 | 4.86k | return NULL; | 1448 | 4.86k | } | 1449 | | | 1450 | | /* Then check the magic and the version (only 0 is supported). */ | 1451 | 1.68M | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1452 | 1.68M | && H_GET_16 (abfd, buffer + 4) == 0) | 1453 | 28.9k | return pe_ILF_object_p (abfd); | 1454 | | | 1455 | 1.65M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1456 | 1.65M | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1457 | 297k | { | 1458 | 297k | if (bfd_get_error () != bfd_error_system_call) | 1459 | 297k | bfd_set_error (bfd_error_wrong_format); | 1460 | 297k | return NULL; | 1461 | 297k | } | 1462 | | | 1463 | | /* There are really two magic numbers involved; the magic number | 1464 | | that says this is a NT executable (PEI) and the magic number that | 1465 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1466 | | the e_magic field. The latter is stored in the f_magic field. | 1467 | | If the NT magic number isn't valid, the architecture magic number | 1468 | | could be mimicked by some other field (specifically, the number | 1469 | | of relocs in section 3). Since this routine can only be called | 1470 | | correctly for a PEI file, check the e_magic number here, and, if | 1471 | | it doesn't match, clobber the f_magic number so that we don't get | 1472 | | a false match. */ | 1473 | 1.35M | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1474 | 762k | { | 1475 | 762k | bfd_set_error (bfd_error_wrong_format); | 1476 | 762k | return NULL; | 1477 | 762k | } | 1478 | | | 1479 | 592k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1480 | 592k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1481 | 592k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1482 | 4.53k | { | 1483 | 4.53k | if (bfd_get_error () != bfd_error_system_call) | 1484 | 4.53k | bfd_set_error (bfd_error_wrong_format); | 1485 | 4.53k | return NULL; | 1486 | 4.53k | } | 1487 | | | 1488 | 588k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1489 | 15.2k | { | 1490 | 15.2k | bfd_set_error (bfd_error_wrong_format); | 1491 | 15.2k | return NULL; | 1492 | 15.2k | } | 1493 | | | 1494 | | /* Swap file header, so that we get the location for calling | 1495 | | real_object_p. */ | 1496 | 572k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1497 | | | 1498 | 572k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1499 | 572k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1500 | 506k | { | 1501 | 506k | bfd_set_error (bfd_error_wrong_format); | 1502 | 506k | return NULL; | 1503 | 506k | } | 1504 | | | 1505 | 66.1k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1506 | 66.1k | sizeof (internal_f.pe.dos_message)); | 1507 | | | 1508 | | /* Read the optional header, which has variable size. */ | 1509 | 66.1k | opt_hdr_size = internal_f.f_opthdr; | 1510 | | | 1511 | 66.1k | if (opt_hdr_size != 0) | 1512 | 49.9k | { | 1513 | 49.9k | bfd_size_type amt = opt_hdr_size; | 1514 | 49.9k | bfd_byte * opthdr; | 1515 | | | 1516 | | /* PR 17521 file: 230-131433-0.004. */ | 1517 | 49.9k | if (amt < sizeof (PEAOUTHDR)) | 1518 | 37.5k | amt = sizeof (PEAOUTHDR); | 1519 | | | 1520 | 49.9k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1521 | 49.9k | if (opthdr == NULL) | 1522 | 1.16k | return NULL; | 1523 | 48.7k | if (amt > opt_hdr_size) | 1524 | 36.9k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1525 | | | 1526 | 48.7k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1527 | | | 1528 | 48.7k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1529 | | | 1530 | | #ifdef ARM | 1531 | | /* Use Subsystem to distinguish between pei-arm-little and | 1532 | | pei-arm-wince-little. */ | 1533 | | #ifdef WINCE | 1534 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1535 | | #else | 1536 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1537 | | #endif | 1538 | | { | 1539 | | bfd_set_error (bfd_error_wrong_format); | 1540 | | return NULL; | 1541 | | } | 1542 | | #endif | 1543 | | | 1544 | 48.7k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1545 | 48.7k | || a->SectionAlignment >= 0x80000000) | 1546 | 31.0k | { | 1547 | 31.0k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1548 | 31.0k | abfd); | 1549 | 31.0k | a->SectionAlignment &= -a->SectionAlignment; | 1550 | 31.0k | if (a->SectionAlignment >= 0x80000000) | 1551 | 989 | a->SectionAlignment = 0x40000000; | 1552 | 31.0k | } | 1553 | | | 1554 | 48.7k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1555 | 48.7k | || a->FileAlignment > a->SectionAlignment) | 1556 | 34.2k | { | 1557 | 34.2k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1558 | 34.2k | abfd); | 1559 | 34.2k | a->FileAlignment &= -a->FileAlignment; | 1560 | 34.2k | if (a->FileAlignment > a->SectionAlignment) | 1561 | 17.1k | a->FileAlignment = a->SectionAlignment; | 1562 | 34.2k | } | 1563 | | | 1564 | 48.7k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1565 | 26.1k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1566 | 48.7k | } | 1567 | | | 1568 | 64.9k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1569 | 64.9k | (opt_hdr_size != 0 | 1570 | 64.9k | ? &internal_a | 1571 | 64.9k | : (struct internal_aouthdr *) NULL)); | 1572 | | | 1573 | 64.9k | if (result) | 1574 | 38.4k | { | 1575 | | /* Now the whole header has been processed, see if there is a build-id */ | 1576 | 38.4k | pe_bfd_read_buildid(abfd); | 1577 | 38.4k | } | 1578 | | | 1579 | 64.9k | return result; | 1580 | 66.1k | } |
pei-x86_64.c:pe_bfd_object_p Line | Count | Source | 1430 | 1.69M | { | 1431 | 1.69M | bfd_byte buffer[6]; | 1432 | 1.69M | struct external_DOS_hdr dos_hdr; | 1433 | 1.69M | struct external_PEI_IMAGE_hdr image_hdr; | 1434 | 1.69M | struct internal_filehdr internal_f; | 1435 | 1.69M | struct internal_aouthdr internal_a; | 1436 | 1.69M | bfd_size_type opt_hdr_size; | 1437 | 1.69M | file_ptr offset; | 1438 | 1.69M | bfd_cleanup result; | 1439 | | | 1440 | | /* Detect if this a Microsoft Import Library Format element. */ | 1441 | | /* First read the beginning of the header. */ | 1442 | 1.69M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1443 | 1.69M | || bfd_read (buffer, 6, abfd) != 6) | 1444 | 4.86k | { | 1445 | 4.86k | if (bfd_get_error () != bfd_error_system_call) | 1446 | 4.40k | bfd_set_error (bfd_error_wrong_format); | 1447 | 4.86k | return NULL; | 1448 | 4.86k | } | 1449 | | | 1450 | | /* Then check the magic and the version (only 0 is supported). */ | 1451 | 1.69M | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1452 | 1.69M | && H_GET_16 (abfd, buffer + 4) == 0) | 1453 | 24.2k | return pe_ILF_object_p (abfd); | 1454 | | | 1455 | 1.66M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1456 | 1.66M | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1457 | 298k | { | 1458 | 298k | if (bfd_get_error () != bfd_error_system_call) | 1459 | 298k | bfd_set_error (bfd_error_wrong_format); | 1460 | 298k | return NULL; | 1461 | 298k | } | 1462 | | | 1463 | | /* There are really two magic numbers involved; the magic number | 1464 | | that says this is a NT executable (PEI) and the magic number that | 1465 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1466 | | the e_magic field. The latter is stored in the f_magic field. | 1467 | | If the NT magic number isn't valid, the architecture magic number | 1468 | | could be mimicked by some other field (specifically, the number | 1469 | | of relocs in section 3). Since this routine can only be called | 1470 | | correctly for a PEI file, check the e_magic number here, and, if | 1471 | | it doesn't match, clobber the f_magic number so that we don't get | 1472 | | a false match. */ | 1473 | 1.36M | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1474 | 766k | { | 1475 | 766k | bfd_set_error (bfd_error_wrong_format); | 1476 | 766k | return NULL; | 1477 | 766k | } | 1478 | | | 1479 | 601k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1480 | 601k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1481 | 601k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1482 | 4.53k | { | 1483 | 4.53k | if (bfd_get_error () != bfd_error_system_call) | 1484 | 4.53k | bfd_set_error (bfd_error_wrong_format); | 1485 | 4.53k | return NULL; | 1486 | 4.53k | } | 1487 | | | 1488 | 596k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1489 | 15.2k | { | 1490 | 15.2k | bfd_set_error (bfd_error_wrong_format); | 1491 | 15.2k | return NULL; | 1492 | 15.2k | } | 1493 | | | 1494 | | /* Swap file header, so that we get the location for calling | 1495 | | real_object_p. */ | 1496 | 581k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1497 | | | 1498 | 581k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1499 | 581k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1500 | 503k | { | 1501 | 503k | bfd_set_error (bfd_error_wrong_format); | 1502 | 503k | return NULL; | 1503 | 503k | } | 1504 | | | 1505 | 78.4k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1506 | 78.4k | sizeof (internal_f.pe.dos_message)); | 1507 | | | 1508 | | /* Read the optional header, which has variable size. */ | 1509 | 78.4k | opt_hdr_size = internal_f.f_opthdr; | 1510 | | | 1511 | 78.4k | if (opt_hdr_size != 0) | 1512 | 51.9k | { | 1513 | 51.9k | bfd_size_type amt = opt_hdr_size; | 1514 | 51.9k | bfd_byte * opthdr; | 1515 | | | 1516 | | /* PR 17521 file: 230-131433-0.004. */ | 1517 | 51.9k | if (amt < sizeof (PEAOUTHDR)) | 1518 | 46.1k | amt = sizeof (PEAOUTHDR); | 1519 | | | 1520 | 51.9k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1521 | 51.9k | if (opthdr == NULL) | 1522 | 1.18k | return NULL; | 1523 | 50.7k | if (amt > opt_hdr_size) | 1524 | 45.3k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1525 | | | 1526 | 50.7k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1527 | | | 1528 | 50.7k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1529 | | | 1530 | | #ifdef ARM | 1531 | | /* Use Subsystem to distinguish between pei-arm-little and | 1532 | | pei-arm-wince-little. */ | 1533 | | #ifdef WINCE | 1534 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1535 | | #else | 1536 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1537 | | #endif | 1538 | | { | 1539 | | bfd_set_error (bfd_error_wrong_format); | 1540 | | return NULL; | 1541 | | } | 1542 | | #endif | 1543 | | | 1544 | 50.7k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1545 | 50.7k | || a->SectionAlignment >= 0x80000000) | 1546 | 32.5k | { | 1547 | 32.5k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1548 | 32.5k | abfd); | 1549 | 32.5k | a->SectionAlignment &= -a->SectionAlignment; | 1550 | 32.5k | if (a->SectionAlignment >= 0x80000000) | 1551 | 641 | a->SectionAlignment = 0x40000000; | 1552 | 32.5k | } | 1553 | | | 1554 | 50.7k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1555 | 50.7k | || a->FileAlignment > a->SectionAlignment) | 1556 | 41.0k | { | 1557 | 41.0k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1558 | 41.0k | abfd); | 1559 | 41.0k | a->FileAlignment &= -a->FileAlignment; | 1560 | 41.0k | if (a->FileAlignment > a->SectionAlignment) | 1561 | 21.6k | a->FileAlignment = a->SectionAlignment; | 1562 | 41.0k | } | 1563 | | | 1564 | 50.7k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1565 | 35.4k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1566 | 50.7k | } | 1567 | | | 1568 | 77.2k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1569 | 77.2k | (opt_hdr_size != 0 | 1570 | 77.2k | ? &internal_a | 1571 | 77.2k | : (struct internal_aouthdr *) NULL)); | 1572 | | | 1573 | 77.2k | if (result) | 1574 | 51.1k | { | 1575 | | /* Now the whole header has been processed, see if there is a build-id */ | 1576 | 51.1k | pe_bfd_read_buildid(abfd); | 1577 | 51.1k | } | 1578 | | | 1579 | 77.2k | return result; | 1580 | 78.4k | } |
pei-aarch64.c:pe_bfd_object_p Line | Count | Source | 1430 | 1.67M | { | 1431 | 1.67M | bfd_byte buffer[6]; | 1432 | 1.67M | struct external_DOS_hdr dos_hdr; | 1433 | 1.67M | struct external_PEI_IMAGE_hdr image_hdr; | 1434 | 1.67M | struct internal_filehdr internal_f; | 1435 | 1.67M | struct internal_aouthdr internal_a; | 1436 | 1.67M | bfd_size_type opt_hdr_size; | 1437 | 1.67M | file_ptr offset; | 1438 | 1.67M | bfd_cleanup result; | 1439 | | | 1440 | | /* Detect if this a Microsoft Import Library Format element. */ | 1441 | | /* First read the beginning of the header. */ | 1442 | 1.67M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1443 | 1.67M | || bfd_read (buffer, 6, abfd) != 6) | 1444 | 4.86k | { | 1445 | 4.86k | if (bfd_get_error () != bfd_error_system_call) | 1446 | 4.40k | bfd_set_error (bfd_error_wrong_format); | 1447 | 4.86k | return NULL; | 1448 | 4.86k | } | 1449 | | | 1450 | | /* Then check the magic and the version (only 0 is supported). */ | 1451 | 1.67M | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1452 | 1.67M | && H_GET_16 (abfd, buffer + 4) == 0) | 1453 | 34.4k | return pe_ILF_object_p (abfd); | 1454 | | | 1455 | 1.63M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1456 | 1.63M | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1457 | 297k | { | 1458 | 297k | if (bfd_get_error () != bfd_error_system_call) | 1459 | 297k | bfd_set_error (bfd_error_wrong_format); | 1460 | 297k | return NULL; | 1461 | 297k | } | 1462 | | | 1463 | | /* There are really two magic numbers involved; the magic number | 1464 | | that says this is a NT executable (PEI) and the magic number that | 1465 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1466 | | the e_magic field. The latter is stored in the f_magic field. | 1467 | | If the NT magic number isn't valid, the architecture magic number | 1468 | | could be mimicked by some other field (specifically, the number | 1469 | | of relocs in section 3). Since this routine can only be called | 1470 | | correctly for a PEI file, check the e_magic number here, and, if | 1471 | | it doesn't match, clobber the f_magic number so that we don't get | 1472 | | a false match. */ | 1473 | 1.33M | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1474 | 756k | { | 1475 | 756k | bfd_set_error (bfd_error_wrong_format); | 1476 | 756k | return NULL; | 1477 | 756k | } | 1478 | | | 1479 | 582k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1480 | 582k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1481 | 582k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1482 | 4.94k | { | 1483 | 4.94k | if (bfd_get_error () != bfd_error_system_call) | 1484 | 4.94k | bfd_set_error (bfd_error_wrong_format); | 1485 | 4.94k | return NULL; | 1486 | 4.94k | } | 1487 | | | 1488 | 577k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1489 | 15.9k | { | 1490 | 15.9k | bfd_set_error (bfd_error_wrong_format); | 1491 | 15.9k | return NULL; | 1492 | 15.9k | } | 1493 | | | 1494 | | /* Swap file header, so that we get the location for calling | 1495 | | real_object_p. */ | 1496 | 561k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1497 | | | 1498 | 561k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1499 | 561k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1500 | 499k | { | 1501 | 499k | bfd_set_error (bfd_error_wrong_format); | 1502 | 499k | return NULL; | 1503 | 499k | } | 1504 | | | 1505 | 62.0k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1506 | 62.0k | sizeof (internal_f.pe.dos_message)); | 1507 | | | 1508 | | /* Read the optional header, which has variable size. */ | 1509 | 62.0k | opt_hdr_size = internal_f.f_opthdr; | 1510 | | | 1511 | 62.0k | if (opt_hdr_size != 0) | 1512 | 52.4k | { | 1513 | 52.4k | bfd_size_type amt = opt_hdr_size; | 1514 | 52.4k | bfd_byte * opthdr; | 1515 | | | 1516 | | /* PR 17521 file: 230-131433-0.004. */ | 1517 | 52.4k | if (amt < sizeof (PEAOUTHDR)) | 1518 | 22.7k | amt = sizeof (PEAOUTHDR); | 1519 | | | 1520 | 52.4k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1521 | 52.4k | if (opthdr == NULL) | 1522 | 1.89k | return NULL; | 1523 | 50.5k | if (amt > opt_hdr_size) | 1524 | 21.5k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1525 | | | 1526 | 50.5k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1527 | | | 1528 | 50.5k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1529 | | | 1530 | | #ifdef ARM | 1531 | | /* Use Subsystem to distinguish between pei-arm-little and | 1532 | | pei-arm-wince-little. */ | 1533 | | #ifdef WINCE | 1534 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1535 | | #else | 1536 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1537 | | #endif | 1538 | | { | 1539 | | bfd_set_error (bfd_error_wrong_format); | 1540 | | return NULL; | 1541 | | } | 1542 | | #endif | 1543 | | | 1544 | 50.5k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1545 | 50.5k | || a->SectionAlignment >= 0x80000000) | 1546 | 30.8k | { | 1547 | 30.8k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1548 | 30.8k | abfd); | 1549 | 30.8k | a->SectionAlignment &= -a->SectionAlignment; | 1550 | 30.8k | if (a->SectionAlignment >= 0x80000000) | 1551 | 969 | a->SectionAlignment = 0x40000000; | 1552 | 30.8k | } | 1553 | | | 1554 | 50.5k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1555 | 50.5k | || a->FileAlignment > a->SectionAlignment) | 1556 | 36.6k | { | 1557 | 36.6k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1558 | 36.6k | abfd); | 1559 | 36.6k | a->FileAlignment &= -a->FileAlignment; | 1560 | 36.6k | if (a->FileAlignment > a->SectionAlignment) | 1561 | 14.0k | a->FileAlignment = a->SectionAlignment; | 1562 | 36.6k | } | 1563 | | | 1564 | 50.5k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1565 | 39.3k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1566 | 50.5k | } | 1567 | | | 1568 | 60.1k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1569 | 60.1k | (opt_hdr_size != 0 | 1570 | 60.1k | ? &internal_a | 1571 | 60.1k | : (struct internal_aouthdr *) NULL)); | 1572 | | | 1573 | 60.1k | if (result) | 1574 | 33.1k | { | 1575 | | /* Now the whole header has been processed, see if there is a build-id */ | 1576 | 33.1k | pe_bfd_read_buildid(abfd); | 1577 | 33.1k | } | 1578 | | | 1579 | 60.1k | return result; | 1580 | 62.0k | } |
pei-ia64.c:pe_bfd_object_p Line | Count | Source | 1430 | 546k | { | 1431 | 546k | bfd_byte buffer[6]; | 1432 | 546k | struct external_DOS_hdr dos_hdr; | 1433 | 546k | struct external_PEI_IMAGE_hdr image_hdr; | 1434 | 546k | struct internal_filehdr internal_f; | 1435 | 546k | struct internal_aouthdr internal_a; | 1436 | 546k | bfd_size_type opt_hdr_size; | 1437 | 546k | file_ptr offset; | 1438 | 546k | bfd_cleanup result; | 1439 | | | 1440 | | /* Detect if this a Microsoft Import Library Format element. */ | 1441 | | /* First read the beginning of the header. */ | 1442 | 546k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1443 | 546k | || bfd_read (buffer, 6, abfd) != 6) | 1444 | 0 | { | 1445 | 0 | if (bfd_get_error () != bfd_error_system_call) | 1446 | 0 | bfd_set_error (bfd_error_wrong_format); | 1447 | 0 | return NULL; | 1448 | 0 | } | 1449 | | | 1450 | | /* Then check the magic and the version (only 0 is supported). */ | 1451 | 546k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1452 | 546k | && H_GET_16 (abfd, buffer + 4) == 0) | 1453 | 0 | return pe_ILF_object_p (abfd); | 1454 | | | 1455 | 546k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1456 | 546k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1457 | 0 | { | 1458 | 0 | if (bfd_get_error () != bfd_error_system_call) | 1459 | 0 | bfd_set_error (bfd_error_wrong_format); | 1460 | 0 | return NULL; | 1461 | 0 | } | 1462 | | | 1463 | | /* There are really two magic numbers involved; the magic number | 1464 | | that says this is a NT executable (PEI) and the magic number that | 1465 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1466 | | the e_magic field. The latter is stored in the f_magic field. | 1467 | | If the NT magic number isn't valid, the architecture magic number | 1468 | | could be mimicked by some other field (specifically, the number | 1469 | | of relocs in section 3). Since this routine can only be called | 1470 | | correctly for a PEI file, check the e_magic number here, and, if | 1471 | | it doesn't match, clobber the f_magic number so that we don't get | 1472 | | a false match. */ | 1473 | 546k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1474 | 0 | { | 1475 | 0 | bfd_set_error (bfd_error_wrong_format); | 1476 | 0 | return NULL; | 1477 | 0 | } | 1478 | | | 1479 | 546k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1480 | 546k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1481 | 546k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1482 | 0 | { | 1483 | 0 | if (bfd_get_error () != bfd_error_system_call) | 1484 | 0 | bfd_set_error (bfd_error_wrong_format); | 1485 | 0 | return NULL; | 1486 | 0 | } | 1487 | | | 1488 | 546k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1489 | 0 | { | 1490 | 0 | bfd_set_error (bfd_error_wrong_format); | 1491 | 0 | return NULL; | 1492 | 0 | } | 1493 | | | 1494 | | /* Swap file header, so that we get the location for calling | 1495 | | real_object_p. */ | 1496 | 546k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1497 | | | 1498 | 546k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1499 | 546k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1500 | 470k | { | 1501 | 470k | bfd_set_error (bfd_error_wrong_format); | 1502 | 470k | return NULL; | 1503 | 470k | } | 1504 | | | 1505 | 75.7k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1506 | 75.7k | sizeof (internal_f.pe.dos_message)); | 1507 | | | 1508 | | /* Read the optional header, which has variable size. */ | 1509 | 75.7k | opt_hdr_size = internal_f.f_opthdr; | 1510 | | | 1511 | 75.7k | if (opt_hdr_size != 0) | 1512 | 48.6k | { | 1513 | 48.6k | bfd_size_type amt = opt_hdr_size; | 1514 | 48.6k | bfd_byte * opthdr; | 1515 | | | 1516 | | /* PR 17521 file: 230-131433-0.004. */ | 1517 | 48.6k | if (amt < sizeof (PEAOUTHDR)) | 1518 | 39.2k | amt = sizeof (PEAOUTHDR); | 1519 | | | 1520 | 48.6k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1521 | 48.6k | if (opthdr == NULL) | 1522 | 2.30k | return NULL; | 1523 | 46.3k | if (amt > opt_hdr_size) | 1524 | 37.2k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1525 | | | 1526 | 46.3k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1527 | | | 1528 | 46.3k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1529 | | | 1530 | | #ifdef ARM | 1531 | | /* Use Subsystem to distinguish between pei-arm-little and | 1532 | | pei-arm-wince-little. */ | 1533 | | #ifdef WINCE | 1534 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1535 | | #else | 1536 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1537 | | #endif | 1538 | | { | 1539 | | bfd_set_error (bfd_error_wrong_format); | 1540 | | return NULL; | 1541 | | } | 1542 | | #endif | 1543 | | | 1544 | 46.3k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1545 | 46.3k | || a->SectionAlignment >= 0x80000000) | 1546 | 29.6k | { | 1547 | 29.6k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1548 | 29.6k | abfd); | 1549 | 29.6k | a->SectionAlignment &= -a->SectionAlignment; | 1550 | 29.6k | if (a->SectionAlignment >= 0x80000000) | 1551 | 1.30k | a->SectionAlignment = 0x40000000; | 1552 | 29.6k | } | 1553 | | | 1554 | 46.3k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1555 | 46.3k | || a->FileAlignment > a->SectionAlignment) | 1556 | 33.4k | { | 1557 | 33.4k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1558 | 33.4k | abfd); | 1559 | 33.4k | a->FileAlignment &= -a->FileAlignment; | 1560 | 33.4k | if (a->FileAlignment > a->SectionAlignment) | 1561 | 10.4k | a->FileAlignment = a->SectionAlignment; | 1562 | 33.4k | } | 1563 | | | 1564 | 46.3k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1565 | 36.3k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1566 | 46.3k | } | 1567 | | | 1568 | 73.4k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1569 | 73.4k | (opt_hdr_size != 0 | 1570 | 73.4k | ? &internal_a | 1571 | 73.4k | : (struct internal_aouthdr *) NULL)); | 1572 | | | 1573 | 73.4k | if (result) | 1574 | 37.1k | { | 1575 | | /* Now the whole header has been processed, see if there is a build-id */ | 1576 | 37.1k | pe_bfd_read_buildid(abfd); | 1577 | 37.1k | } | 1578 | | | 1579 | 73.4k | return result; | 1580 | 75.7k | } |
pei-loongarch64.c:pe_bfd_object_p Line | Count | Source | 1430 | 1.67M | { | 1431 | 1.67M | bfd_byte buffer[6]; | 1432 | 1.67M | struct external_DOS_hdr dos_hdr; | 1433 | 1.67M | struct external_PEI_IMAGE_hdr image_hdr; | 1434 | 1.67M | struct internal_filehdr internal_f; | 1435 | 1.67M | struct internal_aouthdr internal_a; | 1436 | 1.67M | bfd_size_type opt_hdr_size; | 1437 | 1.67M | file_ptr offset; | 1438 | 1.67M | bfd_cleanup result; | 1439 | | | 1440 | | /* Detect if this a Microsoft Import Library Format element. */ | 1441 | | /* First read the beginning of the header. */ | 1442 | 1.67M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1443 | 1.67M | || bfd_read (buffer, 6, abfd) != 6) | 1444 | 4.86k | { | 1445 | 4.86k | if (bfd_get_error () != bfd_error_system_call) | 1446 | 4.40k | bfd_set_error (bfd_error_wrong_format); | 1447 | 4.86k | return NULL; | 1448 | 4.86k | } | 1449 | | | 1450 | | /* Then check the magic and the version (only 0 is supported). */ | 1451 | 1.67M | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1452 | 1.67M | && H_GET_16 (abfd, buffer + 4) == 0) | 1453 | 20.4k | return pe_ILF_object_p (abfd); | 1454 | | | 1455 | 1.65M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1456 | 1.65M | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1457 | 300k | { | 1458 | 300k | if (bfd_get_error () != bfd_error_system_call) | 1459 | 300k | bfd_set_error (bfd_error_wrong_format); | 1460 | 300k | return NULL; | 1461 | 300k | } | 1462 | | | 1463 | | /* There are really two magic numbers involved; the magic number | 1464 | | that says this is a NT executable (PEI) and the magic number that | 1465 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1466 | | the e_magic field. The latter is stored in the f_magic field. | 1467 | | If the NT magic number isn't valid, the architecture magic number | 1468 | | could be mimicked by some other field (specifically, the number | 1469 | | of relocs in section 3). Since this routine can only be called | 1470 | | correctly for a PEI file, check the e_magic number here, and, if | 1471 | | it doesn't match, clobber the f_magic number so that we don't get | 1472 | | a false match. */ | 1473 | 1.34M | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1474 | 768k | { | 1475 | 768k | bfd_set_error (bfd_error_wrong_format); | 1476 | 768k | return NULL; | 1477 | 768k | } | 1478 | | | 1479 | 581k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1480 | 581k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1481 | 581k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1482 | 4.53k | { | 1483 | 4.53k | if (bfd_get_error () != bfd_error_system_call) | 1484 | 4.53k | bfd_set_error (bfd_error_wrong_format); | 1485 | 4.53k | return NULL; | 1486 | 4.53k | } | 1487 | | | 1488 | 576k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1489 | 15.2k | { | 1490 | 15.2k | bfd_set_error (bfd_error_wrong_format); | 1491 | 15.2k | return NULL; | 1492 | 15.2k | } | 1493 | | | 1494 | | /* Swap file header, so that we get the location for calling | 1495 | | real_object_p. */ | 1496 | 561k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1497 | | | 1498 | 561k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1499 | 561k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1500 | 508k | { | 1501 | 508k | bfd_set_error (bfd_error_wrong_format); | 1502 | 508k | return NULL; | 1503 | 508k | } | 1504 | | | 1505 | 53.3k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1506 | 53.3k | sizeof (internal_f.pe.dos_message)); | 1507 | | | 1508 | | /* Read the optional header, which has variable size. */ | 1509 | 53.3k | opt_hdr_size = internal_f.f_opthdr; | 1510 | | | 1511 | 53.3k | if (opt_hdr_size != 0) | 1512 | 38.4k | { | 1513 | 38.4k | bfd_size_type amt = opt_hdr_size; | 1514 | 38.4k | bfd_byte * opthdr; | 1515 | | | 1516 | | /* PR 17521 file: 230-131433-0.004. */ | 1517 | 38.4k | if (amt < sizeof (PEAOUTHDR)) | 1518 | 24.5k | amt = sizeof (PEAOUTHDR); | 1519 | | | 1520 | 38.4k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1521 | 38.4k | if (opthdr == NULL) | 1522 | 1.55k | return NULL; | 1523 | 36.9k | if (amt > opt_hdr_size) | 1524 | 23.9k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1525 | | | 1526 | 36.9k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1527 | | | 1528 | 36.9k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1529 | | | 1530 | | #ifdef ARM | 1531 | | /* Use Subsystem to distinguish between pei-arm-little and | 1532 | | pei-arm-wince-little. */ | 1533 | | #ifdef WINCE | 1534 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1535 | | #else | 1536 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1537 | | #endif | 1538 | | { | 1539 | | bfd_set_error (bfd_error_wrong_format); | 1540 | | return NULL; | 1541 | | } | 1542 | | #endif | 1543 | | | 1544 | 36.9k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1545 | 36.9k | || a->SectionAlignment >= 0x80000000) | 1546 | 18.2k | { | 1547 | 18.2k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1548 | 18.2k | abfd); | 1549 | 18.2k | a->SectionAlignment &= -a->SectionAlignment; | 1550 | 18.2k | if (a->SectionAlignment >= 0x80000000) | 1551 | 354 | a->SectionAlignment = 0x40000000; | 1552 | 18.2k | } | 1553 | | | 1554 | 36.9k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1555 | 36.9k | || a->FileAlignment > a->SectionAlignment) | 1556 | 30.9k | { | 1557 | 30.9k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1558 | 30.9k | abfd); | 1559 | 30.9k | a->FileAlignment &= -a->FileAlignment; | 1560 | 30.9k | if (a->FileAlignment > a->SectionAlignment) | 1561 | 16.5k | a->FileAlignment = a->SectionAlignment; | 1562 | 30.9k | } | 1563 | | | 1564 | 36.9k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1565 | 27.1k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1566 | 36.9k | } | 1567 | | | 1568 | 51.7k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1569 | 51.7k | (opt_hdr_size != 0 | 1570 | 51.7k | ? &internal_a | 1571 | 51.7k | : (struct internal_aouthdr *) NULL)); | 1572 | | | 1573 | 51.7k | if (result) | 1574 | 29.4k | { | 1575 | | /* Now the whole header has been processed, see if there is a build-id */ | 1576 | 29.4k | pe_bfd_read_buildid(abfd); | 1577 | 29.4k | } | 1578 | | | 1579 | 51.7k | return result; | 1580 | 53.3k | } |
pei-arm-wince.c:pe_bfd_object_p Line | Count | Source | 1430 | 3.31M | { | 1431 | 3.31M | bfd_byte buffer[6]; | 1432 | 3.31M | struct external_DOS_hdr dos_hdr; | 1433 | 3.31M | struct external_PEI_IMAGE_hdr image_hdr; | 1434 | 3.31M | struct internal_filehdr internal_f; | 1435 | 3.31M | struct internal_aouthdr internal_a; | 1436 | 3.31M | bfd_size_type opt_hdr_size; | 1437 | 3.31M | file_ptr offset; | 1438 | 3.31M | bfd_cleanup result; | 1439 | | | 1440 | | /* Detect if this a Microsoft Import Library Format element. */ | 1441 | | /* First read the beginning of the header. */ | 1442 | 3.31M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1443 | 3.31M | || bfd_read (buffer, 6, abfd) != 6) | 1444 | 9.37k | { | 1445 | 9.37k | if (bfd_get_error () != bfd_error_system_call) | 1446 | 8.46k | bfd_set_error (bfd_error_wrong_format); | 1447 | 9.37k | return NULL; | 1448 | 9.37k | } | 1449 | | | 1450 | | /* Then check the magic and the version (only 0 is supported). */ | 1451 | 3.30M | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1452 | 3.30M | && H_GET_16 (abfd, buffer + 4) == 0) | 1453 | 28.9k | return pe_ILF_object_p (abfd); | 1454 | | | 1455 | 3.27M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1456 | 3.27M | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1457 | 610k | { | 1458 | 610k | if (bfd_get_error () != bfd_error_system_call) | 1459 | 610k | bfd_set_error (bfd_error_wrong_format); | 1460 | 610k | return NULL; | 1461 | 610k | } | 1462 | | | 1463 | | /* There are really two magic numbers involved; the magic number | 1464 | | that says this is a NT executable (PEI) and the magic number that | 1465 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1466 | | the e_magic field. The latter is stored in the f_magic field. | 1467 | | If the NT magic number isn't valid, the architecture magic number | 1468 | | could be mimicked by some other field (specifically, the number | 1469 | | of relocs in section 3). Since this routine can only be called | 1470 | | correctly for a PEI file, check the e_magic number here, and, if | 1471 | | it doesn't match, clobber the f_magic number so that we don't get | 1472 | | a false match. */ | 1473 | 2.66M | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1474 | 2.08M | { | 1475 | 2.08M | bfd_set_error (bfd_error_wrong_format); | 1476 | 2.08M | return NULL; | 1477 | 2.08M | } | 1478 | | | 1479 | 582k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1480 | 582k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1481 | 582k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1482 | 4.94k | { | 1483 | 4.94k | if (bfd_get_error () != bfd_error_system_call) | 1484 | 4.94k | bfd_set_error (bfd_error_wrong_format); | 1485 | 4.94k | return NULL; | 1486 | 4.94k | } | 1487 | | | 1488 | 577k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1489 | 15.9k | { | 1490 | 15.9k | bfd_set_error (bfd_error_wrong_format); | 1491 | 15.9k | return NULL; | 1492 | 15.9k | } | 1493 | | | 1494 | | /* Swap file header, so that we get the location for calling | 1495 | | real_object_p. */ | 1496 | 561k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1497 | | | 1498 | 561k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1499 | 561k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1500 | 448k | { | 1501 | 448k | bfd_set_error (bfd_error_wrong_format); | 1502 | 448k | return NULL; | 1503 | 448k | } | 1504 | | | 1505 | 112k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1506 | 112k | sizeof (internal_f.pe.dos_message)); | 1507 | | | 1508 | | /* Read the optional header, which has variable size. */ | 1509 | 112k | opt_hdr_size = internal_f.f_opthdr; | 1510 | | | 1511 | 112k | if (opt_hdr_size != 0) | 1512 | 74.5k | { | 1513 | 74.5k | bfd_size_type amt = opt_hdr_size; | 1514 | 74.5k | bfd_byte * opthdr; | 1515 | | | 1516 | | /* PR 17521 file: 230-131433-0.004. */ | 1517 | 74.5k | if (amt < sizeof (PEAOUTHDR)) | 1518 | 44.8k | amt = sizeof (PEAOUTHDR); | 1519 | | | 1520 | 74.5k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1521 | 74.5k | if (opthdr == NULL) | 1522 | 2.16k | return NULL; | 1523 | 72.3k | if (amt > opt_hdr_size) | 1524 | 44.3k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1525 | | | 1526 | 72.3k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1527 | | | 1528 | 72.3k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1529 | | | 1530 | 72.3k | #ifdef ARM | 1531 | | /* Use Subsystem to distinguish between pei-arm-little and | 1532 | | pei-arm-wince-little. */ | 1533 | 72.3k | #ifdef WINCE | 1534 | 72.3k | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1535 | | #else | 1536 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1537 | | #endif | 1538 | 43.6k | { | 1539 | 43.6k | bfd_set_error (bfd_error_wrong_format); | 1540 | 43.6k | return NULL; | 1541 | 43.6k | } | 1542 | 28.7k | #endif | 1543 | | | 1544 | 28.7k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1545 | 28.7k | || a->SectionAlignment >= 0x80000000) | 1546 | 19.3k | { | 1547 | 19.3k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1548 | 19.3k | abfd); | 1549 | 19.3k | a->SectionAlignment &= -a->SectionAlignment; | 1550 | 19.3k | if (a->SectionAlignment >= 0x80000000) | 1551 | 579 | a->SectionAlignment = 0x40000000; | 1552 | 19.3k | } | 1553 | | | 1554 | 28.7k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1555 | 28.7k | || a->FileAlignment > a->SectionAlignment) | 1556 | 17.6k | { | 1557 | 17.6k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1558 | 17.6k | abfd); | 1559 | 17.6k | a->FileAlignment &= -a->FileAlignment; | 1560 | 17.6k | if (a->FileAlignment > a->SectionAlignment) | 1561 | 11.4k | a->FileAlignment = a->SectionAlignment; | 1562 | 17.6k | } | 1563 | | | 1564 | 28.7k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1565 | 23.3k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1566 | 28.7k | } | 1567 | | | 1568 | 67.0k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1569 | 67.0k | (opt_hdr_size != 0 | 1570 | 67.0k | ? &internal_a | 1571 | 67.0k | : (struct internal_aouthdr *) NULL)); | 1572 | | | 1573 | 67.0k | if (result) | 1574 | 21.4k | { | 1575 | | /* Now the whole header has been processed, see if there is a build-id */ | 1576 | 21.4k | pe_bfd_read_buildid(abfd); | 1577 | 21.4k | } | 1578 | | | 1579 | 67.0k | return result; | 1580 | 112k | } |
pei-arm.c:pe_bfd_object_p Line | Count | Source | 1430 | 3.31M | { | 1431 | 3.31M | bfd_byte buffer[6]; | 1432 | 3.31M | struct external_DOS_hdr dos_hdr; | 1433 | 3.31M | struct external_PEI_IMAGE_hdr image_hdr; | 1434 | 3.31M | struct internal_filehdr internal_f; | 1435 | 3.31M | struct internal_aouthdr internal_a; | 1436 | 3.31M | bfd_size_type opt_hdr_size; | 1437 | 3.31M | file_ptr offset; | 1438 | 3.31M | bfd_cleanup result; | 1439 | | | 1440 | | /* Detect if this a Microsoft Import Library Format element. */ | 1441 | | /* First read the beginning of the header. */ | 1442 | 3.31M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1443 | 3.31M | || bfd_read (buffer, 6, abfd) != 6) | 1444 | 9.37k | { | 1445 | 9.37k | if (bfd_get_error () != bfd_error_system_call) | 1446 | 8.46k | bfd_set_error (bfd_error_wrong_format); | 1447 | 9.37k | return NULL; | 1448 | 9.37k | } | 1449 | | | 1450 | | /* Then check the magic and the version (only 0 is supported). */ | 1451 | 3.30M | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1452 | 3.30M | && H_GET_16 (abfd, buffer + 4) == 0) | 1453 | 32.1k | return pe_ILF_object_p (abfd); | 1454 | | | 1455 | 3.27M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1456 | 3.27M | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1457 | 613k | { | 1458 | 613k | if (bfd_get_error () != bfd_error_system_call) | 1459 | 613k | bfd_set_error (bfd_error_wrong_format); | 1460 | 613k | return NULL; | 1461 | 613k | } | 1462 | | | 1463 | | /* There are really two magic numbers involved; the magic number | 1464 | | that says this is a NT executable (PEI) and the magic number that | 1465 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1466 | | the e_magic field. The latter is stored in the f_magic field. | 1467 | | If the NT magic number isn't valid, the architecture magic number | 1468 | | could be mimicked by some other field (specifically, the number | 1469 | | of relocs in section 3). Since this routine can only be called | 1470 | | correctly for a PEI file, check the e_magic number here, and, if | 1471 | | it doesn't match, clobber the f_magic number so that we don't get | 1472 | | a false match. */ | 1473 | 2.66M | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1474 | 2.08M | { | 1475 | 2.08M | bfd_set_error (bfd_error_wrong_format); | 1476 | 2.08M | return NULL; | 1477 | 2.08M | } | 1478 | | | 1479 | 582k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1480 | 582k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1481 | 582k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1482 | 4.94k | { | 1483 | 4.94k | if (bfd_get_error () != bfd_error_system_call) | 1484 | 4.94k | bfd_set_error (bfd_error_wrong_format); | 1485 | 4.94k | return NULL; | 1486 | 4.94k | } | 1487 | | | 1488 | 577k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1489 | 15.9k | { | 1490 | 15.9k | bfd_set_error (bfd_error_wrong_format); | 1491 | 15.9k | return NULL; | 1492 | 15.9k | } | 1493 | | | 1494 | | /* Swap file header, so that we get the location for calling | 1495 | | real_object_p. */ | 1496 | 561k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1497 | | | 1498 | 561k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1499 | 561k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1500 | 448k | { | 1501 | 448k | bfd_set_error (bfd_error_wrong_format); | 1502 | 448k | return NULL; | 1503 | 448k | } | 1504 | | | 1505 | 112k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1506 | 112k | sizeof (internal_f.pe.dos_message)); | 1507 | | | 1508 | | /* Read the optional header, which has variable size. */ | 1509 | 112k | opt_hdr_size = internal_f.f_opthdr; | 1510 | | | 1511 | 112k | if (opt_hdr_size != 0) | 1512 | 74.5k | { | 1513 | 74.5k | bfd_size_type amt = opt_hdr_size; | 1514 | 74.5k | bfd_byte * opthdr; | 1515 | | | 1516 | | /* PR 17521 file: 230-131433-0.004. */ | 1517 | 74.5k | if (amt < sizeof (PEAOUTHDR)) | 1518 | 44.9k | amt = sizeof (PEAOUTHDR); | 1519 | | | 1520 | 74.5k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1521 | 74.5k | if (opthdr == NULL) | 1522 | 2.16k | return NULL; | 1523 | 72.4k | if (amt > opt_hdr_size) | 1524 | 44.3k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1525 | | | 1526 | 72.4k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1527 | | | 1528 | 72.4k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1529 | | | 1530 | 72.4k | #ifdef ARM | 1531 | | /* Use Subsystem to distinguish between pei-arm-little and | 1532 | | pei-arm-wince-little. */ | 1533 | | #ifdef WINCE | 1534 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1535 | | #else | 1536 | 72.4k | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1537 | 28.6k | #endif | 1538 | 28.6k | { | 1539 | 28.6k | bfd_set_error (bfd_error_wrong_format); | 1540 | 28.6k | return NULL; | 1541 | 28.6k | } | 1542 | 43.7k | #endif | 1543 | | | 1544 | 43.7k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1545 | 43.7k | || a->SectionAlignment >= 0x80000000) | 1546 | 28.8k | { | 1547 | 28.8k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1548 | 28.8k | abfd); | 1549 | 28.8k | a->SectionAlignment &= -a->SectionAlignment; | 1550 | 28.8k | if (a->SectionAlignment >= 0x80000000) | 1551 | 588 | a->SectionAlignment = 0x40000000; | 1552 | 28.8k | } | 1553 | | | 1554 | 43.7k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1555 | 43.7k | || a->FileAlignment > a->SectionAlignment) | 1556 | 30.5k | { | 1557 | 30.5k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1558 | 30.5k | abfd); | 1559 | 30.5k | a->FileAlignment &= -a->FileAlignment; | 1560 | 30.5k | if (a->FileAlignment > a->SectionAlignment) | 1561 | 16.6k | a->FileAlignment = a->SectionAlignment; | 1562 | 30.5k | } | 1563 | | | 1564 | 43.7k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1565 | 27.6k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1566 | 43.7k | } | 1567 | | | 1568 | 81.9k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1569 | 81.9k | (opt_hdr_size != 0 | 1570 | 81.9k | ? &internal_a | 1571 | 81.9k | : (struct internal_aouthdr *) NULL)); | 1572 | | | 1573 | 81.9k | if (result) | 1574 | 26.2k | { | 1575 | | /* Now the whole header has been processed, see if there is a build-id */ | 1576 | 26.2k | pe_bfd_read_buildid(abfd); | 1577 | 26.2k | } | 1578 | | | 1579 | 81.9k | return result; | 1580 | 112k | } |
pei-mcore.c:pe_bfd_object_p Line | Count | Source | 1430 | 3.31M | { | 1431 | 3.31M | bfd_byte buffer[6]; | 1432 | 3.31M | struct external_DOS_hdr dos_hdr; | 1433 | 3.31M | struct external_PEI_IMAGE_hdr image_hdr; | 1434 | 3.31M | struct internal_filehdr internal_f; | 1435 | 3.31M | struct internal_aouthdr internal_a; | 1436 | 3.31M | bfd_size_type opt_hdr_size; | 1437 | 3.31M | file_ptr offset; | 1438 | 3.31M | bfd_cleanup result; | 1439 | | | 1440 | | /* Detect if this a Microsoft Import Library Format element. */ | 1441 | | /* First read the beginning of the header. */ | 1442 | 3.31M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1443 | 3.31M | || bfd_read (buffer, 6, abfd) != 6) | 1444 | 9.37k | { | 1445 | 9.37k | if (bfd_get_error () != bfd_error_system_call) | 1446 | 8.46k | bfd_set_error (bfd_error_wrong_format); | 1447 | 9.37k | return NULL; | 1448 | 9.37k | } | 1449 | | | 1450 | | /* Then check the magic and the version (only 0 is supported). */ | 1451 | 3.30M | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1452 | 3.30M | && H_GET_16 (abfd, buffer + 4) == 0) | 1453 | 26.9k | return pe_ILF_object_p (abfd); | 1454 | | | 1455 | 3.28M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1456 | 3.28M | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1457 | 609k | { | 1458 | 609k | if (bfd_get_error () != bfd_error_system_call) | 1459 | 609k | bfd_set_error (bfd_error_wrong_format); | 1460 | 609k | return NULL; | 1461 | 609k | } | 1462 | | | 1463 | | /* There are really two magic numbers involved; the magic number | 1464 | | that says this is a NT executable (PEI) and the magic number that | 1465 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1466 | | the e_magic field. The latter is stored in the f_magic field. | 1467 | | If the NT magic number isn't valid, the architecture magic number | 1468 | | could be mimicked by some other field (specifically, the number | 1469 | | of relocs in section 3). Since this routine can only be called | 1470 | | correctly for a PEI file, check the e_magic number here, and, if | 1471 | | it doesn't match, clobber the f_magic number so that we don't get | 1472 | | a false match. */ | 1473 | 2.67M | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1474 | 2.09M | { | 1475 | 2.09M | bfd_set_error (bfd_error_wrong_format); | 1476 | 2.09M | return NULL; | 1477 | 2.09M | } | 1478 | | | 1479 | 581k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1480 | 581k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1481 | 581k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1482 | 4.52k | { | 1483 | 4.52k | if (bfd_get_error () != bfd_error_system_call) | 1484 | 4.52k | bfd_set_error (bfd_error_wrong_format); | 1485 | 4.52k | return NULL; | 1486 | 4.52k | } | 1487 | | | 1488 | 576k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1489 | 15.2k | { | 1490 | 15.2k | bfd_set_error (bfd_error_wrong_format); | 1491 | 15.2k | return NULL; | 1492 | 15.2k | } | 1493 | | | 1494 | | /* Swap file header, so that we get the location for calling | 1495 | | real_object_p. */ | 1496 | 561k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1497 | | | 1498 | 561k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1499 | 561k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1500 | 490k | { | 1501 | 490k | bfd_set_error (bfd_error_wrong_format); | 1502 | 490k | return NULL; | 1503 | 490k | } | 1504 | | | 1505 | 70.6k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1506 | 70.6k | sizeof (internal_f.pe.dos_message)); | 1507 | | | 1508 | | /* Read the optional header, which has variable size. */ | 1509 | 70.6k | opt_hdr_size = internal_f.f_opthdr; | 1510 | | | 1511 | 70.6k | if (opt_hdr_size != 0) | 1512 | 52.3k | { | 1513 | 52.3k | bfd_size_type amt = opt_hdr_size; | 1514 | 52.3k | bfd_byte * opthdr; | 1515 | | | 1516 | | /* PR 17521 file: 230-131433-0.004. */ | 1517 | 52.3k | if (amt < sizeof (PEAOUTHDR)) | 1518 | 36.8k | amt = sizeof (PEAOUTHDR); | 1519 | | | 1520 | 52.3k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1521 | 52.3k | if (opthdr == NULL) | 1522 | 2.50k | return NULL; | 1523 | 49.8k | if (amt > opt_hdr_size) | 1524 | 35.4k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1525 | | | 1526 | 49.8k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1527 | | | 1528 | 49.8k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1529 | | | 1530 | | #ifdef ARM | 1531 | | /* Use Subsystem to distinguish between pei-arm-little and | 1532 | | pei-arm-wince-little. */ | 1533 | | #ifdef WINCE | 1534 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1535 | | #else | 1536 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1537 | | #endif | 1538 | | { | 1539 | | bfd_set_error (bfd_error_wrong_format); | 1540 | | return NULL; | 1541 | | } | 1542 | | #endif | 1543 | | | 1544 | 49.8k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1545 | 49.8k | || a->SectionAlignment >= 0x80000000) | 1546 | 29.0k | { | 1547 | 29.0k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1548 | 29.0k | abfd); | 1549 | 29.0k | a->SectionAlignment &= -a->SectionAlignment; | 1550 | 29.0k | if (a->SectionAlignment >= 0x80000000) | 1551 | 1.20k | a->SectionAlignment = 0x40000000; | 1552 | 29.0k | } | 1553 | | | 1554 | 49.8k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1555 | 49.8k | || a->FileAlignment > a->SectionAlignment) | 1556 | 39.2k | { | 1557 | 39.2k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1558 | 39.2k | abfd); | 1559 | 39.2k | a->FileAlignment &= -a->FileAlignment; | 1560 | 39.2k | if (a->FileAlignment > a->SectionAlignment) | 1561 | 15.7k | a->FileAlignment = a->SectionAlignment; | 1562 | 39.2k | } | 1563 | | | 1564 | 49.8k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1565 | 39.8k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1566 | 49.8k | } | 1567 | | | 1568 | 68.1k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1569 | 68.1k | (opt_hdr_size != 0 | 1570 | 68.1k | ? &internal_a | 1571 | 68.1k | : (struct internal_aouthdr *) NULL)); | 1572 | | | 1573 | 68.1k | if (result) | 1574 | 39.2k | { | 1575 | | /* Now the whole header has been processed, see if there is a build-id */ | 1576 | 39.2k | pe_bfd_read_buildid(abfd); | 1577 | 39.2k | } | 1578 | | | 1579 | 68.1k | return result; | 1580 | 70.6k | } |
Line | Count | Source | 1430 | 1.65M | { | 1431 | 1.65M | bfd_byte buffer[6]; | 1432 | 1.65M | struct external_DOS_hdr dos_hdr; | 1433 | 1.65M | struct external_PEI_IMAGE_hdr image_hdr; | 1434 | 1.65M | struct internal_filehdr internal_f; | 1435 | 1.65M | struct internal_aouthdr internal_a; | 1436 | 1.65M | bfd_size_type opt_hdr_size; | 1437 | 1.65M | file_ptr offset; | 1438 | 1.65M | bfd_cleanup result; | 1439 | | | 1440 | | /* Detect if this a Microsoft Import Library Format element. */ | 1441 | | /* First read the beginning of the header. */ | 1442 | 1.65M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1443 | 1.65M | || bfd_read (buffer, 6, abfd) != 6) | 1444 | 4.68k | { | 1445 | 4.68k | if (bfd_get_error () != bfd_error_system_call) | 1446 | 4.23k | bfd_set_error (bfd_error_wrong_format); | 1447 | 4.68k | return NULL; | 1448 | 4.68k | } | 1449 | | | 1450 | | /* Then check the magic and the version (only 0 is supported). */ | 1451 | 1.65M | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1452 | 1.65M | && H_GET_16 (abfd, buffer + 4) == 0) | 1453 | 26.7k | return pe_ILF_object_p (abfd); | 1454 | | | 1455 | 1.62M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1456 | 1.62M | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1457 | 294k | { | 1458 | 294k | if (bfd_get_error () != bfd_error_system_call) | 1459 | 294k | bfd_set_error (bfd_error_wrong_format); | 1460 | 294k | return NULL; | 1461 | 294k | } | 1462 | | | 1463 | | /* There are really two magic numbers involved; the magic number | 1464 | | that says this is a NT executable (PEI) and the magic number that | 1465 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1466 | | the e_magic field. The latter is stored in the f_magic field. | 1467 | | If the NT magic number isn't valid, the architecture magic number | 1468 | | could be mimicked by some other field (specifically, the number | 1469 | | of relocs in section 3). Since this routine can only be called | 1470 | | correctly for a PEI file, check the e_magic number here, and, if | 1471 | | it doesn't match, clobber the f_magic number so that we don't get | 1472 | | a false match. */ | 1473 | 1.33M | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1474 | 753k | { | 1475 | 753k | bfd_set_error (bfd_error_wrong_format); | 1476 | 753k | return NULL; | 1477 | 753k | } | 1478 | | | 1479 | 580k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1480 | 580k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1481 | 580k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1482 | 4.52k | { | 1483 | 4.52k | if (bfd_get_error () != bfd_error_system_call) | 1484 | 4.52k | bfd_set_error (bfd_error_wrong_format); | 1485 | 4.52k | return NULL; | 1486 | 4.52k | } | 1487 | | | 1488 | 575k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1489 | 15.2k | { | 1490 | 15.2k | bfd_set_error (bfd_error_wrong_format); | 1491 | 15.2k | return NULL; | 1492 | 15.2k | } | 1493 | | | 1494 | | /* Swap file header, so that we get the location for calling | 1495 | | real_object_p. */ | 1496 | 560k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1497 | | | 1498 | 560k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1499 | 560k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1500 | 499k | { | 1501 | 499k | bfd_set_error (bfd_error_wrong_format); | 1502 | 499k | return NULL; | 1503 | 499k | } | 1504 | | | 1505 | 61.0k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1506 | 61.0k | sizeof (internal_f.pe.dos_message)); | 1507 | | | 1508 | | /* Read the optional header, which has variable size. */ | 1509 | 61.0k | opt_hdr_size = internal_f.f_opthdr; | 1510 | | | 1511 | 61.0k | if (opt_hdr_size != 0) | 1512 | 39.3k | { | 1513 | 39.3k | bfd_size_type amt = opt_hdr_size; | 1514 | 39.3k | bfd_byte * opthdr; | 1515 | | | 1516 | | /* PR 17521 file: 230-131433-0.004. */ | 1517 | 39.3k | if (amt < sizeof (PEAOUTHDR)) | 1518 | 26.9k | amt = sizeof (PEAOUTHDR); | 1519 | | | 1520 | 39.3k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1521 | 39.3k | if (opthdr == NULL) | 1522 | 2.15k | return NULL; | 1523 | 37.1k | if (amt > opt_hdr_size) | 1524 | 26.8k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1525 | | | 1526 | 37.1k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1527 | | | 1528 | 37.1k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1529 | | | 1530 | | #ifdef ARM | 1531 | | /* Use Subsystem to distinguish between pei-arm-little and | 1532 | | pei-arm-wince-little. */ | 1533 | | #ifdef WINCE | 1534 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1535 | | #else | 1536 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1537 | | #endif | 1538 | | { | 1539 | | bfd_set_error (bfd_error_wrong_format); | 1540 | | return NULL; | 1541 | | } | 1542 | | #endif | 1543 | | | 1544 | 37.1k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1545 | 37.1k | || a->SectionAlignment >= 0x80000000) | 1546 | 18.0k | { | 1547 | 18.0k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1548 | 18.0k | abfd); | 1549 | 18.0k | a->SectionAlignment &= -a->SectionAlignment; | 1550 | 18.0k | if (a->SectionAlignment >= 0x80000000) | 1551 | 691 | a->SectionAlignment = 0x40000000; | 1552 | 18.0k | } | 1553 | | | 1554 | 37.1k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1555 | 37.1k | || a->FileAlignment > a->SectionAlignment) | 1556 | 29.1k | { | 1557 | 29.1k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1558 | 29.1k | abfd); | 1559 | 29.1k | a->FileAlignment &= -a->FileAlignment; | 1560 | 29.1k | if (a->FileAlignment > a->SectionAlignment) | 1561 | 18.4k | a->FileAlignment = a->SectionAlignment; | 1562 | 29.1k | } | 1563 | | | 1564 | 37.1k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1565 | 24.9k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1566 | 37.1k | } | 1567 | | | 1568 | 58.8k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1569 | 58.8k | (opt_hdr_size != 0 | 1570 | 58.8k | ? &internal_a | 1571 | 58.8k | : (struct internal_aouthdr *) NULL)); | 1572 | | | 1573 | 58.8k | if (result) | 1574 | 31.8k | { | 1575 | | /* Now the whole header has been processed, see if there is a build-id */ | 1576 | 31.8k | pe_bfd_read_buildid(abfd); | 1577 | 31.8k | } | 1578 | | | 1579 | 58.8k | return result; | 1580 | 61.0k | } |
|
1581 | | |
1582 | 546k | #define coff_object_p pe_bfd_object_p |
1583 | | #endif /* COFF_IMAGE_WITH_PE */ |