/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 | 40.1k | { |
132 | 40.1k | RELOC *reloc_src = (RELOC *) src; |
133 | 40.1k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; |
134 | | |
135 | 40.1k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); |
136 | 40.1k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); |
137 | 40.1k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); |
138 | | #ifdef SWAP_IN_RELOC_OFFSET |
139 | 18.2k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); |
140 | | #endif |
141 | 40.1k | } pei-i386.c:coff_swap_reloc_in Line | Count | Source | 131 | 2.97k | { | 132 | 2.97k | RELOC *reloc_src = (RELOC *) src; | 133 | 2.97k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 2.97k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 2.97k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 2.97k | 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 | 2.97k | } |
pe-x86_64.c:coff_swap_reloc_in Line | Count | Source | 131 | 4.71k | { | 132 | 4.71k | RELOC *reloc_src = (RELOC *) src; | 133 | 4.71k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 4.71k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 4.71k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 4.71k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | | #ifdef SWAP_IN_RELOC_OFFSET | 139 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | | #endif | 141 | 4.71k | } |
pei-x86_64.c:coff_swap_reloc_in Line | Count | Source | 131 | 2.84k | { | 132 | 2.84k | RELOC *reloc_src = (RELOC *) src; | 133 | 2.84k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 2.84k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 2.84k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 2.84k | 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 | 2.84k | } |
pei-aarch64.c:coff_swap_reloc_in Line | Count | Source | 131 | 2.98k | { | 132 | 2.98k | RELOC *reloc_src = (RELOC *) src; | 133 | 2.98k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 2.98k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 2.98k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 2.98k | 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 | 2.98k | } |
pe-aarch64.c:coff_swap_reloc_in Line | Count | Source | 131 | 1.04k | { | 132 | 1.04k | RELOC *reloc_src = (RELOC *) src; | 133 | 1.04k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 1.04k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 1.04k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 1.04k | 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 | 1.04k | } |
pei-ia64.c:coff_swap_reloc_in Line | Count | Source | 131 | 2.24k | { | 132 | 2.24k | RELOC *reloc_src = (RELOC *) src; | 133 | 2.24k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 2.24k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 2.24k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 2.24k | 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 | 2.24k | } |
pei-loongarch64.c:coff_swap_reloc_in Line | Count | Source | 131 | 1.90k | { | 132 | 1.90k | RELOC *reloc_src = (RELOC *) src; | 133 | 1.90k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 1.90k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 1.90k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 1.90k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 1.90k | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 1.90k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 1.90k | #endif | 141 | 1.90k | } |
pe-arm-wince.c:coff_swap_reloc_in Line | Count | Source | 131 | 935 | { | 132 | 935 | RELOC *reloc_src = (RELOC *) src; | 133 | 935 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 935 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 935 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 935 | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 935 | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 935 | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 935 | #endif | 141 | 935 | } |
pe-arm.c:coff_swap_reloc_in Line | Count | Source | 131 | 935 | { | 132 | 935 | RELOC *reloc_src = (RELOC *) src; | 133 | 935 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 935 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 935 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 935 | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 935 | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 935 | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 935 | #endif | 141 | 935 | } |
pe-i386.c:coff_swap_reloc_in Line | Count | Source | 131 | 1.53k | { | 132 | 1.53k | RELOC *reloc_src = (RELOC *) src; | 133 | 1.53k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 1.53k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 1.53k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 1.53k | 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 | 1.53k | } |
pe-mcore.c:coff_swap_reloc_in Line | Count | Source | 131 | 1.66k | { | 132 | 1.66k | RELOC *reloc_src = (RELOC *) src; | 133 | 1.66k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 1.66k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 1.66k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 1.66k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 1.66k | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 1.66k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 1.66k | #endif | 141 | 1.66k | } |
pe-sh.c:coff_swap_reloc_in Line | Count | Source | 131 | 1.59k | { | 132 | 1.59k | RELOC *reloc_src = (RELOC *) src; | 133 | 1.59k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 1.59k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 1.59k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 1.59k | 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 | 1.59k | } |
pei-arm-wince.c:coff_swap_reloc_in Line | Count | Source | 131 | 3.88k | { | 132 | 3.88k | RELOC *reloc_src = (RELOC *) src; | 133 | 3.88k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 3.88k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 3.88k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 3.88k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 3.88k | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 3.88k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 3.88k | #endif | 141 | 3.88k | } |
pei-arm.c:coff_swap_reloc_in Line | Count | Source | 131 | 4.38k | { | 132 | 4.38k | RELOC *reloc_src = (RELOC *) src; | 133 | 4.38k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 4.38k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 4.38k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 4.38k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 4.38k | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 4.38k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 4.38k | #endif | 141 | 4.38k | } |
pei-mcore.c:coff_swap_reloc_in Line | Count | Source | 131 | 4.57k | { | 132 | 4.57k | RELOC *reloc_src = (RELOC *) src; | 133 | 4.57k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 4.57k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 4.57k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 4.57k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 4.57k | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 4.57k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 4.57k | #endif | 141 | 4.57k | } |
pei-sh.c:coff_swap_reloc_in Line | Count | Source | 131 | 1.94k | { | 132 | 1.94k | RELOC *reloc_src = (RELOC *) src; | 133 | 1.94k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 1.94k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 1.94k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 1.94k | 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 | 1.94k | } |
|
142 | | |
143 | | static unsigned int |
144 | | coff_swap_reloc_out (bfd * abfd, void * src, void * dst) |
145 | 0 | { |
146 | 0 | struct internal_reloc *reloc_src = (struct internal_reloc *) src; |
147 | 0 | struct external_reloc *reloc_dst = (struct external_reloc *) dst; |
148 | |
|
149 | 0 | H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr); |
150 | 0 | H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx); |
151 | 0 | H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type); |
152 | |
|
153 | | #ifdef SWAP_OUT_RELOC_OFFSET |
154 | 0 | SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset); |
155 | | #endif |
156 | | #ifdef SWAP_OUT_RELOC_EXTRA |
157 | | SWAP_OUT_RELOC_EXTRA (abfd, reloc_src, reloc_dst); |
158 | | #endif |
159 | 0 | return RELSZ; |
160 | 0 | } Unexecuted instantiation: pei-i386.c:coff_swap_reloc_out Unexecuted instantiation: pe-x86_64.c:coff_swap_reloc_out Unexecuted instantiation: pei-x86_64.c:coff_swap_reloc_out Unexecuted instantiation: pei-aarch64.c:coff_swap_reloc_out Unexecuted instantiation: pe-aarch64.c:coff_swap_reloc_out Unexecuted instantiation: pei-ia64.c:coff_swap_reloc_out Unexecuted instantiation: pei-loongarch64.c:coff_swap_reloc_out Unexecuted instantiation: pe-arm-wince.c:coff_swap_reloc_out Unexecuted instantiation: pe-arm.c:coff_swap_reloc_out Unexecuted instantiation: pe-i386.c:coff_swap_reloc_out Unexecuted instantiation: pe-mcore.c:coff_swap_reloc_out Unexecuted instantiation: pe-sh.c:coff_swap_reloc_out Unexecuted instantiation: pei-arm-wince.c:coff_swap_reloc_out Unexecuted instantiation: pei-arm.c:coff_swap_reloc_out Unexecuted instantiation: pei-mcore.c:coff_swap_reloc_out Unexecuted instantiation: pei-sh.c:coff_swap_reloc_out |
161 | | #endif /* not NO_COFF_RELOCS */ |
162 | | |
163 | | #ifdef COFF_IMAGE_WITH_PE |
164 | | #undef FILHDR |
165 | 1.62M | #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 | 6.78M | { |
171 | 6.78M | FILHDR *filehdr_src = (FILHDR *) src; |
172 | 6.78M | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; |
173 | | |
174 | 6.78M | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); |
175 | 6.78M | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); |
176 | 6.78M | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); |
177 | 6.78M | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); |
178 | 6.78M | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); |
179 | 6.78M | 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 | 6.78M | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) |
184 | 705k | { |
185 | 705k | filehdr_dst->f_nsyms = 0; |
186 | 705k | filehdr_dst->f_flags |= F_LSYMS; |
187 | 705k | } |
188 | | |
189 | 6.78M | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); |
190 | 6.78M | } pei-i386.c:coff_swap_filehdr_in Line | Count | Source | 170 | 183k | { | 171 | 183k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 183k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 183k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 183k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 183k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 183k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 183k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 183k | 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 | 183k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 8.50k | { | 185 | 8.50k | filehdr_dst->f_nsyms = 0; | 186 | 8.50k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 8.50k | } | 188 | | | 189 | 183k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 183k | } |
pe-x86_64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 522k | { | 171 | 522k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 522k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 522k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 522k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 522k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 522k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 522k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 522k | 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 | 522k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 63.2k | { | 185 | 63.2k | filehdr_dst->f_nsyms = 0; | 186 | 63.2k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 63.2k | } | 188 | | | 189 | 522k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 522k | } |
pei-x86_64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 186k | { | 171 | 186k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 186k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 186k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 186k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 186k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 186k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 186k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 186k | 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 | 186k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 8.23k | { | 185 | 8.23k | filehdr_dst->f_nsyms = 0; | 186 | 8.23k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 8.23k | } | 188 | | | 189 | 186k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 186k | } |
pei-aarch64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 179k | { | 171 | 179k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 179k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 179k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 179k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 179k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 179k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 179k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 179k | 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 | 179k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 8.23k | { | 185 | 8.23k | filehdr_dst->f_nsyms = 0; | 186 | 8.23k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 8.23k | } | 188 | | | 189 | 179k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 179k | } |
pe-aarch64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 514k | { | 171 | 514k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 514k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 514k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 514k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 514k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 514k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 514k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 514k | 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 | 514k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 63.3k | { | 185 | 63.3k | filehdr_dst->f_nsyms = 0; | 186 | 63.3k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 63.3k | } | 188 | | | 189 | 514k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 514k | } |
pei-ia64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 179k | { | 171 | 179k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 179k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 179k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 179k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 179k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 179k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 179k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 179k | 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 | 179k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 8.24k | { | 185 | 8.24k | filehdr_dst->f_nsyms = 0; | 186 | 8.24k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 8.24k | } | 188 | | | 189 | 179k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 179k | } |
pei-loongarch64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 179k | { | 171 | 179k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 179k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 179k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 179k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 179k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 179k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 179k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 179k | 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 | 179k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 8.23k | { | 185 | 8.23k | filehdr_dst->f_nsyms = 0; | 186 | 8.23k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 8.23k | } | 188 | | | 189 | 179k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 179k | } |
pe-arm-wince.c:coff_swap_filehdr_in Line | Count | Source | 170 | 1.02M | { | 171 | 1.02M | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 1.02M | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 1.02M | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 1.02M | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 1.02M | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 1.02M | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 1.02M | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 1.02M | 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.02M | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 126k | { | 185 | 126k | filehdr_dst->f_nsyms = 0; | 186 | 126k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 126k | } | 188 | | | 189 | 1.02M | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 1.02M | } |
pe-arm.c:coff_swap_filehdr_in Line | Count | Source | 170 | 1.02M | { | 171 | 1.02M | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 1.02M | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 1.02M | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 1.02M | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 1.02M | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 1.02M | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 1.02M | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 1.02M | 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.02M | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 126k | { | 185 | 126k | filehdr_dst->f_nsyms = 0; | 186 | 126k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 126k | } | 188 | | | 189 | 1.02M | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 1.02M | } |
pe-i386.c:coff_swap_filehdr_in Line | Count | Source | 170 | 514k | { | 171 | 514k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 514k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 514k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 514k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 514k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 514k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 514k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 514k | 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 | 514k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 63.0k | { | 185 | 63.0k | filehdr_dst->f_nsyms = 0; | 186 | 63.0k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 63.0k | } | 188 | | | 189 | 514k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 514k | } |
pe-mcore.c:coff_swap_filehdr_in Line | Count | Source | 170 | 1.02M | { | 171 | 1.02M | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 1.02M | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 1.02M | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 1.02M | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 1.02M | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 1.02M | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 1.02M | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 1.02M | 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.02M | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 126k | { | 185 | 126k | filehdr_dst->f_nsyms = 0; | 186 | 126k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 126k | } | 188 | | | 189 | 1.02M | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 1.02M | } |
pe-sh.c:coff_swap_filehdr_in Line | Count | Source | 170 | 514k | { | 171 | 514k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 514k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 514k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 514k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 514k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 514k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 514k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 514k | 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 | 514k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 63.0k | { | 185 | 63.0k | filehdr_dst->f_nsyms = 0; | 186 | 63.0k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 63.0k | } | 188 | | | 189 | 514k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 514k | } |
pei-arm-wince.c:coff_swap_filehdr_in Line | Count | Source | 170 | 179k | { | 171 | 179k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 179k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 179k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 179k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 179k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 179k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 179k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 179k | 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 | 179k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 8.23k | { | 185 | 8.23k | filehdr_dst->f_nsyms = 0; | 186 | 8.23k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 8.23k | } | 188 | | | 189 | 179k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 179k | } |
pei-arm.c:coff_swap_filehdr_in Line | Count | Source | 170 | 179k | { | 171 | 179k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 179k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 179k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 179k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 179k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 179k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 179k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 179k | 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 | 179k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 8.23k | { | 185 | 8.23k | filehdr_dst->f_nsyms = 0; | 186 | 8.23k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 8.23k | } | 188 | | | 189 | 179k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 179k | } |
pei-mcore.c:coff_swap_filehdr_in Line | Count | Source | 170 | 179k | { | 171 | 179k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 179k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 179k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 179k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 179k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 179k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 179k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 179k | 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 | 179k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 8.23k | { | 185 | 8.23k | filehdr_dst->f_nsyms = 0; | 186 | 8.23k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 8.23k | } | 188 | | | 189 | 179k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 179k | } |
pei-sh.c:coff_swap_filehdr_in Line | Count | Source | 170 | 179k | { | 171 | 179k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 179k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 179k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 179k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 179k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 179k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 179k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 179k | 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 | 179k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 8.23k | { | 185 | 8.23k | filehdr_dst->f_nsyms = 0; | 186 | 8.23k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 8.23k | } | 188 | | | 189 | 179k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 179k | } |
|
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 | 662k | { |
207 | 662k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; |
208 | 662k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; |
209 | | |
210 | 662k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); |
211 | | |
212 | 662k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); |
213 | 662k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); |
214 | 662k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); |
215 | 662k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); |
216 | 662k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); |
217 | 662k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); |
218 | 662k | 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 | 442k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) |
225 | 442k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); |
226 | | scnhdr_int->s_nreloc = 0; |
227 | | #else |
228 | 219k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); |
229 | 219k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); |
230 | | #endif |
231 | | |
232 | 662k | if (scnhdr_int->s_vaddr != 0) |
233 | 474k | { |
234 | 474k | 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 | 474k | } |
240 | | |
241 | 662k | #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 | 662k | if (scnhdr_int->s_paddr > 0 |
247 | 662k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 |
248 | 476k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) |
249 | 476k | || (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 | 157k | scnhdr_int->s_size = scnhdr_int->s_paddr; |
255 | 662k | #endif |
256 | 662k | } pei-i386.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 49.3k | { | 207 | 49.3k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 49.3k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 49.3k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 49.3k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 49.3k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 49.3k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 49.3k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 49.3k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 49.3k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 49.3k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 49.3k | #ifdef COFF_IMAGE_WITH_PE | 224 | 49.3k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 49.3k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 49.3k | 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 | 49.3k | if (scnhdr_int->s_vaddr != 0) | 233 | 32.5k | { | 234 | 32.5k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 32.5k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 32.5k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 32.5k | #endif | 239 | 32.5k | } | 240 | | | 241 | 49.3k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 49.3k | if (scnhdr_int->s_paddr > 0 | 247 | 49.3k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 34.8k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 34.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 | 14.0k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 49.3k | #endif | 256 | 49.3k | } |
pe-x86_64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 91.9k | { | 207 | 91.9k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 91.9k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 91.9k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 91.9k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 91.9k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 91.9k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 91.9k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 91.9k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 91.9k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 91.9k | 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 | 91.9k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 91.9k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 91.9k | #endif | 231 | | | 232 | 91.9k | if (scnhdr_int->s_vaddr != 0) | 233 | 72.9k | { | 234 | 72.9k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | | #endif | 239 | 72.9k | } | 240 | | | 241 | 91.9k | #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 | 91.9k | if (scnhdr_int->s_paddr > 0 | 247 | 91.9k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 65.8k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 65.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 | 9.35k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 91.9k | #endif | 256 | 91.9k | } |
pei-x86_64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 73.2k | { | 207 | 73.2k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 73.2k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 73.2k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 73.2k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 73.2k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 73.2k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 73.2k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 73.2k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 73.2k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 73.2k | 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 | 73.2k | #ifdef COFF_IMAGE_WITH_PE | 224 | 73.2k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 73.2k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 73.2k | 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 | 73.2k | if (scnhdr_int->s_vaddr != 0) | 233 | 48.9k | { | 234 | 48.9k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | | #endif | 239 | 48.9k | } | 240 | | | 241 | 73.2k | #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 | 73.2k | if (scnhdr_int->s_paddr > 0 | 247 | 73.2k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 46.9k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 46.9k | || (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.2k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 73.2k | #endif | 256 | 73.2k | } |
pei-aarch64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 47.4k | { | 207 | 47.4k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 47.4k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 47.4k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 47.4k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 47.4k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 47.4k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 47.4k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 47.4k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 47.4k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 47.4k | 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 | 47.4k | #ifdef COFF_IMAGE_WITH_PE | 224 | 47.4k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 47.4k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 47.4k | 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 | 47.4k | if (scnhdr_int->s_vaddr != 0) | 233 | 39.6k | { | 234 | 39.6k | 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 | 39.6k | } | 240 | | | 241 | 47.4k | #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 | 47.4k | if (scnhdr_int->s_paddr > 0 | 247 | 47.4k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 38.2k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 38.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 | 11.9k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 47.4k | #endif | 256 | 47.4k | } |
pe-aarch64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 36.8k | { | 207 | 36.8k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 36.8k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 36.8k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 36.8k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 36.8k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 36.8k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 36.8k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 36.8k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 36.8k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 36.8k | 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 | 36.8k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 36.8k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 36.8k | #endif | 231 | | | 232 | 36.8k | if (scnhdr_int->s_vaddr != 0) | 233 | 25.1k | { | 234 | 25.1k | 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 | 25.1k | } | 240 | | | 241 | 36.8k | #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 | 36.8k | if (scnhdr_int->s_paddr > 0 | 247 | 36.8k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 26.3k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 26.3k | || (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 | 15.4k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 36.8k | #endif | 256 | 36.8k | } |
pei-ia64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 40.5k | { | 207 | 40.5k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 40.5k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 40.5k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 40.5k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 40.5k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 40.5k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 40.5k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 40.5k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 40.5k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 40.5k | 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 | 40.5k | #ifdef COFF_IMAGE_WITH_PE | 224 | 40.5k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 40.5k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 40.5k | 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 | 40.5k | if (scnhdr_int->s_vaddr != 0) | 233 | 31.3k | { | 234 | 31.3k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 31.3k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 31.3k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 31.3k | #endif | 239 | 31.3k | } | 240 | | | 241 | 40.5k | #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.5k | if (scnhdr_int->s_paddr > 0 | 247 | 40.5k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 31.3k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 31.3k | || (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.6k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 40.5k | #endif | 256 | 40.5k | } |
pei-loongarch64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 32.0k | { | 207 | 32.0k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 32.0k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 32.0k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 32.0k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 32.0k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 32.0k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 32.0k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 32.0k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 32.0k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 32.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 | 32.0k | #ifdef COFF_IMAGE_WITH_PE | 224 | 32.0k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 32.0k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 32.0k | 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 | 32.0k | if (scnhdr_int->s_vaddr != 0) | 233 | 22.9k | { | 234 | 22.9k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | | #endif | 239 | 22.9k | } | 240 | | | 241 | 32.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 | 32.0k | if (scnhdr_int->s_paddr > 0 | 247 | 32.0k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 23.3k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 23.3k | || (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 | 8.57k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 32.0k | #endif | 256 | 32.0k | } |
pe-arm-wince.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 9.74k | { | 207 | 9.74k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 9.74k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 9.74k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 9.74k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 9.74k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 9.74k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 9.74k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 9.74k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 9.74k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 9.74k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | | #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 | 9.74k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 9.74k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 9.74k | #endif | 231 | | | 232 | 9.74k | if (scnhdr_int->s_vaddr != 0) | 233 | 7.35k | { | 234 | 7.35k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 7.35k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 7.35k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 7.35k | #endif | 239 | 7.35k | } | 240 | | | 241 | 9.74k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 9.74k | if (scnhdr_int->s_paddr > 0 | 247 | 9.74k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 7.39k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 7.39k | || (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 | 769 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 9.74k | #endif | 256 | 9.74k | } |
pe-arm.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 9.74k | { | 207 | 9.74k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 9.74k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 9.74k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 9.74k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 9.74k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 9.74k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 9.74k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 9.74k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 9.74k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 9.74k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | | #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 | 9.74k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 9.74k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 9.74k | #endif | 231 | | | 232 | 9.74k | if (scnhdr_int->s_vaddr != 0) | 233 | 7.35k | { | 234 | 7.35k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 7.35k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 7.35k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 7.35k | #endif | 239 | 7.35k | } | 240 | | | 241 | 9.74k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 9.74k | if (scnhdr_int->s_paddr > 0 | 247 | 9.74k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 7.39k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 7.39k | || (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 | 769 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 9.74k | #endif | 256 | 9.74k | } |
pe-i386.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 24.5k | { | 207 | 24.5k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 24.5k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 24.5k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 24.5k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 24.5k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 24.5k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 24.5k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 24.5k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 24.5k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 24.5k | 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 | 24.5k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 24.5k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 24.5k | #endif | 231 | | | 232 | 24.5k | if (scnhdr_int->s_vaddr != 0) | 233 | 18.9k | { | 234 | 18.9k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 18.9k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 18.9k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 18.9k | #endif | 239 | 18.9k | } | 240 | | | 241 | 24.5k | #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 | 24.5k | if (scnhdr_int->s_paddr > 0 | 247 | 24.5k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 19.2k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 19.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 | 1.97k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 24.5k | #endif | 256 | 24.5k | } |
pe-mcore.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 23.4k | { | 207 | 23.4k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 23.4k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 23.4k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 23.4k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 23.4k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 23.4k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 23.4k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 23.4k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 23.4k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 23.4k | 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 | 23.4k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 23.4k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 23.4k | #endif | 231 | | | 232 | 23.4k | if (scnhdr_int->s_vaddr != 0) | 233 | 18.5k | { | 234 | 18.5k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 18.5k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 18.5k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 18.5k | #endif | 239 | 18.5k | } | 240 | | | 241 | 23.4k | #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 | 23.4k | if (scnhdr_int->s_paddr > 0 | 247 | 23.4k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 16.9k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 16.9k | || (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 | 4.67k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 23.4k | #endif | 256 | 23.4k | } |
pe-sh.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 23.5k | { | 207 | 23.5k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 23.5k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 23.5k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 23.5k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 23.5k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 23.5k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 23.5k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 23.5k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 23.5k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 23.5k | 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 | 23.5k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 23.5k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 23.5k | #endif | 231 | | | 232 | 23.5k | if (scnhdr_int->s_vaddr != 0) | 233 | 13.8k | { | 234 | 13.8k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 13.8k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 13.8k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 13.8k | #endif | 239 | 13.8k | } | 240 | | | 241 | 23.5k | #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 | 23.5k | if (scnhdr_int->s_paddr > 0 | 247 | 23.5k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 14.5k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 14.5k | || (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 | 1.08k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 23.5k | #endif | 256 | 23.5k | } |
pei-arm-wince.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 38.0k | { | 207 | 38.0k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 38.0k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 38.0k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 38.0k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 38.0k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 38.0k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 38.0k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 38.0k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 38.0k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 38.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 | 38.0k | #ifdef COFF_IMAGE_WITH_PE | 224 | 38.0k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 38.0k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 38.0k | 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 | 38.0k | 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 | 38.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 | 38.0k | if (scnhdr_int->s_paddr > 0 | 247 | 38.0k | && (((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 | 13.9k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 38.0k | #endif | 256 | 38.0k | } |
pei-arm.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 54.3k | { | 207 | 54.3k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 54.3k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 54.3k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 54.3k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 54.3k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 54.3k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 54.3k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 54.3k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 54.3k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 54.3k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 54.3k | #ifdef COFF_IMAGE_WITH_PE | 224 | 54.3k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 54.3k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 54.3k | 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 | 54.3k | if (scnhdr_int->s_vaddr != 0) | 233 | 35.8k | { | 234 | 35.8k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 35.8k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 35.8k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 35.8k | #endif | 239 | 35.8k | } | 240 | | | 241 | 54.3k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 54.3k | if (scnhdr_int->s_paddr > 0 | 247 | 54.3k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 37.9k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 37.9k | || (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.3k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 54.3k | #endif | 256 | 54.3k | } |
pei-mcore.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 67.4k | { | 207 | 67.4k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 67.4k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 67.4k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 67.4k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 67.4k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 67.4k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 67.4k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 67.4k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 67.4k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 67.4k | 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 | 67.4k | #ifdef COFF_IMAGE_WITH_PE | 224 | 67.4k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 67.4k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 67.4k | 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 | 67.4k | if (scnhdr_int->s_vaddr != 0) | 233 | 45.4k | { | 234 | 45.4k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 45.4k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 45.4k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 45.4k | #endif | 239 | 45.4k | } | 240 | | | 241 | 67.4k | #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 | 67.4k | if (scnhdr_int->s_paddr > 0 | 247 | 67.4k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 50.8k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 50.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 | 17.8k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 67.4k | #endif | 256 | 67.4k | } |
pei-sh.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 40.0k | { | 207 | 40.0k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 40.0k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 40.0k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 40.0k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 40.0k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 40.0k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 40.0k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 40.0k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 40.0k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 40.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 | 40.0k | #ifdef COFF_IMAGE_WITH_PE | 224 | 40.0k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 40.0k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 40.0k | 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 | 40.0k | if (scnhdr_int->s_vaddr != 0) | 233 | 27.7k | { | 234 | 27.7k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 27.7k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 27.7k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 27.7k | #endif | 239 | 27.7k | } | 240 | | | 241 | 40.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 | 40.0k | if (scnhdr_int->s_paddr > 0 | 247 | 40.0k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 28.7k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 28.7k | || (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 | 40.0k | #endif | 256 | 40.0k | } |
|
257 | | |
258 | | static bool |
259 | | pe_mkobject (bfd * abfd) |
260 | 281k | { |
261 | 281k | pe_data_type *pe; |
262 | 281k | size_t amt = sizeof (pe_data_type); |
263 | | |
264 | 281k | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); |
265 | | |
266 | 281k | if (abfd->tdata.pe_obj_data == 0) |
267 | 0 | return false; |
268 | | |
269 | 281k | pe = pe_data (abfd); |
270 | | |
271 | 281k | pe->coff.pe = 1; |
272 | | |
273 | | /* in_reloc_p is architecture dependent. */ |
274 | 281k | pe->in_reloc_p = in_reloc_p; |
275 | | |
276 | | /* Default DOS message string. */ |
277 | 281k | pe->dos_message[0] = 0x0eba1f0e; |
278 | 281k | pe->dos_message[1] = 0xcd09b400; |
279 | 281k | pe->dos_message[2] = 0x4c01b821; |
280 | 281k | pe->dos_message[3] = 0x685421cd; |
281 | 281k | pe->dos_message[4] = 0x70207369; |
282 | 281k | pe->dos_message[5] = 0x72676f72; |
283 | 281k | pe->dos_message[6] = 0x63206d61; |
284 | 281k | pe->dos_message[7] = 0x6f6e6e61; |
285 | 281k | pe->dos_message[8] = 0x65622074; |
286 | 281k | pe->dos_message[9] = 0x6e757220; |
287 | 281k | pe->dos_message[10] = 0x206e6920; |
288 | 281k | pe->dos_message[11] = 0x20534f44; |
289 | 281k | pe->dos_message[12] = 0x65646f6d; |
290 | 281k | pe->dos_message[13] = 0x0a0d0d2e; |
291 | 281k | pe->dos_message[14] = 0x24; |
292 | 281k | pe->dos_message[15] = 0x0; |
293 | | |
294 | 281k | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); |
295 | | |
296 | 281k | bfd_coff_long_section_names (abfd) |
297 | 281k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; |
298 | | |
299 | 281k | return true; |
300 | 281k | } Line | Count | Source | 260 | 20.6k | { | 261 | 20.6k | pe_data_type *pe; | 262 | 20.6k | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 20.6k | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 20.6k | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 20.6k | pe = pe_data (abfd); | 270 | | | 271 | 20.6k | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 20.6k | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 20.6k | pe->dos_message[0] = 0x0eba1f0e; | 278 | 20.6k | pe->dos_message[1] = 0xcd09b400; | 279 | 20.6k | pe->dos_message[2] = 0x4c01b821; | 280 | 20.6k | pe->dos_message[3] = 0x685421cd; | 281 | 20.6k | pe->dos_message[4] = 0x70207369; | 282 | 20.6k | pe->dos_message[5] = 0x72676f72; | 283 | 20.6k | pe->dos_message[6] = 0x63206d61; | 284 | 20.6k | pe->dos_message[7] = 0x6f6e6e61; | 285 | 20.6k | pe->dos_message[8] = 0x65622074; | 286 | 20.6k | pe->dos_message[9] = 0x6e757220; | 287 | 20.6k | pe->dos_message[10] = 0x206e6920; | 288 | 20.6k | pe->dos_message[11] = 0x20534f44; | 289 | 20.6k | pe->dos_message[12] = 0x65646f6d; | 290 | 20.6k | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 20.6k | pe->dos_message[14] = 0x24; | 292 | 20.6k | pe->dos_message[15] = 0x0; | 293 | | | 294 | 20.6k | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 20.6k | bfd_coff_long_section_names (abfd) | 297 | 20.6k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 20.6k | return true; | 300 | 20.6k | } |
Line | Count | Source | 260 | 37.1k | { | 261 | 37.1k | pe_data_type *pe; | 262 | 37.1k | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 37.1k | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 37.1k | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 37.1k | pe = pe_data (abfd); | 270 | | | 271 | 37.1k | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 37.1k | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 37.1k | pe->dos_message[0] = 0x0eba1f0e; | 278 | 37.1k | pe->dos_message[1] = 0xcd09b400; | 279 | 37.1k | pe->dos_message[2] = 0x4c01b821; | 280 | 37.1k | pe->dos_message[3] = 0x685421cd; | 281 | 37.1k | pe->dos_message[4] = 0x70207369; | 282 | 37.1k | pe->dos_message[5] = 0x72676f72; | 283 | 37.1k | pe->dos_message[6] = 0x63206d61; | 284 | 37.1k | pe->dos_message[7] = 0x6f6e6e61; | 285 | 37.1k | pe->dos_message[8] = 0x65622074; | 286 | 37.1k | pe->dos_message[9] = 0x6e757220; | 287 | 37.1k | pe->dos_message[10] = 0x206e6920; | 288 | 37.1k | pe->dos_message[11] = 0x20534f44; | 289 | 37.1k | pe->dos_message[12] = 0x65646f6d; | 290 | 37.1k | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 37.1k | pe->dos_message[14] = 0x24; | 292 | 37.1k | pe->dos_message[15] = 0x0; | 293 | | | 294 | 37.1k | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 37.1k | bfd_coff_long_section_names (abfd) | 297 | 37.1k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 37.1k | return true; | 300 | 37.1k | } |
Line | Count | Source | 260 | 28.0k | { | 261 | 28.0k | pe_data_type *pe; | 262 | 28.0k | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 28.0k | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 28.0k | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 28.0k | pe = pe_data (abfd); | 270 | | | 271 | 28.0k | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 28.0k | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 28.0k | pe->dos_message[0] = 0x0eba1f0e; | 278 | 28.0k | pe->dos_message[1] = 0xcd09b400; | 279 | 28.0k | pe->dos_message[2] = 0x4c01b821; | 280 | 28.0k | pe->dos_message[3] = 0x685421cd; | 281 | 28.0k | pe->dos_message[4] = 0x70207369; | 282 | 28.0k | pe->dos_message[5] = 0x72676f72; | 283 | 28.0k | pe->dos_message[6] = 0x63206d61; | 284 | 28.0k | pe->dos_message[7] = 0x6f6e6e61; | 285 | 28.0k | pe->dos_message[8] = 0x65622074; | 286 | 28.0k | pe->dos_message[9] = 0x6e757220; | 287 | 28.0k | pe->dos_message[10] = 0x206e6920; | 288 | 28.0k | pe->dos_message[11] = 0x20534f44; | 289 | 28.0k | pe->dos_message[12] = 0x65646f6d; | 290 | 28.0k | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 28.0k | pe->dos_message[14] = 0x24; | 292 | 28.0k | pe->dos_message[15] = 0x0; | 293 | | | 294 | 28.0k | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 28.0k | bfd_coff_long_section_names (abfd) | 297 | 28.0k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 28.0k | return true; | 300 | 28.0k | } |
pei-aarch64.c:pe_mkobject Line | Count | Source | 260 | 23.7k | { | 261 | 23.7k | pe_data_type *pe; | 262 | 23.7k | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 23.7k | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 23.7k | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 23.7k | pe = pe_data (abfd); | 270 | | | 271 | 23.7k | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 23.7k | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 23.7k | pe->dos_message[0] = 0x0eba1f0e; | 278 | 23.7k | pe->dos_message[1] = 0xcd09b400; | 279 | 23.7k | pe->dos_message[2] = 0x4c01b821; | 280 | 23.7k | pe->dos_message[3] = 0x685421cd; | 281 | 23.7k | pe->dos_message[4] = 0x70207369; | 282 | 23.7k | pe->dos_message[5] = 0x72676f72; | 283 | 23.7k | pe->dos_message[6] = 0x63206d61; | 284 | 23.7k | pe->dos_message[7] = 0x6f6e6e61; | 285 | 23.7k | pe->dos_message[8] = 0x65622074; | 286 | 23.7k | pe->dos_message[9] = 0x6e757220; | 287 | 23.7k | pe->dos_message[10] = 0x206e6920; | 288 | 23.7k | pe->dos_message[11] = 0x20534f44; | 289 | 23.7k | pe->dos_message[12] = 0x65646f6d; | 290 | 23.7k | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 23.7k | pe->dos_message[14] = 0x24; | 292 | 23.7k | pe->dos_message[15] = 0x0; | 293 | | | 294 | 23.7k | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 23.7k | bfd_coff_long_section_names (abfd) | 297 | 23.7k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 23.7k | return true; | 300 | 23.7k | } |
Line | Count | Source | 260 | 7.22k | { | 261 | 7.22k | pe_data_type *pe; | 262 | 7.22k | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 7.22k | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 7.22k | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 7.22k | pe = pe_data (abfd); | 270 | | | 271 | 7.22k | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 7.22k | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 7.22k | pe->dos_message[0] = 0x0eba1f0e; | 278 | 7.22k | pe->dos_message[1] = 0xcd09b400; | 279 | 7.22k | pe->dos_message[2] = 0x4c01b821; | 280 | 7.22k | pe->dos_message[3] = 0x685421cd; | 281 | 7.22k | pe->dos_message[4] = 0x70207369; | 282 | 7.22k | pe->dos_message[5] = 0x72676f72; | 283 | 7.22k | pe->dos_message[6] = 0x63206d61; | 284 | 7.22k | pe->dos_message[7] = 0x6f6e6e61; | 285 | 7.22k | pe->dos_message[8] = 0x65622074; | 286 | 7.22k | pe->dos_message[9] = 0x6e757220; | 287 | 7.22k | pe->dos_message[10] = 0x206e6920; | 288 | 7.22k | pe->dos_message[11] = 0x20534f44; | 289 | 7.22k | pe->dos_message[12] = 0x65646f6d; | 290 | 7.22k | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 7.22k | pe->dos_message[14] = 0x24; | 292 | 7.22k | pe->dos_message[15] = 0x0; | 293 | | | 294 | 7.22k | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 7.22k | bfd_coff_long_section_names (abfd) | 297 | 7.22k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 7.22k | return true; | 300 | 7.22k | } |
Line | Count | Source | 260 | 22.5k | { | 261 | 22.5k | pe_data_type *pe; | 262 | 22.5k | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 22.5k | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 22.5k | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 22.5k | pe = pe_data (abfd); | 270 | | | 271 | 22.5k | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 22.5k | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 22.5k | pe->dos_message[0] = 0x0eba1f0e; | 278 | 22.5k | pe->dos_message[1] = 0xcd09b400; | 279 | 22.5k | pe->dos_message[2] = 0x4c01b821; | 280 | 22.5k | pe->dos_message[3] = 0x685421cd; | 281 | 22.5k | pe->dos_message[4] = 0x70207369; | 282 | 22.5k | pe->dos_message[5] = 0x72676f72; | 283 | 22.5k | pe->dos_message[6] = 0x63206d61; | 284 | 22.5k | pe->dos_message[7] = 0x6f6e6e61; | 285 | 22.5k | pe->dos_message[8] = 0x65622074; | 286 | 22.5k | pe->dos_message[9] = 0x6e757220; | 287 | 22.5k | pe->dos_message[10] = 0x206e6920; | 288 | 22.5k | pe->dos_message[11] = 0x20534f44; | 289 | 22.5k | pe->dos_message[12] = 0x65646f6d; | 290 | 22.5k | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 22.5k | pe->dos_message[14] = 0x24; | 292 | 22.5k | pe->dos_message[15] = 0x0; | 293 | | | 294 | 22.5k | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 22.5k | bfd_coff_long_section_names (abfd) | 297 | 22.5k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 22.5k | return true; | 300 | 22.5k | } |
pei-loongarch64.c:pe_mkobject Line | Count | Source | 260 | 19.1k | { | 261 | 19.1k | pe_data_type *pe; | 262 | 19.1k | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 19.1k | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 19.1k | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 19.1k | pe = pe_data (abfd); | 270 | | | 271 | 19.1k | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 19.1k | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 19.1k | pe->dos_message[0] = 0x0eba1f0e; | 278 | 19.1k | pe->dos_message[1] = 0xcd09b400; | 279 | 19.1k | pe->dos_message[2] = 0x4c01b821; | 280 | 19.1k | pe->dos_message[3] = 0x685421cd; | 281 | 19.1k | pe->dos_message[4] = 0x70207369; | 282 | 19.1k | pe->dos_message[5] = 0x72676f72; | 283 | 19.1k | pe->dos_message[6] = 0x63206d61; | 284 | 19.1k | pe->dos_message[7] = 0x6f6e6e61; | 285 | 19.1k | pe->dos_message[8] = 0x65622074; | 286 | 19.1k | pe->dos_message[9] = 0x6e757220; | 287 | 19.1k | pe->dos_message[10] = 0x206e6920; | 288 | 19.1k | pe->dos_message[11] = 0x20534f44; | 289 | 19.1k | pe->dos_message[12] = 0x65646f6d; | 290 | 19.1k | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 19.1k | pe->dos_message[14] = 0x24; | 292 | 19.1k | pe->dos_message[15] = 0x0; | 293 | | | 294 | 19.1k | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 19.1k | bfd_coff_long_section_names (abfd) | 297 | 19.1k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 19.1k | return true; | 300 | 19.1k | } |
pe-arm-wince.c:pe_mkobject Line | Count | Source | 260 | 3.68k | { | 261 | 3.68k | pe_data_type *pe; | 262 | 3.68k | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 3.68k | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 3.68k | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 3.68k | pe = pe_data (abfd); | 270 | | | 271 | 3.68k | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 3.68k | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 3.68k | pe->dos_message[0] = 0x0eba1f0e; | 278 | 3.68k | pe->dos_message[1] = 0xcd09b400; | 279 | 3.68k | pe->dos_message[2] = 0x4c01b821; | 280 | 3.68k | pe->dos_message[3] = 0x685421cd; | 281 | 3.68k | pe->dos_message[4] = 0x70207369; | 282 | 3.68k | pe->dos_message[5] = 0x72676f72; | 283 | 3.68k | pe->dos_message[6] = 0x63206d61; | 284 | 3.68k | pe->dos_message[7] = 0x6f6e6e61; | 285 | 3.68k | pe->dos_message[8] = 0x65622074; | 286 | 3.68k | pe->dos_message[9] = 0x6e757220; | 287 | 3.68k | pe->dos_message[10] = 0x206e6920; | 288 | 3.68k | pe->dos_message[11] = 0x20534f44; | 289 | 3.68k | pe->dos_message[12] = 0x65646f6d; | 290 | 3.68k | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 3.68k | pe->dos_message[14] = 0x24; | 292 | 3.68k | pe->dos_message[15] = 0x0; | 293 | | | 294 | 3.68k | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 3.68k | bfd_coff_long_section_names (abfd) | 297 | 3.68k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 3.68k | return true; | 300 | 3.68k | } |
Line | Count | Source | 260 | 3.68k | { | 261 | 3.68k | pe_data_type *pe; | 262 | 3.68k | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 3.68k | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 3.68k | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 3.68k | pe = pe_data (abfd); | 270 | | | 271 | 3.68k | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 3.68k | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 3.68k | pe->dos_message[0] = 0x0eba1f0e; | 278 | 3.68k | pe->dos_message[1] = 0xcd09b400; | 279 | 3.68k | pe->dos_message[2] = 0x4c01b821; | 280 | 3.68k | pe->dos_message[3] = 0x685421cd; | 281 | 3.68k | pe->dos_message[4] = 0x70207369; | 282 | 3.68k | pe->dos_message[5] = 0x72676f72; | 283 | 3.68k | pe->dos_message[6] = 0x63206d61; | 284 | 3.68k | pe->dos_message[7] = 0x6f6e6e61; | 285 | 3.68k | pe->dos_message[8] = 0x65622074; | 286 | 3.68k | pe->dos_message[9] = 0x6e757220; | 287 | 3.68k | pe->dos_message[10] = 0x206e6920; | 288 | 3.68k | pe->dos_message[11] = 0x20534f44; | 289 | 3.68k | pe->dos_message[12] = 0x65646f6d; | 290 | 3.68k | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 3.68k | pe->dos_message[14] = 0x24; | 292 | 3.68k | pe->dos_message[15] = 0x0; | 293 | | | 294 | 3.68k | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 3.68k | bfd_coff_long_section_names (abfd) | 297 | 3.68k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 3.68k | return true; | 300 | 3.68k | } |
Line | Count | Source | 260 | 13.5k | { | 261 | 13.5k | pe_data_type *pe; | 262 | 13.5k | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 13.5k | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 13.5k | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 13.5k | pe = pe_data (abfd); | 270 | | | 271 | 13.5k | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 13.5k | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 13.5k | pe->dos_message[0] = 0x0eba1f0e; | 278 | 13.5k | pe->dos_message[1] = 0xcd09b400; | 279 | 13.5k | pe->dos_message[2] = 0x4c01b821; | 280 | 13.5k | pe->dos_message[3] = 0x685421cd; | 281 | 13.5k | pe->dos_message[4] = 0x70207369; | 282 | 13.5k | pe->dos_message[5] = 0x72676f72; | 283 | 13.5k | pe->dos_message[6] = 0x63206d61; | 284 | 13.5k | pe->dos_message[7] = 0x6f6e6e61; | 285 | 13.5k | pe->dos_message[8] = 0x65622074; | 286 | 13.5k | pe->dos_message[9] = 0x6e757220; | 287 | 13.5k | pe->dos_message[10] = 0x206e6920; | 288 | 13.5k | pe->dos_message[11] = 0x20534f44; | 289 | 13.5k | pe->dos_message[12] = 0x65646f6d; | 290 | 13.5k | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 13.5k | pe->dos_message[14] = 0x24; | 292 | 13.5k | pe->dos_message[15] = 0x0; | 293 | | | 294 | 13.5k | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 13.5k | bfd_coff_long_section_names (abfd) | 297 | 13.5k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 13.5k | return true; | 300 | 13.5k | } |
Line | Count | Source | 260 | 9.07k | { | 261 | 9.07k | pe_data_type *pe; | 262 | 9.07k | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 9.07k | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 9.07k | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 9.07k | pe = pe_data (abfd); | 270 | | | 271 | 9.07k | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 9.07k | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 9.07k | pe->dos_message[0] = 0x0eba1f0e; | 278 | 9.07k | pe->dos_message[1] = 0xcd09b400; | 279 | 9.07k | pe->dos_message[2] = 0x4c01b821; | 280 | 9.07k | pe->dos_message[3] = 0x685421cd; | 281 | 9.07k | pe->dos_message[4] = 0x70207369; | 282 | 9.07k | pe->dos_message[5] = 0x72676f72; | 283 | 9.07k | pe->dos_message[6] = 0x63206d61; | 284 | 9.07k | pe->dos_message[7] = 0x6f6e6e61; | 285 | 9.07k | pe->dos_message[8] = 0x65622074; | 286 | 9.07k | pe->dos_message[9] = 0x6e757220; | 287 | 9.07k | pe->dos_message[10] = 0x206e6920; | 288 | 9.07k | pe->dos_message[11] = 0x20534f44; | 289 | 9.07k | pe->dos_message[12] = 0x65646f6d; | 290 | 9.07k | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 9.07k | pe->dos_message[14] = 0x24; | 292 | 9.07k | pe->dos_message[15] = 0x0; | 293 | | | 294 | 9.07k | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 9.07k | bfd_coff_long_section_names (abfd) | 297 | 9.07k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 9.07k | return true; | 300 | 9.07k | } |
Line | Count | Source | 260 | 8.97k | { | 261 | 8.97k | pe_data_type *pe; | 262 | 8.97k | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 8.97k | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 8.97k | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 8.97k | pe = pe_data (abfd); | 270 | | | 271 | 8.97k | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 8.97k | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 8.97k | pe->dos_message[0] = 0x0eba1f0e; | 278 | 8.97k | pe->dos_message[1] = 0xcd09b400; | 279 | 8.97k | pe->dos_message[2] = 0x4c01b821; | 280 | 8.97k | pe->dos_message[3] = 0x685421cd; | 281 | 8.97k | pe->dos_message[4] = 0x70207369; | 282 | 8.97k | pe->dos_message[5] = 0x72676f72; | 283 | 8.97k | pe->dos_message[6] = 0x63206d61; | 284 | 8.97k | pe->dos_message[7] = 0x6f6e6e61; | 285 | 8.97k | pe->dos_message[8] = 0x65622074; | 286 | 8.97k | pe->dos_message[9] = 0x6e757220; | 287 | 8.97k | pe->dos_message[10] = 0x206e6920; | 288 | 8.97k | pe->dos_message[11] = 0x20534f44; | 289 | 8.97k | pe->dos_message[12] = 0x65646f6d; | 290 | 8.97k | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 8.97k | pe->dos_message[14] = 0x24; | 292 | 8.97k | pe->dos_message[15] = 0x0; | 293 | | | 294 | 8.97k | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 8.97k | bfd_coff_long_section_names (abfd) | 297 | 8.97k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 8.97k | return true; | 300 | 8.97k | } |
pei-arm-wince.c:pe_mkobject Line | Count | Source | 260 | 15.3k | { | 261 | 15.3k | pe_data_type *pe; | 262 | 15.3k | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 15.3k | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 15.3k | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 15.3k | pe = pe_data (abfd); | 270 | | | 271 | 15.3k | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 15.3k | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 15.3k | pe->dos_message[0] = 0x0eba1f0e; | 278 | 15.3k | pe->dos_message[1] = 0xcd09b400; | 279 | 15.3k | pe->dos_message[2] = 0x4c01b821; | 280 | 15.3k | pe->dos_message[3] = 0x685421cd; | 281 | 15.3k | pe->dos_message[4] = 0x70207369; | 282 | 15.3k | pe->dos_message[5] = 0x72676f72; | 283 | 15.3k | pe->dos_message[6] = 0x63206d61; | 284 | 15.3k | pe->dos_message[7] = 0x6f6e6e61; | 285 | 15.3k | pe->dos_message[8] = 0x65622074; | 286 | 15.3k | pe->dos_message[9] = 0x6e757220; | 287 | 15.3k | pe->dos_message[10] = 0x206e6920; | 288 | 15.3k | pe->dos_message[11] = 0x20534f44; | 289 | 15.3k | pe->dos_message[12] = 0x65646f6d; | 290 | 15.3k | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 15.3k | pe->dos_message[14] = 0x24; | 292 | 15.3k | pe->dos_message[15] = 0x0; | 293 | | | 294 | 15.3k | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 15.3k | bfd_coff_long_section_names (abfd) | 297 | 15.3k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 15.3k | return true; | 300 | 15.3k | } |
Line | Count | Source | 260 | 27.3k | { | 261 | 27.3k | pe_data_type *pe; | 262 | 27.3k | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 27.3k | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 27.3k | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 27.3k | pe = pe_data (abfd); | 270 | | | 271 | 27.3k | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 27.3k | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 27.3k | pe->dos_message[0] = 0x0eba1f0e; | 278 | 27.3k | pe->dos_message[1] = 0xcd09b400; | 279 | 27.3k | pe->dos_message[2] = 0x4c01b821; | 280 | 27.3k | pe->dos_message[3] = 0x685421cd; | 281 | 27.3k | pe->dos_message[4] = 0x70207369; | 282 | 27.3k | pe->dos_message[5] = 0x72676f72; | 283 | 27.3k | pe->dos_message[6] = 0x63206d61; | 284 | 27.3k | pe->dos_message[7] = 0x6f6e6e61; | 285 | 27.3k | pe->dos_message[8] = 0x65622074; | 286 | 27.3k | pe->dos_message[9] = 0x6e757220; | 287 | 27.3k | pe->dos_message[10] = 0x206e6920; | 288 | 27.3k | pe->dos_message[11] = 0x20534f44; | 289 | 27.3k | pe->dos_message[12] = 0x65646f6d; | 290 | 27.3k | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 27.3k | pe->dos_message[14] = 0x24; | 292 | 27.3k | pe->dos_message[15] = 0x0; | 293 | | | 294 | 27.3k | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 27.3k | bfd_coff_long_section_names (abfd) | 297 | 27.3k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 27.3k | return true; | 300 | 27.3k | } |
Line | Count | Source | 260 | 26.0k | { | 261 | 26.0k | pe_data_type *pe; | 262 | 26.0k | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 26.0k | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 26.0k | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 26.0k | pe = pe_data (abfd); | 270 | | | 271 | 26.0k | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 26.0k | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 26.0k | pe->dos_message[0] = 0x0eba1f0e; | 278 | 26.0k | pe->dos_message[1] = 0xcd09b400; | 279 | 26.0k | pe->dos_message[2] = 0x4c01b821; | 280 | 26.0k | pe->dos_message[3] = 0x685421cd; | 281 | 26.0k | pe->dos_message[4] = 0x70207369; | 282 | 26.0k | pe->dos_message[5] = 0x72676f72; | 283 | 26.0k | pe->dos_message[6] = 0x63206d61; | 284 | 26.0k | pe->dos_message[7] = 0x6f6e6e61; | 285 | 26.0k | pe->dos_message[8] = 0x65622074; | 286 | 26.0k | pe->dos_message[9] = 0x6e757220; | 287 | 26.0k | pe->dos_message[10] = 0x206e6920; | 288 | 26.0k | pe->dos_message[11] = 0x20534f44; | 289 | 26.0k | pe->dos_message[12] = 0x65646f6d; | 290 | 26.0k | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 26.0k | pe->dos_message[14] = 0x24; | 292 | 26.0k | pe->dos_message[15] = 0x0; | 293 | | | 294 | 26.0k | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 26.0k | bfd_coff_long_section_names (abfd) | 297 | 26.0k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 26.0k | return true; | 300 | 26.0k | } |
Line | Count | Source | 260 | 15.4k | { | 261 | 15.4k | pe_data_type *pe; | 262 | 15.4k | size_t amt = sizeof (pe_data_type); | 263 | | | 264 | 15.4k | abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt); | 265 | | | 266 | 15.4k | if (abfd->tdata.pe_obj_data == 0) | 267 | 0 | return false; | 268 | | | 269 | 15.4k | pe = pe_data (abfd); | 270 | | | 271 | 15.4k | pe->coff.pe = 1; | 272 | | | 273 | | /* in_reloc_p is architecture dependent. */ | 274 | 15.4k | pe->in_reloc_p = in_reloc_p; | 275 | | | 276 | | /* Default DOS message string. */ | 277 | 15.4k | pe->dos_message[0] = 0x0eba1f0e; | 278 | 15.4k | pe->dos_message[1] = 0xcd09b400; | 279 | 15.4k | pe->dos_message[2] = 0x4c01b821; | 280 | 15.4k | pe->dos_message[3] = 0x685421cd; | 281 | 15.4k | pe->dos_message[4] = 0x70207369; | 282 | 15.4k | pe->dos_message[5] = 0x72676f72; | 283 | 15.4k | pe->dos_message[6] = 0x63206d61; | 284 | 15.4k | pe->dos_message[7] = 0x6f6e6e61; | 285 | 15.4k | pe->dos_message[8] = 0x65622074; | 286 | 15.4k | pe->dos_message[9] = 0x6e757220; | 287 | 15.4k | pe->dos_message[10] = 0x206e6920; | 288 | 15.4k | pe->dos_message[11] = 0x20534f44; | 289 | 15.4k | pe->dos_message[12] = 0x65646f6d; | 290 | 15.4k | pe->dos_message[13] = 0x0a0d0d2e; | 291 | 15.4k | pe->dos_message[14] = 0x24; | 292 | 15.4k | pe->dos_message[15] = 0x0; | 293 | | | 294 | 15.4k | memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); | 295 | | | 296 | 15.4k | bfd_coff_long_section_names (abfd) | 297 | 15.4k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 298 | | | 299 | 15.4k | return true; | 300 | 15.4k | } |
|
301 | | |
302 | | /* Create the COFF backend specific information. */ |
303 | | |
304 | | static void * |
305 | | pe_mkobject_hook (bfd * abfd, |
306 | | void * filehdr, |
307 | | void * aouthdr ATTRIBUTE_UNUSED) |
308 | 281k | { |
309 | 281k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; |
310 | 281k | pe_data_type *pe; |
311 | | |
312 | 281k | if (! pe_mkobject (abfd)) |
313 | 0 | return NULL; |
314 | | |
315 | 281k | pe = pe_data (abfd); |
316 | 281k | pe->coff.sym_filepos = internal_f->f_symptr; |
317 | | /* These members communicate important constants about the symbol |
318 | | table to GDB's symbol-reading code. These `constants' |
319 | | unfortunately vary among coff implementations... */ |
320 | 281k | pe->coff.local_n_btmask = N_BTMASK; |
321 | 281k | pe->coff.local_n_btshft = N_BTSHFT; |
322 | 281k | pe->coff.local_n_tmask = N_TMASK; |
323 | 281k | pe->coff.local_n_tshift = N_TSHIFT; |
324 | 281k | pe->coff.local_symesz = SYMESZ; |
325 | 281k | pe->coff.local_auxesz = AUXESZ; |
326 | 281k | pe->coff.local_linesz = LINESZ; |
327 | | |
328 | 281k | pe->coff.timestamp = internal_f->f_timdat; |
329 | | |
330 | 281k | obj_raw_syment_count (abfd) = |
331 | 281k | obj_conv_table_size (abfd) = |
332 | 281k | internal_f->f_nsyms; |
333 | | |
334 | 281k | pe->real_flags = internal_f->f_flags; |
335 | | |
336 | 281k | if ((internal_f->f_flags & F_DLL) != 0) |
337 | 78.7k | pe->dll = 1; |
338 | | |
339 | 281k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) |
340 | 217k | abfd->flags |= HAS_DEBUG; |
341 | | |
342 | | #ifdef COFF_IMAGE_WITH_PE |
343 | 198k | if (aouthdr) |
344 | 138k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; |
345 | | #endif |
346 | | |
347 | | #ifdef ARM |
348 | 50.1k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) |
349 | 0 | coff_data (abfd) ->flags = 0; |
350 | | #endif |
351 | | |
352 | 281k | memcpy (pe->dos_message, internal_f->pe.dos_message, |
353 | 281k | sizeof (pe->dos_message)); |
354 | | |
355 | 281k | return (void *) pe; |
356 | 281k | } pei-i386.c:pe_mkobject_hook Line | Count | Source | 308 | 20.6k | { | 309 | 20.6k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 20.6k | pe_data_type *pe; | 311 | | | 312 | 20.6k | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 20.6k | pe = pe_data (abfd); | 316 | 20.6k | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 20.6k | pe->coff.local_n_btmask = N_BTMASK; | 321 | 20.6k | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 20.6k | pe->coff.local_n_tmask = N_TMASK; | 323 | 20.6k | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 20.6k | pe->coff.local_symesz = SYMESZ; | 325 | 20.6k | pe->coff.local_auxesz = AUXESZ; | 326 | 20.6k | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 20.6k | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 20.6k | obj_raw_syment_count (abfd) = | 331 | 20.6k | obj_conv_table_size (abfd) = | 332 | 20.6k | internal_f->f_nsyms; | 333 | | | 334 | 20.6k | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 20.6k | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 3.27k | pe->dll = 1; | 338 | | | 339 | 20.6k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 18.1k | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | 20.6k | #ifdef COFF_IMAGE_WITH_PE | 343 | 20.6k | if (aouthdr) | 344 | 16.3k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | 20.6k | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 20.6k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 20.6k | sizeof (pe->dos_message)); | 354 | | | 355 | 20.6k | return (void *) pe; | 356 | 20.6k | } |
pe-x86_64.c:pe_mkobject_hook Line | Count | Source | 308 | 37.1k | { | 309 | 37.1k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 37.1k | pe_data_type *pe; | 311 | | | 312 | 37.1k | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 37.1k | pe = pe_data (abfd); | 316 | 37.1k | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 37.1k | pe->coff.local_n_btmask = N_BTMASK; | 321 | 37.1k | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 37.1k | pe->coff.local_n_tmask = N_TMASK; | 323 | 37.1k | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 37.1k | pe->coff.local_symesz = SYMESZ; | 325 | 37.1k | pe->coff.local_auxesz = AUXESZ; | 326 | 37.1k | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 37.1k | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 37.1k | obj_raw_syment_count (abfd) = | 331 | 37.1k | obj_conv_table_size (abfd) = | 332 | 37.1k | internal_f->f_nsyms; | 333 | | | 334 | 37.1k | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 37.1k | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 8.87k | pe->dll = 1; | 338 | | | 339 | 37.1k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 27.5k | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | | #ifdef COFF_IMAGE_WITH_PE | 343 | | if (aouthdr) | 344 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 37.1k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 37.1k | sizeof (pe->dos_message)); | 354 | | | 355 | 37.1k | return (void *) pe; | 356 | 37.1k | } |
pei-x86_64.c:pe_mkobject_hook Line | Count | Source | 308 | 28.0k | { | 309 | 28.0k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 28.0k | pe_data_type *pe; | 311 | | | 312 | 28.0k | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 28.0k | pe = pe_data (abfd); | 316 | 28.0k | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 28.0k | pe->coff.local_n_btmask = N_BTMASK; | 321 | 28.0k | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 28.0k | pe->coff.local_n_tmask = N_TMASK; | 323 | 28.0k | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 28.0k | pe->coff.local_symesz = SYMESZ; | 325 | 28.0k | pe->coff.local_auxesz = AUXESZ; | 326 | 28.0k | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 28.0k | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 28.0k | obj_raw_syment_count (abfd) = | 331 | 28.0k | obj_conv_table_size (abfd) = | 332 | 28.0k | internal_f->f_nsyms; | 333 | | | 334 | 28.0k | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 28.0k | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 17.1k | pe->dll = 1; | 338 | | | 339 | 28.0k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 11.4k | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | 28.0k | #ifdef COFF_IMAGE_WITH_PE | 343 | 28.0k | if (aouthdr) | 344 | 20.5k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | 28.0k | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 28.0k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 28.0k | sizeof (pe->dos_message)); | 354 | | | 355 | 28.0k | return (void *) pe; | 356 | 28.0k | } |
pei-aarch64.c:pe_mkobject_hook Line | Count | Source | 308 | 23.7k | { | 309 | 23.7k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 23.7k | pe_data_type *pe; | 311 | | | 312 | 23.7k | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 23.7k | pe = pe_data (abfd); | 316 | 23.7k | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 23.7k | pe->coff.local_n_btmask = N_BTMASK; | 321 | 23.7k | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 23.7k | pe->coff.local_n_tmask = N_TMASK; | 323 | 23.7k | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 23.7k | pe->coff.local_symesz = SYMESZ; | 325 | 23.7k | pe->coff.local_auxesz = AUXESZ; | 326 | 23.7k | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 23.7k | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 23.7k | obj_raw_syment_count (abfd) = | 331 | 23.7k | obj_conv_table_size (abfd) = | 332 | 23.7k | internal_f->f_nsyms; | 333 | | | 334 | 23.7k | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 23.7k | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 5.46k | pe->dll = 1; | 338 | | | 339 | 23.7k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 18.9k | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | 23.7k | #ifdef COFF_IMAGE_WITH_PE | 343 | 23.7k | if (aouthdr) | 344 | 20.0k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | 23.7k | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 23.7k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 23.7k | sizeof (pe->dos_message)); | 354 | | | 355 | 23.7k | return (void *) pe; | 356 | 23.7k | } |
pe-aarch64.c:pe_mkobject_hook Line | Count | Source | 308 | 7.22k | { | 309 | 7.22k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 7.22k | pe_data_type *pe; | 311 | | | 312 | 7.22k | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 7.22k | pe = pe_data (abfd); | 316 | 7.22k | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 7.22k | pe->coff.local_n_btmask = N_BTMASK; | 321 | 7.22k | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 7.22k | pe->coff.local_n_tmask = N_TMASK; | 323 | 7.22k | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 7.22k | pe->coff.local_symesz = SYMESZ; | 325 | 7.22k | pe->coff.local_auxesz = AUXESZ; | 326 | 7.22k | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 7.22k | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 7.22k | obj_raw_syment_count (abfd) = | 331 | 7.22k | obj_conv_table_size (abfd) = | 332 | 7.22k | internal_f->f_nsyms; | 333 | | | 334 | 7.22k | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 7.22k | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 2.70k | pe->dll = 1; | 338 | | | 339 | 7.22k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 6.19k | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | | #ifdef COFF_IMAGE_WITH_PE | 343 | | if (aouthdr) | 344 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 7.22k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 7.22k | sizeof (pe->dos_message)); | 354 | | | 355 | 7.22k | return (void *) pe; | 356 | 7.22k | } |
pei-ia64.c:pe_mkobject_hook Line | Count | Source | 308 | 22.5k | { | 309 | 22.5k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 22.5k | pe_data_type *pe; | 311 | | | 312 | 22.5k | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 22.5k | pe = pe_data (abfd); | 316 | 22.5k | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 22.5k | pe->coff.local_n_btmask = N_BTMASK; | 321 | 22.5k | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 22.5k | pe->coff.local_n_tmask = N_TMASK; | 323 | 22.5k | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 22.5k | pe->coff.local_symesz = SYMESZ; | 325 | 22.5k | pe->coff.local_auxesz = AUXESZ; | 326 | 22.5k | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 22.5k | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 22.5k | obj_raw_syment_count (abfd) = | 331 | 22.5k | obj_conv_table_size (abfd) = | 332 | 22.5k | internal_f->f_nsyms; | 333 | | | 334 | 22.5k | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 22.5k | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 9.36k | pe->dll = 1; | 338 | | | 339 | 22.5k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 14.8k | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | 22.5k | #ifdef COFF_IMAGE_WITH_PE | 343 | 22.5k | if (aouthdr) | 344 | 15.1k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | 22.5k | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 22.5k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 22.5k | sizeof (pe->dos_message)); | 354 | | | 355 | 22.5k | return (void *) pe; | 356 | 22.5k | } |
pei-loongarch64.c:pe_mkobject_hook Line | Count | Source | 308 | 19.1k | { | 309 | 19.1k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 19.1k | pe_data_type *pe; | 311 | | | 312 | 19.1k | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 19.1k | pe = pe_data (abfd); | 316 | 19.1k | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 19.1k | pe->coff.local_n_btmask = N_BTMASK; | 321 | 19.1k | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 19.1k | pe->coff.local_n_tmask = N_TMASK; | 323 | 19.1k | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 19.1k | pe->coff.local_symesz = SYMESZ; | 325 | 19.1k | pe->coff.local_auxesz = AUXESZ; | 326 | 19.1k | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 19.1k | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 19.1k | obj_raw_syment_count (abfd) = | 331 | 19.1k | obj_conv_table_size (abfd) = | 332 | 19.1k | internal_f->f_nsyms; | 333 | | | 334 | 19.1k | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 19.1k | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 6.56k | pe->dll = 1; | 338 | | | 339 | 19.1k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 15.2k | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | 19.1k | #ifdef COFF_IMAGE_WITH_PE | 343 | 19.1k | if (aouthdr) | 344 | 13.3k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | 19.1k | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 19.1k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 19.1k | sizeof (pe->dos_message)); | 354 | | | 355 | 19.1k | return (void *) pe; | 356 | 19.1k | } |
pe-arm-wince.c:pe_mkobject_hook Line | Count | Source | 308 | 3.68k | { | 309 | 3.68k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 3.68k | pe_data_type *pe; | 311 | | | 312 | 3.68k | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 3.68k | pe = pe_data (abfd); | 316 | 3.68k | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 3.68k | pe->coff.local_n_btmask = N_BTMASK; | 321 | 3.68k | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 3.68k | pe->coff.local_n_tmask = N_TMASK; | 323 | 3.68k | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 3.68k | pe->coff.local_symesz = SYMESZ; | 325 | 3.68k | pe->coff.local_auxesz = AUXESZ; | 326 | 3.68k | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 3.68k | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 3.68k | obj_raw_syment_count (abfd) = | 331 | 3.68k | obj_conv_table_size (abfd) = | 332 | 3.68k | internal_f->f_nsyms; | 333 | | | 334 | 3.68k | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 3.68k | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 1.17k | pe->dll = 1; | 338 | | | 339 | 3.68k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 3.43k | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | | #ifdef COFF_IMAGE_WITH_PE | 343 | | if (aouthdr) | 344 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | | #endif | 346 | | | 347 | 3.68k | #ifdef ARM | 348 | 3.68k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | 0 | coff_data (abfd) ->flags = 0; | 350 | 3.68k | #endif | 351 | | | 352 | 3.68k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 3.68k | sizeof (pe->dos_message)); | 354 | | | 355 | 3.68k | return (void *) pe; | 356 | 3.68k | } |
pe-arm.c:pe_mkobject_hook Line | Count | Source | 308 | 3.68k | { | 309 | 3.68k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 3.68k | pe_data_type *pe; | 311 | | | 312 | 3.68k | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 3.68k | pe = pe_data (abfd); | 316 | 3.68k | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 3.68k | pe->coff.local_n_btmask = N_BTMASK; | 321 | 3.68k | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 3.68k | pe->coff.local_n_tmask = N_TMASK; | 323 | 3.68k | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 3.68k | pe->coff.local_symesz = SYMESZ; | 325 | 3.68k | pe->coff.local_auxesz = AUXESZ; | 326 | 3.68k | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 3.68k | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 3.68k | obj_raw_syment_count (abfd) = | 331 | 3.68k | obj_conv_table_size (abfd) = | 332 | 3.68k | internal_f->f_nsyms; | 333 | | | 334 | 3.68k | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 3.68k | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 1.17k | pe->dll = 1; | 338 | | | 339 | 3.68k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 3.43k | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | | #ifdef COFF_IMAGE_WITH_PE | 343 | | if (aouthdr) | 344 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | | #endif | 346 | | | 347 | 3.68k | #ifdef ARM | 348 | 3.68k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | 0 | coff_data (abfd) ->flags = 0; | 350 | 3.68k | #endif | 351 | | | 352 | 3.68k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 3.68k | sizeof (pe->dos_message)); | 354 | | | 355 | 3.68k | return (void *) pe; | 356 | 3.68k | } |
pe-i386.c:pe_mkobject_hook Line | Count | Source | 308 | 13.5k | { | 309 | 13.5k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 13.5k | pe_data_type *pe; | 311 | | | 312 | 13.5k | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 13.5k | pe = pe_data (abfd); | 316 | 13.5k | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 13.5k | pe->coff.local_n_btmask = N_BTMASK; | 321 | 13.5k | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 13.5k | pe->coff.local_n_tmask = N_TMASK; | 323 | 13.5k | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 13.5k | pe->coff.local_symesz = SYMESZ; | 325 | 13.5k | pe->coff.local_auxesz = AUXESZ; | 326 | 13.5k | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 13.5k | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 13.5k | obj_raw_syment_count (abfd) = | 331 | 13.5k | obj_conv_table_size (abfd) = | 332 | 13.5k | internal_f->f_nsyms; | 333 | | | 334 | 13.5k | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 13.5k | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 5.45k | pe->dll = 1; | 338 | | | 339 | 13.5k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 11.8k | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | | #ifdef COFF_IMAGE_WITH_PE | 343 | | if (aouthdr) | 344 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 13.5k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 13.5k | sizeof (pe->dos_message)); | 354 | | | 355 | 13.5k | return (void *) pe; | 356 | 13.5k | } |
pe-mcore.c:pe_mkobject_hook Line | Count | Source | 308 | 9.07k | { | 309 | 9.07k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 9.07k | pe_data_type *pe; | 311 | | | 312 | 9.07k | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 9.07k | pe = pe_data (abfd); | 316 | 9.07k | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 9.07k | pe->coff.local_n_btmask = N_BTMASK; | 321 | 9.07k | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 9.07k | pe->coff.local_n_tmask = N_TMASK; | 323 | 9.07k | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 9.07k | pe->coff.local_symesz = SYMESZ; | 325 | 9.07k | pe->coff.local_auxesz = AUXESZ; | 326 | 9.07k | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 9.07k | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 9.07k | obj_raw_syment_count (abfd) = | 331 | 9.07k | obj_conv_table_size (abfd) = | 332 | 9.07k | internal_f->f_nsyms; | 333 | | | 334 | 9.07k | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 9.07k | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 2.95k | pe->dll = 1; | 338 | | | 339 | 9.07k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 7.31k | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | | #ifdef COFF_IMAGE_WITH_PE | 343 | | if (aouthdr) | 344 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 9.07k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 9.07k | sizeof (pe->dos_message)); | 354 | | | 355 | 9.07k | return (void *) pe; | 356 | 9.07k | } |
Line | Count | Source | 308 | 8.97k | { | 309 | 8.97k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 8.97k | pe_data_type *pe; | 311 | | | 312 | 8.97k | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 8.97k | pe = pe_data (abfd); | 316 | 8.97k | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 8.97k | pe->coff.local_n_btmask = N_BTMASK; | 321 | 8.97k | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 8.97k | pe->coff.local_n_tmask = N_TMASK; | 323 | 8.97k | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 8.97k | pe->coff.local_symesz = SYMESZ; | 325 | 8.97k | pe->coff.local_auxesz = AUXESZ; | 326 | 8.97k | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 8.97k | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 8.97k | obj_raw_syment_count (abfd) = | 331 | 8.97k | obj_conv_table_size (abfd) = | 332 | 8.97k | internal_f->f_nsyms; | 333 | | | 334 | 8.97k | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 8.97k | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 1.48k | pe->dll = 1; | 338 | | | 339 | 8.97k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 7.80k | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | | #ifdef COFF_IMAGE_WITH_PE | 343 | | if (aouthdr) | 344 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 8.97k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 8.97k | sizeof (pe->dos_message)); | 354 | | | 355 | 8.97k | return (void *) pe; | 356 | 8.97k | } |
pei-arm-wince.c:pe_mkobject_hook Line | Count | Source | 308 | 15.3k | { | 309 | 15.3k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 15.3k | pe_data_type *pe; | 311 | | | 312 | 15.3k | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 15.3k | pe = pe_data (abfd); | 316 | 15.3k | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 15.3k | pe->coff.local_n_btmask = N_BTMASK; | 321 | 15.3k | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 15.3k | pe->coff.local_n_tmask = N_TMASK; | 323 | 15.3k | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 15.3k | pe->coff.local_symesz = SYMESZ; | 325 | 15.3k | pe->coff.local_auxesz = AUXESZ; | 326 | 15.3k | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 15.3k | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 15.3k | obj_raw_syment_count (abfd) = | 331 | 15.3k | obj_conv_table_size (abfd) = | 332 | 15.3k | internal_f->f_nsyms; | 333 | | | 334 | 15.3k | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 15.3k | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 4.09k | pe->dll = 1; | 338 | | | 339 | 15.3k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 10.9k | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | 15.3k | #ifdef COFF_IMAGE_WITH_PE | 343 | 15.3k | if (aouthdr) | 344 | 6.18k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | 15.3k | #endif | 346 | | | 347 | 15.3k | #ifdef ARM | 348 | 15.3k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | 0 | coff_data (abfd) ->flags = 0; | 350 | 15.3k | #endif | 351 | | | 352 | 15.3k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 15.3k | sizeof (pe->dos_message)); | 354 | | | 355 | 15.3k | return (void *) pe; | 356 | 15.3k | } |
pei-arm.c:pe_mkobject_hook Line | Count | Source | 308 | 27.3k | { | 309 | 27.3k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 27.3k | pe_data_type *pe; | 311 | | | 312 | 27.3k | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 27.3k | pe = pe_data (abfd); | 316 | 27.3k | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 27.3k | pe->coff.local_n_btmask = N_BTMASK; | 321 | 27.3k | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 27.3k | pe->coff.local_n_tmask = N_TMASK; | 323 | 27.3k | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 27.3k | pe->coff.local_symesz = SYMESZ; | 325 | 27.3k | pe->coff.local_auxesz = AUXESZ; | 326 | 27.3k | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 27.3k | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 27.3k | obj_raw_syment_count (abfd) = | 331 | 27.3k | obj_conv_table_size (abfd) = | 332 | 27.3k | internal_f->f_nsyms; | 333 | | | 334 | 27.3k | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 27.3k | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 4.70k | pe->dll = 1; | 338 | | | 339 | 27.3k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 22.4k | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | 27.3k | #ifdef COFF_IMAGE_WITH_PE | 343 | 27.3k | if (aouthdr) | 344 | 16.5k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | 27.3k | #endif | 346 | | | 347 | 27.3k | #ifdef ARM | 348 | 27.3k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | 0 | coff_data (abfd) ->flags = 0; | 350 | 27.3k | #endif | 351 | | | 352 | 27.3k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 27.3k | sizeof (pe->dos_message)); | 354 | | | 355 | 27.3k | return (void *) pe; | 356 | 27.3k | } |
pei-mcore.c:pe_mkobject_hook Line | Count | Source | 308 | 26.0k | { | 309 | 26.0k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 26.0k | pe_data_type *pe; | 311 | | | 312 | 26.0k | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 26.0k | pe = pe_data (abfd); | 316 | 26.0k | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 26.0k | pe->coff.local_n_btmask = N_BTMASK; | 321 | 26.0k | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 26.0k | pe->coff.local_n_tmask = N_TMASK; | 323 | 26.0k | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 26.0k | pe->coff.local_symesz = SYMESZ; | 325 | 26.0k | pe->coff.local_auxesz = AUXESZ; | 326 | 26.0k | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 26.0k | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 26.0k | obj_raw_syment_count (abfd) = | 331 | 26.0k | obj_conv_table_size (abfd) = | 332 | 26.0k | internal_f->f_nsyms; | 333 | | | 334 | 26.0k | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 26.0k | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 3.59k | pe->dll = 1; | 338 | | | 339 | 26.0k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 23.4k | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | 26.0k | #ifdef COFF_IMAGE_WITH_PE | 343 | 26.0k | if (aouthdr) | 344 | 19.6k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | 26.0k | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 26.0k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 26.0k | sizeof (pe->dos_message)); | 354 | | | 355 | 26.0k | return (void *) pe; | 356 | 26.0k | } |
pei-sh.c:pe_mkobject_hook Line | Count | Source | 308 | 15.4k | { | 309 | 15.4k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 310 | 15.4k | pe_data_type *pe; | 311 | | | 312 | 15.4k | if (! pe_mkobject (abfd)) | 313 | 0 | return NULL; | 314 | | | 315 | 15.4k | pe = pe_data (abfd); | 316 | 15.4k | pe->coff.sym_filepos = internal_f->f_symptr; | 317 | | /* These members communicate important constants about the symbol | 318 | | table to GDB's symbol-reading code. These `constants' | 319 | | unfortunately vary among coff implementations... */ | 320 | 15.4k | pe->coff.local_n_btmask = N_BTMASK; | 321 | 15.4k | pe->coff.local_n_btshft = N_BTSHFT; | 322 | 15.4k | pe->coff.local_n_tmask = N_TMASK; | 323 | 15.4k | pe->coff.local_n_tshift = N_TSHIFT; | 324 | 15.4k | pe->coff.local_symesz = SYMESZ; | 325 | 15.4k | pe->coff.local_auxesz = AUXESZ; | 326 | 15.4k | pe->coff.local_linesz = LINESZ; | 327 | | | 328 | 15.4k | pe->coff.timestamp = internal_f->f_timdat; | 329 | | | 330 | 15.4k | obj_raw_syment_count (abfd) = | 331 | 15.4k | obj_conv_table_size (abfd) = | 332 | 15.4k | internal_f->f_nsyms; | 333 | | | 334 | 15.4k | pe->real_flags = internal_f->f_flags; | 335 | | | 336 | 15.4k | if ((internal_f->f_flags & F_DLL) != 0) | 337 | 783 | pe->dll = 1; | 338 | | | 339 | 15.4k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 340 | 14.5k | abfd->flags |= HAS_DEBUG; | 341 | | | 342 | 15.4k | #ifdef COFF_IMAGE_WITH_PE | 343 | 15.4k | if (aouthdr) | 344 | 10.4k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 345 | 15.4k | #endif | 346 | | | 347 | | #ifdef ARM | 348 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 349 | | coff_data (abfd) ->flags = 0; | 350 | | #endif | 351 | | | 352 | 15.4k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 353 | 15.4k | sizeof (pe->dos_message)); | 354 | | | 355 | 15.4k | return (void *) pe; | 356 | 15.4k | } |
|
357 | | |
358 | | static bool |
359 | | pe_print_private_bfd_data (bfd *abfd, void * vfile) |
360 | 0 | { |
361 | 0 | FILE *file = (FILE *) vfile; |
362 | |
|
363 | 0 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) |
364 | 0 | return false; |
365 | | |
366 | 0 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) |
367 | 0 | return true; |
368 | | |
369 | 0 | fputc ('\n', file); |
370 | |
|
371 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); |
372 | 0 | } Unexecuted instantiation: pei-i386.c:pe_print_private_bfd_data Unexecuted instantiation: pe-x86_64.c:pe_print_private_bfd_data Unexecuted instantiation: pei-x86_64.c:pe_print_private_bfd_data Unexecuted instantiation: pei-aarch64.c:pe_print_private_bfd_data Unexecuted instantiation: pe-aarch64.c:pe_print_private_bfd_data Unexecuted instantiation: pei-ia64.c:pe_print_private_bfd_data Unexecuted instantiation: pei-loongarch64.c:pe_print_private_bfd_data Unexecuted instantiation: pe-arm-wince.c:pe_print_private_bfd_data Unexecuted instantiation: pe-arm.c:pe_print_private_bfd_data Unexecuted instantiation: pe-i386.c:pe_print_private_bfd_data Unexecuted instantiation: pe-mcore.c:pe_print_private_bfd_data Unexecuted instantiation: pe-sh.c:pe_print_private_bfd_data Unexecuted instantiation: pei-arm-wince.c:pe_print_private_bfd_data Unexecuted instantiation: pei-arm.c:pe_print_private_bfd_data Unexecuted instantiation: pei-mcore.c:pe_print_private_bfd_data Unexecuted instantiation: pei-sh.c:pe_print_private_bfd_data |
373 | | |
374 | | /* Copy any private info we understand from the input bfd |
375 | | to the output bfd. */ |
376 | | |
377 | | static bool |
378 | | pe_bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd) |
379 | 0 | { |
380 | | /* PR binutils/716: Copy the large address aware flag. |
381 | | XXX: Should we be copying other flags or other fields in the pe_data() |
382 | | structure ? */ |
383 | 0 | if (pe_data (obfd) != NULL |
384 | 0 | && pe_data (ibfd) != NULL |
385 | 0 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) |
386 | 0 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; |
387 | |
|
388 | 0 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) |
389 | 0 | return false; |
390 | | |
391 | 0 | if (pe_saved_coff_bfd_copy_private_bfd_data) |
392 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); |
393 | | |
394 | 0 | return true; |
395 | 0 | } Unexecuted instantiation: pei-i386.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pe-x86_64.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-x86_64.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-aarch64.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pe-aarch64.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-ia64.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-loongarch64.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pe-arm-wince.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pe-arm.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pe-i386.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pe-mcore.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pe-sh.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-arm-wince.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-arm.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-mcore.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-sh.c:pe_bfd_copy_private_bfd_data |
396 | | |
397 | | #define coff_bfd_copy_private_section_data \ |
398 | | _bfd_XX_bfd_copy_private_section_data |
399 | | |
400 | | #define coff_get_symbol_info _bfd_XX_get_symbol_info |
401 | | |
402 | | #ifdef COFF_IMAGE_WITH_PE |
403 | | |
404 | | /* Code to handle Microsoft's Import Library Format. |
405 | | Also known as LINK6 format. |
406 | | Documentation about this format can be found at: |
407 | | |
408 | | https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#import-library-format */ |
409 | | |
410 | | /* The following constants specify the sizes of the various data |
411 | | structures that we have to create in order to build a bfd describing |
412 | | an ILF object file. The final "+ 1" in the definitions of SIZEOF_IDATA6 |
413 | | and SIZEOF_IDATA7 below is to allow for the possibility that we might |
414 | | need a padding byte in order to ensure 16 bit alignment for the section's |
415 | | contents. |
416 | | |
417 | | The value for SIZEOF_ILF_STRINGS is computed as follows: |
418 | | |
419 | | There will be NUM_ILF_SECTIONS section symbols. Allow 9 characters |
420 | | per symbol for their names (longest section name is .idata$x). |
421 | | |
422 | | There will be two symbols for the imported value, one the symbol name |
423 | | and one with _imp__ prefixed. Allowing for the terminating nul's this |
424 | | is strlen (symbol_name) * 2 + 8 + 21 + strlen (source_dll). |
425 | | |
426 | | The strings in the string table must start STRING__SIZE_SIZE bytes into |
427 | | the table in order to for the string lookup code in coffgen/coffcode to |
428 | | work. */ |
429 | 45.2k | #define NUM_ILF_RELOCS 8 |
430 | 150k | #define NUM_ILF_SECTIONS 6 |
431 | 113k | #define NUM_ILF_SYMS (2 + NUM_ILF_SECTIONS) |
432 | | |
433 | 22.6k | #define SIZEOF_ILF_SYMS (NUM_ILF_SYMS * sizeof (* vars.sym_cache)) |
434 | 22.6k | #define SIZEOF_ILF_SYM_TABLE (NUM_ILF_SYMS * sizeof (* vars.sym_table)) |
435 | 22.6k | #define SIZEOF_ILF_NATIVE_SYMS (NUM_ILF_SYMS * sizeof (* vars.native_syms)) |
436 | 22.6k | #define SIZEOF_ILF_SYM_PTR_TABLE (NUM_ILF_SYMS * sizeof (* vars.sym_ptr_table)) |
437 | 22.6k | #define SIZEOF_ILF_EXT_SYMS (NUM_ILF_SYMS * sizeof (* vars.esym_table)) |
438 | 22.6k | #define SIZEOF_ILF_RELOCS (NUM_ILF_RELOCS * sizeof (* vars.reltab)) |
439 | 22.6k | #define SIZEOF_ILF_INT_RELOCS (NUM_ILF_RELOCS * sizeof (* vars.int_reltab)) |
440 | 22.6k | #define SIZEOF_ILF_STRINGS (strlen (symbol_name) * 2 + 8 \ |
441 | 22.6k | + 21 + strlen (source_dll) \ |
442 | 22.6k | + NUM_ILF_SECTIONS * 9 \ |
443 | 22.6k | + STRING_SIZE_SIZE) |
444 | 15.0k | #define SIZEOF_IDATA2 (5 * 4) |
445 | | |
446 | | /* For PEx64 idata4 & 5 have thumb size of 8 bytes. */ |
447 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) |
448 | 7.02k | #define SIZEOF_IDATA4 (2 * 4) |
449 | 7.02k | #define SIZEOF_IDATA5 (2 * 4) |
450 | | #else |
451 | 15.5k | #define SIZEOF_IDATA4 (1 * 4) |
452 | 15.5k | #define SIZEOF_IDATA5 (1 * 4) |
453 | | #endif |
454 | | |
455 | 19.4k | #define SIZEOF_IDATA6 (2 + strlen (symbol_name) + 1 + 1) |
456 | 15.0k | #define SIZEOF_IDATA7 (strlen (source_dll) + 1 + 1) |
457 | 15.0k | #define SIZEOF_ILF_SECTIONS (NUM_ILF_SECTIONS * sizeof (struct coff_section_tdata)) |
458 | | |
459 | | #define ILF_DATA_SIZE \ |
460 | 15.0k | + SIZEOF_ILF_SYMS \ |
461 | 15.0k | + SIZEOF_ILF_SYM_TABLE \ |
462 | 15.0k | + SIZEOF_ILF_NATIVE_SYMS \ |
463 | 15.0k | + SIZEOF_ILF_SYM_PTR_TABLE \ |
464 | 15.0k | + SIZEOF_ILF_EXT_SYMS \ |
465 | 15.0k | + SIZEOF_ILF_RELOCS \ |
466 | 15.0k | + SIZEOF_ILF_INT_RELOCS \ |
467 | 15.0k | + SIZEOF_ILF_STRINGS \ |
468 | 15.0k | + SIZEOF_IDATA2 \ |
469 | 15.0k | + SIZEOF_IDATA4 \ |
470 | 15.0k | + SIZEOF_IDATA5 \ |
471 | 15.0k | + SIZEOF_IDATA6 \ |
472 | 15.0k | + SIZEOF_IDATA7 \ |
473 | 15.0k | + SIZEOF_ILF_SECTIONS \ |
474 | 15.0k | + MAX_TEXT_SECTION_SIZE |
475 | | |
476 | | /* Create an empty relocation against the given symbol. */ |
477 | | |
478 | | static void |
479 | | pe_ILF_make_a_symbol_reloc (pe_ILF_vars * vars, |
480 | | bfd_vma address, |
481 | | bfd_reloc_code_real_type reloc, |
482 | | struct bfd_symbol ** sym, |
483 | | unsigned int sym_index) |
484 | 12.7k | { |
485 | 12.7k | arelent * entry; |
486 | 12.7k | struct internal_reloc * internal; |
487 | | |
488 | 12.7k | entry = vars->reltab + vars->relcount; |
489 | 12.7k | internal = vars->int_reltab + vars->relcount; |
490 | | |
491 | 12.7k | entry->address = address; |
492 | 12.7k | entry->addend = 0; |
493 | 12.7k | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); |
494 | 12.7k | entry->sym_ptr_ptr = sym; |
495 | | |
496 | 12.7k | internal->r_vaddr = address; |
497 | 12.7k | internal->r_symndx = sym_index; |
498 | 12.7k | internal->r_type = entry->howto ? entry->howto->type : 0; |
499 | | |
500 | 12.7k | vars->relcount ++; |
501 | | |
502 | 12.7k | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); |
503 | 12.7k | } pei-i386.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 484 | 2.75k | { | 485 | 2.75k | arelent * entry; | 486 | 2.75k | struct internal_reloc * internal; | 487 | | | 488 | 2.75k | entry = vars->reltab + vars->relcount; | 489 | 2.75k | internal = vars->int_reltab + vars->relcount; | 490 | | | 491 | 2.75k | entry->address = address; | 492 | 2.75k | entry->addend = 0; | 493 | 2.75k | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 494 | 2.75k | entry->sym_ptr_ptr = sym; | 495 | | | 496 | 2.75k | internal->r_vaddr = address; | 497 | 2.75k | internal->r_symndx = sym_index; | 498 | 2.75k | internal->r_type = entry->howto ? entry->howto->type : 0; | 499 | | | 500 | 2.75k | vars->relcount ++; | 501 | | | 502 | 2.75k | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 503 | 2.75k | } |
pei-x86_64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 484 | 1.93k | { | 485 | 1.93k | arelent * entry; | 486 | 1.93k | struct internal_reloc * internal; | 487 | | | 488 | 1.93k | entry = vars->reltab + vars->relcount; | 489 | 1.93k | internal = vars->int_reltab + vars->relcount; | 490 | | | 491 | 1.93k | entry->address = address; | 492 | 1.93k | entry->addend = 0; | 493 | 1.93k | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 494 | 1.93k | entry->sym_ptr_ptr = sym; | 495 | | | 496 | 1.93k | internal->r_vaddr = address; | 497 | 1.93k | internal->r_symndx = sym_index; | 498 | 1.93k | internal->r_type = entry->howto ? entry->howto->type : 0; | 499 | | | 500 | 1.93k | vars->relcount ++; | 501 | | | 502 | 1.93k | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 503 | 1.93k | } |
pei-aarch64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 484 | 1.69k | { | 485 | 1.69k | arelent * entry; | 486 | 1.69k | struct internal_reloc * internal; | 487 | | | 488 | 1.69k | entry = vars->reltab + vars->relcount; | 489 | 1.69k | internal = vars->int_reltab + vars->relcount; | 490 | | | 491 | 1.69k | entry->address = address; | 492 | 1.69k | entry->addend = 0; | 493 | 1.69k | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 494 | 1.69k | entry->sym_ptr_ptr = sym; | 495 | | | 496 | 1.69k | internal->r_vaddr = address; | 497 | 1.69k | internal->r_symndx = sym_index; | 498 | 1.69k | internal->r_type = entry->howto ? entry->howto->type : 0; | 499 | | | 500 | 1.69k | vars->relcount ++; | 501 | | | 502 | 1.69k | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 503 | 1.69k | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_symbol_reloc pei-loongarch64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 484 | 2.66k | { | 485 | 2.66k | arelent * entry; | 486 | 2.66k | struct internal_reloc * internal; | 487 | | | 488 | 2.66k | entry = vars->reltab + vars->relcount; | 489 | 2.66k | internal = vars->int_reltab + vars->relcount; | 490 | | | 491 | 2.66k | entry->address = address; | 492 | 2.66k | entry->addend = 0; | 493 | 2.66k | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 494 | 2.66k | entry->sym_ptr_ptr = sym; | 495 | | | 496 | 2.66k | internal->r_vaddr = address; | 497 | 2.66k | internal->r_symndx = sym_index; | 498 | 2.66k | internal->r_type = entry->howto ? entry->howto->type : 0; | 499 | | | 500 | 2.66k | vars->relcount ++; | 501 | | | 502 | 2.66k | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 503 | 2.66k | } |
pei-arm-wince.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 484 | 11 | { | 485 | 11 | arelent * entry; | 486 | 11 | struct internal_reloc * internal; | 487 | | | 488 | 11 | entry = vars->reltab + vars->relcount; | 489 | 11 | internal = vars->int_reltab + vars->relcount; | 490 | | | 491 | 11 | entry->address = address; | 492 | 11 | entry->addend = 0; | 493 | 11 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 494 | 11 | entry->sym_ptr_ptr = sym; | 495 | | | 496 | 11 | internal->r_vaddr = address; | 497 | 11 | internal->r_symndx = sym_index; | 498 | 11 | internal->r_type = entry->howto ? entry->howto->type : 0; | 499 | | | 500 | 11 | vars->relcount ++; | 501 | | | 502 | 11 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 503 | 11 | } |
pei-arm.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 484 | 2.99k | { | 485 | 2.99k | arelent * entry; | 486 | 2.99k | struct internal_reloc * internal; | 487 | | | 488 | 2.99k | entry = vars->reltab + vars->relcount; | 489 | 2.99k | internal = vars->int_reltab + vars->relcount; | 490 | | | 491 | 2.99k | entry->address = address; | 492 | 2.99k | entry->addend = 0; | 493 | 2.99k | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 494 | 2.99k | entry->sym_ptr_ptr = sym; | 495 | | | 496 | 2.99k | internal->r_vaddr = address; | 497 | 2.99k | internal->r_symndx = sym_index; | 498 | 2.99k | internal->r_type = entry->howto ? entry->howto->type : 0; | 499 | | | 500 | 2.99k | vars->relcount ++; | 501 | | | 502 | 2.99k | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 503 | 2.99k | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_symbol_reloc pei-sh.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 484 | 723 | { | 485 | 723 | arelent * entry; | 486 | 723 | struct internal_reloc * internal; | 487 | | | 488 | 723 | entry = vars->reltab + vars->relcount; | 489 | 723 | internal = vars->int_reltab + vars->relcount; | 490 | | | 491 | 723 | entry->address = address; | 492 | 723 | entry->addend = 0; | 493 | 723 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 494 | 723 | entry->sym_ptr_ptr = sym; | 495 | | | 496 | 723 | internal->r_vaddr = address; | 497 | 723 | internal->r_symndx = sym_index; | 498 | 723 | internal->r_type = entry->howto ? entry->howto->type : 0; | 499 | | | 500 | 723 | vars->relcount ++; | 501 | | | 502 | 723 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 503 | 723 | } |
|
504 | | |
505 | | /* Create an empty relocation against the given section. */ |
506 | | |
507 | | static void |
508 | | pe_ILF_make_a_reloc (pe_ILF_vars * vars, |
509 | | bfd_vma address, |
510 | | bfd_reloc_code_real_type reloc, |
511 | | asection_ptr sec) |
512 | 8.72k | { |
513 | 8.72k | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, |
514 | 8.72k | coff_section_data (vars->abfd, sec)->i); |
515 | 8.72k | } pei-i386.c:pe_ILF_make_a_reloc Line | Count | Source | 512 | 1.61k | { | 513 | 1.61k | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 514 | 1.61k | coff_section_data (vars->abfd, sec)->i); | 515 | 1.61k | } |
pei-x86_64.c:pe_ILF_make_a_reloc Line | Count | Source | 512 | 1.13k | { | 513 | 1.13k | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 514 | 1.13k | coff_section_data (vars->abfd, sec)->i); | 515 | 1.13k | } |
pei-aarch64.c:pe_ILF_make_a_reloc Line | Count | Source | 512 | 1.46k | { | 513 | 1.46k | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 514 | 1.46k | coff_section_data (vars->abfd, sec)->i); | 515 | 1.46k | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_reloc pei-loongarch64.c:pe_ILF_make_a_reloc Line | Count | Source | 512 | 1.73k | { | 513 | 1.73k | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 514 | 1.73k | coff_section_data (vars->abfd, sec)->i); | 515 | 1.73k | } |
pei-arm-wince.c:pe_ILF_make_a_reloc Line | Count | Source | 512 | 8 | { | 513 | 8 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 514 | 8 | coff_section_data (vars->abfd, sec)->i); | 515 | 8 | } |
pei-arm.c:pe_ILF_make_a_reloc Line | Count | Source | 512 | 2.29k | { | 513 | 2.29k | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 514 | 2.29k | coff_section_data (vars->abfd, sec)->i); | 515 | 2.29k | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_reloc pei-sh.c:pe_ILF_make_a_reloc Line | Count | Source | 512 | 484 | { | 513 | 484 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 514 | 484 | coff_section_data (vars->abfd, sec)->i); | 515 | 484 | } |
|
516 | | |
517 | | /* Move the queued relocs into the given section. */ |
518 | | |
519 | | static void |
520 | | pe_ILF_save_relocs (pe_ILF_vars * vars, |
521 | | asection_ptr sec) |
522 | 12.7k | { |
523 | | /* Make sure that there is somewhere to store the internal relocs. */ |
524 | 12.7k | if (coff_section_data (vars->abfd, sec) == NULL) |
525 | | /* We should probably return an error indication here. */ |
526 | 0 | abort (); |
527 | | |
528 | 12.7k | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; |
529 | | |
530 | 12.7k | sec->relocation = vars->reltab; |
531 | 12.7k | sec->reloc_count = vars->relcount; |
532 | 12.7k | sec->flags |= SEC_RELOC; |
533 | | |
534 | 12.7k | vars->reltab += vars->relcount; |
535 | 12.7k | vars->int_reltab += vars->relcount; |
536 | 12.7k | vars->relcount = 0; |
537 | | |
538 | 12.7k | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); |
539 | 12.7k | } pei-i386.c:pe_ILF_save_relocs Line | Count | Source | 522 | 2.75k | { | 523 | | /* Make sure that there is somewhere to store the internal relocs. */ | 524 | 2.75k | if (coff_section_data (vars->abfd, sec) == NULL) | 525 | | /* We should probably return an error indication here. */ | 526 | 0 | abort (); | 527 | | | 528 | 2.75k | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 529 | | | 530 | 2.75k | sec->relocation = vars->reltab; | 531 | 2.75k | sec->reloc_count = vars->relcount; | 532 | 2.75k | sec->flags |= SEC_RELOC; | 533 | | | 534 | 2.75k | vars->reltab += vars->relcount; | 535 | 2.75k | vars->int_reltab += vars->relcount; | 536 | 2.75k | vars->relcount = 0; | 537 | | | 538 | 2.75k | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 539 | 2.75k | } |
pei-x86_64.c:pe_ILF_save_relocs Line | Count | Source | 522 | 1.93k | { | 523 | | /* Make sure that there is somewhere to store the internal relocs. */ | 524 | 1.93k | if (coff_section_data (vars->abfd, sec) == NULL) | 525 | | /* We should probably return an error indication here. */ | 526 | 0 | abort (); | 527 | | | 528 | 1.93k | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 529 | | | 530 | 1.93k | sec->relocation = vars->reltab; | 531 | 1.93k | sec->reloc_count = vars->relcount; | 532 | 1.93k | sec->flags |= SEC_RELOC; | 533 | | | 534 | 1.93k | vars->reltab += vars->relcount; | 535 | 1.93k | vars->int_reltab += vars->relcount; | 536 | 1.93k | vars->relcount = 0; | 537 | | | 538 | 1.93k | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 539 | 1.93k | } |
pei-aarch64.c:pe_ILF_save_relocs Line | Count | Source | 522 | 1.69k | { | 523 | | /* Make sure that there is somewhere to store the internal relocs. */ | 524 | 1.69k | if (coff_section_data (vars->abfd, sec) == NULL) | 525 | | /* We should probably return an error indication here. */ | 526 | 0 | abort (); | 527 | | | 528 | 1.69k | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 529 | | | 530 | 1.69k | sec->relocation = vars->reltab; | 531 | 1.69k | sec->reloc_count = vars->relcount; | 532 | 1.69k | sec->flags |= SEC_RELOC; | 533 | | | 534 | 1.69k | vars->reltab += vars->relcount; | 535 | 1.69k | vars->int_reltab += vars->relcount; | 536 | 1.69k | vars->relcount = 0; | 537 | | | 538 | 1.69k | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 539 | 1.69k | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_save_relocs pei-loongarch64.c:pe_ILF_save_relocs Line | Count | Source | 522 | 2.66k | { | 523 | | /* Make sure that there is somewhere to store the internal relocs. */ | 524 | 2.66k | if (coff_section_data (vars->abfd, sec) == NULL) | 525 | | /* We should probably return an error indication here. */ | 526 | 0 | abort (); | 527 | | | 528 | 2.66k | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 529 | | | 530 | 2.66k | sec->relocation = vars->reltab; | 531 | 2.66k | sec->reloc_count = vars->relcount; | 532 | 2.66k | sec->flags |= SEC_RELOC; | 533 | | | 534 | 2.66k | vars->reltab += vars->relcount; | 535 | 2.66k | vars->int_reltab += vars->relcount; | 536 | 2.66k | vars->relcount = 0; | 537 | | | 538 | 2.66k | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 539 | 2.66k | } |
pei-arm-wince.c:pe_ILF_save_relocs Line | Count | Source | 522 | 11 | { | 523 | | /* Make sure that there is somewhere to store the internal relocs. */ | 524 | 11 | if (coff_section_data (vars->abfd, sec) == NULL) | 525 | | /* We should probably return an error indication here. */ | 526 | 0 | abort (); | 527 | | | 528 | 11 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 529 | | | 530 | 11 | sec->relocation = vars->reltab; | 531 | 11 | sec->reloc_count = vars->relcount; | 532 | 11 | sec->flags |= SEC_RELOC; | 533 | | | 534 | 11 | vars->reltab += vars->relcount; | 535 | 11 | vars->int_reltab += vars->relcount; | 536 | 11 | vars->relcount = 0; | 537 | | | 538 | 11 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 539 | 11 | } |
pei-arm.c:pe_ILF_save_relocs Line | Count | Source | 522 | 2.99k | { | 523 | | /* Make sure that there is somewhere to store the internal relocs. */ | 524 | 2.99k | if (coff_section_data (vars->abfd, sec) == NULL) | 525 | | /* We should probably return an error indication here. */ | 526 | 0 | abort (); | 527 | | | 528 | 2.99k | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 529 | | | 530 | 2.99k | sec->relocation = vars->reltab; | 531 | 2.99k | sec->reloc_count = vars->relcount; | 532 | 2.99k | sec->flags |= SEC_RELOC; | 533 | | | 534 | 2.99k | vars->reltab += vars->relcount; | 535 | 2.99k | vars->int_reltab += vars->relcount; | 536 | 2.99k | vars->relcount = 0; | 537 | | | 538 | 2.99k | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 539 | 2.99k | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_save_relocs pei-sh.c:pe_ILF_save_relocs Line | Count | Source | 522 | 723 | { | 523 | | /* Make sure that there is somewhere to store the internal relocs. */ | 524 | 723 | if (coff_section_data (vars->abfd, sec) == NULL) | 525 | | /* We should probably return an error indication here. */ | 526 | 0 | abort (); | 527 | | | 528 | 723 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 529 | | | 530 | 723 | sec->relocation = vars->reltab; | 531 | 723 | sec->reloc_count = vars->relcount; | 532 | 723 | sec->flags |= SEC_RELOC; | 533 | | | 534 | 723 | vars->reltab += vars->relcount; | 535 | 723 | vars->int_reltab += vars->relcount; | 536 | 723 | vars->relcount = 0; | 537 | | | 538 | 723 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 539 | 723 | } |
|
540 | | |
541 | | /* Create a global symbol and add it to the relevant tables. */ |
542 | | |
543 | | static void |
544 | | pe_ILF_make_a_symbol (pe_ILF_vars * vars, |
545 | | const char * prefix, |
546 | | const char * symbol_name, |
547 | | asection_ptr section, |
548 | | flagword extra_flags) |
549 | 41.6k | { |
550 | 41.6k | coff_symbol_type * sym; |
551 | 41.6k | combined_entry_type * ent; |
552 | 41.6k | SYMENT * esym; |
553 | 41.6k | unsigned short sclass; |
554 | | |
555 | 41.6k | if (extra_flags & BSF_LOCAL) |
556 | 23.5k | sclass = C_STAT; |
557 | 18.1k | else |
558 | 18.1k | sclass = C_EXT; |
559 | | |
560 | | #ifdef THUMBPEMAGIC |
561 | 9.47k | if (vars->magic == THUMBPEMAGIC) |
562 | 1.19k | { |
563 | 1.19k | if (extra_flags & BSF_FUNCTION) |
564 | 1 | sclass = C_THUMBEXTFUNC; |
565 | 1.19k | else if (extra_flags & BSF_LOCAL) |
566 | 716 | sclass = C_THUMBSTAT; |
567 | 478 | else |
568 | 478 | sclass = C_THUMBEXT; |
569 | 1.19k | } |
570 | | #endif |
571 | | |
572 | 41.6k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); |
573 | | |
574 | 41.6k | sym = vars->sym_ptr; |
575 | 41.6k | ent = vars->native_ptr; |
576 | 41.6k | esym = vars->esym_ptr; |
577 | | |
578 | | /* Copy the symbol's name into the string table. */ |
579 | 41.6k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); |
580 | | |
581 | 41.6k | if (section == NULL) |
582 | 7.02k | section = bfd_und_section_ptr; |
583 | | |
584 | | /* Initialise the external symbol. */ |
585 | 41.6k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, |
586 | 41.6k | esym->e.e.e_offset); |
587 | 41.6k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); |
588 | 41.6k | esym->e_sclass[0] = sclass; |
589 | | |
590 | | /* The following initialisations are unnecessary - the memory is |
591 | | zero initialised. They are just kept here as reminders. */ |
592 | | |
593 | | /* Initialise the internal symbol structure. */ |
594 | 41.6k | ent->u.syment.n_sclass = sclass; |
595 | 41.6k | ent->u.syment.n_scnum = section->target_index; |
596 | 41.6k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; |
597 | 41.6k | ent->is_sym = true; |
598 | | |
599 | 41.6k | sym->symbol.the_bfd = vars->abfd; |
600 | 41.6k | sym->symbol.name = vars->string_ptr; |
601 | 41.6k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; |
602 | 41.6k | sym->symbol.section = section; |
603 | 41.6k | sym->native = ent; |
604 | | |
605 | 41.6k | * vars->table_ptr = vars->sym_index; |
606 | 41.6k | * vars->sym_ptr_ptr = sym; |
607 | | |
608 | | /* Adjust pointers for the next symbol. */ |
609 | 41.6k | vars->sym_index ++; |
610 | 41.6k | vars->sym_ptr ++; |
611 | 41.6k | vars->sym_ptr_ptr ++; |
612 | 41.6k | vars->table_ptr ++; |
613 | 41.6k | vars->native_ptr ++; |
614 | 41.6k | vars->esym_ptr ++; |
615 | 41.6k | vars->string_ptr += len + 1; |
616 | | |
617 | 41.6k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); |
618 | 41.6k | } pei-i386.c:pe_ILF_make_a_symbol Line | Count | Source | 549 | 8.49k | { | 550 | 8.49k | coff_symbol_type * sym; | 551 | 8.49k | combined_entry_type * ent; | 552 | 8.49k | SYMENT * esym; | 553 | 8.49k | unsigned short sclass; | 554 | | | 555 | 8.49k | if (extra_flags & BSF_LOCAL) | 556 | 4.85k | sclass = C_STAT; | 557 | 3.63k | else | 558 | 3.63k | sclass = C_EXT; | 559 | | | 560 | | #ifdef THUMBPEMAGIC | 561 | | if (vars->magic == THUMBPEMAGIC) | 562 | | { | 563 | | if (extra_flags & BSF_FUNCTION) | 564 | | sclass = C_THUMBEXTFUNC; | 565 | | else if (extra_flags & BSF_LOCAL) | 566 | | sclass = C_THUMBSTAT; | 567 | | else | 568 | | sclass = C_THUMBEXT; | 569 | | } | 570 | | #endif | 571 | | | 572 | 8.49k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 573 | | | 574 | 8.49k | sym = vars->sym_ptr; | 575 | 8.49k | ent = vars->native_ptr; | 576 | 8.49k | esym = vars->esym_ptr; | 577 | | | 578 | | /* Copy the symbol's name into the string table. */ | 579 | 8.49k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 580 | | | 581 | 8.49k | if (section == NULL) | 582 | 1.24k | section = bfd_und_section_ptr; | 583 | | | 584 | | /* Initialise the external symbol. */ | 585 | 8.49k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 586 | 8.49k | esym->e.e.e_offset); | 587 | 8.49k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 588 | 8.49k | esym->e_sclass[0] = sclass; | 589 | | | 590 | | /* The following initialisations are unnecessary - the memory is | 591 | | zero initialised. They are just kept here as reminders. */ | 592 | | | 593 | | /* Initialise the internal symbol structure. */ | 594 | 8.49k | ent->u.syment.n_sclass = sclass; | 595 | 8.49k | ent->u.syment.n_scnum = section->target_index; | 596 | 8.49k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 597 | 8.49k | ent->is_sym = true; | 598 | | | 599 | 8.49k | sym->symbol.the_bfd = vars->abfd; | 600 | 8.49k | sym->symbol.name = vars->string_ptr; | 601 | 8.49k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 602 | 8.49k | sym->symbol.section = section; | 603 | 8.49k | sym->native = ent; | 604 | | | 605 | 8.49k | * vars->table_ptr = vars->sym_index; | 606 | 8.49k | * vars->sym_ptr_ptr = sym; | 607 | | | 608 | | /* Adjust pointers for the next symbol. */ | 609 | 8.49k | vars->sym_index ++; | 610 | 8.49k | vars->sym_ptr ++; | 611 | 8.49k | vars->sym_ptr_ptr ++; | 612 | 8.49k | vars->table_ptr ++; | 613 | 8.49k | vars->native_ptr ++; | 614 | 8.49k | vars->esym_ptr ++; | 615 | 8.49k | vars->string_ptr += len + 1; | 616 | | | 617 | 8.49k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 618 | 8.49k | } |
pei-x86_64.c:pe_ILF_make_a_symbol Line | Count | Source | 549 | 7.45k | { | 550 | 7.45k | coff_symbol_type * sym; | 551 | 7.45k | combined_entry_type * ent; | 552 | 7.45k | SYMENT * esym; | 553 | 7.45k | unsigned short sclass; | 554 | | | 555 | 7.45k | if (extra_flags & BSF_LOCAL) | 556 | 4.11k | sclass = C_STAT; | 557 | 3.34k | else | 558 | 3.34k | sclass = C_EXT; | 559 | | | 560 | | #ifdef THUMBPEMAGIC | 561 | | if (vars->magic == THUMBPEMAGIC) | 562 | | { | 563 | | if (extra_flags & BSF_FUNCTION) | 564 | | sclass = C_THUMBEXTFUNC; | 565 | | else if (extra_flags & BSF_LOCAL) | 566 | | sclass = C_THUMBSTAT; | 567 | | else | 568 | | sclass = C_THUMBEXT; | 569 | | } | 570 | | #endif | 571 | | | 572 | 7.45k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 573 | | | 574 | 7.45k | sym = vars->sym_ptr; | 575 | 7.45k | ent = vars->native_ptr; | 576 | 7.45k | esym = vars->esym_ptr; | 577 | | | 578 | | /* Copy the symbol's name into the string table. */ | 579 | 7.45k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 580 | | | 581 | 7.45k | if (section == NULL) | 582 | 1.26k | section = bfd_und_section_ptr; | 583 | | | 584 | | /* Initialise the external symbol. */ | 585 | 7.45k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 586 | 7.45k | esym->e.e.e_offset); | 587 | 7.45k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 588 | 7.45k | esym->e_sclass[0] = sclass; | 589 | | | 590 | | /* The following initialisations are unnecessary - the memory is | 591 | | zero initialised. They are just kept here as reminders. */ | 592 | | | 593 | | /* Initialise the internal symbol structure. */ | 594 | 7.45k | ent->u.syment.n_sclass = sclass; | 595 | 7.45k | ent->u.syment.n_scnum = section->target_index; | 596 | 7.45k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 597 | 7.45k | ent->is_sym = true; | 598 | | | 599 | 7.45k | sym->symbol.the_bfd = vars->abfd; | 600 | 7.45k | sym->symbol.name = vars->string_ptr; | 601 | 7.45k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 602 | 7.45k | sym->symbol.section = section; | 603 | 7.45k | sym->native = ent; | 604 | | | 605 | 7.45k | * vars->table_ptr = vars->sym_index; | 606 | 7.45k | * vars->sym_ptr_ptr = sym; | 607 | | | 608 | | /* Adjust pointers for the next symbol. */ | 609 | 7.45k | vars->sym_index ++; | 610 | 7.45k | vars->sym_ptr ++; | 611 | 7.45k | vars->sym_ptr_ptr ++; | 612 | 7.45k | vars->table_ptr ++; | 613 | 7.45k | vars->native_ptr ++; | 614 | 7.45k | vars->esym_ptr ++; | 615 | 7.45k | vars->string_ptr += len + 1; | 616 | | | 617 | 7.45k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 618 | 7.45k | } |
pei-aarch64.c:pe_ILF_make_a_symbol Line | Count | Source | 549 | 5.07k | { | 550 | 5.07k | coff_symbol_type * sym; | 551 | 5.07k | combined_entry_type * ent; | 552 | 5.07k | SYMENT * esym; | 553 | 5.07k | unsigned short sclass; | 554 | | | 555 | 5.07k | if (extra_flags & BSF_LOCAL) | 556 | 2.90k | sclass = C_STAT; | 557 | 2.16k | else | 558 | 2.16k | sclass = C_EXT; | 559 | | | 560 | | #ifdef THUMBPEMAGIC | 561 | | if (vars->magic == THUMBPEMAGIC) | 562 | | { | 563 | | if (extra_flags & BSF_FUNCTION) | 564 | | sclass = C_THUMBEXTFUNC; | 565 | | else if (extra_flags & BSF_LOCAL) | 566 | | sclass = C_THUMBSTAT; | 567 | | else | 568 | | sclass = C_THUMBEXT; | 569 | | } | 570 | | #endif | 571 | | | 572 | 5.07k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 573 | | | 574 | 5.07k | sym = vars->sym_ptr; | 575 | 5.07k | ent = vars->native_ptr; | 576 | 5.07k | esym = vars->esym_ptr; | 577 | | | 578 | | /* Copy the symbol's name into the string table. */ | 579 | 5.07k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 580 | | | 581 | 5.07k | if (section == NULL) | 582 | 967 | section = bfd_und_section_ptr; | 583 | | | 584 | | /* Initialise the external symbol. */ | 585 | 5.07k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 586 | 5.07k | esym->e.e.e_offset); | 587 | 5.07k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 588 | 5.07k | esym->e_sclass[0] = sclass; | 589 | | | 590 | | /* The following initialisations are unnecessary - the memory is | 591 | | zero initialised. They are just kept here as reminders. */ | 592 | | | 593 | | /* Initialise the internal symbol structure. */ | 594 | 5.07k | ent->u.syment.n_sclass = sclass; | 595 | 5.07k | ent->u.syment.n_scnum = section->target_index; | 596 | 5.07k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 597 | 5.07k | ent->is_sym = true; | 598 | | | 599 | 5.07k | sym->symbol.the_bfd = vars->abfd; | 600 | 5.07k | sym->symbol.name = vars->string_ptr; | 601 | 5.07k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 602 | 5.07k | sym->symbol.section = section; | 603 | 5.07k | sym->native = ent; | 604 | | | 605 | 5.07k | * vars->table_ptr = vars->sym_index; | 606 | 5.07k | * vars->sym_ptr_ptr = sym; | 607 | | | 608 | | /* Adjust pointers for the next symbol. */ | 609 | 5.07k | vars->sym_index ++; | 610 | 5.07k | vars->sym_ptr ++; | 611 | 5.07k | vars->sym_ptr_ptr ++; | 612 | 5.07k | vars->table_ptr ++; | 613 | 5.07k | vars->native_ptr ++; | 614 | 5.07k | vars->esym_ptr ++; | 615 | 5.07k | vars->string_ptr += len + 1; | 616 | | | 617 | 5.07k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 618 | 5.07k | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_symbol pei-loongarch64.c:pe_ILF_make_a_symbol Line | Count | Source | 549 | 8.47k | { | 550 | 8.47k | coff_symbol_type * sym; | 551 | 8.47k | combined_entry_type * ent; | 552 | 8.47k | SYMENT * esym; | 553 | 8.47k | unsigned short sclass; | 554 | | | 555 | 8.47k | if (extra_flags & BSF_LOCAL) | 556 | 4.67k | sclass = C_STAT; | 557 | 3.80k | else | 558 | 3.80k | sclass = C_EXT; | 559 | | | 560 | | #ifdef THUMBPEMAGIC | 561 | | if (vars->magic == THUMBPEMAGIC) | 562 | | { | 563 | | if (extra_flags & BSF_FUNCTION) | 564 | | sclass = C_THUMBEXTFUNC; | 565 | | else if (extra_flags & BSF_LOCAL) | 566 | | sclass = C_THUMBSTAT; | 567 | | else | 568 | | sclass = C_THUMBEXT; | 569 | | } | 570 | | #endif | 571 | | | 572 | 8.47k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 573 | | | 574 | 8.47k | sym = vars->sym_ptr; | 575 | 8.47k | ent = vars->native_ptr; | 576 | 8.47k | esym = vars->esym_ptr; | 577 | | | 578 | | /* Copy the symbol's name into the string table. */ | 579 | 8.47k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 580 | | | 581 | 8.47k | if (section == NULL) | 582 | 1.43k | section = bfd_und_section_ptr; | 583 | | | 584 | | /* Initialise the external symbol. */ | 585 | 8.47k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 586 | 8.47k | esym->e.e.e_offset); | 587 | 8.47k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 588 | 8.47k | esym->e_sclass[0] = sclass; | 589 | | | 590 | | /* The following initialisations are unnecessary - the memory is | 591 | | zero initialised. They are just kept here as reminders. */ | 592 | | | 593 | | /* Initialise the internal symbol structure. */ | 594 | 8.47k | ent->u.syment.n_sclass = sclass; | 595 | 8.47k | ent->u.syment.n_scnum = section->target_index; | 596 | 8.47k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 597 | 8.47k | ent->is_sym = true; | 598 | | | 599 | 8.47k | sym->symbol.the_bfd = vars->abfd; | 600 | 8.47k | sym->symbol.name = vars->string_ptr; | 601 | 8.47k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 602 | 8.47k | sym->symbol.section = section; | 603 | 8.47k | sym->native = ent; | 604 | | | 605 | 8.47k | * vars->table_ptr = vars->sym_index; | 606 | 8.47k | * vars->sym_ptr_ptr = sym; | 607 | | | 608 | | /* Adjust pointers for the next symbol. */ | 609 | 8.47k | vars->sym_index ++; | 610 | 8.47k | vars->sym_ptr ++; | 611 | 8.47k | vars->sym_ptr_ptr ++; | 612 | 8.47k | vars->table_ptr ++; | 613 | 8.47k | vars->native_ptr ++; | 614 | 8.47k | vars->esym_ptr ++; | 615 | 8.47k | vars->string_ptr += len + 1; | 616 | | | 617 | 8.47k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 618 | 8.47k | } |
pei-arm-wince.c:pe_ILF_make_a_symbol Line | Count | Source | 549 | 236 | { | 550 | 236 | coff_symbol_type * sym; | 551 | 236 | combined_entry_type * ent; | 552 | 236 | SYMENT * esym; | 553 | 236 | unsigned short sclass; | 554 | | | 555 | 236 | if (extra_flags & BSF_LOCAL) | 556 | 221 | sclass = C_STAT; | 557 | 15 | else | 558 | 15 | sclass = C_EXT; | 559 | | | 560 | 236 | #ifdef THUMBPEMAGIC | 561 | 236 | if (vars->magic == THUMBPEMAGIC) | 562 | 5 | { | 563 | 5 | if (extra_flags & BSF_FUNCTION) | 564 | 0 | sclass = C_THUMBEXTFUNC; | 565 | 5 | else if (extra_flags & BSF_LOCAL) | 566 | 3 | sclass = C_THUMBSTAT; | 567 | 2 | else | 568 | 2 | sclass = C_THUMBEXT; | 569 | 5 | } | 570 | 236 | #endif | 571 | | | 572 | 236 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 573 | | | 574 | 236 | sym = vars->sym_ptr; | 575 | 236 | ent = vars->native_ptr; | 576 | 236 | esym = vars->esym_ptr; | 577 | | | 578 | | /* Copy the symbol's name into the string table. */ | 579 | 236 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 580 | | | 581 | 236 | if (section == NULL) | 582 | 6 | section = bfd_und_section_ptr; | 583 | | | 584 | | /* Initialise the external symbol. */ | 585 | 236 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 586 | 236 | esym->e.e.e_offset); | 587 | 236 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 588 | 236 | esym->e_sclass[0] = sclass; | 589 | | | 590 | | /* The following initialisations are unnecessary - the memory is | 591 | | zero initialised. They are just kept here as reminders. */ | 592 | | | 593 | | /* Initialise the internal symbol structure. */ | 594 | 236 | ent->u.syment.n_sclass = sclass; | 595 | 236 | ent->u.syment.n_scnum = section->target_index; | 596 | 236 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 597 | 236 | ent->is_sym = true; | 598 | | | 599 | 236 | sym->symbol.the_bfd = vars->abfd; | 600 | 236 | sym->symbol.name = vars->string_ptr; | 601 | 236 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 602 | 236 | sym->symbol.section = section; | 603 | 236 | sym->native = ent; | 604 | | | 605 | 236 | * vars->table_ptr = vars->sym_index; | 606 | 236 | * vars->sym_ptr_ptr = sym; | 607 | | | 608 | | /* Adjust pointers for the next symbol. */ | 609 | 236 | vars->sym_index ++; | 610 | 236 | vars->sym_ptr ++; | 611 | 236 | vars->sym_ptr_ptr ++; | 612 | 236 | vars->table_ptr ++; | 613 | 236 | vars->native_ptr ++; | 614 | 236 | vars->esym_ptr ++; | 615 | 236 | vars->string_ptr += len + 1; | 616 | | | 617 | 236 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 618 | 236 | } |
pei-arm.c:pe_ILF_make_a_symbol Line | Count | Source | 549 | 9.23k | { | 550 | 9.23k | coff_symbol_type * sym; | 551 | 9.23k | combined_entry_type * ent; | 552 | 9.23k | SYMENT * esym; | 553 | 9.23k | unsigned short sclass; | 554 | | | 555 | 9.23k | if (extra_flags & BSF_LOCAL) | 556 | 5.29k | sclass = C_STAT; | 557 | 3.94k | else | 558 | 3.94k | sclass = C_EXT; | 559 | | | 560 | 9.23k | #ifdef THUMBPEMAGIC | 561 | 9.23k | if (vars->magic == THUMBPEMAGIC) | 562 | 1.19k | { | 563 | 1.19k | if (extra_flags & BSF_FUNCTION) | 564 | 1 | sclass = C_THUMBEXTFUNC; | 565 | 1.18k | else if (extra_flags & BSF_LOCAL) | 566 | 713 | sclass = C_THUMBSTAT; | 567 | 476 | else | 568 | 476 | sclass = C_THUMBEXT; | 569 | 1.19k | } | 570 | 9.23k | #endif | 571 | | | 572 | 9.23k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 573 | | | 574 | 9.23k | sym = vars->sym_ptr; | 575 | 9.23k | ent = vars->native_ptr; | 576 | 9.23k | esym = vars->esym_ptr; | 577 | | | 578 | | /* Copy the symbol's name into the string table. */ | 579 | 9.23k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 580 | | | 581 | 9.23k | if (section == NULL) | 582 | 1.61k | section = bfd_und_section_ptr; | 583 | | | 584 | | /* Initialise the external symbol. */ | 585 | 9.23k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 586 | 9.23k | esym->e.e.e_offset); | 587 | 9.23k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 588 | 9.23k | esym->e_sclass[0] = sclass; | 589 | | | 590 | | /* The following initialisations are unnecessary - the memory is | 591 | | zero initialised. They are just kept here as reminders. */ | 592 | | | 593 | | /* Initialise the internal symbol structure. */ | 594 | 9.23k | ent->u.syment.n_sclass = sclass; | 595 | 9.23k | ent->u.syment.n_scnum = section->target_index; | 596 | 9.23k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 597 | 9.23k | ent->is_sym = true; | 598 | | | 599 | 9.23k | sym->symbol.the_bfd = vars->abfd; | 600 | 9.23k | sym->symbol.name = vars->string_ptr; | 601 | 9.23k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 602 | 9.23k | sym->symbol.section = section; | 603 | 9.23k | sym->native = ent; | 604 | | | 605 | 9.23k | * vars->table_ptr = vars->sym_index; | 606 | 9.23k | * vars->sym_ptr_ptr = sym; | 607 | | | 608 | | /* Adjust pointers for the next symbol. */ | 609 | 9.23k | vars->sym_index ++; | 610 | 9.23k | vars->sym_ptr ++; | 611 | 9.23k | vars->sym_ptr_ptr ++; | 612 | 9.23k | vars->table_ptr ++; | 613 | 9.23k | vars->native_ptr ++; | 614 | 9.23k | vars->esym_ptr ++; | 615 | 9.23k | vars->string_ptr += len + 1; | 616 | | | 617 | 9.23k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 618 | 9.23k | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_symbol pei-sh.c:pe_ILF_make_a_symbol Line | Count | Source | 549 | 2.64k | { | 550 | 2.64k | coff_symbol_type * sym; | 551 | 2.64k | combined_entry_type * ent; | 552 | 2.64k | SYMENT * esym; | 553 | 2.64k | unsigned short sclass; | 554 | | | 555 | 2.64k | if (extra_flags & BSF_LOCAL) | 556 | 1.44k | sclass = C_STAT; | 557 | 1.19k | else | 558 | 1.19k | sclass = C_EXT; | 559 | | | 560 | | #ifdef THUMBPEMAGIC | 561 | | if (vars->magic == THUMBPEMAGIC) | 562 | | { | 563 | | if (extra_flags & BSF_FUNCTION) | 564 | | sclass = C_THUMBEXTFUNC; | 565 | | else if (extra_flags & BSF_LOCAL) | 566 | | sclass = C_THUMBSTAT; | 567 | | else | 568 | | sclass = C_THUMBEXT; | 569 | | } | 570 | | #endif | 571 | | | 572 | 2.64k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 573 | | | 574 | 2.64k | sym = vars->sym_ptr; | 575 | 2.64k | ent = vars->native_ptr; | 576 | 2.64k | esym = vars->esym_ptr; | 577 | | | 578 | | /* Copy the symbol's name into the string table. */ | 579 | 2.64k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 580 | | | 581 | 2.64k | if (section == NULL) | 582 | 479 | section = bfd_und_section_ptr; | 583 | | | 584 | | /* Initialise the external symbol. */ | 585 | 2.64k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 586 | 2.64k | esym->e.e.e_offset); | 587 | 2.64k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 588 | 2.64k | esym->e_sclass[0] = sclass; | 589 | | | 590 | | /* The following initialisations are unnecessary - the memory is | 591 | | zero initialised. They are just kept here as reminders. */ | 592 | | | 593 | | /* Initialise the internal symbol structure. */ | 594 | 2.64k | ent->u.syment.n_sclass = sclass; | 595 | 2.64k | ent->u.syment.n_scnum = section->target_index; | 596 | 2.64k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 597 | 2.64k | ent->is_sym = true; | 598 | | | 599 | 2.64k | sym->symbol.the_bfd = vars->abfd; | 600 | 2.64k | sym->symbol.name = vars->string_ptr; | 601 | 2.64k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 602 | 2.64k | sym->symbol.section = section; | 603 | 2.64k | sym->native = ent; | 604 | | | 605 | 2.64k | * vars->table_ptr = vars->sym_index; | 606 | 2.64k | * vars->sym_ptr_ptr = sym; | 607 | | | 608 | | /* Adjust pointers for the next symbol. */ | 609 | 2.64k | vars->sym_index ++; | 610 | 2.64k | vars->sym_ptr ++; | 611 | 2.64k | vars->sym_ptr_ptr ++; | 612 | 2.64k | vars->table_ptr ++; | 613 | 2.64k | vars->native_ptr ++; | 614 | 2.64k | vars->esym_ptr ++; | 615 | 2.64k | vars->string_ptr += len + 1; | 616 | | | 617 | 2.64k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 618 | 2.64k | } |
|
619 | | |
620 | | /* Create a section. */ |
621 | | |
622 | | static asection_ptr |
623 | | pe_ILF_make_a_section (pe_ILF_vars * vars, |
624 | | const char * name, |
625 | | unsigned int size, |
626 | | flagword extra_flags) |
627 | 23.5k | { |
628 | 23.5k | asection_ptr sec; |
629 | 23.5k | flagword flags; |
630 | 23.5k | intptr_t alignment; |
631 | | |
632 | 23.5k | sec = bfd_make_section_old_way (vars->abfd, name); |
633 | 23.5k | if (sec == NULL) |
634 | 0 | return NULL; |
635 | | |
636 | 23.5k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; |
637 | | |
638 | 23.5k | bfd_set_section_flags (sec, flags | extra_flags); |
639 | | |
640 | 23.5k | bfd_set_section_alignment (sec, 2); |
641 | | |
642 | | /* Check that we will not run out of space. */ |
643 | 23.5k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); |
644 | | |
645 | | /* Set the section size and contents. The actual |
646 | | contents are filled in by our parent. */ |
647 | 23.5k | bfd_set_section_size (sec, (bfd_size_type) size); |
648 | 23.5k | sec->contents = vars->data; |
649 | 23.5k | sec->target_index = vars->sec_index ++; |
650 | | |
651 | | /* Advance data pointer in the vars structure. */ |
652 | 23.5k | vars->data += size; |
653 | | |
654 | | /* Skip the padding byte if it was not needed. |
655 | | The logic here is that if the string length is odd, |
656 | | then the entire string length, including the null byte, |
657 | | is even and so the extra, padding byte, is not needed. */ |
658 | 23.5k | if (size & 1) |
659 | 1.82k | vars->data --; |
660 | | |
661 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we |
662 | | preserve host alignment requirements. The BFD_ASSERTs in this |
663 | | functions will warn us if we run out of room, but we should |
664 | | already have enough padding built in to ILF_DATA_SIZE. */ |
665 | 23.5k | #if GCC_VERSION >= 3000 |
666 | 23.5k | alignment = __alignof__ (struct coff_section_tdata); |
667 | | #else |
668 | | alignment = 8; |
669 | | #endif |
670 | 23.5k | vars->data |
671 | 23.5k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); |
672 | | |
673 | | /* Create a coff_section_tdata structure for our use. */ |
674 | 23.5k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; |
675 | 23.5k | vars->data += sizeof (struct coff_section_tdata); |
676 | | |
677 | 23.5k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); |
678 | | |
679 | | /* Create a symbol to refer to this section. */ |
680 | 23.5k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); |
681 | | |
682 | | /* Cache the index to the symbol in the coff_section_data structure. */ |
683 | 23.5k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; |
684 | | |
685 | 23.5k | return sec; |
686 | 23.5k | } pei-i386.c:pe_ILF_make_a_section Line | Count | Source | 627 | 4.85k | { | 628 | 4.85k | asection_ptr sec; | 629 | 4.85k | flagword flags; | 630 | 4.85k | intptr_t alignment; | 631 | | | 632 | 4.85k | sec = bfd_make_section_old_way (vars->abfd, name); | 633 | 4.85k | if (sec == NULL) | 634 | 0 | return NULL; | 635 | | | 636 | 4.85k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 637 | | | 638 | 4.85k | bfd_set_section_flags (sec, flags | extra_flags); | 639 | | | 640 | 4.85k | bfd_set_section_alignment (sec, 2); | 641 | | | 642 | | /* Check that we will not run out of space. */ | 643 | 4.85k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 644 | | | 645 | | /* Set the section size and contents. The actual | 646 | | contents are filled in by our parent. */ | 647 | 4.85k | bfd_set_section_size (sec, (bfd_size_type) size); | 648 | 4.85k | sec->contents = vars->data; | 649 | 4.85k | sec->target_index = vars->sec_index ++; | 650 | | | 651 | | /* Advance data pointer in the vars structure. */ | 652 | 4.85k | vars->data += size; | 653 | | | 654 | | /* Skip the padding byte if it was not needed. | 655 | | The logic here is that if the string length is odd, | 656 | | then the entire string length, including the null byte, | 657 | | is even and so the extra, padding byte, is not needed. */ | 658 | 4.85k | if (size & 1) | 659 | 441 | vars->data --; | 660 | | | 661 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 662 | | preserve host alignment requirements. The BFD_ASSERTs in this | 663 | | functions will warn us if we run out of room, but we should | 664 | | already have enough padding built in to ILF_DATA_SIZE. */ | 665 | 4.85k | #if GCC_VERSION >= 3000 | 666 | 4.85k | alignment = __alignof__ (struct coff_section_tdata); | 667 | | #else | 668 | | alignment = 8; | 669 | | #endif | 670 | 4.85k | vars->data | 671 | 4.85k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 672 | | | 673 | | /* Create a coff_section_tdata structure for our use. */ | 674 | 4.85k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 675 | 4.85k | vars->data += sizeof (struct coff_section_tdata); | 676 | | | 677 | 4.85k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 678 | | | 679 | | /* Create a symbol to refer to this section. */ | 680 | 4.85k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 681 | | | 682 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 683 | 4.85k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 684 | | | 685 | 4.85k | return sec; | 686 | 4.85k | } |
pei-x86_64.c:pe_ILF_make_a_section Line | Count | Source | 627 | 4.11k | { | 628 | 4.11k | asection_ptr sec; | 629 | 4.11k | flagword flags; | 630 | 4.11k | intptr_t alignment; | 631 | | | 632 | 4.11k | sec = bfd_make_section_old_way (vars->abfd, name); | 633 | 4.11k | if (sec == NULL) | 634 | 0 | return NULL; | 635 | | | 636 | 4.11k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 637 | | | 638 | 4.11k | bfd_set_section_flags (sec, flags | extra_flags); | 639 | | | 640 | 4.11k | bfd_set_section_alignment (sec, 2); | 641 | | | 642 | | /* Check that we will not run out of space. */ | 643 | 4.11k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 644 | | | 645 | | /* Set the section size and contents. The actual | 646 | | contents are filled in by our parent. */ | 647 | 4.11k | bfd_set_section_size (sec, (bfd_size_type) size); | 648 | 4.11k | sec->contents = vars->data; | 649 | 4.11k | sec->target_index = vars->sec_index ++; | 650 | | | 651 | | /* Advance data pointer in the vars structure. */ | 652 | 4.11k | vars->data += size; | 653 | | | 654 | | /* Skip the padding byte if it was not needed. | 655 | | The logic here is that if the string length is odd, | 656 | | then the entire string length, including the null byte, | 657 | | is even and so the extra, padding byte, is not needed. */ | 658 | 4.11k | if (size & 1) | 659 | 102 | vars->data --; | 660 | | | 661 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 662 | | preserve host alignment requirements. The BFD_ASSERTs in this | 663 | | functions will warn us if we run out of room, but we should | 664 | | already have enough padding built in to ILF_DATA_SIZE. */ | 665 | 4.11k | #if GCC_VERSION >= 3000 | 666 | 4.11k | alignment = __alignof__ (struct coff_section_tdata); | 667 | | #else | 668 | | alignment = 8; | 669 | | #endif | 670 | 4.11k | vars->data | 671 | 4.11k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 672 | | | 673 | | /* Create a coff_section_tdata structure for our use. */ | 674 | 4.11k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 675 | 4.11k | vars->data += sizeof (struct coff_section_tdata); | 676 | | | 677 | 4.11k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 678 | | | 679 | | /* Create a symbol to refer to this section. */ | 680 | 4.11k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 681 | | | 682 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 683 | 4.11k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 684 | | | 685 | 4.11k | return sec; | 686 | 4.11k | } |
pei-aarch64.c:pe_ILF_make_a_section Line | Count | Source | 627 | 2.90k | { | 628 | 2.90k | asection_ptr sec; | 629 | 2.90k | flagword flags; | 630 | 2.90k | intptr_t alignment; | 631 | | | 632 | 2.90k | sec = bfd_make_section_old_way (vars->abfd, name); | 633 | 2.90k | if (sec == NULL) | 634 | 0 | return NULL; | 635 | | | 636 | 2.90k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 637 | | | 638 | 2.90k | bfd_set_section_flags (sec, flags | extra_flags); | 639 | | | 640 | 2.90k | bfd_set_section_alignment (sec, 2); | 641 | | | 642 | | /* Check that we will not run out of space. */ | 643 | 2.90k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 644 | | | 645 | | /* Set the section size and contents. The actual | 646 | | contents are filled in by our parent. */ | 647 | 2.90k | bfd_set_section_size (sec, (bfd_size_type) size); | 648 | 2.90k | sec->contents = vars->data; | 649 | 2.90k | sec->target_index = vars->sec_index ++; | 650 | | | 651 | | /* Advance data pointer in the vars structure. */ | 652 | 2.90k | vars->data += size; | 653 | | | 654 | | /* Skip the padding byte if it was not needed. | 655 | | The logic here is that if the string length is odd, | 656 | | then the entire string length, including the null byte, | 657 | | is even and so the extra, padding byte, is not needed. */ | 658 | 2.90k | if (size & 1) | 659 | 366 | vars->data --; | 660 | | | 661 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 662 | | preserve host alignment requirements. The BFD_ASSERTs in this | 663 | | functions will warn us if we run out of room, but we should | 664 | | already have enough padding built in to ILF_DATA_SIZE. */ | 665 | 2.90k | #if GCC_VERSION >= 3000 | 666 | 2.90k | alignment = __alignof__ (struct coff_section_tdata); | 667 | | #else | 668 | | alignment = 8; | 669 | | #endif | 670 | 2.90k | vars->data | 671 | 2.90k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 672 | | | 673 | | /* Create a coff_section_tdata structure for our use. */ | 674 | 2.90k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 675 | 2.90k | vars->data += sizeof (struct coff_section_tdata); | 676 | | | 677 | 2.90k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 678 | | | 679 | | /* Create a symbol to refer to this section. */ | 680 | 2.90k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 681 | | | 682 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 683 | 2.90k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 684 | | | 685 | 2.90k | return sec; | 686 | 2.90k | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_section pei-loongarch64.c:pe_ILF_make_a_section Line | Count | Source | 627 | 4.67k | { | 628 | 4.67k | asection_ptr sec; | 629 | 4.67k | flagword flags; | 630 | 4.67k | intptr_t alignment; | 631 | | | 632 | 4.67k | sec = bfd_make_section_old_way (vars->abfd, name); | 633 | 4.67k | if (sec == NULL) | 634 | 0 | return NULL; | 635 | | | 636 | 4.67k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 637 | | | 638 | 4.67k | bfd_set_section_flags (sec, flags | extra_flags); | 639 | | | 640 | 4.67k | bfd_set_section_alignment (sec, 2); | 641 | | | 642 | | /* Check that we will not run out of space. */ | 643 | 4.67k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 644 | | | 645 | | /* Set the section size and contents. The actual | 646 | | contents are filled in by our parent. */ | 647 | 4.67k | bfd_set_section_size (sec, (bfd_size_type) size); | 648 | 4.67k | sec->contents = vars->data; | 649 | 4.67k | sec->target_index = vars->sec_index ++; | 650 | | | 651 | | /* Advance data pointer in the vars structure. */ | 652 | 4.67k | vars->data += size; | 653 | | | 654 | | /* Skip the padding byte if it was not needed. | 655 | | The logic here is that if the string length is odd, | 656 | | then the entire string length, including the null byte, | 657 | | is even and so the extra, padding byte, is not needed. */ | 658 | 4.67k | if (size & 1) | 659 | 234 | vars->data --; | 660 | | | 661 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 662 | | preserve host alignment requirements. The BFD_ASSERTs in this | 663 | | functions will warn us if we run out of room, but we should | 664 | | already have enough padding built in to ILF_DATA_SIZE. */ | 665 | 4.67k | #if GCC_VERSION >= 3000 | 666 | 4.67k | alignment = __alignof__ (struct coff_section_tdata); | 667 | | #else | 668 | | alignment = 8; | 669 | | #endif | 670 | 4.67k | vars->data | 671 | 4.67k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 672 | | | 673 | | /* Create a coff_section_tdata structure for our use. */ | 674 | 4.67k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 675 | 4.67k | vars->data += sizeof (struct coff_section_tdata); | 676 | | | 677 | 4.67k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 678 | | | 679 | | /* Create a symbol to refer to this section. */ | 680 | 4.67k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 681 | | | 682 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 683 | 4.67k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 684 | | | 685 | 4.67k | return sec; | 686 | 4.67k | } |
pei-arm-wince.c:pe_ILF_make_a_section Line | Count | Source | 627 | 221 | { | 628 | 221 | asection_ptr sec; | 629 | 221 | flagword flags; | 630 | 221 | intptr_t alignment; | 631 | | | 632 | 221 | sec = bfd_make_section_old_way (vars->abfd, name); | 633 | 221 | if (sec == NULL) | 634 | 0 | return NULL; | 635 | | | 636 | 221 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 637 | | | 638 | 221 | bfd_set_section_flags (sec, flags | extra_flags); | 639 | | | 640 | 221 | bfd_set_section_alignment (sec, 2); | 641 | | | 642 | | /* Check that we will not run out of space. */ | 643 | 221 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 644 | | | 645 | | /* Set the section size and contents. The actual | 646 | | contents are filled in by our parent. */ | 647 | 221 | bfd_set_section_size (sec, (bfd_size_type) size); | 648 | 221 | sec->contents = vars->data; | 649 | 221 | sec->target_index = vars->sec_index ++; | 650 | | | 651 | | /* Advance data pointer in the vars structure. */ | 652 | 221 | vars->data += size; | 653 | | | 654 | | /* Skip the padding byte if it was not needed. | 655 | | The logic here is that if the string length is odd, | 656 | | then the entire string length, including the null byte, | 657 | | is even and so the extra, padding byte, is not needed. */ | 658 | 221 | if (size & 1) | 659 | 2 | vars->data --; | 660 | | | 661 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 662 | | preserve host alignment requirements. The BFD_ASSERTs in this | 663 | | functions will warn us if we run out of room, but we should | 664 | | already have enough padding built in to ILF_DATA_SIZE. */ | 665 | 221 | #if GCC_VERSION >= 3000 | 666 | 221 | alignment = __alignof__ (struct coff_section_tdata); | 667 | | #else | 668 | | alignment = 8; | 669 | | #endif | 670 | 221 | vars->data | 671 | 221 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 672 | | | 673 | | /* Create a coff_section_tdata structure for our use. */ | 674 | 221 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 675 | 221 | vars->data += sizeof (struct coff_section_tdata); | 676 | | | 677 | 221 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 678 | | | 679 | | /* Create a symbol to refer to this section. */ | 680 | 221 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 681 | | | 682 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 683 | 221 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 684 | | | 685 | 221 | return sec; | 686 | 221 | } |
pei-arm.c:pe_ILF_make_a_section Line | Count | Source | 627 | 5.29k | { | 628 | 5.29k | asection_ptr sec; | 629 | 5.29k | flagword flags; | 630 | 5.29k | intptr_t alignment; | 631 | | | 632 | 5.29k | sec = bfd_make_section_old_way (vars->abfd, name); | 633 | 5.29k | if (sec == NULL) | 634 | 0 | return NULL; | 635 | | | 636 | 5.29k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 637 | | | 638 | 5.29k | bfd_set_section_flags (sec, flags | extra_flags); | 639 | | | 640 | 5.29k | bfd_set_section_alignment (sec, 2); | 641 | | | 642 | | /* Check that we will not run out of space. */ | 643 | 5.29k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 644 | | | 645 | | /* Set the section size and contents. The actual | 646 | | contents are filled in by our parent. */ | 647 | 5.29k | bfd_set_section_size (sec, (bfd_size_type) size); | 648 | 5.29k | sec->contents = vars->data; | 649 | 5.29k | sec->target_index = vars->sec_index ++; | 650 | | | 651 | | /* Advance data pointer in the vars structure. */ | 652 | 5.29k | vars->data += size; | 653 | | | 654 | | /* Skip the padding byte if it was not needed. | 655 | | The logic here is that if the string length is odd, | 656 | | then the entire string length, including the null byte, | 657 | | is even and so the extra, padding byte, is not needed. */ | 658 | 5.29k | if (size & 1) | 659 | 676 | vars->data --; | 660 | | | 661 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 662 | | preserve host alignment requirements. The BFD_ASSERTs in this | 663 | | functions will warn us if we run out of room, but we should | 664 | | already have enough padding built in to ILF_DATA_SIZE. */ | 665 | 5.29k | #if GCC_VERSION >= 3000 | 666 | 5.29k | alignment = __alignof__ (struct coff_section_tdata); | 667 | | #else | 668 | | alignment = 8; | 669 | | #endif | 670 | 5.29k | vars->data | 671 | 5.29k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 672 | | | 673 | | /* Create a coff_section_tdata structure for our use. */ | 674 | 5.29k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 675 | 5.29k | vars->data += sizeof (struct coff_section_tdata); | 676 | | | 677 | 5.29k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 678 | | | 679 | | /* Create a symbol to refer to this section. */ | 680 | 5.29k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 681 | | | 682 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 683 | 5.29k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 684 | | | 685 | 5.29k | return sec; | 686 | 5.29k | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_section pei-sh.c:pe_ILF_make_a_section Line | Count | Source | 627 | 1.44k | { | 628 | 1.44k | asection_ptr sec; | 629 | 1.44k | flagword flags; | 630 | 1.44k | intptr_t alignment; | 631 | | | 632 | 1.44k | sec = bfd_make_section_old_way (vars->abfd, name); | 633 | 1.44k | if (sec == NULL) | 634 | 0 | return NULL; | 635 | | | 636 | 1.44k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 637 | | | 638 | 1.44k | bfd_set_section_flags (sec, flags | extra_flags); | 639 | | | 640 | 1.44k | bfd_set_section_alignment (sec, 2); | 641 | | | 642 | | /* Check that we will not run out of space. */ | 643 | 1.44k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 644 | | | 645 | | /* Set the section size and contents. The actual | 646 | | contents are filled in by our parent. */ | 647 | 1.44k | bfd_set_section_size (sec, (bfd_size_type) size); | 648 | 1.44k | sec->contents = vars->data; | 649 | 1.44k | sec->target_index = vars->sec_index ++; | 650 | | | 651 | | /* Advance data pointer in the vars structure. */ | 652 | 1.44k | vars->data += size; | 653 | | | 654 | | /* Skip the padding byte if it was not needed. | 655 | | The logic here is that if the string length is odd, | 656 | | then the entire string length, including the null byte, | 657 | | is even and so the extra, padding byte, is not needed. */ | 658 | 1.44k | if (size & 1) | 659 | 3 | vars->data --; | 660 | | | 661 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 662 | | preserve host alignment requirements. The BFD_ASSERTs in this | 663 | | functions will warn us if we run out of room, but we should | 664 | | already have enough padding built in to ILF_DATA_SIZE. */ | 665 | 1.44k | #if GCC_VERSION >= 3000 | 666 | 1.44k | alignment = __alignof__ (struct coff_section_tdata); | 667 | | #else | 668 | | alignment = 8; | 669 | | #endif | 670 | 1.44k | vars->data | 671 | 1.44k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 672 | | | 673 | | /* Create a coff_section_tdata structure for our use. */ | 674 | 1.44k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 675 | 1.44k | vars->data += sizeof (struct coff_section_tdata); | 676 | | | 677 | 1.44k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 678 | | | 679 | | /* Create a symbol to refer to this section. */ | 680 | 1.44k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 681 | | | 682 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 683 | 1.44k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 684 | | | 685 | 1.44k | return sec; | 686 | 1.44k | } |
|
687 | | |
688 | | /* This structure contains the code that goes into the .text section |
689 | | in order to perform a jump into the DLL lookup table. The entries |
690 | | in the table are index by the magic number used to represent the |
691 | | machine type in the PE file. The contents of the data[] arrays in |
692 | | these entries are stolen from the jtab[] arrays in ld/pe-dll.c. |
693 | | The SIZE field says how many bytes in the DATA array are actually |
694 | | used. The OFFSET field says where in the data array the address |
695 | | of the .idata$5 section should be placed. */ |
696 | 15.0k | #define MAX_TEXT_SECTION_SIZE 32 |
697 | | |
698 | | typedef struct |
699 | | { |
700 | | unsigned short magic; |
701 | | unsigned char data[MAX_TEXT_SECTION_SIZE]; |
702 | | unsigned int size; |
703 | | unsigned int offset; |
704 | | } |
705 | | jump_table; |
706 | | |
707 | | static const jump_table jtab[] = |
708 | | { |
709 | | #ifdef I386MAGIC |
710 | | { I386MAGIC, |
711 | | { 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90 }, |
712 | | 8, 2 |
713 | | }, |
714 | | #endif |
715 | | |
716 | | #ifdef AMD64MAGIC |
717 | | { AMD64MAGIC, |
718 | | { 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90 }, |
719 | | 8, 2 |
720 | | }, |
721 | | #endif |
722 | | |
723 | | #ifdef MC68MAGIC |
724 | | { MC68MAGIC, |
725 | | { /* XXX fill me in */ }, |
726 | | 0, 0 |
727 | | }, |
728 | | #endif |
729 | | |
730 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
731 | | { MIPS_ARCH_MAGIC_WINCE, |
732 | | { 0x00, 0x00, 0x08, 0x3c, 0x00, 0x00, 0x08, 0x8d, |
733 | | 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }, |
734 | | 16, 0 |
735 | | }, |
736 | | #endif |
737 | | |
738 | | #ifdef SH_ARCH_MAGIC_WINCE |
739 | | { SH_ARCH_MAGIC_WINCE, |
740 | | { 0x01, 0xd0, 0x02, 0x60, 0x2b, 0x40, |
741 | | 0x09, 0x00, 0x00, 0x00, 0x00, 0x00 }, |
742 | | 12, 8 |
743 | | }, |
744 | | #endif |
745 | | |
746 | | #ifdef AARCH64MAGIC |
747 | | /* We don't currently support jumping to DLLs, so if |
748 | | someone does try emit a runtime trap. Through UDF #0. */ |
749 | | { AARCH64MAGIC, |
750 | | { 0x00, 0x00, 0x00, 0x00 }, |
751 | | 4, 0 |
752 | | }, |
753 | | |
754 | | #endif |
755 | | |
756 | | #ifdef ARMPEMAGIC |
757 | | { ARMPEMAGIC, |
758 | | { 0x00, 0xc0, 0x9f, 0xe5, 0x00, 0xf0, |
759 | | 0x9c, 0xe5, 0x00, 0x00, 0x00, 0x00}, |
760 | | 12, 8 |
761 | | }, |
762 | | #endif |
763 | | |
764 | | #ifdef THUMBPEMAGIC |
765 | | { THUMBPEMAGIC, |
766 | | { 0x40, 0xb4, 0x02, 0x4e, 0x36, 0x68, 0xb4, 0x46, |
767 | | 0x40, 0xbc, 0x60, 0x47, 0x00, 0x00, 0x00, 0x00 }, |
768 | | 16, 12 |
769 | | }, |
770 | | #endif |
771 | | |
772 | | #ifdef LOONGARCH64MAGIC |
773 | | /* We don't currently support jumping to DLLs, so if |
774 | | someone does try emit a runtime trap. Through BREAK 0. */ |
775 | | { LOONGARCH64MAGIC, |
776 | | { 0x00, 0x00, 0x2a, 0x00 }, |
777 | | 4, 0 |
778 | | }, |
779 | | |
780 | | #endif |
781 | | |
782 | | { 0, { 0 }, 0, 0 } |
783 | | }; |
784 | | |
785 | | #ifndef NUM_ENTRIES |
786 | 4.06k | #define NUM_ENTRIES(a) (sizeof (a) / sizeof (a)[0]) |
787 | | #endif |
788 | | |
789 | | /* Build a full BFD from the information supplied in a ILF object. */ |
790 | | |
791 | | static bool |
792 | | pe_ILF_build_a_bfd (bfd * abfd, |
793 | | unsigned int magic, |
794 | | char * symbol_name, |
795 | | char * source_dll, |
796 | | unsigned int ordinal, |
797 | | unsigned int types) |
798 | 9.20k | { |
799 | 9.20k | bfd_byte * ptr; |
800 | 9.20k | pe_ILF_vars vars; |
801 | 9.20k | struct internal_filehdr internal_f; |
802 | 9.20k | unsigned int import_type; |
803 | 9.20k | unsigned int import_name_type; |
804 | 9.20k | asection_ptr id4, id5, id6 = NULL, text = NULL; |
805 | 9.20k | coff_symbol_type ** imp_sym; |
806 | 9.20k | unsigned int imp_index; |
807 | 9.20k | intptr_t alignment; |
808 | | |
809 | | /* Decode and verify the types field of the ILF structure. */ |
810 | 9.20k | import_type = types & 0x3; |
811 | 9.20k | import_name_type = (types & 0x1c) >> 2; |
812 | | |
813 | 9.20k | switch (import_type) |
814 | 9.20k | { |
815 | 4.79k | case IMPORT_CODE: |
816 | 7.96k | case IMPORT_DATA: |
817 | 7.96k | break; |
818 | | |
819 | 1.13k | case IMPORT_CONST: |
820 | | /* XXX code yet to be written. */ |
821 | | /* xgettext:c-format */ |
822 | 1.13k | _bfd_error_handler (_("%pB: unhandled import type; %x"), |
823 | 1.13k | abfd, import_type); |
824 | 1.13k | return false; |
825 | | |
826 | 115 | default: |
827 | | /* xgettext:c-format */ |
828 | 115 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), |
829 | 115 | abfd, import_type); |
830 | 115 | return false; |
831 | 9.20k | } |
832 | | |
833 | 7.96k | switch (import_name_type) |
834 | 7.96k | { |
835 | 3.17k | case IMPORT_ORDINAL: |
836 | 4.01k | case IMPORT_NAME: |
837 | 5.02k | case IMPORT_NAME_NOPREFIX: |
838 | 7.54k | case IMPORT_NAME_UNDECORATE: |
839 | 7.54k | break; |
840 | | |
841 | 421 | default: |
842 | | /* xgettext:c-format */ |
843 | 421 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), |
844 | 421 | abfd, import_name_type); |
845 | 421 | return false; |
846 | 7.96k | } |
847 | | |
848 | | /* Initialise local variables. |
849 | | |
850 | | Note these are kept in a structure rather than being |
851 | | declared as statics since bfd frowns on global variables. |
852 | | |
853 | | We are going to construct the contents of the BFD in memory, |
854 | | so allocate all the space that we will need right now. */ |
855 | 7.54k | vars.bim |
856 | 7.54k | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); |
857 | 7.54k | if (vars.bim == NULL) |
858 | 0 | return false; |
859 | | |
860 | 7.54k | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); |
861 | 7.54k | vars.bim->buffer = ptr; |
862 | 7.54k | vars.bim->size = ILF_DATA_SIZE; |
863 | 7.54k | if (ptr == NULL) |
864 | 0 | goto error_return; |
865 | | |
866 | | /* Initialise the pointers to regions of the memory and the |
867 | | other contents of the pe_ILF_vars structure as well. */ |
868 | 7.54k | vars.sym_cache = (coff_symbol_type *) ptr; |
869 | 7.54k | vars.sym_ptr = (coff_symbol_type *) ptr; |
870 | 7.54k | vars.sym_index = 0; |
871 | 7.54k | ptr += SIZEOF_ILF_SYMS; |
872 | | |
873 | 7.54k | vars.sym_table = (unsigned int *) ptr; |
874 | 7.54k | vars.table_ptr = (unsigned int *) ptr; |
875 | 7.54k | ptr += SIZEOF_ILF_SYM_TABLE; |
876 | | |
877 | 7.54k | vars.native_syms = (combined_entry_type *) ptr; |
878 | 7.54k | vars.native_ptr = (combined_entry_type *) ptr; |
879 | 7.54k | ptr += SIZEOF_ILF_NATIVE_SYMS; |
880 | | |
881 | 7.54k | vars.sym_ptr_table = (coff_symbol_type **) ptr; |
882 | 7.54k | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; |
883 | 7.54k | ptr += SIZEOF_ILF_SYM_PTR_TABLE; |
884 | | |
885 | 7.54k | vars.esym_table = (SYMENT *) ptr; |
886 | 7.54k | vars.esym_ptr = (SYMENT *) ptr; |
887 | 7.54k | ptr += SIZEOF_ILF_EXT_SYMS; |
888 | | |
889 | 7.54k | vars.reltab = (arelent *) ptr; |
890 | 7.54k | vars.relcount = 0; |
891 | 7.54k | ptr += SIZEOF_ILF_RELOCS; |
892 | | |
893 | 7.54k | vars.int_reltab = (struct internal_reloc *) ptr; |
894 | 7.54k | ptr += SIZEOF_ILF_INT_RELOCS; |
895 | | |
896 | 7.54k | vars.string_table = (char *) ptr; |
897 | 7.54k | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; |
898 | 7.54k | ptr += SIZEOF_ILF_STRINGS; |
899 | 7.54k | vars.end_string_ptr = (char *) ptr; |
900 | | |
901 | | /* The remaining space in bim->buffer is used |
902 | | by the pe_ILF_make_a_section() function. */ |
903 | | |
904 | | /* PR 18758: Make sure that the data area is sufficiently aligned for |
905 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence |
906 | | the test of GCC_VERSION. For other compilers we assume 8 byte |
907 | | alignment. */ |
908 | 7.54k | #if GCC_VERSION >= 3000 |
909 | 7.54k | alignment = __alignof__ (struct coff_section_tdata); |
910 | | #else |
911 | | alignment = 8; |
912 | | #endif |
913 | 7.54k | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); |
914 | | |
915 | 7.54k | vars.data = ptr; |
916 | 7.54k | vars.abfd = abfd; |
917 | 7.54k | vars.sec_index = 0; |
918 | 7.54k | vars.magic = magic; |
919 | | |
920 | | /* Create the initial .idata$<n> sections: |
921 | | [.idata$2: Import Directory Table -- not needed] |
922 | | .idata$4: Import Lookup Table |
923 | | .idata$5: Import Address Table |
924 | | |
925 | | Note we do not create a .idata$3 section as this is |
926 | | created for us by the linker script. */ |
927 | 7.54k | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); |
928 | 7.54k | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); |
929 | 7.54k | if (id4 == NULL || id5 == NULL) |
930 | 0 | goto error_return; |
931 | | |
932 | | /* Fill in the contents of these sections. */ |
933 | 7.54k | if (import_name_type == IMPORT_ORDINAL) |
934 | 3.17k | { |
935 | 3.17k | if (ordinal == 0) |
936 | | /* See PR 20907 for a reproducer. */ |
937 | 519 | goto error_return; |
938 | | |
939 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) |
940 | 1.50k | ((unsigned int *) id4->contents)[0] = ordinal; |
941 | 1.50k | ((unsigned int *) id4->contents)[1] = 0x80000000; |
942 | 1.50k | ((unsigned int *) id5->contents)[0] = ordinal; |
943 | 1.50k | ((unsigned int *) id5->contents)[1] = 0x80000000; |
944 | | #else |
945 | 1.15k | * (unsigned int *) id4->contents = ordinal | 0x80000000; |
946 | 1.15k | * (unsigned int *) id5->contents = ordinal | 0x80000000; |
947 | 1.15k | #endif |
948 | 1.15k | } |
949 | 4.36k | else |
950 | 4.36k | { |
951 | 4.36k | char * symbol; |
952 | 4.36k | unsigned int len; |
953 | | |
954 | | /* Create .idata$6 - the Hint Name Table. */ |
955 | 4.36k | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); |
956 | 4.36k | if (id6 == NULL) |
957 | 0 | goto error_return; |
958 | | |
959 | | /* If necessary, trim the import symbol name. */ |
960 | 4.36k | symbol = symbol_name; |
961 | | |
962 | | /* As used by MS compiler, '_', '@', and '?' are alternative |
963 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, |
964 | | '@' used for fastcall (in C), '_' everywhere else. Only one |
965 | | of these is used for a symbol. We strip this leading char for |
966 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the |
967 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ |
968 | | |
969 | 4.36k | if (import_name_type != IMPORT_NAME) |
970 | 3.52k | { |
971 | 3.52k | char c = symbol[0]; |
972 | | |
973 | | /* Check that we don't remove for targets with empty |
974 | | USER_LABEL_PREFIX the leading underscore. */ |
975 | 3.52k | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) |
976 | 3.52k | || c == '@' || c == '?') |
977 | 835 | symbol++; |
978 | 3.52k | } |
979 | | |
980 | 4.36k | len = strlen (symbol); |
981 | 4.36k | if (import_name_type == IMPORT_NAME_UNDECORATE) |
982 | 2.51k | { |
983 | | /* Truncate at the first '@'. */ |
984 | 2.51k | char *at = strchr (symbol, '@'); |
985 | | |
986 | 2.51k | if (at != NULL) |
987 | 133 | len = at - symbol; |
988 | 2.51k | } |
989 | | |
990 | 4.36k | id6->contents[0] = ordinal & 0xff; |
991 | 4.36k | id6->contents[1] = ordinal >> 8; |
992 | | |
993 | 4.36k | memcpy ((char *) id6->contents + 2, symbol, len); |
994 | 4.36k | id6->contents[len + 2] = '\0'; |
995 | 4.36k | } |
996 | | |
997 | 7.02k | if (import_name_type != IMPORT_ORDINAL) |
998 | 4.36k | { |
999 | 4.36k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); |
1000 | 4.36k | pe_ILF_save_relocs (&vars, id4); |
1001 | | |
1002 | 4.36k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); |
1003 | 4.36k | pe_ILF_save_relocs (&vars, id5); |
1004 | 4.36k | } |
1005 | | |
1006 | | /* Create an import symbol. */ |
1007 | 7.02k | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); |
1008 | 7.02k | imp_sym = vars.sym_ptr_ptr - 1; |
1009 | 7.02k | imp_index = vars.sym_index - 1; |
1010 | | |
1011 | | /* Create extra sections depending upon the type of import we are dealing with. */ |
1012 | 7.02k | switch (import_type) |
1013 | 7.02k | { |
1014 | 0 | int i; |
1015 | | |
1016 | 4.06k | case IMPORT_CODE: |
1017 | | /* CODE functions are special, in that they get a trampoline that |
1018 | | jumps to the main import symbol. Create a .text section to hold it. |
1019 | | First we need to look up its contents in the jump table. */ |
1020 | 8.83k | for (i = NUM_ENTRIES (jtab); i--;) |
1021 | 8.83k | { |
1022 | 8.83k | if (jtab[i].size == 0) |
1023 | 4.06k | continue; |
1024 | 4.77k | if (jtab[i].magic == magic) |
1025 | 4.06k | break; |
1026 | 4.77k | } |
1027 | | /* If we did not find a matching entry something is wrong. */ |
1028 | 4.06k | if (i < 0) |
1029 | 0 | abort (); |
1030 | | |
1031 | | /* Create the .text section. */ |
1032 | 4.06k | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); |
1033 | 4.06k | if (text == NULL) |
1034 | 0 | goto error_return; |
1035 | | |
1036 | | /* Copy in the jump code. */ |
1037 | 4.06k | memcpy (text->contents, jtab[i].data, jtab[i].size); |
1038 | | |
1039 | | /* Create a reloc for the data in the text section. */ |
1040 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
1041 | | if (magic == MIPS_ARCH_MAGIC_WINCE) |
1042 | | { |
1043 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, |
1044 | | (struct bfd_symbol **) imp_sym, |
1045 | | imp_index); |
1046 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); |
1047 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, |
1048 | | (struct bfd_symbol **) imp_sym, |
1049 | | imp_index); |
1050 | | } |
1051 | | else |
1052 | | #endif |
1053 | | #ifdef AMD64MAGIC |
1054 | 803 | if (magic == AMD64MAGIC) |
1055 | 803 | { |
1056 | 803 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, |
1057 | 803 | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, |
1058 | 803 | imp_index); |
1059 | 803 | } |
1060 | 0 | else |
1061 | 0 | #endif |
1062 | 0 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, |
1063 | 0 | BFD_RELOC_32, (asymbol **) imp_sym, |
1064 | 0 | imp_index); |
1065 | | |
1066 | 4.06k | pe_ILF_save_relocs (& vars, text); |
1067 | 4.06k | break; |
1068 | | |
1069 | 2.95k | case IMPORT_DATA: |
1070 | 2.95k | break; |
1071 | | |
1072 | 0 | default: |
1073 | | /* XXX code not yet written. */ |
1074 | 0 | abort (); |
1075 | 7.02k | } |
1076 | | |
1077 | | /* Now create a symbol describing the imported value. */ |
1078 | 7.02k | switch (import_type) |
1079 | 7.02k | { |
1080 | 4.06k | case IMPORT_CODE: |
1081 | 4.06k | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, |
1082 | 4.06k | BSF_NOT_AT_END | BSF_FUNCTION); |
1083 | | |
1084 | 4.06k | break; |
1085 | | |
1086 | 2.95k | case IMPORT_DATA: |
1087 | | /* Nothing to do here. */ |
1088 | 2.95k | break; |
1089 | | |
1090 | 0 | default: |
1091 | | /* XXX code not yet written. */ |
1092 | 0 | abort (); |
1093 | 7.02k | } |
1094 | | |
1095 | | /* Create an import symbol for the DLL, without the .dll suffix. */ |
1096 | 7.02k | ptr = (bfd_byte *) strrchr (source_dll, '.'); |
1097 | 7.02k | if (ptr) |
1098 | 1.40k | * ptr = 0; |
1099 | 7.02k | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); |
1100 | 7.02k | if (ptr) |
1101 | 1.40k | * ptr = '.'; |
1102 | | |
1103 | | /* Initialise the bfd. */ |
1104 | 7.02k | memset (& internal_f, 0, sizeof (internal_f)); |
1105 | | |
1106 | 7.02k | internal_f.f_magic = magic; |
1107 | 7.02k | internal_f.f_symptr = 0; |
1108 | 7.02k | internal_f.f_nsyms = 0; |
1109 | 7.02k | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ |
1110 | | |
1111 | 7.02k | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) |
1112 | 7.02k | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) |
1113 | 0 | goto error_return; |
1114 | | |
1115 | 7.02k | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) |
1116 | 0 | goto error_return; |
1117 | | |
1118 | 7.02k | obj_pe (abfd) = true; |
1119 | | #ifdef THUMBPEMAGIC |
1120 | 1.62k | if (vars.magic == THUMBPEMAGIC) |
1121 | | /* Stop some linker warnings about thumb code not supporting interworking. */ |
1122 | 239 | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; |
1123 | | #endif |
1124 | | |
1125 | | /* Switch from file contents to memory contents. */ |
1126 | 7.02k | bfd_cache_close (abfd); |
1127 | | |
1128 | 7.02k | abfd->iostream = (void *) vars.bim; |
1129 | 7.02k | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; |
1130 | 7.02k | abfd->iovec = &_bfd_memory_iovec; |
1131 | 7.02k | abfd->where = 0; |
1132 | 7.02k | abfd->origin = 0; |
1133 | 7.02k | abfd->size = 0; |
1134 | 7.02k | obj_sym_filepos (abfd) = 0; |
1135 | | |
1136 | | /* Point the bfd at the symbol table. */ |
1137 | 7.02k | obj_symbols (abfd) = vars.sym_cache; |
1138 | 7.02k | abfd->symcount = vars.sym_index; |
1139 | | |
1140 | 7.02k | obj_raw_syments (abfd) = vars.native_syms; |
1141 | 7.02k | obj_raw_syment_count (abfd) = vars.sym_index; |
1142 | | |
1143 | 7.02k | obj_coff_external_syms (abfd) = (void *) vars.esym_table; |
1144 | 7.02k | obj_coff_keep_syms (abfd) = true; |
1145 | | |
1146 | 7.02k | obj_convert (abfd) = vars.sym_table; |
1147 | 7.02k | obj_conv_table_size (abfd) = vars.sym_index; |
1148 | | |
1149 | 7.02k | obj_coff_strings (abfd) = vars.string_table; |
1150 | 7.02k | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; |
1151 | 7.02k | obj_coff_keep_strings (abfd) = true; |
1152 | | |
1153 | 7.02k | return true; |
1154 | | |
1155 | 519 | error_return: |
1156 | 519 | free (vars.bim->buffer); |
1157 | 519 | free (vars.bim); |
1158 | 519 | return false; |
1159 | 7.02k | } pei-i386.c:pe_ILF_build_a_bfd Line | Count | Source | 798 | 1.55k | { | 799 | 1.55k | bfd_byte * ptr; | 800 | 1.55k | pe_ILF_vars vars; | 801 | 1.55k | struct internal_filehdr internal_f; | 802 | 1.55k | unsigned int import_type; | 803 | 1.55k | unsigned int import_name_type; | 804 | 1.55k | asection_ptr id4, id5, id6 = NULL, text = NULL; | 805 | 1.55k | coff_symbol_type ** imp_sym; | 806 | 1.55k | unsigned int imp_index; | 807 | 1.55k | intptr_t alignment; | 808 | | | 809 | | /* Decode and verify the types field of the ILF structure. */ | 810 | 1.55k | import_type = types & 0x3; | 811 | 1.55k | import_name_type = (types & 0x1c) >> 2; | 812 | | | 813 | 1.55k | switch (import_type) | 814 | 1.55k | { | 815 | 1.45k | case IMPORT_CODE: | 816 | 1.55k | case IMPORT_DATA: | 817 | 1.55k | break; | 818 | | | 819 | 3 | case IMPORT_CONST: | 820 | | /* XXX code yet to be written. */ | 821 | | /* xgettext:c-format */ | 822 | 3 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 823 | 3 | abfd, import_type); | 824 | 3 | return false; | 825 | | | 826 | 3 | default: | 827 | | /* xgettext:c-format */ | 828 | 3 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 829 | 3 | abfd, import_type); | 830 | 3 | return false; | 831 | 1.55k | } | 832 | | | 833 | 1.55k | switch (import_name_type) | 834 | 1.55k | { | 835 | 645 | case IMPORT_ORDINAL: | 836 | 879 | case IMPORT_NAME: | 837 | 1.11k | case IMPORT_NAME_NOPREFIX: | 838 | 1.45k | case IMPORT_NAME_UNDECORATE: | 839 | 1.45k | break; | 840 | | | 841 | 101 | default: | 842 | | /* xgettext:c-format */ | 843 | 101 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 844 | 101 | abfd, import_name_type); | 845 | 101 | return false; | 846 | 1.55k | } | 847 | | | 848 | | /* Initialise local variables. | 849 | | | 850 | | Note these are kept in a structure rather than being | 851 | | declared as statics since bfd frowns on global variables. | 852 | | | 853 | | We are going to construct the contents of the BFD in memory, | 854 | | so allocate all the space that we will need right now. */ | 855 | 1.45k | vars.bim | 856 | 1.45k | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 857 | 1.45k | if (vars.bim == NULL) | 858 | 0 | return false; | 859 | | | 860 | 1.45k | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 861 | 1.45k | vars.bim->buffer = ptr; | 862 | 1.45k | vars.bim->size = ILF_DATA_SIZE; | 863 | 1.45k | if (ptr == NULL) | 864 | 0 | goto error_return; | 865 | | | 866 | | /* Initialise the pointers to regions of the memory and the | 867 | | other contents of the pe_ILF_vars structure as well. */ | 868 | 1.45k | vars.sym_cache = (coff_symbol_type *) ptr; | 869 | 1.45k | vars.sym_ptr = (coff_symbol_type *) ptr; | 870 | 1.45k | vars.sym_index = 0; | 871 | 1.45k | ptr += SIZEOF_ILF_SYMS; | 872 | | | 873 | 1.45k | vars.sym_table = (unsigned int *) ptr; | 874 | 1.45k | vars.table_ptr = (unsigned int *) ptr; | 875 | 1.45k | ptr += SIZEOF_ILF_SYM_TABLE; | 876 | | | 877 | 1.45k | vars.native_syms = (combined_entry_type *) ptr; | 878 | 1.45k | vars.native_ptr = (combined_entry_type *) ptr; | 879 | 1.45k | ptr += SIZEOF_ILF_NATIVE_SYMS; | 880 | | | 881 | 1.45k | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 882 | 1.45k | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 883 | 1.45k | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 884 | | | 885 | 1.45k | vars.esym_table = (SYMENT *) ptr; | 886 | 1.45k | vars.esym_ptr = (SYMENT *) ptr; | 887 | 1.45k | ptr += SIZEOF_ILF_EXT_SYMS; | 888 | | | 889 | 1.45k | vars.reltab = (arelent *) ptr; | 890 | 1.45k | vars.relcount = 0; | 891 | 1.45k | ptr += SIZEOF_ILF_RELOCS; | 892 | | | 893 | 1.45k | vars.int_reltab = (struct internal_reloc *) ptr; | 894 | 1.45k | ptr += SIZEOF_ILF_INT_RELOCS; | 895 | | | 896 | 1.45k | vars.string_table = (char *) ptr; | 897 | 1.45k | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 898 | 1.45k | ptr += SIZEOF_ILF_STRINGS; | 899 | 1.45k | vars.end_string_ptr = (char *) ptr; | 900 | | | 901 | | /* The remaining space in bim->buffer is used | 902 | | by the pe_ILF_make_a_section() function. */ | 903 | | | 904 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 905 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 906 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 907 | | alignment. */ | 908 | 1.45k | #if GCC_VERSION >= 3000 | 909 | 1.45k | alignment = __alignof__ (struct coff_section_tdata); | 910 | | #else | 911 | | alignment = 8; | 912 | | #endif | 913 | 1.45k | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 914 | | | 915 | 1.45k | vars.data = ptr; | 916 | 1.45k | vars.abfd = abfd; | 917 | 1.45k | vars.sec_index = 0; | 918 | 1.45k | vars.magic = magic; | 919 | | | 920 | | /* Create the initial .idata$<n> sections: | 921 | | [.idata$2: Import Directory Table -- not needed] | 922 | | .idata$4: Import Lookup Table | 923 | | .idata$5: Import Address Table | 924 | | | 925 | | Note we do not create a .idata$3 section as this is | 926 | | created for us by the linker script. */ | 927 | 1.45k | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 928 | 1.45k | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 929 | 1.45k | if (id4 == NULL || id5 == NULL) | 930 | 0 | goto error_return; | 931 | | | 932 | | /* Fill in the contents of these sections. */ | 933 | 1.45k | if (import_name_type == IMPORT_ORDINAL) | 934 | 645 | { | 935 | 645 | if (ordinal == 0) | 936 | | /* See PR 20907 for a reproducer. */ | 937 | 205 | goto error_return; | 938 | | | 939 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 940 | | ((unsigned int *) id4->contents)[0] = ordinal; | 941 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 942 | | ((unsigned int *) id5->contents)[0] = ordinal; | 943 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 944 | | #else | 945 | 440 | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 946 | 440 | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 947 | 440 | #endif | 948 | 440 | } | 949 | 807 | else | 950 | 807 | { | 951 | 807 | char * symbol; | 952 | 807 | unsigned int len; | 953 | | | 954 | | /* Create .idata$6 - the Hint Name Table. */ | 955 | 807 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 956 | 807 | if (id6 == NULL) | 957 | 0 | goto error_return; | 958 | | | 959 | | /* If necessary, trim the import symbol name. */ | 960 | 807 | symbol = symbol_name; | 961 | | | 962 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 963 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 964 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 965 | | of these is used for a symbol. We strip this leading char for | 966 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 967 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 968 | | | 969 | 807 | if (import_name_type != IMPORT_NAME) | 970 | 573 | { | 971 | 573 | char c = symbol[0]; | 972 | | | 973 | | /* Check that we don't remove for targets with empty | 974 | | USER_LABEL_PREFIX the leading underscore. */ | 975 | 573 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 976 | 573 | || c == '@' || c == '?') | 977 | 234 | symbol++; | 978 | 573 | } | 979 | | | 980 | 807 | len = strlen (symbol); | 981 | 807 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 982 | 340 | { | 983 | | /* Truncate at the first '@'. */ | 984 | 340 | char *at = strchr (symbol, '@'); | 985 | | | 986 | 340 | if (at != NULL) | 987 | 0 | len = at - symbol; | 988 | 340 | } | 989 | | | 990 | 807 | id6->contents[0] = ordinal & 0xff; | 991 | 807 | id6->contents[1] = ordinal >> 8; | 992 | | | 993 | 807 | memcpy ((char *) id6->contents + 2, symbol, len); | 994 | 807 | id6->contents[len + 2] = '\0'; | 995 | 807 | } | 996 | | | 997 | 1.24k | if (import_name_type != IMPORT_ORDINAL) | 998 | 807 | { | 999 | 807 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1000 | 807 | pe_ILF_save_relocs (&vars, id4); | 1001 | | | 1002 | 807 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1003 | 807 | pe_ILF_save_relocs (&vars, id5); | 1004 | 807 | } | 1005 | | | 1006 | | /* Create an import symbol. */ | 1007 | 1.24k | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 1008 | 1.24k | imp_sym = vars.sym_ptr_ptr - 1; | 1009 | 1.24k | imp_index = vars.sym_index - 1; | 1010 | | | 1011 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1012 | 1.24k | switch (import_type) | 1013 | 1.24k | { | 1014 | 0 | int i; | 1015 | | | 1016 | 1.14k | case IMPORT_CODE: | 1017 | | /* CODE functions are special, in that they get a trampoline that | 1018 | | jumps to the main import symbol. Create a .text section to hold it. | 1019 | | First we need to look up its contents in the jump table. */ | 1020 | 2.28k | for (i = NUM_ENTRIES (jtab); i--;) | 1021 | 2.28k | { | 1022 | 2.28k | if (jtab[i].size == 0) | 1023 | 1.14k | continue; | 1024 | 1.14k | if (jtab[i].magic == magic) | 1025 | 1.14k | break; | 1026 | 1.14k | } | 1027 | | /* If we did not find a matching entry something is wrong. */ | 1028 | 1.14k | if (i < 0) | 1029 | 0 | abort (); | 1030 | | | 1031 | | /* Create the .text section. */ | 1032 | 1.14k | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1033 | 1.14k | if (text == NULL) | 1034 | 0 | goto error_return; | 1035 | | | 1036 | | /* Copy in the jump code. */ | 1037 | 1.14k | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1038 | | | 1039 | | /* Create a reloc for the data in the text section. */ | 1040 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1041 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1042 | | { | 1043 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1044 | | (struct bfd_symbol **) imp_sym, | 1045 | | imp_index); | 1046 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1047 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1048 | | (struct bfd_symbol **) imp_sym, | 1049 | | imp_index); | 1050 | | } | 1051 | | else | 1052 | | #endif | 1053 | | #ifdef AMD64MAGIC | 1054 | | if (magic == AMD64MAGIC) | 1055 | | { | 1056 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1057 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1058 | | imp_index); | 1059 | | } | 1060 | | else | 1061 | | #endif | 1062 | 1.14k | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1063 | 1.14k | BFD_RELOC_32, (asymbol **) imp_sym, | 1064 | 1.14k | imp_index); | 1065 | | | 1066 | 1.14k | pe_ILF_save_relocs (& vars, text); | 1067 | 1.14k | break; | 1068 | | | 1069 | 103 | case IMPORT_DATA: | 1070 | 103 | break; | 1071 | | | 1072 | 0 | default: | 1073 | | /* XXX code not yet written. */ | 1074 | 0 | abort (); | 1075 | 1.24k | } | 1076 | | | 1077 | | /* Now create a symbol describing the imported value. */ | 1078 | 1.24k | switch (import_type) | 1079 | 1.24k | { | 1080 | 1.14k | case IMPORT_CODE: | 1081 | 1.14k | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1082 | 1.14k | BSF_NOT_AT_END | BSF_FUNCTION); | 1083 | | | 1084 | 1.14k | break; | 1085 | | | 1086 | 103 | case IMPORT_DATA: | 1087 | | /* Nothing to do here. */ | 1088 | 103 | break; | 1089 | | | 1090 | 0 | default: | 1091 | | /* XXX code not yet written. */ | 1092 | 0 | abort (); | 1093 | 1.24k | } | 1094 | | | 1095 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1096 | 1.24k | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1097 | 1.24k | if (ptr) | 1098 | 2 | * ptr = 0; | 1099 | 1.24k | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1100 | 1.24k | if (ptr) | 1101 | 2 | * ptr = '.'; | 1102 | | | 1103 | | /* Initialise the bfd. */ | 1104 | 1.24k | memset (& internal_f, 0, sizeof (internal_f)); | 1105 | | | 1106 | 1.24k | internal_f.f_magic = magic; | 1107 | 1.24k | internal_f.f_symptr = 0; | 1108 | 1.24k | internal_f.f_nsyms = 0; | 1109 | 1.24k | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1110 | | | 1111 | 1.24k | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1112 | 1.24k | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1113 | 0 | goto error_return; | 1114 | | | 1115 | 1.24k | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1116 | 0 | goto error_return; | 1117 | | | 1118 | 1.24k | obj_pe (abfd) = true; | 1119 | | #ifdef THUMBPEMAGIC | 1120 | | if (vars.magic == THUMBPEMAGIC) | 1121 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1122 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1123 | | #endif | 1124 | | | 1125 | | /* Switch from file contents to memory contents. */ | 1126 | 1.24k | bfd_cache_close (abfd); | 1127 | | | 1128 | 1.24k | abfd->iostream = (void *) vars.bim; | 1129 | 1.24k | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1130 | 1.24k | abfd->iovec = &_bfd_memory_iovec; | 1131 | 1.24k | abfd->where = 0; | 1132 | 1.24k | abfd->origin = 0; | 1133 | 1.24k | abfd->size = 0; | 1134 | 1.24k | obj_sym_filepos (abfd) = 0; | 1135 | | | 1136 | | /* Point the bfd at the symbol table. */ | 1137 | 1.24k | obj_symbols (abfd) = vars.sym_cache; | 1138 | 1.24k | abfd->symcount = vars.sym_index; | 1139 | | | 1140 | 1.24k | obj_raw_syments (abfd) = vars.native_syms; | 1141 | 1.24k | obj_raw_syment_count (abfd) = vars.sym_index; | 1142 | | | 1143 | 1.24k | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1144 | 1.24k | obj_coff_keep_syms (abfd) = true; | 1145 | | | 1146 | 1.24k | obj_convert (abfd) = vars.sym_table; | 1147 | 1.24k | obj_conv_table_size (abfd) = vars.sym_index; | 1148 | | | 1149 | 1.24k | obj_coff_strings (abfd) = vars.string_table; | 1150 | 1.24k | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1151 | 1.24k | obj_coff_keep_strings (abfd) = true; | 1152 | | | 1153 | 1.24k | return true; | 1154 | | | 1155 | 205 | error_return: | 1156 | 205 | free (vars.bim->buffer); | 1157 | 205 | free (vars.bim); | 1158 | 205 | return false; | 1159 | 1.24k | } |
pei-x86_64.c:pe_ILF_build_a_bfd Line | Count | Source | 798 | 1.48k | { | 799 | 1.48k | bfd_byte * ptr; | 800 | 1.48k | pe_ILF_vars vars; | 801 | 1.48k | struct internal_filehdr internal_f; | 802 | 1.48k | unsigned int import_type; | 803 | 1.48k | unsigned int import_name_type; | 804 | 1.48k | asection_ptr id4, id5, id6 = NULL, text = NULL; | 805 | 1.48k | coff_symbol_type ** imp_sym; | 806 | 1.48k | unsigned int imp_index; | 807 | 1.48k | intptr_t alignment; | 808 | | | 809 | | /* Decode and verify the types field of the ILF structure. */ | 810 | 1.48k | import_type = types & 0x3; | 811 | 1.48k | import_name_type = (types & 0x1c) >> 2; | 812 | | | 813 | 1.48k | switch (import_type) | 814 | 1.48k | { | 815 | 910 | case IMPORT_CODE: | 816 | 1.47k | case IMPORT_DATA: | 817 | 1.47k | break; | 818 | | | 819 | 3 | case IMPORT_CONST: | 820 | | /* XXX code yet to be written. */ | 821 | | /* xgettext:c-format */ | 822 | 3 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 823 | 3 | abfd, import_type); | 824 | 3 | return false; | 825 | | | 826 | 1 | default: | 827 | | /* xgettext:c-format */ | 828 | 1 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 829 | 1 | abfd, import_type); | 830 | 1 | return false; | 831 | 1.48k | } | 832 | | | 833 | 1.47k | switch (import_name_type) | 834 | 1.47k | { | 835 | 805 | case IMPORT_ORDINAL: | 836 | 806 | case IMPORT_NAME: | 837 | 1.14k | case IMPORT_NAME_NOPREFIX: | 838 | 1.37k | case IMPORT_NAME_UNDECORATE: | 839 | 1.37k | break; | 840 | | | 841 | 104 | default: | 842 | | /* xgettext:c-format */ | 843 | 104 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 844 | 104 | abfd, import_name_type); | 845 | 104 | return false; | 846 | 1.47k | } | 847 | | | 848 | | /* Initialise local variables. | 849 | | | 850 | | Note these are kept in a structure rather than being | 851 | | declared as statics since bfd frowns on global variables. | 852 | | | 853 | | We are going to construct the contents of the BFD in memory, | 854 | | so allocate all the space that we will need right now. */ | 855 | 1.37k | vars.bim | 856 | 1.37k | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 857 | 1.37k | if (vars.bim == NULL) | 858 | 0 | return false; | 859 | | | 860 | 1.37k | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 861 | 1.37k | vars.bim->buffer = ptr; | 862 | 1.37k | vars.bim->size = ILF_DATA_SIZE; | 863 | 1.37k | if (ptr == NULL) | 864 | 0 | goto error_return; | 865 | | | 866 | | /* Initialise the pointers to regions of the memory and the | 867 | | other contents of the pe_ILF_vars structure as well. */ | 868 | 1.37k | vars.sym_cache = (coff_symbol_type *) ptr; | 869 | 1.37k | vars.sym_ptr = (coff_symbol_type *) ptr; | 870 | 1.37k | vars.sym_index = 0; | 871 | 1.37k | ptr += SIZEOF_ILF_SYMS; | 872 | | | 873 | 1.37k | vars.sym_table = (unsigned int *) ptr; | 874 | 1.37k | vars.table_ptr = (unsigned int *) ptr; | 875 | 1.37k | ptr += SIZEOF_ILF_SYM_TABLE; | 876 | | | 877 | 1.37k | vars.native_syms = (combined_entry_type *) ptr; | 878 | 1.37k | vars.native_ptr = (combined_entry_type *) ptr; | 879 | 1.37k | ptr += SIZEOF_ILF_NATIVE_SYMS; | 880 | | | 881 | 1.37k | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 882 | 1.37k | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 883 | 1.37k | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 884 | | | 885 | 1.37k | vars.esym_table = (SYMENT *) ptr; | 886 | 1.37k | vars.esym_ptr = (SYMENT *) ptr; | 887 | 1.37k | ptr += SIZEOF_ILF_EXT_SYMS; | 888 | | | 889 | 1.37k | vars.reltab = (arelent *) ptr; | 890 | 1.37k | vars.relcount = 0; | 891 | 1.37k | ptr += SIZEOF_ILF_RELOCS; | 892 | | | 893 | 1.37k | vars.int_reltab = (struct internal_reloc *) ptr; | 894 | 1.37k | ptr += SIZEOF_ILF_INT_RELOCS; | 895 | | | 896 | 1.37k | vars.string_table = (char *) ptr; | 897 | 1.37k | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 898 | 1.37k | ptr += SIZEOF_ILF_STRINGS; | 899 | 1.37k | vars.end_string_ptr = (char *) ptr; | 900 | | | 901 | | /* The remaining space in bim->buffer is used | 902 | | by the pe_ILF_make_a_section() function. */ | 903 | | | 904 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 905 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 906 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 907 | | alignment. */ | 908 | 1.37k | #if GCC_VERSION >= 3000 | 909 | 1.37k | alignment = __alignof__ (struct coff_section_tdata); | 910 | | #else | 911 | | alignment = 8; | 912 | | #endif | 913 | 1.37k | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 914 | | | 915 | 1.37k | vars.data = ptr; | 916 | 1.37k | vars.abfd = abfd; | 917 | 1.37k | vars.sec_index = 0; | 918 | 1.37k | vars.magic = magic; | 919 | | | 920 | | /* Create the initial .idata$<n> sections: | 921 | | [.idata$2: Import Directory Table -- not needed] | 922 | | .idata$4: Import Lookup Table | 923 | | .idata$5: Import Address Table | 924 | | | 925 | | Note we do not create a .idata$3 section as this is | 926 | | created for us by the linker script. */ | 927 | 1.37k | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 928 | 1.37k | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 929 | 1.37k | if (id4 == NULL || id5 == NULL) | 930 | 0 | goto error_return; | 931 | | | 932 | | /* Fill in the contents of these sections. */ | 933 | 1.37k | if (import_name_type == IMPORT_ORDINAL) | 934 | 805 | { | 935 | 805 | if (ordinal == 0) | 936 | | /* See PR 20907 for a reproducer. */ | 937 | 104 | goto error_return; | 938 | | | 939 | 701 | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 940 | 701 | ((unsigned int *) id4->contents)[0] = ordinal; | 941 | 701 | ((unsigned int *) id4->contents)[1] = 0x80000000; | 942 | 701 | ((unsigned int *) id5->contents)[0] = ordinal; | 943 | 701 | ((unsigned int *) id5->contents)[1] = 0x80000000; | 944 | | #else | 945 | | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 946 | | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 947 | | #endif | 948 | 701 | } | 949 | 568 | else | 950 | 568 | { | 951 | 568 | char * symbol; | 952 | 568 | unsigned int len; | 953 | | | 954 | | /* Create .idata$6 - the Hint Name Table. */ | 955 | 568 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 956 | 568 | if (id6 == NULL) | 957 | 0 | goto error_return; | 958 | | | 959 | | /* If necessary, trim the import symbol name. */ | 960 | 568 | symbol = symbol_name; | 961 | | | 962 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 963 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 964 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 965 | | of these is used for a symbol. We strip this leading char for | 966 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 967 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 968 | | | 969 | 568 | if (import_name_type != IMPORT_NAME) | 970 | 567 | { | 971 | 567 | char c = symbol[0]; | 972 | | | 973 | | /* Check that we don't remove for targets with empty | 974 | | USER_LABEL_PREFIX the leading underscore. */ | 975 | 567 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 976 | 567 | || c == '@' || c == '?') | 977 | 0 | symbol++; | 978 | 567 | } | 979 | | | 980 | 568 | len = strlen (symbol); | 981 | 568 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 982 | 233 | { | 983 | | /* Truncate at the first '@'. */ | 984 | 233 | char *at = strchr (symbol, '@'); | 985 | | | 986 | 233 | if (at != NULL) | 987 | 0 | len = at - symbol; | 988 | 233 | } | 989 | | | 990 | 568 | id6->contents[0] = ordinal & 0xff; | 991 | 568 | id6->contents[1] = ordinal >> 8; | 992 | | | 993 | 568 | memcpy ((char *) id6->contents + 2, symbol, len); | 994 | 568 | id6->contents[len + 2] = '\0'; | 995 | 568 | } | 996 | | | 997 | 1.26k | if (import_name_type != IMPORT_ORDINAL) | 998 | 568 | { | 999 | 568 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1000 | 568 | pe_ILF_save_relocs (&vars, id4); | 1001 | | | 1002 | 568 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1003 | 568 | pe_ILF_save_relocs (&vars, id5); | 1004 | 568 | } | 1005 | | | 1006 | | /* Create an import symbol. */ | 1007 | 1.26k | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 1008 | 1.26k | imp_sym = vars.sym_ptr_ptr - 1; | 1009 | 1.26k | imp_index = vars.sym_index - 1; | 1010 | | | 1011 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1012 | 1.26k | switch (import_type) | 1013 | 1.26k | { | 1014 | 0 | int i; | 1015 | | | 1016 | 803 | case IMPORT_CODE: | 1017 | | /* CODE functions are special, in that they get a trampoline that | 1018 | | jumps to the main import symbol. Create a .text section to hold it. | 1019 | | First we need to look up its contents in the jump table. */ | 1020 | 1.60k | for (i = NUM_ENTRIES (jtab); i--;) | 1021 | 1.60k | { | 1022 | 1.60k | if (jtab[i].size == 0) | 1023 | 803 | continue; | 1024 | 803 | if (jtab[i].magic == magic) | 1025 | 803 | break; | 1026 | 803 | } | 1027 | | /* If we did not find a matching entry something is wrong. */ | 1028 | 803 | if (i < 0) | 1029 | 0 | abort (); | 1030 | | | 1031 | | /* Create the .text section. */ | 1032 | 803 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1033 | 803 | if (text == NULL) | 1034 | 0 | goto error_return; | 1035 | | | 1036 | | /* Copy in the jump code. */ | 1037 | 803 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1038 | | | 1039 | | /* Create a reloc for the data in the text section. */ | 1040 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1041 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1042 | | { | 1043 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1044 | | (struct bfd_symbol **) imp_sym, | 1045 | | imp_index); | 1046 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1047 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1048 | | (struct bfd_symbol **) imp_sym, | 1049 | | imp_index); | 1050 | | } | 1051 | | else | 1052 | | #endif | 1053 | 803 | #ifdef AMD64MAGIC | 1054 | 803 | if (magic == AMD64MAGIC) | 1055 | 803 | { | 1056 | 803 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1057 | 803 | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1058 | 803 | imp_index); | 1059 | 803 | } | 1060 | 0 | else | 1061 | 0 | #endif | 1062 | 0 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1063 | 0 | BFD_RELOC_32, (asymbol **) imp_sym, | 1064 | 0 | imp_index); | 1065 | | | 1066 | 803 | pe_ILF_save_relocs (& vars, text); | 1067 | 803 | break; | 1068 | | | 1069 | 466 | case IMPORT_DATA: | 1070 | 466 | break; | 1071 | | | 1072 | 0 | default: | 1073 | | /* XXX code not yet written. */ | 1074 | 0 | abort (); | 1075 | 1.26k | } | 1076 | | | 1077 | | /* Now create a symbol describing the imported value. */ | 1078 | 1.26k | switch (import_type) | 1079 | 1.26k | { | 1080 | 803 | case IMPORT_CODE: | 1081 | 803 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1082 | 803 | BSF_NOT_AT_END | BSF_FUNCTION); | 1083 | | | 1084 | 803 | break; | 1085 | | | 1086 | 466 | case IMPORT_DATA: | 1087 | | /* Nothing to do here. */ | 1088 | 466 | break; | 1089 | | | 1090 | 0 | default: | 1091 | | /* XXX code not yet written. */ | 1092 | 0 | abort (); | 1093 | 1.26k | } | 1094 | | | 1095 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1096 | 1.26k | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1097 | 1.26k | if (ptr) | 1098 | 334 | * ptr = 0; | 1099 | 1.26k | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1100 | 1.26k | if (ptr) | 1101 | 334 | * ptr = '.'; | 1102 | | | 1103 | | /* Initialise the bfd. */ | 1104 | 1.26k | memset (& internal_f, 0, sizeof (internal_f)); | 1105 | | | 1106 | 1.26k | internal_f.f_magic = magic; | 1107 | 1.26k | internal_f.f_symptr = 0; | 1108 | 1.26k | internal_f.f_nsyms = 0; | 1109 | 1.26k | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1110 | | | 1111 | 1.26k | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1112 | 1.26k | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1113 | 0 | goto error_return; | 1114 | | | 1115 | 1.26k | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1116 | 0 | goto error_return; | 1117 | | | 1118 | 1.26k | obj_pe (abfd) = true; | 1119 | | #ifdef THUMBPEMAGIC | 1120 | | if (vars.magic == THUMBPEMAGIC) | 1121 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1122 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1123 | | #endif | 1124 | | | 1125 | | /* Switch from file contents to memory contents. */ | 1126 | 1.26k | bfd_cache_close (abfd); | 1127 | | | 1128 | 1.26k | abfd->iostream = (void *) vars.bim; | 1129 | 1.26k | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1130 | 1.26k | abfd->iovec = &_bfd_memory_iovec; | 1131 | 1.26k | abfd->where = 0; | 1132 | 1.26k | abfd->origin = 0; | 1133 | 1.26k | abfd->size = 0; | 1134 | 1.26k | obj_sym_filepos (abfd) = 0; | 1135 | | | 1136 | | /* Point the bfd at the symbol table. */ | 1137 | 1.26k | obj_symbols (abfd) = vars.sym_cache; | 1138 | 1.26k | abfd->symcount = vars.sym_index; | 1139 | | | 1140 | 1.26k | obj_raw_syments (abfd) = vars.native_syms; | 1141 | 1.26k | obj_raw_syment_count (abfd) = vars.sym_index; | 1142 | | | 1143 | 1.26k | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1144 | 1.26k | obj_coff_keep_syms (abfd) = true; | 1145 | | | 1146 | 1.26k | obj_convert (abfd) = vars.sym_table; | 1147 | 1.26k | obj_conv_table_size (abfd) = vars.sym_index; | 1148 | | | 1149 | 1.26k | obj_coff_strings (abfd) = vars.string_table; | 1150 | 1.26k | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1151 | 1.26k | obj_coff_keep_strings (abfd) = true; | 1152 | | | 1153 | 1.26k | return true; | 1154 | | | 1155 | 104 | error_return: | 1156 | 104 | free (vars.bim->buffer); | 1157 | 104 | free (vars.bim); | 1158 | 104 | return false; | 1159 | 1.26k | } |
pei-aarch64.c:pe_ILF_build_a_bfd Line | Count | Source | 798 | 977 | { | 799 | 977 | bfd_byte * ptr; | 800 | 977 | pe_ILF_vars vars; | 801 | 977 | struct internal_filehdr internal_f; | 802 | 977 | unsigned int import_type; | 803 | 977 | unsigned int import_name_type; | 804 | 977 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 805 | 977 | coff_symbol_type ** imp_sym; | 806 | 977 | unsigned int imp_index; | 807 | 977 | intptr_t alignment; | 808 | | | 809 | | /* Decode and verify the types field of the ILF structure. */ | 810 | 977 | import_type = types & 0x3; | 811 | 977 | import_name_type = (types & 0x1c) >> 2; | 812 | | | 813 | 977 | switch (import_type) | 814 | 977 | { | 815 | 238 | case IMPORT_CODE: | 816 | 972 | case IMPORT_DATA: | 817 | 972 | break; | 818 | | | 819 | 3 | case IMPORT_CONST: | 820 | | /* XXX code yet to be written. */ | 821 | | /* xgettext:c-format */ | 822 | 3 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 823 | 3 | abfd, import_type); | 824 | 3 | return false; | 825 | | | 826 | 2 | default: | 827 | | /* xgettext:c-format */ | 828 | 2 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 829 | 2 | abfd, import_type); | 830 | 2 | return false; | 831 | 977 | } | 832 | | | 833 | 972 | switch (import_name_type) | 834 | 972 | { | 835 | 237 | case IMPORT_ORDINAL: | 836 | 471 | case IMPORT_NAME: | 837 | 472 | case IMPORT_NAME_NOPREFIX: | 838 | 969 | case IMPORT_NAME_UNDECORATE: | 839 | 969 | break; | 840 | | | 841 | 3 | default: | 842 | | /* xgettext:c-format */ | 843 | 3 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 844 | 3 | abfd, import_name_type); | 845 | 3 | return false; | 846 | 972 | } | 847 | | | 848 | | /* Initialise local variables. | 849 | | | 850 | | Note these are kept in a structure rather than being | 851 | | declared as statics since bfd frowns on global variables. | 852 | | | 853 | | We are going to construct the contents of the BFD in memory, | 854 | | so allocate all the space that we will need right now. */ | 855 | 969 | vars.bim | 856 | 969 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 857 | 969 | if (vars.bim == NULL) | 858 | 0 | return false; | 859 | | | 860 | 969 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 861 | 969 | vars.bim->buffer = ptr; | 862 | 969 | vars.bim->size = ILF_DATA_SIZE; | 863 | 969 | if (ptr == NULL) | 864 | 0 | goto error_return; | 865 | | | 866 | | /* Initialise the pointers to regions of the memory and the | 867 | | other contents of the pe_ILF_vars structure as well. */ | 868 | 969 | vars.sym_cache = (coff_symbol_type *) ptr; | 869 | 969 | vars.sym_ptr = (coff_symbol_type *) ptr; | 870 | 969 | vars.sym_index = 0; | 871 | 969 | ptr += SIZEOF_ILF_SYMS; | 872 | | | 873 | 969 | vars.sym_table = (unsigned int *) ptr; | 874 | 969 | vars.table_ptr = (unsigned int *) ptr; | 875 | 969 | ptr += SIZEOF_ILF_SYM_TABLE; | 876 | | | 877 | 969 | vars.native_syms = (combined_entry_type *) ptr; | 878 | 969 | vars.native_ptr = (combined_entry_type *) ptr; | 879 | 969 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 880 | | | 881 | 969 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 882 | 969 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 883 | 969 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 884 | | | 885 | 969 | vars.esym_table = (SYMENT *) ptr; | 886 | 969 | vars.esym_ptr = (SYMENT *) ptr; | 887 | 969 | ptr += SIZEOF_ILF_EXT_SYMS; | 888 | | | 889 | 969 | vars.reltab = (arelent *) ptr; | 890 | 969 | vars.relcount = 0; | 891 | 969 | ptr += SIZEOF_ILF_RELOCS; | 892 | | | 893 | 969 | vars.int_reltab = (struct internal_reloc *) ptr; | 894 | 969 | ptr += SIZEOF_ILF_INT_RELOCS; | 895 | | | 896 | 969 | vars.string_table = (char *) ptr; | 897 | 969 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 898 | 969 | ptr += SIZEOF_ILF_STRINGS; | 899 | 969 | vars.end_string_ptr = (char *) ptr; | 900 | | | 901 | | /* The remaining space in bim->buffer is used | 902 | | by the pe_ILF_make_a_section() function. */ | 903 | | | 904 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 905 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 906 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 907 | | alignment. */ | 908 | 969 | #if GCC_VERSION >= 3000 | 909 | 969 | alignment = __alignof__ (struct coff_section_tdata); | 910 | | #else | 911 | | alignment = 8; | 912 | | #endif | 913 | 969 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 914 | | | 915 | 969 | vars.data = ptr; | 916 | 969 | vars.abfd = abfd; | 917 | 969 | vars.sec_index = 0; | 918 | 969 | vars.magic = magic; | 919 | | | 920 | | /* Create the initial .idata$<n> sections: | 921 | | [.idata$2: Import Directory Table -- not needed] | 922 | | .idata$4: Import Lookup Table | 923 | | .idata$5: Import Address Table | 924 | | | 925 | | Note we do not create a .idata$3 section as this is | 926 | | created for us by the linker script. */ | 927 | 969 | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 928 | 969 | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 929 | 969 | if (id4 == NULL || id5 == NULL) | 930 | 0 | goto error_return; | 931 | | | 932 | | /* Fill in the contents of these sections. */ | 933 | 969 | if (import_name_type == IMPORT_ORDINAL) | 934 | 237 | { | 935 | 237 | if (ordinal == 0) | 936 | | /* See PR 20907 for a reproducer. */ | 937 | 2 | goto error_return; | 938 | | | 939 | 235 | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 940 | 235 | ((unsigned int *) id4->contents)[0] = ordinal; | 941 | 235 | ((unsigned int *) id4->contents)[1] = 0x80000000; | 942 | 235 | ((unsigned int *) id5->contents)[0] = ordinal; | 943 | 235 | ((unsigned int *) id5->contents)[1] = 0x80000000; | 944 | | #else | 945 | | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 946 | | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 947 | | #endif | 948 | 235 | } | 949 | 732 | else | 950 | 732 | { | 951 | 732 | char * symbol; | 952 | 732 | unsigned int len; | 953 | | | 954 | | /* Create .idata$6 - the Hint Name Table. */ | 955 | 732 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 956 | 732 | if (id6 == NULL) | 957 | 0 | goto error_return; | 958 | | | 959 | | /* If necessary, trim the import symbol name. */ | 960 | 732 | symbol = symbol_name; | 961 | | | 962 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 963 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 964 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 965 | | of these is used for a symbol. We strip this leading char for | 966 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 967 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 968 | | | 969 | 732 | if (import_name_type != IMPORT_NAME) | 970 | 498 | { | 971 | 498 | char c = symbol[0]; | 972 | | | 973 | | /* Check that we don't remove for targets with empty | 974 | | USER_LABEL_PREFIX the leading underscore. */ | 975 | 498 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 976 | 498 | || c == '@' || c == '?') | 977 | 233 | symbol++; | 978 | 498 | } | 979 | | | 980 | 732 | len = strlen (symbol); | 981 | 732 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 982 | 497 | { | 983 | | /* Truncate at the first '@'. */ | 984 | 497 | char *at = strchr (symbol, '@'); | 985 | | | 986 | 497 | if (at != NULL) | 987 | 0 | len = at - symbol; | 988 | 497 | } | 989 | | | 990 | 732 | id6->contents[0] = ordinal & 0xff; | 991 | 732 | id6->contents[1] = ordinal >> 8; | 992 | | | 993 | 732 | memcpy ((char *) id6->contents + 2, symbol, len); | 994 | 732 | id6->contents[len + 2] = '\0'; | 995 | 732 | } | 996 | | | 997 | 967 | if (import_name_type != IMPORT_ORDINAL) | 998 | 732 | { | 999 | 732 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1000 | 732 | pe_ILF_save_relocs (&vars, id4); | 1001 | | | 1002 | 732 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1003 | 732 | pe_ILF_save_relocs (&vars, id5); | 1004 | 732 | } | 1005 | | | 1006 | | /* Create an import symbol. */ | 1007 | 967 | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 1008 | 967 | imp_sym = vars.sym_ptr_ptr - 1; | 1009 | 967 | imp_index = vars.sym_index - 1; | 1010 | | | 1011 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1012 | 967 | switch (import_type) | 1013 | 967 | { | 1014 | 0 | int i; | 1015 | | | 1016 | 235 | case IMPORT_CODE: | 1017 | | /* CODE functions are special, in that they get a trampoline that | 1018 | | jumps to the main import symbol. Create a .text section to hold it. | 1019 | | First we need to look up its contents in the jump table. */ | 1020 | 470 | for (i = NUM_ENTRIES (jtab); i--;) | 1021 | 470 | { | 1022 | 470 | if (jtab[i].size == 0) | 1023 | 235 | continue; | 1024 | 235 | if (jtab[i].magic == magic) | 1025 | 235 | break; | 1026 | 235 | } | 1027 | | /* If we did not find a matching entry something is wrong. */ | 1028 | 235 | if (i < 0) | 1029 | 0 | abort (); | 1030 | | | 1031 | | /* Create the .text section. */ | 1032 | 235 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1033 | 235 | if (text == NULL) | 1034 | 0 | goto error_return; | 1035 | | | 1036 | | /* Copy in the jump code. */ | 1037 | 235 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1038 | | | 1039 | | /* Create a reloc for the data in the text section. */ | 1040 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1041 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1042 | | { | 1043 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1044 | | (struct bfd_symbol **) imp_sym, | 1045 | | imp_index); | 1046 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1047 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1048 | | (struct bfd_symbol **) imp_sym, | 1049 | | imp_index); | 1050 | | } | 1051 | | else | 1052 | | #endif | 1053 | | #ifdef AMD64MAGIC | 1054 | | if (magic == AMD64MAGIC) | 1055 | | { | 1056 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1057 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1058 | | imp_index); | 1059 | | } | 1060 | | else | 1061 | | #endif | 1062 | 235 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1063 | 235 | BFD_RELOC_32, (asymbol **) imp_sym, | 1064 | 235 | imp_index); | 1065 | | | 1066 | 235 | pe_ILF_save_relocs (& vars, text); | 1067 | 235 | break; | 1068 | | | 1069 | 732 | case IMPORT_DATA: | 1070 | 732 | break; | 1071 | | | 1072 | 0 | default: | 1073 | | /* XXX code not yet written. */ | 1074 | 0 | abort (); | 1075 | 967 | } | 1076 | | | 1077 | | /* Now create a symbol describing the imported value. */ | 1078 | 967 | switch (import_type) | 1079 | 967 | { | 1080 | 235 | case IMPORT_CODE: | 1081 | 235 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1082 | 235 | BSF_NOT_AT_END | BSF_FUNCTION); | 1083 | | | 1084 | 235 | break; | 1085 | | | 1086 | 732 | case IMPORT_DATA: | 1087 | | /* Nothing to do here. */ | 1088 | 732 | break; | 1089 | | | 1090 | 0 | default: | 1091 | | /* XXX code not yet written. */ | 1092 | 0 | abort (); | 1093 | 967 | } | 1094 | | | 1095 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1096 | 967 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1097 | 967 | if (ptr) | 1098 | 466 | * ptr = 0; | 1099 | 967 | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1100 | 967 | if (ptr) | 1101 | 466 | * ptr = '.'; | 1102 | | | 1103 | | /* Initialise the bfd. */ | 1104 | 967 | memset (& internal_f, 0, sizeof (internal_f)); | 1105 | | | 1106 | 967 | internal_f.f_magic = magic; | 1107 | 967 | internal_f.f_symptr = 0; | 1108 | 967 | internal_f.f_nsyms = 0; | 1109 | 967 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1110 | | | 1111 | 967 | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1112 | 967 | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1113 | 0 | goto error_return; | 1114 | | | 1115 | 967 | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1116 | 0 | goto error_return; | 1117 | | | 1118 | 967 | obj_pe (abfd) = true; | 1119 | | #ifdef THUMBPEMAGIC | 1120 | | if (vars.magic == THUMBPEMAGIC) | 1121 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1122 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1123 | | #endif | 1124 | | | 1125 | | /* Switch from file contents to memory contents. */ | 1126 | 967 | bfd_cache_close (abfd); | 1127 | | | 1128 | 967 | abfd->iostream = (void *) vars.bim; | 1129 | 967 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1130 | 967 | abfd->iovec = &_bfd_memory_iovec; | 1131 | 967 | abfd->where = 0; | 1132 | 967 | abfd->origin = 0; | 1133 | 967 | abfd->size = 0; | 1134 | 967 | obj_sym_filepos (abfd) = 0; | 1135 | | | 1136 | | /* Point the bfd at the symbol table. */ | 1137 | 967 | obj_symbols (abfd) = vars.sym_cache; | 1138 | 967 | abfd->symcount = vars.sym_index; | 1139 | | | 1140 | 967 | obj_raw_syments (abfd) = vars.native_syms; | 1141 | 967 | obj_raw_syment_count (abfd) = vars.sym_index; | 1142 | | | 1143 | 967 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1144 | 967 | obj_coff_keep_syms (abfd) = true; | 1145 | | | 1146 | 967 | obj_convert (abfd) = vars.sym_table; | 1147 | 967 | obj_conv_table_size (abfd) = vars.sym_index; | 1148 | | | 1149 | 967 | obj_coff_strings (abfd) = vars.string_table; | 1150 | 967 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1151 | 967 | obj_coff_keep_strings (abfd) = true; | 1152 | | | 1153 | 967 | return true; | 1154 | | | 1155 | 2 | error_return: | 1156 | 2 | free (vars.bim->buffer); | 1157 | 2 | free (vars.bim); | 1158 | 2 | return false; | 1159 | 967 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_build_a_bfd pei-loongarch64.c:pe_ILF_build_a_bfd Line | Count | Source | 798 | 1.74k | { | 799 | 1.74k | bfd_byte * ptr; | 800 | 1.74k | pe_ILF_vars vars; | 801 | 1.74k | struct internal_filehdr internal_f; | 802 | 1.74k | unsigned int import_type; | 803 | 1.74k | unsigned int import_name_type; | 804 | 1.74k | asection_ptr id4, id5, id6 = NULL, text = NULL; | 805 | 1.74k | coff_symbol_type ** imp_sym; | 806 | 1.74k | unsigned int imp_index; | 807 | 1.74k | intptr_t alignment; | 808 | | | 809 | | /* Decode and verify the types field of the ILF structure. */ | 810 | 1.74k | import_type = types & 0x3; | 811 | 1.74k | import_name_type = (types & 0x1c) >> 2; | 812 | | | 813 | 1.74k | switch (import_type) | 814 | 1.74k | { | 815 | 937 | case IMPORT_CODE: | 816 | 1.54k | case IMPORT_DATA: | 817 | 1.54k | break; | 818 | | | 819 | 104 | case IMPORT_CONST: | 820 | | /* XXX code yet to be written. */ | 821 | | /* xgettext:c-format */ | 822 | 104 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 823 | 104 | abfd, import_type); | 824 | 104 | return false; | 825 | | | 826 | 104 | default: | 827 | | /* xgettext:c-format */ | 828 | 104 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 829 | 104 | abfd, import_type); | 830 | 104 | return false; | 831 | 1.74k | } | 832 | | | 833 | 1.54k | switch (import_name_type) | 834 | 1.54k | { | 835 | 572 | case IMPORT_ORDINAL: | 836 | 705 | case IMPORT_NAME: | 837 | 705 | case IMPORT_NAME_NOPREFIX: | 838 | 1.43k | case IMPORT_NAME_UNDECORATE: | 839 | 1.43k | break; | 840 | | | 841 | 103 | default: | 842 | | /* xgettext:c-format */ | 843 | 103 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 844 | 103 | abfd, import_name_type); | 845 | 103 | return false; | 846 | 1.54k | } | 847 | | | 848 | | /* Initialise local variables. | 849 | | | 850 | | Note these are kept in a structure rather than being | 851 | | declared as statics since bfd frowns on global variables. | 852 | | | 853 | | We are going to construct the contents of the BFD in memory, | 854 | | so allocate all the space that we will need right now. */ | 855 | 1.43k | vars.bim | 856 | 1.43k | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 857 | 1.43k | if (vars.bim == NULL) | 858 | 0 | return false; | 859 | | | 860 | 1.43k | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 861 | 1.43k | vars.bim->buffer = ptr; | 862 | 1.43k | vars.bim->size = ILF_DATA_SIZE; | 863 | 1.43k | if (ptr == NULL) | 864 | 0 | goto error_return; | 865 | | | 866 | | /* Initialise the pointers to regions of the memory and the | 867 | | other contents of the pe_ILF_vars structure as well. */ | 868 | 1.43k | vars.sym_cache = (coff_symbol_type *) ptr; | 869 | 1.43k | vars.sym_ptr = (coff_symbol_type *) ptr; | 870 | 1.43k | vars.sym_index = 0; | 871 | 1.43k | ptr += SIZEOF_ILF_SYMS; | 872 | | | 873 | 1.43k | vars.sym_table = (unsigned int *) ptr; | 874 | 1.43k | vars.table_ptr = (unsigned int *) ptr; | 875 | 1.43k | ptr += SIZEOF_ILF_SYM_TABLE; | 876 | | | 877 | 1.43k | vars.native_syms = (combined_entry_type *) ptr; | 878 | 1.43k | vars.native_ptr = (combined_entry_type *) ptr; | 879 | 1.43k | ptr += SIZEOF_ILF_NATIVE_SYMS; | 880 | | | 881 | 1.43k | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 882 | 1.43k | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 883 | 1.43k | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 884 | | | 885 | 1.43k | vars.esym_table = (SYMENT *) ptr; | 886 | 1.43k | vars.esym_ptr = (SYMENT *) ptr; | 887 | 1.43k | ptr += SIZEOF_ILF_EXT_SYMS; | 888 | | | 889 | 1.43k | vars.reltab = (arelent *) ptr; | 890 | 1.43k | vars.relcount = 0; | 891 | 1.43k | ptr += SIZEOF_ILF_RELOCS; | 892 | | | 893 | 1.43k | vars.int_reltab = (struct internal_reloc *) ptr; | 894 | 1.43k | ptr += SIZEOF_ILF_INT_RELOCS; | 895 | | | 896 | 1.43k | vars.string_table = (char *) ptr; | 897 | 1.43k | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 898 | 1.43k | ptr += SIZEOF_ILF_STRINGS; | 899 | 1.43k | vars.end_string_ptr = (char *) ptr; | 900 | | | 901 | | /* The remaining space in bim->buffer is used | 902 | | by the pe_ILF_make_a_section() function. */ | 903 | | | 904 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 905 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 906 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 907 | | alignment. */ | 908 | 1.43k | #if GCC_VERSION >= 3000 | 909 | 1.43k | alignment = __alignof__ (struct coff_section_tdata); | 910 | | #else | 911 | | alignment = 8; | 912 | | #endif | 913 | 1.43k | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 914 | | | 915 | 1.43k | vars.data = ptr; | 916 | 1.43k | vars.abfd = abfd; | 917 | 1.43k | vars.sec_index = 0; | 918 | 1.43k | vars.magic = magic; | 919 | | | 920 | | /* Create the initial .idata$<n> sections: | 921 | | [.idata$2: Import Directory Table -- not needed] | 922 | | .idata$4: Import Lookup Table | 923 | | .idata$5: Import Address Table | 924 | | | 925 | | Note we do not create a .idata$3 section as this is | 926 | | created for us by the linker script. */ | 927 | 1.43k | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 928 | 1.43k | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 929 | 1.43k | if (id4 == NULL || id5 == NULL) | 930 | 0 | goto error_return; | 931 | | | 932 | | /* Fill in the contents of these sections. */ | 933 | 1.43k | if (import_name_type == IMPORT_ORDINAL) | 934 | 572 | { | 935 | 572 | if (ordinal == 0) | 936 | | /* See PR 20907 for a reproducer. */ | 937 | 3 | goto error_return; | 938 | | | 939 | 569 | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 940 | 569 | ((unsigned int *) id4->contents)[0] = ordinal; | 941 | 569 | ((unsigned int *) id4->contents)[1] = 0x80000000; | 942 | 569 | ((unsigned int *) id5->contents)[0] = ordinal; | 943 | 569 | ((unsigned int *) id5->contents)[1] = 0x80000000; | 944 | | #else | 945 | | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 946 | | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 947 | | #endif | 948 | 569 | } | 949 | 865 | else | 950 | 865 | { | 951 | 865 | char * symbol; | 952 | 865 | unsigned int len; | 953 | | | 954 | | /* Create .idata$6 - the Hint Name Table. */ | 955 | 865 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 956 | 865 | if (id6 == NULL) | 957 | 0 | goto error_return; | 958 | | | 959 | | /* If necessary, trim the import symbol name. */ | 960 | 865 | symbol = symbol_name; | 961 | | | 962 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 963 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 964 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 965 | | of these is used for a symbol. We strip this leading char for | 966 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 967 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 968 | | | 969 | 865 | if (import_name_type != IMPORT_NAME) | 970 | 732 | { | 971 | 732 | char c = symbol[0]; | 972 | | | 973 | | /* Check that we don't remove for targets with empty | 974 | | USER_LABEL_PREFIX the leading underscore. */ | 975 | 732 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 976 | 732 | || c == '@' || c == '?') | 977 | 133 | symbol++; | 978 | 732 | } | 979 | | | 980 | 865 | len = strlen (symbol); | 981 | 865 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 982 | 732 | { | 983 | | /* Truncate at the first '@'. */ | 984 | 732 | char *at = strchr (symbol, '@'); | 985 | | | 986 | 732 | if (at != NULL) | 987 | 132 | len = at - symbol; | 988 | 732 | } | 989 | | | 990 | 865 | id6->contents[0] = ordinal & 0xff; | 991 | 865 | id6->contents[1] = ordinal >> 8; | 992 | | | 993 | 865 | memcpy ((char *) id6->contents + 2, symbol, len); | 994 | 865 | id6->contents[len + 2] = '\0'; | 995 | 865 | } | 996 | | | 997 | 1.43k | if (import_name_type != IMPORT_ORDINAL) | 998 | 865 | { | 999 | 865 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1000 | 865 | pe_ILF_save_relocs (&vars, id4); | 1001 | | | 1002 | 865 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1003 | 865 | pe_ILF_save_relocs (&vars, id5); | 1004 | 865 | } | 1005 | | | 1006 | | /* Create an import symbol. */ | 1007 | 1.43k | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 1008 | 1.43k | imp_sym = vars.sym_ptr_ptr - 1; | 1009 | 1.43k | imp_index = vars.sym_index - 1; | 1010 | | | 1011 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1012 | 1.43k | switch (import_type) | 1013 | 1.43k | { | 1014 | 0 | int i; | 1015 | | | 1016 | 934 | case IMPORT_CODE: | 1017 | | /* CODE functions are special, in that they get a trampoline that | 1018 | | jumps to the main import symbol. Create a .text section to hold it. | 1019 | | First we need to look up its contents in the jump table. */ | 1020 | 1.86k | for (i = NUM_ENTRIES (jtab); i--;) | 1021 | 1.86k | { | 1022 | 1.86k | if (jtab[i].size == 0) | 1023 | 934 | continue; | 1024 | 934 | if (jtab[i].magic == magic) | 1025 | 934 | break; | 1026 | 934 | } | 1027 | | /* If we did not find a matching entry something is wrong. */ | 1028 | 934 | if (i < 0) | 1029 | 0 | abort (); | 1030 | | | 1031 | | /* Create the .text section. */ | 1032 | 934 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1033 | 934 | if (text == NULL) | 1034 | 0 | goto error_return; | 1035 | | | 1036 | | /* Copy in the jump code. */ | 1037 | 934 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1038 | | | 1039 | | /* Create a reloc for the data in the text section. */ | 1040 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1041 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1042 | | { | 1043 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1044 | | (struct bfd_symbol **) imp_sym, | 1045 | | imp_index); | 1046 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1047 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1048 | | (struct bfd_symbol **) imp_sym, | 1049 | | imp_index); | 1050 | | } | 1051 | | else | 1052 | | #endif | 1053 | | #ifdef AMD64MAGIC | 1054 | | if (magic == AMD64MAGIC) | 1055 | | { | 1056 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1057 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1058 | | imp_index); | 1059 | | } | 1060 | | else | 1061 | | #endif | 1062 | 934 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1063 | 934 | BFD_RELOC_32, (asymbol **) imp_sym, | 1064 | 934 | imp_index); | 1065 | | | 1066 | 934 | pe_ILF_save_relocs (& vars, text); | 1067 | 934 | break; | 1068 | | | 1069 | 500 | case IMPORT_DATA: | 1070 | 500 | break; | 1071 | | | 1072 | 0 | default: | 1073 | | /* XXX code not yet written. */ | 1074 | 0 | abort (); | 1075 | 1.43k | } | 1076 | | | 1077 | | /* Now create a symbol describing the imported value. */ | 1078 | 1.43k | switch (import_type) | 1079 | 1.43k | { | 1080 | 934 | case IMPORT_CODE: | 1081 | 934 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1082 | 934 | BSF_NOT_AT_END | BSF_FUNCTION); | 1083 | | | 1084 | 934 | break; | 1085 | | | 1086 | 500 | case IMPORT_DATA: | 1087 | | /* Nothing to do here. */ | 1088 | 500 | break; | 1089 | | | 1090 | 0 | default: | 1091 | | /* XXX code not yet written. */ | 1092 | 0 | abort (); | 1093 | 1.43k | } | 1094 | | | 1095 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1096 | 1.43k | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1097 | 1.43k | if (ptr) | 1098 | 265 | * ptr = 0; | 1099 | 1.43k | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1100 | 1.43k | if (ptr) | 1101 | 265 | * ptr = '.'; | 1102 | | | 1103 | | /* Initialise the bfd. */ | 1104 | 1.43k | memset (& internal_f, 0, sizeof (internal_f)); | 1105 | | | 1106 | 1.43k | internal_f.f_magic = magic; | 1107 | 1.43k | internal_f.f_symptr = 0; | 1108 | 1.43k | internal_f.f_nsyms = 0; | 1109 | 1.43k | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1110 | | | 1111 | 1.43k | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1112 | 1.43k | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1113 | 0 | goto error_return; | 1114 | | | 1115 | 1.43k | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1116 | 0 | goto error_return; | 1117 | | | 1118 | 1.43k | obj_pe (abfd) = true; | 1119 | | #ifdef THUMBPEMAGIC | 1120 | | if (vars.magic == THUMBPEMAGIC) | 1121 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1122 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1123 | | #endif | 1124 | | | 1125 | | /* Switch from file contents to memory contents. */ | 1126 | 1.43k | bfd_cache_close (abfd); | 1127 | | | 1128 | 1.43k | abfd->iostream = (void *) vars.bim; | 1129 | 1.43k | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1130 | 1.43k | abfd->iovec = &_bfd_memory_iovec; | 1131 | 1.43k | abfd->where = 0; | 1132 | 1.43k | abfd->origin = 0; | 1133 | 1.43k | abfd->size = 0; | 1134 | 1.43k | obj_sym_filepos (abfd) = 0; | 1135 | | | 1136 | | /* Point the bfd at the symbol table. */ | 1137 | 1.43k | obj_symbols (abfd) = vars.sym_cache; | 1138 | 1.43k | abfd->symcount = vars.sym_index; | 1139 | | | 1140 | 1.43k | obj_raw_syments (abfd) = vars.native_syms; | 1141 | 1.43k | obj_raw_syment_count (abfd) = vars.sym_index; | 1142 | | | 1143 | 1.43k | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1144 | 1.43k | obj_coff_keep_syms (abfd) = true; | 1145 | | | 1146 | 1.43k | obj_convert (abfd) = vars.sym_table; | 1147 | 1.43k | obj_conv_table_size (abfd) = vars.sym_index; | 1148 | | | 1149 | 1.43k | obj_coff_strings (abfd) = vars.string_table; | 1150 | 1.43k | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1151 | 1.43k | obj_coff_keep_strings (abfd) = true; | 1152 | | | 1153 | 1.43k | return true; | 1154 | | | 1155 | 3 | error_return: | 1156 | 3 | free (vars.bim->buffer); | 1157 | 3 | free (vars.bim); | 1158 | 3 | return false; | 1159 | 1.43k | } |
pei-arm-wince.c:pe_ILF_build_a_bfd Line | Count | Source | 798 | 619 | { | 799 | 619 | bfd_byte * ptr; | 800 | 619 | pe_ILF_vars vars; | 801 | 619 | struct internal_filehdr internal_f; | 802 | 619 | unsigned int import_type; | 803 | 619 | unsigned int import_name_type; | 804 | 619 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 805 | 619 | coff_symbol_type ** imp_sym; | 806 | 619 | unsigned int imp_index; | 807 | 619 | intptr_t alignment; | 808 | | | 809 | | /* Decode and verify the types field of the ILF structure. */ | 810 | 619 | import_type = types & 0x3; | 811 | 619 | import_name_type = (types & 0x1c) >> 2; | 812 | | | 813 | 619 | switch (import_type) | 814 | 619 | { | 815 | 107 | case IMPORT_CODE: | 816 | 110 | case IMPORT_DATA: | 817 | 110 | break; | 818 | | | 819 | 508 | case IMPORT_CONST: | 820 | | /* XXX code yet to be written. */ | 821 | | /* xgettext:c-format */ | 822 | 508 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 823 | 508 | abfd, import_type); | 824 | 508 | return false; | 825 | | | 826 | 1 | default: | 827 | | /* xgettext:c-format */ | 828 | 1 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 829 | 1 | abfd, import_type); | 830 | 1 | return false; | 831 | 619 | } | 832 | | | 833 | 110 | switch (import_name_type) | 834 | 110 | { | 835 | 103 | case IMPORT_ORDINAL: | 836 | 104 | case IMPORT_NAME: | 837 | 105 | case IMPORT_NAME_NOPREFIX: | 838 | 107 | case IMPORT_NAME_UNDECORATE: | 839 | 107 | break; | 840 | | | 841 | 3 | default: | 842 | | /* xgettext:c-format */ | 843 | 3 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 844 | 3 | abfd, import_name_type); | 845 | 3 | return false; | 846 | 110 | } | 847 | | | 848 | | /* Initialise local variables. | 849 | | | 850 | | Note these are kept in a structure rather than being | 851 | | declared as statics since bfd frowns on global variables. | 852 | | | 853 | | We are going to construct the contents of the BFD in memory, | 854 | | so allocate all the space that we will need right now. */ | 855 | 107 | vars.bim | 856 | 107 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 857 | 107 | if (vars.bim == NULL) | 858 | 0 | return false; | 859 | | | 860 | 107 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 861 | 107 | vars.bim->buffer = ptr; | 862 | 107 | vars.bim->size = ILF_DATA_SIZE; | 863 | 107 | if (ptr == NULL) | 864 | 0 | goto error_return; | 865 | | | 866 | | /* Initialise the pointers to regions of the memory and the | 867 | | other contents of the pe_ILF_vars structure as well. */ | 868 | 107 | vars.sym_cache = (coff_symbol_type *) ptr; | 869 | 107 | vars.sym_ptr = (coff_symbol_type *) ptr; | 870 | 107 | vars.sym_index = 0; | 871 | 107 | ptr += SIZEOF_ILF_SYMS; | 872 | | | 873 | 107 | vars.sym_table = (unsigned int *) ptr; | 874 | 107 | vars.table_ptr = (unsigned int *) ptr; | 875 | 107 | ptr += SIZEOF_ILF_SYM_TABLE; | 876 | | | 877 | 107 | vars.native_syms = (combined_entry_type *) ptr; | 878 | 107 | vars.native_ptr = (combined_entry_type *) ptr; | 879 | 107 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 880 | | | 881 | 107 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 882 | 107 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 883 | 107 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 884 | | | 885 | 107 | vars.esym_table = (SYMENT *) ptr; | 886 | 107 | vars.esym_ptr = (SYMENT *) ptr; | 887 | 107 | ptr += SIZEOF_ILF_EXT_SYMS; | 888 | | | 889 | 107 | vars.reltab = (arelent *) ptr; | 890 | 107 | vars.relcount = 0; | 891 | 107 | ptr += SIZEOF_ILF_RELOCS; | 892 | | | 893 | 107 | vars.int_reltab = (struct internal_reloc *) ptr; | 894 | 107 | ptr += SIZEOF_ILF_INT_RELOCS; | 895 | | | 896 | 107 | vars.string_table = (char *) ptr; | 897 | 107 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 898 | 107 | ptr += SIZEOF_ILF_STRINGS; | 899 | 107 | vars.end_string_ptr = (char *) ptr; | 900 | | | 901 | | /* The remaining space in bim->buffer is used | 902 | | by the pe_ILF_make_a_section() function. */ | 903 | | | 904 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 905 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 906 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 907 | | alignment. */ | 908 | 107 | #if GCC_VERSION >= 3000 | 909 | 107 | alignment = __alignof__ (struct coff_section_tdata); | 910 | | #else | 911 | | alignment = 8; | 912 | | #endif | 913 | 107 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 914 | | | 915 | 107 | vars.data = ptr; | 916 | 107 | vars.abfd = abfd; | 917 | 107 | vars.sec_index = 0; | 918 | 107 | vars.magic = magic; | 919 | | | 920 | | /* Create the initial .idata$<n> sections: | 921 | | [.idata$2: Import Directory Table -- not needed] | 922 | | .idata$4: Import Lookup Table | 923 | | .idata$5: Import Address Table | 924 | | | 925 | | Note we do not create a .idata$3 section as this is | 926 | | created for us by the linker script. */ | 927 | 107 | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 928 | 107 | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 929 | 107 | if (id4 == NULL || id5 == NULL) | 930 | 0 | goto error_return; | 931 | | | 932 | | /* Fill in the contents of these sections. */ | 933 | 107 | if (import_name_type == IMPORT_ORDINAL) | 934 | 103 | { | 935 | 103 | if (ordinal == 0) | 936 | | /* See PR 20907 for a reproducer. */ | 937 | 101 | goto error_return; | 938 | | | 939 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 940 | | ((unsigned int *) id4->contents)[0] = ordinal; | 941 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 942 | | ((unsigned int *) id5->contents)[0] = ordinal; | 943 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 944 | | #else | 945 | 2 | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 946 | 2 | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 947 | 2 | #endif | 948 | 2 | } | 949 | 4 | else | 950 | 4 | { | 951 | 4 | char * symbol; | 952 | 4 | unsigned int len; | 953 | | | 954 | | /* Create .idata$6 - the Hint Name Table. */ | 955 | 4 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 956 | 4 | if (id6 == NULL) | 957 | 0 | goto error_return; | 958 | | | 959 | | /* If necessary, trim the import symbol name. */ | 960 | 4 | symbol = symbol_name; | 961 | | | 962 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 963 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 964 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 965 | | of these is used for a symbol. We strip this leading char for | 966 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 967 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 968 | | | 969 | 4 | if (import_name_type != IMPORT_NAME) | 970 | 3 | { | 971 | 3 | char c = symbol[0]; | 972 | | | 973 | | /* Check that we don't remove for targets with empty | 974 | | USER_LABEL_PREFIX the leading underscore. */ | 975 | 3 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 976 | 3 | || c == '@' || c == '?') | 977 | 1 | symbol++; | 978 | 3 | } | 979 | | | 980 | 4 | len = strlen (symbol); | 981 | 4 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 982 | 2 | { | 983 | | /* Truncate at the first '@'. */ | 984 | 2 | char *at = strchr (symbol, '@'); | 985 | | | 986 | 2 | if (at != NULL) | 987 | 0 | len = at - symbol; | 988 | 2 | } | 989 | | | 990 | 4 | id6->contents[0] = ordinal & 0xff; | 991 | 4 | id6->contents[1] = ordinal >> 8; | 992 | | | 993 | 4 | memcpy ((char *) id6->contents + 2, symbol, len); | 994 | 4 | id6->contents[len + 2] = '\0'; | 995 | 4 | } | 996 | | | 997 | 6 | if (import_name_type != IMPORT_ORDINAL) | 998 | 4 | { | 999 | 4 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1000 | 4 | pe_ILF_save_relocs (&vars, id4); | 1001 | | | 1002 | 4 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1003 | 4 | pe_ILF_save_relocs (&vars, id5); | 1004 | 4 | } | 1005 | | | 1006 | | /* Create an import symbol. */ | 1007 | 6 | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 1008 | 6 | imp_sym = vars.sym_ptr_ptr - 1; | 1009 | 6 | imp_index = vars.sym_index - 1; | 1010 | | | 1011 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1012 | 6 | switch (import_type) | 1013 | 6 | { | 1014 | 0 | int i; | 1015 | | | 1016 | 3 | case IMPORT_CODE: | 1017 | | /* CODE functions are special, in that they get a trampoline that | 1018 | | jumps to the main import symbol. Create a .text section to hold it. | 1019 | | First we need to look up its contents in the jump table. */ | 1020 | 9 | for (i = NUM_ENTRIES (jtab); i--;) | 1021 | 9 | { | 1022 | 9 | if (jtab[i].size == 0) | 1023 | 3 | continue; | 1024 | 6 | if (jtab[i].magic == magic) | 1025 | 3 | break; | 1026 | 6 | } | 1027 | | /* If we did not find a matching entry something is wrong. */ | 1028 | 3 | if (i < 0) | 1029 | 0 | abort (); | 1030 | | | 1031 | | /* Create the .text section. */ | 1032 | 3 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1033 | 3 | if (text == NULL) | 1034 | 0 | goto error_return; | 1035 | | | 1036 | | /* Copy in the jump code. */ | 1037 | 3 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1038 | | | 1039 | | /* Create a reloc for the data in the text section. */ | 1040 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1041 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1042 | | { | 1043 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1044 | | (struct bfd_symbol **) imp_sym, | 1045 | | imp_index); | 1046 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1047 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1048 | | (struct bfd_symbol **) imp_sym, | 1049 | | imp_index); | 1050 | | } | 1051 | | else | 1052 | | #endif | 1053 | | #ifdef AMD64MAGIC | 1054 | | if (magic == AMD64MAGIC) | 1055 | | { | 1056 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1057 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1058 | | imp_index); | 1059 | | } | 1060 | | else | 1061 | | #endif | 1062 | 3 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1063 | 3 | BFD_RELOC_32, (asymbol **) imp_sym, | 1064 | 3 | imp_index); | 1065 | | | 1066 | 3 | pe_ILF_save_relocs (& vars, text); | 1067 | 3 | break; | 1068 | | | 1069 | 3 | case IMPORT_DATA: | 1070 | 3 | break; | 1071 | | | 1072 | 0 | default: | 1073 | | /* XXX code not yet written. */ | 1074 | 0 | abort (); | 1075 | 6 | } | 1076 | | | 1077 | | /* Now create a symbol describing the imported value. */ | 1078 | 6 | switch (import_type) | 1079 | 6 | { | 1080 | 3 | case IMPORT_CODE: | 1081 | 3 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1082 | 3 | BSF_NOT_AT_END | BSF_FUNCTION); | 1083 | | | 1084 | 3 | break; | 1085 | | | 1086 | 3 | case IMPORT_DATA: | 1087 | | /* Nothing to do here. */ | 1088 | 3 | break; | 1089 | | | 1090 | 0 | default: | 1091 | | /* XXX code not yet written. */ | 1092 | 0 | abort (); | 1093 | 6 | } | 1094 | | | 1095 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1096 | 6 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1097 | 6 | if (ptr) | 1098 | 1 | * ptr = 0; | 1099 | 6 | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1100 | 6 | if (ptr) | 1101 | 1 | * ptr = '.'; | 1102 | | | 1103 | | /* Initialise the bfd. */ | 1104 | 6 | memset (& internal_f, 0, sizeof (internal_f)); | 1105 | | | 1106 | 6 | internal_f.f_magic = magic; | 1107 | 6 | internal_f.f_symptr = 0; | 1108 | 6 | internal_f.f_nsyms = 0; | 1109 | 6 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1110 | | | 1111 | 6 | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1112 | 6 | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1113 | 0 | goto error_return; | 1114 | | | 1115 | 6 | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1116 | 0 | goto error_return; | 1117 | | | 1118 | 6 | obj_pe (abfd) = true; | 1119 | 6 | #ifdef THUMBPEMAGIC | 1120 | 6 | if (vars.magic == THUMBPEMAGIC) | 1121 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1122 | 1 | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1123 | 6 | #endif | 1124 | | | 1125 | | /* Switch from file contents to memory contents. */ | 1126 | 6 | bfd_cache_close (abfd); | 1127 | | | 1128 | 6 | abfd->iostream = (void *) vars.bim; | 1129 | 6 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1130 | 6 | abfd->iovec = &_bfd_memory_iovec; | 1131 | 6 | abfd->where = 0; | 1132 | 6 | abfd->origin = 0; | 1133 | 6 | abfd->size = 0; | 1134 | 6 | obj_sym_filepos (abfd) = 0; | 1135 | | | 1136 | | /* Point the bfd at the symbol table. */ | 1137 | 6 | obj_symbols (abfd) = vars.sym_cache; | 1138 | 6 | abfd->symcount = vars.sym_index; | 1139 | | | 1140 | 6 | obj_raw_syments (abfd) = vars.native_syms; | 1141 | 6 | obj_raw_syment_count (abfd) = vars.sym_index; | 1142 | | | 1143 | 6 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1144 | 6 | obj_coff_keep_syms (abfd) = true; | 1145 | | | 1146 | 6 | obj_convert (abfd) = vars.sym_table; | 1147 | 6 | obj_conv_table_size (abfd) = vars.sym_index; | 1148 | | | 1149 | 6 | obj_coff_strings (abfd) = vars.string_table; | 1150 | 6 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1151 | 6 | obj_coff_keep_strings (abfd) = true; | 1152 | | | 1153 | 6 | return true; | 1154 | | | 1155 | 101 | error_return: | 1156 | 101 | free (vars.bim->buffer); | 1157 | 101 | free (vars.bim); | 1158 | 101 | return false; | 1159 | 6 | } |
pei-arm.c:pe_ILF_build_a_bfd Line | Count | Source | 798 | 2.23k | { | 799 | 2.23k | bfd_byte * ptr; | 800 | 2.23k | pe_ILF_vars vars; | 801 | 2.23k | struct internal_filehdr internal_f; | 802 | 2.23k | unsigned int import_type; | 803 | 2.23k | unsigned int import_name_type; | 804 | 2.23k | asection_ptr id4, id5, id6 = NULL, text = NULL; | 805 | 2.23k | coff_symbol_type ** imp_sym; | 806 | 2.23k | unsigned int imp_index; | 807 | 2.23k | intptr_t alignment; | 808 | | | 809 | | /* Decode and verify the types field of the ILF structure. */ | 810 | 2.23k | import_type = types & 0x3; | 811 | 2.23k | import_name_type = (types & 0x1c) >> 2; | 812 | | | 813 | 2.23k | switch (import_type) | 814 | 2.23k | { | 815 | 811 | case IMPORT_CODE: | 816 | 1.72k | case IMPORT_DATA: | 817 | 1.72k | break; | 818 | | | 819 | 508 | case IMPORT_CONST: | 820 | | /* XXX code yet to be written. */ | 821 | | /* xgettext:c-format */ | 822 | 508 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 823 | 508 | abfd, import_type); | 824 | 508 | return false; | 825 | | | 826 | 1 | default: | 827 | | /* xgettext:c-format */ | 828 | 1 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 829 | 1 | abfd, import_type); | 830 | 1 | return false; | 831 | 2.23k | } | 832 | | | 833 | 1.72k | switch (import_name_type) | 834 | 1.72k | { | 835 | 575 | case IMPORT_ORDINAL: | 836 | 812 | case IMPORT_NAME: | 837 | 1.25k | case IMPORT_NAME_NOPREFIX: | 838 | 1.72k | case IMPORT_NAME_UNDECORATE: | 839 | 1.72k | break; | 840 | | | 841 | 3 | default: | 842 | | /* xgettext:c-format */ | 843 | 3 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 844 | 3 | abfd, import_name_type); | 845 | 3 | return false; | 846 | 1.72k | } | 847 | | | 848 | | /* Initialise local variables. | 849 | | | 850 | | Note these are kept in a structure rather than being | 851 | | declared as statics since bfd frowns on global variables. | 852 | | | 853 | | We are going to construct the contents of the BFD in memory, | 854 | | so allocate all the space that we will need right now. */ | 855 | 1.72k | vars.bim | 856 | 1.72k | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 857 | 1.72k | if (vars.bim == NULL) | 858 | 0 | return false; | 859 | | | 860 | 1.72k | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 861 | 1.72k | vars.bim->buffer = ptr; | 862 | 1.72k | vars.bim->size = ILF_DATA_SIZE; | 863 | 1.72k | if (ptr == NULL) | 864 | 0 | goto error_return; | 865 | | | 866 | | /* Initialise the pointers to regions of the memory and the | 867 | | other contents of the pe_ILF_vars structure as well. */ | 868 | 1.72k | vars.sym_cache = (coff_symbol_type *) ptr; | 869 | 1.72k | vars.sym_ptr = (coff_symbol_type *) ptr; | 870 | 1.72k | vars.sym_index = 0; | 871 | 1.72k | ptr += SIZEOF_ILF_SYMS; | 872 | | | 873 | 1.72k | vars.sym_table = (unsigned int *) ptr; | 874 | 1.72k | vars.table_ptr = (unsigned int *) ptr; | 875 | 1.72k | ptr += SIZEOF_ILF_SYM_TABLE; | 876 | | | 877 | 1.72k | vars.native_syms = (combined_entry_type *) ptr; | 878 | 1.72k | vars.native_ptr = (combined_entry_type *) ptr; | 879 | 1.72k | ptr += SIZEOF_ILF_NATIVE_SYMS; | 880 | | | 881 | 1.72k | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 882 | 1.72k | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 883 | 1.72k | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 884 | | | 885 | 1.72k | vars.esym_table = (SYMENT *) ptr; | 886 | 1.72k | vars.esym_ptr = (SYMENT *) ptr; | 887 | 1.72k | ptr += SIZEOF_ILF_EXT_SYMS; | 888 | | | 889 | 1.72k | vars.reltab = (arelent *) ptr; | 890 | 1.72k | vars.relcount = 0; | 891 | 1.72k | ptr += SIZEOF_ILF_RELOCS; | 892 | | | 893 | 1.72k | vars.int_reltab = (struct internal_reloc *) ptr; | 894 | 1.72k | ptr += SIZEOF_ILF_INT_RELOCS; | 895 | | | 896 | 1.72k | vars.string_table = (char *) ptr; | 897 | 1.72k | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 898 | 1.72k | ptr += SIZEOF_ILF_STRINGS; | 899 | 1.72k | vars.end_string_ptr = (char *) ptr; | 900 | | | 901 | | /* The remaining space in bim->buffer is used | 902 | | by the pe_ILF_make_a_section() function. */ | 903 | | | 904 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 905 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 906 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 907 | | alignment. */ | 908 | 1.72k | #if GCC_VERSION >= 3000 | 909 | 1.72k | alignment = __alignof__ (struct coff_section_tdata); | 910 | | #else | 911 | | alignment = 8; | 912 | | #endif | 913 | 1.72k | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 914 | | | 915 | 1.72k | vars.data = ptr; | 916 | 1.72k | vars.abfd = abfd; | 917 | 1.72k | vars.sec_index = 0; | 918 | 1.72k | vars.magic = magic; | 919 | | | 920 | | /* Create the initial .idata$<n> sections: | 921 | | [.idata$2: Import Directory Table -- not needed] | 922 | | .idata$4: Import Lookup Table | 923 | | .idata$5: Import Address Table | 924 | | | 925 | | Note we do not create a .idata$3 section as this is | 926 | | created for us by the linker script. */ | 927 | 1.72k | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 928 | 1.72k | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 929 | 1.72k | if (id4 == NULL || id5 == NULL) | 930 | 0 | goto error_return; | 931 | | | 932 | | /* Fill in the contents of these sections. */ | 933 | 1.72k | if (import_name_type == IMPORT_ORDINAL) | 934 | 575 | { | 935 | 575 | if (ordinal == 0) | 936 | | /* See PR 20907 for a reproducer. */ | 937 | 101 | goto error_return; | 938 | | | 939 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 940 | | ((unsigned int *) id4->contents)[0] = ordinal; | 941 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 942 | | ((unsigned int *) id5->contents)[0] = ordinal; | 943 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 944 | | #else | 945 | 474 | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 946 | 474 | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 947 | 474 | #endif | 948 | 474 | } | 949 | 1.14k | else | 950 | 1.14k | { | 951 | 1.14k | char * symbol; | 952 | 1.14k | unsigned int len; | 953 | | | 954 | | /* Create .idata$6 - the Hint Name Table. */ | 955 | 1.14k | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 956 | 1.14k | if (id6 == NULL) | 957 | 0 | goto error_return; | 958 | | | 959 | | /* If necessary, trim the import symbol name. */ | 960 | 1.14k | symbol = symbol_name; | 961 | | | 962 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 963 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 964 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 965 | | of these is used for a symbol. We strip this leading char for | 966 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 967 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 968 | | | 969 | 1.14k | if (import_name_type != IMPORT_NAME) | 970 | 908 | { | 971 | 908 | char c = symbol[0]; | 972 | | | 973 | | /* Check that we don't remove for targets with empty | 974 | | USER_LABEL_PREFIX the leading underscore. */ | 975 | 908 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 976 | 908 | || c == '@' || c == '?') | 977 | 233 | symbol++; | 978 | 908 | } | 979 | | | 980 | 1.14k | len = strlen (symbol); | 981 | 1.14k | if (import_name_type == IMPORT_NAME_UNDECORATE) | 982 | 469 | { | 983 | | /* Truncate at the first '@'. */ | 984 | 469 | char *at = strchr (symbol, '@'); | 985 | | | 986 | 469 | if (at != NULL) | 987 | 0 | len = at - symbol; | 988 | 469 | } | 989 | | | 990 | 1.14k | id6->contents[0] = ordinal & 0xff; | 991 | 1.14k | id6->contents[1] = ordinal >> 8; | 992 | | | 993 | 1.14k | memcpy ((char *) id6->contents + 2, symbol, len); | 994 | 1.14k | id6->contents[len + 2] = '\0'; | 995 | 1.14k | } | 996 | | | 997 | 1.61k | if (import_name_type != IMPORT_ORDINAL) | 998 | 1.14k | { | 999 | 1.14k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1000 | 1.14k | pe_ILF_save_relocs (&vars, id4); | 1001 | | | 1002 | 1.14k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1003 | 1.14k | pe_ILF_save_relocs (&vars, id5); | 1004 | 1.14k | } | 1005 | | | 1006 | | /* Create an import symbol. */ | 1007 | 1.61k | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 1008 | 1.61k | imp_sym = vars.sym_ptr_ptr - 1; | 1009 | 1.61k | imp_index = vars.sym_index - 1; | 1010 | | | 1011 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1012 | 1.61k | switch (import_type) | 1013 | 1.61k | { | 1014 | 0 | int i; | 1015 | | | 1016 | 707 | case IMPORT_CODE: | 1017 | | /* CODE functions are special, in that they get a trampoline that | 1018 | | jumps to the main import symbol. Create a .text section to hold it. | 1019 | | First we need to look up its contents in the jump table. */ | 1020 | 2.12k | for (i = NUM_ENTRIES (jtab); i--;) | 1021 | 2.12k | { | 1022 | 2.12k | if (jtab[i].size == 0) | 1023 | 707 | continue; | 1024 | 1.41k | if (jtab[i].magic == magic) | 1025 | 707 | break; | 1026 | 1.41k | } | 1027 | | /* If we did not find a matching entry something is wrong. */ | 1028 | 707 | if (i < 0) | 1029 | 0 | abort (); | 1030 | | | 1031 | | /* Create the .text section. */ | 1032 | 707 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1033 | 707 | if (text == NULL) | 1034 | 0 | goto error_return; | 1035 | | | 1036 | | /* Copy in the jump code. */ | 1037 | 707 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1038 | | | 1039 | | /* Create a reloc for the data in the text section. */ | 1040 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1041 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1042 | | { | 1043 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1044 | | (struct bfd_symbol **) imp_sym, | 1045 | | imp_index); | 1046 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1047 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1048 | | (struct bfd_symbol **) imp_sym, | 1049 | | imp_index); | 1050 | | } | 1051 | | else | 1052 | | #endif | 1053 | | #ifdef AMD64MAGIC | 1054 | | if (magic == AMD64MAGIC) | 1055 | | { | 1056 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1057 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1058 | | imp_index); | 1059 | | } | 1060 | | else | 1061 | | #endif | 1062 | 707 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1063 | 707 | BFD_RELOC_32, (asymbol **) imp_sym, | 1064 | 707 | imp_index); | 1065 | | | 1066 | 707 | pe_ILF_save_relocs (& vars, text); | 1067 | 707 | break; | 1068 | | | 1069 | 912 | case IMPORT_DATA: | 1070 | 912 | break; | 1071 | | | 1072 | 0 | default: | 1073 | | /* XXX code not yet written. */ | 1074 | 0 | abort (); | 1075 | 1.61k | } | 1076 | | | 1077 | | /* Now create a symbol describing the imported value. */ | 1078 | 1.61k | switch (import_type) | 1079 | 1.61k | { | 1080 | 707 | case IMPORT_CODE: | 1081 | 707 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1082 | 707 | BSF_NOT_AT_END | BSF_FUNCTION); | 1083 | | | 1084 | 707 | break; | 1085 | | | 1086 | 912 | case IMPORT_DATA: | 1087 | | /* Nothing to do here. */ | 1088 | 912 | break; | 1089 | | | 1090 | 0 | default: | 1091 | | /* XXX code not yet written. */ | 1092 | 0 | abort (); | 1093 | 1.61k | } | 1094 | | | 1095 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1096 | 1.61k | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1097 | 1.61k | if (ptr) | 1098 | 337 | * ptr = 0; | 1099 | 1.61k | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1100 | 1.61k | if (ptr) | 1101 | 337 | * ptr = '.'; | 1102 | | | 1103 | | /* Initialise the bfd. */ | 1104 | 1.61k | memset (& internal_f, 0, sizeof (internal_f)); | 1105 | | | 1106 | 1.61k | internal_f.f_magic = magic; | 1107 | 1.61k | internal_f.f_symptr = 0; | 1108 | 1.61k | internal_f.f_nsyms = 0; | 1109 | 1.61k | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1110 | | | 1111 | 1.61k | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1112 | 1.61k | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1113 | 0 | goto error_return; | 1114 | | | 1115 | 1.61k | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1116 | 0 | goto error_return; | 1117 | | | 1118 | 1.61k | obj_pe (abfd) = true; | 1119 | 1.61k | #ifdef THUMBPEMAGIC | 1120 | 1.61k | if (vars.magic == THUMBPEMAGIC) | 1121 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1122 | 238 | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1123 | 1.61k | #endif | 1124 | | | 1125 | | /* Switch from file contents to memory contents. */ | 1126 | 1.61k | bfd_cache_close (abfd); | 1127 | | | 1128 | 1.61k | abfd->iostream = (void *) vars.bim; | 1129 | 1.61k | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1130 | 1.61k | abfd->iovec = &_bfd_memory_iovec; | 1131 | 1.61k | abfd->where = 0; | 1132 | 1.61k | abfd->origin = 0; | 1133 | 1.61k | abfd->size = 0; | 1134 | 1.61k | obj_sym_filepos (abfd) = 0; | 1135 | | | 1136 | | /* Point the bfd at the symbol table. */ | 1137 | 1.61k | obj_symbols (abfd) = vars.sym_cache; | 1138 | 1.61k | abfd->symcount = vars.sym_index; | 1139 | | | 1140 | 1.61k | obj_raw_syments (abfd) = vars.native_syms; | 1141 | 1.61k | obj_raw_syment_count (abfd) = vars.sym_index; | 1142 | | | 1143 | 1.61k | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1144 | 1.61k | obj_coff_keep_syms (abfd) = true; | 1145 | | | 1146 | 1.61k | obj_convert (abfd) = vars.sym_table; | 1147 | 1.61k | obj_conv_table_size (abfd) = vars.sym_index; | 1148 | | | 1149 | 1.61k | obj_coff_strings (abfd) = vars.string_table; | 1150 | 1.61k | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1151 | 1.61k | obj_coff_keep_strings (abfd) = true; | 1152 | | | 1153 | 1.61k | return true; | 1154 | | | 1155 | 101 | error_return: | 1156 | 101 | free (vars.bim->buffer); | 1157 | 101 | free (vars.bim); | 1158 | 101 | return false; | 1159 | 1.61k | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_build_a_bfd pei-sh.c:pe_ILF_build_a_bfd Line | Count | Source | 798 | 592 | { | 799 | 592 | bfd_byte * ptr; | 800 | 592 | pe_ILF_vars vars; | 801 | 592 | struct internal_filehdr internal_f; | 802 | 592 | unsigned int import_type; | 803 | 592 | unsigned int import_name_type; | 804 | 592 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 805 | 592 | coff_symbol_type ** imp_sym; | 806 | 592 | unsigned int imp_index; | 807 | 592 | intptr_t alignment; | 808 | | | 809 | | /* Decode and verify the types field of the ILF structure. */ | 810 | 592 | import_type = types & 0x3; | 811 | 592 | import_name_type = (types & 0x1c) >> 2; | 812 | | | 813 | 592 | switch (import_type) | 814 | 592 | { | 815 | 343 | case IMPORT_CODE: | 816 | 586 | case IMPORT_DATA: | 817 | 586 | break; | 818 | | | 819 | 3 | case IMPORT_CONST: | 820 | | /* XXX code yet to be written. */ | 821 | | /* xgettext:c-format */ | 822 | 3 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 823 | 3 | abfd, import_type); | 824 | 3 | return false; | 825 | | | 826 | 3 | default: | 827 | | /* xgettext:c-format */ | 828 | 3 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 829 | 3 | abfd, import_type); | 830 | 3 | return false; | 831 | 592 | } | 832 | | | 833 | 586 | switch (import_name_type) | 834 | 586 | { | 835 | 240 | case IMPORT_ORDINAL: | 836 | 241 | case IMPORT_NAME: | 837 | 243 | case IMPORT_NAME_NOPREFIX: | 838 | 482 | case IMPORT_NAME_UNDECORATE: | 839 | 482 | break; | 840 | | | 841 | 104 | default: | 842 | | /* xgettext:c-format */ | 843 | 104 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 844 | 104 | abfd, import_name_type); | 845 | 104 | return false; | 846 | 586 | } | 847 | | | 848 | | /* Initialise local variables. | 849 | | | 850 | | Note these are kept in a structure rather than being | 851 | | declared as statics since bfd frowns on global variables. | 852 | | | 853 | | We are going to construct the contents of the BFD in memory, | 854 | | so allocate all the space that we will need right now. */ | 855 | 482 | vars.bim | 856 | 482 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 857 | 482 | if (vars.bim == NULL) | 858 | 0 | return false; | 859 | | | 860 | 482 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 861 | 482 | vars.bim->buffer = ptr; | 862 | 482 | vars.bim->size = ILF_DATA_SIZE; | 863 | 482 | if (ptr == NULL) | 864 | 0 | goto error_return; | 865 | | | 866 | | /* Initialise the pointers to regions of the memory and the | 867 | | other contents of the pe_ILF_vars structure as well. */ | 868 | 482 | vars.sym_cache = (coff_symbol_type *) ptr; | 869 | 482 | vars.sym_ptr = (coff_symbol_type *) ptr; | 870 | 482 | vars.sym_index = 0; | 871 | 482 | ptr += SIZEOF_ILF_SYMS; | 872 | | | 873 | 482 | vars.sym_table = (unsigned int *) ptr; | 874 | 482 | vars.table_ptr = (unsigned int *) ptr; | 875 | 482 | ptr += SIZEOF_ILF_SYM_TABLE; | 876 | | | 877 | 482 | vars.native_syms = (combined_entry_type *) ptr; | 878 | 482 | vars.native_ptr = (combined_entry_type *) ptr; | 879 | 482 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 880 | | | 881 | 482 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 882 | 482 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 883 | 482 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 884 | | | 885 | 482 | vars.esym_table = (SYMENT *) ptr; | 886 | 482 | vars.esym_ptr = (SYMENT *) ptr; | 887 | 482 | ptr += SIZEOF_ILF_EXT_SYMS; | 888 | | | 889 | 482 | vars.reltab = (arelent *) ptr; | 890 | 482 | vars.relcount = 0; | 891 | 482 | ptr += SIZEOF_ILF_RELOCS; | 892 | | | 893 | 482 | vars.int_reltab = (struct internal_reloc *) ptr; | 894 | 482 | ptr += SIZEOF_ILF_INT_RELOCS; | 895 | | | 896 | 482 | vars.string_table = (char *) ptr; | 897 | 482 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 898 | 482 | ptr += SIZEOF_ILF_STRINGS; | 899 | 482 | vars.end_string_ptr = (char *) ptr; | 900 | | | 901 | | /* The remaining space in bim->buffer is used | 902 | | by the pe_ILF_make_a_section() function. */ | 903 | | | 904 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 905 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 906 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 907 | | alignment. */ | 908 | 482 | #if GCC_VERSION >= 3000 | 909 | 482 | alignment = __alignof__ (struct coff_section_tdata); | 910 | | #else | 911 | | alignment = 8; | 912 | | #endif | 913 | 482 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 914 | | | 915 | 482 | vars.data = ptr; | 916 | 482 | vars.abfd = abfd; | 917 | 482 | vars.sec_index = 0; | 918 | 482 | vars.magic = magic; | 919 | | | 920 | | /* Create the initial .idata$<n> sections: | 921 | | [.idata$2: Import Directory Table -- not needed] | 922 | | .idata$4: Import Lookup Table | 923 | | .idata$5: Import Address Table | 924 | | | 925 | | Note we do not create a .idata$3 section as this is | 926 | | created for us by the linker script. */ | 927 | 482 | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 928 | 482 | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 929 | 482 | if (id4 == NULL || id5 == NULL) | 930 | 0 | goto error_return; | 931 | | | 932 | | /* Fill in the contents of these sections. */ | 933 | 482 | if (import_name_type == IMPORT_ORDINAL) | 934 | 240 | { | 935 | 240 | if (ordinal == 0) | 936 | | /* See PR 20907 for a reproducer. */ | 937 | 3 | goto error_return; | 938 | | | 939 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 940 | | ((unsigned int *) id4->contents)[0] = ordinal; | 941 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 942 | | ((unsigned int *) id5->contents)[0] = ordinal; | 943 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 944 | | #else | 945 | 237 | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 946 | 237 | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 947 | 237 | #endif | 948 | 237 | } | 949 | 242 | else | 950 | 242 | { | 951 | 242 | char * symbol; | 952 | 242 | unsigned int len; | 953 | | | 954 | | /* Create .idata$6 - the Hint Name Table. */ | 955 | 242 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 956 | 242 | if (id6 == NULL) | 957 | 0 | goto error_return; | 958 | | | 959 | | /* If necessary, trim the import symbol name. */ | 960 | 242 | symbol = symbol_name; | 961 | | | 962 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 963 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 964 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 965 | | of these is used for a symbol. We strip this leading char for | 966 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 967 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 968 | | | 969 | 242 | if (import_name_type != IMPORT_NAME) | 970 | 241 | { | 971 | 241 | char c = symbol[0]; | 972 | | | 973 | | /* Check that we don't remove for targets with empty | 974 | | USER_LABEL_PREFIX the leading underscore. */ | 975 | 241 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 976 | 241 | || c == '@' || c == '?') | 977 | 1 | symbol++; | 978 | 241 | } | 979 | | | 980 | 242 | len = strlen (symbol); | 981 | 242 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 982 | 239 | { | 983 | | /* Truncate at the first '@'. */ | 984 | 239 | char *at = strchr (symbol, '@'); | 985 | | | 986 | 239 | if (at != NULL) | 987 | 1 | len = at - symbol; | 988 | 239 | } | 989 | | | 990 | 242 | id6->contents[0] = ordinal & 0xff; | 991 | 242 | id6->contents[1] = ordinal >> 8; | 992 | | | 993 | 242 | memcpy ((char *) id6->contents + 2, symbol, len); | 994 | 242 | id6->contents[len + 2] = '\0'; | 995 | 242 | } | 996 | | | 997 | 479 | if (import_name_type != IMPORT_ORDINAL) | 998 | 242 | { | 999 | 242 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1000 | 242 | pe_ILF_save_relocs (&vars, id4); | 1001 | | | 1002 | 242 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1003 | 242 | pe_ILF_save_relocs (&vars, id5); | 1004 | 242 | } | 1005 | | | 1006 | | /* Create an import symbol. */ | 1007 | 479 | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 1008 | 479 | imp_sym = vars.sym_ptr_ptr - 1; | 1009 | 479 | imp_index = vars.sym_index - 1; | 1010 | | | 1011 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1012 | 479 | switch (import_type) | 1013 | 479 | { | 1014 | 0 | int i; | 1015 | | | 1016 | 239 | case IMPORT_CODE: | 1017 | | /* CODE functions are special, in that they get a trampoline that | 1018 | | jumps to the main import symbol. Create a .text section to hold it. | 1019 | | First we need to look up its contents in the jump table. */ | 1020 | 478 | for (i = NUM_ENTRIES (jtab); i--;) | 1021 | 478 | { | 1022 | 478 | if (jtab[i].size == 0) | 1023 | 239 | continue; | 1024 | 239 | if (jtab[i].magic == magic) | 1025 | 239 | break; | 1026 | 239 | } | 1027 | | /* If we did not find a matching entry something is wrong. */ | 1028 | 239 | if (i < 0) | 1029 | 0 | abort (); | 1030 | | | 1031 | | /* Create the .text section. */ | 1032 | 239 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1033 | 239 | if (text == NULL) | 1034 | 0 | goto error_return; | 1035 | | | 1036 | | /* Copy in the jump code. */ | 1037 | 239 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1038 | | | 1039 | | /* Create a reloc for the data in the text section. */ | 1040 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1041 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1042 | | { | 1043 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1044 | | (struct bfd_symbol **) imp_sym, | 1045 | | imp_index); | 1046 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1047 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1048 | | (struct bfd_symbol **) imp_sym, | 1049 | | imp_index); | 1050 | | } | 1051 | | else | 1052 | | #endif | 1053 | | #ifdef AMD64MAGIC | 1054 | | if (magic == AMD64MAGIC) | 1055 | | { | 1056 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1057 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1058 | | imp_index); | 1059 | | } | 1060 | | else | 1061 | | #endif | 1062 | 239 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1063 | 239 | BFD_RELOC_32, (asymbol **) imp_sym, | 1064 | 239 | imp_index); | 1065 | | | 1066 | 239 | pe_ILF_save_relocs (& vars, text); | 1067 | 239 | break; | 1068 | | | 1069 | 240 | case IMPORT_DATA: | 1070 | 240 | break; | 1071 | | | 1072 | 0 | default: | 1073 | | /* XXX code not yet written. */ | 1074 | 0 | abort (); | 1075 | 479 | } | 1076 | | | 1077 | | /* Now create a symbol describing the imported value. */ | 1078 | 479 | switch (import_type) | 1079 | 479 | { | 1080 | 239 | case IMPORT_CODE: | 1081 | 239 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1082 | 239 | BSF_NOT_AT_END | BSF_FUNCTION); | 1083 | | | 1084 | 239 | break; | 1085 | | | 1086 | 240 | case IMPORT_DATA: | 1087 | | /* Nothing to do here. */ | 1088 | 240 | break; | 1089 | | | 1090 | 0 | default: | 1091 | | /* XXX code not yet written. */ | 1092 | 0 | abort (); | 1093 | 479 | } | 1094 | | | 1095 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1096 | 479 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1097 | 479 | if (ptr) | 1098 | 0 | * ptr = 0; | 1099 | 479 | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1100 | 479 | if (ptr) | 1101 | 0 | * ptr = '.'; | 1102 | | | 1103 | | /* Initialise the bfd. */ | 1104 | 479 | memset (& internal_f, 0, sizeof (internal_f)); | 1105 | | | 1106 | 479 | internal_f.f_magic = magic; | 1107 | 479 | internal_f.f_symptr = 0; | 1108 | 479 | internal_f.f_nsyms = 0; | 1109 | 479 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1110 | | | 1111 | 479 | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1112 | 479 | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1113 | 0 | goto error_return; | 1114 | | | 1115 | 479 | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1116 | 0 | goto error_return; | 1117 | | | 1118 | 479 | obj_pe (abfd) = true; | 1119 | | #ifdef THUMBPEMAGIC | 1120 | | if (vars.magic == THUMBPEMAGIC) | 1121 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1122 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1123 | | #endif | 1124 | | | 1125 | | /* Switch from file contents to memory contents. */ | 1126 | 479 | bfd_cache_close (abfd); | 1127 | | | 1128 | 479 | abfd->iostream = (void *) vars.bim; | 1129 | 479 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1130 | 479 | abfd->iovec = &_bfd_memory_iovec; | 1131 | 479 | abfd->where = 0; | 1132 | 479 | abfd->origin = 0; | 1133 | 479 | abfd->size = 0; | 1134 | 479 | obj_sym_filepos (abfd) = 0; | 1135 | | | 1136 | | /* Point the bfd at the symbol table. */ | 1137 | 479 | obj_symbols (abfd) = vars.sym_cache; | 1138 | 479 | abfd->symcount = vars.sym_index; | 1139 | | | 1140 | 479 | obj_raw_syments (abfd) = vars.native_syms; | 1141 | 479 | obj_raw_syment_count (abfd) = vars.sym_index; | 1142 | | | 1143 | 479 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1144 | 479 | obj_coff_keep_syms (abfd) = true; | 1145 | | | 1146 | 479 | obj_convert (abfd) = vars.sym_table; | 1147 | 479 | obj_conv_table_size (abfd) = vars.sym_index; | 1148 | | | 1149 | 479 | obj_coff_strings (abfd) = vars.string_table; | 1150 | 479 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1151 | 479 | obj_coff_keep_strings (abfd) = true; | 1152 | | | 1153 | 479 | return true; | 1154 | | | 1155 | 3 | error_return: | 1156 | 3 | free (vars.bim->buffer); | 1157 | 3 | free (vars.bim); | 1158 | 3 | return false; | 1159 | 479 | } |
|
1160 | | |
1161 | | /* Cleanup function, returned from check_format hook. */ |
1162 | | |
1163 | | static void |
1164 | | pe_ILF_cleanup (bfd *abfd) |
1165 | 0 | { |
1166 | 0 | struct bfd_in_memory *bim = abfd->iostream; |
1167 | 0 | free (bim->buffer); |
1168 | 0 | free (bim); |
1169 | 0 | abfd->iostream = NULL; |
1170 | 0 | } 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 Unexecuted instantiation: pei-arm-wince.c:pe_ILF_cleanup Unexecuted instantiation: pei-arm.c:pe_ILF_cleanup Unexecuted instantiation: pei-mcore.c:pe_ILF_cleanup Unexecuted instantiation: pei-sh.c:pe_ILF_cleanup |
1171 | | |
1172 | | /* We have detected an Import Library Format archive element. |
1173 | | Decode the element and return the appropriate target. */ |
1174 | | |
1175 | | static bfd_cleanup |
1176 | | pe_ILF_object_p (bfd * abfd) |
1177 | 76.9k | { |
1178 | 76.9k | bfd_byte buffer[14]; |
1179 | 76.9k | bfd_byte * ptr; |
1180 | 76.9k | char * symbol_name; |
1181 | 76.9k | char * source_dll; |
1182 | 76.9k | unsigned int machine; |
1183 | 76.9k | bfd_size_type size; |
1184 | 76.9k | unsigned int ordinal; |
1185 | 76.9k | unsigned int types; |
1186 | 76.9k | unsigned int magic; |
1187 | | |
1188 | | /* Upon entry the first six bytes of the ILF header have |
1189 | | already been read. Now read the rest of the header. */ |
1190 | 76.9k | if (bfd_bread (buffer, (bfd_size_type) 14, abfd) != 14) |
1191 | 872 | return NULL; |
1192 | | |
1193 | 76.0k | ptr = buffer; |
1194 | | |
1195 | 76.0k | machine = H_GET_16 (abfd, ptr); |
1196 | 76.0k | ptr += 2; |
1197 | | |
1198 | | /* Check that the machine type is recognised. */ |
1199 | 76.0k | magic = 0; |
1200 | | |
1201 | 76.0k | switch (machine) |
1202 | 76.0k | { |
1203 | 827 | case IMAGE_FILE_MACHINE_UNKNOWN: |
1204 | 827 | case IMAGE_FILE_MACHINE_ALPHA: |
1205 | 827 | case IMAGE_FILE_MACHINE_ALPHA64: |
1206 | 846 | case IMAGE_FILE_MACHINE_IA64: |
1207 | 846 | break; |
1208 | | |
1209 | 12.4k | case IMAGE_FILE_MACHINE_I386: |
1210 | | #ifdef I386MAGIC |
1211 | 2.18k | magic = I386MAGIC; |
1212 | | #endif |
1213 | 12.4k | break; |
1214 | | |
1215 | 13.9k | case IMAGE_FILE_MACHINE_AMD64: |
1216 | | #ifdef AMD64MAGIC |
1217 | 1.90k | magic = AMD64MAGIC; |
1218 | | #endif |
1219 | 13.9k | break; |
1220 | | |
1221 | 0 | case IMAGE_FILE_MACHINE_R3000: |
1222 | 0 | case IMAGE_FILE_MACHINE_R4000: |
1223 | 0 | case IMAGE_FILE_MACHINE_R10000: |
1224 | |
|
1225 | 0 | case IMAGE_FILE_MACHINE_MIPS16: |
1226 | 0 | case IMAGE_FILE_MACHINE_MIPSFPU: |
1227 | 8 | case IMAGE_FILE_MACHINE_MIPSFPU16: |
1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
1229 | | magic = MIPS_ARCH_MAGIC_WINCE; |
1230 | | #endif |
1231 | 8 | break; |
1232 | | |
1233 | 3.02k | case IMAGE_FILE_MACHINE_SH3: |
1234 | 7.13k | case IMAGE_FILE_MACHINE_SH4: |
1235 | | #ifdef SH_ARCH_MAGIC_WINCE |
1236 | 1.01k | magic = SH_ARCH_MAGIC_WINCE; |
1237 | | #endif |
1238 | 7.13k | break; |
1239 | | |
1240 | 13.4k | case IMAGE_FILE_MACHINE_ARM: |
1241 | | #ifdef ARMPEMAGIC |
1242 | 4.04k | magic = ARMPEMAGIC; |
1243 | | #endif |
1244 | 13.4k | break; |
1245 | | |
1246 | 2.81k | case IMAGE_FILE_MACHINE_ARM64: |
1247 | | #ifdef AARCH64MAGIC |
1248 | 1.19k | magic = AARCH64MAGIC; |
1249 | | #endif |
1250 | 2.81k | break; |
1251 | | |
1252 | 17.2k | case IMAGE_FILE_MACHINE_LOONGARCH64: |
1253 | | #ifdef LOONGARCH64MAGIC |
1254 | 2.16k | magic = LOONGARCH64MAGIC; |
1255 | | #endif |
1256 | 17.2k | break; |
1257 | | |
1258 | 617 | case IMAGE_FILE_MACHINE_THUMB: |
1259 | | #ifdef THUMBPEMAGIC |
1260 | | { |
1261 | | extern const bfd_target TARGET_LITTLE_SYM; |
1262 | | |
1263 | 273 | if (abfd->xvec == & TARGET_LITTLE_SYM) |
1264 | 273 | magic = THUMBPEMAGIC; |
1265 | | } |
1266 | | #endif |
1267 | 617 | break; |
1268 | | |
1269 | 0 | case IMAGE_FILE_MACHINE_POWERPC: |
1270 | | /* We no longer support PowerPC. */ |
1271 | 7.61k | default: |
1272 | 7.61k | _bfd_error_handler |
1273 | | /* xgettext:c-format */ |
1274 | 7.61k | (_("%pB: unrecognised machine type (0x%x)" |
1275 | 7.61k | " in Import Library Format archive"), |
1276 | 7.61k | abfd, machine); |
1277 | 7.61k | bfd_set_error (bfd_error_malformed_archive); |
1278 | | |
1279 | 7.61k | return NULL; |
1280 | 0 | break; |
1281 | 76.0k | } |
1282 | | |
1283 | 68.4k | if (magic == 0) |
1284 | 55.6k | { |
1285 | 55.6k | _bfd_error_handler |
1286 | | /* xgettext:c-format */ |
1287 | 55.6k | (_("%pB: recognised but unhandled machine type (0x%x)" |
1288 | 55.6k | " in Import Library Format archive"), |
1289 | 55.6k | abfd, machine); |
1290 | 55.6k | bfd_set_error (bfd_error_wrong_format); |
1291 | | |
1292 | 55.6k | return NULL; |
1293 | 55.6k | } |
1294 | | |
1295 | | /* We do not bother to check the date. |
1296 | | date = H_GET_32 (abfd, ptr); */ |
1297 | 12.7k | ptr += 4; |
1298 | | |
1299 | 12.7k | size = H_GET_32 (abfd, ptr); |
1300 | 12.7k | ptr += 4; |
1301 | | |
1302 | 12.7k | if (size == 0) |
1303 | 623 | { |
1304 | 623 | _bfd_error_handler |
1305 | 623 | (_("%pB: size field is zero in Import Library Format header"), abfd); |
1306 | 623 | bfd_set_error (bfd_error_malformed_archive); |
1307 | | |
1308 | 623 | return NULL; |
1309 | 623 | } |
1310 | | |
1311 | 12.1k | ordinal = H_GET_16 (abfd, ptr); |
1312 | 12.1k | ptr += 2; |
1313 | | |
1314 | 12.1k | types = H_GET_16 (abfd, ptr); |
1315 | | /* ptr += 2; */ |
1316 | | |
1317 | | /* Now read in the two strings that follow. */ |
1318 | 12.1k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); |
1319 | 12.1k | if (ptr == NULL) |
1320 | 1.99k | return NULL; |
1321 | | |
1322 | 10.1k | symbol_name = (char *) ptr; |
1323 | | /* See PR 20905 for an example of where the strnlen is necessary. */ |
1324 | 10.1k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; |
1325 | | |
1326 | | /* Verify that the strings are null terminated. */ |
1327 | 10.1k | if (ptr[size - 1] != 0 |
1328 | 10.1k | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) |
1329 | 947 | { |
1330 | 947 | _bfd_error_handler |
1331 | 947 | (_("%pB: string not null terminated in ILF object file"), abfd); |
1332 | 947 | bfd_set_error (bfd_error_malformed_archive); |
1333 | 947 | bfd_release (abfd, ptr); |
1334 | 947 | return NULL; |
1335 | 947 | } |
1336 | | |
1337 | | /* Now construct the bfd. */ |
1338 | 9.20k | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, |
1339 | 9.20k | source_dll, ordinal, types)) |
1340 | 2.18k | { |
1341 | 2.18k | bfd_release (abfd, ptr); |
1342 | 2.18k | return NULL; |
1343 | 2.18k | } |
1344 | | |
1345 | 7.02k | return pe_ILF_cleanup; |
1346 | 9.20k | } pei-i386.c:pe_ILF_object_p Line | Count | Source | 1177 | 9.99k | { | 1178 | 9.99k | bfd_byte buffer[14]; | 1179 | 9.99k | bfd_byte * ptr; | 1180 | 9.99k | char * symbol_name; | 1181 | 9.99k | char * source_dll; | 1182 | 9.99k | unsigned int machine; | 1183 | 9.99k | bfd_size_type size; | 1184 | 9.99k | unsigned int ordinal; | 1185 | 9.99k | unsigned int types; | 1186 | 9.99k | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 9.99k | if (bfd_bread (buffer, (bfd_size_type) 14, abfd) != 14) | 1191 | 109 | return NULL; | 1192 | | | 1193 | 9.88k | ptr = buffer; | 1194 | | | 1195 | 9.88k | machine = H_GET_16 (abfd, ptr); | 1196 | 9.88k | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 9.88k | magic = 0; | 1200 | | | 1201 | 9.88k | switch (machine) | 1202 | 9.88k | { | 1203 | 103 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 103 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 103 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 105 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 105 | break; | 1208 | | | 1209 | 2.18k | case IMAGE_FILE_MACHINE_I386: | 1210 | 2.18k | #ifdef I386MAGIC | 1211 | 2.18k | magic = I386MAGIC; | 1212 | 2.18k | #endif | 1213 | 2.18k | break; | 1214 | | | 1215 | 1.89k | case IMAGE_FILE_MACHINE_AMD64: | 1216 | | #ifdef AMD64MAGIC | 1217 | | magic = AMD64MAGIC; | 1218 | | #endif | 1219 | 1.89k | break; | 1220 | | | 1221 | 0 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 0 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 0 | case IMAGE_FILE_MACHINE_R10000: | 1224 | |
| 1225 | 0 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 0 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 1 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 1 | break; | 1232 | | | 1233 | 496 | case IMAGE_FILE_MACHINE_SH3: | 1234 | 1.01k | case IMAGE_FILE_MACHINE_SH4: | 1235 | | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | | magic = SH_ARCH_MAGIC_WINCE; | 1237 | | #endif | 1238 | 1.01k | break; | 1239 | | | 1240 | 1.33k | case IMAGE_FILE_MACHINE_ARM: | 1241 | | #ifdef ARMPEMAGIC | 1242 | | magic = ARMPEMAGIC; | 1243 | | #endif | 1244 | 1.33k | break; | 1245 | | | 1246 | 231 | case IMAGE_FILE_MACHINE_ARM64: | 1247 | | #ifdef AARCH64MAGIC | 1248 | | magic = AARCH64MAGIC; | 1249 | | #endif | 1250 | 231 | break; | 1251 | | | 1252 | 2.15k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | | #ifdef LOONGARCH64MAGIC | 1254 | | magic = LOONGARCH64MAGIC; | 1255 | | #endif | 1256 | 2.15k | break; | 1257 | | | 1258 | 18 | case IMAGE_FILE_MACHINE_THUMB: | 1259 | | #ifdef THUMBPEMAGIC | 1260 | | { | 1261 | | extern const bfd_target TARGET_LITTLE_SYM; | 1262 | | | 1263 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1264 | | magic = THUMBPEMAGIC; | 1265 | | } | 1266 | | #endif | 1267 | 18 | break; | 1268 | | | 1269 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1270 | | /* We no longer support PowerPC. */ | 1271 | 952 | default: | 1272 | 952 | _bfd_error_handler | 1273 | | /* xgettext:c-format */ | 1274 | 952 | (_("%pB: unrecognised machine type (0x%x)" | 1275 | 952 | " in Import Library Format archive"), | 1276 | 952 | abfd, machine); | 1277 | 952 | bfd_set_error (bfd_error_malformed_archive); | 1278 | | | 1279 | 952 | return NULL; | 1280 | 0 | break; | 1281 | 9.88k | } | 1282 | | | 1283 | 8.92k | if (magic == 0) | 1284 | 6.74k | { | 1285 | 6.74k | _bfd_error_handler | 1286 | | /* xgettext:c-format */ | 1287 | 6.74k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1288 | 6.74k | " in Import Library Format archive"), | 1289 | 6.74k | abfd, machine); | 1290 | 6.74k | bfd_set_error (bfd_error_wrong_format); | 1291 | | | 1292 | 6.74k | return NULL; | 1293 | 6.74k | } | 1294 | | | 1295 | | /* We do not bother to check the date. | 1296 | | date = H_GET_32 (abfd, ptr); */ | 1297 | 2.18k | ptr += 4; | 1298 | | | 1299 | 2.18k | size = H_GET_32 (abfd, ptr); | 1300 | 2.18k | ptr += 4; | 1301 | | | 1302 | 2.18k | if (size == 0) | 1303 | 104 | { | 1304 | 104 | _bfd_error_handler | 1305 | 104 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1306 | 104 | bfd_set_error (bfd_error_malformed_archive); | 1307 | | | 1308 | 104 | return NULL; | 1309 | 104 | } | 1310 | | | 1311 | 2.07k | ordinal = H_GET_16 (abfd, ptr); | 1312 | 2.07k | ptr += 2; | 1313 | | | 1314 | 2.07k | types = H_GET_16 (abfd, ptr); | 1315 | | /* ptr += 2; */ | 1316 | | | 1317 | | /* Now read in the two strings that follow. */ | 1318 | 2.07k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1319 | 2.07k | if (ptr == NULL) | 1320 | 211 | return NULL; | 1321 | | | 1322 | 1.86k | symbol_name = (char *) ptr; | 1323 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1324 | 1.86k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1325 | | | 1326 | | /* Verify that the strings are null terminated. */ | 1327 | 1.86k | if (ptr[size - 1] != 0 | 1328 | 1.86k | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1329 | 308 | { | 1330 | 308 | _bfd_error_handler | 1331 | 308 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1332 | 308 | bfd_set_error (bfd_error_malformed_archive); | 1333 | 308 | bfd_release (abfd, ptr); | 1334 | 308 | return NULL; | 1335 | 308 | } | 1336 | | | 1337 | | /* Now construct the bfd. */ | 1338 | 1.55k | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1339 | 1.55k | source_dll, ordinal, types)) | 1340 | 312 | { | 1341 | 312 | bfd_release (abfd, ptr); | 1342 | 312 | return NULL; | 1343 | 312 | } | 1344 | | | 1345 | 1.24k | return pe_ILF_cleanup; | 1346 | 1.55k | } |
pei-x86_64.c:pe_ILF_object_p Line | Count | Source | 1177 | 8.27k | { | 1178 | 8.27k | bfd_byte buffer[14]; | 1179 | 8.27k | bfd_byte * ptr; | 1180 | 8.27k | char * symbol_name; | 1181 | 8.27k | char * source_dll; | 1182 | 8.27k | unsigned int machine; | 1183 | 8.27k | bfd_size_type size; | 1184 | 8.27k | unsigned int ordinal; | 1185 | 8.27k | unsigned int types; | 1186 | 8.27k | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 8.27k | if (bfd_bread (buffer, (bfd_size_type) 14, abfd) != 14) | 1191 | 109 | return NULL; | 1192 | | | 1193 | 8.16k | ptr = buffer; | 1194 | | | 1195 | 8.16k | machine = H_GET_16 (abfd, ptr); | 1196 | 8.16k | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 8.16k | magic = 0; | 1200 | | | 1201 | 8.16k | switch (machine) | 1202 | 8.16k | { | 1203 | 103 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 103 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 103 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 105 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 105 | break; | 1208 | | | 1209 | 939 | case IMAGE_FILE_MACHINE_I386: | 1210 | | #ifdef I386MAGIC | 1211 | | magic = I386MAGIC; | 1212 | | #endif | 1213 | 939 | break; | 1214 | | | 1215 | 1.90k | case IMAGE_FILE_MACHINE_AMD64: | 1216 | 1.90k | #ifdef AMD64MAGIC | 1217 | 1.90k | magic = AMD64MAGIC; | 1218 | 1.90k | #endif | 1219 | 1.90k | break; | 1220 | | | 1221 | 0 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 0 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 0 | case IMAGE_FILE_MACHINE_R10000: | 1224 | |
| 1225 | 0 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 0 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 1 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 1 | break; | 1232 | | | 1233 | 23 | case IMAGE_FILE_MACHINE_SH3: | 1234 | 535 | case IMAGE_FILE_MACHINE_SH4: | 1235 | | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | | magic = SH_ARCH_MAGIC_WINCE; | 1237 | | #endif | 1238 | 535 | break; | 1239 | | | 1240 | 1.33k | case IMAGE_FILE_MACHINE_ARM: | 1241 | | #ifdef ARMPEMAGIC | 1242 | | magic = ARMPEMAGIC; | 1243 | | #endif | 1244 | 1.33k | break; | 1245 | | | 1246 | 231 | case IMAGE_FILE_MACHINE_ARM64: | 1247 | | #ifdef AARCH64MAGIC | 1248 | | magic = AARCH64MAGIC; | 1249 | | #endif | 1250 | 231 | break; | 1251 | | | 1252 | 2.15k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | | #ifdef LOONGARCH64MAGIC | 1254 | | magic = LOONGARCH64MAGIC; | 1255 | | #endif | 1256 | 2.15k | break; | 1257 | | | 1258 | 18 | case IMAGE_FILE_MACHINE_THUMB: | 1259 | | #ifdef THUMBPEMAGIC | 1260 | | { | 1261 | | extern const bfd_target TARGET_LITTLE_SYM; | 1262 | | | 1263 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1264 | | magic = THUMBPEMAGIC; | 1265 | | } | 1266 | | #endif | 1267 | 18 | break; | 1268 | | | 1269 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1270 | | /* We no longer support PowerPC. */ | 1271 | 952 | default: | 1272 | 952 | _bfd_error_handler | 1273 | | /* xgettext:c-format */ | 1274 | 952 | (_("%pB: unrecognised machine type (0x%x)" | 1275 | 952 | " in Import Library Format archive"), | 1276 | 952 | abfd, machine); | 1277 | 952 | bfd_set_error (bfd_error_malformed_archive); | 1278 | | | 1279 | 952 | return NULL; | 1280 | 0 | break; | 1281 | 8.16k | } | 1282 | | | 1283 | 7.21k | if (magic == 0) | 1284 | 5.31k | { | 1285 | 5.31k | _bfd_error_handler | 1286 | | /* xgettext:c-format */ | 1287 | 5.31k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1288 | 5.31k | " in Import Library Format archive"), | 1289 | 5.31k | abfd, machine); | 1290 | 5.31k | bfd_set_error (bfd_error_wrong_format); | 1291 | | | 1292 | 5.31k | return NULL; | 1293 | 5.31k | } | 1294 | | | 1295 | | /* We do not bother to check the date. | 1296 | | date = H_GET_32 (abfd, ptr); */ | 1297 | 1.90k | ptr += 4; | 1298 | | | 1299 | 1.90k | size = H_GET_32 (abfd, ptr); | 1300 | 1.90k | ptr += 4; | 1301 | | | 1302 | 1.90k | if (size == 0) | 1303 | 104 | { | 1304 | 104 | _bfd_error_handler | 1305 | 104 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1306 | 104 | bfd_set_error (bfd_error_malformed_archive); | 1307 | | | 1308 | 104 | return NULL; | 1309 | 104 | } | 1310 | | | 1311 | 1.79k | ordinal = H_GET_16 (abfd, ptr); | 1312 | 1.79k | ptr += 2; | 1313 | | | 1314 | 1.79k | types = H_GET_16 (abfd, ptr); | 1315 | | /* ptr += 2; */ | 1316 | | | 1317 | | /* Now read in the two strings that follow. */ | 1318 | 1.79k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1319 | 1.79k | if (ptr == NULL) | 1320 | 210 | return NULL; | 1321 | | | 1322 | 1.58k | symbol_name = (char *) ptr; | 1323 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1324 | 1.58k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1325 | | | 1326 | | /* Verify that the strings are null terminated. */ | 1327 | 1.58k | if (ptr[size - 1] != 0 | 1328 | 1.58k | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1329 | 105 | { | 1330 | 105 | _bfd_error_handler | 1331 | 105 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1332 | 105 | bfd_set_error (bfd_error_malformed_archive); | 1333 | 105 | bfd_release (abfd, ptr); | 1334 | 105 | return NULL; | 1335 | 105 | } | 1336 | | | 1337 | | /* Now construct the bfd. */ | 1338 | 1.48k | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1339 | 1.48k | source_dll, ordinal, types)) | 1340 | 212 | { | 1341 | 212 | bfd_release (abfd, ptr); | 1342 | 212 | return NULL; | 1343 | 212 | } | 1344 | | | 1345 | 1.26k | return pe_ILF_cleanup; | 1346 | 1.48k | } |
pei-aarch64.c:pe_ILF_object_p Line | Count | Source | 1177 | 12.5k | { | 1178 | 12.5k | bfd_byte buffer[14]; | 1179 | 12.5k | bfd_byte * ptr; | 1180 | 12.5k | char * symbol_name; | 1181 | 12.5k | char * source_dll; | 1182 | 12.5k | unsigned int machine; | 1183 | 12.5k | bfd_size_type size; | 1184 | 12.5k | unsigned int ordinal; | 1185 | 12.5k | unsigned int types; | 1186 | 12.5k | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 12.5k | if (bfd_bread (buffer, (bfd_size_type) 14, abfd) != 14) | 1191 | 109 | return NULL; | 1192 | | | 1193 | 12.4k | ptr = buffer; | 1194 | | | 1195 | 12.4k | machine = H_GET_16 (abfd, ptr); | 1196 | 12.4k | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 12.4k | magic = 0; | 1200 | | | 1201 | 12.4k | switch (machine) | 1202 | 12.4k | { | 1203 | 103 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 103 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 103 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 105 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 105 | break; | 1208 | | | 1209 | 2.17k | case IMAGE_FILE_MACHINE_I386: | 1210 | | #ifdef I386MAGIC | 1211 | | magic = I386MAGIC; | 1212 | | #endif | 1213 | 2.17k | break; | 1214 | | | 1215 | 1.89k | case IMAGE_FILE_MACHINE_AMD64: | 1216 | | #ifdef AMD64MAGIC | 1217 | | magic = AMD64MAGIC; | 1218 | | #endif | 1219 | 1.89k | break; | 1220 | | | 1221 | 0 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 0 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 0 | case IMAGE_FILE_MACHINE_R10000: | 1224 | |
| 1225 | 0 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 0 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 1 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 1 | break; | 1232 | | | 1233 | 496 | case IMAGE_FILE_MACHINE_SH3: | 1234 | 1.01k | case IMAGE_FILE_MACHINE_SH4: | 1235 | | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | | magic = SH_ARCH_MAGIC_WINCE; | 1237 | | #endif | 1238 | 1.01k | break; | 1239 | | | 1240 | 2.70k | case IMAGE_FILE_MACHINE_ARM: | 1241 | | #ifdef ARMPEMAGIC | 1242 | | magic = ARMPEMAGIC; | 1243 | | #endif | 1244 | 2.70k | break; | 1245 | | | 1246 | 1.19k | case IMAGE_FILE_MACHINE_ARM64: | 1247 | 1.19k | #ifdef AARCH64MAGIC | 1248 | 1.19k | magic = AARCH64MAGIC; | 1249 | 1.19k | #endif | 1250 | 1.19k | break; | 1251 | | | 1252 | 2.15k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | | #ifdef LOONGARCH64MAGIC | 1254 | | magic = LOONGARCH64MAGIC; | 1255 | | #endif | 1256 | 2.15k | break; | 1257 | | | 1258 | 254 | case IMAGE_FILE_MACHINE_THUMB: | 1259 | | #ifdef THUMBPEMAGIC | 1260 | | { | 1261 | | extern const bfd_target TARGET_LITTLE_SYM; | 1262 | | | 1263 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1264 | | magic = THUMBPEMAGIC; | 1265 | | } | 1266 | | #endif | 1267 | 254 | break; | 1268 | | | 1269 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1270 | | /* We no longer support PowerPC. */ | 1271 | 952 | default: | 1272 | 952 | _bfd_error_handler | 1273 | | /* xgettext:c-format */ | 1274 | 952 | (_("%pB: unrecognised machine type (0x%x)" | 1275 | 952 | " in Import Library Format archive"), | 1276 | 952 | abfd, machine); | 1277 | 952 | bfd_set_error (bfd_error_malformed_archive); | 1278 | | | 1279 | 952 | return NULL; | 1280 | 0 | break; | 1281 | 12.4k | } | 1282 | | | 1283 | 11.4k | if (magic == 0) | 1284 | 10.3k | { | 1285 | 10.3k | _bfd_error_handler | 1286 | | /* xgettext:c-format */ | 1287 | 10.3k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1288 | 10.3k | " in Import Library Format archive"), | 1289 | 10.3k | abfd, machine); | 1290 | 10.3k | bfd_set_error (bfd_error_wrong_format); | 1291 | | | 1292 | 10.3k | return NULL; | 1293 | 10.3k | } | 1294 | | | 1295 | | /* We do not bother to check the date. | 1296 | | date = H_GET_32 (abfd, ptr); */ | 1297 | 1.19k | ptr += 4; | 1298 | | | 1299 | 1.19k | size = H_GET_32 (abfd, ptr); | 1300 | 1.19k | ptr += 4; | 1301 | | | 1302 | 1.19k | if (size == 0) | 1303 | 102 | { | 1304 | 102 | _bfd_error_handler | 1305 | 102 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1306 | 102 | bfd_set_error (bfd_error_malformed_archive); | 1307 | | | 1308 | 102 | return NULL; | 1309 | 102 | } | 1310 | | | 1311 | 1.09k | ordinal = H_GET_16 (abfd, ptr); | 1312 | 1.09k | ptr += 2; | 1313 | | | 1314 | 1.09k | types = H_GET_16 (abfd, ptr); | 1315 | | /* ptr += 2; */ | 1316 | | | 1317 | | /* Now read in the two strings that follow. */ | 1318 | 1.09k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1319 | 1.09k | if (ptr == NULL) | 1320 | 108 | return NULL; | 1321 | | | 1322 | 983 | symbol_name = (char *) ptr; | 1323 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1324 | 983 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1325 | | | 1326 | | /* Verify that the strings are null terminated. */ | 1327 | 983 | if (ptr[size - 1] != 0 | 1328 | 983 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1329 | 6 | { | 1330 | 6 | _bfd_error_handler | 1331 | 6 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1332 | 6 | bfd_set_error (bfd_error_malformed_archive); | 1333 | 6 | bfd_release (abfd, ptr); | 1334 | 6 | return NULL; | 1335 | 6 | } | 1336 | | | 1337 | | /* Now construct the bfd. */ | 1338 | 977 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1339 | 977 | source_dll, ordinal, types)) | 1340 | 10 | { | 1341 | 10 | bfd_release (abfd, ptr); | 1342 | 10 | return NULL; | 1343 | 10 | } | 1344 | | | 1345 | 967 | return pe_ILF_cleanup; | 1346 | 977 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_object_p pei-loongarch64.c:pe_ILF_object_p Line | Count | Source | 1177 | 7.02k | { | 1178 | 7.02k | bfd_byte buffer[14]; | 1179 | 7.02k | bfd_byte * ptr; | 1180 | 7.02k | char * symbol_name; | 1181 | 7.02k | char * source_dll; | 1182 | 7.02k | unsigned int machine; | 1183 | 7.02k | bfd_size_type size; | 1184 | 7.02k | unsigned int ordinal; | 1185 | 7.02k | unsigned int types; | 1186 | 7.02k | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 7.02k | if (bfd_bread (buffer, (bfd_size_type) 14, abfd) != 14) | 1191 | 109 | return NULL; | 1192 | | | 1193 | 6.91k | ptr = buffer; | 1194 | | | 1195 | 6.91k | machine = H_GET_16 (abfd, ptr); | 1196 | 6.91k | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 6.91k | magic = 0; | 1200 | | | 1201 | 6.91k | switch (machine) | 1202 | 6.91k | { | 1203 | 103 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 103 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 103 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 105 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 105 | break; | 1208 | | | 1209 | 939 | case IMAGE_FILE_MACHINE_I386: | 1210 | | #ifdef I386MAGIC | 1211 | | magic = I386MAGIC; | 1212 | | #endif | 1213 | 939 | break; | 1214 | | | 1215 | 636 | case IMAGE_FILE_MACHINE_AMD64: | 1216 | | #ifdef AMD64MAGIC | 1217 | | magic = AMD64MAGIC; | 1218 | | #endif | 1219 | 636 | break; | 1220 | | | 1221 | 0 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 0 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 0 | case IMAGE_FILE_MACHINE_R10000: | 1224 | |
| 1225 | 0 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 0 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 1 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 1 | break; | 1232 | | | 1233 | 23 | case IMAGE_FILE_MACHINE_SH3: | 1234 | 535 | case IMAGE_FILE_MACHINE_SH4: | 1235 | | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | | magic = SH_ARCH_MAGIC_WINCE; | 1237 | | #endif | 1238 | 535 | break; | 1239 | | | 1240 | 1.33k | case IMAGE_FILE_MACHINE_ARM: | 1241 | | #ifdef ARMPEMAGIC | 1242 | | magic = ARMPEMAGIC; | 1243 | | #endif | 1244 | 1.33k | break; | 1245 | | | 1246 | 231 | case IMAGE_FILE_MACHINE_ARM64: | 1247 | | #ifdef AARCH64MAGIC | 1248 | | magic = AARCH64MAGIC; | 1249 | | #endif | 1250 | 231 | break; | 1251 | | | 1252 | 2.16k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | 2.16k | #ifdef LOONGARCH64MAGIC | 1254 | 2.16k | magic = LOONGARCH64MAGIC; | 1255 | 2.16k | #endif | 1256 | 2.16k | break; | 1257 | | | 1258 | 18 | case IMAGE_FILE_MACHINE_THUMB: | 1259 | | #ifdef THUMBPEMAGIC | 1260 | | { | 1261 | | extern const bfd_target TARGET_LITTLE_SYM; | 1262 | | | 1263 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1264 | | magic = THUMBPEMAGIC; | 1265 | | } | 1266 | | #endif | 1267 | 18 | break; | 1268 | | | 1269 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1270 | | /* We no longer support PowerPC. */ | 1271 | 952 | default: | 1272 | 952 | _bfd_error_handler | 1273 | | /* xgettext:c-format */ | 1274 | 952 | (_("%pB: unrecognised machine type (0x%x)" | 1275 | 952 | " in Import Library Format archive"), | 1276 | 952 | abfd, machine); | 1277 | 952 | bfd_set_error (bfd_error_malformed_archive); | 1278 | | | 1279 | 952 | return NULL; | 1280 | 0 | break; | 1281 | 6.91k | } | 1282 | | | 1283 | 5.96k | if (magic == 0) | 1284 | 3.79k | { | 1285 | 3.79k | _bfd_error_handler | 1286 | | /* xgettext:c-format */ | 1287 | 3.79k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1288 | 3.79k | " in Import Library Format archive"), | 1289 | 3.79k | abfd, machine); | 1290 | 3.79k | bfd_set_error (bfd_error_wrong_format); | 1291 | | | 1292 | 3.79k | return NULL; | 1293 | 3.79k | } | 1294 | | | 1295 | | /* We do not bother to check the date. | 1296 | | date = H_GET_32 (abfd, ptr); */ | 1297 | 2.16k | ptr += 4; | 1298 | | | 1299 | 2.16k | size = H_GET_32 (abfd, ptr); | 1300 | 2.16k | ptr += 4; | 1301 | | | 1302 | 2.16k | if (size == 0) | 1303 | 1 | { | 1304 | 1 | _bfd_error_handler | 1305 | 1 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1306 | 1 | bfd_set_error (bfd_error_malformed_archive); | 1307 | | | 1308 | 1 | return NULL; | 1309 | 1 | } | 1310 | | | 1311 | 2.16k | ordinal = H_GET_16 (abfd, ptr); | 1312 | 2.16k | ptr += 2; | 1313 | | | 1314 | 2.16k | types = H_GET_16 (abfd, ptr); | 1315 | | /* ptr += 2; */ | 1316 | | | 1317 | | /* Now read in the two strings that follow. */ | 1318 | 2.16k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1319 | 2.16k | if (ptr == NULL) | 1320 | 212 | return NULL; | 1321 | | | 1322 | 1.95k | symbol_name = (char *) ptr; | 1323 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1324 | 1.95k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1325 | | | 1326 | | /* Verify that the strings are null terminated. */ | 1327 | 1.95k | if (ptr[size - 1] != 0 | 1328 | 1.95k | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1329 | 207 | { | 1330 | 207 | _bfd_error_handler | 1331 | 207 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1332 | 207 | bfd_set_error (bfd_error_malformed_archive); | 1333 | 207 | bfd_release (abfd, ptr); | 1334 | 207 | return NULL; | 1335 | 207 | } | 1336 | | | 1337 | | /* Now construct the bfd. */ | 1338 | 1.74k | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1339 | 1.74k | source_dll, ordinal, types)) | 1340 | 314 | { | 1341 | 314 | bfd_release (abfd, ptr); | 1342 | 314 | return NULL; | 1343 | 314 | } | 1344 | | | 1345 | 1.43k | return pe_ILF_cleanup; | 1346 | 1.74k | } |
pei-arm-wince.c:pe_ILF_object_p Line | Count | Source | 1177 | 9.98k | { | 1178 | 9.98k | bfd_byte buffer[14]; | 1179 | 9.98k | bfd_byte * ptr; | 1180 | 9.98k | char * symbol_name; | 1181 | 9.98k | char * source_dll; | 1182 | 9.98k | unsigned int machine; | 1183 | 9.98k | bfd_size_type size; | 1184 | 9.98k | unsigned int ordinal; | 1185 | 9.98k | unsigned int types; | 1186 | 9.98k | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 9.98k | if (bfd_bread (buffer, (bfd_size_type) 14, abfd) != 14) | 1191 | 109 | return NULL; | 1192 | | | 1193 | 9.88k | ptr = buffer; | 1194 | | | 1195 | 9.88k | machine = H_GET_16 (abfd, ptr); | 1196 | 9.88k | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 9.88k | magic = 0; | 1200 | | | 1201 | 9.88k | switch (machine) | 1202 | 9.88k | { | 1203 | 104 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 104 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 104 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 107 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 107 | break; | 1208 | | | 1209 | 2.17k | case IMAGE_FILE_MACHINE_I386: | 1210 | | #ifdef I386MAGIC | 1211 | | magic = I386MAGIC; | 1212 | | #endif | 1213 | 2.17k | break; | 1214 | | | 1215 | 1.89k | case IMAGE_FILE_MACHINE_AMD64: | 1216 | | #ifdef AMD64MAGIC | 1217 | | magic = AMD64MAGIC; | 1218 | | #endif | 1219 | 1.89k | break; | 1220 | | | 1221 | 0 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 0 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 0 | case IMAGE_FILE_MACHINE_R10000: | 1224 | |
| 1225 | 0 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 0 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 1 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 1 | break; | 1232 | | | 1233 | 496 | case IMAGE_FILE_MACHINE_SH3: | 1234 | 1.01k | case IMAGE_FILE_MACHINE_SH4: | 1235 | | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | | magic = SH_ARCH_MAGIC_WINCE; | 1237 | | #endif | 1238 | 1.01k | break; | 1239 | | | 1240 | 1.33k | case IMAGE_FILE_MACHINE_ARM: | 1241 | 1.33k | #ifdef ARMPEMAGIC | 1242 | 1.33k | magic = ARMPEMAGIC; | 1243 | 1.33k | #endif | 1244 | 1.33k | break; | 1245 | | | 1246 | 231 | case IMAGE_FILE_MACHINE_ARM64: | 1247 | | #ifdef AARCH64MAGIC | 1248 | | magic = AARCH64MAGIC; | 1249 | | #endif | 1250 | 231 | break; | 1251 | | | 1252 | 2.15k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | | #ifdef LOONGARCH64MAGIC | 1254 | | magic = LOONGARCH64MAGIC; | 1255 | | #endif | 1256 | 2.15k | break; | 1257 | | | 1258 | 18 | case IMAGE_FILE_MACHINE_THUMB: | 1259 | 18 | #ifdef THUMBPEMAGIC | 1260 | 18 | { | 1261 | 18 | extern const bfd_target TARGET_LITTLE_SYM; | 1262 | | | 1263 | 18 | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1264 | 18 | magic = THUMBPEMAGIC; | 1265 | 18 | } | 1266 | 18 | #endif | 1267 | 18 | break; | 1268 | | | 1269 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1270 | | /* We no longer support PowerPC. */ | 1271 | 953 | default: | 1272 | 953 | _bfd_error_handler | 1273 | | /* xgettext:c-format */ | 1274 | 953 | (_("%pB: unrecognised machine type (0x%x)" | 1275 | 953 | " in Import Library Format archive"), | 1276 | 953 | abfd, machine); | 1277 | 953 | bfd_set_error (bfd_error_malformed_archive); | 1278 | | | 1279 | 953 | return NULL; | 1280 | 0 | break; | 1281 | 9.88k | } | 1282 | | | 1283 | 8.92k | if (magic == 0) | 1284 | 7.57k | { | 1285 | 7.57k | _bfd_error_handler | 1286 | | /* xgettext:c-format */ | 1287 | 7.57k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1288 | 7.57k | " in Import Library Format archive"), | 1289 | 7.57k | abfd, machine); | 1290 | 7.57k | bfd_set_error (bfd_error_wrong_format); | 1291 | | | 1292 | 7.57k | return NULL; | 1293 | 7.57k | } | 1294 | | | 1295 | | /* We do not bother to check the date. | 1296 | | date = H_GET_32 (abfd, ptr); */ | 1297 | 1.35k | ptr += 4; | 1298 | | | 1299 | 1.35k | size = H_GET_32 (abfd, ptr); | 1300 | 1.35k | ptr += 4; | 1301 | | | 1302 | 1.35k | if (size == 0) | 1303 | 104 | { | 1304 | 104 | _bfd_error_handler | 1305 | 104 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1306 | 104 | bfd_set_error (bfd_error_malformed_archive); | 1307 | | | 1308 | 104 | return NULL; | 1309 | 104 | } | 1310 | | | 1311 | 1.24k | ordinal = H_GET_16 (abfd, ptr); | 1312 | 1.24k | ptr += 2; | 1313 | | | 1314 | 1.24k | types = H_GET_16 (abfd, ptr); | 1315 | | /* ptr += 2; */ | 1316 | | | 1317 | | /* Now read in the two strings that follow. */ | 1318 | 1.24k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1319 | 1.24k | if (ptr == NULL) | 1320 | 521 | return NULL; | 1321 | | | 1322 | 726 | symbol_name = (char *) ptr; | 1323 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1324 | 726 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1325 | | | 1326 | | /* Verify that the strings are null terminated. */ | 1327 | 726 | if (ptr[size - 1] != 0 | 1328 | 726 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1329 | 107 | { | 1330 | 107 | _bfd_error_handler | 1331 | 107 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1332 | 107 | bfd_set_error (bfd_error_malformed_archive); | 1333 | 107 | bfd_release (abfd, ptr); | 1334 | 107 | return NULL; | 1335 | 107 | } | 1336 | | | 1337 | | /* Now construct the bfd. */ | 1338 | 619 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1339 | 619 | source_dll, ordinal, types)) | 1340 | 613 | { | 1341 | 613 | bfd_release (abfd, ptr); | 1342 | 613 | return NULL; | 1343 | 613 | } | 1344 | | | 1345 | 6 | return pe_ILF_cleanup; | 1346 | 619 | } |
pei-arm.c:pe_ILF_object_p Line | Count | Source | 1177 | 11.6k | { | 1178 | 11.6k | bfd_byte buffer[14]; | 1179 | 11.6k | bfd_byte * ptr; | 1180 | 11.6k | char * symbol_name; | 1181 | 11.6k | char * source_dll; | 1182 | 11.6k | unsigned int machine; | 1183 | 11.6k | bfd_size_type size; | 1184 | 11.6k | unsigned int ordinal; | 1185 | 11.6k | unsigned int types; | 1186 | 11.6k | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 11.6k | if (bfd_bread (buffer, (bfd_size_type) 14, abfd) != 14) | 1191 | 109 | return NULL; | 1192 | | | 1193 | 11.4k | ptr = buffer; | 1194 | | | 1195 | 11.4k | machine = H_GET_16 (abfd, ptr); | 1196 | 11.4k | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 11.4k | magic = 0; | 1200 | | | 1201 | 11.4k | switch (machine) | 1202 | 11.4k | { | 1203 | 104 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 104 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 104 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 107 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 107 | break; | 1208 | | | 1209 | 2.17k | case IMAGE_FILE_MACHINE_I386: | 1210 | | #ifdef I386MAGIC | 1211 | | magic = I386MAGIC; | 1212 | | #endif | 1213 | 2.17k | break; | 1214 | | | 1215 | 1.89k | case IMAGE_FILE_MACHINE_AMD64: | 1216 | | #ifdef AMD64MAGIC | 1217 | | magic = AMD64MAGIC; | 1218 | | #endif | 1219 | 1.89k | break; | 1220 | | | 1221 | 0 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 0 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 0 | case IMAGE_FILE_MACHINE_R10000: | 1224 | |
| 1225 | 0 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 0 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 1 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 1 | break; | 1232 | | | 1233 | 496 | case IMAGE_FILE_MACHINE_SH3: | 1234 | 1.01k | case IMAGE_FILE_MACHINE_SH4: | 1235 | | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | | magic = SH_ARCH_MAGIC_WINCE; | 1237 | | #endif | 1238 | 1.01k | break; | 1239 | | | 1240 | 2.70k | case IMAGE_FILE_MACHINE_ARM: | 1241 | 2.70k | #ifdef ARMPEMAGIC | 1242 | 2.70k | magic = ARMPEMAGIC; | 1243 | 2.70k | #endif | 1244 | 2.70k | break; | 1245 | | | 1246 | 231 | case IMAGE_FILE_MACHINE_ARM64: | 1247 | | #ifdef AARCH64MAGIC | 1248 | | magic = AARCH64MAGIC; | 1249 | | #endif | 1250 | 231 | break; | 1251 | | | 1252 | 2.15k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | | #ifdef LOONGARCH64MAGIC | 1254 | | magic = LOONGARCH64MAGIC; | 1255 | | #endif | 1256 | 2.15k | break; | 1257 | | | 1258 | 255 | case IMAGE_FILE_MACHINE_THUMB: | 1259 | 255 | #ifdef THUMBPEMAGIC | 1260 | 255 | { | 1261 | 255 | extern const bfd_target TARGET_LITTLE_SYM; | 1262 | | | 1263 | 255 | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1264 | 255 | magic = THUMBPEMAGIC; | 1265 | 255 | } | 1266 | 255 | #endif | 1267 | 255 | break; | 1268 | | | 1269 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1270 | | /* We no longer support PowerPC. */ | 1271 | 953 | default: | 1272 | 953 | _bfd_error_handler | 1273 | | /* xgettext:c-format */ | 1274 | 953 | (_("%pB: unrecognised machine type (0x%x)" | 1275 | 953 | " in Import Library Format archive"), | 1276 | 953 | abfd, machine); | 1277 | 953 | bfd_set_error (bfd_error_malformed_archive); | 1278 | | | 1279 | 953 | return NULL; | 1280 | 0 | break; | 1281 | 11.4k | } | 1282 | | | 1283 | 10.5k | if (magic == 0) | 1284 | 7.57k | { | 1285 | 7.57k | _bfd_error_handler | 1286 | | /* xgettext:c-format */ | 1287 | 7.57k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1288 | 7.57k | " in Import Library Format archive"), | 1289 | 7.57k | abfd, machine); | 1290 | 7.57k | bfd_set_error (bfd_error_wrong_format); | 1291 | | | 1292 | 7.57k | return NULL; | 1293 | 7.57k | } | 1294 | | | 1295 | | /* We do not bother to check the date. | 1296 | | date = H_GET_32 (abfd, ptr); */ | 1297 | 2.96k | ptr += 4; | 1298 | | | 1299 | 2.96k | size = H_GET_32 (abfd, ptr); | 1300 | 2.96k | ptr += 4; | 1301 | | | 1302 | 2.96k | if (size == 0) | 1303 | 104 | { | 1304 | 104 | _bfd_error_handler | 1305 | 104 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1306 | 104 | bfd_set_error (bfd_error_malformed_archive); | 1307 | | | 1308 | 104 | return NULL; | 1309 | 104 | } | 1310 | | | 1311 | 2.86k | ordinal = H_GET_16 (abfd, ptr); | 1312 | 2.86k | ptr += 2; | 1313 | | | 1314 | 2.86k | types = H_GET_16 (abfd, ptr); | 1315 | | /* ptr += 2; */ | 1316 | | | 1317 | | /* Now read in the two strings that follow. */ | 1318 | 2.86k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1319 | 2.86k | if (ptr == NULL) | 1320 | 521 | return NULL; | 1321 | | | 1322 | 2.33k | symbol_name = (char *) ptr; | 1323 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1324 | 2.33k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1325 | | | 1326 | | /* Verify that the strings are null terminated. */ | 1327 | 2.33k | if (ptr[size - 1] != 0 | 1328 | 2.33k | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1329 | 107 | { | 1330 | 107 | _bfd_error_handler | 1331 | 107 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1332 | 107 | bfd_set_error (bfd_error_malformed_archive); | 1333 | 107 | bfd_release (abfd, ptr); | 1334 | 107 | return NULL; | 1335 | 107 | } | 1336 | | | 1337 | | /* Now construct the bfd. */ | 1338 | 2.23k | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1339 | 2.23k | source_dll, ordinal, types)) | 1340 | 613 | { | 1341 | 613 | bfd_release (abfd, ptr); | 1342 | 613 | return NULL; | 1343 | 613 | } | 1344 | | | 1345 | 1.61k | return pe_ILF_cleanup; | 1346 | 2.23k | } |
pei-mcore.c:pe_ILF_object_p Line | Count | Source | 1177 | 8.75k | { | 1178 | 8.75k | bfd_byte buffer[14]; | 1179 | 8.75k | bfd_byte * ptr; | 1180 | 8.75k | char * symbol_name; | 1181 | 8.75k | char * source_dll; | 1182 | 8.75k | unsigned int machine; | 1183 | 8.75k | bfd_size_type size; | 1184 | 8.75k | unsigned int ordinal; | 1185 | 8.75k | unsigned int types; | 1186 | 8.75k | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 8.75k | if (bfd_bread (buffer, (bfd_size_type) 14, abfd) != 14) | 1191 | 109 | return NULL; | 1192 | | | 1193 | 8.64k | ptr = buffer; | 1194 | | | 1195 | 8.64k | machine = H_GET_16 (abfd, ptr); | 1196 | 8.64k | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 8.64k | magic = 0; | 1200 | | | 1201 | 8.64k | switch (machine) | 1202 | 8.64k | { | 1203 | 104 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 104 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 104 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 107 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 107 | break; | 1208 | | | 1209 | 939 | case IMAGE_FILE_MACHINE_I386: | 1210 | | #ifdef I386MAGIC | 1211 | | magic = I386MAGIC; | 1212 | | #endif | 1213 | 939 | break; | 1214 | | | 1215 | 1.89k | case IMAGE_FILE_MACHINE_AMD64: | 1216 | | #ifdef AMD64MAGIC | 1217 | | magic = AMD64MAGIC; | 1218 | | #endif | 1219 | 1.89k | break; | 1220 | | | 1221 | 0 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 0 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 0 | case IMAGE_FILE_MACHINE_R10000: | 1224 | |
| 1225 | 0 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 0 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 1 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 1 | break; | 1232 | | | 1233 | 496 | case IMAGE_FILE_MACHINE_SH3: | 1234 | 1.01k | case IMAGE_FILE_MACHINE_SH4: | 1235 | | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | | magic = SH_ARCH_MAGIC_WINCE; | 1237 | | #endif | 1238 | 1.01k | break; | 1239 | | | 1240 | 1.33k | case IMAGE_FILE_MACHINE_ARM: | 1241 | | #ifdef ARMPEMAGIC | 1242 | | magic = ARMPEMAGIC; | 1243 | | #endif | 1244 | 1.33k | break; | 1245 | | | 1246 | 231 | case IMAGE_FILE_MACHINE_ARM64: | 1247 | | #ifdef AARCH64MAGIC | 1248 | | magic = AARCH64MAGIC; | 1249 | | #endif | 1250 | 231 | break; | 1251 | | | 1252 | 2.15k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | | #ifdef LOONGARCH64MAGIC | 1254 | | magic = LOONGARCH64MAGIC; | 1255 | | #endif | 1256 | 2.15k | break; | 1257 | | | 1258 | 18 | case IMAGE_FILE_MACHINE_THUMB: | 1259 | | #ifdef THUMBPEMAGIC | 1260 | | { | 1261 | | extern const bfd_target TARGET_LITTLE_SYM; | 1262 | | | 1263 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1264 | | magic = THUMBPEMAGIC; | 1265 | | } | 1266 | | #endif | 1267 | 18 | break; | 1268 | | | 1269 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1270 | | /* We no longer support PowerPC. */ | 1271 | 953 | default: | 1272 | 953 | _bfd_error_handler | 1273 | | /* xgettext:c-format */ | 1274 | 953 | (_("%pB: unrecognised machine type (0x%x)" | 1275 | 953 | " in Import Library Format archive"), | 1276 | 953 | abfd, machine); | 1277 | 953 | bfd_set_error (bfd_error_malformed_archive); | 1278 | | | 1279 | 953 | return NULL; | 1280 | 0 | break; | 1281 | 8.64k | } | 1282 | | | 1283 | 7.68k | if (magic == 0) | 1284 | 7.68k | { | 1285 | 7.68k | _bfd_error_handler | 1286 | | /* xgettext:c-format */ | 1287 | 7.68k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1288 | 7.68k | " in Import Library Format archive"), | 1289 | 7.68k | abfd, machine); | 1290 | 7.68k | bfd_set_error (bfd_error_wrong_format); | 1291 | | | 1292 | 7.68k | return NULL; | 1293 | 7.68k | } | 1294 | | | 1295 | | /* We do not bother to check the date. | 1296 | | date = H_GET_32 (abfd, ptr); */ | 1297 | 0 | ptr += 4; | 1298 | |
| 1299 | 0 | size = H_GET_32 (abfd, ptr); | 1300 | 0 | ptr += 4; | 1301 | |
| 1302 | 0 | if (size == 0) | 1303 | 0 | { | 1304 | 0 | _bfd_error_handler | 1305 | 0 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1306 | 0 | bfd_set_error (bfd_error_malformed_archive); | 1307 | |
| 1308 | 0 | return NULL; | 1309 | 0 | } | 1310 | | | 1311 | 0 | ordinal = H_GET_16 (abfd, ptr); | 1312 | 0 | ptr += 2; | 1313 | |
| 1314 | 0 | types = H_GET_16 (abfd, ptr); | 1315 | | /* ptr += 2; */ | 1316 | | | 1317 | | /* Now read in the two strings that follow. */ | 1318 | 0 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1319 | 0 | if (ptr == NULL) | 1320 | 0 | return NULL; | 1321 | | | 1322 | 0 | symbol_name = (char *) ptr; | 1323 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1324 | 0 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1325 | | | 1326 | | /* Verify that the strings are null terminated. */ | 1327 | 0 | if (ptr[size - 1] != 0 | 1328 | 0 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1329 | 0 | { | 1330 | 0 | _bfd_error_handler | 1331 | 0 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1332 | 0 | bfd_set_error (bfd_error_malformed_archive); | 1333 | 0 | bfd_release (abfd, ptr); | 1334 | 0 | return NULL; | 1335 | 0 | } | 1336 | | | 1337 | | /* Now construct the bfd. */ | 1338 | 0 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1339 | 0 | source_dll, ordinal, types)) | 1340 | 0 | { | 1341 | 0 | bfd_release (abfd, ptr); | 1342 | 0 | return NULL; | 1343 | 0 | } | 1344 | | | 1345 | 0 | return pe_ILF_cleanup; | 1346 | 0 | } |
Line | Count | Source | 1177 | 8.74k | { | 1178 | 8.74k | bfd_byte buffer[14]; | 1179 | 8.74k | bfd_byte * ptr; | 1180 | 8.74k | char * symbol_name; | 1181 | 8.74k | char * source_dll; | 1182 | 8.74k | unsigned int machine; | 1183 | 8.74k | bfd_size_type size; | 1184 | 8.74k | unsigned int ordinal; | 1185 | 8.74k | unsigned int types; | 1186 | 8.74k | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 8.74k | if (bfd_bread (buffer, (bfd_size_type) 14, abfd) != 14) | 1191 | 109 | return NULL; | 1192 | | | 1193 | 8.64k | ptr = buffer; | 1194 | | | 1195 | 8.64k | machine = H_GET_16 (abfd, ptr); | 1196 | 8.64k | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 8.64k | magic = 0; | 1200 | | | 1201 | 8.64k | switch (machine) | 1202 | 8.64k | { | 1203 | 103 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 103 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 103 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 105 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 105 | break; | 1208 | | | 1209 | 939 | case IMAGE_FILE_MACHINE_I386: | 1210 | | #ifdef I386MAGIC | 1211 | | magic = I386MAGIC; | 1212 | | #endif | 1213 | 939 | break; | 1214 | | | 1215 | 1.89k | case IMAGE_FILE_MACHINE_AMD64: | 1216 | | #ifdef AMD64MAGIC | 1217 | | magic = AMD64MAGIC; | 1218 | | #endif | 1219 | 1.89k | break; | 1220 | | | 1221 | 0 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 0 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 0 | case IMAGE_FILE_MACHINE_R10000: | 1224 | |
| 1225 | 0 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 0 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 1 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 1 | break; | 1232 | | | 1233 | 498 | case IMAGE_FILE_MACHINE_SH3: | 1234 | 1.01k | case IMAGE_FILE_MACHINE_SH4: | 1235 | 1.01k | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | 1.01k | magic = SH_ARCH_MAGIC_WINCE; | 1237 | 1.01k | #endif | 1238 | 1.01k | break; | 1239 | | | 1240 | 1.33k | case IMAGE_FILE_MACHINE_ARM: | 1241 | | #ifdef ARMPEMAGIC | 1242 | | magic = ARMPEMAGIC; | 1243 | | #endif | 1244 | 1.33k | break; | 1245 | | | 1246 | 231 | case IMAGE_FILE_MACHINE_ARM64: | 1247 | | #ifdef AARCH64MAGIC | 1248 | | magic = AARCH64MAGIC; | 1249 | | #endif | 1250 | 231 | break; | 1251 | | | 1252 | 2.15k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | | #ifdef LOONGARCH64MAGIC | 1254 | | magic = LOONGARCH64MAGIC; | 1255 | | #endif | 1256 | 2.15k | break; | 1257 | | | 1258 | 18 | case IMAGE_FILE_MACHINE_THUMB: | 1259 | | #ifdef THUMBPEMAGIC | 1260 | | { | 1261 | | extern const bfd_target TARGET_LITTLE_SYM; | 1262 | | | 1263 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1264 | | magic = THUMBPEMAGIC; | 1265 | | } | 1266 | | #endif | 1267 | 18 | break; | 1268 | | | 1269 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1270 | | /* We no longer support PowerPC. */ | 1271 | 952 | default: | 1272 | 952 | _bfd_error_handler | 1273 | | /* xgettext:c-format */ | 1274 | 952 | (_("%pB: unrecognised machine type (0x%x)" | 1275 | 952 | " in Import Library Format archive"), | 1276 | 952 | abfd, machine); | 1277 | 952 | bfd_set_error (bfd_error_malformed_archive); | 1278 | | | 1279 | 952 | return NULL; | 1280 | 0 | break; | 1281 | 8.64k | } | 1282 | | | 1283 | 7.68k | if (magic == 0) | 1284 | 6.67k | { | 1285 | 6.67k | _bfd_error_handler | 1286 | | /* xgettext:c-format */ | 1287 | 6.67k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1288 | 6.67k | " in Import Library Format archive"), | 1289 | 6.67k | abfd, machine); | 1290 | 6.67k | bfd_set_error (bfd_error_wrong_format); | 1291 | | | 1292 | 6.67k | return NULL; | 1293 | 6.67k | } | 1294 | | | 1295 | | /* We do not bother to check the date. | 1296 | | date = H_GET_32 (abfd, ptr); */ | 1297 | 1.01k | ptr += 4; | 1298 | | | 1299 | 1.01k | size = H_GET_32 (abfd, ptr); | 1300 | 1.01k | ptr += 4; | 1301 | | | 1302 | 1.01k | if (size == 0) | 1303 | 104 | { | 1304 | 104 | _bfd_error_handler | 1305 | 104 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1306 | 104 | bfd_set_error (bfd_error_malformed_archive); | 1307 | | | 1308 | 104 | return NULL; | 1309 | 104 | } | 1310 | | | 1311 | 908 | ordinal = H_GET_16 (abfd, ptr); | 1312 | 908 | ptr += 2; | 1313 | | | 1314 | 908 | types = H_GET_16 (abfd, ptr); | 1315 | | /* ptr += 2; */ | 1316 | | | 1317 | | /* Now read in the two strings that follow. */ | 1318 | 908 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1319 | 908 | if (ptr == NULL) | 1320 | 209 | return NULL; | 1321 | | | 1322 | 699 | symbol_name = (char *) ptr; | 1323 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1324 | 699 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1325 | | | 1326 | | /* Verify that the strings are null terminated. */ | 1327 | 699 | if (ptr[size - 1] != 0 | 1328 | 699 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1329 | 107 | { | 1330 | 107 | _bfd_error_handler | 1331 | 107 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1332 | 107 | bfd_set_error (bfd_error_malformed_archive); | 1333 | 107 | bfd_release (abfd, ptr); | 1334 | 107 | return NULL; | 1335 | 107 | } | 1336 | | | 1337 | | /* Now construct the bfd. */ | 1338 | 592 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1339 | 592 | source_dll, ordinal, types)) | 1340 | 113 | { | 1341 | 113 | bfd_release (abfd, ptr); | 1342 | 113 | return NULL; | 1343 | 113 | } | 1344 | | | 1345 | 479 | return pe_ILF_cleanup; | 1346 | 592 | } |
|
1347 | | |
1348 | | static void |
1349 | | pe_bfd_read_buildid (bfd *abfd) |
1350 | 96.9k | { |
1351 | 96.9k | pe_data_type *pe = pe_data (abfd); |
1352 | 96.9k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; |
1353 | 96.9k | asection *section; |
1354 | 96.9k | bfd_byte *data = 0; |
1355 | 96.9k | bfd_size_type dataoff; |
1356 | 96.9k | unsigned int i; |
1357 | 96.9k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; |
1358 | 96.9k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; |
1359 | | |
1360 | 96.9k | if (size == 0) |
1361 | 26.2k | return; |
1362 | | |
1363 | 70.6k | addr += extra->ImageBase; |
1364 | | |
1365 | | /* Search for the section containing the DebugDirectory. */ |
1366 | 158k | for (section = abfd->sections; section != NULL; section = section->next) |
1367 | 118k | { |
1368 | 118k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) |
1369 | 30.4k | break; |
1370 | 118k | } |
1371 | | |
1372 | 70.6k | if (section == NULL) |
1373 | 40.1k | return; |
1374 | | |
1375 | 30.4k | if (!(section->flags & SEC_HAS_CONTENTS)) |
1376 | 2.03k | return; |
1377 | | |
1378 | 28.4k | dataoff = addr - section->vma; |
1379 | | |
1380 | | /* PR 20605 and 22373: Make sure that the data is really there. |
1381 | | Note - since we are dealing with unsigned quantities we have |
1382 | | to be careful to check for potential overflows. */ |
1383 | 28.4k | if (dataoff >= section->size |
1384 | 28.4k | || size > section->size - dataoff) |
1385 | 10.2k | { |
1386 | 10.2k | _bfd_error_handler |
1387 | 10.2k | (_("%pB: error: debug data ends beyond end of debug directory"), |
1388 | 10.2k | abfd); |
1389 | 10.2k | return; |
1390 | 10.2k | } |
1391 | | |
1392 | | /* Read the whole section. */ |
1393 | 18.1k | if (!bfd_malloc_and_get_section (abfd, section, &data)) |
1394 | 11.5k | { |
1395 | 11.5k | free (data); |
1396 | 11.5k | return; |
1397 | 11.5k | } |
1398 | | |
1399 | | /* Search for a CodeView entry in the DebugDirectory */ |
1400 | 96.4k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) |
1401 | 93.4k | { |
1402 | 93.4k | struct external_IMAGE_DEBUG_DIRECTORY *ext |
1403 | 93.4k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; |
1404 | 93.4k | struct internal_IMAGE_DEBUG_DIRECTORY idd; |
1405 | | |
1406 | 93.4k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); |
1407 | | |
1408 | 93.4k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) |
1409 | 3.57k | { |
1410 | 3.57k | char buffer[256 + 1]; |
1411 | 3.57k | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; |
1412 | | |
1413 | | /* |
1414 | | The debug entry doesn't have to have to be in a section, in which |
1415 | | case AddressOfRawData is 0, so always use PointerToRawData. |
1416 | | */ |
1417 | 3.57k | if (_bfd_XXi_slurp_codeview_record (abfd, |
1418 | 3.57k | (file_ptr) idd.PointerToRawData, |
1419 | 3.57k | idd.SizeOfData, cvinfo, NULL)) |
1420 | 0 | { |
1421 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, |
1422 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); |
1423 | 0 | if (build_id) |
1424 | 0 | { |
1425 | 0 | build_id->size = cvinfo->SignatureLength; |
1426 | 0 | memcpy(build_id->data, cvinfo->Signature, |
1427 | 0 | cvinfo->SignatureLength); |
1428 | 0 | abfd->build_id = build_id; |
1429 | 0 | } |
1430 | 0 | } |
1431 | 3.57k | break; |
1432 | 3.57k | } |
1433 | 93.4k | } |
1434 | | |
1435 | 6.60k | free (data); |
1436 | 6.60k | } pei-i386.c:pe_bfd_read_buildid Line | Count | Source | 1350 | 11.2k | { | 1351 | 11.2k | pe_data_type *pe = pe_data (abfd); | 1352 | 11.2k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1353 | 11.2k | asection *section; | 1354 | 11.2k | bfd_byte *data = 0; | 1355 | 11.2k | bfd_size_type dataoff; | 1356 | 11.2k | unsigned int i; | 1357 | 11.2k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1358 | 11.2k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1359 | | | 1360 | 11.2k | if (size == 0) | 1361 | 7.08k | return; | 1362 | | | 1363 | 4.17k | addr += extra->ImageBase; | 1364 | | | 1365 | | /* Search for the section containing the DebugDirectory. */ | 1366 | 6.49k | for (section = abfd->sections; section != NULL; section = section->next) | 1367 | 4.04k | { | 1368 | 4.04k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1369 | 1.72k | break; | 1370 | 4.04k | } | 1371 | | | 1372 | 4.17k | if (section == NULL) | 1373 | 2.45k | return; | 1374 | | | 1375 | 1.72k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1376 | 135 | return; | 1377 | | | 1378 | 1.58k | dataoff = addr - section->vma; | 1379 | | | 1380 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1381 | | Note - since we are dealing with unsigned quantities we have | 1382 | | to be careful to check for potential overflows. */ | 1383 | 1.58k | if (dataoff >= section->size | 1384 | 1.58k | || size > section->size - dataoff) | 1385 | 1.01k | { | 1386 | 1.01k | _bfd_error_handler | 1387 | 1.01k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1388 | 1.01k | abfd); | 1389 | 1.01k | return; | 1390 | 1.01k | } | 1391 | | | 1392 | | /* Read the whole section. */ | 1393 | 571 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1394 | 571 | { | 1395 | 571 | free (data); | 1396 | 571 | return; | 1397 | 571 | } | 1398 | | | 1399 | | /* Search for a CodeView entry in the DebugDirectory */ | 1400 | 0 | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1401 | 0 | { | 1402 | 0 | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1403 | 0 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1404 | 0 | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1405 | |
| 1406 | 0 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1407 | |
| 1408 | 0 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1409 | 0 | { | 1410 | 0 | char buffer[256 + 1]; | 1411 | 0 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1412 | | | 1413 | | /* | 1414 | | The debug entry doesn't have to have to be in a section, in which | 1415 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1416 | | */ | 1417 | 0 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1418 | 0 | (file_ptr) idd.PointerToRawData, | 1419 | 0 | idd.SizeOfData, cvinfo, NULL)) | 1420 | 0 | { | 1421 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1422 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1423 | 0 | if (build_id) | 1424 | 0 | { | 1425 | 0 | build_id->size = cvinfo->SignatureLength; | 1426 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1427 | 0 | cvinfo->SignatureLength); | 1428 | 0 | abfd->build_id = build_id; | 1429 | 0 | } | 1430 | 0 | } | 1431 | 0 | break; | 1432 | 0 | } | 1433 | 0 | } | 1434 | |
| 1435 | 0 | free (data); | 1436 | 0 | } |
pei-x86_64.c:pe_bfd_read_buildid Line | Count | Source | 1350 | 18.0k | { | 1351 | 18.0k | pe_data_type *pe = pe_data (abfd); | 1352 | 18.0k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1353 | 18.0k | asection *section; | 1354 | 18.0k | bfd_byte *data = 0; | 1355 | 18.0k | bfd_size_type dataoff; | 1356 | 18.0k | unsigned int i; | 1357 | 18.0k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1358 | 18.0k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1359 | | | 1360 | 18.0k | if (size == 0) | 1361 | 5.48k | return; | 1362 | | | 1363 | 12.5k | addr += extra->ImageBase; | 1364 | | | 1365 | | /* Search for the section containing the DebugDirectory. */ | 1366 | 40.3k | for (section = abfd->sections; section != NULL; section = section->next) | 1367 | 34.1k | { | 1368 | 34.1k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1369 | 6.33k | break; | 1370 | 34.1k | } | 1371 | | | 1372 | 12.5k | if (section == NULL) | 1373 | 6.21k | return; | 1374 | | | 1375 | 6.33k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1376 | 499 | return; | 1377 | | | 1378 | 5.83k | dataoff = addr - section->vma; | 1379 | | | 1380 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1381 | | Note - since we are dealing with unsigned quantities we have | 1382 | | to be careful to check for potential overflows. */ | 1383 | 5.83k | if (dataoff >= section->size | 1384 | 5.83k | || size > section->size - dataoff) | 1385 | 1.12k | { | 1386 | 1.12k | _bfd_error_handler | 1387 | 1.12k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1388 | 1.12k | abfd); | 1389 | 1.12k | return; | 1390 | 1.12k | } | 1391 | | | 1392 | | /* Read the whole section. */ | 1393 | 4.70k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1394 | 2.56k | { | 1395 | 2.56k | free (data); | 1396 | 2.56k | return; | 1397 | 2.56k | } | 1398 | | | 1399 | | /* Search for a CodeView entry in the DebugDirectory */ | 1400 | 5.23k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1401 | 4.29k | { | 1402 | 4.29k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1403 | 4.29k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1404 | 4.29k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1405 | | | 1406 | 4.29k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1407 | | | 1408 | 4.29k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1409 | 1.19k | { | 1410 | 1.19k | char buffer[256 + 1]; | 1411 | 1.19k | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1412 | | | 1413 | | /* | 1414 | | The debug entry doesn't have to have to be in a section, in which | 1415 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1416 | | */ | 1417 | 1.19k | if (_bfd_XXi_slurp_codeview_record (abfd, | 1418 | 1.19k | (file_ptr) idd.PointerToRawData, | 1419 | 1.19k | idd.SizeOfData, cvinfo, NULL)) | 1420 | 0 | { | 1421 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1422 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1423 | 0 | if (build_id) | 1424 | 0 | { | 1425 | 0 | build_id->size = cvinfo->SignatureLength; | 1426 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1427 | 0 | cvinfo->SignatureLength); | 1428 | 0 | abfd->build_id = build_id; | 1429 | 0 | } | 1430 | 0 | } | 1431 | 1.19k | break; | 1432 | 1.19k | } | 1433 | 4.29k | } | 1434 | | | 1435 | 2.14k | free (data); | 1436 | 2.14k | } |
pei-aarch64.c:pe_bfd_read_buildid Line | Count | Source | 1350 | 10.5k | { | 1351 | 10.5k | pe_data_type *pe = pe_data (abfd); | 1352 | 10.5k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1353 | 10.5k | asection *section; | 1354 | 10.5k | bfd_byte *data = 0; | 1355 | 10.5k | bfd_size_type dataoff; | 1356 | 10.5k | unsigned int i; | 1357 | 10.5k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1358 | 10.5k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1359 | | | 1360 | 10.5k | if (size == 0) | 1361 | 1.89k | return; | 1362 | | | 1363 | 8.65k | addr += extra->ImageBase; | 1364 | | | 1365 | | /* Search for the section containing the DebugDirectory. */ | 1366 | 21.3k | for (section = abfd->sections; section != NULL; section = section->next) | 1367 | 14.3k | { | 1368 | 14.3k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1369 | 1.70k | break; | 1370 | 14.3k | } | 1371 | | | 1372 | 8.65k | if (section == NULL) | 1373 | 6.94k | return; | 1374 | | | 1375 | 1.70k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1376 | 3 | return; | 1377 | | | 1378 | 1.70k | dataoff = addr - section->vma; | 1379 | | | 1380 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1381 | | Note - since we are dealing with unsigned quantities we have | 1382 | | to be careful to check for potential overflows. */ | 1383 | 1.70k | if (dataoff >= section->size | 1384 | 1.70k | || size > section->size - dataoff) | 1385 | 980 | { | 1386 | 980 | _bfd_error_handler | 1387 | 980 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1388 | 980 | abfd); | 1389 | 980 | return; | 1390 | 980 | } | 1391 | | | 1392 | | /* Read the whole section. */ | 1393 | 726 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1394 | 715 | { | 1395 | 715 | free (data); | 1396 | 715 | return; | 1397 | 715 | } | 1398 | | | 1399 | | /* Search for a CodeView entry in the DebugDirectory */ | 1400 | 60 | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1401 | 53 | { | 1402 | 53 | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1403 | 53 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1404 | 53 | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1405 | | | 1406 | 53 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1407 | | | 1408 | 53 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1409 | 4 | { | 1410 | 4 | char buffer[256 + 1]; | 1411 | 4 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1412 | | | 1413 | | /* | 1414 | | The debug entry doesn't have to have to be in a section, in which | 1415 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1416 | | */ | 1417 | 4 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1418 | 4 | (file_ptr) idd.PointerToRawData, | 1419 | 4 | idd.SizeOfData, cvinfo, NULL)) | 1420 | 0 | { | 1421 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1422 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1423 | 0 | if (build_id) | 1424 | 0 | { | 1425 | 0 | build_id->size = cvinfo->SignatureLength; | 1426 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1427 | 0 | cvinfo->SignatureLength); | 1428 | 0 | abfd->build_id = build_id; | 1429 | 0 | } | 1430 | 0 | } | 1431 | 4 | break; | 1432 | 4 | } | 1433 | 53 | } | 1434 | | | 1435 | 11 | free (data); | 1436 | 11 | } |
pei-ia64.c:pe_bfd_read_buildid Line | Count | Source | 1350 | 9.29k | { | 1351 | 9.29k | pe_data_type *pe = pe_data (abfd); | 1352 | 9.29k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1353 | 9.29k | asection *section; | 1354 | 9.29k | bfd_byte *data = 0; | 1355 | 9.29k | bfd_size_type dataoff; | 1356 | 9.29k | unsigned int i; | 1357 | 9.29k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1358 | 9.29k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1359 | | | 1360 | 9.29k | if (size == 0) | 1361 | 3.50k | return; | 1362 | | | 1363 | 5.78k | addr += extra->ImageBase; | 1364 | | | 1365 | | /* Search for the section containing the DebugDirectory. */ | 1366 | 10.3k | for (section = abfd->sections; section != NULL; section = section->next) | 1367 | 6.97k | { | 1368 | 6.97k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1369 | 2.42k | break; | 1370 | 6.97k | } | 1371 | | | 1372 | 5.78k | if (section == NULL) | 1373 | 3.36k | return; | 1374 | | | 1375 | 2.42k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1376 | 339 | return; | 1377 | | | 1378 | 2.08k | dataoff = addr - section->vma; | 1379 | | | 1380 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1381 | | Note - since we are dealing with unsigned quantities we have | 1382 | | to be careful to check for potential overflows. */ | 1383 | 2.08k | if (dataoff >= section->size | 1384 | 2.08k | || size > section->size - dataoff) | 1385 | 683 | { | 1386 | 683 | _bfd_error_handler | 1387 | 683 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1388 | 683 | abfd); | 1389 | 683 | return; | 1390 | 683 | } | 1391 | | | 1392 | | /* Read the whole section. */ | 1393 | 1.40k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1394 | 446 | { | 1395 | 446 | free (data); | 1396 | 446 | return; | 1397 | 446 | } | 1398 | | | 1399 | | /* Search for a CodeView entry in the DebugDirectory */ | 1400 | 2.86k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1401 | 2.62k | { | 1402 | 2.62k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1403 | 2.62k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1404 | 2.62k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1405 | | | 1406 | 2.62k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1407 | | | 1408 | 2.62k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1409 | 714 | { | 1410 | 714 | char buffer[256 + 1]; | 1411 | 714 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1412 | | | 1413 | | /* | 1414 | | The debug entry doesn't have to have to be in a section, in which | 1415 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1416 | | */ | 1417 | 714 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1418 | 714 | (file_ptr) idd.PointerToRawData, | 1419 | 714 | idd.SizeOfData, cvinfo, NULL)) | 1420 | 0 | { | 1421 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1422 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1423 | 0 | if (build_id) | 1424 | 0 | { | 1425 | 0 | build_id->size = cvinfo->SignatureLength; | 1426 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1427 | 0 | cvinfo->SignatureLength); | 1428 | 0 | abfd->build_id = build_id; | 1429 | 0 | } | 1430 | 0 | } | 1431 | 714 | break; | 1432 | 714 | } | 1433 | 2.62k | } | 1434 | | | 1435 | 956 | free (data); | 1436 | 956 | } |
pei-loongarch64.c:pe_bfd_read_buildid Line | Count | Source | 1350 | 8.09k | { | 1351 | 8.09k | pe_data_type *pe = pe_data (abfd); | 1352 | 8.09k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1353 | 8.09k | asection *section; | 1354 | 8.09k | bfd_byte *data = 0; | 1355 | 8.09k | bfd_size_type dataoff; | 1356 | 8.09k | unsigned int i; | 1357 | 8.09k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1358 | 8.09k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1359 | | | 1360 | 8.09k | if (size == 0) | 1361 | 1.63k | return; | 1362 | | | 1363 | 6.46k | addr += extra->ImageBase; | 1364 | | | 1365 | | /* Search for the section containing the DebugDirectory. */ | 1366 | 17.3k | for (section = abfd->sections; section != NULL; section = section->next) | 1367 | 12.9k | { | 1368 | 12.9k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1369 | 2.00k | break; | 1370 | 12.9k | } | 1371 | | | 1372 | 6.46k | if (section == NULL) | 1373 | 4.45k | return; | 1374 | | | 1375 | 2.00k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1376 | 1 | return; | 1377 | | | 1378 | 2.00k | dataoff = addr - section->vma; | 1379 | | | 1380 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1381 | | Note - since we are dealing with unsigned quantities we have | 1382 | | to be careful to check for potential overflows. */ | 1383 | 2.00k | if (dataoff >= section->size | 1384 | 2.00k | || size > section->size - dataoff) | 1385 | 1.05k | { | 1386 | 1.05k | _bfd_error_handler | 1387 | 1.05k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1388 | 1.05k | abfd); | 1389 | 1.05k | return; | 1390 | 1.05k | } | 1391 | | | 1392 | | /* Read the whole section. */ | 1393 | 952 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1394 | 477 | { | 1395 | 477 | free (data); | 1396 | 477 | return; | 1397 | 477 | } | 1398 | | | 1399 | | /* Search for a CodeView entry in the DebugDirectory */ | 1400 | 1.45k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1401 | 982 | { | 1402 | 982 | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1403 | 982 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1404 | 982 | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1405 | | | 1406 | 982 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1407 | | | 1408 | 982 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1409 | 2 | { | 1410 | 2 | char buffer[256 + 1]; | 1411 | 2 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1412 | | | 1413 | | /* | 1414 | | The debug entry doesn't have to have to be in a section, in which | 1415 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1416 | | */ | 1417 | 2 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1418 | 2 | (file_ptr) idd.PointerToRawData, | 1419 | 2 | idd.SizeOfData, cvinfo, NULL)) | 1420 | 0 | { | 1421 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1422 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1423 | 0 | if (build_id) | 1424 | 0 | { | 1425 | 0 | build_id->size = cvinfo->SignatureLength; | 1426 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1427 | 0 | cvinfo->SignatureLength); | 1428 | 0 | abfd->build_id = build_id; | 1429 | 0 | } | 1430 | 0 | } | 1431 | 2 | break; | 1432 | 2 | } | 1433 | 982 | } | 1434 | | | 1435 | 475 | free (data); | 1436 | 475 | } |
pei-arm-wince.c:pe_bfd_read_buildid Line | Count | Source | 1350 | 5.02k | { | 1351 | 5.02k | pe_data_type *pe = pe_data (abfd); | 1352 | 5.02k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1353 | 5.02k | asection *section; | 1354 | 5.02k | bfd_byte *data = 0; | 1355 | 5.02k | bfd_size_type dataoff; | 1356 | 5.02k | unsigned int i; | 1357 | 5.02k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1358 | 5.02k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1359 | | | 1360 | 5.02k | if (size == 0) | 1361 | 364 | return; | 1362 | | | 1363 | 4.65k | addr += extra->ImageBase; | 1364 | | | 1365 | | /* Search for the section containing the DebugDirectory. */ | 1366 | 9.08k | for (section = abfd->sections; section != NULL; section = section->next) | 1367 | 6.25k | { | 1368 | 6.25k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1369 | 1.82k | break; | 1370 | 6.25k | } | 1371 | | | 1372 | 4.65k | if (section == NULL) | 1373 | 2.83k | return; | 1374 | | | 1375 | 1.82k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1376 | 240 | return; | 1377 | | | 1378 | 1.58k | dataoff = addr - section->vma; | 1379 | | | 1380 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1381 | | Note - since we are dealing with unsigned quantities we have | 1382 | | to be careful to check for potential overflows. */ | 1383 | 1.58k | if (dataoff >= section->size | 1384 | 1.58k | || size > section->size - dataoff) | 1385 | 822 | { | 1386 | 822 | _bfd_error_handler | 1387 | 822 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1388 | 822 | abfd); | 1389 | 822 | return; | 1390 | 822 | } | 1391 | | | 1392 | | /* Read the whole section. */ | 1393 | 762 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1394 | 344 | { | 1395 | 344 | free (data); | 1396 | 344 | return; | 1397 | 344 | } | 1398 | | | 1399 | | /* Search for a CodeView entry in the DebugDirectory */ | 1400 | 16.5k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1401 | 16.3k | { | 1402 | 16.3k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1403 | 16.3k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1404 | 16.3k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1405 | | | 1406 | 16.3k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1407 | | | 1408 | 16.3k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1409 | 211 | { | 1410 | 211 | char buffer[256 + 1]; | 1411 | 211 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1412 | | | 1413 | | /* | 1414 | | The debug entry doesn't have to have to be in a section, in which | 1415 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1416 | | */ | 1417 | 211 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1418 | 211 | (file_ptr) idd.PointerToRawData, | 1419 | 211 | idd.SizeOfData, cvinfo, NULL)) | 1420 | 0 | { | 1421 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1422 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1423 | 0 | if (build_id) | 1424 | 0 | { | 1425 | 0 | build_id->size = cvinfo->SignatureLength; | 1426 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1427 | 0 | cvinfo->SignatureLength); | 1428 | 0 | abfd->build_id = build_id; | 1429 | 0 | } | 1430 | 0 | } | 1431 | 211 | break; | 1432 | 211 | } | 1433 | 16.3k | } | 1434 | | | 1435 | 418 | free (data); | 1436 | 418 | } |
pei-arm.c:pe_bfd_read_buildid Line | Count | Source | 1350 | 11.2k | { | 1351 | 11.2k | pe_data_type *pe = pe_data (abfd); | 1352 | 11.2k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1353 | 11.2k | asection *section; | 1354 | 11.2k | bfd_byte *data = 0; | 1355 | 11.2k | bfd_size_type dataoff; | 1356 | 11.2k | unsigned int i; | 1357 | 11.2k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1358 | 11.2k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1359 | | | 1360 | 11.2k | if (size == 0) | 1361 | 1.17k | return; | 1362 | | | 1363 | 10.0k | addr += extra->ImageBase; | 1364 | | | 1365 | | /* Search for the section containing the DebugDirectory. */ | 1366 | 17.7k | for (section = abfd->sections; section != NULL; section = section->next) | 1367 | 13.5k | { | 1368 | 13.5k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1369 | 5.81k | break; | 1370 | 13.5k | } | 1371 | | | 1372 | 10.0k | if (section == NULL) | 1373 | 4.26k | return; | 1374 | | | 1375 | 5.81k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1376 | 241 | return; | 1377 | | | 1378 | 5.57k | dataoff = addr - section->vma; | 1379 | | | 1380 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1381 | | Note - since we are dealing with unsigned quantities we have | 1382 | | to be careful to check for potential overflows. */ | 1383 | 5.57k | if (dataoff >= section->size | 1384 | 5.57k | || size > section->size - dataoff) | 1385 | 1.77k | { | 1386 | 1.77k | _bfd_error_handler | 1387 | 1.77k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1388 | 1.77k | abfd); | 1389 | 1.77k | return; | 1390 | 1.77k | } | 1391 | | | 1392 | | /* Read the whole section. */ | 1393 | 3.80k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1394 | 2.56k | { | 1395 | 2.56k | free (data); | 1396 | 2.56k | return; | 1397 | 2.56k | } | 1398 | | | 1399 | | /* Search for a CodeView entry in the DebugDirectory */ | 1400 | 34.3k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1401 | 33.9k | { | 1402 | 33.9k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1403 | 33.9k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1404 | 33.9k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1405 | | | 1406 | 33.9k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1407 | | | 1408 | 33.9k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1409 | 903 | { | 1410 | 903 | char buffer[256 + 1]; | 1411 | 903 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1412 | | | 1413 | | /* | 1414 | | The debug entry doesn't have to have to be in a section, in which | 1415 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1416 | | */ | 1417 | 903 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1418 | 903 | (file_ptr) idd.PointerToRawData, | 1419 | 903 | idd.SizeOfData, cvinfo, NULL)) | 1420 | 0 | { | 1421 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1422 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1423 | 0 | if (build_id) | 1424 | 0 | { | 1425 | 0 | build_id->size = cvinfo->SignatureLength; | 1426 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1427 | 0 | cvinfo->SignatureLength); | 1428 | 0 | abfd->build_id = build_id; | 1429 | 0 | } | 1430 | 0 | } | 1431 | 903 | break; | 1432 | 903 | } | 1433 | 33.9k | } | 1434 | | | 1435 | 1.24k | free (data); | 1436 | 1.24k | } |
pei-mcore.c:pe_bfd_read_buildid Line | Count | Source | 1350 | 17.7k | { | 1351 | 17.7k | pe_data_type *pe = pe_data (abfd); | 1352 | 17.7k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1353 | 17.7k | asection *section; | 1354 | 17.7k | bfd_byte *data = 0; | 1355 | 17.7k | bfd_size_type dataoff; | 1356 | 17.7k | unsigned int i; | 1357 | 17.7k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1358 | 17.7k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1359 | | | 1360 | 17.7k | if (size == 0) | 1361 | 3.26k | return; | 1362 | | | 1363 | 14.4k | addr += extra->ImageBase; | 1364 | | | 1365 | | /* Search for the section containing the DebugDirectory. */ | 1366 | 28.0k | for (section = abfd->sections; section != NULL; section = section->next) | 1367 | 20.9k | { | 1368 | 20.9k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1369 | 7.32k | break; | 1370 | 20.9k | } | 1371 | | | 1372 | 14.4k | if (section == NULL) | 1373 | 7.14k | return; | 1374 | | | 1375 | 7.32k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1376 | 577 | return; | 1377 | | | 1378 | 6.74k | dataoff = addr - section->vma; | 1379 | | | 1380 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1381 | | Note - since we are dealing with unsigned quantities we have | 1382 | | to be careful to check for potential overflows. */ | 1383 | 6.74k | if (dataoff >= section->size | 1384 | 6.74k | || size > section->size - dataoff) | 1385 | 2.24k | { | 1386 | 2.24k | _bfd_error_handler | 1387 | 2.24k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1388 | 2.24k | abfd); | 1389 | 2.24k | return; | 1390 | 2.24k | } | 1391 | | | 1392 | | /* Read the whole section. */ | 1393 | 4.49k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1394 | 3.50k | { | 1395 | 3.50k | free (data); | 1396 | 3.50k | return; | 1397 | 3.50k | } | 1398 | | | 1399 | | /* Search for a CodeView entry in the DebugDirectory */ | 1400 | 34.4k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1401 | 34.0k | { | 1402 | 34.0k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1403 | 34.0k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1404 | 34.0k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1405 | | | 1406 | 34.0k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1407 | | | 1408 | 34.0k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1409 | 541 | { | 1410 | 541 | char buffer[256 + 1]; | 1411 | 541 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1412 | | | 1413 | | /* | 1414 | | The debug entry doesn't have to have to be in a section, in which | 1415 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1416 | | */ | 1417 | 541 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1418 | 541 | (file_ptr) idd.PointerToRawData, | 1419 | 541 | idd.SizeOfData, cvinfo, NULL)) | 1420 | 0 | { | 1421 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1422 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1423 | 0 | if (build_id) | 1424 | 0 | { | 1425 | 0 | build_id->size = cvinfo->SignatureLength; | 1426 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1427 | 0 | cvinfo->SignatureLength); | 1428 | 0 | abfd->build_id = build_id; | 1429 | 0 | } | 1430 | 0 | } | 1431 | 541 | break; | 1432 | 541 | } | 1433 | 34.0k | } | 1434 | | | 1435 | 987 | free (data); | 1436 | 987 | } |
pei-sh.c:pe_bfd_read_buildid Line | Count | Source | 1350 | 5.68k | { | 1351 | 5.68k | pe_data_type *pe = pe_data (abfd); | 1352 | 5.68k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1353 | 5.68k | asection *section; | 1354 | 5.68k | bfd_byte *data = 0; | 1355 | 5.68k | bfd_size_type dataoff; | 1356 | 5.68k | unsigned int i; | 1357 | 5.68k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1358 | 5.68k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1359 | | | 1360 | 5.68k | if (size == 0) | 1361 | 1.89k | return; | 1362 | | | 1363 | 3.78k | addr += extra->ImageBase; | 1364 | | | 1365 | | /* Search for the section containing the DebugDirectory. */ | 1366 | 7.95k | for (section = abfd->sections; section != NULL; section = section->next) | 1367 | 5.49k | { | 1368 | 5.49k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1369 | 1.33k | break; | 1370 | 5.49k | } | 1371 | | | 1372 | 3.78k | if (section == NULL) | 1373 | 2.45k | return; | 1374 | | | 1375 | 1.33k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1376 | 3 | return; | 1377 | | | 1378 | 1.32k | dataoff = addr - section->vma; | 1379 | | | 1380 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1381 | | Note - since we are dealing with unsigned quantities we have | 1382 | | to be careful to check for potential overflows. */ | 1383 | 1.32k | if (dataoff >= section->size | 1384 | 1.32k | || size > section->size - dataoff) | 1385 | 580 | { | 1386 | 580 | _bfd_error_handler | 1387 | 580 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1388 | 580 | abfd); | 1389 | 580 | return; | 1390 | 580 | } | 1391 | | | 1392 | | /* Read the whole section. */ | 1393 | 748 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1394 | 378 | { | 1395 | 378 | free (data); | 1396 | 378 | return; | 1397 | 378 | } | 1398 | | | 1399 | | /* Search for a CodeView entry in the DebugDirectory */ | 1400 | 1.55k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1401 | 1.18k | { | 1402 | 1.18k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1403 | 1.18k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1404 | 1.18k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1405 | | | 1406 | 1.18k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1407 | | | 1408 | 1.18k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1409 | 2 | { | 1410 | 2 | char buffer[256 + 1]; | 1411 | 2 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1412 | | | 1413 | | /* | 1414 | | The debug entry doesn't have to have to be in a section, in which | 1415 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1416 | | */ | 1417 | 2 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1418 | 2 | (file_ptr) idd.PointerToRawData, | 1419 | 2 | idd.SizeOfData, cvinfo, NULL)) | 1420 | 0 | { | 1421 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1422 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1423 | 0 | if (build_id) | 1424 | 0 | { | 1425 | 0 | build_id->size = cvinfo->SignatureLength; | 1426 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1427 | 0 | cvinfo->SignatureLength); | 1428 | 0 | abfd->build_id = build_id; | 1429 | 0 | } | 1430 | 0 | } | 1431 | 2 | break; | 1432 | 2 | } | 1433 | 1.18k | } | 1434 | | | 1435 | 370 | free (data); | 1436 | 370 | } |
|
1437 | | |
1438 | | static bfd_cleanup |
1439 | | pe_bfd_object_p (bfd * abfd) |
1440 | 5.95M | { |
1441 | 5.95M | bfd_byte buffer[6]; |
1442 | 5.95M | struct external_DOS_hdr dos_hdr; |
1443 | 5.95M | struct external_PEI_IMAGE_hdr image_hdr; |
1444 | 5.95M | struct internal_filehdr internal_f; |
1445 | 5.95M | struct internal_aouthdr internal_a; |
1446 | 5.95M | bfd_size_type opt_hdr_size; |
1447 | 5.95M | file_ptr offset; |
1448 | 5.95M | bfd_cleanup result; |
1449 | | |
1450 | | /* Detect if this a Microsoft Import Library Format element. */ |
1451 | | /* First read the beginning of the header. */ |
1452 | 5.95M | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 |
1453 | 5.95M | || bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) |
1454 | 16.5k | { |
1455 | 16.5k | if (bfd_get_error () != bfd_error_system_call) |
1456 | 14.3k | bfd_set_error (bfd_error_wrong_format); |
1457 | 16.5k | return NULL; |
1458 | 16.5k | } |
1459 | | |
1460 | | /* Then check the magic and the version (only 0 is supported). */ |
1461 | 5.93M | if (H_GET_32 (abfd, buffer) == 0xffff0000 |
1462 | 5.93M | && H_GET_16 (abfd, buffer + 4) == 0) |
1463 | 76.9k | return pe_ILF_object_p (abfd); |
1464 | | |
1465 | 5.85M | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 |
1466 | 5.85M | || bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd) |
1467 | 5.85M | != sizeof (dos_hdr)) |
1468 | 1.17M | { |
1469 | 1.17M | if (bfd_get_error () != bfd_error_system_call) |
1470 | 1.17M | bfd_set_error (bfd_error_wrong_format); |
1471 | 1.17M | return NULL; |
1472 | 1.17M | } |
1473 | | |
1474 | | /* There are really two magic numbers involved; the magic number |
1475 | | that says this is a NT executable (PEI) and the magic number that |
1476 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in |
1477 | | the e_magic field. The latter is stored in the f_magic field. |
1478 | | If the NT magic number isn't valid, the architecture magic number |
1479 | | could be mimicked by some other field (specifically, the number |
1480 | | of relocs in section 3). Since this routine can only be called |
1481 | | correctly for a PEI file, check the e_magic number here, and, if |
1482 | | it doesn't match, clobber the f_magic number so that we don't get |
1483 | | a false match. */ |
1484 | 4.68M | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) |
1485 | 2.99M | { |
1486 | 2.99M | bfd_set_error (bfd_error_wrong_format); |
1487 | 2.99M | return NULL; |
1488 | 2.99M | } |
1489 | | |
1490 | 1.69M | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); |
1491 | 1.69M | if (bfd_seek (abfd, offset, SEEK_SET) != 0 |
1492 | 1.69M | || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd) |
1493 | 1.69M | != sizeof (image_hdr))) |
1494 | 20.8k | { |
1495 | 20.8k | if (bfd_get_error () != bfd_error_system_call) |
1496 | 20.8k | bfd_set_error (bfd_error_wrong_format); |
1497 | 20.8k | return NULL; |
1498 | 20.8k | } |
1499 | | |
1500 | 1.66M | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) |
1501 | 40.6k | { |
1502 | 40.6k | bfd_set_error (bfd_error_wrong_format); |
1503 | 40.6k | return NULL; |
1504 | 40.6k | } |
1505 | | |
1506 | | /* Swap file header, so that we get the location for calling |
1507 | | real_object_p. */ |
1508 | 1.62M | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); |
1509 | | |
1510 | 1.62M | if (! bfd_coff_bad_format_hook (abfd, &internal_f) |
1511 | 1.62M | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) |
1512 | 1.41M | { |
1513 | 1.41M | bfd_set_error (bfd_error_wrong_format); |
1514 | 1.41M | return NULL; |
1515 | 1.41M | } |
1516 | | |
1517 | 218k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, |
1518 | 218k | sizeof (internal_f.pe.dos_message)); |
1519 | | |
1520 | | /* Read the optional header, which has variable size. */ |
1521 | 218k | opt_hdr_size = internal_f.f_opthdr; |
1522 | | |
1523 | 218k | if (opt_hdr_size != 0) |
1524 | 165k | { |
1525 | 165k | bfd_size_type amt = opt_hdr_size; |
1526 | 165k | bfd_byte * opthdr; |
1527 | | |
1528 | | /* PR 17521 file: 230-131433-0.004. */ |
1529 | 165k | if (amt < sizeof (PEAOUTHDR)) |
1530 | 109k | amt = sizeof (PEAOUTHDR); |
1531 | | |
1532 | 165k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); |
1533 | 165k | if (opthdr == NULL) |
1534 | 4.33k | return NULL; |
1535 | 160k | if (amt > opt_hdr_size) |
1536 | 107k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); |
1537 | | |
1538 | 160k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); |
1539 | | |
1540 | 160k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; |
1541 | | |
1542 | | #ifdef ARM |
1543 | | /* Use Subsystem to distinguish between pei-arm-little and |
1544 | | pei-arm-wince-little. */ |
1545 | | #ifdef WINCE |
1546 | 22.6k | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) |
1547 | | #else |
1548 | 22.6k | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) |
1549 | 6.16k | #endif |
1550 | 22.6k | { |
1551 | 22.6k | bfd_set_error (bfd_error_wrong_format); |
1552 | 22.6k | return NULL; |
1553 | 22.6k | } |
1554 | 22.7k | #endif |
1555 | | |
1556 | 138k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment |
1557 | 138k | || a->SectionAlignment >= 0x80000000) |
1558 | 89.6k | { |
1559 | 89.6k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), |
1560 | 89.6k | abfd); |
1561 | 89.6k | a->SectionAlignment &= -a->SectionAlignment; |
1562 | 89.6k | if (a->SectionAlignment >= 0x80000000) |
1563 | 2.71k | a->SectionAlignment = 0x40000000; |
1564 | 89.6k | } |
1565 | | |
1566 | 138k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment |
1567 | 138k | || a->FileAlignment > a->SectionAlignment) |
1568 | 114k | { |
1569 | 114k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), |
1570 | 114k | abfd); |
1571 | 114k | a->FileAlignment &= -a->FileAlignment; |
1572 | 114k | if (a->FileAlignment > a->SectionAlignment) |
1573 | 54.3k | a->FileAlignment = a->SectionAlignment; |
1574 | 114k | } |
1575 | | |
1576 | 138k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) |
1577 | 98.4k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); |
1578 | 22.7k | } |
1579 | | |
1580 | 191k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, |
1581 | 191k | (opt_hdr_size != 0 |
1582 | 191k | ? &internal_a |
1583 | 191k | : (struct internal_aouthdr *) NULL)); |
1584 | | |
1585 | 191k | if (result) |
1586 | 96.9k | { |
1587 | | /* Now the whole header has been processed, see if there is a build-id */ |
1588 | 96.9k | pe_bfd_read_buildid(abfd); |
1589 | 96.9k | } |
1590 | | |
1591 | 191k | return result; |
1592 | 218k | } pei-i386.c:pe_bfd_object_p Line | Count | Source | 1440 | 527k | { | 1441 | 527k | bfd_byte buffer[6]; | 1442 | 527k | struct external_DOS_hdr dos_hdr; | 1443 | 527k | struct external_PEI_IMAGE_hdr image_hdr; | 1444 | 527k | struct internal_filehdr internal_f; | 1445 | 527k | struct internal_aouthdr internal_a; | 1446 | 527k | bfd_size_type opt_hdr_size; | 1447 | 527k | file_ptr offset; | 1448 | 527k | bfd_cleanup result; | 1449 | | | 1450 | | /* Detect if this a Microsoft Import Library Format element. */ | 1451 | | /* First read the beginning of the header. */ | 1452 | 527k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1453 | 527k | || bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) | 1454 | 1.50k | { | 1455 | 1.50k | if (bfd_get_error () != bfd_error_system_call) | 1456 | 1.30k | bfd_set_error (bfd_error_wrong_format); | 1457 | 1.50k | return NULL; | 1458 | 1.50k | } | 1459 | | | 1460 | | /* Then check the magic and the version (only 0 is supported). */ | 1461 | 526k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1462 | 526k | && H_GET_16 (abfd, buffer + 4) == 0) | 1463 | 9.99k | return pe_ILF_object_p (abfd); | 1464 | | | 1465 | 516k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1466 | 516k | || bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd) | 1467 | 516k | != sizeof (dos_hdr)) | 1468 | 104k | { | 1469 | 104k | if (bfd_get_error () != bfd_error_system_call) | 1470 | 104k | bfd_set_error (bfd_error_wrong_format); | 1471 | 104k | return NULL; | 1472 | 104k | } | 1473 | | | 1474 | | /* There are really two magic numbers involved; the magic number | 1475 | | that says this is a NT executable (PEI) and the magic number that | 1476 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1477 | | the e_magic field. The latter is stored in the f_magic field. | 1478 | | If the NT magic number isn't valid, the architecture magic number | 1479 | | could be mimicked by some other field (specifically, the number | 1480 | | of relocs in section 3). Since this routine can only be called | 1481 | | correctly for a PEI file, check the e_magic number here, and, if | 1482 | | it doesn't match, clobber the f_magic number so that we don't get | 1483 | | a false match. */ | 1484 | 411k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1485 | 220k | { | 1486 | 220k | bfd_set_error (bfd_error_wrong_format); | 1487 | 220k | return NULL; | 1488 | 220k | } | 1489 | | | 1490 | 191k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1491 | 191k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1492 | 191k | || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd) | 1493 | 191k | != sizeof (image_hdr))) | 1494 | 2.60k | { | 1495 | 2.60k | if (bfd_get_error () != bfd_error_system_call) | 1496 | 2.60k | bfd_set_error (bfd_error_wrong_format); | 1497 | 2.60k | return NULL; | 1498 | 2.60k | } | 1499 | | | 1500 | 188k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1501 | 5.08k | { | 1502 | 5.08k | bfd_set_error (bfd_error_wrong_format); | 1503 | 5.08k | return NULL; | 1504 | 5.08k | } | 1505 | | | 1506 | | /* Swap file header, so that we get the location for calling | 1507 | | real_object_p. */ | 1508 | 183k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1509 | | | 1510 | 183k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1511 | 183k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1512 | 163k | { | 1513 | 163k | bfd_set_error (bfd_error_wrong_format); | 1514 | 163k | return NULL; | 1515 | 163k | } | 1516 | | | 1517 | 19.8k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1518 | 19.8k | sizeof (internal_f.pe.dos_message)); | 1519 | | | 1520 | | /* Read the optional header, which has variable size. */ | 1521 | 19.8k | opt_hdr_size = internal_f.f_opthdr; | 1522 | | | 1523 | 19.8k | if (opt_hdr_size != 0) | 1524 | 16.8k | { | 1525 | 16.8k | bfd_size_type amt = opt_hdr_size; | 1526 | 16.8k | bfd_byte * opthdr; | 1527 | | | 1528 | | /* PR 17521 file: 230-131433-0.004. */ | 1529 | 16.8k | if (amt < sizeof (PEAOUTHDR)) | 1530 | 12.7k | amt = sizeof (PEAOUTHDR); | 1531 | | | 1532 | 16.8k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1533 | 16.8k | if (opthdr == NULL) | 1534 | 449 | return NULL; | 1535 | 16.3k | if (amt > opt_hdr_size) | 1536 | 12.3k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1537 | | | 1538 | 16.3k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1539 | | | 1540 | 16.3k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1541 | | | 1542 | | #ifdef ARM | 1543 | | /* Use Subsystem to distinguish between pei-arm-little and | 1544 | | pei-arm-wince-little. */ | 1545 | | #ifdef WINCE | 1546 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1547 | | #else | 1548 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1549 | | #endif | 1550 | | { | 1551 | | bfd_set_error (bfd_error_wrong_format); | 1552 | | return NULL; | 1553 | | } | 1554 | | #endif | 1555 | | | 1556 | 16.3k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1557 | 16.3k | || a->SectionAlignment >= 0x80000000) | 1558 | 13.4k | { | 1559 | 13.4k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1560 | 13.4k | abfd); | 1561 | 13.4k | a->SectionAlignment &= -a->SectionAlignment; | 1562 | 13.4k | if (a->SectionAlignment >= 0x80000000) | 1563 | 630 | a->SectionAlignment = 0x40000000; | 1564 | 13.4k | } | 1565 | | | 1566 | 16.3k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1567 | 16.3k | || a->FileAlignment > a->SectionAlignment) | 1568 | 13.2k | { | 1569 | 13.2k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1570 | 13.2k | abfd); | 1571 | 13.2k | a->FileAlignment &= -a->FileAlignment; | 1572 | 13.2k | if (a->FileAlignment > a->SectionAlignment) | 1573 | 4.84k | a->FileAlignment = a->SectionAlignment; | 1574 | 13.2k | } | 1575 | | | 1576 | 16.3k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1577 | 4.83k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1578 | 16.3k | } | 1579 | | | 1580 | 19.4k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1581 | 19.4k | (opt_hdr_size != 0 | 1582 | 19.4k | ? &internal_a | 1583 | 19.4k | : (struct internal_aouthdr *) NULL)); | 1584 | | | 1585 | 19.4k | if (result) | 1586 | 11.2k | { | 1587 | | /* Now the whole header has been processed, see if there is a build-id */ | 1588 | 11.2k | pe_bfd_read_buildid(abfd); | 1589 | 11.2k | } | 1590 | | | 1591 | 19.4k | return result; | 1592 | 19.8k | } |
pei-x86_64.c:pe_bfd_object_p Line | Count | Source | 1440 | 530k | { | 1441 | 530k | bfd_byte buffer[6]; | 1442 | 530k | struct external_DOS_hdr dos_hdr; | 1443 | 530k | struct external_PEI_IMAGE_hdr image_hdr; | 1444 | 530k | struct internal_filehdr internal_f; | 1445 | 530k | struct internal_aouthdr internal_a; | 1446 | 530k | bfd_size_type opt_hdr_size; | 1447 | 530k | file_ptr offset; | 1448 | 530k | bfd_cleanup result; | 1449 | | | 1450 | | /* Detect if this a Microsoft Import Library Format element. */ | 1451 | | /* First read the beginning of the header. */ | 1452 | 530k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1453 | 530k | || bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) | 1454 | 1.50k | { | 1455 | 1.50k | if (bfd_get_error () != bfd_error_system_call) | 1456 | 1.30k | bfd_set_error (bfd_error_wrong_format); | 1457 | 1.50k | return NULL; | 1458 | 1.50k | } | 1459 | | | 1460 | | /* Then check the magic and the version (only 0 is supported). */ | 1461 | 528k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1462 | 528k | && H_GET_16 (abfd, buffer + 4) == 0) | 1463 | 8.27k | return pe_ILF_object_p (abfd); | 1464 | | | 1465 | 520k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1466 | 520k | || bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd) | 1467 | 520k | != sizeof (dos_hdr)) | 1468 | 104k | { | 1469 | 104k | if (bfd_get_error () != bfd_error_system_call) | 1470 | 104k | bfd_set_error (bfd_error_wrong_format); | 1471 | 104k | return NULL; | 1472 | 104k | } | 1473 | | | 1474 | | /* There are really two magic numbers involved; the magic number | 1475 | | that says this is a NT executable (PEI) and the magic number that | 1476 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1477 | | the e_magic field. The latter is stored in the f_magic field. | 1478 | | If the NT magic number isn't valid, the architecture magic number | 1479 | | could be mimicked by some other field (specifically, the number | 1480 | | of relocs in section 3). Since this routine can only be called | 1481 | | correctly for a PEI file, check the e_magic number here, and, if | 1482 | | it doesn't match, clobber the f_magic number so that we don't get | 1483 | | a false match. */ | 1484 | 415k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1485 | 221k | { | 1486 | 221k | bfd_set_error (bfd_error_wrong_format); | 1487 | 221k | return NULL; | 1488 | 221k | } | 1489 | | | 1490 | 193k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1491 | 193k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1492 | 193k | || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd) | 1493 | 193k | != sizeof (image_hdr))) | 1494 | 2.60k | { | 1495 | 2.60k | if (bfd_get_error () != bfd_error_system_call) | 1496 | 2.60k | bfd_set_error (bfd_error_wrong_format); | 1497 | 2.60k | return NULL; | 1498 | 2.60k | } | 1499 | | | 1500 | 191k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1501 | 5.08k | { | 1502 | 5.08k | bfd_set_error (bfd_error_wrong_format); | 1503 | 5.08k | return NULL; | 1504 | 5.08k | } | 1505 | | | 1506 | | /* Swap file header, so that we get the location for calling | 1507 | | real_object_p. */ | 1508 | 186k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1509 | | | 1510 | 186k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1511 | 186k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1512 | 159k | { | 1513 | 159k | bfd_set_error (bfd_error_wrong_format); | 1514 | 159k | return NULL; | 1515 | 159k | } | 1516 | | | 1517 | 27.2k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1518 | 27.2k | sizeof (internal_f.pe.dos_message)); | 1519 | | | 1520 | | /* Read the optional header, which has variable size. */ | 1521 | 27.2k | opt_hdr_size = internal_f.f_opthdr; | 1522 | | | 1523 | 27.2k | if (opt_hdr_size != 0) | 1524 | 20.9k | { | 1525 | 20.9k | bfd_size_type amt = opt_hdr_size; | 1526 | 20.9k | bfd_byte * opthdr; | 1527 | | | 1528 | | /* PR 17521 file: 230-131433-0.004. */ | 1529 | 20.9k | if (amt < sizeof (PEAOUTHDR)) | 1530 | 19.6k | amt = sizeof (PEAOUTHDR); | 1531 | | | 1532 | 20.9k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1533 | 20.9k | if (opthdr == NULL) | 1534 | 449 | return NULL; | 1535 | 20.5k | if (amt > opt_hdr_size) | 1536 | 19.3k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1537 | | | 1538 | 20.5k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1539 | | | 1540 | 20.5k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1541 | | | 1542 | | #ifdef ARM | 1543 | | /* Use Subsystem to distinguish between pei-arm-little and | 1544 | | pei-arm-wince-little. */ | 1545 | | #ifdef WINCE | 1546 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1547 | | #else | 1548 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1549 | | #endif | 1550 | | { | 1551 | | bfd_set_error (bfd_error_wrong_format); | 1552 | | return NULL; | 1553 | | } | 1554 | | #endif | 1555 | | | 1556 | 20.5k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1557 | 20.5k | || a->SectionAlignment >= 0x80000000) | 1558 | 12.0k | { | 1559 | 12.0k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1560 | 12.0k | abfd); | 1561 | 12.0k | a->SectionAlignment &= -a->SectionAlignment; | 1562 | 12.0k | if (a->SectionAlignment >= 0x80000000) | 1563 | 104 | a->SectionAlignment = 0x40000000; | 1564 | 12.0k | } | 1565 | | | 1566 | 20.5k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1567 | 20.5k | || a->FileAlignment > a->SectionAlignment) | 1568 | 18.1k | { | 1569 | 18.1k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1570 | 18.1k | abfd); | 1571 | 18.1k | a->FileAlignment &= -a->FileAlignment; | 1572 | 18.1k | if (a->FileAlignment > a->SectionAlignment) | 1573 | 7.47k | a->FileAlignment = a->SectionAlignment; | 1574 | 18.1k | } | 1575 | | | 1576 | 20.5k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1577 | 15.2k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1578 | 20.5k | } | 1579 | | | 1580 | 26.8k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1581 | 26.8k | (opt_hdr_size != 0 | 1582 | 26.8k | ? &internal_a | 1583 | 26.8k | : (struct internal_aouthdr *) NULL)); | 1584 | | | 1585 | 26.8k | if (result) | 1586 | 18.0k | { | 1587 | | /* Now the whole header has been processed, see if there is a build-id */ | 1588 | 18.0k | pe_bfd_read_buildid(abfd); | 1589 | 18.0k | } | 1590 | | | 1591 | 26.8k | return result; | 1592 | 27.2k | } |
pei-aarch64.c:pe_bfd_object_p Line | Count | Source | 1440 | 523k | { | 1441 | 523k | bfd_byte buffer[6]; | 1442 | 523k | struct external_DOS_hdr dos_hdr; | 1443 | 523k | struct external_PEI_IMAGE_hdr image_hdr; | 1444 | 523k | struct internal_filehdr internal_f; | 1445 | 523k | struct internal_aouthdr internal_a; | 1446 | 523k | bfd_size_type opt_hdr_size; | 1447 | 523k | file_ptr offset; | 1448 | 523k | bfd_cleanup result; | 1449 | | | 1450 | | /* Detect if this a Microsoft Import Library Format element. */ | 1451 | | /* First read the beginning of the header. */ | 1452 | 523k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1453 | 523k | || bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) | 1454 | 1.50k | { | 1455 | 1.50k | if (bfd_get_error () != bfd_error_system_call) | 1456 | 1.30k | bfd_set_error (bfd_error_wrong_format); | 1457 | 1.50k | return NULL; | 1458 | 1.50k | } | 1459 | | | 1460 | | /* Then check the magic and the version (only 0 is supported). */ | 1461 | 522k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1462 | 522k | && H_GET_16 (abfd, buffer + 4) == 0) | 1463 | 12.5k | return pe_ILF_object_p (abfd); | 1464 | | | 1465 | 509k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1466 | 509k | || bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd) | 1467 | 509k | != sizeof (dos_hdr)) | 1468 | 104k | { | 1469 | 104k | if (bfd_get_error () != bfd_error_system_call) | 1470 | 104k | bfd_set_error (bfd_error_wrong_format); | 1471 | 104k | return NULL; | 1472 | 104k | } | 1473 | | | 1474 | | /* There are really two magic numbers involved; the magic number | 1475 | | that says this is a NT executable (PEI) and the magic number that | 1476 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1477 | | the e_magic field. The latter is stored in the f_magic field. | 1478 | | If the NT magic number isn't valid, the architecture magic number | 1479 | | could be mimicked by some other field (specifically, the number | 1480 | | of relocs in section 3). Since this routine can only be called | 1481 | | correctly for a PEI file, check the e_magic number here, and, if | 1482 | | it doesn't match, clobber the f_magic number so that we don't get | 1483 | | a false match. */ | 1484 | 405k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1485 | 217k | { | 1486 | 217k | bfd_set_error (bfd_error_wrong_format); | 1487 | 217k | return NULL; | 1488 | 217k | } | 1489 | | | 1490 | 187k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1491 | 187k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1492 | 187k | || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd) | 1493 | 187k | != sizeof (image_hdr))) | 1494 | 2.60k | { | 1495 | 2.60k | if (bfd_get_error () != bfd_error_system_call) | 1496 | 2.60k | bfd_set_error (bfd_error_wrong_format); | 1497 | 2.60k | return NULL; | 1498 | 2.60k | } | 1499 | | | 1500 | 184k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1501 | 5.08k | { | 1502 | 5.08k | bfd_set_error (bfd_error_wrong_format); | 1503 | 5.08k | return NULL; | 1504 | 5.08k | } | 1505 | | | 1506 | | /* Swap file header, so that we get the location for calling | 1507 | | real_object_p. */ | 1508 | 179k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1509 | | | 1510 | 179k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1511 | 179k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1512 | 156k | { | 1513 | 156k | bfd_set_error (bfd_error_wrong_format); | 1514 | 156k | return NULL; | 1515 | 156k | } | 1516 | | | 1517 | 23.0k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1518 | 23.0k | sizeof (internal_f.pe.dos_message)); | 1519 | | | 1520 | | /* Read the optional header, which has variable size. */ | 1521 | 23.0k | opt_hdr_size = internal_f.f_opthdr; | 1522 | | | 1523 | 23.0k | if (opt_hdr_size != 0) | 1524 | 20.3k | { | 1525 | 20.3k | bfd_size_type amt = opt_hdr_size; | 1526 | 20.3k | bfd_byte * opthdr; | 1527 | | | 1528 | | /* PR 17521 file: 230-131433-0.004. */ | 1529 | 20.3k | if (amt < sizeof (PEAOUTHDR)) | 1530 | 3.95k | amt = sizeof (PEAOUTHDR); | 1531 | | | 1532 | 20.3k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1533 | 20.3k | if (opthdr == NULL) | 1534 | 342 | return NULL; | 1535 | 20.0k | if (amt > opt_hdr_size) | 1536 | 3.95k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1537 | | | 1538 | 20.0k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1539 | | | 1540 | 20.0k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1541 | | | 1542 | | #ifdef ARM | 1543 | | /* Use Subsystem to distinguish between pei-arm-little and | 1544 | | pei-arm-wince-little. */ | 1545 | | #ifdef WINCE | 1546 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1547 | | #else | 1548 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1549 | | #endif | 1550 | | { | 1551 | | bfd_set_error (bfd_error_wrong_format); | 1552 | | return NULL; | 1553 | | } | 1554 | | #endif | 1555 | | | 1556 | 20.0k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1557 | 20.0k | || a->SectionAlignment >= 0x80000000) | 1558 | 13.4k | { | 1559 | 13.4k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1560 | 13.4k | abfd); | 1561 | 13.4k | a->SectionAlignment &= -a->SectionAlignment; | 1562 | 13.4k | if (a->SectionAlignment >= 0x80000000) | 1563 | 575 | a->SectionAlignment = 0x40000000; | 1564 | 13.4k | } | 1565 | | | 1566 | 20.0k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1567 | 20.0k | || a->FileAlignment > a->SectionAlignment) | 1568 | 17.2k | { | 1569 | 17.2k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1570 | 17.2k | abfd); | 1571 | 17.2k | a->FileAlignment &= -a->FileAlignment; | 1572 | 17.2k | if (a->FileAlignment > a->SectionAlignment) | 1573 | 8.43k | a->FileAlignment = a->SectionAlignment; | 1574 | 17.2k | } | 1575 | | | 1576 | 20.0k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1577 | 16.7k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1578 | 20.0k | } | 1579 | | | 1580 | 22.7k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1581 | 22.7k | (opt_hdr_size != 0 | 1582 | 22.7k | ? &internal_a | 1583 | 22.7k | : (struct internal_aouthdr *) NULL)); | 1584 | | | 1585 | 22.7k | if (result) | 1586 | 10.5k | { | 1587 | | /* Now the whole header has been processed, see if there is a build-id */ | 1588 | 10.5k | pe_bfd_read_buildid(abfd); | 1589 | 10.5k | } | 1590 | | | 1591 | 22.7k | return result; | 1592 | 23.0k | } |
pei-ia64.c:pe_bfd_object_p Line | Count | Source | 1440 | 179k | { | 1441 | 179k | bfd_byte buffer[6]; | 1442 | 179k | struct external_DOS_hdr dos_hdr; | 1443 | 179k | struct external_PEI_IMAGE_hdr image_hdr; | 1444 | 179k | struct internal_filehdr internal_f; | 1445 | 179k | struct internal_aouthdr internal_a; | 1446 | 179k | bfd_size_type opt_hdr_size; | 1447 | 179k | file_ptr offset; | 1448 | 179k | bfd_cleanup result; | 1449 | | | 1450 | | /* Detect if this a Microsoft Import Library Format element. */ | 1451 | | /* First read the beginning of the header. */ | 1452 | 179k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1453 | 179k | || bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) | 1454 | 0 | { | 1455 | 0 | if (bfd_get_error () != bfd_error_system_call) | 1456 | 0 | bfd_set_error (bfd_error_wrong_format); | 1457 | 0 | return NULL; | 1458 | 0 | } | 1459 | | | 1460 | | /* Then check the magic and the version (only 0 is supported). */ | 1461 | 179k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1462 | 179k | && H_GET_16 (abfd, buffer + 4) == 0) | 1463 | 0 | return pe_ILF_object_p (abfd); | 1464 | | | 1465 | 179k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1466 | 179k | || bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd) | 1467 | 179k | != sizeof (dos_hdr)) | 1468 | 0 | { | 1469 | 0 | if (bfd_get_error () != bfd_error_system_call) | 1470 | 0 | bfd_set_error (bfd_error_wrong_format); | 1471 | 0 | return NULL; | 1472 | 0 | } | 1473 | | | 1474 | | /* There are really two magic numbers involved; the magic number | 1475 | | that says this is a NT executable (PEI) and the magic number that | 1476 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1477 | | the e_magic field. The latter is stored in the f_magic field. | 1478 | | If the NT magic number isn't valid, the architecture magic number | 1479 | | could be mimicked by some other field (specifically, the number | 1480 | | of relocs in section 3). Since this routine can only be called | 1481 | | correctly for a PEI file, check the e_magic number here, and, if | 1482 | | it doesn't match, clobber the f_magic number so that we don't get | 1483 | | a false match. */ | 1484 | 179k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1485 | 0 | { | 1486 | 0 | bfd_set_error (bfd_error_wrong_format); | 1487 | 0 | return NULL; | 1488 | 0 | } | 1489 | | | 1490 | 179k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1491 | 179k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1492 | 179k | || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd) | 1493 | 179k | != sizeof (image_hdr))) | 1494 | 0 | { | 1495 | 0 | if (bfd_get_error () != bfd_error_system_call) | 1496 | 0 | bfd_set_error (bfd_error_wrong_format); | 1497 | 0 | return NULL; | 1498 | 0 | } | 1499 | | | 1500 | 179k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1501 | 0 | { | 1502 | 0 | bfd_set_error (bfd_error_wrong_format); | 1503 | 0 | return NULL; | 1504 | 0 | } | 1505 | | | 1506 | | /* Swap file header, so that we get the location for calling | 1507 | | real_object_p. */ | 1508 | 179k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1509 | | | 1510 | 179k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1511 | 179k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1512 | 156k | { | 1513 | 156k | bfd_set_error (bfd_error_wrong_format); | 1514 | 156k | return NULL; | 1515 | 156k | } | 1516 | | | 1517 | 23.1k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1518 | 23.1k | sizeof (internal_f.pe.dos_message)); | 1519 | | | 1520 | | /* Read the optional header, which has variable size. */ | 1521 | 23.1k | opt_hdr_size = internal_f.f_opthdr; | 1522 | | | 1523 | 23.1k | if (opt_hdr_size != 0) | 1524 | 15.7k | { | 1525 | 15.7k | bfd_size_type amt = opt_hdr_size; | 1526 | 15.7k | bfd_byte * opthdr; | 1527 | | | 1528 | | /* PR 17521 file: 230-131433-0.004. */ | 1529 | 15.7k | if (amt < sizeof (PEAOUTHDR)) | 1530 | 6.90k | amt = sizeof (PEAOUTHDR); | 1531 | | | 1532 | 15.7k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1533 | 15.7k | if (opthdr == NULL) | 1534 | 576 | return NULL; | 1535 | 15.1k | if (amt > opt_hdr_size) | 1536 | 6.67k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1537 | | | 1538 | 15.1k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1539 | | | 1540 | 15.1k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1541 | | | 1542 | | #ifdef ARM | 1543 | | /* Use Subsystem to distinguish between pei-arm-little and | 1544 | | pei-arm-wince-little. */ | 1545 | | #ifdef WINCE | 1546 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1547 | | #else | 1548 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1549 | | #endif | 1550 | | { | 1551 | | bfd_set_error (bfd_error_wrong_format); | 1552 | | return NULL; | 1553 | | } | 1554 | | #endif | 1555 | | | 1556 | 15.1k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1557 | 15.1k | || a->SectionAlignment >= 0x80000000) | 1558 | 9.12k | { | 1559 | 9.12k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1560 | 9.12k | abfd); | 1561 | 9.12k | a->SectionAlignment &= -a->SectionAlignment; | 1562 | 9.12k | if (a->SectionAlignment >= 0x80000000) | 1563 | 236 | a->SectionAlignment = 0x40000000; | 1564 | 9.12k | } | 1565 | | | 1566 | 15.1k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1567 | 15.1k | || a->FileAlignment > a->SectionAlignment) | 1568 | 13.4k | { | 1569 | 13.4k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1570 | 13.4k | abfd); | 1571 | 13.4k | a->FileAlignment &= -a->FileAlignment; | 1572 | 13.4k | if (a->FileAlignment > a->SectionAlignment) | 1573 | 5.53k | a->FileAlignment = a->SectionAlignment; | 1574 | 13.4k | } | 1575 | | | 1576 | 15.1k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1577 | 11.5k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1578 | 15.1k | } | 1579 | | | 1580 | 22.5k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1581 | 22.5k | (opt_hdr_size != 0 | 1582 | 22.5k | ? &internal_a | 1583 | 22.5k | : (struct internal_aouthdr *) NULL)); | 1584 | | | 1585 | 22.5k | if (result) | 1586 | 9.29k | { | 1587 | | /* Now the whole header has been processed, see if there is a build-id */ | 1588 | 9.29k | pe_bfd_read_buildid(abfd); | 1589 | 9.29k | } | 1590 | | | 1591 | 22.5k | return result; | 1592 | 23.1k | } |
pei-loongarch64.c:pe_bfd_object_p Line | Count | Source | 1440 | 523k | { | 1441 | 523k | bfd_byte buffer[6]; | 1442 | 523k | struct external_DOS_hdr dos_hdr; | 1443 | 523k | struct external_PEI_IMAGE_hdr image_hdr; | 1444 | 523k | struct internal_filehdr internal_f; | 1445 | 523k | struct internal_aouthdr internal_a; | 1446 | 523k | bfd_size_type opt_hdr_size; | 1447 | 523k | file_ptr offset; | 1448 | 523k | bfd_cleanup result; | 1449 | | | 1450 | | /* Detect if this a Microsoft Import Library Format element. */ | 1451 | | /* First read the beginning of the header. */ | 1452 | 523k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1453 | 523k | || bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) | 1454 | 1.50k | { | 1455 | 1.50k | if (bfd_get_error () != bfd_error_system_call) | 1456 | 1.30k | bfd_set_error (bfd_error_wrong_format); | 1457 | 1.50k | return NULL; | 1458 | 1.50k | } | 1459 | | | 1460 | | /* Then check the magic and the version (only 0 is supported). */ | 1461 | 522k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1462 | 522k | && H_GET_16 (abfd, buffer + 4) == 0) | 1463 | 7.02k | return pe_ILF_object_p (abfd); | 1464 | | | 1465 | 515k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1466 | 515k | || bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd) | 1467 | 515k | != sizeof (dos_hdr)) | 1468 | 105k | { | 1469 | 105k | if (bfd_get_error () != bfd_error_system_call) | 1470 | 105k | bfd_set_error (bfd_error_wrong_format); | 1471 | 105k | return NULL; | 1472 | 105k | } | 1473 | | | 1474 | | /* There are really two magic numbers involved; the magic number | 1475 | | that says this is a NT executable (PEI) and the magic number that | 1476 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1477 | | the e_magic field. The latter is stored in the f_magic field. | 1478 | | If the NT magic number isn't valid, the architecture magic number | 1479 | | could be mimicked by some other field (specifically, the number | 1480 | | of relocs in section 3). Since this routine can only be called | 1481 | | correctly for a PEI file, check the e_magic number here, and, if | 1482 | | it doesn't match, clobber the f_magic number so that we don't get | 1483 | | a false match. */ | 1484 | 410k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1485 | 222k | { | 1486 | 222k | bfd_set_error (bfd_error_wrong_format); | 1487 | 222k | return NULL; | 1488 | 222k | } | 1489 | | | 1490 | 187k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1491 | 187k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1492 | 187k | || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd) | 1493 | 187k | != sizeof (image_hdr))) | 1494 | 2.60k | { | 1495 | 2.60k | if (bfd_get_error () != bfd_error_system_call) | 1496 | 2.60k | bfd_set_error (bfd_error_wrong_format); | 1497 | 2.60k | return NULL; | 1498 | 2.60k | } | 1499 | | | 1500 | 184k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1501 | 5.08k | { | 1502 | 5.08k | bfd_set_error (bfd_error_wrong_format); | 1503 | 5.08k | return NULL; | 1504 | 5.08k | } | 1505 | | | 1506 | | /* Swap file header, so that we get the location for calling | 1507 | | real_object_p. */ | 1508 | 179k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1509 | | | 1510 | 179k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1511 | 179k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1512 | 161k | { | 1513 | 161k | bfd_set_error (bfd_error_wrong_format); | 1514 | 161k | return NULL; | 1515 | 161k | } | 1516 | | | 1517 | 18.4k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1518 | 18.4k | sizeof (internal_f.pe.dos_message)); | 1519 | | | 1520 | | /* Read the optional header, which has variable size. */ | 1521 | 18.4k | opt_hdr_size = internal_f.f_opthdr; | 1522 | | | 1523 | 18.4k | if (opt_hdr_size != 0) | 1524 | 14.1k | { | 1525 | 14.1k | bfd_size_type amt = opt_hdr_size; | 1526 | 14.1k | bfd_byte * opthdr; | 1527 | | | 1528 | | /* PR 17521 file: 230-131433-0.004. */ | 1529 | 14.1k | if (amt < sizeof (PEAOUTHDR)) | 1530 | 7.61k | amt = sizeof (PEAOUTHDR); | 1531 | | | 1532 | 14.1k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1533 | 14.1k | if (opthdr == NULL) | 1534 | 817 | return NULL; | 1535 | 13.3k | if (amt > opt_hdr_size) | 1536 | 7.37k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1537 | | | 1538 | 13.3k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1539 | | | 1540 | 13.3k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1541 | | | 1542 | | #ifdef ARM | 1543 | | /* Use Subsystem to distinguish between pei-arm-little and | 1544 | | pei-arm-wince-little. */ | 1545 | | #ifdef WINCE | 1546 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1547 | | #else | 1548 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1549 | | #endif | 1550 | | { | 1551 | | bfd_set_error (bfd_error_wrong_format); | 1552 | | return NULL; | 1553 | | } | 1554 | | #endif | 1555 | | | 1556 | 13.3k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1557 | 13.3k | || a->SectionAlignment >= 0x80000000) | 1558 | 12.0k | { | 1559 | 12.0k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1560 | 12.0k | abfd); | 1561 | 12.0k | a->SectionAlignment &= -a->SectionAlignment; | 1562 | 12.0k | if (a->SectionAlignment >= 0x80000000) | 1563 | 479 | a->SectionAlignment = 0x40000000; | 1564 | 12.0k | } | 1565 | | | 1566 | 13.3k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1567 | 13.3k | || a->FileAlignment > a->SectionAlignment) | 1568 | 12.0k | { | 1569 | 12.0k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1570 | 12.0k | abfd); | 1571 | 12.0k | a->FileAlignment &= -a->FileAlignment; | 1572 | 12.0k | if (a->FileAlignment > a->SectionAlignment) | 1573 | 4.52k | a->FileAlignment = a->SectionAlignment; | 1574 | 12.0k | } | 1575 | | | 1576 | 13.3k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1577 | 11.5k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1578 | 13.3k | } | 1579 | | | 1580 | 17.6k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1581 | 17.6k | (opt_hdr_size != 0 | 1582 | 17.6k | ? &internal_a | 1583 | 17.6k | : (struct internal_aouthdr *) NULL)); | 1584 | | | 1585 | 17.6k | if (result) | 1586 | 8.09k | { | 1587 | | /* Now the whole header has been processed, see if there is a build-id */ | 1588 | 8.09k | pe_bfd_read_buildid(abfd); | 1589 | 8.09k | } | 1590 | | | 1591 | 17.6k | return result; | 1592 | 18.4k | } |
pei-arm-wince.c:pe_bfd_object_p Line | Count | Source | 1440 | 1.04M | { | 1441 | 1.04M | bfd_byte buffer[6]; | 1442 | 1.04M | struct external_DOS_hdr dos_hdr; | 1443 | 1.04M | struct external_PEI_IMAGE_hdr image_hdr; | 1444 | 1.04M | struct internal_filehdr internal_f; | 1445 | 1.04M | struct internal_aouthdr internal_a; | 1446 | 1.04M | bfd_size_type opt_hdr_size; | 1447 | 1.04M | file_ptr offset; | 1448 | 1.04M | bfd_cleanup result; | 1449 | | | 1450 | | /* Detect if this a Microsoft Import Library Format element. */ | 1451 | | /* First read the beginning of the header. */ | 1452 | 1.04M | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1453 | 1.04M | || bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) | 1454 | 3.01k | { | 1455 | 3.01k | if (bfd_get_error () != bfd_error_system_call) | 1456 | 2.60k | bfd_set_error (bfd_error_wrong_format); | 1457 | 3.01k | return NULL; | 1458 | 3.01k | } | 1459 | | | 1460 | | /* Then check the magic and the version (only 0 is supported). */ | 1461 | 1.04M | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1462 | 1.04M | && H_GET_16 (abfd, buffer + 4) == 0) | 1463 | 9.98k | return pe_ILF_object_p (abfd); | 1464 | | | 1465 | 1.03M | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1466 | 1.03M | || bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd) | 1467 | 1.03M | != sizeof (dos_hdr)) | 1468 | 216k | { | 1469 | 216k | if (bfd_get_error () != bfd_error_system_call) | 1470 | 216k | bfd_set_error (bfd_error_wrong_format); | 1471 | 216k | return NULL; | 1472 | 216k | } | 1473 | | | 1474 | | /* There are really two magic numbers involved; the magic number | 1475 | | that says this is a NT executable (PEI) and the magic number that | 1476 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1477 | | the e_magic field. The latter is stored in the f_magic field. | 1478 | | If the NT magic number isn't valid, the architecture magic number | 1479 | | could be mimicked by some other field (specifically, the number | 1480 | | of relocs in section 3). Since this routine can only be called | 1481 | | correctly for a PEI file, check the e_magic number here, and, if | 1482 | | it doesn't match, clobber the f_magic number so that we don't get | 1483 | | a false match. */ | 1484 | 817k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1485 | 630k | { | 1486 | 630k | bfd_set_error (bfd_error_wrong_format); | 1487 | 630k | return NULL; | 1488 | 630k | } | 1489 | | | 1490 | 187k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1491 | 187k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1492 | 187k | || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd) | 1493 | 187k | != sizeof (image_hdr))) | 1494 | 2.60k | { | 1495 | 2.60k | if (bfd_get_error () != bfd_error_system_call) | 1496 | 2.60k | bfd_set_error (bfd_error_wrong_format); | 1497 | 2.60k | return NULL; | 1498 | 2.60k | } | 1499 | | | 1500 | 184k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1501 | 5.08k | { | 1502 | 5.08k | bfd_set_error (bfd_error_wrong_format); | 1503 | 5.08k | return NULL; | 1504 | 5.08k | } | 1505 | | | 1506 | | /* Swap file header, so that we get the location for calling | 1507 | | real_object_p. */ | 1508 | 179k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1509 | | | 1510 | 179k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1511 | 179k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1512 | 147k | { | 1513 | 147k | bfd_set_error (bfd_error_wrong_format); | 1514 | 147k | return NULL; | 1515 | 147k | } | 1516 | | | 1517 | 32.1k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1518 | 32.1k | sizeof (internal_f.pe.dos_message)); | 1519 | | | 1520 | | /* Read the optional header, which has variable size. */ | 1521 | 32.1k | opt_hdr_size = internal_f.f_opthdr; | 1522 | | | 1523 | 32.1k | if (opt_hdr_size != 0) | 1524 | 22.9k | { | 1525 | 22.9k | bfd_size_type amt = opt_hdr_size; | 1526 | 22.9k | bfd_byte * opthdr; | 1527 | | | 1528 | | /* PR 17521 file: 230-131433-0.004. */ | 1529 | 22.9k | if (amt < sizeof (PEAOUTHDR)) | 1530 | 17.0k | amt = sizeof (PEAOUTHDR); | 1531 | | | 1532 | 22.9k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1533 | 22.9k | if (opthdr == NULL) | 1534 | 343 | return NULL; | 1535 | 22.6k | if (amt > opt_hdr_size) | 1536 | 17.0k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1537 | | | 1538 | 22.6k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1539 | | | 1540 | 22.6k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1541 | | | 1542 | 22.6k | #ifdef ARM | 1543 | | /* Use Subsystem to distinguish between pei-arm-little and | 1544 | | pei-arm-wince-little. */ | 1545 | 22.6k | #ifdef WINCE | 1546 | 22.6k | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1547 | | #else | 1548 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1549 | | #endif | 1550 | 16.4k | { | 1551 | 16.4k | bfd_set_error (bfd_error_wrong_format); | 1552 | 16.4k | return NULL; | 1553 | 16.4k | } | 1554 | 6.18k | #endif | 1555 | | | 1556 | 6.18k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1557 | 6.18k | || a->SectionAlignment >= 0x80000000) | 1558 | 3.20k | { | 1559 | 3.20k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1560 | 3.20k | abfd); | 1561 | 3.20k | a->SectionAlignment &= -a->SectionAlignment; | 1562 | 3.20k | if (a->SectionAlignment >= 0x80000000) | 1563 | 239 | a->SectionAlignment = 0x40000000; | 1564 | 3.20k | } | 1565 | | | 1566 | 6.18k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1567 | 6.18k | || a->FileAlignment > a->SectionAlignment) | 1568 | 3.61k | { | 1569 | 3.61k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1570 | 3.61k | abfd); | 1571 | 3.61k | a->FileAlignment &= -a->FileAlignment; | 1572 | 3.61k | if (a->FileAlignment > a->SectionAlignment) | 1573 | 3.36k | a->FileAlignment = a->SectionAlignment; | 1574 | 3.61k | } | 1575 | | | 1576 | 6.18k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1577 | 5.37k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1578 | 6.18k | } | 1579 | | | 1580 | 15.3k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1581 | 15.3k | (opt_hdr_size != 0 | 1582 | 15.3k | ? &internal_a | 1583 | 15.3k | : (struct internal_aouthdr *) NULL)); | 1584 | | | 1585 | 15.3k | if (result) | 1586 | 5.02k | { | 1587 | | /* Now the whole header has been processed, see if there is a build-id */ | 1588 | 5.02k | pe_bfd_read_buildid(abfd); | 1589 | 5.02k | } | 1590 | | | 1591 | 15.3k | return result; | 1592 | 32.1k | } |
pei-arm.c:pe_bfd_object_p Line | Count | Source | 1440 | 1.04M | { | 1441 | 1.04M | bfd_byte buffer[6]; | 1442 | 1.04M | struct external_DOS_hdr dos_hdr; | 1443 | 1.04M | struct external_PEI_IMAGE_hdr image_hdr; | 1444 | 1.04M | struct internal_filehdr internal_f; | 1445 | 1.04M | struct internal_aouthdr internal_a; | 1446 | 1.04M | bfd_size_type opt_hdr_size; | 1447 | 1.04M | file_ptr offset; | 1448 | 1.04M | bfd_cleanup result; | 1449 | | | 1450 | | /* Detect if this a Microsoft Import Library Format element. */ | 1451 | | /* First read the beginning of the header. */ | 1452 | 1.04M | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1453 | 1.04M | || bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) | 1454 | 3.01k | { | 1455 | 3.01k | if (bfd_get_error () != bfd_error_system_call) | 1456 | 2.60k | bfd_set_error (bfd_error_wrong_format); | 1457 | 3.01k | return NULL; | 1458 | 3.01k | } | 1459 | | | 1460 | | /* Then check the magic and the version (only 0 is supported). */ | 1461 | 1.04M | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1462 | 1.04M | && H_GET_16 (abfd, buffer + 4) == 0) | 1463 | 11.6k | return pe_ILF_object_p (abfd); | 1464 | | | 1465 | 1.03M | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1466 | 1.03M | || bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd) | 1467 | 1.03M | != sizeof (dos_hdr)) | 1468 | 218k | { | 1469 | 218k | if (bfd_get_error () != bfd_error_system_call) | 1470 | 218k | bfd_set_error (bfd_error_wrong_format); | 1471 | 218k | return NULL; | 1472 | 218k | } | 1473 | | | 1474 | | /* There are really two magic numbers involved; the magic number | 1475 | | that says this is a NT executable (PEI) and the magic number that | 1476 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1477 | | the e_magic field. The latter is stored in the f_magic field. | 1478 | | If the NT magic number isn't valid, the architecture magic number | 1479 | | could be mimicked by some other field (specifically, the number | 1480 | | of relocs in section 3). Since this routine can only be called | 1481 | | correctly for a PEI file, check the e_magic number here, and, if | 1482 | | it doesn't match, clobber the f_magic number so that we don't get | 1483 | | a false match. */ | 1484 | 814k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1485 | 627k | { | 1486 | 627k | bfd_set_error (bfd_error_wrong_format); | 1487 | 627k | return NULL; | 1488 | 627k | } | 1489 | | | 1490 | 187k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1491 | 187k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1492 | 187k | || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd) | 1493 | 187k | != sizeof (image_hdr))) | 1494 | 2.60k | { | 1495 | 2.60k | if (bfd_get_error () != bfd_error_system_call) | 1496 | 2.60k | bfd_set_error (bfd_error_wrong_format); | 1497 | 2.60k | return NULL; | 1498 | 2.60k | } | 1499 | | | 1500 | 184k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1501 | 5.08k | { | 1502 | 5.08k | bfd_set_error (bfd_error_wrong_format); | 1503 | 5.08k | return NULL; | 1504 | 5.08k | } | 1505 | | | 1506 | | /* Swap file header, so that we get the location for calling | 1507 | | real_object_p. */ | 1508 | 179k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1509 | | | 1510 | 179k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1511 | 179k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1512 | 147k | { | 1513 | 147k | bfd_set_error (bfd_error_wrong_format); | 1514 | 147k | return NULL; | 1515 | 147k | } | 1516 | | | 1517 | 32.2k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1518 | 32.2k | sizeof (internal_f.pe.dos_message)); | 1519 | | | 1520 | | /* Read the optional header, which has variable size. */ | 1521 | 32.2k | opt_hdr_size = internal_f.f_opthdr; | 1522 | | | 1523 | 32.2k | if (opt_hdr_size != 0) | 1524 | 23.0k | { | 1525 | 23.0k | bfd_size_type amt = opt_hdr_size; | 1526 | 23.0k | bfd_byte * opthdr; | 1527 | | | 1528 | | /* PR 17521 file: 230-131433-0.004. */ | 1529 | 23.0k | if (amt < sizeof (PEAOUTHDR)) | 1530 | 17.0k | amt = sizeof (PEAOUTHDR); | 1531 | | | 1532 | 23.0k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1533 | 23.0k | if (opthdr == NULL) | 1534 | 343 | return NULL; | 1535 | 22.6k | if (amt > opt_hdr_size) | 1536 | 17.0k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1537 | | | 1538 | 22.6k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1539 | | | 1540 | 22.6k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1541 | | | 1542 | 22.6k | #ifdef ARM | 1543 | | /* Use Subsystem to distinguish between pei-arm-little and | 1544 | | pei-arm-wince-little. */ | 1545 | | #ifdef WINCE | 1546 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1547 | | #else | 1548 | 22.6k | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1549 | 6.16k | #endif | 1550 | 6.16k | { | 1551 | 6.16k | bfd_set_error (bfd_error_wrong_format); | 1552 | 6.16k | return NULL; | 1553 | 6.16k | } | 1554 | 16.5k | #endif | 1555 | | | 1556 | 16.5k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1557 | 16.5k | || a->SectionAlignment >= 0x80000000) | 1558 | 9.79k | { | 1559 | 9.79k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1560 | 9.79k | abfd); | 1561 | 9.79k | a->SectionAlignment &= -a->SectionAlignment; | 1562 | 9.79k | if (a->SectionAlignment >= 0x80000000) | 1563 | 341 | a->SectionAlignment = 0x40000000; | 1564 | 9.79k | } | 1565 | | | 1566 | 16.5k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1567 | 16.5k | || a->FileAlignment > a->SectionAlignment) | 1568 | 13.0k | { | 1569 | 13.0k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1570 | 13.0k | abfd); | 1571 | 13.0k | a->FileAlignment &= -a->FileAlignment; | 1572 | 13.0k | if (a->FileAlignment > a->SectionAlignment) | 1573 | 6.96k | a->FileAlignment = a->SectionAlignment; | 1574 | 13.0k | } | 1575 | | | 1576 | 16.5k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1577 | 10.9k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1578 | 16.5k | } | 1579 | | | 1580 | 25.7k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1581 | 25.7k | (opt_hdr_size != 0 | 1582 | 25.7k | ? &internal_a | 1583 | 25.7k | : (struct internal_aouthdr *) NULL)); | 1584 | | | 1585 | 25.7k | if (result) | 1586 | 11.2k | { | 1587 | | /* Now the whole header has been processed, see if there is a build-id */ | 1588 | 11.2k | pe_bfd_read_buildid(abfd); | 1589 | 11.2k | } | 1590 | | | 1591 | 25.7k | return result; | 1592 | 32.2k | } |
pei-mcore.c:pe_bfd_object_p Line | Count | Source | 1440 | 1.04M | { | 1441 | 1.04M | bfd_byte buffer[6]; | 1442 | 1.04M | struct external_DOS_hdr dos_hdr; | 1443 | 1.04M | struct external_PEI_IMAGE_hdr image_hdr; | 1444 | 1.04M | struct internal_filehdr internal_f; | 1445 | 1.04M | struct internal_aouthdr internal_a; | 1446 | 1.04M | bfd_size_type opt_hdr_size; | 1447 | 1.04M | file_ptr offset; | 1448 | 1.04M | bfd_cleanup result; | 1449 | | | 1450 | | /* Detect if this a Microsoft Import Library Format element. */ | 1451 | | /* First read the beginning of the header. */ | 1452 | 1.04M | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1453 | 1.04M | || bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) | 1454 | 3.01k | { | 1455 | 3.01k | if (bfd_get_error () != bfd_error_system_call) | 1456 | 2.60k | bfd_set_error (bfd_error_wrong_format); | 1457 | 3.01k | return NULL; | 1458 | 3.01k | } | 1459 | | | 1460 | | /* Then check the magic and the version (only 0 is supported). */ | 1461 | 1.04M | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1462 | 1.04M | && H_GET_16 (abfd, buffer + 4) == 0) | 1463 | 8.75k | return pe_ILF_object_p (abfd); | 1464 | | | 1465 | 1.03M | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1466 | 1.03M | || bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd) | 1467 | 1.03M | != sizeof (dos_hdr)) | 1468 | 216k | { | 1469 | 216k | if (bfd_get_error () != bfd_error_system_call) | 1470 | 216k | bfd_set_error (bfd_error_wrong_format); | 1471 | 216k | return NULL; | 1472 | 216k | } | 1473 | | | 1474 | | /* There are really two magic numbers involved; the magic number | 1475 | | that says this is a NT executable (PEI) and the magic number that | 1476 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1477 | | the e_magic field. The latter is stored in the f_magic field. | 1478 | | If the NT magic number isn't valid, the architecture magic number | 1479 | | could be mimicked by some other field (specifically, the number | 1480 | | of relocs in section 3). Since this routine can only be called | 1481 | | correctly for a PEI file, check the e_magic number here, and, if | 1482 | | it doesn't match, clobber the f_magic number so that we don't get | 1483 | | a false match. */ | 1484 | 819k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1485 | 632k | { | 1486 | 632k | bfd_set_error (bfd_error_wrong_format); | 1487 | 632k | return NULL; | 1488 | 632k | } | 1489 | | | 1490 | 187k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1491 | 187k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1492 | 187k | || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd) | 1493 | 187k | != sizeof (image_hdr))) | 1494 | 2.60k | { | 1495 | 2.60k | if (bfd_get_error () != bfd_error_system_call) | 1496 | 2.60k | bfd_set_error (bfd_error_wrong_format); | 1497 | 2.60k | return NULL; | 1498 | 2.60k | } | 1499 | | | 1500 | 184k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1501 | 5.08k | { | 1502 | 5.08k | bfd_set_error (bfd_error_wrong_format); | 1503 | 5.08k | return NULL; | 1504 | 5.08k | } | 1505 | | | 1506 | | /* Swap file header, so that we get the location for calling | 1507 | | real_object_p. */ | 1508 | 179k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1509 | | | 1510 | 179k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1511 | 179k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1512 | 153k | { | 1513 | 153k | bfd_set_error (bfd_error_wrong_format); | 1514 | 153k | return NULL; | 1515 | 153k | } | 1516 | | | 1517 | 26.5k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1518 | 26.5k | sizeof (internal_f.pe.dos_message)); | 1519 | | | 1520 | | /* Read the optional header, which has variable size. */ | 1521 | 26.5k | opt_hdr_size = internal_f.f_opthdr; | 1522 | | | 1523 | 26.5k | if (opt_hdr_size != 0) | 1524 | 20.0k | { | 1525 | 20.0k | bfd_size_type amt = opt_hdr_size; | 1526 | 20.0k | bfd_byte * opthdr; | 1527 | | | 1528 | | /* PR 17521 file: 230-131433-0.004. */ | 1529 | 20.0k | if (amt < sizeof (PEAOUTHDR)) | 1530 | 14.2k | amt = sizeof (PEAOUTHDR); | 1531 | | | 1532 | 20.0k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1533 | 20.0k | if (opthdr == NULL) | 1534 | 445 | return NULL; | 1535 | 19.6k | if (amt > opt_hdr_size) | 1536 | 14.1k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1537 | | | 1538 | 19.6k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1539 | | | 1540 | 19.6k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1541 | | | 1542 | | #ifdef ARM | 1543 | | /* Use Subsystem to distinguish between pei-arm-little and | 1544 | | pei-arm-wince-little. */ | 1545 | | #ifdef WINCE | 1546 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1547 | | #else | 1548 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1549 | | #endif | 1550 | | { | 1551 | | bfd_set_error (bfd_error_wrong_format); | 1552 | | return NULL; | 1553 | | } | 1554 | | #endif | 1555 | | | 1556 | 19.6k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1557 | 19.6k | || a->SectionAlignment >= 0x80000000) | 1558 | 7.84k | { | 1559 | 7.84k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1560 | 7.84k | abfd); | 1561 | 7.84k | a->SectionAlignment &= -a->SectionAlignment; | 1562 | 7.84k | if (a->SectionAlignment >= 0x80000000) | 1563 | 3 | a->SectionAlignment = 0x40000000; | 1564 | 7.84k | } | 1565 | | | 1566 | 19.6k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1567 | 19.6k | || a->FileAlignment > a->SectionAlignment) | 1568 | 13.9k | { | 1569 | 13.9k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1570 | 13.9k | abfd); | 1571 | 13.9k | a->FileAlignment &= -a->FileAlignment; | 1572 | 13.9k | if (a->FileAlignment > a->SectionAlignment) | 1573 | 8.63k | a->FileAlignment = a->SectionAlignment; | 1574 | 13.9k | } | 1575 | | | 1576 | 19.6k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1577 | 16.2k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1578 | 19.6k | } | 1579 | | | 1580 | 26.0k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1581 | 26.0k | (opt_hdr_size != 0 | 1582 | 26.0k | ? &internal_a | 1583 | 26.0k | : (struct internal_aouthdr *) NULL)); | 1584 | | | 1585 | 26.0k | if (result) | 1586 | 17.7k | { | 1587 | | /* Now the whole header has been processed, see if there is a build-id */ | 1588 | 17.7k | pe_bfd_read_buildid(abfd); | 1589 | 17.7k | } | 1590 | | | 1591 | 26.0k | return result; | 1592 | 26.5k | } |
Line | Count | Source | 1440 | 523k | { | 1441 | 523k | bfd_byte buffer[6]; | 1442 | 523k | struct external_DOS_hdr dos_hdr; | 1443 | 523k | struct external_PEI_IMAGE_hdr image_hdr; | 1444 | 523k | struct internal_filehdr internal_f; | 1445 | 523k | struct internal_aouthdr internal_a; | 1446 | 523k | bfd_size_type opt_hdr_size; | 1447 | 523k | file_ptr offset; | 1448 | 523k | bfd_cleanup result; | 1449 | | | 1450 | | /* Detect if this a Microsoft Import Library Format element. */ | 1451 | | /* First read the beginning of the header. */ | 1452 | 523k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1453 | 523k | || bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) | 1454 | 1.50k | { | 1455 | 1.50k | if (bfd_get_error () != bfd_error_system_call) | 1456 | 1.30k | bfd_set_error (bfd_error_wrong_format); | 1457 | 1.50k | return NULL; | 1458 | 1.50k | } | 1459 | | | 1460 | | /* Then check the magic and the version (only 0 is supported). */ | 1461 | 522k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1462 | 522k | && H_GET_16 (abfd, buffer + 4) == 0) | 1463 | 8.74k | return pe_ILF_object_p (abfd); | 1464 | | | 1465 | 513k | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 | 1466 | 513k | || bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd) | 1467 | 513k | != sizeof (dos_hdr)) | 1468 | 104k | { | 1469 | 104k | if (bfd_get_error () != bfd_error_system_call) | 1470 | 104k | bfd_set_error (bfd_error_wrong_format); | 1471 | 104k | return NULL; | 1472 | 104k | } | 1473 | | | 1474 | | /* There are really two magic numbers involved; the magic number | 1475 | | that says this is a NT executable (PEI) and the magic number that | 1476 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1477 | | the e_magic field. The latter is stored in the f_magic field. | 1478 | | If the NT magic number isn't valid, the architecture magic number | 1479 | | could be mimicked by some other field (specifically, the number | 1480 | | of relocs in section 3). Since this routine can only be called | 1481 | | correctly for a PEI file, check the e_magic number here, and, if | 1482 | | it doesn't match, clobber the f_magic number so that we don't get | 1483 | | a false match. */ | 1484 | 408k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1485 | 221k | { | 1486 | 221k | bfd_set_error (bfd_error_wrong_format); | 1487 | 221k | return NULL; | 1488 | 221k | } | 1489 | | | 1490 | 187k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1491 | 187k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1492 | 187k | || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd) | 1493 | 187k | != sizeof (image_hdr))) | 1494 | 2.60k | { | 1495 | 2.60k | if (bfd_get_error () != bfd_error_system_call) | 1496 | 2.60k | bfd_set_error (bfd_error_wrong_format); | 1497 | 2.60k | return NULL; | 1498 | 2.60k | } | 1499 | | | 1500 | 184k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1501 | 5.08k | { | 1502 | 5.08k | bfd_set_error (bfd_error_wrong_format); | 1503 | 5.08k | return NULL; | 1504 | 5.08k | } | 1505 | | | 1506 | | /* Swap file header, so that we get the location for calling | 1507 | | real_object_p. */ | 1508 | 179k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1509 | | | 1510 | 179k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1511 | 179k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1512 | 164k | { | 1513 | 164k | bfd_set_error (bfd_error_wrong_format); | 1514 | 164k | return NULL; | 1515 | 164k | } | 1516 | | | 1517 | 15.5k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1518 | 15.5k | sizeof (internal_f.pe.dos_message)); | 1519 | | | 1520 | | /* Read the optional header, which has variable size. */ | 1521 | 15.5k | opt_hdr_size = internal_f.f_opthdr; | 1522 | | | 1523 | 15.5k | if (opt_hdr_size != 0) | 1524 | 11.0k | { | 1525 | 11.0k | bfd_size_type amt = opt_hdr_size; | 1526 | 11.0k | bfd_byte * opthdr; | 1527 | | | 1528 | | /* PR 17521 file: 230-131433-0.004. */ | 1529 | 11.0k | if (amt < sizeof (PEAOUTHDR)) | 1530 | 9.74k | amt = sizeof (PEAOUTHDR); | 1531 | | | 1532 | 11.0k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1533 | 11.0k | if (opthdr == NULL) | 1534 | 573 | return NULL; | 1535 | 10.4k | if (amt > opt_hdr_size) | 1536 | 9.73k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1537 | | | 1538 | 10.4k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1539 | | | 1540 | 10.4k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1541 | | | 1542 | | #ifdef ARM | 1543 | | /* Use Subsystem to distinguish between pei-arm-little and | 1544 | | pei-arm-wince-little. */ | 1545 | | #ifdef WINCE | 1546 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1547 | | #else | 1548 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1549 | | #endif | 1550 | | { | 1551 | | bfd_set_error (bfd_error_wrong_format); | 1552 | | return NULL; | 1553 | | } | 1554 | | #endif | 1555 | | | 1556 | 10.4k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1557 | 10.4k | || a->SectionAlignment >= 0x80000000) | 1558 | 8.65k | { | 1559 | 8.65k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1560 | 8.65k | abfd); | 1561 | 8.65k | a->SectionAlignment &= -a->SectionAlignment; | 1562 | 8.65k | if (a->SectionAlignment >= 0x80000000) | 1563 | 104 | a->SectionAlignment = 0x40000000; | 1564 | 8.65k | } | 1565 | | | 1566 | 10.4k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1567 | 10.4k | || a->FileAlignment > a->SectionAlignment) | 1568 | 9.77k | { | 1569 | 9.77k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1570 | 9.77k | abfd); | 1571 | 9.77k | a->FileAlignment &= -a->FileAlignment; | 1572 | 9.77k | if (a->FileAlignment > a->SectionAlignment) | 1573 | 4.54k | a->FileAlignment = a->SectionAlignment; | 1574 | 9.77k | } | 1575 | | | 1576 | 10.4k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1577 | 6.00k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1578 | 10.4k | } | 1579 | | | 1580 | 14.9k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1581 | 14.9k | (opt_hdr_size != 0 | 1582 | 14.9k | ? &internal_a | 1583 | 14.9k | : (struct internal_aouthdr *) NULL)); | 1584 | | | 1585 | 14.9k | if (result) | 1586 | 5.68k | { | 1587 | | /* Now the whole header has been processed, see if there is a build-id */ | 1588 | 5.68k | pe_bfd_read_buildid(abfd); | 1589 | 5.68k | } | 1590 | | | 1591 | 14.9k | return result; | 1592 | 15.5k | } |
|
1593 | | |
1594 | 179k | #define coff_object_p pe_bfd_object_p |
1595 | | #endif /* COFF_IMAGE_WITH_PE */ |