/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 | 123k | { |
132 | 123k | RELOC *reloc_src = (RELOC *) src; |
133 | 123k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; |
134 | | |
135 | 123k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); |
136 | 123k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); |
137 | 123k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); |
138 | | #ifdef SWAP_IN_RELOC_OFFSET |
139 | 1.24k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); |
140 | | #endif |
141 | 123k | } pei-i386.c:coff_swap_reloc_in Line | Count | Source | 131 | 42 | { | 132 | 42 | RELOC *reloc_src = (RELOC *) src; | 133 | 42 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 42 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 42 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 42 | 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 | 42 | } |
pe-x86_64.c:coff_swap_reloc_in Line | Count | Source | 131 | 644 | { | 132 | 644 | RELOC *reloc_src = (RELOC *) src; | 133 | 644 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 644 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 644 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 644 | 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 | 644 | } |
pei-x86_64.c:coff_swap_reloc_in Line | Count | Source | 131 | 33 | { | 132 | 33 | RELOC *reloc_src = (RELOC *) src; | 133 | 33 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 33 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 33 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 33 | 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 | 33 | } |
pe-aarch64.c:coff_swap_reloc_in Line | Count | Source | 131 | 9.50k | { | 132 | 9.50k | RELOC *reloc_src = (RELOC *) src; | 133 | 9.50k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 9.50k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 9.50k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 9.50k | 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 | 9.50k | } |
pei-aarch64.c:coff_swap_reloc_in Line | Count | Source | 131 | 32 | { | 132 | 32 | RELOC *reloc_src = (RELOC *) src; | 133 | 32 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 32 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 32 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 32 | 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 | 32 | } |
pei-ia64.c:coff_swap_reloc_in Line | Count | Source | 131 | 53 | { | 132 | 53 | RELOC *reloc_src = (RELOC *) src; | 133 | 53 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 53 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 53 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 53 | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | | #ifdef SWAP_IN_RELOC_OFFSET | 139 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | | #endif | 141 | 53 | } |
pei-loongarch64.c:coff_swap_reloc_in Line | Count | Source | 131 | 32 | { | 132 | 32 | RELOC *reloc_src = (RELOC *) src; | 133 | 32 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 32 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 32 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 32 | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 32 | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 32 | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 32 | #endif | 141 | 32 | } |
pe-arm-wince.c:coff_swap_reloc_in Line | Count | Source | 131 | 51 | { | 132 | 51 | RELOC *reloc_src = (RELOC *) src; | 133 | 51 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 51 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 51 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 51 | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 51 | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 51 | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 51 | #endif | 141 | 51 | } |
pe-arm.c:coff_swap_reloc_in Line | Count | Source | 131 | 51 | { | 132 | 51 | RELOC *reloc_src = (RELOC *) src; | 133 | 51 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 51 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 51 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 51 | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 51 | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 51 | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 51 | #endif | 141 | 51 | } |
pe-i386.c:coff_swap_reloc_in Line | Count | Source | 131 | 97.6k | { | 132 | 97.6k | RELOC *reloc_src = (RELOC *) src; | 133 | 97.6k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 97.6k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 97.6k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 97.6k | 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 | 97.6k | } |
pe-mcore.c:coff_swap_reloc_in Line | Count | Source | 131 | 948 | { | 132 | 948 | RELOC *reloc_src = (RELOC *) src; | 133 | 948 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 948 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 948 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 948 | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 948 | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 948 | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 948 | #endif | 141 | 948 | } |
pe-sh.c:coff_swap_reloc_in Line | Count | Source | 131 | 14.1k | { | 132 | 14.1k | RELOC *reloc_src = (RELOC *) src; | 133 | 14.1k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 14.1k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 14.1k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 14.1k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | | #ifdef SWAP_IN_RELOC_OFFSET | 139 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | | #endif | 141 | 14.1k | } |
pei-arm-wince.c:coff_swap_reloc_in Line | Count | Source | 131 | 53 | { | 132 | 53 | RELOC *reloc_src = (RELOC *) src; | 133 | 53 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 53 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 53 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 53 | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 53 | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 53 | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 53 | #endif | 141 | 53 | } |
pei-arm.c:coff_swap_reloc_in Line | Count | Source | 131 | 61 | { | 132 | 61 | RELOC *reloc_src = (RELOC *) src; | 133 | 61 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 61 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 61 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 61 | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 61 | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 61 | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 61 | #endif | 141 | 61 | } |
pei-mcore.c:coff_swap_reloc_in Line | Count | Source | 131 | 48 | { | 132 | 48 | RELOC *reloc_src = (RELOC *) src; | 133 | 48 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 48 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 48 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 48 | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 48 | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 48 | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 48 | #endif | 141 | 48 | } |
pei-sh.c:coff_swap_reloc_in Line | Count | Source | 131 | 106 | { | 132 | 106 | RELOC *reloc_src = (RELOC *) src; | 133 | 106 | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 106 | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 106 | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 106 | 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 | 106 | } |
|
142 | | |
143 | | static unsigned int |
144 | | coff_swap_reloc_out (bfd * abfd, void * src, void * dst) |
145 | 0 | { |
146 | 0 | struct internal_reloc *reloc_src = (struct internal_reloc *) src; |
147 | 0 | struct external_reloc *reloc_dst = (struct external_reloc *) dst; |
148 | |
|
149 | 0 | H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr); |
150 | 0 | H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx); |
151 | 0 | H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type); |
152 | |
|
153 | | #ifdef SWAP_OUT_RELOC_OFFSET |
154 | 0 | SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset); |
155 | | #endif |
156 | | #ifdef SWAP_OUT_RELOC_EXTRA |
157 | | SWAP_OUT_RELOC_EXTRA (abfd, reloc_src, reloc_dst); |
158 | | #endif |
159 | 0 | return RELSZ; |
160 | 0 | } Unexecuted instantiation: pei-i386.c:coff_swap_reloc_out Unexecuted instantiation: pe-x86_64.c:coff_swap_reloc_out Unexecuted instantiation: pei-x86_64.c:coff_swap_reloc_out Unexecuted instantiation: pe-aarch64.c:coff_swap_reloc_out Unexecuted instantiation: pei-aarch64.c:coff_swap_reloc_out Unexecuted instantiation: pei-ia64.c:coff_swap_reloc_out Unexecuted instantiation: pei-loongarch64.c:coff_swap_reloc_out Unexecuted instantiation: pe-arm-wince.c:coff_swap_reloc_out Unexecuted instantiation: pe-arm.c:coff_swap_reloc_out Unexecuted instantiation: pe-i386.c:coff_swap_reloc_out Unexecuted instantiation: pe-mcore.c:coff_swap_reloc_out Unexecuted instantiation: pe-sh.c:coff_swap_reloc_out Unexecuted instantiation: pei-arm-wince.c:coff_swap_reloc_out Unexecuted instantiation: pei-arm.c:coff_swap_reloc_out Unexecuted instantiation: pei-mcore.c:coff_swap_reloc_out Unexecuted instantiation: pei-sh.c:coff_swap_reloc_out |
161 | | #endif /* not NO_COFF_RELOCS */ |
162 | | |
163 | | #ifdef COFF_IMAGE_WITH_PE |
164 | | #undef FILHDR |
165 | 18.9k | #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 | 158k | { |
171 | 158k | FILHDR *filehdr_src = (FILHDR *) src; |
172 | 158k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; |
173 | | |
174 | 158k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); |
175 | 158k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); |
176 | 158k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); |
177 | 158k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); |
178 | 158k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); |
179 | 158k | 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 | 158k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) |
184 | 20.0k | { |
185 | 20.0k | filehdr_dst->f_nsyms = 0; |
186 | 20.0k | filehdr_dst->f_flags |= F_LSYMS; |
187 | 20.0k | } |
188 | | |
189 | 158k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); |
190 | 158k | } pei-i386.c:coff_swap_filehdr_in Line | Count | Source | 170 | 2.22k | { | 171 | 2.22k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 2.22k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 2.22k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 2.22k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 2.22k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 2.22k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 2.22k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 2.22k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 2.22k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 80 | { | 185 | 80 | filehdr_dst->f_nsyms = 0; | 186 | 80 | filehdr_dst->f_flags |= F_LSYMS; | 187 | 80 | } | 188 | | | 189 | 2.22k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 2.22k | } |
pe-x86_64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 14.2k | { | 171 | 14.2k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 14.2k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 14.2k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 14.2k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 14.2k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 14.2k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 14.2k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 14.2k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 14.2k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 1.94k | { | 185 | 1.94k | filehdr_dst->f_nsyms = 0; | 186 | 1.94k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 1.94k | } | 188 | | | 189 | 14.2k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 14.2k | } |
pei-x86_64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 2.21k | { | 171 | 2.21k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 2.21k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 2.21k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 2.21k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 2.21k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 2.21k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 2.21k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 2.21k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 2.21k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 92 | { | 185 | 92 | filehdr_dst->f_nsyms = 0; | 186 | 92 | filehdr_dst->f_flags |= F_LSYMS; | 187 | 92 | } | 188 | | | 189 | 2.21k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 2.21k | } |
pe-aarch64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 13.9k | { | 171 | 13.9k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 13.9k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 13.9k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 13.9k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 13.9k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 13.9k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 13.9k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 13.9k | 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 | 13.9k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 1.93k | { | 185 | 1.93k | filehdr_dst->f_nsyms = 0; | 186 | 1.93k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 1.93k | } | 188 | | | 189 | 13.9k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 13.9k | } |
pei-aarch64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 2.10k | { | 171 | 2.10k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 2.10k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 2.10k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 2.10k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 2.10k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 2.10k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 2.10k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 2.10k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 2.10k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 79 | { | 185 | 79 | filehdr_dst->f_nsyms = 0; | 186 | 79 | filehdr_dst->f_flags |= F_LSYMS; | 187 | 79 | } | 188 | | | 189 | 2.10k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 2.10k | } |
pei-ia64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 1.68k | { | 171 | 1.68k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 1.68k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 1.68k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 1.68k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 1.68k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 1.68k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 1.68k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 1.68k | 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.68k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 37 | { | 185 | 37 | filehdr_dst->f_nsyms = 0; | 186 | 37 | filehdr_dst->f_flags |= F_LSYMS; | 187 | 37 | } | 188 | | | 189 | 1.68k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 1.68k | } |
pei-loongarch64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 2.10k | { | 171 | 2.10k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 2.10k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 2.10k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 2.10k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 2.10k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 2.10k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 2.10k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 2.10k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 2.10k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 79 | { | 185 | 79 | filehdr_dst->f_nsyms = 0; | 186 | 79 | filehdr_dst->f_flags |= F_LSYMS; | 187 | 79 | } | 188 | | | 189 | 2.10k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 2.10k | } |
pe-arm-wince.c:coff_swap_filehdr_in Line | Count | Source | 170 | 27.8k | { | 171 | 27.8k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 27.8k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 27.8k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 27.8k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 27.8k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 27.8k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 27.8k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 27.8k | 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 | 27.8k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 3.86k | { | 185 | 3.86k | filehdr_dst->f_nsyms = 0; | 186 | 3.86k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 3.86k | } | 188 | | | 189 | 27.8k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 27.8k | } |
pe-arm.c:coff_swap_filehdr_in Line | Count | Source | 170 | 27.8k | { | 171 | 27.8k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 27.8k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 27.8k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 27.8k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 27.8k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 27.8k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 27.8k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 27.8k | 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 | 27.8k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 3.86k | { | 185 | 3.86k | filehdr_dst->f_nsyms = 0; | 186 | 3.86k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 3.86k | } | 188 | | | 189 | 27.8k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 27.8k | } |
pe-i386.c:coff_swap_filehdr_in Line | Count | Source | 170 | 13.9k | { | 171 | 13.9k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 13.9k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 13.9k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 13.9k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 13.9k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 13.9k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 13.9k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 13.9k | 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 | 13.9k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 1.93k | { | 185 | 1.93k | filehdr_dst->f_nsyms = 0; | 186 | 1.93k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 1.93k | } | 188 | | | 189 | 13.9k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 13.9k | } |
pe-mcore.c:coff_swap_filehdr_in Line | Count | Source | 170 | 27.8k | { | 171 | 27.8k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 27.8k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 27.8k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 27.8k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 27.8k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 27.8k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 27.8k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 27.8k | 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 | 27.8k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 3.86k | { | 185 | 3.86k | filehdr_dst->f_nsyms = 0; | 186 | 3.86k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 3.86k | } | 188 | | | 189 | 27.8k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 27.8k | } |
pe-sh.c:coff_swap_filehdr_in Line | Count | Source | 170 | 13.9k | { | 171 | 13.9k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 13.9k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 13.9k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 13.9k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 13.9k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 13.9k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 13.9k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 13.9k | 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 | 13.9k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 1.93k | { | 185 | 1.93k | filehdr_dst->f_nsyms = 0; | 186 | 1.93k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 1.93k | } | 188 | | | 189 | 13.9k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 13.9k | } |
pei-arm-wince.c:coff_swap_filehdr_in Line | Count | Source | 170 | 2.18k | { | 171 | 2.18k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 2.18k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 2.18k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 2.18k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 2.18k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 2.18k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 2.18k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 2.18k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 2.18k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 79 | { | 185 | 79 | filehdr_dst->f_nsyms = 0; | 186 | 79 | filehdr_dst->f_flags |= F_LSYMS; | 187 | 79 | } | 188 | | | 189 | 2.18k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 2.18k | } |
pei-arm.c:coff_swap_filehdr_in Line | Count | Source | 170 | 2.18k | { | 171 | 2.18k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 2.18k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 2.18k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 2.18k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 2.18k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 2.18k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 2.18k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 2.18k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 2.18k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 79 | { | 185 | 79 | filehdr_dst->f_nsyms = 0; | 186 | 79 | filehdr_dst->f_flags |= F_LSYMS; | 187 | 79 | } | 188 | | | 189 | 2.18k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 2.18k | } |
pei-mcore.c:coff_swap_filehdr_in Line | Count | Source | 170 | 2.18k | { | 171 | 2.18k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 2.18k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 2.18k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 2.18k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 2.18k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 2.18k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 2.18k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 2.18k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 2.18k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 79 | { | 185 | 79 | filehdr_dst->f_nsyms = 0; | 186 | 79 | filehdr_dst->f_flags |= F_LSYMS; | 187 | 79 | } | 188 | | | 189 | 2.18k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 2.18k | } |
pei-sh.c:coff_swap_filehdr_in Line | Count | Source | 170 | 2.10k | { | 171 | 2.10k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 2.10k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 2.10k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 2.10k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 2.10k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 2.10k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 2.10k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 2.10k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 2.10k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 79 | { | 185 | 79 | filehdr_dst->f_nsyms = 0; | 186 | 79 | filehdr_dst->f_flags |= F_LSYMS; | 187 | 79 | } | 188 | | | 189 | 2.10k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 2.10k | } |
|
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 | 65.1k | { |
207 | 65.1k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; |
208 | 65.1k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; |
209 | | |
210 | 65.1k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); |
211 | | |
212 | 65.1k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); |
213 | 65.1k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); |
214 | 65.1k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); |
215 | 65.1k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); |
216 | 65.1k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); |
217 | 65.1k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); |
218 | 65.1k | 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 | 50.0k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) |
225 | 50.0k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); |
226 | | scnhdr_int->s_nreloc = 0; |
227 | | #else |
228 | 15.1k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); |
229 | 15.1k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); |
230 | | #endif |
231 | | |
232 | 65.1k | if (scnhdr_int->s_vaddr != 0) |
233 | 19.8k | { |
234 | 19.8k | 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 | 19.8k | } |
240 | | |
241 | 65.1k | #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 | 65.1k | if (scnhdr_int->s_paddr > 0 |
247 | 65.1k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 |
248 | 22.5k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) |
249 | 22.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 | 5.21k | scnhdr_int->s_size = scnhdr_int->s_paddr; |
255 | 65.1k | #endif |
256 | 65.1k | } pei-i386.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 32.1k | { | 207 | 32.1k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 32.1k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 32.1k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 32.1k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 32.1k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 32.1k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 32.1k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 32.1k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 32.1k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 32.1k | 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.1k | #ifdef COFF_IMAGE_WITH_PE | 224 | 32.1k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 32.1k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 32.1k | 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.1k | if (scnhdr_int->s_vaddr != 0) | 233 | 971 | { | 234 | 971 | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 971 | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 971 | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 971 | #endif | 239 | 971 | } | 240 | | | 241 | 32.1k | #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.1k | if (scnhdr_int->s_paddr > 0 | 247 | 32.1k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 1.12k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 1.12k | || (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 | 254 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 32.1k | #endif | 256 | 32.1k | } |
pe-x86_64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 3.92k | { | 207 | 3.92k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 3.92k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 3.92k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 3.92k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 3.92k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 3.92k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 3.92k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 3.92k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 3.92k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 3.92k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | | #ifdef COFF_IMAGE_WITH_PE | 224 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | 3.92k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 3.92k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 3.92k | #endif | 231 | | | 232 | 3.92k | if (scnhdr_int->s_vaddr != 0) | 233 | 1.97k | { | 234 | 1.97k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | | #endif | 239 | 1.97k | } | 240 | | | 241 | 3.92k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 3.92k | if (scnhdr_int->s_paddr > 0 | 247 | 3.92k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 2.18k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 2.18k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 220 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 3.92k | #endif | 256 | 3.92k | } |
pei-x86_64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 2.52k | { | 207 | 2.52k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 2.52k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 2.52k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 2.52k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 2.52k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 2.52k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 2.52k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 2.52k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 2.52k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 2.52k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 2.52k | #ifdef COFF_IMAGE_WITH_PE | 224 | 2.52k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 2.52k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 2.52k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 2.52k | if (scnhdr_int->s_vaddr != 0) | 233 | 1.09k | { | 234 | 1.09k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | | #endif | 239 | 1.09k | } | 240 | | | 241 | 2.52k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 2.52k | if (scnhdr_int->s_paddr > 0 | 247 | 2.52k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 1.28k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 1.28k | || (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 | 304 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 2.52k | #endif | 256 | 2.52k | } |
pe-aarch64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 2.70k | { | 207 | 2.70k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 2.70k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 2.70k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 2.70k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 2.70k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 2.70k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 2.70k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 2.70k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 2.70k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 2.70k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | | #ifdef COFF_IMAGE_WITH_PE | 224 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | 2.70k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 2.70k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 2.70k | #endif | 231 | | | 232 | 2.70k | if (scnhdr_int->s_vaddr != 0) | 233 | 950 | { | 234 | 950 | 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 | 950 | } | 240 | | | 241 | 2.70k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 2.70k | if (scnhdr_int->s_paddr > 0 | 247 | 2.70k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 1.62k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 1.62k | || (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 | 137 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 2.70k | #endif | 256 | 2.70k | } |
pei-aarch64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 890 | { | 207 | 890 | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 890 | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 890 | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 890 | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 890 | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 890 | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 890 | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 890 | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 890 | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 890 | 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 | 890 | #ifdef COFF_IMAGE_WITH_PE | 224 | 890 | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 890 | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 890 | 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 | 890 | if (scnhdr_int->s_vaddr != 0) | 233 | 408 | { | 234 | 408 | 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 | 408 | } | 240 | | | 241 | 890 | #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 | 890 | if (scnhdr_int->s_paddr > 0 | 247 | 890 | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 394 | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 394 | || (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 | 101 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 890 | #endif | 256 | 890 | } |
pei-ia64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 2.22k | { | 207 | 2.22k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 2.22k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 2.22k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 2.22k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 2.22k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 2.22k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 2.22k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 2.22k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 2.22k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 2.22k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 2.22k | #ifdef COFF_IMAGE_WITH_PE | 224 | 2.22k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 2.22k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 2.22k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 2.22k | if (scnhdr_int->s_vaddr != 0) | 233 | 1.08k | { | 234 | 1.08k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 1.08k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 1.08k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 1.08k | #endif | 239 | 1.08k | } | 240 | | | 241 | 2.22k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 2.22k | if (scnhdr_int->s_paddr > 0 | 247 | 2.22k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 1.42k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 1.42k | || (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 | 409 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 2.22k | #endif | 256 | 2.22k | } |
pei-loongarch64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 4.07k | { | 207 | 4.07k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 4.07k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 4.07k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 4.07k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 4.07k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 4.07k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 4.07k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 4.07k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 4.07k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 4.07k | 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 | 4.07k | #ifdef COFF_IMAGE_WITH_PE | 224 | 4.07k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 4.07k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 4.07k | 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 | 4.07k | if (scnhdr_int->s_vaddr != 0) | 233 | 3.77k | { | 234 | 3.77k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | | #endif | 239 | 3.77k | } | 240 | | | 241 | 4.07k | #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 | 4.07k | if (scnhdr_int->s_paddr > 0 | 247 | 4.07k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 3.81k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 3.81k | || (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 | 209 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 4.07k | #endif | 256 | 4.07k | } |
pe-arm-wince.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 856 | { | 207 | 856 | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 856 | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 856 | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 856 | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 856 | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 856 | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 856 | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 856 | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 856 | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 856 | 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 | 856 | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 856 | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 856 | #endif | 231 | | | 232 | 856 | if (scnhdr_int->s_vaddr != 0) | 233 | 609 | { | 234 | 609 | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 609 | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 609 | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 609 | #endif | 239 | 609 | } | 240 | | | 241 | 856 | #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 | 856 | if (scnhdr_int->s_paddr > 0 | 247 | 856 | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 653 | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 653 | || (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 | 235 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 856 | #endif | 256 | 856 | } |
pe-arm.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 856 | { | 207 | 856 | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 856 | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 856 | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 856 | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 856 | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 856 | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 856 | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 856 | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 856 | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 856 | 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 | 856 | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 856 | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 856 | #endif | 231 | | | 232 | 856 | if (scnhdr_int->s_vaddr != 0) | 233 | 609 | { | 234 | 609 | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 609 | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 609 | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 609 | #endif | 239 | 609 | } | 240 | | | 241 | 856 | #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 | 856 | if (scnhdr_int->s_paddr > 0 | 247 | 856 | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 653 | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 653 | || (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 | 235 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 856 | #endif | 256 | 856 | } |
pe-i386.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 2.64k | { | 207 | 2.64k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 2.64k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 2.64k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 2.64k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 2.64k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 2.64k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 2.64k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 2.64k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 2.64k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 2.64k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | | #ifdef COFF_IMAGE_WITH_PE | 224 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | 2.64k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 2.64k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 2.64k | #endif | 231 | | | 232 | 2.64k | if (scnhdr_int->s_vaddr != 0) | 233 | 1.59k | { | 234 | 1.59k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 1.59k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 1.59k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 1.59k | #endif | 239 | 1.59k | } | 240 | | | 241 | 2.64k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 2.64k | if (scnhdr_int->s_paddr > 0 | 247 | 2.64k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 1.78k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 1.78k | || (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 | 856 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 2.64k | #endif | 256 | 2.64k | } |
pe-mcore.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 1.76k | { | 207 | 1.76k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 1.76k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 1.76k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 1.76k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 1.76k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 1.76k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 1.76k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 1.76k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 1.76k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 1.76k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | | #ifdef COFF_IMAGE_WITH_PE | 224 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | 1.76k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 1.76k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 1.76k | #endif | 231 | | | 232 | 1.76k | if (scnhdr_int->s_vaddr != 0) | 233 | 1.03k | { | 234 | 1.03k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 1.03k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 1.03k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 1.03k | #endif | 239 | 1.03k | } | 240 | | | 241 | 1.76k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 1.76k | if (scnhdr_int->s_paddr > 0 | 247 | 1.76k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 1.12k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 1.12k | || (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 | 238 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 1.76k | #endif | 256 | 1.76k | } |
pe-sh.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 2.36k | { | 207 | 2.36k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 2.36k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 2.36k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 2.36k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 2.36k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 2.36k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 2.36k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 2.36k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 2.36k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 2.36k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | | #ifdef COFF_IMAGE_WITH_PE | 224 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | 2.36k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 2.36k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 2.36k | #endif | 231 | | | 232 | 2.36k | if (scnhdr_int->s_vaddr != 0) | 233 | 1.39k | { | 234 | 1.39k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 1.39k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 1.39k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 1.39k | #endif | 239 | 1.39k | } | 240 | | | 241 | 2.36k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 2.36k | if (scnhdr_int->s_paddr > 0 | 247 | 2.36k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 1.51k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 1.51k | || (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 | 840 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 2.36k | #endif | 256 | 2.36k | } |
pei-arm-wince.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 1.52k | { | 207 | 1.52k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 1.52k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 1.52k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 1.52k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 1.52k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 1.52k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 1.52k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 1.52k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 1.52k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 1.52k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 1.52k | #ifdef COFF_IMAGE_WITH_PE | 224 | 1.52k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 1.52k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 1.52k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 1.52k | if (scnhdr_int->s_vaddr != 0) | 233 | 592 | { | 234 | 592 | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 592 | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 592 | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 592 | #endif | 239 | 592 | } | 240 | | | 241 | 1.52k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 1.52k | if (scnhdr_int->s_paddr > 0 | 247 | 1.52k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 684 | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 684 | || (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 | 225 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 1.52k | #endif | 256 | 1.52k | } |
pei-arm.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 1.99k | { | 207 | 1.99k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 1.99k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 1.99k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 1.99k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 1.99k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 1.99k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 1.99k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 1.99k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 1.99k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 1.99k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 1.99k | #ifdef COFF_IMAGE_WITH_PE | 224 | 1.99k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 1.99k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 1.99k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 1.99k | if (scnhdr_int->s_vaddr != 0) | 233 | 777 | { | 234 | 777 | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 777 | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 777 | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 777 | #endif | 239 | 777 | } | 240 | | | 241 | 1.99k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 1.99k | if (scnhdr_int->s_paddr > 0 | 247 | 1.99k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 932 | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 932 | || (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 | 327 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 1.99k | #endif | 256 | 1.99k | } |
pei-mcore.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 3.35k | { | 207 | 3.35k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 3.35k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 3.35k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 3.35k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 3.35k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 3.35k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 3.35k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 3.35k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 3.35k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 3.35k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 3.35k | #ifdef COFF_IMAGE_WITH_PE | 224 | 3.35k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 3.35k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 3.35k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 3.35k | if (scnhdr_int->s_vaddr != 0) | 233 | 2.34k | { | 234 | 2.34k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 2.34k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 2.34k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 2.34k | #endif | 239 | 2.34k | } | 240 | | | 241 | 3.35k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 3.35k | if (scnhdr_int->s_paddr > 0 | 247 | 3.35k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 2.70k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 2.70k | || (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 | 454 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 3.35k | #endif | 256 | 3.35k | } |
pei-sh.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 1.35k | { | 207 | 1.35k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 1.35k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 1.35k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 1.35k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 1.35k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 1.35k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 1.35k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 1.35k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 1.35k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 1.35k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 1.35k | #ifdef COFF_IMAGE_WITH_PE | 224 | 1.35k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 1.35k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 1.35k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 1.35k | if (scnhdr_int->s_vaddr != 0) | 233 | 649 | { | 234 | 649 | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 649 | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) | 237 | 649 | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 649 | #endif | 239 | 649 | } | 240 | | | 241 | 1.35k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 1.35k | if (scnhdr_int->s_paddr > 0 | 247 | 1.35k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 686 | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 686 | || (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 | 175 | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 1.35k | #endif | 256 | 1.35k | } |
|
257 | | |
258 | | static bool |
259 | | pe_mkobject (bfd * abfd) |
260 | 5.26k | { |
261 | | /* Some x86 code followed by an ascii string. */ |
262 | 5.26k | static const char default_dos_message[64] = { |
263 | 5.26k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, |
264 | 5.26k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, |
265 | 5.26k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, |
266 | 5.26k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, |
267 | 5.26k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, |
268 | 5.26k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, |
269 | 5.26k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, |
270 | 5.26k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
271 | | |
272 | 5.26k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); |
273 | 5.26k | abfd->tdata.pe_obj_data = pe; |
274 | 5.26k | if (pe == NULL) |
275 | 0 | return false; |
276 | | |
277 | 5.26k | pe->coff.pe = 1; |
278 | | |
279 | | /* in_reloc_p is architecture dependent. */ |
280 | 5.26k | pe->in_reloc_p = in_reloc_p; |
281 | | |
282 | 5.26k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); |
283 | | |
284 | 5.26k | bfd_coff_long_section_names (abfd) |
285 | 5.26k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; |
286 | | |
287 | 5.26k | return true; |
288 | 5.26k | } Line | Count | Source | 260 | 363 | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 363 | static const char default_dos_message[64] = { | 263 | 363 | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 363 | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 363 | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 363 | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 363 | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 363 | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 363 | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 363 | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 363 | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 363 | abfd->tdata.pe_obj_data = pe; | 274 | 363 | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 363 | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 363 | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 363 | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 363 | bfd_coff_long_section_names (abfd) | 285 | 363 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 363 | return true; | 288 | 363 | } |
Line | Count | Source | 260 | 1.10k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 1.10k | static const char default_dos_message[64] = { | 263 | 1.10k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 1.10k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 1.10k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 1.10k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 1.10k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 1.10k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 1.10k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 1.10k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 1.10k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 1.10k | abfd->tdata.pe_obj_data = pe; | 274 | 1.10k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 1.10k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 1.10k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 1.10k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 1.10k | bfd_coff_long_section_names (abfd) | 285 | 1.10k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 1.10k | return true; | 288 | 1.10k | } |
Line | Count | Source | 260 | 414 | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 414 | static const char default_dos_message[64] = { | 263 | 414 | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 414 | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 414 | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 414 | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 414 | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 414 | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 414 | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 414 | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 414 | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 414 | abfd->tdata.pe_obj_data = pe; | 274 | 414 | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 414 | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 414 | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 414 | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 414 | bfd_coff_long_section_names (abfd) | 285 | 414 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 414 | return true; | 288 | 414 | } |
Line | Count | Source | 260 | 272 | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 272 | static const char default_dos_message[64] = { | 263 | 272 | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 272 | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 272 | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 272 | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 272 | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 272 | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 272 | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 272 | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 272 | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 272 | abfd->tdata.pe_obj_data = pe; | 274 | 272 | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 272 | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 272 | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 272 | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 272 | bfd_coff_long_section_names (abfd) | 285 | 272 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 272 | return true; | 288 | 272 | } |
pei-aarch64.c:pe_mkobject Line | Count | Source | 260 | 233 | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 233 | static const char default_dos_message[64] = { | 263 | 233 | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 233 | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 233 | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 233 | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 233 | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 233 | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 233 | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 233 | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 233 | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 233 | abfd->tdata.pe_obj_data = pe; | 274 | 233 | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 233 | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 233 | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 233 | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 233 | bfd_coff_long_section_names (abfd) | 285 | 233 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 233 | return true; | 288 | 233 | } |
Line | Count | Source | 260 | 276 | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 276 | static const char default_dos_message[64] = { | 263 | 276 | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 276 | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 276 | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 276 | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 276 | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 276 | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 276 | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 276 | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 276 | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 276 | abfd->tdata.pe_obj_data = pe; | 274 | 276 | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 276 | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 276 | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 276 | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 276 | bfd_coff_long_section_names (abfd) | 285 | 276 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 276 | return true; | 288 | 276 | } |
pei-loongarch64.c:pe_mkobject Line | Count | Source | 260 | 247 | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 247 | static const char default_dos_message[64] = { | 263 | 247 | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 247 | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 247 | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 247 | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 247 | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 247 | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 247 | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 247 | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 247 | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 247 | abfd->tdata.pe_obj_data = pe; | 274 | 247 | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 247 | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 247 | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 247 | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 247 | bfd_coff_long_section_names (abfd) | 285 | 247 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 247 | return true; | 288 | 247 | } |
pe-arm-wince.c:pe_mkobject Line | Count | Source | 260 | 162 | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 162 | static const char default_dos_message[64] = { | 263 | 162 | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 162 | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 162 | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 162 | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 162 | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 162 | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 162 | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 162 | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 162 | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 162 | abfd->tdata.pe_obj_data = pe; | 274 | 162 | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 162 | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 162 | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 162 | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 162 | bfd_coff_long_section_names (abfd) | 285 | 162 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 162 | return true; | 288 | 162 | } |
Line | Count | Source | 260 | 162 | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 162 | static const char default_dos_message[64] = { | 263 | 162 | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 162 | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 162 | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 162 | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 162 | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 162 | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 162 | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 162 | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 162 | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 162 | abfd->tdata.pe_obj_data = pe; | 274 | 162 | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 162 | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 162 | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 162 | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 162 | bfd_coff_long_section_names (abfd) | 285 | 162 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 162 | return true; | 288 | 162 | } |
Line | Count | Source | 260 | 462 | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 462 | static const char default_dos_message[64] = { | 263 | 462 | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 462 | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 462 | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 462 | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 462 | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 462 | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 462 | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 462 | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 462 | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 462 | abfd->tdata.pe_obj_data = pe; | 274 | 462 | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 462 | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 462 | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 462 | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 462 | bfd_coff_long_section_names (abfd) | 285 | 462 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 462 | return true; | 288 | 462 | } |
Line | Count | Source | 260 | 265 | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 265 | static const char default_dos_message[64] = { | 263 | 265 | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 265 | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 265 | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 265 | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 265 | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 265 | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 265 | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 265 | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 265 | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 265 | abfd->tdata.pe_obj_data = pe; | 274 | 265 | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 265 | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 265 | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 265 | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 265 | bfd_coff_long_section_names (abfd) | 285 | 265 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 265 | return true; | 288 | 265 | } |
Line | Count | Source | 260 | 316 | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 316 | static const char default_dos_message[64] = { | 263 | 316 | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 316 | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 316 | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 316 | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 316 | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 316 | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 316 | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 316 | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 316 | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 316 | abfd->tdata.pe_obj_data = pe; | 274 | 316 | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 316 | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 316 | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 316 | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 316 | bfd_coff_long_section_names (abfd) | 285 | 316 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 316 | return true; | 288 | 316 | } |
pei-arm-wince.c:pe_mkobject Line | Count | Source | 260 | 215 | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 215 | static const char default_dos_message[64] = { | 263 | 215 | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 215 | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 215 | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 215 | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 215 | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 215 | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 215 | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 215 | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 215 | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 215 | abfd->tdata.pe_obj_data = pe; | 274 | 215 | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 215 | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 215 | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 215 | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 215 | bfd_coff_long_section_names (abfd) | 285 | 215 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 215 | return true; | 288 | 215 | } |
Line | Count | Source | 260 | 318 | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 318 | static const char default_dos_message[64] = { | 263 | 318 | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 318 | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 318 | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 318 | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 318 | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 318 | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 318 | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 318 | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 318 | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 318 | abfd->tdata.pe_obj_data = pe; | 274 | 318 | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 318 | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 318 | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 318 | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 318 | bfd_coff_long_section_names (abfd) | 285 | 318 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 318 | return true; | 288 | 318 | } |
Line | Count | Source | 260 | 221 | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 221 | static const char default_dos_message[64] = { | 263 | 221 | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 221 | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 221 | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 221 | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 221 | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 221 | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 221 | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 221 | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 221 | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 221 | abfd->tdata.pe_obj_data = pe; | 274 | 221 | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 221 | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 221 | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 221 | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 221 | bfd_coff_long_section_names (abfd) | 285 | 221 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 221 | return true; | 288 | 221 | } |
Line | Count | Source | 260 | 235 | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 235 | static const char default_dos_message[64] = { | 263 | 235 | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 235 | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 235 | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 235 | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 235 | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 235 | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 235 | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 235 | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 235 | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 235 | abfd->tdata.pe_obj_data = pe; | 274 | 235 | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 235 | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 235 | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 235 | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 235 | bfd_coff_long_section_names (abfd) | 285 | 235 | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 235 | return true; | 288 | 235 | } |
|
289 | | |
290 | | /* Create the COFF backend specific information. */ |
291 | | |
292 | | static void * |
293 | | pe_mkobject_hook (bfd * abfd, |
294 | | void * filehdr, |
295 | | void * aouthdr ATTRIBUTE_UNUSED) |
296 | 5.26k | { |
297 | 5.26k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; |
298 | 5.26k | pe_data_type *pe; |
299 | | |
300 | 5.26k | if (! pe_mkobject (abfd)) |
301 | 0 | return NULL; |
302 | | |
303 | 5.26k | pe = pe_data (abfd); |
304 | 5.26k | pe->coff.sym_filepos = internal_f->f_symptr; |
305 | | /* These members communicate important constants about the symbol |
306 | | table to GDB's symbol-reading code. These `constants' |
307 | | unfortunately vary among coff implementations... */ |
308 | 5.26k | pe->coff.local_n_btmask = N_BTMASK; |
309 | 5.26k | pe->coff.local_n_btshft = N_BTSHFT; |
310 | 5.26k | pe->coff.local_n_tmask = N_TMASK; |
311 | 5.26k | pe->coff.local_n_tshift = N_TSHIFT; |
312 | 5.26k | pe->coff.local_symesz = SYMESZ; |
313 | 5.26k | pe->coff.local_auxesz = AUXESZ; |
314 | 5.26k | pe->coff.local_linesz = LINESZ; |
315 | | |
316 | 5.26k | pe->coff.timestamp = internal_f->f_timdat; |
317 | | |
318 | 5.26k | obj_raw_syment_count (abfd) = |
319 | 5.26k | obj_conv_table_size (abfd) = |
320 | 5.26k | internal_f->f_nsyms; |
321 | | |
322 | 5.26k | pe->real_flags = internal_f->f_flags; |
323 | | |
324 | 5.26k | if ((internal_f->f_flags & F_DLL) != 0) |
325 | 1.02k | pe->dll = 1; |
326 | | |
327 | 5.26k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) |
328 | 3.78k | abfd->flags |= HAS_DEBUG; |
329 | | |
330 | | #ifdef COFF_IMAGE_WITH_PE |
331 | 2.52k | if (aouthdr) |
332 | 1.89k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; |
333 | | #endif |
334 | | |
335 | | #ifdef ARM |
336 | 857 | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) |
337 | 0 | coff_data (abfd) ->flags = 0; |
338 | | #endif |
339 | | |
340 | 5.26k | memcpy (pe->dos_message, internal_f->pe.dos_message, |
341 | 5.26k | sizeof (pe->dos_message)); |
342 | | |
343 | 5.26k | return (void *) pe; |
344 | 5.26k | } pei-i386.c:pe_mkobject_hook Line | Count | Source | 296 | 363 | { | 297 | 363 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 363 | pe_data_type *pe; | 299 | | | 300 | 363 | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 363 | pe = pe_data (abfd); | 304 | 363 | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 363 | pe->coff.local_n_btmask = N_BTMASK; | 309 | 363 | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 363 | pe->coff.local_n_tmask = N_TMASK; | 311 | 363 | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 363 | pe->coff.local_symesz = SYMESZ; | 313 | 363 | pe->coff.local_auxesz = AUXESZ; | 314 | 363 | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 363 | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 363 | obj_raw_syment_count (abfd) = | 319 | 363 | obj_conv_table_size (abfd) = | 320 | 363 | internal_f->f_nsyms; | 321 | | | 322 | 363 | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 363 | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 76 | pe->dll = 1; | 326 | | | 327 | 363 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 280 | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 363 | #ifdef COFF_IMAGE_WITH_PE | 331 | 363 | if (aouthdr) | 332 | 328 | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 363 | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 363 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 363 | sizeof (pe->dos_message)); | 342 | | | 343 | 363 | return (void *) pe; | 344 | 363 | } |
pe-x86_64.c:pe_mkobject_hook Line | Count | Source | 296 | 1.10k | { | 297 | 1.10k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 1.10k | pe_data_type *pe; | 299 | | | 300 | 1.10k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 1.10k | pe = pe_data (abfd); | 304 | 1.10k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 1.10k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 1.10k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 1.10k | pe->coff.local_n_tmask = N_TMASK; | 311 | 1.10k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 1.10k | pe->coff.local_symesz = SYMESZ; | 313 | 1.10k | pe->coff.local_auxesz = AUXESZ; | 314 | 1.10k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 1.10k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 1.10k | obj_raw_syment_count (abfd) = | 319 | 1.10k | obj_conv_table_size (abfd) = | 320 | 1.10k | internal_f->f_nsyms; | 321 | | | 322 | 1.10k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 1.10k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 148 | pe->dll = 1; | 326 | | | 327 | 1.10k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 836 | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | | #ifdef COFF_IMAGE_WITH_PE | 331 | | if (aouthdr) | 332 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 1.10k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 1.10k | sizeof (pe->dos_message)); | 342 | | | 343 | 1.10k | return (void *) pe; | 344 | 1.10k | } |
pei-x86_64.c:pe_mkobject_hook Line | Count | Source | 296 | 414 | { | 297 | 414 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 414 | pe_data_type *pe; | 299 | | | 300 | 414 | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 414 | pe = pe_data (abfd); | 304 | 414 | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 414 | pe->coff.local_n_btmask = N_BTMASK; | 309 | 414 | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 414 | pe->coff.local_n_tmask = N_TMASK; | 311 | 414 | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 414 | pe->coff.local_symesz = SYMESZ; | 313 | 414 | pe->coff.local_auxesz = AUXESZ; | 314 | 414 | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 414 | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 414 | obj_raw_syment_count (abfd) = | 319 | 414 | obj_conv_table_size (abfd) = | 320 | 414 | internal_f->f_nsyms; | 321 | | | 322 | 414 | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 414 | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 17 | pe->dll = 1; | 326 | | | 327 | 414 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 135 | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 414 | #ifdef COFF_IMAGE_WITH_PE | 331 | 414 | if (aouthdr) | 332 | 346 | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 414 | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 414 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 414 | sizeof (pe->dos_message)); | 342 | | | 343 | 414 | return (void *) pe; | 344 | 414 | } |
pe-aarch64.c:pe_mkobject_hook Line | Count | Source | 296 | 272 | { | 297 | 272 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 272 | pe_data_type *pe; | 299 | | | 300 | 272 | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 272 | pe = pe_data (abfd); | 304 | 272 | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 272 | pe->coff.local_n_btmask = N_BTMASK; | 309 | 272 | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 272 | pe->coff.local_n_tmask = N_TMASK; | 311 | 272 | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 272 | pe->coff.local_symesz = SYMESZ; | 313 | 272 | pe->coff.local_auxesz = AUXESZ; | 314 | 272 | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 272 | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 272 | obj_raw_syment_count (abfd) = | 319 | 272 | obj_conv_table_size (abfd) = | 320 | 272 | internal_f->f_nsyms; | 321 | | | 322 | 272 | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 272 | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 32 | pe->dll = 1; | 326 | | | 327 | 272 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 235 | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | | #ifdef COFF_IMAGE_WITH_PE | 331 | | if (aouthdr) | 332 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 272 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 272 | sizeof (pe->dos_message)); | 342 | | | 343 | 272 | return (void *) pe; | 344 | 272 | } |
pei-aarch64.c:pe_mkobject_hook Line | Count | Source | 296 | 233 | { | 297 | 233 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 233 | pe_data_type *pe; | 299 | | | 300 | 233 | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 233 | pe = pe_data (abfd); | 304 | 233 | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 233 | pe->coff.local_n_btmask = N_BTMASK; | 309 | 233 | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 233 | pe->coff.local_n_tmask = N_TMASK; | 311 | 233 | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 233 | pe->coff.local_symesz = SYMESZ; | 313 | 233 | pe->coff.local_auxesz = AUXESZ; | 314 | 233 | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 233 | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 233 | obj_raw_syment_count (abfd) = | 319 | 233 | obj_conv_table_size (abfd) = | 320 | 233 | internal_f->f_nsyms; | 321 | | | 322 | 233 | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 233 | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 27 | pe->dll = 1; | 326 | | | 327 | 233 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 174 | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 233 | #ifdef COFF_IMAGE_WITH_PE | 331 | 233 | if (aouthdr) | 332 | 183 | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 233 | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 233 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 233 | sizeof (pe->dos_message)); | 342 | | | 343 | 233 | return (void *) pe; | 344 | 233 | } |
pei-ia64.c:pe_mkobject_hook Line | Count | Source | 296 | 276 | { | 297 | 276 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 276 | pe_data_type *pe; | 299 | | | 300 | 276 | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 276 | pe = pe_data (abfd); | 304 | 276 | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 276 | pe->coff.local_n_btmask = N_BTMASK; | 309 | 276 | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 276 | pe->coff.local_n_tmask = N_TMASK; | 311 | 276 | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 276 | pe->coff.local_symesz = SYMESZ; | 313 | 276 | pe->coff.local_auxesz = AUXESZ; | 314 | 276 | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 276 | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 276 | obj_raw_syment_count (abfd) = | 319 | 276 | obj_conv_table_size (abfd) = | 320 | 276 | internal_f->f_nsyms; | 321 | | | 322 | 276 | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 276 | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 72 | pe->dll = 1; | 326 | | | 327 | 276 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 240 | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 276 | #ifdef COFF_IMAGE_WITH_PE | 331 | 276 | if (aouthdr) | 332 | 210 | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 276 | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 276 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 276 | sizeof (pe->dos_message)); | 342 | | | 343 | 276 | return (void *) pe; | 344 | 276 | } |
pei-loongarch64.c:pe_mkobject_hook Line | Count | Source | 296 | 247 | { | 297 | 247 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 247 | pe_data_type *pe; | 299 | | | 300 | 247 | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 247 | pe = pe_data (abfd); | 304 | 247 | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 247 | pe->coff.local_n_btmask = N_BTMASK; | 309 | 247 | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 247 | pe->coff.local_n_tmask = N_TMASK; | 311 | 247 | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 247 | pe->coff.local_symesz = SYMESZ; | 313 | 247 | pe->coff.local_auxesz = AUXESZ; | 314 | 247 | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 247 | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 247 | obj_raw_syment_count (abfd) = | 319 | 247 | obj_conv_table_size (abfd) = | 320 | 247 | internal_f->f_nsyms; | 321 | | | 322 | 247 | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 247 | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 47 | pe->dll = 1; | 326 | | | 327 | 247 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 202 | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 247 | #ifdef COFF_IMAGE_WITH_PE | 331 | 247 | if (aouthdr) | 332 | 199 | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 247 | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 247 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 247 | sizeof (pe->dos_message)); | 342 | | | 343 | 247 | return (void *) pe; | 344 | 247 | } |
pe-arm-wince.c:pe_mkobject_hook Line | Count | Source | 296 | 162 | { | 297 | 162 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 162 | pe_data_type *pe; | 299 | | | 300 | 162 | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 162 | pe = pe_data (abfd); | 304 | 162 | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 162 | pe->coff.local_n_btmask = N_BTMASK; | 309 | 162 | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 162 | pe->coff.local_n_tmask = N_TMASK; | 311 | 162 | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 162 | pe->coff.local_symesz = SYMESZ; | 313 | 162 | pe->coff.local_auxesz = AUXESZ; | 314 | 162 | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 162 | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 162 | obj_raw_syment_count (abfd) = | 319 | 162 | obj_conv_table_size (abfd) = | 320 | 162 | internal_f->f_nsyms; | 321 | | | 322 | 162 | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 162 | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 37 | pe->dll = 1; | 326 | | | 327 | 162 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 134 | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | | #ifdef COFF_IMAGE_WITH_PE | 331 | | if (aouthdr) | 332 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | | #endif | 334 | | | 335 | 162 | #ifdef ARM | 336 | 162 | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | 0 | coff_data (abfd) ->flags = 0; | 338 | 162 | #endif | 339 | | | 340 | 162 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 162 | sizeof (pe->dos_message)); | 342 | | | 343 | 162 | return (void *) pe; | 344 | 162 | } |
pe-arm.c:pe_mkobject_hook Line | Count | Source | 296 | 162 | { | 297 | 162 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 162 | pe_data_type *pe; | 299 | | | 300 | 162 | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 162 | pe = pe_data (abfd); | 304 | 162 | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 162 | pe->coff.local_n_btmask = N_BTMASK; | 309 | 162 | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 162 | pe->coff.local_n_tmask = N_TMASK; | 311 | 162 | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 162 | pe->coff.local_symesz = SYMESZ; | 313 | 162 | pe->coff.local_auxesz = AUXESZ; | 314 | 162 | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 162 | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 162 | obj_raw_syment_count (abfd) = | 319 | 162 | obj_conv_table_size (abfd) = | 320 | 162 | internal_f->f_nsyms; | 321 | | | 322 | 162 | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 162 | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 37 | pe->dll = 1; | 326 | | | 327 | 162 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 134 | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | | #ifdef COFF_IMAGE_WITH_PE | 331 | | if (aouthdr) | 332 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | | #endif | 334 | | | 335 | 162 | #ifdef ARM | 336 | 162 | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | 0 | coff_data (abfd) ->flags = 0; | 338 | 162 | #endif | 339 | | | 340 | 162 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 162 | sizeof (pe->dos_message)); | 342 | | | 343 | 162 | return (void *) pe; | 344 | 162 | } |
pe-i386.c:pe_mkobject_hook Line | Count | Source | 296 | 462 | { | 297 | 462 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 462 | pe_data_type *pe; | 299 | | | 300 | 462 | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 462 | pe = pe_data (abfd); | 304 | 462 | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 462 | pe->coff.local_n_btmask = N_BTMASK; | 309 | 462 | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 462 | pe->coff.local_n_tmask = N_TMASK; | 311 | 462 | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 462 | pe->coff.local_symesz = SYMESZ; | 313 | 462 | pe->coff.local_auxesz = AUXESZ; | 314 | 462 | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 462 | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 462 | obj_raw_syment_count (abfd) = | 319 | 462 | obj_conv_table_size (abfd) = | 320 | 462 | internal_f->f_nsyms; | 321 | | | 322 | 462 | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 462 | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 174 | pe->dll = 1; | 326 | | | 327 | 462 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 316 | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | | #ifdef COFF_IMAGE_WITH_PE | 331 | | if (aouthdr) | 332 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 462 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 462 | sizeof (pe->dos_message)); | 342 | | | 343 | 462 | return (void *) pe; | 344 | 462 | } |
pe-mcore.c:pe_mkobject_hook Line | Count | Source | 296 | 265 | { | 297 | 265 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 265 | pe_data_type *pe; | 299 | | | 300 | 265 | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 265 | pe = pe_data (abfd); | 304 | 265 | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 265 | pe->coff.local_n_btmask = N_BTMASK; | 309 | 265 | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 265 | pe->coff.local_n_tmask = N_TMASK; | 311 | 265 | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 265 | pe->coff.local_symesz = SYMESZ; | 313 | 265 | pe->coff.local_auxesz = AUXESZ; | 314 | 265 | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 265 | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 265 | obj_raw_syment_count (abfd) = | 319 | 265 | obj_conv_table_size (abfd) = | 320 | 265 | internal_f->f_nsyms; | 321 | | | 322 | 265 | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 265 | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 29 | pe->dll = 1; | 326 | | | 327 | 265 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 214 | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | | #ifdef COFF_IMAGE_WITH_PE | 331 | | if (aouthdr) | 332 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 265 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 265 | sizeof (pe->dos_message)); | 342 | | | 343 | 265 | return (void *) pe; | 344 | 265 | } |
Line | Count | Source | 296 | 316 | { | 297 | 316 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 316 | pe_data_type *pe; | 299 | | | 300 | 316 | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 316 | pe = pe_data (abfd); | 304 | 316 | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 316 | pe->coff.local_n_btmask = N_BTMASK; | 309 | 316 | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 316 | pe->coff.local_n_tmask = N_TMASK; | 311 | 316 | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 316 | pe->coff.local_symesz = SYMESZ; | 313 | 316 | pe->coff.local_auxesz = AUXESZ; | 314 | 316 | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 316 | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 316 | obj_raw_syment_count (abfd) = | 319 | 316 | obj_conv_table_size (abfd) = | 320 | 316 | internal_f->f_nsyms; | 321 | | | 322 | 316 | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 316 | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 99 | pe->dll = 1; | 326 | | | 327 | 316 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 163 | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | | #ifdef COFF_IMAGE_WITH_PE | 331 | | if (aouthdr) | 332 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 316 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 316 | sizeof (pe->dos_message)); | 342 | | | 343 | 316 | return (void *) pe; | 344 | 316 | } |
pei-arm-wince.c:pe_mkobject_hook Line | Count | Source | 296 | 215 | { | 297 | 215 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 215 | pe_data_type *pe; | 299 | | | 300 | 215 | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 215 | pe = pe_data (abfd); | 304 | 215 | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 215 | pe->coff.local_n_btmask = N_BTMASK; | 309 | 215 | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 215 | pe->coff.local_n_tmask = N_TMASK; | 311 | 215 | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 215 | pe->coff.local_symesz = SYMESZ; | 313 | 215 | pe->coff.local_auxesz = AUXESZ; | 314 | 215 | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 215 | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 215 | obj_raw_syment_count (abfd) = | 319 | 215 | obj_conv_table_size (abfd) = | 320 | 215 | internal_f->f_nsyms; | 321 | | | 322 | 215 | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 215 | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 50 | pe->dll = 1; | 326 | | | 327 | 215 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 107 | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 215 | #ifdef COFF_IMAGE_WITH_PE | 331 | 215 | if (aouthdr) | 332 | 120 | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 215 | #endif | 334 | | | 335 | 215 | #ifdef ARM | 336 | 215 | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | 0 | coff_data (abfd) ->flags = 0; | 338 | 215 | #endif | 339 | | | 340 | 215 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 215 | sizeof (pe->dos_message)); | 342 | | | 343 | 215 | return (void *) pe; | 344 | 215 | } |
pei-arm.c:pe_mkobject_hook Line | Count | Source | 296 | 318 | { | 297 | 318 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 318 | pe_data_type *pe; | 299 | | | 300 | 318 | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 318 | pe = pe_data (abfd); | 304 | 318 | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 318 | pe->coff.local_n_btmask = N_BTMASK; | 309 | 318 | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 318 | pe->coff.local_n_tmask = N_TMASK; | 311 | 318 | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 318 | pe->coff.local_symesz = SYMESZ; | 313 | 318 | pe->coff.local_auxesz = AUXESZ; | 314 | 318 | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 318 | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 318 | obj_raw_syment_count (abfd) = | 319 | 318 | obj_conv_table_size (abfd) = | 320 | 318 | internal_f->f_nsyms; | 321 | | | 322 | 318 | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 318 | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 70 | pe->dll = 1; | 326 | | | 327 | 318 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 212 | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 318 | #ifdef COFF_IMAGE_WITH_PE | 331 | 318 | if (aouthdr) | 332 | 215 | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 318 | #endif | 334 | | | 335 | 318 | #ifdef ARM | 336 | 318 | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | 0 | coff_data (abfd) ->flags = 0; | 338 | 318 | #endif | 339 | | | 340 | 318 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 318 | sizeof (pe->dos_message)); | 342 | | | 343 | 318 | return (void *) pe; | 344 | 318 | } |
pei-mcore.c:pe_mkobject_hook Line | Count | Source | 296 | 221 | { | 297 | 221 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 221 | pe_data_type *pe; | 299 | | | 300 | 221 | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 221 | pe = pe_data (abfd); | 304 | 221 | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 221 | pe->coff.local_n_btmask = N_BTMASK; | 309 | 221 | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 221 | pe->coff.local_n_tmask = N_TMASK; | 311 | 221 | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 221 | pe->coff.local_symesz = SYMESZ; | 313 | 221 | pe->coff.local_auxesz = AUXESZ; | 314 | 221 | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 221 | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 221 | obj_raw_syment_count (abfd) = | 319 | 221 | obj_conv_table_size (abfd) = | 320 | 221 | internal_f->f_nsyms; | 321 | | | 322 | 221 | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 221 | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 83 | pe->dll = 1; | 326 | | | 327 | 221 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 194 | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 221 | #ifdef COFF_IMAGE_WITH_PE | 331 | 221 | if (aouthdr) | 332 | 106 | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 221 | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 221 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 221 | sizeof (pe->dos_message)); | 342 | | | 343 | 221 | return (void *) pe; | 344 | 221 | } |
pei-sh.c:pe_mkobject_hook Line | Count | Source | 296 | 235 | { | 297 | 235 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 235 | pe_data_type *pe; | 299 | | | 300 | 235 | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 235 | pe = pe_data (abfd); | 304 | 235 | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 235 | pe->coff.local_n_btmask = N_BTMASK; | 309 | 235 | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 235 | pe->coff.local_n_tmask = N_TMASK; | 311 | 235 | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 235 | pe->coff.local_symesz = SYMESZ; | 313 | 235 | pe->coff.local_auxesz = AUXESZ; | 314 | 235 | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 235 | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 235 | obj_raw_syment_count (abfd) = | 319 | 235 | obj_conv_table_size (abfd) = | 320 | 235 | internal_f->f_nsyms; | 321 | | | 322 | 235 | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 235 | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 26 | pe->dll = 1; | 326 | | | 327 | 235 | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 208 | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 235 | #ifdef COFF_IMAGE_WITH_PE | 331 | 235 | if (aouthdr) | 332 | 183 | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 235 | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 235 | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 235 | sizeof (pe->dos_message)); | 342 | | | 343 | 235 | return (void *) pe; | 344 | 235 | } |
|
345 | | |
346 | | static bool |
347 | | pe_print_private_bfd_data (bfd *abfd, void * vfile) |
348 | 0 | { |
349 | 0 | FILE *file = (FILE *) vfile; |
350 | |
|
351 | 0 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) |
352 | 0 | return false; |
353 | | |
354 | 0 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) |
355 | 0 | return true; |
356 | | |
357 | 0 | fputc ('\n', file); |
358 | |
|
359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); |
360 | 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: pe-aarch64.c:pe_print_private_bfd_data Unexecuted instantiation: pei-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 |
361 | | |
362 | | /* Copy any private info we understand from the input bfd |
363 | | to the output bfd. */ |
364 | | |
365 | | static bool |
366 | | pe_bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd) |
367 | 0 | { |
368 | | /* PR binutils/716: Copy the large address aware flag. |
369 | | XXX: Should we be copying other flags or other fields in the pe_data() |
370 | | structure ? */ |
371 | 0 | if (pe_data (obfd) != NULL |
372 | 0 | && pe_data (ibfd) != NULL |
373 | 0 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) |
374 | 0 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; |
375 | |
|
376 | 0 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) |
377 | 0 | return false; |
378 | | |
379 | 0 | if (pe_saved_coff_bfd_copy_private_bfd_data) |
380 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); |
381 | | |
382 | 0 | return true; |
383 | 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: pe-aarch64.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-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 |
384 | | |
385 | | #define coff_bfd_copy_private_section_data \ |
386 | | _bfd_XX_bfd_copy_private_section_data |
387 | | |
388 | | #define coff_get_symbol_info _bfd_XX_get_symbol_info |
389 | | |
390 | | #ifdef COFF_IMAGE_WITH_PE |
391 | | |
392 | | /* Code to handle Microsoft's Import Library Format. |
393 | | Also known as LINK6 format. |
394 | | Documentation about this format can be found at: |
395 | | |
396 | | https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#import-library-format */ |
397 | | |
398 | | /* The following constants specify the sizes of the various data |
399 | | structures that we have to create in order to build a bfd describing |
400 | | an ILF object file. The final "+ 1" in the definitions of SIZEOF_IDATA6 |
401 | | and SIZEOF_IDATA7 below is to allow for the possibility that we might |
402 | | need a padding byte in order to ensure 16 bit alignment for the section's |
403 | | contents. |
404 | | |
405 | | The value for SIZEOF_ILF_STRINGS is computed as follows: |
406 | | |
407 | | There will be NUM_ILF_SECTIONS section symbols. Allow 9 characters |
408 | | per symbol for their names (longest section name is .idata$x). |
409 | | |
410 | | There will be two symbols for the imported value, one the symbol name |
411 | | and one with _imp__ prefixed. Allowing for the terminating nul's this |
412 | | is strlen (symbol_name) * 2 + 8 + 21 + strlen (source_dll). |
413 | | |
414 | | The strings in the string table must start STRING__SIZE_SIZE bytes into |
415 | | the table in order to for the string lookup code in coffgen/coffcode to |
416 | | work. */ |
417 | 462 | #define NUM_ILF_RELOCS 8 |
418 | 1.54k | #define NUM_ILF_SECTIONS 6 |
419 | 1.15k | #define NUM_ILF_SYMS (2 + NUM_ILF_SECTIONS) |
420 | | |
421 | 231 | #define SIZEOF_ILF_SYMS (NUM_ILF_SYMS * sizeof (* vars.sym_cache)) |
422 | 231 | #define SIZEOF_ILF_SYM_TABLE (NUM_ILF_SYMS * sizeof (* vars.sym_table)) |
423 | 231 | #define SIZEOF_ILF_NATIVE_SYMS (NUM_ILF_SYMS * sizeof (* vars.native_syms)) |
424 | 231 | #define SIZEOF_ILF_SYM_PTR_TABLE (NUM_ILF_SYMS * sizeof (* vars.sym_ptr_table)) |
425 | 231 | #define SIZEOF_ILF_EXT_SYMS (NUM_ILF_SYMS * sizeof (* vars.esym_table)) |
426 | 231 | #define SIZEOF_ILF_RELOCS (NUM_ILF_RELOCS * sizeof (* vars.reltab)) |
427 | 231 | #define SIZEOF_ILF_INT_RELOCS (NUM_ILF_RELOCS * sizeof (* vars.int_reltab)) |
428 | 231 | #define SIZEOF_ILF_STRINGS (strlen (symbol_name) * 2 + 8 \ |
429 | 231 | + 21 + strlen (source_dll) \ |
430 | 231 | + NUM_ILF_SECTIONS * 9 \ |
431 | 231 | + STRING_SIZE_SIZE) |
432 | 154 | #define SIZEOF_IDATA2 (5 * 4) |
433 | | |
434 | | /* For PEx64 idata4 & 5 have thumb size of 8 bytes. */ |
435 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) |
436 | 42 | #define SIZEOF_IDATA4 (2 * 4) |
437 | 42 | #define SIZEOF_IDATA5 (2 * 4) |
438 | | #else |
439 | 189 | #define SIZEOF_IDATA4 (1 * 4) |
440 | 189 | #define SIZEOF_IDATA5 (1 * 4) |
441 | | #endif |
442 | | |
443 | 193 | #define SIZEOF_IDATA6 (2 + strlen (symbol_name) + 1 + 1) |
444 | 154 | #define SIZEOF_IDATA7 (strlen (source_dll) + 1 + 1) |
445 | 154 | #define SIZEOF_ILF_SECTIONS (NUM_ILF_SECTIONS * sizeof (struct coff_section_tdata)) |
446 | | |
447 | | #define ILF_DATA_SIZE \ |
448 | 154 | + SIZEOF_ILF_SYMS \ |
449 | 154 | + SIZEOF_ILF_SYM_TABLE \ |
450 | 154 | + SIZEOF_ILF_NATIVE_SYMS \ |
451 | 154 | + SIZEOF_ILF_SYM_PTR_TABLE \ |
452 | 154 | + SIZEOF_ILF_EXT_SYMS \ |
453 | 154 | + SIZEOF_ILF_RELOCS \ |
454 | 154 | + SIZEOF_ILF_INT_RELOCS \ |
455 | 154 | + SIZEOF_ILF_STRINGS \ |
456 | 154 | + SIZEOF_IDATA2 \ |
457 | 154 | + SIZEOF_IDATA4 \ |
458 | 154 | + SIZEOF_IDATA5 \ |
459 | 154 | + SIZEOF_IDATA6 \ |
460 | 154 | + SIZEOF_IDATA7 \ |
461 | 154 | + SIZEOF_ILF_SECTIONS \ |
462 | 154 | + MAX_TEXT_SECTION_SIZE |
463 | | |
464 | | /* Create an empty relocation against the given symbol. */ |
465 | | |
466 | | static void |
467 | | pe_ILF_make_a_symbol_reloc (pe_ILF_vars * vars, |
468 | | bfd_vma address, |
469 | | bfd_reloc_code_real_type reloc, |
470 | | struct bfd_symbol ** sym, |
471 | | unsigned int sym_index) |
472 | 121 | { |
473 | 121 | arelent * entry; |
474 | 121 | struct internal_reloc * internal; |
475 | | |
476 | 121 | entry = vars->reltab + vars->relcount; |
477 | 121 | internal = vars->int_reltab + vars->relcount; |
478 | | |
479 | 121 | entry->address = address; |
480 | 121 | entry->addend = 0; |
481 | 121 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); |
482 | 121 | entry->sym_ptr_ptr = sym; |
483 | | |
484 | 121 | internal->r_vaddr = address; |
485 | 121 | internal->r_symndx = sym_index; |
486 | 121 | internal->r_type = entry->howto ? entry->howto->type : 0; |
487 | | |
488 | 121 | vars->relcount ++; |
489 | | |
490 | 121 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); |
491 | 121 | } pei-i386.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 472 | 20 | { | 473 | 20 | arelent * entry; | 474 | 20 | struct internal_reloc * internal; | 475 | | | 476 | 20 | entry = vars->reltab + vars->relcount; | 477 | 20 | internal = vars->int_reltab + vars->relcount; | 478 | | | 479 | 20 | entry->address = address; | 480 | 20 | entry->addend = 0; | 481 | 20 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 482 | 20 | entry->sym_ptr_ptr = sym; | 483 | | | 484 | 20 | internal->r_vaddr = address; | 485 | 20 | internal->r_symndx = sym_index; | 486 | 20 | internal->r_type = entry->howto ? entry->howto->type : 0; | 487 | | | 488 | 20 | vars->relcount ++; | 489 | | | 490 | 20 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 491 | 20 | } |
pei-x86_64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 472 | 14 | { | 473 | 14 | arelent * entry; | 474 | 14 | struct internal_reloc * internal; | 475 | | | 476 | 14 | entry = vars->reltab + vars->relcount; | 477 | 14 | internal = vars->int_reltab + vars->relcount; | 478 | | | 479 | 14 | entry->address = address; | 480 | 14 | entry->addend = 0; | 481 | 14 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 482 | 14 | entry->sym_ptr_ptr = sym; | 483 | | | 484 | 14 | internal->r_vaddr = address; | 485 | 14 | internal->r_symndx = sym_index; | 486 | 14 | internal->r_type = entry->howto ? entry->howto->type : 0; | 487 | | | 488 | 14 | vars->relcount ++; | 489 | | | 490 | 14 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 491 | 14 | } |
pei-aarch64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 472 | 8 | { | 473 | 8 | arelent * entry; | 474 | 8 | struct internal_reloc * internal; | 475 | | | 476 | 8 | entry = vars->reltab + vars->relcount; | 477 | 8 | internal = vars->int_reltab + vars->relcount; | 478 | | | 479 | 8 | entry->address = address; | 480 | 8 | entry->addend = 0; | 481 | 8 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 482 | 8 | entry->sym_ptr_ptr = sym; | 483 | | | 484 | 8 | internal->r_vaddr = address; | 485 | 8 | internal->r_symndx = sym_index; | 486 | 8 | internal->r_type = entry->howto ? entry->howto->type : 0; | 487 | | | 488 | 8 | vars->relcount ++; | 489 | | | 490 | 8 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 491 | 8 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_symbol_reloc pei-loongarch64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 472 | 10 | { | 473 | 10 | arelent * entry; | 474 | 10 | struct internal_reloc * internal; | 475 | | | 476 | 10 | entry = vars->reltab + vars->relcount; | 477 | 10 | internal = vars->int_reltab + vars->relcount; | 478 | | | 479 | 10 | entry->address = address; | 480 | 10 | entry->addend = 0; | 481 | 10 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 482 | 10 | entry->sym_ptr_ptr = sym; | 483 | | | 484 | 10 | internal->r_vaddr = address; | 485 | 10 | internal->r_symndx = sym_index; | 486 | 10 | internal->r_type = entry->howto ? entry->howto->type : 0; | 487 | | | 488 | 10 | vars->relcount ++; | 489 | | | 490 | 10 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 491 | 10 | } |
pei-arm-wince.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 472 | 12 | { | 473 | 12 | arelent * entry; | 474 | 12 | struct internal_reloc * internal; | 475 | | | 476 | 12 | entry = vars->reltab + vars->relcount; | 477 | 12 | internal = vars->int_reltab + vars->relcount; | 478 | | | 479 | 12 | entry->address = address; | 480 | 12 | entry->addend = 0; | 481 | 12 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 482 | 12 | entry->sym_ptr_ptr = sym; | 483 | | | 484 | 12 | internal->r_vaddr = address; | 485 | 12 | internal->r_symndx = sym_index; | 486 | 12 | internal->r_type = entry->howto ? entry->howto->type : 0; | 487 | | | 488 | 12 | vars->relcount ++; | 489 | | | 490 | 12 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 491 | 12 | } |
pei-arm.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 472 | 31 | { | 473 | 31 | arelent * entry; | 474 | 31 | struct internal_reloc * internal; | 475 | | | 476 | 31 | entry = vars->reltab + vars->relcount; | 477 | 31 | internal = vars->int_reltab + vars->relcount; | 478 | | | 479 | 31 | entry->address = address; | 480 | 31 | entry->addend = 0; | 481 | 31 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 482 | 31 | entry->sym_ptr_ptr = sym; | 483 | | | 484 | 31 | internal->r_vaddr = address; | 485 | 31 | internal->r_symndx = sym_index; | 486 | 31 | internal->r_type = entry->howto ? entry->howto->type : 0; | 487 | | | 488 | 31 | vars->relcount ++; | 489 | | | 490 | 31 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 491 | 31 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_symbol_reloc pei-sh.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 472 | 26 | { | 473 | 26 | arelent * entry; | 474 | 26 | struct internal_reloc * internal; | 475 | | | 476 | 26 | entry = vars->reltab + vars->relcount; | 477 | 26 | internal = vars->int_reltab + vars->relcount; | 478 | | | 479 | 26 | entry->address = address; | 480 | 26 | entry->addend = 0; | 481 | 26 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 482 | 26 | entry->sym_ptr_ptr = sym; | 483 | | | 484 | 26 | internal->r_vaddr = address; | 485 | 26 | internal->r_symndx = sym_index; | 486 | 26 | internal->r_type = entry->howto ? entry->howto->type : 0; | 487 | | | 488 | 26 | vars->relcount ++; | 489 | | | 490 | 26 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 491 | 26 | } |
|
492 | | |
493 | | /* Create an empty relocation against the given section. */ |
494 | | |
495 | | static void |
496 | | pe_ILF_make_a_reloc (pe_ILF_vars * vars, |
497 | | bfd_vma address, |
498 | | bfd_reloc_code_real_type reloc, |
499 | | asection_ptr sec) |
500 | 78 | { |
501 | 78 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, |
502 | 78 | coff_section_data (vars->abfd, sec)->i); |
503 | 78 | } pei-i386.c:pe_ILF_make_a_reloc Line | Count | Source | 500 | 12 | { | 501 | 12 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 502 | 12 | coff_section_data (vars->abfd, sec)->i); | 503 | 12 | } |
pei-x86_64.c:pe_ILF_make_a_reloc Line | Count | Source | 500 | 10 | { | 501 | 10 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 502 | 10 | coff_section_data (vars->abfd, sec)->i); | 503 | 10 | } |
pei-aarch64.c:pe_ILF_make_a_reloc Line | Count | Source | 500 | 4 | { | 501 | 4 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 502 | 4 | coff_section_data (vars->abfd, sec)->i); | 503 | 4 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_reloc pei-loongarch64.c:pe_ILF_make_a_reloc Line | Count | Source | 500 | 8 | { | 501 | 8 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 502 | 8 | coff_section_data (vars->abfd, sec)->i); | 503 | 8 | } |
pei-arm-wince.c:pe_ILF_make_a_reloc Line | Count | Source | 500 | 8 | { | 501 | 8 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 502 | 8 | coff_section_data (vars->abfd, sec)->i); | 503 | 8 | } |
pei-arm.c:pe_ILF_make_a_reloc Line | Count | Source | 500 | 22 | { | 501 | 22 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 502 | 22 | coff_section_data (vars->abfd, sec)->i); | 503 | 22 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_reloc pei-sh.c:pe_ILF_make_a_reloc Line | Count | Source | 500 | 14 | { | 501 | 14 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 502 | 14 | coff_section_data (vars->abfd, sec)->i); | 503 | 14 | } |
|
504 | | |
505 | | /* Move the queued relocs into the given section. */ |
506 | | |
507 | | static void |
508 | | pe_ILF_save_relocs (pe_ILF_vars * vars, |
509 | | asection_ptr sec) |
510 | 121 | { |
511 | | /* Make sure that there is somewhere to store the internal relocs. */ |
512 | 121 | if (coff_section_data (vars->abfd, sec) == NULL) |
513 | | /* We should probably return an error indication here. */ |
514 | 0 | abort (); |
515 | | |
516 | 121 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; |
517 | | |
518 | 121 | sec->relocation = vars->reltab; |
519 | 121 | sec->reloc_count = vars->relcount; |
520 | 121 | sec->flags |= SEC_RELOC; |
521 | | |
522 | 121 | vars->reltab += vars->relcount; |
523 | 121 | vars->int_reltab += vars->relcount; |
524 | 121 | vars->relcount = 0; |
525 | | |
526 | 121 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); |
527 | 121 | } pei-i386.c:pe_ILF_save_relocs Line | Count | Source | 510 | 20 | { | 511 | | /* Make sure that there is somewhere to store the internal relocs. */ | 512 | 20 | if (coff_section_data (vars->abfd, sec) == NULL) | 513 | | /* We should probably return an error indication here. */ | 514 | 0 | abort (); | 515 | | | 516 | 20 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 517 | | | 518 | 20 | sec->relocation = vars->reltab; | 519 | 20 | sec->reloc_count = vars->relcount; | 520 | 20 | sec->flags |= SEC_RELOC; | 521 | | | 522 | 20 | vars->reltab += vars->relcount; | 523 | 20 | vars->int_reltab += vars->relcount; | 524 | 20 | vars->relcount = 0; | 525 | | | 526 | 20 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 527 | 20 | } |
pei-x86_64.c:pe_ILF_save_relocs Line | Count | Source | 510 | 14 | { | 511 | | /* Make sure that there is somewhere to store the internal relocs. */ | 512 | 14 | if (coff_section_data (vars->abfd, sec) == NULL) | 513 | | /* We should probably return an error indication here. */ | 514 | 0 | abort (); | 515 | | | 516 | 14 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 517 | | | 518 | 14 | sec->relocation = vars->reltab; | 519 | 14 | sec->reloc_count = vars->relcount; | 520 | 14 | sec->flags |= SEC_RELOC; | 521 | | | 522 | 14 | vars->reltab += vars->relcount; | 523 | 14 | vars->int_reltab += vars->relcount; | 524 | 14 | vars->relcount = 0; | 525 | | | 526 | 14 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 527 | 14 | } |
pei-aarch64.c:pe_ILF_save_relocs Line | Count | Source | 510 | 8 | { | 511 | | /* Make sure that there is somewhere to store the internal relocs. */ | 512 | 8 | if (coff_section_data (vars->abfd, sec) == NULL) | 513 | | /* We should probably return an error indication here. */ | 514 | 0 | abort (); | 515 | | | 516 | 8 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 517 | | | 518 | 8 | sec->relocation = vars->reltab; | 519 | 8 | sec->reloc_count = vars->relcount; | 520 | 8 | sec->flags |= SEC_RELOC; | 521 | | | 522 | 8 | vars->reltab += vars->relcount; | 523 | 8 | vars->int_reltab += vars->relcount; | 524 | 8 | vars->relcount = 0; | 525 | | | 526 | 8 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 527 | 8 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_save_relocs pei-loongarch64.c:pe_ILF_save_relocs Line | Count | Source | 510 | 10 | { | 511 | | /* Make sure that there is somewhere to store the internal relocs. */ | 512 | 10 | if (coff_section_data (vars->abfd, sec) == NULL) | 513 | | /* We should probably return an error indication here. */ | 514 | 0 | abort (); | 515 | | | 516 | 10 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 517 | | | 518 | 10 | sec->relocation = vars->reltab; | 519 | 10 | sec->reloc_count = vars->relcount; | 520 | 10 | sec->flags |= SEC_RELOC; | 521 | | | 522 | 10 | vars->reltab += vars->relcount; | 523 | 10 | vars->int_reltab += vars->relcount; | 524 | 10 | vars->relcount = 0; | 525 | | | 526 | 10 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 527 | 10 | } |
pei-arm-wince.c:pe_ILF_save_relocs Line | Count | Source | 510 | 12 | { | 511 | | /* Make sure that there is somewhere to store the internal relocs. */ | 512 | 12 | if (coff_section_data (vars->abfd, sec) == NULL) | 513 | | /* We should probably return an error indication here. */ | 514 | 0 | abort (); | 515 | | | 516 | 12 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 517 | | | 518 | 12 | sec->relocation = vars->reltab; | 519 | 12 | sec->reloc_count = vars->relcount; | 520 | 12 | sec->flags |= SEC_RELOC; | 521 | | | 522 | 12 | vars->reltab += vars->relcount; | 523 | 12 | vars->int_reltab += vars->relcount; | 524 | 12 | vars->relcount = 0; | 525 | | | 526 | 12 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 527 | 12 | } |
pei-arm.c:pe_ILF_save_relocs Line | Count | Source | 510 | 31 | { | 511 | | /* Make sure that there is somewhere to store the internal relocs. */ | 512 | 31 | if (coff_section_data (vars->abfd, sec) == NULL) | 513 | | /* We should probably return an error indication here. */ | 514 | 0 | abort (); | 515 | | | 516 | 31 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 517 | | | 518 | 31 | sec->relocation = vars->reltab; | 519 | 31 | sec->reloc_count = vars->relcount; | 520 | 31 | sec->flags |= SEC_RELOC; | 521 | | | 522 | 31 | vars->reltab += vars->relcount; | 523 | 31 | vars->int_reltab += vars->relcount; | 524 | 31 | vars->relcount = 0; | 525 | | | 526 | 31 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 527 | 31 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_save_relocs pei-sh.c:pe_ILF_save_relocs Line | Count | Source | 510 | 26 | { | 511 | | /* Make sure that there is somewhere to store the internal relocs. */ | 512 | 26 | if (coff_section_data (vars->abfd, sec) == NULL) | 513 | | /* We should probably return an error indication here. */ | 514 | 0 | abort (); | 515 | | | 516 | 26 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 517 | | | 518 | 26 | sec->relocation = vars->reltab; | 519 | 26 | sec->reloc_count = vars->relcount; | 520 | 26 | sec->flags |= SEC_RELOC; | 521 | | | 522 | 26 | vars->reltab += vars->relcount; | 523 | 26 | vars->int_reltab += vars->relcount; | 524 | 26 | vars->relcount = 0; | 525 | | | 526 | 26 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 527 | 26 | } |
|
528 | | |
529 | | /* Create a global symbol and add it to the relevant tables. */ |
530 | | |
531 | | static void |
532 | | pe_ILF_make_a_symbol (pe_ILF_vars * vars, |
533 | | const char * prefix, |
534 | | const char * symbol_name, |
535 | | asection_ptr section, |
536 | | flagword extra_flags) |
537 | 413 | { |
538 | 413 | coff_symbol_type * sym; |
539 | 413 | combined_entry_type * ent; |
540 | 413 | SYMENT * esym; |
541 | 413 | unsigned short sclass; |
542 | | |
543 | 413 | if (extra_flags & BSF_LOCAL) |
544 | 236 | sclass = C_STAT; |
545 | 177 | else |
546 | 177 | sclass = C_EXT; |
547 | | |
548 | | #ifdef THUMBPEMAGIC |
549 | 137 | if (vars->magic == THUMBPEMAGIC) |
550 | 65 | { |
551 | 65 | if (extra_flags & BSF_FUNCTION) |
552 | 7 | sclass = C_THUMBEXTFUNC; |
553 | 58 | else if (extra_flags & BSF_LOCAL) |
554 | 38 | sclass = C_THUMBSTAT; |
555 | 20 | else |
556 | 20 | sclass = C_THUMBEXT; |
557 | 65 | } |
558 | | #endif |
559 | | |
560 | 413 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); |
561 | | |
562 | 413 | sym = vars->sym_ptr; |
563 | 413 | ent = vars->native_ptr; |
564 | 413 | esym = vars->esym_ptr; |
565 | | |
566 | | /* Copy the symbol's name into the string table. */ |
567 | 413 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); |
568 | | |
569 | 413 | if (section == NULL) |
570 | 67 | section = bfd_und_section_ptr; |
571 | | |
572 | | /* Initialise the external symbol. */ |
573 | 413 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, |
574 | 413 | esym->e.e.e_offset); |
575 | 413 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); |
576 | 413 | esym->e_sclass[0] = sclass; |
577 | | |
578 | | /* The following initialisations are unnecessary - the memory is |
579 | | zero initialised. They are just kept here as reminders. */ |
580 | | |
581 | | /* Initialise the internal symbol structure. */ |
582 | 413 | ent->u.syment.n_sclass = sclass; |
583 | 413 | ent->u.syment.n_scnum = section->target_index; |
584 | 413 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; |
585 | 413 | ent->is_sym = true; |
586 | | |
587 | 413 | sym->symbol.the_bfd = vars->abfd; |
588 | 413 | sym->symbol.name = vars->string_ptr; |
589 | 413 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; |
590 | 413 | sym->symbol.section = section; |
591 | 413 | sym->native = ent; |
592 | | |
593 | 413 | * vars->table_ptr = vars->sym_index; |
594 | 413 | * vars->sym_ptr_ptr = sym; |
595 | | |
596 | | /* Adjust pointers for the next symbol. */ |
597 | 413 | vars->sym_index ++; |
598 | 413 | vars->sym_ptr ++; |
599 | 413 | vars->sym_ptr_ptr ++; |
600 | 413 | vars->table_ptr ++; |
601 | 413 | vars->native_ptr ++; |
602 | 413 | vars->esym_ptr ++; |
603 | 413 | vars->string_ptr += len + 1; |
604 | | |
605 | 413 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); |
606 | 413 | } pei-i386.c:pe_ILF_make_a_symbol Line | Count | Source | 537 | 64 | { | 538 | 64 | coff_symbol_type * sym; | 539 | 64 | combined_entry_type * ent; | 540 | 64 | SYMENT * esym; | 541 | 64 | unsigned short sclass; | 542 | | | 543 | 64 | if (extra_flags & BSF_LOCAL) | 544 | 36 | sclass = C_STAT; | 545 | 28 | else | 546 | 28 | sclass = C_EXT; | 547 | | | 548 | | #ifdef THUMBPEMAGIC | 549 | | if (vars->magic == THUMBPEMAGIC) | 550 | | { | 551 | | if (extra_flags & BSF_FUNCTION) | 552 | | sclass = C_THUMBEXTFUNC; | 553 | | else if (extra_flags & BSF_LOCAL) | 554 | | sclass = C_THUMBSTAT; | 555 | | else | 556 | | sclass = C_THUMBEXT; | 557 | | } | 558 | | #endif | 559 | | | 560 | 64 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 561 | | | 562 | 64 | sym = vars->sym_ptr; | 563 | 64 | ent = vars->native_ptr; | 564 | 64 | esym = vars->esym_ptr; | 565 | | | 566 | | /* Copy the symbol's name into the string table. */ | 567 | 64 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 568 | | | 569 | 64 | if (section == NULL) | 570 | 10 | section = bfd_und_section_ptr; | 571 | | | 572 | | /* Initialise the external symbol. */ | 573 | 64 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 574 | 64 | esym->e.e.e_offset); | 575 | 64 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 576 | 64 | esym->e_sclass[0] = sclass; | 577 | | | 578 | | /* The following initialisations are unnecessary - the memory is | 579 | | zero initialised. They are just kept here as reminders. */ | 580 | | | 581 | | /* Initialise the internal symbol structure. */ | 582 | 64 | ent->u.syment.n_sclass = sclass; | 583 | 64 | ent->u.syment.n_scnum = section->target_index; | 584 | 64 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 585 | 64 | ent->is_sym = true; | 586 | | | 587 | 64 | sym->symbol.the_bfd = vars->abfd; | 588 | 64 | sym->symbol.name = vars->string_ptr; | 589 | 64 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 590 | 64 | sym->symbol.section = section; | 591 | 64 | sym->native = ent; | 592 | | | 593 | 64 | * vars->table_ptr = vars->sym_index; | 594 | 64 | * vars->sym_ptr_ptr = sym; | 595 | | | 596 | | /* Adjust pointers for the next symbol. */ | 597 | 64 | vars->sym_index ++; | 598 | 64 | vars->sym_ptr ++; | 599 | 64 | vars->sym_ptr_ptr ++; | 600 | 64 | vars->table_ptr ++; | 601 | 64 | vars->native_ptr ++; | 602 | 64 | vars->esym_ptr ++; | 603 | 64 | vars->string_ptr += len + 1; | 604 | | | 605 | 64 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 606 | 64 | } |
pei-x86_64.c:pe_ILF_make_a_symbol Line | Count | Source | 537 | 43 | { | 538 | 43 | coff_symbol_type * sym; | 539 | 43 | combined_entry_type * ent; | 540 | 43 | SYMENT * esym; | 541 | 43 | unsigned short sclass; | 542 | | | 543 | 43 | if (extra_flags & BSF_LOCAL) | 544 | 25 | sclass = C_STAT; | 545 | 18 | else | 546 | 18 | sclass = C_EXT; | 547 | | | 548 | | #ifdef THUMBPEMAGIC | 549 | | if (vars->magic == THUMBPEMAGIC) | 550 | | { | 551 | | if (extra_flags & BSF_FUNCTION) | 552 | | sclass = C_THUMBEXTFUNC; | 553 | | else if (extra_flags & BSF_LOCAL) | 554 | | sclass = C_THUMBSTAT; | 555 | | else | 556 | | sclass = C_THUMBEXT; | 557 | | } | 558 | | #endif | 559 | | | 560 | 43 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 561 | | | 562 | 43 | sym = vars->sym_ptr; | 563 | 43 | ent = vars->native_ptr; | 564 | 43 | esym = vars->esym_ptr; | 565 | | | 566 | | /* Copy the symbol's name into the string table. */ | 567 | 43 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 568 | | | 569 | 43 | if (section == NULL) | 570 | 7 | section = bfd_und_section_ptr; | 571 | | | 572 | | /* Initialise the external symbol. */ | 573 | 43 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 574 | 43 | esym->e.e.e_offset); | 575 | 43 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 576 | 43 | esym->e_sclass[0] = sclass; | 577 | | | 578 | | /* The following initialisations are unnecessary - the memory is | 579 | | zero initialised. They are just kept here as reminders. */ | 580 | | | 581 | | /* Initialise the internal symbol structure. */ | 582 | 43 | ent->u.syment.n_sclass = sclass; | 583 | 43 | ent->u.syment.n_scnum = section->target_index; | 584 | 43 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 585 | 43 | ent->is_sym = true; | 586 | | | 587 | 43 | sym->symbol.the_bfd = vars->abfd; | 588 | 43 | sym->symbol.name = vars->string_ptr; | 589 | 43 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 590 | 43 | sym->symbol.section = section; | 591 | 43 | sym->native = ent; | 592 | | | 593 | 43 | * vars->table_ptr = vars->sym_index; | 594 | 43 | * vars->sym_ptr_ptr = sym; | 595 | | | 596 | | /* Adjust pointers for the next symbol. */ | 597 | 43 | vars->sym_index ++; | 598 | 43 | vars->sym_ptr ++; | 599 | 43 | vars->sym_ptr_ptr ++; | 600 | 43 | vars->table_ptr ++; | 601 | 43 | vars->native_ptr ++; | 602 | 43 | vars->esym_ptr ++; | 603 | 43 | vars->string_ptr += len + 1; | 604 | | | 605 | 43 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 606 | 43 | } |
pei-aarch64.c:pe_ILF_make_a_symbol Line | Count | Source | 537 | 32 | { | 538 | 32 | coff_symbol_type * sym; | 539 | 32 | combined_entry_type * ent; | 540 | 32 | SYMENT * esym; | 541 | 32 | unsigned short sclass; | 542 | | | 543 | 32 | if (extra_flags & BSF_LOCAL) | 544 | 18 | sclass = C_STAT; | 545 | 14 | else | 546 | 14 | sclass = C_EXT; | 547 | | | 548 | | #ifdef THUMBPEMAGIC | 549 | | if (vars->magic == THUMBPEMAGIC) | 550 | | { | 551 | | if (extra_flags & BSF_FUNCTION) | 552 | | sclass = C_THUMBEXTFUNC; | 553 | | else if (extra_flags & BSF_LOCAL) | 554 | | sclass = C_THUMBSTAT; | 555 | | else | 556 | | sclass = C_THUMBEXT; | 557 | | } | 558 | | #endif | 559 | | | 560 | 32 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 561 | | | 562 | 32 | sym = vars->sym_ptr; | 563 | 32 | ent = vars->native_ptr; | 564 | 32 | esym = vars->esym_ptr; | 565 | | | 566 | | /* Copy the symbol's name into the string table. */ | 567 | 32 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 568 | | | 569 | 32 | if (section == NULL) | 570 | 5 | section = bfd_und_section_ptr; | 571 | | | 572 | | /* Initialise the external symbol. */ | 573 | 32 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 574 | 32 | esym->e.e.e_offset); | 575 | 32 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 576 | 32 | esym->e_sclass[0] = sclass; | 577 | | | 578 | | /* The following initialisations are unnecessary - the memory is | 579 | | zero initialised. They are just kept here as reminders. */ | 580 | | | 581 | | /* Initialise the internal symbol structure. */ | 582 | 32 | ent->u.syment.n_sclass = sclass; | 583 | 32 | ent->u.syment.n_scnum = section->target_index; | 584 | 32 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 585 | 32 | ent->is_sym = true; | 586 | | | 587 | 32 | sym->symbol.the_bfd = vars->abfd; | 588 | 32 | sym->symbol.name = vars->string_ptr; | 589 | 32 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 590 | 32 | sym->symbol.section = section; | 591 | 32 | sym->native = ent; | 592 | | | 593 | 32 | * vars->table_ptr = vars->sym_index; | 594 | 32 | * vars->sym_ptr_ptr = sym; | 595 | | | 596 | | /* Adjust pointers for the next symbol. */ | 597 | 32 | vars->sym_index ++; | 598 | 32 | vars->sym_ptr ++; | 599 | 32 | vars->sym_ptr_ptr ++; | 600 | 32 | vars->table_ptr ++; | 601 | 32 | vars->native_ptr ++; | 602 | 32 | vars->esym_ptr ++; | 603 | 32 | vars->string_ptr += len + 1; | 604 | | | 605 | 32 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 606 | 32 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_symbol pei-loongarch64.c:pe_ILF_make_a_symbol Line | Count | Source | 537 | 32 | { | 538 | 32 | coff_symbol_type * sym; | 539 | 32 | combined_entry_type * ent; | 540 | 32 | SYMENT * esym; | 541 | 32 | unsigned short sclass; | 542 | | | 543 | 32 | if (extra_flags & BSF_LOCAL) | 544 | 18 | sclass = C_STAT; | 545 | 14 | else | 546 | 14 | sclass = C_EXT; | 547 | | | 548 | | #ifdef THUMBPEMAGIC | 549 | | if (vars->magic == THUMBPEMAGIC) | 550 | | { | 551 | | if (extra_flags & BSF_FUNCTION) | 552 | | sclass = C_THUMBEXTFUNC; | 553 | | else if (extra_flags & BSF_LOCAL) | 554 | | sclass = C_THUMBSTAT; | 555 | | else | 556 | | sclass = C_THUMBEXT; | 557 | | } | 558 | | #endif | 559 | | | 560 | 32 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 561 | | | 562 | 32 | sym = vars->sym_ptr; | 563 | 32 | ent = vars->native_ptr; | 564 | 32 | esym = vars->esym_ptr; | 565 | | | 566 | | /* Copy the symbol's name into the string table. */ | 567 | 32 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 568 | | | 569 | 32 | if (section == NULL) | 570 | 6 | section = bfd_und_section_ptr; | 571 | | | 572 | | /* Initialise the external symbol. */ | 573 | 32 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 574 | 32 | esym->e.e.e_offset); | 575 | 32 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 576 | 32 | esym->e_sclass[0] = sclass; | 577 | | | 578 | | /* The following initialisations are unnecessary - the memory is | 579 | | zero initialised. They are just kept here as reminders. */ | 580 | | | 581 | | /* Initialise the internal symbol structure. */ | 582 | 32 | ent->u.syment.n_sclass = sclass; | 583 | 32 | ent->u.syment.n_scnum = section->target_index; | 584 | 32 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 585 | 32 | ent->is_sym = true; | 586 | | | 587 | 32 | sym->symbol.the_bfd = vars->abfd; | 588 | 32 | sym->symbol.name = vars->string_ptr; | 589 | 32 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 590 | 32 | sym->symbol.section = section; | 591 | 32 | sym->native = ent; | 592 | | | 593 | 32 | * vars->table_ptr = vars->sym_index; | 594 | 32 | * vars->sym_ptr_ptr = sym; | 595 | | | 596 | | /* Adjust pointers for the next symbol. */ | 597 | 32 | vars->sym_index ++; | 598 | 32 | vars->sym_ptr ++; | 599 | 32 | vars->sym_ptr_ptr ++; | 600 | 32 | vars->table_ptr ++; | 601 | 32 | vars->native_ptr ++; | 602 | 32 | vars->esym_ptr ++; | 603 | 32 | vars->string_ptr += len + 1; | 604 | | | 605 | 32 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 606 | 32 | } |
pei-arm-wince.c:pe_ILF_make_a_symbol Line | Count | Source | 537 | 44 | { | 538 | 44 | coff_symbol_type * sym; | 539 | 44 | combined_entry_type * ent; | 540 | 44 | SYMENT * esym; | 541 | 44 | unsigned short sclass; | 542 | | | 543 | 44 | if (extra_flags & BSF_LOCAL) | 544 | 26 | sclass = C_STAT; | 545 | 18 | else | 546 | 18 | sclass = C_EXT; | 547 | | | 548 | 44 | #ifdef THUMBPEMAGIC | 549 | 44 | if (vars->magic == THUMBPEMAGIC) | 550 | 8 | { | 551 | 8 | if (extra_flags & BSF_FUNCTION) | 552 | 1 | sclass = C_THUMBEXTFUNC; | 553 | 7 | else if (extra_flags & BSF_LOCAL) | 554 | 5 | sclass = C_THUMBSTAT; | 555 | 2 | else | 556 | 2 | sclass = C_THUMBEXT; | 557 | 8 | } | 558 | 44 | #endif | 559 | | | 560 | 44 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 561 | | | 562 | 44 | sym = vars->sym_ptr; | 563 | 44 | ent = vars->native_ptr; | 564 | 44 | esym = vars->esym_ptr; | 565 | | | 566 | | /* Copy the symbol's name into the string table. */ | 567 | 44 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 568 | | | 569 | 44 | if (section == NULL) | 570 | 7 | section = bfd_und_section_ptr; | 571 | | | 572 | | /* Initialise the external symbol. */ | 573 | 44 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 574 | 44 | esym->e.e.e_offset); | 575 | 44 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 576 | 44 | esym->e_sclass[0] = sclass; | 577 | | | 578 | | /* The following initialisations are unnecessary - the memory is | 579 | | zero initialised. They are just kept here as reminders. */ | 580 | | | 581 | | /* Initialise the internal symbol structure. */ | 582 | 44 | ent->u.syment.n_sclass = sclass; | 583 | 44 | ent->u.syment.n_scnum = section->target_index; | 584 | 44 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 585 | 44 | ent->is_sym = true; | 586 | | | 587 | 44 | sym->symbol.the_bfd = vars->abfd; | 588 | 44 | sym->symbol.name = vars->string_ptr; | 589 | 44 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 590 | 44 | sym->symbol.section = section; | 591 | 44 | sym->native = ent; | 592 | | | 593 | 44 | * vars->table_ptr = vars->sym_index; | 594 | 44 | * vars->sym_ptr_ptr = sym; | 595 | | | 596 | | /* Adjust pointers for the next symbol. */ | 597 | 44 | vars->sym_index ++; | 598 | 44 | vars->sym_ptr ++; | 599 | 44 | vars->sym_ptr_ptr ++; | 600 | 44 | vars->table_ptr ++; | 601 | 44 | vars->native_ptr ++; | 602 | 44 | vars->esym_ptr ++; | 603 | 44 | vars->string_ptr += len + 1; | 604 | | | 605 | 44 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 606 | 44 | } |
pei-arm.c:pe_ILF_make_a_symbol Line | Count | Source | 537 | 93 | { | 538 | 93 | coff_symbol_type * sym; | 539 | 93 | combined_entry_type * ent; | 540 | 93 | SYMENT * esym; | 541 | 93 | unsigned short sclass; | 542 | | | 543 | 93 | if (extra_flags & BSF_LOCAL) | 544 | 54 | sclass = C_STAT; | 545 | 39 | else | 546 | 39 | sclass = C_EXT; | 547 | | | 548 | 93 | #ifdef THUMBPEMAGIC | 549 | 93 | if (vars->magic == THUMBPEMAGIC) | 550 | 57 | { | 551 | 57 | if (extra_flags & BSF_FUNCTION) | 552 | 6 | sclass = C_THUMBEXTFUNC; | 553 | 51 | else if (extra_flags & BSF_LOCAL) | 554 | 33 | sclass = C_THUMBSTAT; | 555 | 18 | else | 556 | 18 | sclass = C_THUMBEXT; | 557 | 57 | } | 558 | 93 | #endif | 559 | | | 560 | 93 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 561 | | | 562 | 93 | sym = vars->sym_ptr; | 563 | 93 | ent = vars->native_ptr; | 564 | 93 | esym = vars->esym_ptr; | 565 | | | 566 | | /* Copy the symbol's name into the string table. */ | 567 | 93 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 568 | | | 569 | 93 | if (section == NULL) | 570 | 15 | section = bfd_und_section_ptr; | 571 | | | 572 | | /* Initialise the external symbol. */ | 573 | 93 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 574 | 93 | esym->e.e.e_offset); | 575 | 93 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 576 | 93 | esym->e_sclass[0] = sclass; | 577 | | | 578 | | /* The following initialisations are unnecessary - the memory is | 579 | | zero initialised. They are just kept here as reminders. */ | 580 | | | 581 | | /* Initialise the internal symbol structure. */ | 582 | 93 | ent->u.syment.n_sclass = sclass; | 583 | 93 | ent->u.syment.n_scnum = section->target_index; | 584 | 93 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 585 | 93 | ent->is_sym = true; | 586 | | | 587 | 93 | sym->symbol.the_bfd = vars->abfd; | 588 | 93 | sym->symbol.name = vars->string_ptr; | 589 | 93 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 590 | 93 | sym->symbol.section = section; | 591 | 93 | sym->native = ent; | 592 | | | 593 | 93 | * vars->table_ptr = vars->sym_index; | 594 | 93 | * vars->sym_ptr_ptr = sym; | 595 | | | 596 | | /* Adjust pointers for the next symbol. */ | 597 | 93 | vars->sym_index ++; | 598 | 93 | vars->sym_ptr ++; | 599 | 93 | vars->sym_ptr_ptr ++; | 600 | 93 | vars->table_ptr ++; | 601 | 93 | vars->native_ptr ++; | 602 | 93 | vars->esym_ptr ++; | 603 | 93 | vars->string_ptr += len + 1; | 604 | | | 605 | 93 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 606 | 93 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_symbol pei-sh.c:pe_ILF_make_a_symbol Line | Count | Source | 537 | 105 | { | 538 | 105 | coff_symbol_type * sym; | 539 | 105 | combined_entry_type * ent; | 540 | 105 | SYMENT * esym; | 541 | 105 | unsigned short sclass; | 542 | | | 543 | 105 | if (extra_flags & BSF_LOCAL) | 544 | 59 | sclass = C_STAT; | 545 | 46 | else | 546 | 46 | sclass = C_EXT; | 547 | | | 548 | | #ifdef THUMBPEMAGIC | 549 | | if (vars->magic == THUMBPEMAGIC) | 550 | | { | 551 | | if (extra_flags & BSF_FUNCTION) | 552 | | sclass = C_THUMBEXTFUNC; | 553 | | else if (extra_flags & BSF_LOCAL) | 554 | | sclass = C_THUMBSTAT; | 555 | | else | 556 | | sclass = C_THUMBEXT; | 557 | | } | 558 | | #endif | 559 | | | 560 | 105 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 561 | | | 562 | 105 | sym = vars->sym_ptr; | 563 | 105 | ent = vars->native_ptr; | 564 | 105 | esym = vars->esym_ptr; | 565 | | | 566 | | /* Copy the symbol's name into the string table. */ | 567 | 105 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 568 | | | 569 | 105 | if (section == NULL) | 570 | 17 | section = bfd_und_section_ptr; | 571 | | | 572 | | /* Initialise the external symbol. */ | 573 | 105 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 574 | 105 | esym->e.e.e_offset); | 575 | 105 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 576 | 105 | esym->e_sclass[0] = sclass; | 577 | | | 578 | | /* The following initialisations are unnecessary - the memory is | 579 | | zero initialised. They are just kept here as reminders. */ | 580 | | | 581 | | /* Initialise the internal symbol structure. */ | 582 | 105 | ent->u.syment.n_sclass = sclass; | 583 | 105 | ent->u.syment.n_scnum = section->target_index; | 584 | 105 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 585 | 105 | ent->is_sym = true; | 586 | | | 587 | 105 | sym->symbol.the_bfd = vars->abfd; | 588 | 105 | sym->symbol.name = vars->string_ptr; | 589 | 105 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 590 | 105 | sym->symbol.section = section; | 591 | 105 | sym->native = ent; | 592 | | | 593 | 105 | * vars->table_ptr = vars->sym_index; | 594 | 105 | * vars->sym_ptr_ptr = sym; | 595 | | | 596 | | /* Adjust pointers for the next symbol. */ | 597 | 105 | vars->sym_index ++; | 598 | 105 | vars->sym_ptr ++; | 599 | 105 | vars->sym_ptr_ptr ++; | 600 | 105 | vars->table_ptr ++; | 601 | 105 | vars->native_ptr ++; | 602 | 105 | vars->esym_ptr ++; | 603 | 105 | vars->string_ptr += len + 1; | 604 | | | 605 | 105 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 606 | 105 | } |
|
607 | | |
608 | | /* Create a section. */ |
609 | | |
610 | | static asection_ptr |
611 | | pe_ILF_make_a_section (pe_ILF_vars * vars, |
612 | | const char * name, |
613 | | unsigned int size, |
614 | | flagword extra_flags) |
615 | 236 | { |
616 | 236 | asection_ptr sec; |
617 | 236 | flagword flags; |
618 | 236 | intptr_t alignment; |
619 | | |
620 | 236 | sec = bfd_make_section_old_way (vars->abfd, name); |
621 | 236 | if (sec == NULL) |
622 | 0 | return NULL; |
623 | | |
624 | 236 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; |
625 | | |
626 | 236 | bfd_set_section_flags (sec, flags | extra_flags); |
627 | | |
628 | 236 | bfd_set_section_alignment (sec, 2); |
629 | | |
630 | | /* Check that we will not run out of space. */ |
631 | 236 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); |
632 | | |
633 | | /* Set the section size and contents. The actual |
634 | | contents are filled in by our parent. */ |
635 | 236 | bfd_set_section_size (sec, (bfd_size_type) size); |
636 | 236 | sec->contents = vars->data; |
637 | 236 | sec->target_index = vars->sec_index ++; |
638 | | |
639 | | /* Advance data pointer in the vars structure. */ |
640 | 236 | vars->data += size; |
641 | | |
642 | | /* Skip the padding byte if it was not needed. |
643 | | The logic here is that if the string length is odd, |
644 | | then the entire string length, including the null byte, |
645 | | is even and so the extra, padding byte, is not needed. */ |
646 | 236 | if (size & 1) |
647 | 16 | vars->data --; |
648 | | |
649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we |
650 | | preserve host alignment requirements. The BFD_ASSERTs in this |
651 | | functions will warn us if we run out of room, but we should |
652 | | already have enough padding built in to ILF_DATA_SIZE. */ |
653 | 236 | #if GCC_VERSION >= 3000 |
654 | 236 | alignment = __alignof__ (struct coff_section_tdata); |
655 | | #else |
656 | | alignment = 8; |
657 | | #endif |
658 | 236 | vars->data |
659 | 236 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); |
660 | | |
661 | | /* Create a coff_section_tdata structure for our use. */ |
662 | 236 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; |
663 | 236 | vars->data += sizeof (struct coff_section_tdata); |
664 | | |
665 | 236 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); |
666 | | |
667 | | /* Create a symbol to refer to this section. */ |
668 | 236 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); |
669 | | |
670 | | /* Cache the index to the symbol in the coff_section_data structure. */ |
671 | 236 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; |
672 | | |
673 | 236 | return sec; |
674 | 236 | } pei-i386.c:pe_ILF_make_a_section Line | Count | Source | 615 | 36 | { | 616 | 36 | asection_ptr sec; | 617 | 36 | flagword flags; | 618 | 36 | intptr_t alignment; | 619 | | | 620 | 36 | sec = bfd_make_section_old_way (vars->abfd, name); | 621 | 36 | if (sec == NULL) | 622 | 0 | return NULL; | 623 | | | 624 | 36 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 625 | | | 626 | 36 | bfd_set_section_flags (sec, flags | extra_flags); | 627 | | | 628 | 36 | bfd_set_section_alignment (sec, 2); | 629 | | | 630 | | /* Check that we will not run out of space. */ | 631 | 36 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 632 | | | 633 | | /* Set the section size and contents. The actual | 634 | | contents are filled in by our parent. */ | 635 | 36 | bfd_set_section_size (sec, (bfd_size_type) size); | 636 | 36 | sec->contents = vars->data; | 637 | 36 | sec->target_index = vars->sec_index ++; | 638 | | | 639 | | /* Advance data pointer in the vars structure. */ | 640 | 36 | vars->data += size; | 641 | | | 642 | | /* Skip the padding byte if it was not needed. | 643 | | The logic here is that if the string length is odd, | 644 | | then the entire string length, including the null byte, | 645 | | is even and so the extra, padding byte, is not needed. */ | 646 | 36 | if (size & 1) | 647 | 3 | vars->data --; | 648 | | | 649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 650 | | preserve host alignment requirements. The BFD_ASSERTs in this | 651 | | functions will warn us if we run out of room, but we should | 652 | | already have enough padding built in to ILF_DATA_SIZE. */ | 653 | 36 | #if GCC_VERSION >= 3000 | 654 | 36 | alignment = __alignof__ (struct coff_section_tdata); | 655 | | #else | 656 | | alignment = 8; | 657 | | #endif | 658 | 36 | vars->data | 659 | 36 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 660 | | | 661 | | /* Create a coff_section_tdata structure for our use. */ | 662 | 36 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 663 | 36 | vars->data += sizeof (struct coff_section_tdata); | 664 | | | 665 | 36 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 666 | | | 667 | | /* Create a symbol to refer to this section. */ | 668 | 36 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 669 | | | 670 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 671 | 36 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 672 | | | 673 | 36 | return sec; | 674 | 36 | } |
pei-x86_64.c:pe_ILF_make_a_section Line | Count | Source | 615 | 25 | { | 616 | 25 | asection_ptr sec; | 617 | 25 | flagword flags; | 618 | 25 | intptr_t alignment; | 619 | | | 620 | 25 | sec = bfd_make_section_old_way (vars->abfd, name); | 621 | 25 | if (sec == NULL) | 622 | 0 | return NULL; | 623 | | | 624 | 25 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 625 | | | 626 | 25 | bfd_set_section_flags (sec, flags | extra_flags); | 627 | | | 628 | 25 | bfd_set_section_alignment (sec, 2); | 629 | | | 630 | | /* Check that we will not run out of space. */ | 631 | 25 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 632 | | | 633 | | /* Set the section size and contents. The actual | 634 | | contents are filled in by our parent. */ | 635 | 25 | bfd_set_section_size (sec, (bfd_size_type) size); | 636 | 25 | sec->contents = vars->data; | 637 | 25 | sec->target_index = vars->sec_index ++; | 638 | | | 639 | | /* Advance data pointer in the vars structure. */ | 640 | 25 | vars->data += size; | 641 | | | 642 | | /* Skip the padding byte if it was not needed. | 643 | | The logic here is that if the string length is odd, | 644 | | then the entire string length, including the null byte, | 645 | | is even and so the extra, padding byte, is not needed. */ | 646 | 25 | if (size & 1) | 647 | 3 | vars->data --; | 648 | | | 649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 650 | | preserve host alignment requirements. The BFD_ASSERTs in this | 651 | | functions will warn us if we run out of room, but we should | 652 | | already have enough padding built in to ILF_DATA_SIZE. */ | 653 | 25 | #if GCC_VERSION >= 3000 | 654 | 25 | alignment = __alignof__ (struct coff_section_tdata); | 655 | | #else | 656 | | alignment = 8; | 657 | | #endif | 658 | 25 | vars->data | 659 | 25 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 660 | | | 661 | | /* Create a coff_section_tdata structure for our use. */ | 662 | 25 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 663 | 25 | vars->data += sizeof (struct coff_section_tdata); | 664 | | | 665 | 25 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 666 | | | 667 | | /* Create a symbol to refer to this section. */ | 668 | 25 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 669 | | | 670 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 671 | 25 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 672 | | | 673 | 25 | return sec; | 674 | 25 | } |
pei-aarch64.c:pe_ILF_make_a_section Line | Count | Source | 615 | 18 | { | 616 | 18 | asection_ptr sec; | 617 | 18 | flagword flags; | 618 | 18 | intptr_t alignment; | 619 | | | 620 | 18 | sec = bfd_make_section_old_way (vars->abfd, name); | 621 | 18 | if (sec == NULL) | 622 | 0 | return NULL; | 623 | | | 624 | 18 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 625 | | | 626 | 18 | bfd_set_section_flags (sec, flags | extra_flags); | 627 | | | 628 | 18 | bfd_set_section_alignment (sec, 2); | 629 | | | 630 | | /* Check that we will not run out of space. */ | 631 | 18 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 632 | | | 633 | | /* Set the section size and contents. The actual | 634 | | contents are filled in by our parent. */ | 635 | 18 | bfd_set_section_size (sec, (bfd_size_type) size); | 636 | 18 | sec->contents = vars->data; | 637 | 18 | sec->target_index = vars->sec_index ++; | 638 | | | 639 | | /* Advance data pointer in the vars structure. */ | 640 | 18 | vars->data += size; | 641 | | | 642 | | /* Skip the padding byte if it was not needed. | 643 | | The logic here is that if the string length is odd, | 644 | | then the entire string length, including the null byte, | 645 | | is even and so the extra, padding byte, is not needed. */ | 646 | 18 | if (size & 1) | 647 | 1 | vars->data --; | 648 | | | 649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 650 | | preserve host alignment requirements. The BFD_ASSERTs in this | 651 | | functions will warn us if we run out of room, but we should | 652 | | already have enough padding built in to ILF_DATA_SIZE. */ | 653 | 18 | #if GCC_VERSION >= 3000 | 654 | 18 | alignment = __alignof__ (struct coff_section_tdata); | 655 | | #else | 656 | | alignment = 8; | 657 | | #endif | 658 | 18 | vars->data | 659 | 18 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 660 | | | 661 | | /* Create a coff_section_tdata structure for our use. */ | 662 | 18 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 663 | 18 | vars->data += sizeof (struct coff_section_tdata); | 664 | | | 665 | 18 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 666 | | | 667 | | /* Create a symbol to refer to this section. */ | 668 | 18 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 669 | | | 670 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 671 | 18 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 672 | | | 673 | 18 | return sec; | 674 | 18 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_section pei-loongarch64.c:pe_ILF_make_a_section Line | Count | Source | 615 | 18 | { | 616 | 18 | asection_ptr sec; | 617 | 18 | flagword flags; | 618 | 18 | intptr_t alignment; | 619 | | | 620 | 18 | sec = bfd_make_section_old_way (vars->abfd, name); | 621 | 18 | if (sec == NULL) | 622 | 0 | return NULL; | 623 | | | 624 | 18 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 625 | | | 626 | 18 | bfd_set_section_flags (sec, flags | extra_flags); | 627 | | | 628 | 18 | bfd_set_section_alignment (sec, 2); | 629 | | | 630 | | /* Check that we will not run out of space. */ | 631 | 18 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 632 | | | 633 | | /* Set the section size and contents. The actual | 634 | | contents are filled in by our parent. */ | 635 | 18 | bfd_set_section_size (sec, (bfd_size_type) size); | 636 | 18 | sec->contents = vars->data; | 637 | 18 | sec->target_index = vars->sec_index ++; | 638 | | | 639 | | /* Advance data pointer in the vars structure. */ | 640 | 18 | vars->data += size; | 641 | | | 642 | | /* Skip the padding byte if it was not needed. | 643 | | The logic here is that if the string length is odd, | 644 | | then the entire string length, including the null byte, | 645 | | is even and so the extra, padding byte, is not needed. */ | 646 | 18 | if (size & 1) | 647 | 1 | vars->data --; | 648 | | | 649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 650 | | preserve host alignment requirements. The BFD_ASSERTs in this | 651 | | functions will warn us if we run out of room, but we should | 652 | | already have enough padding built in to ILF_DATA_SIZE. */ | 653 | 18 | #if GCC_VERSION >= 3000 | 654 | 18 | alignment = __alignof__ (struct coff_section_tdata); | 655 | | #else | 656 | | alignment = 8; | 657 | | #endif | 658 | 18 | vars->data | 659 | 18 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 660 | | | 661 | | /* Create a coff_section_tdata structure for our use. */ | 662 | 18 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 663 | 18 | vars->data += sizeof (struct coff_section_tdata); | 664 | | | 665 | 18 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 666 | | | 667 | | /* Create a symbol to refer to this section. */ | 668 | 18 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 669 | | | 670 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 671 | 18 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 672 | | | 673 | 18 | return sec; | 674 | 18 | } |
pei-arm-wince.c:pe_ILF_make_a_section Line | Count | Source | 615 | 26 | { | 616 | 26 | asection_ptr sec; | 617 | 26 | flagword flags; | 618 | 26 | intptr_t alignment; | 619 | | | 620 | 26 | sec = bfd_make_section_old_way (vars->abfd, name); | 621 | 26 | if (sec == NULL) | 622 | 0 | return NULL; | 623 | | | 624 | 26 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 625 | | | 626 | 26 | bfd_set_section_flags (sec, flags | extra_flags); | 627 | | | 628 | 26 | bfd_set_section_alignment (sec, 2); | 629 | | | 630 | | /* Check that we will not run out of space. */ | 631 | 26 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 632 | | | 633 | | /* Set the section size and contents. The actual | 634 | | contents are filled in by our parent. */ | 635 | 26 | bfd_set_section_size (sec, (bfd_size_type) size); | 636 | 26 | sec->contents = vars->data; | 637 | 26 | sec->target_index = vars->sec_index ++; | 638 | | | 639 | | /* Advance data pointer in the vars structure. */ | 640 | 26 | vars->data += size; | 641 | | | 642 | | /* Skip the padding byte if it was not needed. | 643 | | The logic here is that if the string length is odd, | 644 | | then the entire string length, including the null byte, | 645 | | is even and so the extra, padding byte, is not needed. */ | 646 | 26 | if (size & 1) | 647 | 2 | vars->data --; | 648 | | | 649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 650 | | preserve host alignment requirements. The BFD_ASSERTs in this | 651 | | functions will warn us if we run out of room, but we should | 652 | | already have enough padding built in to ILF_DATA_SIZE. */ | 653 | 26 | #if GCC_VERSION >= 3000 | 654 | 26 | alignment = __alignof__ (struct coff_section_tdata); | 655 | | #else | 656 | | alignment = 8; | 657 | | #endif | 658 | 26 | vars->data | 659 | 26 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 660 | | | 661 | | /* Create a coff_section_tdata structure for our use. */ | 662 | 26 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 663 | 26 | vars->data += sizeof (struct coff_section_tdata); | 664 | | | 665 | 26 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 666 | | | 667 | | /* Create a symbol to refer to this section. */ | 668 | 26 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 669 | | | 670 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 671 | 26 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 672 | | | 673 | 26 | return sec; | 674 | 26 | } |
pei-arm.c:pe_ILF_make_a_section Line | Count | Source | 615 | 54 | { | 616 | 54 | asection_ptr sec; | 617 | 54 | flagword flags; | 618 | 54 | intptr_t alignment; | 619 | | | 620 | 54 | sec = bfd_make_section_old_way (vars->abfd, name); | 621 | 54 | if (sec == NULL) | 622 | 0 | return NULL; | 623 | | | 624 | 54 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 625 | | | 626 | 54 | bfd_set_section_flags (sec, flags | extra_flags); | 627 | | | 628 | 54 | bfd_set_section_alignment (sec, 2); | 629 | | | 630 | | /* Check that we will not run out of space. */ | 631 | 54 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 632 | | | 633 | | /* Set the section size and contents. The actual | 634 | | contents are filled in by our parent. */ | 635 | 54 | bfd_set_section_size (sec, (bfd_size_type) size); | 636 | 54 | sec->contents = vars->data; | 637 | 54 | sec->target_index = vars->sec_index ++; | 638 | | | 639 | | /* Advance data pointer in the vars structure. */ | 640 | 54 | vars->data += size; | 641 | | | 642 | | /* Skip the padding byte if it was not needed. | 643 | | The logic here is that if the string length is odd, | 644 | | then the entire string length, including the null byte, | 645 | | is even and so the extra, padding byte, is not needed. */ | 646 | 54 | if (size & 1) | 647 | 2 | vars->data --; | 648 | | | 649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 650 | | preserve host alignment requirements. The BFD_ASSERTs in this | 651 | | functions will warn us if we run out of room, but we should | 652 | | already have enough padding built in to ILF_DATA_SIZE. */ | 653 | 54 | #if GCC_VERSION >= 3000 | 654 | 54 | alignment = __alignof__ (struct coff_section_tdata); | 655 | | #else | 656 | | alignment = 8; | 657 | | #endif | 658 | 54 | vars->data | 659 | 54 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 660 | | | 661 | | /* Create a coff_section_tdata structure for our use. */ | 662 | 54 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 663 | 54 | vars->data += sizeof (struct coff_section_tdata); | 664 | | | 665 | 54 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 666 | | | 667 | | /* Create a symbol to refer to this section. */ | 668 | 54 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 669 | | | 670 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 671 | 54 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 672 | | | 673 | 54 | return sec; | 674 | 54 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_section pei-sh.c:pe_ILF_make_a_section Line | Count | Source | 615 | 59 | { | 616 | 59 | asection_ptr sec; | 617 | 59 | flagword flags; | 618 | 59 | intptr_t alignment; | 619 | | | 620 | 59 | sec = bfd_make_section_old_way (vars->abfd, name); | 621 | 59 | if (sec == NULL) | 622 | 0 | return NULL; | 623 | | | 624 | 59 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 625 | | | 626 | 59 | bfd_set_section_flags (sec, flags | extra_flags); | 627 | | | 628 | 59 | bfd_set_section_alignment (sec, 2); | 629 | | | 630 | | /* Check that we will not run out of space. */ | 631 | 59 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 632 | | | 633 | | /* Set the section size and contents. The actual | 634 | | contents are filled in by our parent. */ | 635 | 59 | bfd_set_section_size (sec, (bfd_size_type) size); | 636 | 59 | sec->contents = vars->data; | 637 | 59 | sec->target_index = vars->sec_index ++; | 638 | | | 639 | | /* Advance data pointer in the vars structure. */ | 640 | 59 | vars->data += size; | 641 | | | 642 | | /* Skip the padding byte if it was not needed. | 643 | | The logic here is that if the string length is odd, | 644 | | then the entire string length, including the null byte, | 645 | | is even and so the extra, padding byte, is not needed. */ | 646 | 59 | if (size & 1) | 647 | 4 | vars->data --; | 648 | | | 649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 650 | | preserve host alignment requirements. The BFD_ASSERTs in this | 651 | | functions will warn us if we run out of room, but we should | 652 | | already have enough padding built in to ILF_DATA_SIZE. */ | 653 | 59 | #if GCC_VERSION >= 3000 | 654 | 59 | alignment = __alignof__ (struct coff_section_tdata); | 655 | | #else | 656 | | alignment = 8; | 657 | | #endif | 658 | 59 | vars->data | 659 | 59 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 660 | | | 661 | | /* Create a coff_section_tdata structure for our use. */ | 662 | 59 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 663 | 59 | vars->data += sizeof (struct coff_section_tdata); | 664 | | | 665 | 59 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 666 | | | 667 | | /* Create a symbol to refer to this section. */ | 668 | 59 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 669 | | | 670 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 671 | 59 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 672 | | | 673 | 59 | return sec; | 674 | 59 | } |
|
675 | | |
676 | | /* This structure contains the code that goes into the .text section |
677 | | in order to perform a jump into the DLL lookup table. The entries |
678 | | in the table are index by the magic number used to represent the |
679 | | machine type in the PE file. The contents of the data[] arrays in |
680 | | these entries are stolen from the jtab[] arrays in ld/pe-dll.c. |
681 | | The SIZE field says how many bytes in the DATA array are actually |
682 | | used. The OFFSET field says where in the data array the address |
683 | | of the .idata$5 section should be placed. */ |
684 | 154 | #define MAX_TEXT_SECTION_SIZE 32 |
685 | | |
686 | | typedef struct |
687 | | { |
688 | | unsigned short magic; |
689 | | unsigned char data[MAX_TEXT_SECTION_SIZE]; |
690 | | unsigned int size; |
691 | | unsigned int offset; |
692 | | } |
693 | | jump_table; |
694 | | |
695 | | static const jump_table jtab[] = |
696 | | { |
697 | | #ifdef I386MAGIC |
698 | | { I386MAGIC, |
699 | | { 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90 }, |
700 | | 8, 2 |
701 | | }, |
702 | | #endif |
703 | | |
704 | | #ifdef AMD64MAGIC |
705 | | { AMD64MAGIC, |
706 | | { 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90 }, |
707 | | 8, 2 |
708 | | }, |
709 | | #endif |
710 | | |
711 | | #ifdef MC68MAGIC |
712 | | { MC68MAGIC, |
713 | | { /* XXX fill me in */ }, |
714 | | 0, 0 |
715 | | }, |
716 | | #endif |
717 | | |
718 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
719 | | { MIPS_ARCH_MAGIC_WINCE, |
720 | | { 0x00, 0x00, 0x08, 0x3c, 0x00, 0x00, 0x08, 0x8d, |
721 | | 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }, |
722 | | 16, 0 |
723 | | }, |
724 | | #endif |
725 | | |
726 | | #ifdef SH_ARCH_MAGIC_WINCE |
727 | | { SH_ARCH_MAGIC_WINCE, |
728 | | { 0x01, 0xd0, 0x02, 0x60, 0x2b, 0x40, |
729 | | 0x09, 0x00, 0x00, 0x00, 0x00, 0x00 }, |
730 | | 12, 8 |
731 | | }, |
732 | | #endif |
733 | | |
734 | | #ifdef AARCH64MAGIC |
735 | | /* We don't currently support jumping to DLLs, so if |
736 | | someone does try emit a runtime trap. Through UDF #0. */ |
737 | | { AARCH64MAGIC, |
738 | | { 0x00, 0x00, 0x00, 0x00 }, |
739 | | 4, 0 |
740 | | }, |
741 | | |
742 | | #endif |
743 | | |
744 | | #ifdef ARMPEMAGIC |
745 | | { ARMPEMAGIC, |
746 | | { 0x00, 0xc0, 0x9f, 0xe5, 0x00, 0xf0, |
747 | | 0x9c, 0xe5, 0x00, 0x00, 0x00, 0x00}, |
748 | | 12, 8 |
749 | | }, |
750 | | #endif |
751 | | |
752 | | #ifdef THUMBPEMAGIC |
753 | | { THUMBPEMAGIC, |
754 | | { 0x40, 0xb4, 0x02, 0x4e, 0x36, 0x68, 0xb4, 0x46, |
755 | | 0x40, 0xbc, 0x60, 0x47, 0x00, 0x00, 0x00, 0x00 }, |
756 | | 16, 12 |
757 | | }, |
758 | | #endif |
759 | | |
760 | | #ifdef LOONGARCH64MAGIC |
761 | | /* We don't currently support jumping to DLLs, so if |
762 | | someone does try emit a runtime trap. Through BREAK 0. */ |
763 | | { LOONGARCH64MAGIC, |
764 | | { 0x00, 0x00, 0x2a, 0x00 }, |
765 | | 4, 0 |
766 | | }, |
767 | | |
768 | | #endif |
769 | | |
770 | | { 0, { 0 }, 0, 0 } |
771 | | }; |
772 | | |
773 | | #ifndef NUM_ENTRIES |
774 | 43 | #define NUM_ENTRIES(a) (sizeof (a) / sizeof (a)[0]) |
775 | | #endif |
776 | | |
777 | | /* Build a full BFD from the information supplied in a ILF object. */ |
778 | | |
779 | | static bool |
780 | | pe_ILF_build_a_bfd (bfd * abfd, |
781 | | unsigned int magic, |
782 | | char * symbol_name, |
783 | | char * source_dll, |
784 | | unsigned int ordinal, |
785 | | unsigned int types) |
786 | 104 | { |
787 | 104 | bfd_byte * ptr; |
788 | 104 | pe_ILF_vars vars; |
789 | 104 | struct internal_filehdr internal_f; |
790 | 104 | unsigned int import_type; |
791 | 104 | unsigned int import_name_type; |
792 | 104 | asection_ptr id4, id5, id6 = NULL, text = NULL; |
793 | 104 | coff_symbol_type ** imp_sym; |
794 | 104 | unsigned int imp_index; |
795 | 104 | intptr_t alignment; |
796 | | |
797 | | /* Decode and verify the types field of the ILF structure. */ |
798 | 104 | import_type = types & 0x3; |
799 | 104 | import_name_type = (types & 0x1c) >> 2; |
800 | | |
801 | 104 | switch (import_type) |
802 | 104 | { |
803 | 57 | case IMPORT_CODE: |
804 | 85 | case IMPORT_DATA: |
805 | 85 | break; |
806 | | |
807 | 7 | case IMPORT_CONST: |
808 | | /* XXX code yet to be written. */ |
809 | | /* xgettext:c-format */ |
810 | 7 | _bfd_error_handler (_("%pB: unhandled import type; %x"), |
811 | 7 | abfd, import_type); |
812 | 7 | return false; |
813 | | |
814 | 12 | default: |
815 | | /* xgettext:c-format */ |
816 | 12 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), |
817 | 12 | abfd, import_type); |
818 | 12 | return false; |
819 | 104 | } |
820 | | |
821 | 85 | switch (import_name_type) |
822 | 85 | { |
823 | 38 | case IMPORT_ORDINAL: |
824 | 47 | case IMPORT_NAME: |
825 | 56 | case IMPORT_NAME_NOPREFIX: |
826 | 77 | case IMPORT_NAME_UNDECORATE: |
827 | 77 | break; |
828 | | |
829 | 8 | default: |
830 | | /* xgettext:c-format */ |
831 | 8 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), |
832 | 8 | abfd, import_name_type); |
833 | 8 | return false; |
834 | 85 | } |
835 | | |
836 | | /* Initialise local variables. |
837 | | |
838 | | Note these are kept in a structure rather than being |
839 | | declared as statics since bfd frowns on global variables. |
840 | | |
841 | | We are going to construct the contents of the BFD in memory, |
842 | | so allocate all the space that we will need right now. */ |
843 | 77 | vars.bim |
844 | 77 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); |
845 | 77 | if (vars.bim == NULL) |
846 | 0 | return false; |
847 | | |
848 | 77 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); |
849 | 77 | vars.bim->buffer = ptr; |
850 | 77 | vars.bim->size = ILF_DATA_SIZE; |
851 | 77 | if (ptr == NULL) |
852 | 0 | goto error_return; |
853 | | |
854 | | /* Initialise the pointers to regions of the memory and the |
855 | | other contents of the pe_ILF_vars structure as well. */ |
856 | 77 | vars.sym_cache = (coff_symbol_type *) ptr; |
857 | 77 | vars.sym_ptr = (coff_symbol_type *) ptr; |
858 | 77 | vars.sym_index = 0; |
859 | 77 | ptr += SIZEOF_ILF_SYMS; |
860 | | |
861 | 77 | vars.sym_table = (unsigned int *) ptr; |
862 | 77 | vars.table_ptr = (unsigned int *) ptr; |
863 | 77 | ptr += SIZEOF_ILF_SYM_TABLE; |
864 | | |
865 | 77 | vars.native_syms = (combined_entry_type *) ptr; |
866 | 77 | vars.native_ptr = (combined_entry_type *) ptr; |
867 | 77 | ptr += SIZEOF_ILF_NATIVE_SYMS; |
868 | | |
869 | 77 | vars.sym_ptr_table = (coff_symbol_type **) ptr; |
870 | 77 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; |
871 | 77 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; |
872 | | |
873 | 77 | vars.esym_table = (SYMENT *) ptr; |
874 | 77 | vars.esym_ptr = (SYMENT *) ptr; |
875 | 77 | ptr += SIZEOF_ILF_EXT_SYMS; |
876 | | |
877 | 77 | vars.reltab = (arelent *) ptr; |
878 | 77 | vars.relcount = 0; |
879 | 77 | ptr += SIZEOF_ILF_RELOCS; |
880 | | |
881 | 77 | vars.int_reltab = (struct internal_reloc *) ptr; |
882 | 77 | ptr += SIZEOF_ILF_INT_RELOCS; |
883 | | |
884 | 77 | vars.string_table = (char *) ptr; |
885 | 77 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; |
886 | 77 | ptr += SIZEOF_ILF_STRINGS; |
887 | 77 | vars.end_string_ptr = (char *) ptr; |
888 | | |
889 | | /* The remaining space in bim->buffer is used |
890 | | by the pe_ILF_make_a_section() function. */ |
891 | | |
892 | | /* PR 18758: Make sure that the data area is sufficiently aligned for |
893 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence |
894 | | the test of GCC_VERSION. For other compilers we assume 8 byte |
895 | | alignment. */ |
896 | 77 | #if GCC_VERSION >= 3000 |
897 | 77 | alignment = __alignof__ (struct coff_section_tdata); |
898 | | #else |
899 | | alignment = 8; |
900 | | #endif |
901 | 77 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); |
902 | | |
903 | 77 | vars.data = ptr; |
904 | 77 | vars.abfd = abfd; |
905 | 77 | vars.sec_index = 0; |
906 | 77 | vars.magic = magic; |
907 | | |
908 | | /* Create the initial .idata$<n> sections: |
909 | | [.idata$2: Import Directory Table -- not needed] |
910 | | .idata$4: Import Lookup Table |
911 | | .idata$5: Import Address Table |
912 | | |
913 | | Note we do not create a .idata$3 section as this is |
914 | | created for us by the linker script. */ |
915 | 77 | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); |
916 | 77 | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); |
917 | 77 | if (id4 == NULL || id5 == NULL) |
918 | 0 | goto error_return; |
919 | | |
920 | | /* Fill in the contents of these sections. */ |
921 | 77 | if (import_name_type == IMPORT_ORDINAL) |
922 | 38 | { |
923 | 38 | if (ordinal == 0) |
924 | | /* See PR 20907 for a reproducer. */ |
925 | 10 | goto error_return; |
926 | | |
927 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) |
928 | 7 | ((unsigned int *) id4->contents)[0] = ordinal; |
929 | 7 | ((unsigned int *) id4->contents)[1] = 0x80000000; |
930 | 7 | ((unsigned int *) id5->contents)[0] = ordinal; |
931 | 7 | ((unsigned int *) id5->contents)[1] = 0x80000000; |
932 | | #else |
933 | 21 | * (unsigned int *) id4->contents = ordinal | 0x80000000; |
934 | 21 | * (unsigned int *) id5->contents = ordinal | 0x80000000; |
935 | 21 | #endif |
936 | 21 | } |
937 | 39 | else |
938 | 39 | { |
939 | 39 | char * symbol; |
940 | 39 | unsigned int len; |
941 | | |
942 | | /* Create .idata$6 - the Hint Name Table. */ |
943 | 39 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); |
944 | 39 | if (id6 == NULL) |
945 | 0 | goto error_return; |
946 | | |
947 | | /* If necessary, trim the import symbol name. */ |
948 | 39 | symbol = symbol_name; |
949 | | |
950 | | /* As used by MS compiler, '_', '@', and '?' are alternative |
951 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, |
952 | | '@' used for fastcall (in C), '_' everywhere else. Only one |
953 | | of these is used for a symbol. We strip this leading char for |
954 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the |
955 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ |
956 | | |
957 | 39 | if (import_name_type != IMPORT_NAME) |
958 | 30 | { |
959 | 30 | char c = symbol[0]; |
960 | | |
961 | | /* Check that we don't remove for targets with empty |
962 | | USER_LABEL_PREFIX the leading underscore. */ |
963 | 30 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) |
964 | 30 | || c == '@' || c == '?') |
965 | 6 | symbol++; |
966 | 30 | } |
967 | | |
968 | 39 | len = strlen (symbol); |
969 | 39 | if (import_name_type == IMPORT_NAME_UNDECORATE) |
970 | 21 | { |
971 | | /* Truncate at the first '@'. */ |
972 | 21 | char *at = strchr (symbol, '@'); |
973 | | |
974 | 21 | if (at != NULL) |
975 | 3 | len = at - symbol; |
976 | 21 | } |
977 | | |
978 | 39 | id6->contents[0] = ordinal & 0xff; |
979 | 39 | id6->contents[1] = ordinal >> 8; |
980 | | |
981 | 39 | memcpy ((char *) id6->contents + 2, symbol, len); |
982 | 39 | id6->contents[len + 2] = '\0'; |
983 | 39 | } |
984 | | |
985 | 67 | if (import_name_type != IMPORT_ORDINAL) |
986 | 39 | { |
987 | 39 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); |
988 | 39 | pe_ILF_save_relocs (&vars, id4); |
989 | | |
990 | 39 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); |
991 | 39 | pe_ILF_save_relocs (&vars, id5); |
992 | 39 | } |
993 | | |
994 | | /* Create an import symbol. */ |
995 | 67 | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); |
996 | 67 | imp_sym = vars.sym_ptr_ptr - 1; |
997 | 67 | imp_index = vars.sym_index - 1; |
998 | | |
999 | | /* Create extra sections depending upon the type of import we are dealing with. */ |
1000 | 67 | switch (import_type) |
1001 | 67 | { |
1002 | 0 | int i; |
1003 | | |
1004 | 43 | case IMPORT_CODE: |
1005 | | /* CODE functions are special, in that they get a trampoline that |
1006 | | jumps to the main import symbol. Create a .text section to hold it. |
1007 | | First we need to look up its contents in the jump table. */ |
1008 | 92 | for (i = NUM_ENTRIES (jtab); i--;) |
1009 | 92 | { |
1010 | 92 | if (jtab[i].size == 0) |
1011 | 43 | continue; |
1012 | 49 | if (jtab[i].magic == magic) |
1013 | 43 | break; |
1014 | 49 | } |
1015 | | /* If we did not find a matching entry something is wrong. */ |
1016 | 43 | if (i < 0) |
1017 | 0 | abort (); |
1018 | | |
1019 | | /* Create the .text section. */ |
1020 | 43 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); |
1021 | 43 | if (text == NULL) |
1022 | 0 | goto error_return; |
1023 | | |
1024 | | /* Copy in the jump code. */ |
1025 | 43 | memcpy (text->contents, jtab[i].data, jtab[i].size); |
1026 | | |
1027 | | /* Create a reloc for the data in the text section. */ |
1028 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
1029 | | if (magic == MIPS_ARCH_MAGIC_WINCE) |
1030 | | { |
1031 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, |
1032 | | (struct bfd_symbol **) imp_sym, |
1033 | | imp_index); |
1034 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); |
1035 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, |
1036 | | (struct bfd_symbol **) imp_sym, |
1037 | | imp_index); |
1038 | | } |
1039 | | else |
1040 | | #endif |
1041 | | #ifdef AMD64MAGIC |
1042 | 4 | if (magic == AMD64MAGIC) |
1043 | 4 | { |
1044 | 4 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, |
1045 | 4 | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, |
1046 | 4 | imp_index); |
1047 | 4 | } |
1048 | 0 | else |
1049 | 0 | #endif |
1050 | 0 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, |
1051 | 0 | BFD_RELOC_32, (asymbol **) imp_sym, |
1052 | 0 | imp_index); |
1053 | | |
1054 | 43 | pe_ILF_save_relocs (& vars, text); |
1055 | 43 | break; |
1056 | | |
1057 | 24 | case IMPORT_DATA: |
1058 | 24 | break; |
1059 | | |
1060 | 0 | default: |
1061 | | /* XXX code not yet written. */ |
1062 | 0 | abort (); |
1063 | 67 | } |
1064 | | |
1065 | | /* Now create a symbol describing the imported value. */ |
1066 | 67 | switch (import_type) |
1067 | 67 | { |
1068 | 43 | case IMPORT_CODE: |
1069 | 43 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, |
1070 | 43 | BSF_NOT_AT_END | BSF_FUNCTION); |
1071 | | |
1072 | 43 | break; |
1073 | | |
1074 | 24 | case IMPORT_DATA: |
1075 | | /* Nothing to do here. */ |
1076 | 24 | break; |
1077 | | |
1078 | 0 | default: |
1079 | | /* XXX code not yet written. */ |
1080 | 0 | abort (); |
1081 | 67 | } |
1082 | | |
1083 | | /* Create an import symbol for the DLL, without the .dll suffix. */ |
1084 | 67 | ptr = (bfd_byte *) strrchr (source_dll, '.'); |
1085 | 67 | if (ptr) |
1086 | 11 | * ptr = 0; |
1087 | 67 | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); |
1088 | 67 | if (ptr) |
1089 | 11 | * ptr = '.'; |
1090 | | |
1091 | | /* Initialise the bfd. */ |
1092 | 67 | memset (& internal_f, 0, sizeof (internal_f)); |
1093 | | |
1094 | 67 | internal_f.f_magic = magic; |
1095 | 67 | internal_f.f_symptr = 0; |
1096 | 67 | internal_f.f_nsyms = 0; |
1097 | 67 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ |
1098 | | |
1099 | 67 | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) |
1100 | 67 | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) |
1101 | 0 | goto error_return; |
1102 | | |
1103 | 67 | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) |
1104 | 0 | goto error_return; |
1105 | | |
1106 | 67 | obj_pe (abfd) = true; |
1107 | | #ifdef THUMBPEMAGIC |
1108 | 22 | if (vars.magic == THUMBPEMAGIC) |
1109 | | /* Stop some linker warnings about thumb code not supporting interworking. */ |
1110 | 10 | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; |
1111 | | #endif |
1112 | | |
1113 | | /* Switch from file contents to memory contents. */ |
1114 | 67 | bfd_cache_close (abfd); |
1115 | | |
1116 | 67 | abfd->iostream = (void *) vars.bim; |
1117 | 67 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; |
1118 | 67 | abfd->iovec = &_bfd_memory_iovec; |
1119 | 67 | abfd->where = 0; |
1120 | 67 | abfd->origin = 0; |
1121 | 67 | abfd->size = 0; |
1122 | 67 | obj_sym_filepos (abfd) = 0; |
1123 | | |
1124 | | /* Point the bfd at the symbol table. */ |
1125 | 67 | obj_symbols (abfd) = vars.sym_cache; |
1126 | 67 | abfd->symcount = vars.sym_index; |
1127 | | |
1128 | 67 | obj_raw_syments (abfd) = vars.native_syms; |
1129 | 67 | obj_raw_syment_count (abfd) = vars.sym_index; |
1130 | | |
1131 | 67 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; |
1132 | 67 | obj_coff_keep_syms (abfd) = true; |
1133 | | |
1134 | 67 | obj_convert (abfd) = vars.sym_table; |
1135 | 67 | obj_conv_table_size (abfd) = vars.sym_index; |
1136 | | |
1137 | 67 | obj_coff_strings (abfd) = vars.string_table; |
1138 | 67 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; |
1139 | 67 | obj_coff_keep_strings (abfd) = true; |
1140 | | |
1141 | 67 | return true; |
1142 | | |
1143 | 10 | error_return: |
1144 | 10 | free (vars.bim->buffer); |
1145 | 10 | free (vars.bim); |
1146 | 10 | return false; |
1147 | 67 | } pei-i386.c:pe_ILF_build_a_bfd Line | Count | Source | 786 | 16 | { | 787 | 16 | bfd_byte * ptr; | 788 | 16 | pe_ILF_vars vars; | 789 | 16 | struct internal_filehdr internal_f; | 790 | 16 | unsigned int import_type; | 791 | 16 | unsigned int import_name_type; | 792 | 16 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 793 | 16 | coff_symbol_type ** imp_sym; | 794 | 16 | unsigned int imp_index; | 795 | 16 | intptr_t alignment; | 796 | | | 797 | | /* Decode and verify the types field of the ILF structure. */ | 798 | 16 | import_type = types & 0x3; | 799 | 16 | import_name_type = (types & 0x1c) >> 2; | 800 | | | 801 | 16 | switch (import_type) | 802 | 16 | { | 803 | 10 | case IMPORT_CODE: | 804 | 13 | case IMPORT_DATA: | 805 | 13 | break; | 806 | | | 807 | 1 | case IMPORT_CONST: | 808 | | /* XXX code yet to be written. */ | 809 | | /* xgettext:c-format */ | 810 | 1 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 811 | 1 | abfd, import_type); | 812 | 1 | return false; | 813 | | | 814 | 2 | default: | 815 | | /* xgettext:c-format */ | 816 | 2 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 817 | 2 | abfd, import_type); | 818 | 2 | return false; | 819 | 16 | } | 820 | | | 821 | 13 | switch (import_name_type) | 822 | 13 | { | 823 | 5 | case IMPORT_ORDINAL: | 824 | 6 | case IMPORT_NAME: | 825 | 6 | case IMPORT_NAME_NOPREFIX: | 826 | 11 | case IMPORT_NAME_UNDECORATE: | 827 | 11 | break; | 828 | | | 829 | 2 | default: | 830 | | /* xgettext:c-format */ | 831 | 2 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 832 | 2 | abfd, import_name_type); | 833 | 2 | return false; | 834 | 13 | } | 835 | | | 836 | | /* Initialise local variables. | 837 | | | 838 | | Note these are kept in a structure rather than being | 839 | | declared as statics since bfd frowns on global variables. | 840 | | | 841 | | We are going to construct the contents of the BFD in memory, | 842 | | so allocate all the space that we will need right now. */ | 843 | 11 | vars.bim | 844 | 11 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 845 | 11 | if (vars.bim == NULL) | 846 | 0 | return false; | 847 | | | 848 | 11 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 849 | 11 | vars.bim->buffer = ptr; | 850 | 11 | vars.bim->size = ILF_DATA_SIZE; | 851 | 11 | if (ptr == NULL) | 852 | 0 | goto error_return; | 853 | | | 854 | | /* Initialise the pointers to regions of the memory and the | 855 | | other contents of the pe_ILF_vars structure as well. */ | 856 | 11 | vars.sym_cache = (coff_symbol_type *) ptr; | 857 | 11 | vars.sym_ptr = (coff_symbol_type *) ptr; | 858 | 11 | vars.sym_index = 0; | 859 | 11 | ptr += SIZEOF_ILF_SYMS; | 860 | | | 861 | 11 | vars.sym_table = (unsigned int *) ptr; | 862 | 11 | vars.table_ptr = (unsigned int *) ptr; | 863 | 11 | ptr += SIZEOF_ILF_SYM_TABLE; | 864 | | | 865 | 11 | vars.native_syms = (combined_entry_type *) ptr; | 866 | 11 | vars.native_ptr = (combined_entry_type *) ptr; | 867 | 11 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 868 | | | 869 | 11 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 870 | 11 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 871 | 11 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 872 | | | 873 | 11 | vars.esym_table = (SYMENT *) ptr; | 874 | 11 | vars.esym_ptr = (SYMENT *) ptr; | 875 | 11 | ptr += SIZEOF_ILF_EXT_SYMS; | 876 | | | 877 | 11 | vars.reltab = (arelent *) ptr; | 878 | 11 | vars.relcount = 0; | 879 | 11 | ptr += SIZEOF_ILF_RELOCS; | 880 | | | 881 | 11 | vars.int_reltab = (struct internal_reloc *) ptr; | 882 | 11 | ptr += SIZEOF_ILF_INT_RELOCS; | 883 | | | 884 | 11 | vars.string_table = (char *) ptr; | 885 | 11 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 886 | 11 | ptr += SIZEOF_ILF_STRINGS; | 887 | 11 | vars.end_string_ptr = (char *) ptr; | 888 | | | 889 | | /* The remaining space in bim->buffer is used | 890 | | by the pe_ILF_make_a_section() function. */ | 891 | | | 892 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 893 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 894 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 895 | | alignment. */ | 896 | 11 | #if GCC_VERSION >= 3000 | 897 | 11 | alignment = __alignof__ (struct coff_section_tdata); | 898 | | #else | 899 | | alignment = 8; | 900 | | #endif | 901 | 11 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 902 | | | 903 | 11 | vars.data = ptr; | 904 | 11 | vars.abfd = abfd; | 905 | 11 | vars.sec_index = 0; | 906 | 11 | vars.magic = magic; | 907 | | | 908 | | /* Create the initial .idata$<n> sections: | 909 | | [.idata$2: Import Directory Table -- not needed] | 910 | | .idata$4: Import Lookup Table | 911 | | .idata$5: Import Address Table | 912 | | | 913 | | Note we do not create a .idata$3 section as this is | 914 | | created for us by the linker script. */ | 915 | 11 | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 916 | 11 | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 917 | 11 | if (id4 == NULL || id5 == NULL) | 918 | 0 | goto error_return; | 919 | | | 920 | | /* Fill in the contents of these sections. */ | 921 | 11 | if (import_name_type == IMPORT_ORDINAL) | 922 | 5 | { | 923 | 5 | if (ordinal == 0) | 924 | | /* See PR 20907 for a reproducer. */ | 925 | 1 | goto error_return; | 926 | | | 927 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 928 | | ((unsigned int *) id4->contents)[0] = ordinal; | 929 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 930 | | ((unsigned int *) id5->contents)[0] = ordinal; | 931 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 932 | | #else | 933 | 4 | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 934 | 4 | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 935 | 4 | #endif | 936 | 4 | } | 937 | 6 | else | 938 | 6 | { | 939 | 6 | char * symbol; | 940 | 6 | unsigned int len; | 941 | | | 942 | | /* Create .idata$6 - the Hint Name Table. */ | 943 | 6 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 944 | 6 | if (id6 == NULL) | 945 | 0 | goto error_return; | 946 | | | 947 | | /* If necessary, trim the import symbol name. */ | 948 | 6 | symbol = symbol_name; | 949 | | | 950 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 951 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 952 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 953 | | of these is used for a symbol. We strip this leading char for | 954 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 955 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 956 | | | 957 | 6 | if (import_name_type != IMPORT_NAME) | 958 | 5 | { | 959 | 5 | char c = symbol[0]; | 960 | | | 961 | | /* Check that we don't remove for targets with empty | 962 | | USER_LABEL_PREFIX the leading underscore. */ | 963 | 5 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 964 | 5 | || c == '@' || c == '?') | 965 | 1 | symbol++; | 966 | 5 | } | 967 | | | 968 | 6 | len = strlen (symbol); | 969 | 6 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 970 | 5 | { | 971 | | /* Truncate at the first '@'. */ | 972 | 5 | char *at = strchr (symbol, '@'); | 973 | | | 974 | 5 | if (at != NULL) | 975 | 1 | len = at - symbol; | 976 | 5 | } | 977 | | | 978 | 6 | id6->contents[0] = ordinal & 0xff; | 979 | 6 | id6->contents[1] = ordinal >> 8; | 980 | | | 981 | 6 | memcpy ((char *) id6->contents + 2, symbol, len); | 982 | 6 | id6->contents[len + 2] = '\0'; | 983 | 6 | } | 984 | | | 985 | 10 | if (import_name_type != IMPORT_ORDINAL) | 986 | 6 | { | 987 | 6 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 988 | 6 | pe_ILF_save_relocs (&vars, id4); | 989 | | | 990 | 6 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 991 | 6 | pe_ILF_save_relocs (&vars, id5); | 992 | 6 | } | 993 | | | 994 | | /* Create an import symbol. */ | 995 | 10 | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 996 | 10 | imp_sym = vars.sym_ptr_ptr - 1; | 997 | 10 | imp_index = vars.sym_index - 1; | 998 | | | 999 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1000 | 10 | switch (import_type) | 1001 | 10 | { | 1002 | 0 | int i; | 1003 | | | 1004 | 8 | case IMPORT_CODE: | 1005 | | /* CODE functions are special, in that they get a trampoline that | 1006 | | jumps to the main import symbol. Create a .text section to hold it. | 1007 | | First we need to look up its contents in the jump table. */ | 1008 | 16 | for (i = NUM_ENTRIES (jtab); i--;) | 1009 | 16 | { | 1010 | 16 | if (jtab[i].size == 0) | 1011 | 8 | continue; | 1012 | 8 | if (jtab[i].magic == magic) | 1013 | 8 | break; | 1014 | 8 | } | 1015 | | /* If we did not find a matching entry something is wrong. */ | 1016 | 8 | if (i < 0) | 1017 | 0 | abort (); | 1018 | | | 1019 | | /* Create the .text section. */ | 1020 | 8 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1021 | 8 | if (text == NULL) | 1022 | 0 | goto error_return; | 1023 | | | 1024 | | /* Copy in the jump code. */ | 1025 | 8 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1026 | | | 1027 | | /* Create a reloc for the data in the text section. */ | 1028 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1029 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1030 | | { | 1031 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1032 | | (struct bfd_symbol **) imp_sym, | 1033 | | imp_index); | 1034 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1035 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1036 | | (struct bfd_symbol **) imp_sym, | 1037 | | imp_index); | 1038 | | } | 1039 | | else | 1040 | | #endif | 1041 | | #ifdef AMD64MAGIC | 1042 | | if (magic == AMD64MAGIC) | 1043 | | { | 1044 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1045 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1046 | | imp_index); | 1047 | | } | 1048 | | else | 1049 | | #endif | 1050 | 8 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1051 | 8 | BFD_RELOC_32, (asymbol **) imp_sym, | 1052 | 8 | imp_index); | 1053 | | | 1054 | 8 | pe_ILF_save_relocs (& vars, text); | 1055 | 8 | break; | 1056 | | | 1057 | 2 | case IMPORT_DATA: | 1058 | 2 | break; | 1059 | | | 1060 | 0 | default: | 1061 | | /* XXX code not yet written. */ | 1062 | 0 | abort (); | 1063 | 10 | } | 1064 | | | 1065 | | /* Now create a symbol describing the imported value. */ | 1066 | 10 | switch (import_type) | 1067 | 10 | { | 1068 | 8 | case IMPORT_CODE: | 1069 | 8 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1070 | 8 | BSF_NOT_AT_END | BSF_FUNCTION); | 1071 | | | 1072 | 8 | break; | 1073 | | | 1074 | 2 | case IMPORT_DATA: | 1075 | | /* Nothing to do here. */ | 1076 | 2 | break; | 1077 | | | 1078 | 0 | default: | 1079 | | /* XXX code not yet written. */ | 1080 | 0 | abort (); | 1081 | 10 | } | 1082 | | | 1083 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1084 | 10 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1085 | 10 | if (ptr) | 1086 | 0 | * ptr = 0; | 1087 | 10 | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1088 | 10 | if (ptr) | 1089 | 0 | * ptr = '.'; | 1090 | | | 1091 | | /* Initialise the bfd. */ | 1092 | 10 | memset (& internal_f, 0, sizeof (internal_f)); | 1093 | | | 1094 | 10 | internal_f.f_magic = magic; | 1095 | 10 | internal_f.f_symptr = 0; | 1096 | 10 | internal_f.f_nsyms = 0; | 1097 | 10 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1098 | | | 1099 | 10 | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1100 | 10 | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1101 | 0 | goto error_return; | 1102 | | | 1103 | 10 | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1104 | 0 | goto error_return; | 1105 | | | 1106 | 10 | obj_pe (abfd) = true; | 1107 | | #ifdef THUMBPEMAGIC | 1108 | | if (vars.magic == THUMBPEMAGIC) | 1109 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1110 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1111 | | #endif | 1112 | | | 1113 | | /* Switch from file contents to memory contents. */ | 1114 | 10 | bfd_cache_close (abfd); | 1115 | | | 1116 | 10 | abfd->iostream = (void *) vars.bim; | 1117 | 10 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1118 | 10 | abfd->iovec = &_bfd_memory_iovec; | 1119 | 10 | abfd->where = 0; | 1120 | 10 | abfd->origin = 0; | 1121 | 10 | abfd->size = 0; | 1122 | 10 | obj_sym_filepos (abfd) = 0; | 1123 | | | 1124 | | /* Point the bfd at the symbol table. */ | 1125 | 10 | obj_symbols (abfd) = vars.sym_cache; | 1126 | 10 | abfd->symcount = vars.sym_index; | 1127 | | | 1128 | 10 | obj_raw_syments (abfd) = vars.native_syms; | 1129 | 10 | obj_raw_syment_count (abfd) = vars.sym_index; | 1130 | | | 1131 | 10 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1132 | 10 | obj_coff_keep_syms (abfd) = true; | 1133 | | | 1134 | 10 | obj_convert (abfd) = vars.sym_table; | 1135 | 10 | obj_conv_table_size (abfd) = vars.sym_index; | 1136 | | | 1137 | 10 | obj_coff_strings (abfd) = vars.string_table; | 1138 | 10 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1139 | 10 | obj_coff_keep_strings (abfd) = true; | 1140 | | | 1141 | 10 | return true; | 1142 | | | 1143 | 1 | error_return: | 1144 | 1 | free (vars.bim->buffer); | 1145 | 1 | free (vars.bim); | 1146 | 1 | return false; | 1147 | 10 | } |
pei-x86_64.c:pe_ILF_build_a_bfd Line | Count | Source | 786 | 11 | { | 787 | 11 | bfd_byte * ptr; | 788 | 11 | pe_ILF_vars vars; | 789 | 11 | struct internal_filehdr internal_f; | 790 | 11 | unsigned int import_type; | 791 | 11 | unsigned int import_name_type; | 792 | 11 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 793 | 11 | coff_symbol_type ** imp_sym; | 794 | 11 | unsigned int imp_index; | 795 | 11 | intptr_t alignment; | 796 | | | 797 | | /* Decode and verify the types field of the ILF structure. */ | 798 | 11 | import_type = types & 0x3; | 799 | 11 | import_name_type = (types & 0x1c) >> 2; | 800 | | | 801 | 11 | switch (import_type) | 802 | 11 | { | 803 | 6 | case IMPORT_CODE: | 804 | 9 | case IMPORT_DATA: | 805 | 9 | break; | 806 | | | 807 | 1 | case IMPORT_CONST: | 808 | | /* XXX code yet to be written. */ | 809 | | /* xgettext:c-format */ | 810 | 1 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 811 | 1 | abfd, import_type); | 812 | 1 | return false; | 813 | | | 814 | 1 | default: | 815 | | /* xgettext:c-format */ | 816 | 1 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 817 | 1 | abfd, import_type); | 818 | 1 | return false; | 819 | 11 | } | 820 | | | 821 | 9 | switch (import_name_type) | 822 | 9 | { | 823 | 3 | case IMPORT_ORDINAL: | 824 | 4 | case IMPORT_NAME: | 825 | 7 | case IMPORT_NAME_NOPREFIX: | 826 | 8 | case IMPORT_NAME_UNDECORATE: | 827 | 8 | break; | 828 | | | 829 | 1 | default: | 830 | | /* xgettext:c-format */ | 831 | 1 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 832 | 1 | abfd, import_name_type); | 833 | 1 | return false; | 834 | 9 | } | 835 | | | 836 | | /* Initialise local variables. | 837 | | | 838 | | Note these are kept in a structure rather than being | 839 | | declared as statics since bfd frowns on global variables. | 840 | | | 841 | | We are going to construct the contents of the BFD in memory, | 842 | | so allocate all the space that we will need right now. */ | 843 | 8 | vars.bim | 844 | 8 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 845 | 8 | if (vars.bim == NULL) | 846 | 0 | return false; | 847 | | | 848 | 8 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 849 | 8 | vars.bim->buffer = ptr; | 850 | 8 | vars.bim->size = ILF_DATA_SIZE; | 851 | 8 | if (ptr == NULL) | 852 | 0 | goto error_return; | 853 | | | 854 | | /* Initialise the pointers to regions of the memory and the | 855 | | other contents of the pe_ILF_vars structure as well. */ | 856 | 8 | vars.sym_cache = (coff_symbol_type *) ptr; | 857 | 8 | vars.sym_ptr = (coff_symbol_type *) ptr; | 858 | 8 | vars.sym_index = 0; | 859 | 8 | ptr += SIZEOF_ILF_SYMS; | 860 | | | 861 | 8 | vars.sym_table = (unsigned int *) ptr; | 862 | 8 | vars.table_ptr = (unsigned int *) ptr; | 863 | 8 | ptr += SIZEOF_ILF_SYM_TABLE; | 864 | | | 865 | 8 | vars.native_syms = (combined_entry_type *) ptr; | 866 | 8 | vars.native_ptr = (combined_entry_type *) ptr; | 867 | 8 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 868 | | | 869 | 8 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 870 | 8 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 871 | 8 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 872 | | | 873 | 8 | vars.esym_table = (SYMENT *) ptr; | 874 | 8 | vars.esym_ptr = (SYMENT *) ptr; | 875 | 8 | ptr += SIZEOF_ILF_EXT_SYMS; | 876 | | | 877 | 8 | vars.reltab = (arelent *) ptr; | 878 | 8 | vars.relcount = 0; | 879 | 8 | ptr += SIZEOF_ILF_RELOCS; | 880 | | | 881 | 8 | vars.int_reltab = (struct internal_reloc *) ptr; | 882 | 8 | ptr += SIZEOF_ILF_INT_RELOCS; | 883 | | | 884 | 8 | vars.string_table = (char *) ptr; | 885 | 8 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 886 | 8 | ptr += SIZEOF_ILF_STRINGS; | 887 | 8 | vars.end_string_ptr = (char *) ptr; | 888 | | | 889 | | /* The remaining space in bim->buffer is used | 890 | | by the pe_ILF_make_a_section() function. */ | 891 | | | 892 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 893 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 894 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 895 | | alignment. */ | 896 | 8 | #if GCC_VERSION >= 3000 | 897 | 8 | alignment = __alignof__ (struct coff_section_tdata); | 898 | | #else | 899 | | alignment = 8; | 900 | | #endif | 901 | 8 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 902 | | | 903 | 8 | vars.data = ptr; | 904 | 8 | vars.abfd = abfd; | 905 | 8 | vars.sec_index = 0; | 906 | 8 | vars.magic = magic; | 907 | | | 908 | | /* Create the initial .idata$<n> sections: | 909 | | [.idata$2: Import Directory Table -- not needed] | 910 | | .idata$4: Import Lookup Table | 911 | | .idata$5: Import Address Table | 912 | | | 913 | | Note we do not create a .idata$3 section as this is | 914 | | created for us by the linker script. */ | 915 | 8 | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 916 | 8 | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 917 | 8 | if (id4 == NULL || id5 == NULL) | 918 | 0 | goto error_return; | 919 | | | 920 | | /* Fill in the contents of these sections. */ | 921 | 8 | if (import_name_type == IMPORT_ORDINAL) | 922 | 3 | { | 923 | 3 | if (ordinal == 0) | 924 | | /* See PR 20907 for a reproducer. */ | 925 | 1 | goto error_return; | 926 | | | 927 | 2 | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 928 | 2 | ((unsigned int *) id4->contents)[0] = ordinal; | 929 | 2 | ((unsigned int *) id4->contents)[1] = 0x80000000; | 930 | 2 | ((unsigned int *) id5->contents)[0] = ordinal; | 931 | 2 | ((unsigned int *) id5->contents)[1] = 0x80000000; | 932 | | #else | 933 | | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 934 | | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 935 | | #endif | 936 | 2 | } | 937 | 5 | else | 938 | 5 | { | 939 | 5 | char * symbol; | 940 | 5 | unsigned int len; | 941 | | | 942 | | /* Create .idata$6 - the Hint Name Table. */ | 943 | 5 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 944 | 5 | if (id6 == NULL) | 945 | 0 | goto error_return; | 946 | | | 947 | | /* If necessary, trim the import symbol name. */ | 948 | 5 | symbol = symbol_name; | 949 | | | 950 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 951 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 952 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 953 | | of these is used for a symbol. We strip this leading char for | 954 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 955 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 956 | | | 957 | 5 | if (import_name_type != IMPORT_NAME) | 958 | 4 | { | 959 | 4 | char c = symbol[0]; | 960 | | | 961 | | /* Check that we don't remove for targets with empty | 962 | | USER_LABEL_PREFIX the leading underscore. */ | 963 | 4 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 964 | 4 | || c == '@' || c == '?') | 965 | 1 | symbol++; | 966 | 4 | } | 967 | | | 968 | 5 | len = strlen (symbol); | 969 | 5 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 970 | 1 | { | 971 | | /* Truncate at the first '@'. */ | 972 | 1 | char *at = strchr (symbol, '@'); | 973 | | | 974 | 1 | if (at != NULL) | 975 | 0 | len = at - symbol; | 976 | 1 | } | 977 | | | 978 | 5 | id6->contents[0] = ordinal & 0xff; | 979 | 5 | id6->contents[1] = ordinal >> 8; | 980 | | | 981 | 5 | memcpy ((char *) id6->contents + 2, symbol, len); | 982 | 5 | id6->contents[len + 2] = '\0'; | 983 | 5 | } | 984 | | | 985 | 7 | if (import_name_type != IMPORT_ORDINAL) | 986 | 5 | { | 987 | 5 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 988 | 5 | pe_ILF_save_relocs (&vars, id4); | 989 | | | 990 | 5 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 991 | 5 | pe_ILF_save_relocs (&vars, id5); | 992 | 5 | } | 993 | | | 994 | | /* Create an import symbol. */ | 995 | 7 | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 996 | 7 | imp_sym = vars.sym_ptr_ptr - 1; | 997 | 7 | imp_index = vars.sym_index - 1; | 998 | | | 999 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1000 | 7 | switch (import_type) | 1001 | 7 | { | 1002 | 0 | int i; | 1003 | | | 1004 | 4 | case IMPORT_CODE: | 1005 | | /* CODE functions are special, in that they get a trampoline that | 1006 | | jumps to the main import symbol. Create a .text section to hold it. | 1007 | | First we need to look up its contents in the jump table. */ | 1008 | 8 | for (i = NUM_ENTRIES (jtab); i--;) | 1009 | 8 | { | 1010 | 8 | if (jtab[i].size == 0) | 1011 | 4 | continue; | 1012 | 4 | if (jtab[i].magic == magic) | 1013 | 4 | break; | 1014 | 4 | } | 1015 | | /* If we did not find a matching entry something is wrong. */ | 1016 | 4 | if (i < 0) | 1017 | 0 | abort (); | 1018 | | | 1019 | | /* Create the .text section. */ | 1020 | 4 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1021 | 4 | if (text == NULL) | 1022 | 0 | goto error_return; | 1023 | | | 1024 | | /* Copy in the jump code. */ | 1025 | 4 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1026 | | | 1027 | | /* Create a reloc for the data in the text section. */ | 1028 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1029 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1030 | | { | 1031 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1032 | | (struct bfd_symbol **) imp_sym, | 1033 | | imp_index); | 1034 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1035 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1036 | | (struct bfd_symbol **) imp_sym, | 1037 | | imp_index); | 1038 | | } | 1039 | | else | 1040 | | #endif | 1041 | 4 | #ifdef AMD64MAGIC | 1042 | 4 | if (magic == AMD64MAGIC) | 1043 | 4 | { | 1044 | 4 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1045 | 4 | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1046 | 4 | imp_index); | 1047 | 4 | } | 1048 | 0 | else | 1049 | 0 | #endif | 1050 | 0 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1051 | 0 | BFD_RELOC_32, (asymbol **) imp_sym, | 1052 | 0 | imp_index); | 1053 | | | 1054 | 4 | pe_ILF_save_relocs (& vars, text); | 1055 | 4 | break; | 1056 | | | 1057 | 3 | case IMPORT_DATA: | 1058 | 3 | break; | 1059 | | | 1060 | 0 | default: | 1061 | | /* XXX code not yet written. */ | 1062 | 0 | abort (); | 1063 | 7 | } | 1064 | | | 1065 | | /* Now create a symbol describing the imported value. */ | 1066 | 7 | switch (import_type) | 1067 | 7 | { | 1068 | 4 | case IMPORT_CODE: | 1069 | 4 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1070 | 4 | BSF_NOT_AT_END | BSF_FUNCTION); | 1071 | | | 1072 | 4 | break; | 1073 | | | 1074 | 3 | case IMPORT_DATA: | 1075 | | /* Nothing to do here. */ | 1076 | 3 | break; | 1077 | | | 1078 | 0 | default: | 1079 | | /* XXX code not yet written. */ | 1080 | 0 | abort (); | 1081 | 7 | } | 1082 | | | 1083 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1084 | 7 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1085 | 7 | if (ptr) | 1086 | 0 | * ptr = 0; | 1087 | 7 | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1088 | 7 | if (ptr) | 1089 | 0 | * ptr = '.'; | 1090 | | | 1091 | | /* Initialise the bfd. */ | 1092 | 7 | memset (& internal_f, 0, sizeof (internal_f)); | 1093 | | | 1094 | 7 | internal_f.f_magic = magic; | 1095 | 7 | internal_f.f_symptr = 0; | 1096 | 7 | internal_f.f_nsyms = 0; | 1097 | 7 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1098 | | | 1099 | 7 | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1100 | 7 | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1101 | 0 | goto error_return; | 1102 | | | 1103 | 7 | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1104 | 0 | goto error_return; | 1105 | | | 1106 | 7 | obj_pe (abfd) = true; | 1107 | | #ifdef THUMBPEMAGIC | 1108 | | if (vars.magic == THUMBPEMAGIC) | 1109 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1110 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1111 | | #endif | 1112 | | | 1113 | | /* Switch from file contents to memory contents. */ | 1114 | 7 | bfd_cache_close (abfd); | 1115 | | | 1116 | 7 | abfd->iostream = (void *) vars.bim; | 1117 | 7 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1118 | 7 | abfd->iovec = &_bfd_memory_iovec; | 1119 | 7 | abfd->where = 0; | 1120 | 7 | abfd->origin = 0; | 1121 | 7 | abfd->size = 0; | 1122 | 7 | obj_sym_filepos (abfd) = 0; | 1123 | | | 1124 | | /* Point the bfd at the symbol table. */ | 1125 | 7 | obj_symbols (abfd) = vars.sym_cache; | 1126 | 7 | abfd->symcount = vars.sym_index; | 1127 | | | 1128 | 7 | obj_raw_syments (abfd) = vars.native_syms; | 1129 | 7 | obj_raw_syment_count (abfd) = vars.sym_index; | 1130 | | | 1131 | 7 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1132 | 7 | obj_coff_keep_syms (abfd) = true; | 1133 | | | 1134 | 7 | obj_convert (abfd) = vars.sym_table; | 1135 | 7 | obj_conv_table_size (abfd) = vars.sym_index; | 1136 | | | 1137 | 7 | obj_coff_strings (abfd) = vars.string_table; | 1138 | 7 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1139 | 7 | obj_coff_keep_strings (abfd) = true; | 1140 | | | 1141 | 7 | return true; | 1142 | | | 1143 | 1 | error_return: | 1144 | 1 | free (vars.bim->buffer); | 1145 | 1 | free (vars.bim); | 1146 | 1 | return false; | 1147 | 7 | } |
pei-aarch64.c:pe_ILF_build_a_bfd Line | Count | Source | 786 | 8 | { | 787 | 8 | bfd_byte * ptr; | 788 | 8 | pe_ILF_vars vars; | 789 | 8 | struct internal_filehdr internal_f; | 790 | 8 | unsigned int import_type; | 791 | 8 | unsigned int import_name_type; | 792 | 8 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 793 | 8 | coff_symbol_type ** imp_sym; | 794 | 8 | unsigned int imp_index; | 795 | 8 | intptr_t alignment; | 796 | | | 797 | | /* Decode and verify the types field of the ILF structure. */ | 798 | 8 | import_type = types & 0x3; | 799 | 8 | import_name_type = (types & 0x1c) >> 2; | 800 | | | 801 | 8 | switch (import_type) | 802 | 8 | { | 803 | 5 | case IMPORT_CODE: | 804 | 6 | case IMPORT_DATA: | 805 | 6 | break; | 806 | | | 807 | 1 | case IMPORT_CONST: | 808 | | /* XXX code yet to be written. */ | 809 | | /* xgettext:c-format */ | 810 | 1 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 811 | 1 | abfd, import_type); | 812 | 1 | return false; | 813 | | | 814 | 1 | default: | 815 | | /* xgettext:c-format */ | 816 | 1 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 817 | 1 | abfd, import_type); | 818 | 1 | return false; | 819 | 8 | } | 820 | | | 821 | 6 | switch (import_name_type) | 822 | 6 | { | 823 | 4 | case IMPORT_ORDINAL: | 824 | 5 | case IMPORT_NAME: | 825 | 6 | case IMPORT_NAME_NOPREFIX: | 826 | 6 | case IMPORT_NAME_UNDECORATE: | 827 | 6 | break; | 828 | | | 829 | 0 | default: | 830 | | /* xgettext:c-format */ | 831 | 0 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 832 | 0 | abfd, import_name_type); | 833 | 0 | return false; | 834 | 6 | } | 835 | | | 836 | | /* Initialise local variables. | 837 | | | 838 | | Note these are kept in a structure rather than being | 839 | | declared as statics since bfd frowns on global variables. | 840 | | | 841 | | We are going to construct the contents of the BFD in memory, | 842 | | so allocate all the space that we will need right now. */ | 843 | 6 | vars.bim | 844 | 6 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 845 | 6 | if (vars.bim == NULL) | 846 | 0 | return false; | 847 | | | 848 | 6 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 849 | 6 | vars.bim->buffer = ptr; | 850 | 6 | vars.bim->size = ILF_DATA_SIZE; | 851 | 6 | if (ptr == NULL) | 852 | 0 | goto error_return; | 853 | | | 854 | | /* Initialise the pointers to regions of the memory and the | 855 | | other contents of the pe_ILF_vars structure as well. */ | 856 | 6 | vars.sym_cache = (coff_symbol_type *) ptr; | 857 | 6 | vars.sym_ptr = (coff_symbol_type *) ptr; | 858 | 6 | vars.sym_index = 0; | 859 | 6 | ptr += SIZEOF_ILF_SYMS; | 860 | | | 861 | 6 | vars.sym_table = (unsigned int *) ptr; | 862 | 6 | vars.table_ptr = (unsigned int *) ptr; | 863 | 6 | ptr += SIZEOF_ILF_SYM_TABLE; | 864 | | | 865 | 6 | vars.native_syms = (combined_entry_type *) ptr; | 866 | 6 | vars.native_ptr = (combined_entry_type *) ptr; | 867 | 6 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 868 | | | 869 | 6 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 870 | 6 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 871 | 6 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 872 | | | 873 | 6 | vars.esym_table = (SYMENT *) ptr; | 874 | 6 | vars.esym_ptr = (SYMENT *) ptr; | 875 | 6 | ptr += SIZEOF_ILF_EXT_SYMS; | 876 | | | 877 | 6 | vars.reltab = (arelent *) ptr; | 878 | 6 | vars.relcount = 0; | 879 | 6 | ptr += SIZEOF_ILF_RELOCS; | 880 | | | 881 | 6 | vars.int_reltab = (struct internal_reloc *) ptr; | 882 | 6 | ptr += SIZEOF_ILF_INT_RELOCS; | 883 | | | 884 | 6 | vars.string_table = (char *) ptr; | 885 | 6 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 886 | 6 | ptr += SIZEOF_ILF_STRINGS; | 887 | 6 | vars.end_string_ptr = (char *) ptr; | 888 | | | 889 | | /* The remaining space in bim->buffer is used | 890 | | by the pe_ILF_make_a_section() function. */ | 891 | | | 892 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 893 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 894 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 895 | | alignment. */ | 896 | 6 | #if GCC_VERSION >= 3000 | 897 | 6 | alignment = __alignof__ (struct coff_section_tdata); | 898 | | #else | 899 | | alignment = 8; | 900 | | #endif | 901 | 6 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 902 | | | 903 | 6 | vars.data = ptr; | 904 | 6 | vars.abfd = abfd; | 905 | 6 | vars.sec_index = 0; | 906 | 6 | vars.magic = magic; | 907 | | | 908 | | /* Create the initial .idata$<n> sections: | 909 | | [.idata$2: Import Directory Table -- not needed] | 910 | | .idata$4: Import Lookup Table | 911 | | .idata$5: Import Address Table | 912 | | | 913 | | Note we do not create a .idata$3 section as this is | 914 | | created for us by the linker script. */ | 915 | 6 | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 916 | 6 | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 917 | 6 | if (id4 == NULL || id5 == NULL) | 918 | 0 | goto error_return; | 919 | | | 920 | | /* Fill in the contents of these sections. */ | 921 | 6 | if (import_name_type == IMPORT_ORDINAL) | 922 | 4 | { | 923 | 4 | if (ordinal == 0) | 924 | | /* See PR 20907 for a reproducer. */ | 925 | 1 | goto error_return; | 926 | | | 927 | 3 | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 928 | 3 | ((unsigned int *) id4->contents)[0] = ordinal; | 929 | 3 | ((unsigned int *) id4->contents)[1] = 0x80000000; | 930 | 3 | ((unsigned int *) id5->contents)[0] = ordinal; | 931 | 3 | ((unsigned int *) id5->contents)[1] = 0x80000000; | 932 | | #else | 933 | | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 934 | | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 935 | | #endif | 936 | 3 | } | 937 | 2 | else | 938 | 2 | { | 939 | 2 | char * symbol; | 940 | 2 | unsigned int len; | 941 | | | 942 | | /* Create .idata$6 - the Hint Name Table. */ | 943 | 2 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 944 | 2 | if (id6 == NULL) | 945 | 0 | goto error_return; | 946 | | | 947 | | /* If necessary, trim the import symbol name. */ | 948 | 2 | symbol = symbol_name; | 949 | | | 950 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 951 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 952 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 953 | | of these is used for a symbol. We strip this leading char for | 954 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 955 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 956 | | | 957 | 2 | if (import_name_type != IMPORT_NAME) | 958 | 1 | { | 959 | 1 | char c = symbol[0]; | 960 | | | 961 | | /* Check that we don't remove for targets with empty | 962 | | USER_LABEL_PREFIX the leading underscore. */ | 963 | 1 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 964 | 1 | || c == '@' || c == '?') | 965 | 0 | symbol++; | 966 | 1 | } | 967 | | | 968 | 2 | len = strlen (symbol); | 969 | 2 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 970 | 0 | { | 971 | | /* Truncate at the first '@'. */ | 972 | 0 | char *at = strchr (symbol, '@'); | 973 | |
| 974 | 0 | if (at != NULL) | 975 | 0 | len = at - symbol; | 976 | 0 | } | 977 | | | 978 | 2 | id6->contents[0] = ordinal & 0xff; | 979 | 2 | id6->contents[1] = ordinal >> 8; | 980 | | | 981 | 2 | memcpy ((char *) id6->contents + 2, symbol, len); | 982 | 2 | id6->contents[len + 2] = '\0'; | 983 | 2 | } | 984 | | | 985 | 5 | if (import_name_type != IMPORT_ORDINAL) | 986 | 2 | { | 987 | 2 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 988 | 2 | pe_ILF_save_relocs (&vars, id4); | 989 | | | 990 | 2 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 991 | 2 | pe_ILF_save_relocs (&vars, id5); | 992 | 2 | } | 993 | | | 994 | | /* Create an import symbol. */ | 995 | 5 | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 996 | 5 | imp_sym = vars.sym_ptr_ptr - 1; | 997 | 5 | imp_index = vars.sym_index - 1; | 998 | | | 999 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1000 | 5 | switch (import_type) | 1001 | 5 | { | 1002 | 0 | int i; | 1003 | | | 1004 | 4 | case IMPORT_CODE: | 1005 | | /* CODE functions are special, in that they get a trampoline that | 1006 | | jumps to the main import symbol. Create a .text section to hold it. | 1007 | | First we need to look up its contents in the jump table. */ | 1008 | 8 | for (i = NUM_ENTRIES (jtab); i--;) | 1009 | 8 | { | 1010 | 8 | if (jtab[i].size == 0) | 1011 | 4 | continue; | 1012 | 4 | if (jtab[i].magic == magic) | 1013 | 4 | break; | 1014 | 4 | } | 1015 | | /* If we did not find a matching entry something is wrong. */ | 1016 | 4 | if (i < 0) | 1017 | 0 | abort (); | 1018 | | | 1019 | | /* Create the .text section. */ | 1020 | 4 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1021 | 4 | if (text == NULL) | 1022 | 0 | goto error_return; | 1023 | | | 1024 | | /* Copy in the jump code. */ | 1025 | 4 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1026 | | | 1027 | | /* Create a reloc for the data in the text section. */ | 1028 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1029 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1030 | | { | 1031 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1032 | | (struct bfd_symbol **) imp_sym, | 1033 | | imp_index); | 1034 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1035 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1036 | | (struct bfd_symbol **) imp_sym, | 1037 | | imp_index); | 1038 | | } | 1039 | | else | 1040 | | #endif | 1041 | | #ifdef AMD64MAGIC | 1042 | | if (magic == AMD64MAGIC) | 1043 | | { | 1044 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1045 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1046 | | imp_index); | 1047 | | } | 1048 | | else | 1049 | | #endif | 1050 | 4 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1051 | 4 | BFD_RELOC_32, (asymbol **) imp_sym, | 1052 | 4 | imp_index); | 1053 | | | 1054 | 4 | pe_ILF_save_relocs (& vars, text); | 1055 | 4 | break; | 1056 | | | 1057 | 1 | case IMPORT_DATA: | 1058 | 1 | break; | 1059 | | | 1060 | 0 | default: | 1061 | | /* XXX code not yet written. */ | 1062 | 0 | abort (); | 1063 | 5 | } | 1064 | | | 1065 | | /* Now create a symbol describing the imported value. */ | 1066 | 5 | switch (import_type) | 1067 | 5 | { | 1068 | 4 | case IMPORT_CODE: | 1069 | 4 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1070 | 4 | BSF_NOT_AT_END | BSF_FUNCTION); | 1071 | | | 1072 | 4 | break; | 1073 | | | 1074 | 1 | case IMPORT_DATA: | 1075 | | /* Nothing to do here. */ | 1076 | 1 | break; | 1077 | | | 1078 | 0 | default: | 1079 | | /* XXX code not yet written. */ | 1080 | 0 | abort (); | 1081 | 5 | } | 1082 | | | 1083 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1084 | 5 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1085 | 5 | if (ptr) | 1086 | 1 | * ptr = 0; | 1087 | 5 | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1088 | 5 | if (ptr) | 1089 | 1 | * ptr = '.'; | 1090 | | | 1091 | | /* Initialise the bfd. */ | 1092 | 5 | memset (& internal_f, 0, sizeof (internal_f)); | 1093 | | | 1094 | 5 | internal_f.f_magic = magic; | 1095 | 5 | internal_f.f_symptr = 0; | 1096 | 5 | internal_f.f_nsyms = 0; | 1097 | 5 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1098 | | | 1099 | 5 | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1100 | 5 | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1101 | 0 | goto error_return; | 1102 | | | 1103 | 5 | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1104 | 0 | goto error_return; | 1105 | | | 1106 | 5 | obj_pe (abfd) = true; | 1107 | | #ifdef THUMBPEMAGIC | 1108 | | if (vars.magic == THUMBPEMAGIC) | 1109 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1110 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1111 | | #endif | 1112 | | | 1113 | | /* Switch from file contents to memory contents. */ | 1114 | 5 | bfd_cache_close (abfd); | 1115 | | | 1116 | 5 | abfd->iostream = (void *) vars.bim; | 1117 | 5 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1118 | 5 | abfd->iovec = &_bfd_memory_iovec; | 1119 | 5 | abfd->where = 0; | 1120 | 5 | abfd->origin = 0; | 1121 | 5 | abfd->size = 0; | 1122 | 5 | obj_sym_filepos (abfd) = 0; | 1123 | | | 1124 | | /* Point the bfd at the symbol table. */ | 1125 | 5 | obj_symbols (abfd) = vars.sym_cache; | 1126 | 5 | abfd->symcount = vars.sym_index; | 1127 | | | 1128 | 5 | obj_raw_syments (abfd) = vars.native_syms; | 1129 | 5 | obj_raw_syment_count (abfd) = vars.sym_index; | 1130 | | | 1131 | 5 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1132 | 5 | obj_coff_keep_syms (abfd) = true; | 1133 | | | 1134 | 5 | obj_convert (abfd) = vars.sym_table; | 1135 | 5 | obj_conv_table_size (abfd) = vars.sym_index; | 1136 | | | 1137 | 5 | obj_coff_strings (abfd) = vars.string_table; | 1138 | 5 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1139 | 5 | obj_coff_keep_strings (abfd) = true; | 1140 | | | 1141 | 5 | return true; | 1142 | | | 1143 | 1 | error_return: | 1144 | 1 | free (vars.bim->buffer); | 1145 | 1 | free (vars.bim); | 1146 | 1 | return false; | 1147 | 5 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_build_a_bfd pei-loongarch64.c:pe_ILF_build_a_bfd Line | Count | Source | 786 | 11 | { | 787 | 11 | bfd_byte * ptr; | 788 | 11 | pe_ILF_vars vars; | 789 | 11 | struct internal_filehdr internal_f; | 790 | 11 | unsigned int import_type; | 791 | 11 | unsigned int import_name_type; | 792 | 11 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 793 | 11 | coff_symbol_type ** imp_sym; | 794 | 11 | unsigned int imp_index; | 795 | 11 | intptr_t alignment; | 796 | | | 797 | | /* Decode and verify the types field of the ILF structure. */ | 798 | 11 | import_type = types & 0x3; | 799 | 11 | import_name_type = (types & 0x1c) >> 2; | 800 | | | 801 | 11 | switch (import_type) | 802 | 11 | { | 803 | 2 | case IMPORT_CODE: | 804 | 9 | case IMPORT_DATA: | 805 | 9 | break; | 806 | | | 807 | 1 | case IMPORT_CONST: | 808 | | /* XXX code yet to be written. */ | 809 | | /* xgettext:c-format */ | 810 | 1 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 811 | 1 | abfd, import_type); | 812 | 1 | return false; | 813 | | | 814 | 1 | default: | 815 | | /* xgettext:c-format */ | 816 | 1 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 817 | 1 | abfd, import_type); | 818 | 1 | return false; | 819 | 11 | } | 820 | | | 821 | 9 | switch (import_name_type) | 822 | 9 | { | 823 | 2 | case IMPORT_ORDINAL: | 824 | 4 | case IMPORT_NAME: | 825 | 4 | case IMPORT_NAME_NOPREFIX: | 826 | 6 | case IMPORT_NAME_UNDECORATE: | 827 | 6 | break; | 828 | | | 829 | 3 | default: | 830 | | /* xgettext:c-format */ | 831 | 3 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 832 | 3 | abfd, import_name_type); | 833 | 3 | return false; | 834 | 9 | } | 835 | | | 836 | | /* Initialise local variables. | 837 | | | 838 | | Note these are kept in a structure rather than being | 839 | | declared as statics since bfd frowns on global variables. | 840 | | | 841 | | We are going to construct the contents of the BFD in memory, | 842 | | so allocate all the space that we will need right now. */ | 843 | 6 | vars.bim | 844 | 6 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 845 | 6 | if (vars.bim == NULL) | 846 | 0 | return false; | 847 | | | 848 | 6 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 849 | 6 | vars.bim->buffer = ptr; | 850 | 6 | vars.bim->size = ILF_DATA_SIZE; | 851 | 6 | if (ptr == NULL) | 852 | 0 | goto error_return; | 853 | | | 854 | | /* Initialise the pointers to regions of the memory and the | 855 | | other contents of the pe_ILF_vars structure as well. */ | 856 | 6 | vars.sym_cache = (coff_symbol_type *) ptr; | 857 | 6 | vars.sym_ptr = (coff_symbol_type *) ptr; | 858 | 6 | vars.sym_index = 0; | 859 | 6 | ptr += SIZEOF_ILF_SYMS; | 860 | | | 861 | 6 | vars.sym_table = (unsigned int *) ptr; | 862 | 6 | vars.table_ptr = (unsigned int *) ptr; | 863 | 6 | ptr += SIZEOF_ILF_SYM_TABLE; | 864 | | | 865 | 6 | vars.native_syms = (combined_entry_type *) ptr; | 866 | 6 | vars.native_ptr = (combined_entry_type *) ptr; | 867 | 6 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 868 | | | 869 | 6 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 870 | 6 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 871 | 6 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 872 | | | 873 | 6 | vars.esym_table = (SYMENT *) ptr; | 874 | 6 | vars.esym_ptr = (SYMENT *) ptr; | 875 | 6 | ptr += SIZEOF_ILF_EXT_SYMS; | 876 | | | 877 | 6 | vars.reltab = (arelent *) ptr; | 878 | 6 | vars.relcount = 0; | 879 | 6 | ptr += SIZEOF_ILF_RELOCS; | 880 | | | 881 | 6 | vars.int_reltab = (struct internal_reloc *) ptr; | 882 | 6 | ptr += SIZEOF_ILF_INT_RELOCS; | 883 | | | 884 | 6 | vars.string_table = (char *) ptr; | 885 | 6 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 886 | 6 | ptr += SIZEOF_ILF_STRINGS; | 887 | 6 | vars.end_string_ptr = (char *) ptr; | 888 | | | 889 | | /* The remaining space in bim->buffer is used | 890 | | by the pe_ILF_make_a_section() function. */ | 891 | | | 892 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 893 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 894 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 895 | | alignment. */ | 896 | 6 | #if GCC_VERSION >= 3000 | 897 | 6 | alignment = __alignof__ (struct coff_section_tdata); | 898 | | #else | 899 | | alignment = 8; | 900 | | #endif | 901 | 6 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 902 | | | 903 | 6 | vars.data = ptr; | 904 | 6 | vars.abfd = abfd; | 905 | 6 | vars.sec_index = 0; | 906 | 6 | vars.magic = magic; | 907 | | | 908 | | /* Create the initial .idata$<n> sections: | 909 | | [.idata$2: Import Directory Table -- not needed] | 910 | | .idata$4: Import Lookup Table | 911 | | .idata$5: Import Address Table | 912 | | | 913 | | Note we do not create a .idata$3 section as this is | 914 | | created for us by the linker script. */ | 915 | 6 | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 916 | 6 | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 917 | 6 | if (id4 == NULL || id5 == NULL) | 918 | 0 | goto error_return; | 919 | | | 920 | | /* Fill in the contents of these sections. */ | 921 | 6 | if (import_name_type == IMPORT_ORDINAL) | 922 | 2 | { | 923 | 2 | if (ordinal == 0) | 924 | | /* See PR 20907 for a reproducer. */ | 925 | 0 | goto error_return; | 926 | | | 927 | 2 | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 928 | 2 | ((unsigned int *) id4->contents)[0] = ordinal; | 929 | 2 | ((unsigned int *) id4->contents)[1] = 0x80000000; | 930 | 2 | ((unsigned int *) id5->contents)[0] = ordinal; | 931 | 2 | ((unsigned int *) id5->contents)[1] = 0x80000000; | 932 | | #else | 933 | | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 934 | | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 935 | | #endif | 936 | 2 | } | 937 | 4 | else | 938 | 4 | { | 939 | 4 | char * symbol; | 940 | 4 | unsigned int len; | 941 | | | 942 | | /* Create .idata$6 - the Hint Name Table. */ | 943 | 4 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 944 | 4 | if (id6 == NULL) | 945 | 0 | goto error_return; | 946 | | | 947 | | /* If necessary, trim the import symbol name. */ | 948 | 4 | symbol = symbol_name; | 949 | | | 950 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 951 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 952 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 953 | | of these is used for a symbol. We strip this leading char for | 954 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 955 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 956 | | | 957 | 4 | if (import_name_type != IMPORT_NAME) | 958 | 2 | { | 959 | 2 | char c = symbol[0]; | 960 | | | 961 | | /* Check that we don't remove for targets with empty | 962 | | USER_LABEL_PREFIX the leading underscore. */ | 963 | 2 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 964 | 2 | || c == '@' || c == '?') | 965 | 1 | symbol++; | 966 | 2 | } | 967 | | | 968 | 4 | len = strlen (symbol); | 969 | 4 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 970 | 2 | { | 971 | | /* Truncate at the first '@'. */ | 972 | 2 | char *at = strchr (symbol, '@'); | 973 | | | 974 | 2 | if (at != NULL) | 975 | 1 | len = at - symbol; | 976 | 2 | } | 977 | | | 978 | 4 | id6->contents[0] = ordinal & 0xff; | 979 | 4 | id6->contents[1] = ordinal >> 8; | 980 | | | 981 | 4 | memcpy ((char *) id6->contents + 2, symbol, len); | 982 | 4 | id6->contents[len + 2] = '\0'; | 983 | 4 | } | 984 | | | 985 | 6 | if (import_name_type != IMPORT_ORDINAL) | 986 | 4 | { | 987 | 4 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 988 | 4 | pe_ILF_save_relocs (&vars, id4); | 989 | | | 990 | 4 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 991 | 4 | pe_ILF_save_relocs (&vars, id5); | 992 | 4 | } | 993 | | | 994 | | /* Create an import symbol. */ | 995 | 6 | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 996 | 6 | imp_sym = vars.sym_ptr_ptr - 1; | 997 | 6 | imp_index = vars.sym_index - 1; | 998 | | | 999 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1000 | 6 | switch (import_type) | 1001 | 6 | { | 1002 | 0 | int i; | 1003 | | | 1004 | 2 | case IMPORT_CODE: | 1005 | | /* CODE functions are special, in that they get a trampoline that | 1006 | | jumps to the main import symbol. Create a .text section to hold it. | 1007 | | First we need to look up its contents in the jump table. */ | 1008 | 4 | for (i = NUM_ENTRIES (jtab); i--;) | 1009 | 4 | { | 1010 | 4 | if (jtab[i].size == 0) | 1011 | 2 | continue; | 1012 | 2 | if (jtab[i].magic == magic) | 1013 | 2 | break; | 1014 | 2 | } | 1015 | | /* If we did not find a matching entry something is wrong. */ | 1016 | 2 | if (i < 0) | 1017 | 0 | abort (); | 1018 | | | 1019 | | /* Create the .text section. */ | 1020 | 2 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1021 | 2 | if (text == NULL) | 1022 | 0 | goto error_return; | 1023 | | | 1024 | | /* Copy in the jump code. */ | 1025 | 2 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1026 | | | 1027 | | /* Create a reloc for the data in the text section. */ | 1028 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1029 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1030 | | { | 1031 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1032 | | (struct bfd_symbol **) imp_sym, | 1033 | | imp_index); | 1034 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1035 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1036 | | (struct bfd_symbol **) imp_sym, | 1037 | | imp_index); | 1038 | | } | 1039 | | else | 1040 | | #endif | 1041 | | #ifdef AMD64MAGIC | 1042 | | if (magic == AMD64MAGIC) | 1043 | | { | 1044 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1045 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1046 | | imp_index); | 1047 | | } | 1048 | | else | 1049 | | #endif | 1050 | 2 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1051 | 2 | BFD_RELOC_32, (asymbol **) imp_sym, | 1052 | 2 | imp_index); | 1053 | | | 1054 | 2 | pe_ILF_save_relocs (& vars, text); | 1055 | 2 | break; | 1056 | | | 1057 | 4 | case IMPORT_DATA: | 1058 | 4 | break; | 1059 | | | 1060 | 0 | default: | 1061 | | /* XXX code not yet written. */ | 1062 | 0 | abort (); | 1063 | 6 | } | 1064 | | | 1065 | | /* Now create a symbol describing the imported value. */ | 1066 | 6 | switch (import_type) | 1067 | 6 | { | 1068 | 2 | case IMPORT_CODE: | 1069 | 2 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1070 | 2 | BSF_NOT_AT_END | BSF_FUNCTION); | 1071 | | | 1072 | 2 | break; | 1073 | | | 1074 | 4 | case IMPORT_DATA: | 1075 | | /* Nothing to do here. */ | 1076 | 4 | break; | 1077 | | | 1078 | 0 | default: | 1079 | | /* XXX code not yet written. */ | 1080 | 0 | abort (); | 1081 | 6 | } | 1082 | | | 1083 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1084 | 6 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1085 | 6 | if (ptr) | 1086 | 0 | * ptr = 0; | 1087 | 6 | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1088 | 6 | if (ptr) | 1089 | 0 | * ptr = '.'; | 1090 | | | 1091 | | /* Initialise the bfd. */ | 1092 | 6 | memset (& internal_f, 0, sizeof (internal_f)); | 1093 | | | 1094 | 6 | internal_f.f_magic = magic; | 1095 | 6 | internal_f.f_symptr = 0; | 1096 | 6 | internal_f.f_nsyms = 0; | 1097 | 6 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1098 | | | 1099 | 6 | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1100 | 6 | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1101 | 0 | goto error_return; | 1102 | | | 1103 | 6 | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1104 | 0 | goto error_return; | 1105 | | | 1106 | 6 | obj_pe (abfd) = true; | 1107 | | #ifdef THUMBPEMAGIC | 1108 | | if (vars.magic == THUMBPEMAGIC) | 1109 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1110 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1111 | | #endif | 1112 | | | 1113 | | /* Switch from file contents to memory contents. */ | 1114 | 6 | bfd_cache_close (abfd); | 1115 | | | 1116 | 6 | abfd->iostream = (void *) vars.bim; | 1117 | 6 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1118 | 6 | abfd->iovec = &_bfd_memory_iovec; | 1119 | 6 | abfd->where = 0; | 1120 | 6 | abfd->origin = 0; | 1121 | 6 | abfd->size = 0; | 1122 | 6 | obj_sym_filepos (abfd) = 0; | 1123 | | | 1124 | | /* Point the bfd at the symbol table. */ | 1125 | 6 | obj_symbols (abfd) = vars.sym_cache; | 1126 | 6 | abfd->symcount = vars.sym_index; | 1127 | | | 1128 | 6 | obj_raw_syments (abfd) = vars.native_syms; | 1129 | 6 | obj_raw_syment_count (abfd) = vars.sym_index; | 1130 | | | 1131 | 6 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1132 | 6 | obj_coff_keep_syms (abfd) = true; | 1133 | | | 1134 | 6 | obj_convert (abfd) = vars.sym_table; | 1135 | 6 | obj_conv_table_size (abfd) = vars.sym_index; | 1136 | | | 1137 | 6 | obj_coff_strings (abfd) = vars.string_table; | 1138 | 6 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1139 | 6 | obj_coff_keep_strings (abfd) = true; | 1140 | | | 1141 | 6 | return true; | 1142 | | | 1143 | 0 | error_return: | 1144 | 0 | free (vars.bim->buffer); | 1145 | 0 | free (vars.bim); | 1146 | 0 | return false; | 1147 | 6 | } |
pei-arm-wince.c:pe_ILF_build_a_bfd Line | Count | Source | 786 | 14 | { | 787 | 14 | bfd_byte * ptr; | 788 | 14 | pe_ILF_vars vars; | 789 | 14 | struct internal_filehdr internal_f; | 790 | 14 | unsigned int import_type; | 791 | 14 | unsigned int import_name_type; | 792 | 14 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 793 | 14 | coff_symbol_type ** imp_sym; | 794 | 14 | unsigned int imp_index; | 795 | 14 | intptr_t alignment; | 796 | | | 797 | | /* Decode and verify the types field of the ILF structure. */ | 798 | 14 | import_type = types & 0x3; | 799 | 14 | import_name_type = (types & 0x1c) >> 2; | 800 | | | 801 | 14 | switch (import_type) | 802 | 14 | { | 803 | 7 | case IMPORT_CODE: | 804 | 10 | case IMPORT_DATA: | 805 | 10 | break; | 806 | | | 807 | 1 | case IMPORT_CONST: | 808 | | /* XXX code yet to be written. */ | 809 | | /* xgettext:c-format */ | 810 | 1 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 811 | 1 | abfd, import_type); | 812 | 1 | return false; | 813 | | | 814 | 3 | default: | 815 | | /* xgettext:c-format */ | 816 | 3 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 817 | 3 | abfd, import_type); | 818 | 3 | return false; | 819 | 14 | } | 820 | | | 821 | 10 | switch (import_name_type) | 822 | 10 | { | 823 | 5 | case IMPORT_ORDINAL: | 824 | 6 | case IMPORT_NAME: | 825 | 8 | case IMPORT_NAME_NOPREFIX: | 826 | 9 | case IMPORT_NAME_UNDECORATE: | 827 | 9 | break; | 828 | | | 829 | 1 | default: | 830 | | /* xgettext:c-format */ | 831 | 1 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 832 | 1 | abfd, import_name_type); | 833 | 1 | return false; | 834 | 10 | } | 835 | | | 836 | | /* Initialise local variables. | 837 | | | 838 | | Note these are kept in a structure rather than being | 839 | | declared as statics since bfd frowns on global variables. | 840 | | | 841 | | We are going to construct the contents of the BFD in memory, | 842 | | so allocate all the space that we will need right now. */ | 843 | 9 | vars.bim | 844 | 9 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 845 | 9 | if (vars.bim == NULL) | 846 | 0 | return false; | 847 | | | 848 | 9 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 849 | 9 | vars.bim->buffer = ptr; | 850 | 9 | vars.bim->size = ILF_DATA_SIZE; | 851 | 9 | if (ptr == NULL) | 852 | 0 | goto error_return; | 853 | | | 854 | | /* Initialise the pointers to regions of the memory and the | 855 | | other contents of the pe_ILF_vars structure as well. */ | 856 | 9 | vars.sym_cache = (coff_symbol_type *) ptr; | 857 | 9 | vars.sym_ptr = (coff_symbol_type *) ptr; | 858 | 9 | vars.sym_index = 0; | 859 | 9 | ptr += SIZEOF_ILF_SYMS; | 860 | | | 861 | 9 | vars.sym_table = (unsigned int *) ptr; | 862 | 9 | vars.table_ptr = (unsigned int *) ptr; | 863 | 9 | ptr += SIZEOF_ILF_SYM_TABLE; | 864 | | | 865 | 9 | vars.native_syms = (combined_entry_type *) ptr; | 866 | 9 | vars.native_ptr = (combined_entry_type *) ptr; | 867 | 9 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 868 | | | 869 | 9 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 870 | 9 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 871 | 9 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 872 | | | 873 | 9 | vars.esym_table = (SYMENT *) ptr; | 874 | 9 | vars.esym_ptr = (SYMENT *) ptr; | 875 | 9 | ptr += SIZEOF_ILF_EXT_SYMS; | 876 | | | 877 | 9 | vars.reltab = (arelent *) ptr; | 878 | 9 | vars.relcount = 0; | 879 | 9 | ptr += SIZEOF_ILF_RELOCS; | 880 | | | 881 | 9 | vars.int_reltab = (struct internal_reloc *) ptr; | 882 | 9 | ptr += SIZEOF_ILF_INT_RELOCS; | 883 | | | 884 | 9 | vars.string_table = (char *) ptr; | 885 | 9 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 886 | 9 | ptr += SIZEOF_ILF_STRINGS; | 887 | 9 | vars.end_string_ptr = (char *) ptr; | 888 | | | 889 | | /* The remaining space in bim->buffer is used | 890 | | by the pe_ILF_make_a_section() function. */ | 891 | | | 892 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 893 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 894 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 895 | | alignment. */ | 896 | 9 | #if GCC_VERSION >= 3000 | 897 | 9 | alignment = __alignof__ (struct coff_section_tdata); | 898 | | #else | 899 | | alignment = 8; | 900 | | #endif | 901 | 9 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 902 | | | 903 | 9 | vars.data = ptr; | 904 | 9 | vars.abfd = abfd; | 905 | 9 | vars.sec_index = 0; | 906 | 9 | vars.magic = magic; | 907 | | | 908 | | /* Create the initial .idata$<n> sections: | 909 | | [.idata$2: Import Directory Table -- not needed] | 910 | | .idata$4: Import Lookup Table | 911 | | .idata$5: Import Address Table | 912 | | | 913 | | Note we do not create a .idata$3 section as this is | 914 | | created for us by the linker script. */ | 915 | 9 | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 916 | 9 | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 917 | 9 | if (id4 == NULL || id5 == NULL) | 918 | 0 | goto error_return; | 919 | | | 920 | | /* Fill in the contents of these sections. */ | 921 | 9 | if (import_name_type == IMPORT_ORDINAL) | 922 | 5 | { | 923 | 5 | if (ordinal == 0) | 924 | | /* See PR 20907 for a reproducer. */ | 925 | 2 | goto error_return; | 926 | | | 927 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 928 | | ((unsigned int *) id4->contents)[0] = ordinal; | 929 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 930 | | ((unsigned int *) id5->contents)[0] = ordinal; | 931 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 932 | | #else | 933 | 3 | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 934 | 3 | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 935 | 3 | #endif | 936 | 3 | } | 937 | 4 | else | 938 | 4 | { | 939 | 4 | char * symbol; | 940 | 4 | unsigned int len; | 941 | | | 942 | | /* Create .idata$6 - the Hint Name Table. */ | 943 | 4 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 944 | 4 | if (id6 == NULL) | 945 | 0 | goto error_return; | 946 | | | 947 | | /* If necessary, trim the import symbol name. */ | 948 | 4 | symbol = symbol_name; | 949 | | | 950 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 951 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 952 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 953 | | of these is used for a symbol. We strip this leading char for | 954 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 955 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 956 | | | 957 | 4 | if (import_name_type != IMPORT_NAME) | 958 | 3 | { | 959 | 3 | char c = symbol[0]; | 960 | | | 961 | | /* Check that we don't remove for targets with empty | 962 | | USER_LABEL_PREFIX the leading underscore. */ | 963 | 3 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 964 | 3 | || c == '@' || c == '?') | 965 | 0 | symbol++; | 966 | 3 | } | 967 | | | 968 | 4 | len = strlen (symbol); | 969 | 4 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 970 | 1 | { | 971 | | /* Truncate at the first '@'. */ | 972 | 1 | char *at = strchr (symbol, '@'); | 973 | | | 974 | 1 | if (at != NULL) | 975 | 0 | len = at - symbol; | 976 | 1 | } | 977 | | | 978 | 4 | id6->contents[0] = ordinal & 0xff; | 979 | 4 | id6->contents[1] = ordinal >> 8; | 980 | | | 981 | 4 | memcpy ((char *) id6->contents + 2, symbol, len); | 982 | 4 | id6->contents[len + 2] = '\0'; | 983 | 4 | } | 984 | | | 985 | 7 | if (import_name_type != IMPORT_ORDINAL) | 986 | 4 | { | 987 | 4 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 988 | 4 | pe_ILF_save_relocs (&vars, id4); | 989 | | | 990 | 4 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 991 | 4 | pe_ILF_save_relocs (&vars, id5); | 992 | 4 | } | 993 | | | 994 | | /* Create an import symbol. */ | 995 | 7 | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 996 | 7 | imp_sym = vars.sym_ptr_ptr - 1; | 997 | 7 | imp_index = vars.sym_index - 1; | 998 | | | 999 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1000 | 7 | switch (import_type) | 1001 | 7 | { | 1002 | 0 | int i; | 1003 | | | 1004 | 4 | case IMPORT_CODE: | 1005 | | /* CODE functions are special, in that they get a trampoline that | 1006 | | jumps to the main import symbol. Create a .text section to hold it. | 1007 | | First we need to look up its contents in the jump table. */ | 1008 | 11 | for (i = NUM_ENTRIES (jtab); i--;) | 1009 | 11 | { | 1010 | 11 | if (jtab[i].size == 0) | 1011 | 4 | continue; | 1012 | 7 | if (jtab[i].magic == magic) | 1013 | 4 | break; | 1014 | 7 | } | 1015 | | /* If we did not find a matching entry something is wrong. */ | 1016 | 4 | if (i < 0) | 1017 | 0 | abort (); | 1018 | | | 1019 | | /* Create the .text section. */ | 1020 | 4 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1021 | 4 | if (text == NULL) | 1022 | 0 | goto error_return; | 1023 | | | 1024 | | /* Copy in the jump code. */ | 1025 | 4 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1026 | | | 1027 | | /* Create a reloc for the data in the text section. */ | 1028 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1029 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1030 | | { | 1031 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1032 | | (struct bfd_symbol **) imp_sym, | 1033 | | imp_index); | 1034 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1035 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1036 | | (struct bfd_symbol **) imp_sym, | 1037 | | imp_index); | 1038 | | } | 1039 | | else | 1040 | | #endif | 1041 | | #ifdef AMD64MAGIC | 1042 | | if (magic == AMD64MAGIC) | 1043 | | { | 1044 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1045 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1046 | | imp_index); | 1047 | | } | 1048 | | else | 1049 | | #endif | 1050 | 4 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1051 | 4 | BFD_RELOC_32, (asymbol **) imp_sym, | 1052 | 4 | imp_index); | 1053 | | | 1054 | 4 | pe_ILF_save_relocs (& vars, text); | 1055 | 4 | break; | 1056 | | | 1057 | 3 | case IMPORT_DATA: | 1058 | 3 | break; | 1059 | | | 1060 | 0 | default: | 1061 | | /* XXX code not yet written. */ | 1062 | 0 | abort (); | 1063 | 7 | } | 1064 | | | 1065 | | /* Now create a symbol describing the imported value. */ | 1066 | 7 | switch (import_type) | 1067 | 7 | { | 1068 | 4 | case IMPORT_CODE: | 1069 | 4 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1070 | 4 | BSF_NOT_AT_END | BSF_FUNCTION); | 1071 | | | 1072 | 4 | break; | 1073 | | | 1074 | 3 | case IMPORT_DATA: | 1075 | | /* Nothing to do here. */ | 1076 | 3 | break; | 1077 | | | 1078 | 0 | default: | 1079 | | /* XXX code not yet written. */ | 1080 | 0 | abort (); | 1081 | 7 | } | 1082 | | | 1083 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1084 | 7 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1085 | 7 | if (ptr) | 1086 | 1 | * ptr = 0; | 1087 | 7 | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1088 | 7 | if (ptr) | 1089 | 1 | * ptr = '.'; | 1090 | | | 1091 | | /* Initialise the bfd. */ | 1092 | 7 | memset (& internal_f, 0, sizeof (internal_f)); | 1093 | | | 1094 | 7 | internal_f.f_magic = magic; | 1095 | 7 | internal_f.f_symptr = 0; | 1096 | 7 | internal_f.f_nsyms = 0; | 1097 | 7 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1098 | | | 1099 | 7 | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1100 | 7 | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1101 | 0 | goto error_return; | 1102 | | | 1103 | 7 | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1104 | 0 | goto error_return; | 1105 | | | 1106 | 7 | obj_pe (abfd) = true; | 1107 | 7 | #ifdef THUMBPEMAGIC | 1108 | 7 | if (vars.magic == THUMBPEMAGIC) | 1109 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1110 | 1 | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1111 | 7 | #endif | 1112 | | | 1113 | | /* Switch from file contents to memory contents. */ | 1114 | 7 | bfd_cache_close (abfd); | 1115 | | | 1116 | 7 | abfd->iostream = (void *) vars.bim; | 1117 | 7 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1118 | 7 | abfd->iovec = &_bfd_memory_iovec; | 1119 | 7 | abfd->where = 0; | 1120 | 7 | abfd->origin = 0; | 1121 | 7 | abfd->size = 0; | 1122 | 7 | obj_sym_filepos (abfd) = 0; | 1123 | | | 1124 | | /* Point the bfd at the symbol table. */ | 1125 | 7 | obj_symbols (abfd) = vars.sym_cache; | 1126 | 7 | abfd->symcount = vars.sym_index; | 1127 | | | 1128 | 7 | obj_raw_syments (abfd) = vars.native_syms; | 1129 | 7 | obj_raw_syment_count (abfd) = vars.sym_index; | 1130 | | | 1131 | 7 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1132 | 7 | obj_coff_keep_syms (abfd) = true; | 1133 | | | 1134 | 7 | obj_convert (abfd) = vars.sym_table; | 1135 | 7 | obj_conv_table_size (abfd) = vars.sym_index; | 1136 | | | 1137 | 7 | obj_coff_strings (abfd) = vars.string_table; | 1138 | 7 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1139 | 7 | obj_coff_keep_strings (abfd) = true; | 1140 | | | 1141 | 7 | return true; | 1142 | | | 1143 | 2 | error_return: | 1144 | 2 | free (vars.bim->buffer); | 1145 | 2 | free (vars.bim); | 1146 | 2 | return false; | 1147 | 7 | } |
pei-arm.c:pe_ILF_build_a_bfd Line | Count | Source | 786 | 22 | { | 787 | 22 | bfd_byte * ptr; | 788 | 22 | pe_ILF_vars vars; | 789 | 22 | struct internal_filehdr internal_f; | 790 | 22 | unsigned int import_type; | 791 | 22 | unsigned int import_name_type; | 792 | 22 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 793 | 22 | coff_symbol_type ** imp_sym; | 794 | 22 | unsigned int imp_index; | 795 | 22 | intptr_t alignment; | 796 | | | 797 | | /* Decode and verify the types field of the ILF structure. */ | 798 | 22 | import_type = types & 0x3; | 799 | 22 | import_name_type = (types & 0x1c) >> 2; | 800 | | | 801 | 22 | switch (import_type) | 802 | 22 | { | 803 | 12 | case IMPORT_CODE: | 804 | 18 | case IMPORT_DATA: | 805 | 18 | break; | 806 | | | 807 | 1 | case IMPORT_CONST: | 808 | | /* XXX code yet to be written. */ | 809 | | /* xgettext:c-format */ | 810 | 1 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 811 | 1 | abfd, import_type); | 812 | 1 | return false; | 813 | | | 814 | 3 | default: | 815 | | /* xgettext:c-format */ | 816 | 3 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 817 | 3 | abfd, import_type); | 818 | 3 | return false; | 819 | 22 | } | 820 | | | 821 | 18 | switch (import_name_type) | 822 | 18 | { | 823 | 6 | case IMPORT_ORDINAL: | 824 | 7 | case IMPORT_NAME: | 825 | 9 | case IMPORT_NAME_NOPREFIX: | 826 | 17 | case IMPORT_NAME_UNDECORATE: | 827 | 17 | break; | 828 | | | 829 | 1 | default: | 830 | | /* xgettext:c-format */ | 831 | 1 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 832 | 1 | abfd, import_name_type); | 833 | 1 | return false; | 834 | 18 | } | 835 | | | 836 | | /* Initialise local variables. | 837 | | | 838 | | Note these are kept in a structure rather than being | 839 | | declared as statics since bfd frowns on global variables. | 840 | | | 841 | | We are going to construct the contents of the BFD in memory, | 842 | | so allocate all the space that we will need right now. */ | 843 | 17 | vars.bim | 844 | 17 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 845 | 17 | if (vars.bim == NULL) | 846 | 0 | return false; | 847 | | | 848 | 17 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 849 | 17 | vars.bim->buffer = ptr; | 850 | 17 | vars.bim->size = ILF_DATA_SIZE; | 851 | 17 | if (ptr == NULL) | 852 | 0 | goto error_return; | 853 | | | 854 | | /* Initialise the pointers to regions of the memory and the | 855 | | other contents of the pe_ILF_vars structure as well. */ | 856 | 17 | vars.sym_cache = (coff_symbol_type *) ptr; | 857 | 17 | vars.sym_ptr = (coff_symbol_type *) ptr; | 858 | 17 | vars.sym_index = 0; | 859 | 17 | ptr += SIZEOF_ILF_SYMS; | 860 | | | 861 | 17 | vars.sym_table = (unsigned int *) ptr; | 862 | 17 | vars.table_ptr = (unsigned int *) ptr; | 863 | 17 | ptr += SIZEOF_ILF_SYM_TABLE; | 864 | | | 865 | 17 | vars.native_syms = (combined_entry_type *) ptr; | 866 | 17 | vars.native_ptr = (combined_entry_type *) ptr; | 867 | 17 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 868 | | | 869 | 17 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 870 | 17 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 871 | 17 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 872 | | | 873 | 17 | vars.esym_table = (SYMENT *) ptr; | 874 | 17 | vars.esym_ptr = (SYMENT *) ptr; | 875 | 17 | ptr += SIZEOF_ILF_EXT_SYMS; | 876 | | | 877 | 17 | vars.reltab = (arelent *) ptr; | 878 | 17 | vars.relcount = 0; | 879 | 17 | ptr += SIZEOF_ILF_RELOCS; | 880 | | | 881 | 17 | vars.int_reltab = (struct internal_reloc *) ptr; | 882 | 17 | ptr += SIZEOF_ILF_INT_RELOCS; | 883 | | | 884 | 17 | vars.string_table = (char *) ptr; | 885 | 17 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 886 | 17 | ptr += SIZEOF_ILF_STRINGS; | 887 | 17 | vars.end_string_ptr = (char *) ptr; | 888 | | | 889 | | /* The remaining space in bim->buffer is used | 890 | | by the pe_ILF_make_a_section() function. */ | 891 | | | 892 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 893 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 894 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 895 | | alignment. */ | 896 | 17 | #if GCC_VERSION >= 3000 | 897 | 17 | alignment = __alignof__ (struct coff_section_tdata); | 898 | | #else | 899 | | alignment = 8; | 900 | | #endif | 901 | 17 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 902 | | | 903 | 17 | vars.data = ptr; | 904 | 17 | vars.abfd = abfd; | 905 | 17 | vars.sec_index = 0; | 906 | 17 | vars.magic = magic; | 907 | | | 908 | | /* Create the initial .idata$<n> sections: | 909 | | [.idata$2: Import Directory Table -- not needed] | 910 | | .idata$4: Import Lookup Table | 911 | | .idata$5: Import Address Table | 912 | | | 913 | | Note we do not create a .idata$3 section as this is | 914 | | created for us by the linker script. */ | 915 | 17 | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 916 | 17 | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 917 | 17 | if (id4 == NULL || id5 == NULL) | 918 | 0 | goto error_return; | 919 | | | 920 | | /* Fill in the contents of these sections. */ | 921 | 17 | if (import_name_type == IMPORT_ORDINAL) | 922 | 6 | { | 923 | 6 | if (ordinal == 0) | 924 | | /* See PR 20907 for a reproducer. */ | 925 | 2 | goto error_return; | 926 | | | 927 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 928 | | ((unsigned int *) id4->contents)[0] = ordinal; | 929 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 930 | | ((unsigned int *) id5->contents)[0] = ordinal; | 931 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 932 | | #else | 933 | 4 | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 934 | 4 | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 935 | 4 | #endif | 936 | 4 | } | 937 | 11 | else | 938 | 11 | { | 939 | 11 | char * symbol; | 940 | 11 | unsigned int len; | 941 | | | 942 | | /* Create .idata$6 - the Hint Name Table. */ | 943 | 11 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 944 | 11 | if (id6 == NULL) | 945 | 0 | goto error_return; | 946 | | | 947 | | /* If necessary, trim the import symbol name. */ | 948 | 11 | symbol = symbol_name; | 949 | | | 950 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 951 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 952 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 953 | | of these is used for a symbol. We strip this leading char for | 954 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 955 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 956 | | | 957 | 11 | if (import_name_type != IMPORT_NAME) | 958 | 10 | { | 959 | 10 | char c = symbol[0]; | 960 | | | 961 | | /* Check that we don't remove for targets with empty | 962 | | USER_LABEL_PREFIX the leading underscore. */ | 963 | 10 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 964 | 10 | || c == '@' || c == '?') | 965 | 3 | symbol++; | 966 | 10 | } | 967 | | | 968 | 11 | len = strlen (symbol); | 969 | 11 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 970 | 8 | { | 971 | | /* Truncate at the first '@'. */ | 972 | 8 | char *at = strchr (symbol, '@'); | 973 | | | 974 | 8 | if (at != NULL) | 975 | 1 | len = at - symbol; | 976 | 8 | } | 977 | | | 978 | 11 | id6->contents[0] = ordinal & 0xff; | 979 | 11 | id6->contents[1] = ordinal >> 8; | 980 | | | 981 | 11 | memcpy ((char *) id6->contents + 2, symbol, len); | 982 | 11 | id6->contents[len + 2] = '\0'; | 983 | 11 | } | 984 | | | 985 | 15 | if (import_name_type != IMPORT_ORDINAL) | 986 | 11 | { | 987 | 11 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 988 | 11 | pe_ILF_save_relocs (&vars, id4); | 989 | | | 990 | 11 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 991 | 11 | pe_ILF_save_relocs (&vars, id5); | 992 | 11 | } | 993 | | | 994 | | /* Create an import symbol. */ | 995 | 15 | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 996 | 15 | imp_sym = vars.sym_ptr_ptr - 1; | 997 | 15 | imp_index = vars.sym_index - 1; | 998 | | | 999 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1000 | 15 | switch (import_type) | 1001 | 15 | { | 1002 | 0 | int i; | 1003 | | | 1004 | 9 | case IMPORT_CODE: | 1005 | | /* CODE functions are special, in that they get a trampoline that | 1006 | | jumps to the main import symbol. Create a .text section to hold it. | 1007 | | First we need to look up its contents in the jump table. */ | 1008 | 21 | for (i = NUM_ENTRIES (jtab); i--;) | 1009 | 21 | { | 1010 | 21 | if (jtab[i].size == 0) | 1011 | 9 | continue; | 1012 | 12 | if (jtab[i].magic == magic) | 1013 | 9 | break; | 1014 | 12 | } | 1015 | | /* If we did not find a matching entry something is wrong. */ | 1016 | 9 | if (i < 0) | 1017 | 0 | abort (); | 1018 | | | 1019 | | /* Create the .text section. */ | 1020 | 9 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1021 | 9 | if (text == NULL) | 1022 | 0 | goto error_return; | 1023 | | | 1024 | | /* Copy in the jump code. */ | 1025 | 9 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1026 | | | 1027 | | /* Create a reloc for the data in the text section. */ | 1028 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1029 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1030 | | { | 1031 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1032 | | (struct bfd_symbol **) imp_sym, | 1033 | | imp_index); | 1034 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1035 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1036 | | (struct bfd_symbol **) imp_sym, | 1037 | | imp_index); | 1038 | | } | 1039 | | else | 1040 | | #endif | 1041 | | #ifdef AMD64MAGIC | 1042 | | if (magic == AMD64MAGIC) | 1043 | | { | 1044 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1045 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1046 | | imp_index); | 1047 | | } | 1048 | | else | 1049 | | #endif | 1050 | 9 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1051 | 9 | BFD_RELOC_32, (asymbol **) imp_sym, | 1052 | 9 | imp_index); | 1053 | | | 1054 | 9 | pe_ILF_save_relocs (& vars, text); | 1055 | 9 | break; | 1056 | | | 1057 | 6 | case IMPORT_DATA: | 1058 | 6 | break; | 1059 | | | 1060 | 0 | default: | 1061 | | /* XXX code not yet written. */ | 1062 | 0 | abort (); | 1063 | 15 | } | 1064 | | | 1065 | | /* Now create a symbol describing the imported value. */ | 1066 | 15 | switch (import_type) | 1067 | 15 | { | 1068 | 9 | case IMPORT_CODE: | 1069 | 9 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1070 | 9 | BSF_NOT_AT_END | BSF_FUNCTION); | 1071 | | | 1072 | 9 | break; | 1073 | | | 1074 | 6 | case IMPORT_DATA: | 1075 | | /* Nothing to do here. */ | 1076 | 6 | break; | 1077 | | | 1078 | 0 | default: | 1079 | | /* XXX code not yet written. */ | 1080 | 0 | abort (); | 1081 | 15 | } | 1082 | | | 1083 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1084 | 15 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1085 | 15 | if (ptr) | 1086 | 5 | * ptr = 0; | 1087 | 15 | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1088 | 15 | if (ptr) | 1089 | 5 | * ptr = '.'; | 1090 | | | 1091 | | /* Initialise the bfd. */ | 1092 | 15 | memset (& internal_f, 0, sizeof (internal_f)); | 1093 | | | 1094 | 15 | internal_f.f_magic = magic; | 1095 | 15 | internal_f.f_symptr = 0; | 1096 | 15 | internal_f.f_nsyms = 0; | 1097 | 15 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1098 | | | 1099 | 15 | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1100 | 15 | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1101 | 0 | goto error_return; | 1102 | | | 1103 | 15 | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1104 | 0 | goto error_return; | 1105 | | | 1106 | 15 | obj_pe (abfd) = true; | 1107 | 15 | #ifdef THUMBPEMAGIC | 1108 | 15 | if (vars.magic == THUMBPEMAGIC) | 1109 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1110 | 9 | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1111 | 15 | #endif | 1112 | | | 1113 | | /* Switch from file contents to memory contents. */ | 1114 | 15 | bfd_cache_close (abfd); | 1115 | | | 1116 | 15 | abfd->iostream = (void *) vars.bim; | 1117 | 15 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1118 | 15 | abfd->iovec = &_bfd_memory_iovec; | 1119 | 15 | abfd->where = 0; | 1120 | 15 | abfd->origin = 0; | 1121 | 15 | abfd->size = 0; | 1122 | 15 | obj_sym_filepos (abfd) = 0; | 1123 | | | 1124 | | /* Point the bfd at the symbol table. */ | 1125 | 15 | obj_symbols (abfd) = vars.sym_cache; | 1126 | 15 | abfd->symcount = vars.sym_index; | 1127 | | | 1128 | 15 | obj_raw_syments (abfd) = vars.native_syms; | 1129 | 15 | obj_raw_syment_count (abfd) = vars.sym_index; | 1130 | | | 1131 | 15 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1132 | 15 | obj_coff_keep_syms (abfd) = true; | 1133 | | | 1134 | 15 | obj_convert (abfd) = vars.sym_table; | 1135 | 15 | obj_conv_table_size (abfd) = vars.sym_index; | 1136 | | | 1137 | 15 | obj_coff_strings (abfd) = vars.string_table; | 1138 | 15 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1139 | 15 | obj_coff_keep_strings (abfd) = true; | 1140 | | | 1141 | 15 | return true; | 1142 | | | 1143 | 2 | error_return: | 1144 | 2 | free (vars.bim->buffer); | 1145 | 2 | free (vars.bim); | 1146 | 2 | return false; | 1147 | 15 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_build_a_bfd pei-sh.c:pe_ILF_build_a_bfd Line | Count | Source | 786 | 22 | { | 787 | 22 | bfd_byte * ptr; | 788 | 22 | pe_ILF_vars vars; | 789 | 22 | struct internal_filehdr internal_f; | 790 | 22 | unsigned int import_type; | 791 | 22 | unsigned int import_name_type; | 792 | 22 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 793 | 22 | coff_symbol_type ** imp_sym; | 794 | 22 | unsigned int imp_index; | 795 | 22 | intptr_t alignment; | 796 | | | 797 | | /* Decode and verify the types field of the ILF structure. */ | 798 | 22 | import_type = types & 0x3; | 799 | 22 | import_name_type = (types & 0x1c) >> 2; | 800 | | | 801 | 22 | switch (import_type) | 802 | 22 | { | 803 | 15 | case IMPORT_CODE: | 804 | 20 | case IMPORT_DATA: | 805 | 20 | break; | 806 | | | 807 | 1 | case IMPORT_CONST: | 808 | | /* XXX code yet to be written. */ | 809 | | /* xgettext:c-format */ | 810 | 1 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 811 | 1 | abfd, import_type); | 812 | 1 | return false; | 813 | | | 814 | 1 | default: | 815 | | /* xgettext:c-format */ | 816 | 1 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 817 | 1 | abfd, import_type); | 818 | 1 | return false; | 819 | 22 | } | 820 | | | 821 | 20 | switch (import_name_type) | 822 | 20 | { | 823 | 13 | case IMPORT_ORDINAL: | 824 | 15 | case IMPORT_NAME: | 825 | 16 | case IMPORT_NAME_NOPREFIX: | 826 | 20 | case IMPORT_NAME_UNDECORATE: | 827 | 20 | break; | 828 | | | 829 | 0 | default: | 830 | | /* xgettext:c-format */ | 831 | 0 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 832 | 0 | abfd, import_name_type); | 833 | 0 | return false; | 834 | 20 | } | 835 | | | 836 | | /* Initialise local variables. | 837 | | | 838 | | Note these are kept in a structure rather than being | 839 | | declared as statics since bfd frowns on global variables. | 840 | | | 841 | | We are going to construct the contents of the BFD in memory, | 842 | | so allocate all the space that we will need right now. */ | 843 | 20 | vars.bim | 844 | 20 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 845 | 20 | if (vars.bim == NULL) | 846 | 0 | return false; | 847 | | | 848 | 20 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 849 | 20 | vars.bim->buffer = ptr; | 850 | 20 | vars.bim->size = ILF_DATA_SIZE; | 851 | 20 | if (ptr == NULL) | 852 | 0 | goto error_return; | 853 | | | 854 | | /* Initialise the pointers to regions of the memory and the | 855 | | other contents of the pe_ILF_vars structure as well. */ | 856 | 20 | vars.sym_cache = (coff_symbol_type *) ptr; | 857 | 20 | vars.sym_ptr = (coff_symbol_type *) ptr; | 858 | 20 | vars.sym_index = 0; | 859 | 20 | ptr += SIZEOF_ILF_SYMS; | 860 | | | 861 | 20 | vars.sym_table = (unsigned int *) ptr; | 862 | 20 | vars.table_ptr = (unsigned int *) ptr; | 863 | 20 | ptr += SIZEOF_ILF_SYM_TABLE; | 864 | | | 865 | 20 | vars.native_syms = (combined_entry_type *) ptr; | 866 | 20 | vars.native_ptr = (combined_entry_type *) ptr; | 867 | 20 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 868 | | | 869 | 20 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 870 | 20 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 871 | 20 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 872 | | | 873 | 20 | vars.esym_table = (SYMENT *) ptr; | 874 | 20 | vars.esym_ptr = (SYMENT *) ptr; | 875 | 20 | ptr += SIZEOF_ILF_EXT_SYMS; | 876 | | | 877 | 20 | vars.reltab = (arelent *) ptr; | 878 | 20 | vars.relcount = 0; | 879 | 20 | ptr += SIZEOF_ILF_RELOCS; | 880 | | | 881 | 20 | vars.int_reltab = (struct internal_reloc *) ptr; | 882 | 20 | ptr += SIZEOF_ILF_INT_RELOCS; | 883 | | | 884 | 20 | vars.string_table = (char *) ptr; | 885 | 20 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 886 | 20 | ptr += SIZEOF_ILF_STRINGS; | 887 | 20 | vars.end_string_ptr = (char *) ptr; | 888 | | | 889 | | /* The remaining space in bim->buffer is used | 890 | | by the pe_ILF_make_a_section() function. */ | 891 | | | 892 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 893 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 894 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 895 | | alignment. */ | 896 | 20 | #if GCC_VERSION >= 3000 | 897 | 20 | alignment = __alignof__ (struct coff_section_tdata); | 898 | | #else | 899 | | alignment = 8; | 900 | | #endif | 901 | 20 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 902 | | | 903 | 20 | vars.data = ptr; | 904 | 20 | vars.abfd = abfd; | 905 | 20 | vars.sec_index = 0; | 906 | 20 | vars.magic = magic; | 907 | | | 908 | | /* Create the initial .idata$<n> sections: | 909 | | [.idata$2: Import Directory Table -- not needed] | 910 | | .idata$4: Import Lookup Table | 911 | | .idata$5: Import Address Table | 912 | | | 913 | | Note we do not create a .idata$3 section as this is | 914 | | created for us by the linker script. */ | 915 | 20 | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 916 | 20 | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 917 | 20 | if (id4 == NULL || id5 == NULL) | 918 | 0 | goto error_return; | 919 | | | 920 | | /* Fill in the contents of these sections. */ | 921 | 20 | if (import_name_type == IMPORT_ORDINAL) | 922 | 13 | { | 923 | 13 | if (ordinal == 0) | 924 | | /* See PR 20907 for a reproducer. */ | 925 | 3 | goto error_return; | 926 | | | 927 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) | 928 | | ((unsigned int *) id4->contents)[0] = ordinal; | 929 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 930 | | ((unsigned int *) id5->contents)[0] = ordinal; | 931 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 932 | | #else | 933 | 10 | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 934 | 10 | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 935 | 10 | #endif | 936 | 10 | } | 937 | 7 | else | 938 | 7 | { | 939 | 7 | char * symbol; | 940 | 7 | unsigned int len; | 941 | | | 942 | | /* Create .idata$6 - the Hint Name Table. */ | 943 | 7 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 944 | 7 | if (id6 == NULL) | 945 | 0 | goto error_return; | 946 | | | 947 | | /* If necessary, trim the import symbol name. */ | 948 | 7 | symbol = symbol_name; | 949 | | | 950 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 951 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 952 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 953 | | of these is used for a symbol. We strip this leading char for | 954 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 955 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 956 | | | 957 | 7 | if (import_name_type != IMPORT_NAME) | 958 | 5 | { | 959 | 5 | char c = symbol[0]; | 960 | | | 961 | | /* Check that we don't remove for targets with empty | 962 | | USER_LABEL_PREFIX the leading underscore. */ | 963 | 5 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 964 | 5 | || c == '@' || c == '?') | 965 | 0 | symbol++; | 966 | 5 | } | 967 | | | 968 | 7 | len = strlen (symbol); | 969 | 7 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 970 | 4 | { | 971 | | /* Truncate at the first '@'. */ | 972 | 4 | char *at = strchr (symbol, '@'); | 973 | | | 974 | 4 | if (at != NULL) | 975 | 0 | len = at - symbol; | 976 | 4 | } | 977 | | | 978 | 7 | id6->contents[0] = ordinal & 0xff; | 979 | 7 | id6->contents[1] = ordinal >> 8; | 980 | | | 981 | 7 | memcpy ((char *) id6->contents + 2, symbol, len); | 982 | 7 | id6->contents[len + 2] = '\0'; | 983 | 7 | } | 984 | | | 985 | 17 | if (import_name_type != IMPORT_ORDINAL) | 986 | 7 | { | 987 | 7 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 988 | 7 | pe_ILF_save_relocs (&vars, id4); | 989 | | | 990 | 7 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 991 | 7 | pe_ILF_save_relocs (&vars, id5); | 992 | 7 | } | 993 | | | 994 | | /* Create an import symbol. */ | 995 | 17 | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 996 | 17 | imp_sym = vars.sym_ptr_ptr - 1; | 997 | 17 | imp_index = vars.sym_index - 1; | 998 | | | 999 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1000 | 17 | switch (import_type) | 1001 | 17 | { | 1002 | 0 | int i; | 1003 | | | 1004 | 12 | case IMPORT_CODE: | 1005 | | /* CODE functions are special, in that they get a trampoline that | 1006 | | jumps to the main import symbol. Create a .text section to hold it. | 1007 | | First we need to look up its contents in the jump table. */ | 1008 | 24 | for (i = NUM_ENTRIES (jtab); i--;) | 1009 | 24 | { | 1010 | 24 | if (jtab[i].size == 0) | 1011 | 12 | continue; | 1012 | 12 | if (jtab[i].magic == magic) | 1013 | 12 | break; | 1014 | 12 | } | 1015 | | /* If we did not find a matching entry something is wrong. */ | 1016 | 12 | if (i < 0) | 1017 | 0 | abort (); | 1018 | | | 1019 | | /* Create the .text section. */ | 1020 | 12 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1021 | 12 | if (text == NULL) | 1022 | 0 | goto error_return; | 1023 | | | 1024 | | /* Copy in the jump code. */ | 1025 | 12 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1026 | | | 1027 | | /* Create a reloc for the data in the text section. */ | 1028 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1029 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1030 | | { | 1031 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1032 | | (struct bfd_symbol **) imp_sym, | 1033 | | imp_index); | 1034 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1035 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1036 | | (struct bfd_symbol **) imp_sym, | 1037 | | imp_index); | 1038 | | } | 1039 | | else | 1040 | | #endif | 1041 | | #ifdef AMD64MAGIC | 1042 | | if (magic == AMD64MAGIC) | 1043 | | { | 1044 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1045 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1046 | | imp_index); | 1047 | | } | 1048 | | else | 1049 | | #endif | 1050 | 12 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1051 | 12 | BFD_RELOC_32, (asymbol **) imp_sym, | 1052 | 12 | imp_index); | 1053 | | | 1054 | 12 | pe_ILF_save_relocs (& vars, text); | 1055 | 12 | break; | 1056 | | | 1057 | 5 | case IMPORT_DATA: | 1058 | 5 | break; | 1059 | | | 1060 | 0 | default: | 1061 | | /* XXX code not yet written. */ | 1062 | 0 | abort (); | 1063 | 17 | } | 1064 | | | 1065 | | /* Now create a symbol describing the imported value. */ | 1066 | 17 | switch (import_type) | 1067 | 17 | { | 1068 | 12 | case IMPORT_CODE: | 1069 | 12 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1070 | 12 | BSF_NOT_AT_END | BSF_FUNCTION); | 1071 | | | 1072 | 12 | break; | 1073 | | | 1074 | 5 | case IMPORT_DATA: | 1075 | | /* Nothing to do here. */ | 1076 | 5 | break; | 1077 | | | 1078 | 0 | default: | 1079 | | /* XXX code not yet written. */ | 1080 | 0 | abort (); | 1081 | 17 | } | 1082 | | | 1083 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1084 | 17 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1085 | 17 | if (ptr) | 1086 | 4 | * ptr = 0; | 1087 | 17 | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1088 | 17 | if (ptr) | 1089 | 4 | * ptr = '.'; | 1090 | | | 1091 | | /* Initialise the bfd. */ | 1092 | 17 | memset (& internal_f, 0, sizeof (internal_f)); | 1093 | | | 1094 | 17 | internal_f.f_magic = magic; | 1095 | 17 | internal_f.f_symptr = 0; | 1096 | 17 | internal_f.f_nsyms = 0; | 1097 | 17 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1098 | | | 1099 | 17 | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1100 | 17 | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1101 | 0 | goto error_return; | 1102 | | | 1103 | 17 | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1104 | 0 | goto error_return; | 1105 | | | 1106 | 17 | obj_pe (abfd) = true; | 1107 | | #ifdef THUMBPEMAGIC | 1108 | | if (vars.magic == THUMBPEMAGIC) | 1109 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1110 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1111 | | #endif | 1112 | | | 1113 | | /* Switch from file contents to memory contents. */ | 1114 | 17 | bfd_cache_close (abfd); | 1115 | | | 1116 | 17 | abfd->iostream = (void *) vars.bim; | 1117 | 17 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1118 | 17 | abfd->iovec = &_bfd_memory_iovec; | 1119 | 17 | abfd->where = 0; | 1120 | 17 | abfd->origin = 0; | 1121 | 17 | abfd->size = 0; | 1122 | 17 | obj_sym_filepos (abfd) = 0; | 1123 | | | 1124 | | /* Point the bfd at the symbol table. */ | 1125 | 17 | obj_symbols (abfd) = vars.sym_cache; | 1126 | 17 | abfd->symcount = vars.sym_index; | 1127 | | | 1128 | 17 | obj_raw_syments (abfd) = vars.native_syms; | 1129 | 17 | obj_raw_syment_count (abfd) = vars.sym_index; | 1130 | | | 1131 | 17 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1132 | 17 | obj_coff_keep_syms (abfd) = true; | 1133 | | | 1134 | 17 | obj_convert (abfd) = vars.sym_table; | 1135 | 17 | obj_conv_table_size (abfd) = vars.sym_index; | 1136 | | | 1137 | 17 | obj_coff_strings (abfd) = vars.string_table; | 1138 | 17 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1139 | 17 | obj_coff_keep_strings (abfd) = true; | 1140 | | | 1141 | 17 | return true; | 1142 | | | 1143 | 3 | error_return: | 1144 | 3 | free (vars.bim->buffer); | 1145 | 3 | free (vars.bim); | 1146 | 3 | return false; | 1147 | 17 | } |
|
1148 | | |
1149 | | /* Cleanup function, returned from check_format hook. */ |
1150 | | |
1151 | | static void |
1152 | | pe_ILF_cleanup (bfd *abfd) |
1153 | 14 | { |
1154 | 14 | coff_object_cleanup (abfd); |
1155 | | |
1156 | 14 | struct bfd_in_memory *bim = abfd->iostream; |
1157 | 14 | free (bim->buffer); |
1158 | 14 | free (bim); |
1159 | 14 | abfd->iostream = NULL; |
1160 | 14 | } Unexecuted instantiation: pei-i386.c:pe_ILF_cleanup Unexecuted instantiation: pei-x86_64.c:pe_ILF_cleanup Unexecuted instantiation: pei-aarch64.c:pe_ILF_cleanup Unexecuted instantiation: pei-ia64.c:pe_ILF_cleanup Unexecuted instantiation: pei-loongarch64.c:pe_ILF_cleanup pei-arm-wince.c:pe_ILF_cleanup Line | Count | Source | 1153 | 7 | { | 1154 | 7 | coff_object_cleanup (abfd); | 1155 | | | 1156 | 7 | struct bfd_in_memory *bim = abfd->iostream; | 1157 | 7 | free (bim->buffer); | 1158 | 7 | free (bim); | 1159 | 7 | abfd->iostream = NULL; | 1160 | 7 | } |
Line | Count | Source | 1153 | 7 | { | 1154 | 7 | coff_object_cleanup (abfd); | 1155 | | | 1156 | 7 | struct bfd_in_memory *bim = abfd->iostream; | 1157 | 7 | free (bim->buffer); | 1158 | 7 | free (bim); | 1159 | 7 | abfd->iostream = NULL; | 1160 | 7 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_cleanup Unexecuted instantiation: pei-sh.c:pe_ILF_cleanup |
1161 | | |
1162 | | /* We have detected an Import Library Format archive element. |
1163 | | Decode the element and return the appropriate target. */ |
1164 | | |
1165 | | static bfd_cleanup |
1166 | | pe_ILF_object_p (bfd * abfd) |
1167 | 1.78k | { |
1168 | 1.78k | bfd_byte buffer[14]; |
1169 | 1.78k | bfd_byte * ptr; |
1170 | 1.78k | char * symbol_name; |
1171 | 1.78k | char * source_dll; |
1172 | 1.78k | unsigned int machine; |
1173 | 1.78k | bfd_size_type size; |
1174 | 1.78k | unsigned int ordinal; |
1175 | 1.78k | unsigned int types; |
1176 | 1.78k | unsigned int magic; |
1177 | | |
1178 | | /* Upon entry the first six bytes of the ILF header have |
1179 | | already been read. Now read the rest of the header. */ |
1180 | 1.78k | if (bfd_read (buffer, 14, abfd) != 14) |
1181 | 43 | return NULL; |
1182 | | |
1183 | 1.73k | ptr = buffer; |
1184 | | |
1185 | 1.73k | machine = H_GET_16 (abfd, ptr); |
1186 | 1.73k | ptr += 2; |
1187 | | |
1188 | | /* Check that the machine type is recognised. */ |
1189 | 1.73k | magic = 0; |
1190 | | |
1191 | 1.73k | switch (machine) |
1192 | 1.73k | { |
1193 | 67 | case IMAGE_FILE_MACHINE_UNKNOWN: |
1194 | 75 | case IMAGE_FILE_MACHINE_ALPHA: |
1195 | 75 | case IMAGE_FILE_MACHINE_ALPHA64: |
1196 | 83 | case IMAGE_FILE_MACHINE_IA64: |
1197 | 83 | break; |
1198 | | |
1199 | 224 | case IMAGE_FILE_MACHINE_I386: |
1200 | | #ifdef I386MAGIC |
1201 | 28 | magic = I386MAGIC; |
1202 | | #endif |
1203 | 224 | break; |
1204 | | |
1205 | 144 | case IMAGE_FILE_MACHINE_AMD64: |
1206 | | #ifdef AMD64MAGIC |
1207 | 18 | magic = AMD64MAGIC; |
1208 | | #endif |
1209 | 144 | break; |
1210 | | |
1211 | 8 | case IMAGE_FILE_MACHINE_R3000: |
1212 | 16 | case IMAGE_FILE_MACHINE_R4000: |
1213 | 24 | case IMAGE_FILE_MACHINE_R10000: |
1214 | | |
1215 | 32 | case IMAGE_FILE_MACHINE_MIPS16: |
1216 | 32 | case IMAGE_FILE_MACHINE_MIPSFPU: |
1217 | 32 | case IMAGE_FILE_MACHINE_MIPSFPU16: |
1218 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
1219 | | magic = MIPS_ARCH_MAGIC_WINCE; |
1220 | | #endif |
1221 | 32 | break; |
1222 | | |
1223 | 336 | case IMAGE_FILE_MACHINE_SH3: |
1224 | 344 | case IMAGE_FILE_MACHINE_SH4: |
1225 | | #ifdef SH_ARCH_MAGIC_WINCE |
1226 | 47 | magic = SH_ARCH_MAGIC_WINCE; |
1227 | | #endif |
1228 | 344 | break; |
1229 | | |
1230 | 85 | case IMAGE_FILE_MACHINE_ARM: |
1231 | | #ifdef ARMPEMAGIC |
1232 | 50 | magic = ARMPEMAGIC; |
1233 | | #endif |
1234 | 85 | break; |
1235 | | |
1236 | 136 | case IMAGE_FILE_MACHINE_ARM64: |
1237 | | #ifdef AARCH64MAGIC |
1238 | 17 | magic = AARCH64MAGIC; |
1239 | | #endif |
1240 | 136 | break; |
1241 | | |
1242 | 136 | case IMAGE_FILE_MACHINE_LOONGARCH64: |
1243 | | #ifdef LOONGARCH64MAGIC |
1244 | 17 | magic = LOONGARCH64MAGIC; |
1245 | | #endif |
1246 | 136 | break; |
1247 | | |
1248 | 248 | case IMAGE_FILE_MACHINE_THUMB: |
1249 | | #ifdef THUMBPEMAGIC |
1250 | | { |
1251 | | extern const bfd_target TARGET_LITTLE_SYM; |
1252 | | |
1253 | 66 | if (abfd->xvec == & TARGET_LITTLE_SYM) |
1254 | 66 | magic = THUMBPEMAGIC; |
1255 | | } |
1256 | | #endif |
1257 | 248 | break; |
1258 | | |
1259 | 0 | case IMAGE_FILE_MACHINE_POWERPC: |
1260 | | /* We no longer support PowerPC. */ |
1261 | 305 | default: |
1262 | 305 | _bfd_error_handler |
1263 | | /* xgettext:c-format */ |
1264 | 305 | (_("%pB: unrecognised machine type (0x%x)" |
1265 | 305 | " in Import Library Format archive"), |
1266 | 305 | abfd, machine); |
1267 | 305 | bfd_set_error (bfd_error_malformed_archive); |
1268 | | |
1269 | 305 | return NULL; |
1270 | 0 | break; |
1271 | 1.73k | } |
1272 | | |
1273 | 1.43k | if (magic == 0) |
1274 | 1.18k | { |
1275 | 1.18k | _bfd_error_handler |
1276 | | /* xgettext:c-format */ |
1277 | 1.18k | (_("%pB: recognised but unhandled machine type (0x%x)" |
1278 | 1.18k | " in Import Library Format archive"), |
1279 | 1.18k | abfd, machine); |
1280 | 1.18k | bfd_set_error (bfd_error_wrong_format); |
1281 | | |
1282 | 1.18k | return NULL; |
1283 | 1.18k | } |
1284 | | |
1285 | | /* We do not bother to check the date. |
1286 | | date = H_GET_32 (abfd, ptr); */ |
1287 | 243 | ptr += 4; |
1288 | | |
1289 | 243 | size = H_GET_32 (abfd, ptr); |
1290 | 243 | ptr += 4; |
1291 | | |
1292 | 243 | if (size == 0) |
1293 | 7 | { |
1294 | 7 | _bfd_error_handler |
1295 | 7 | (_("%pB: size field is zero in Import Library Format header"), abfd); |
1296 | 7 | bfd_set_error (bfd_error_malformed_archive); |
1297 | | |
1298 | 7 | return NULL; |
1299 | 7 | } |
1300 | | |
1301 | 236 | ordinal = H_GET_16 (abfd, ptr); |
1302 | 236 | ptr += 2; |
1303 | | |
1304 | 236 | types = H_GET_16 (abfd, ptr); |
1305 | | /* ptr += 2; */ |
1306 | | |
1307 | | /* Now read in the two strings that follow. */ |
1308 | 236 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); |
1309 | 236 | if (ptr == NULL) |
1310 | 105 | return NULL; |
1311 | | |
1312 | 131 | symbol_name = (char *) ptr; |
1313 | | /* See PR 20905 for an example of where the strnlen is necessary. */ |
1314 | 131 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; |
1315 | | |
1316 | | /* Verify that the strings are null terminated. */ |
1317 | 131 | if (ptr[size - 1] != 0 |
1318 | 131 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) |
1319 | 27 | { |
1320 | 27 | _bfd_error_handler |
1321 | 27 | (_("%pB: string not null terminated in ILF object file"), abfd); |
1322 | 27 | bfd_set_error (bfd_error_malformed_archive); |
1323 | 27 | bfd_release (abfd, ptr); |
1324 | 27 | return NULL; |
1325 | 27 | } |
1326 | | |
1327 | | /* Now construct the bfd. */ |
1328 | 104 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, |
1329 | 104 | source_dll, ordinal, types)) |
1330 | 37 | { |
1331 | 37 | bfd_release (abfd, ptr); |
1332 | 37 | return NULL; |
1333 | 37 | } |
1334 | | |
1335 | 67 | return pe_ILF_cleanup; |
1336 | 104 | } pei-i386.c:pe_ILF_object_p Line | Count | Source | 1167 | 211 | { | 1168 | 211 | bfd_byte buffer[14]; | 1169 | 211 | bfd_byte * ptr; | 1170 | 211 | char * symbol_name; | 1171 | 211 | char * source_dll; | 1172 | 211 | unsigned int machine; | 1173 | 211 | bfd_size_type size; | 1174 | 211 | unsigned int ordinal; | 1175 | 211 | unsigned int types; | 1176 | 211 | unsigned int magic; | 1177 | | | 1178 | | /* Upon entry the first six bytes of the ILF header have | 1179 | | already been read. Now read the rest of the header. */ | 1180 | 211 | if (bfd_read (buffer, 14, abfd) != 14) | 1181 | 5 | return NULL; | 1182 | | | 1183 | 206 | ptr = buffer; | 1184 | | | 1185 | 206 | machine = H_GET_16 (abfd, ptr); | 1186 | 206 | ptr += 2; | 1187 | | | 1188 | | /* Check that the machine type is recognised. */ | 1189 | 206 | magic = 0; | 1190 | | | 1191 | 206 | switch (machine) | 1192 | 206 | { | 1193 | 8 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1194 | 9 | case IMAGE_FILE_MACHINE_ALPHA: | 1195 | 9 | case IMAGE_FILE_MACHINE_ALPHA64: | 1196 | 10 | case IMAGE_FILE_MACHINE_IA64: | 1197 | 10 | break; | 1198 | | | 1199 | 28 | case IMAGE_FILE_MACHINE_I386: | 1200 | 28 | #ifdef I386MAGIC | 1201 | 28 | magic = I386MAGIC; | 1202 | 28 | #endif | 1203 | 28 | break; | 1204 | | | 1205 | 18 | case IMAGE_FILE_MACHINE_AMD64: | 1206 | | #ifdef AMD64MAGIC | 1207 | | magic = AMD64MAGIC; | 1208 | | #endif | 1209 | 18 | break; | 1210 | | | 1211 | 1 | case IMAGE_FILE_MACHINE_R3000: | 1212 | 2 | case IMAGE_FILE_MACHINE_R4000: | 1213 | 3 | case IMAGE_FILE_MACHINE_R10000: | 1214 | | | 1215 | 4 | case IMAGE_FILE_MACHINE_MIPS16: | 1216 | 4 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1217 | 4 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1218 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1219 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1220 | | #endif | 1221 | 4 | break; | 1222 | | | 1223 | 46 | case IMAGE_FILE_MACHINE_SH3: | 1224 | 47 | case IMAGE_FILE_MACHINE_SH4: | 1225 | | #ifdef SH_ARCH_MAGIC_WINCE | 1226 | | magic = SH_ARCH_MAGIC_WINCE; | 1227 | | #endif | 1228 | 47 | break; | 1229 | | | 1230 | 2 | case IMAGE_FILE_MACHINE_ARM: | 1231 | | #ifdef ARMPEMAGIC | 1232 | | magic = ARMPEMAGIC; | 1233 | | #endif | 1234 | 2 | break; | 1235 | | | 1236 | 17 | case IMAGE_FILE_MACHINE_ARM64: | 1237 | | #ifdef AARCH64MAGIC | 1238 | | magic = AARCH64MAGIC; | 1239 | | #endif | 1240 | 17 | break; | 1241 | | | 1242 | 17 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1243 | | #ifdef LOONGARCH64MAGIC | 1244 | | magic = LOONGARCH64MAGIC; | 1245 | | #endif | 1246 | 17 | break; | 1247 | | | 1248 | 29 | case IMAGE_FILE_MACHINE_THUMB: | 1249 | | #ifdef THUMBPEMAGIC | 1250 | | { | 1251 | | extern const bfd_target TARGET_LITTLE_SYM; | 1252 | | | 1253 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1254 | | magic = THUMBPEMAGIC; | 1255 | | } | 1256 | | #endif | 1257 | 29 | break; | 1258 | | | 1259 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1260 | | /* We no longer support PowerPC. */ | 1261 | 34 | default: | 1262 | 34 | _bfd_error_handler | 1263 | | /* xgettext:c-format */ | 1264 | 34 | (_("%pB: unrecognised machine type (0x%x)" | 1265 | 34 | " in Import Library Format archive"), | 1266 | 34 | abfd, machine); | 1267 | 34 | bfd_set_error (bfd_error_malformed_archive); | 1268 | | | 1269 | 34 | return NULL; | 1270 | 0 | break; | 1271 | 206 | } | 1272 | | | 1273 | 172 | if (magic == 0) | 1274 | 144 | { | 1275 | 144 | _bfd_error_handler | 1276 | | /* xgettext:c-format */ | 1277 | 144 | (_("%pB: recognised but unhandled machine type (0x%x)" | 1278 | 144 | " in Import Library Format archive"), | 1279 | 144 | abfd, machine); | 1280 | 144 | bfd_set_error (bfd_error_wrong_format); | 1281 | | | 1282 | 144 | return NULL; | 1283 | 144 | } | 1284 | | | 1285 | | /* We do not bother to check the date. | 1286 | | date = H_GET_32 (abfd, ptr); */ | 1287 | 28 | ptr += 4; | 1288 | | | 1289 | 28 | size = H_GET_32 (abfd, ptr); | 1290 | 28 | ptr += 4; | 1291 | | | 1292 | 28 | if (size == 0) | 1293 | 1 | { | 1294 | 1 | _bfd_error_handler | 1295 | 1 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1296 | 1 | bfd_set_error (bfd_error_malformed_archive); | 1297 | | | 1298 | 1 | return NULL; | 1299 | 1 | } | 1300 | | | 1301 | 27 | ordinal = H_GET_16 (abfd, ptr); | 1302 | 27 | ptr += 2; | 1303 | | | 1304 | 27 | types = H_GET_16 (abfd, ptr); | 1305 | | /* ptr += 2; */ | 1306 | | | 1307 | | /* Now read in the two strings that follow. */ | 1308 | 27 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1309 | 27 | if (ptr == NULL) | 1310 | 8 | return NULL; | 1311 | | | 1312 | 19 | symbol_name = (char *) ptr; | 1313 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1314 | 19 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1315 | | | 1316 | | /* Verify that the strings are null terminated. */ | 1317 | 19 | if (ptr[size - 1] != 0 | 1318 | 19 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1319 | 3 | { | 1320 | 3 | _bfd_error_handler | 1321 | 3 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1322 | 3 | bfd_set_error (bfd_error_malformed_archive); | 1323 | 3 | bfd_release (abfd, ptr); | 1324 | 3 | return NULL; | 1325 | 3 | } | 1326 | | | 1327 | | /* Now construct the bfd. */ | 1328 | 16 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1329 | 16 | source_dll, ordinal, types)) | 1330 | 6 | { | 1331 | 6 | bfd_release (abfd, ptr); | 1332 | 6 | return NULL; | 1333 | 6 | } | 1334 | | | 1335 | 10 | return pe_ILF_cleanup; | 1336 | 16 | } |
pei-x86_64.c:pe_ILF_object_p Line | Count | Source | 1167 | 195 | { | 1168 | 195 | bfd_byte buffer[14]; | 1169 | 195 | bfd_byte * ptr; | 1170 | 195 | char * symbol_name; | 1171 | 195 | char * source_dll; | 1172 | 195 | unsigned int machine; | 1173 | 195 | bfd_size_type size; | 1174 | 195 | unsigned int ordinal; | 1175 | 195 | unsigned int types; | 1176 | 195 | unsigned int magic; | 1177 | | | 1178 | | /* Upon entry the first six bytes of the ILF header have | 1179 | | already been read. Now read the rest of the header. */ | 1180 | 195 | if (bfd_read (buffer, 14, abfd) != 14) | 1181 | 5 | return NULL; | 1182 | | | 1183 | 190 | ptr = buffer; | 1184 | | | 1185 | 190 | machine = H_GET_16 (abfd, ptr); | 1186 | 190 | ptr += 2; | 1187 | | | 1188 | | /* Check that the machine type is recognised. */ | 1189 | 190 | magic = 0; | 1190 | | | 1191 | 190 | switch (machine) | 1192 | 190 | { | 1193 | 8 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1194 | 9 | case IMAGE_FILE_MACHINE_ALPHA: | 1195 | 9 | case IMAGE_FILE_MACHINE_ALPHA64: | 1196 | 10 | case IMAGE_FILE_MACHINE_IA64: | 1197 | 10 | break; | 1198 | | | 1199 | 28 | case IMAGE_FILE_MACHINE_I386: | 1200 | | #ifdef I386MAGIC | 1201 | | magic = I386MAGIC; | 1202 | | #endif | 1203 | 28 | break; | 1204 | | | 1205 | 18 | case IMAGE_FILE_MACHINE_AMD64: | 1206 | 18 | #ifdef AMD64MAGIC | 1207 | 18 | magic = AMD64MAGIC; | 1208 | 18 | #endif | 1209 | 18 | break; | 1210 | | | 1211 | 1 | case IMAGE_FILE_MACHINE_R3000: | 1212 | 2 | case IMAGE_FILE_MACHINE_R4000: | 1213 | 3 | case IMAGE_FILE_MACHINE_R10000: | 1214 | | | 1215 | 4 | case IMAGE_FILE_MACHINE_MIPS16: | 1216 | 4 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1217 | 4 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1218 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1219 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1220 | | #endif | 1221 | 4 | break; | 1222 | | | 1223 | 30 | case IMAGE_FILE_MACHINE_SH3: | 1224 | 31 | case IMAGE_FILE_MACHINE_SH4: | 1225 | | #ifdef SH_ARCH_MAGIC_WINCE | 1226 | | magic = SH_ARCH_MAGIC_WINCE; | 1227 | | #endif | 1228 | 31 | break; | 1229 | | | 1230 | 2 | case IMAGE_FILE_MACHINE_ARM: | 1231 | | #ifdef ARMPEMAGIC | 1232 | | magic = ARMPEMAGIC; | 1233 | | #endif | 1234 | 2 | break; | 1235 | | | 1236 | 17 | case IMAGE_FILE_MACHINE_ARM64: | 1237 | | #ifdef AARCH64MAGIC | 1238 | | magic = AARCH64MAGIC; | 1239 | | #endif | 1240 | 17 | break; | 1241 | | | 1242 | 17 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1243 | | #ifdef LOONGARCH64MAGIC | 1244 | | magic = LOONGARCH64MAGIC; | 1245 | | #endif | 1246 | 17 | break; | 1247 | | | 1248 | 29 | case IMAGE_FILE_MACHINE_THUMB: | 1249 | | #ifdef THUMBPEMAGIC | 1250 | | { | 1251 | | extern const bfd_target TARGET_LITTLE_SYM; | 1252 | | | 1253 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1254 | | magic = THUMBPEMAGIC; | 1255 | | } | 1256 | | #endif | 1257 | 29 | break; | 1258 | | | 1259 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1260 | | /* We no longer support PowerPC. */ | 1261 | 34 | default: | 1262 | 34 | _bfd_error_handler | 1263 | | /* xgettext:c-format */ | 1264 | 34 | (_("%pB: unrecognised machine type (0x%x)" | 1265 | 34 | " in Import Library Format archive"), | 1266 | 34 | abfd, machine); | 1267 | 34 | bfd_set_error (bfd_error_malformed_archive); | 1268 | | | 1269 | 34 | return NULL; | 1270 | 0 | break; | 1271 | 190 | } | 1272 | | | 1273 | 156 | if (magic == 0) | 1274 | 138 | { | 1275 | 138 | _bfd_error_handler | 1276 | | /* xgettext:c-format */ | 1277 | 138 | (_("%pB: recognised but unhandled machine type (0x%x)" | 1278 | 138 | " in Import Library Format archive"), | 1279 | 138 | abfd, machine); | 1280 | 138 | bfd_set_error (bfd_error_wrong_format); | 1281 | | | 1282 | 138 | return NULL; | 1283 | 138 | } | 1284 | | | 1285 | | /* We do not bother to check the date. | 1286 | | date = H_GET_32 (abfd, ptr); */ | 1287 | 18 | ptr += 4; | 1288 | | | 1289 | 18 | size = H_GET_32 (abfd, ptr); | 1290 | 18 | ptr += 4; | 1291 | | | 1292 | 18 | if (size == 0) | 1293 | 1 | { | 1294 | 1 | _bfd_error_handler | 1295 | 1 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1296 | 1 | bfd_set_error (bfd_error_malformed_archive); | 1297 | | | 1298 | 1 | return NULL; | 1299 | 1 | } | 1300 | | | 1301 | 17 | ordinal = H_GET_16 (abfd, ptr); | 1302 | 17 | ptr += 2; | 1303 | | | 1304 | 17 | types = H_GET_16 (abfd, ptr); | 1305 | | /* ptr += 2; */ | 1306 | | | 1307 | | /* Now read in the two strings that follow. */ | 1308 | 17 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1309 | 17 | if (ptr == NULL) | 1310 | 4 | return NULL; | 1311 | | | 1312 | 13 | symbol_name = (char *) ptr; | 1313 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1314 | 13 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1315 | | | 1316 | | /* Verify that the strings are null terminated. */ | 1317 | 13 | if (ptr[size - 1] != 0 | 1318 | 13 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1319 | 2 | { | 1320 | 2 | _bfd_error_handler | 1321 | 2 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1322 | 2 | bfd_set_error (bfd_error_malformed_archive); | 1323 | 2 | bfd_release (abfd, ptr); | 1324 | 2 | return NULL; | 1325 | 2 | } | 1326 | | | 1327 | | /* Now construct the bfd. */ | 1328 | 11 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1329 | 11 | source_dll, ordinal, types)) | 1330 | 4 | { | 1331 | 4 | bfd_release (abfd, ptr); | 1332 | 4 | return NULL; | 1333 | 4 | } | 1334 | | | 1335 | 7 | return pe_ILF_cleanup; | 1336 | 11 | } |
pei-aarch64.c:pe_ILF_object_p Line | Count | Source | 1167 | 219 | { | 1168 | 219 | bfd_byte buffer[14]; | 1169 | 219 | bfd_byte * ptr; | 1170 | 219 | char * symbol_name; | 1171 | 219 | char * source_dll; | 1172 | 219 | unsigned int machine; | 1173 | 219 | bfd_size_type size; | 1174 | 219 | unsigned int ordinal; | 1175 | 219 | unsigned int types; | 1176 | 219 | unsigned int magic; | 1177 | | | 1178 | | /* Upon entry the first six bytes of the ILF header have | 1179 | | already been read. Now read the rest of the header. */ | 1180 | 219 | if (bfd_read (buffer, 14, abfd) != 14) | 1181 | 5 | return NULL; | 1182 | | | 1183 | 214 | ptr = buffer; | 1184 | | | 1185 | 214 | machine = H_GET_16 (abfd, ptr); | 1186 | 214 | ptr += 2; | 1187 | | | 1188 | | /* Check that the machine type is recognised. */ | 1189 | 214 | magic = 0; | 1190 | | | 1191 | 214 | switch (machine) | 1192 | 214 | { | 1193 | 8 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1194 | 9 | case IMAGE_FILE_MACHINE_ALPHA: | 1195 | 9 | case IMAGE_FILE_MACHINE_ALPHA64: | 1196 | 10 | case IMAGE_FILE_MACHINE_IA64: | 1197 | 10 | break; | 1198 | | | 1199 | 28 | case IMAGE_FILE_MACHINE_I386: | 1200 | | #ifdef I386MAGIC | 1201 | | magic = I386MAGIC; | 1202 | | #endif | 1203 | 28 | break; | 1204 | | | 1205 | 18 | case IMAGE_FILE_MACHINE_AMD64: | 1206 | | #ifdef AMD64MAGIC | 1207 | | magic = AMD64MAGIC; | 1208 | | #endif | 1209 | 18 | break; | 1210 | | | 1211 | 1 | case IMAGE_FILE_MACHINE_R3000: | 1212 | 2 | case IMAGE_FILE_MACHINE_R4000: | 1213 | 3 | case IMAGE_FILE_MACHINE_R10000: | 1214 | | | 1215 | 4 | case IMAGE_FILE_MACHINE_MIPS16: | 1216 | 4 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1217 | 4 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1218 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1219 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1220 | | #endif | 1221 | 4 | break; | 1222 | | | 1223 | 46 | case IMAGE_FILE_MACHINE_SH3: | 1224 | 47 | case IMAGE_FILE_MACHINE_SH4: | 1225 | | #ifdef SH_ARCH_MAGIC_WINCE | 1226 | | magic = SH_ARCH_MAGIC_WINCE; | 1227 | | #endif | 1228 | 47 | break; | 1229 | | | 1230 | 2 | case IMAGE_FILE_MACHINE_ARM: | 1231 | | #ifdef ARMPEMAGIC | 1232 | | magic = ARMPEMAGIC; | 1233 | | #endif | 1234 | 2 | break; | 1235 | | | 1236 | 17 | case IMAGE_FILE_MACHINE_ARM64: | 1237 | 17 | #ifdef AARCH64MAGIC | 1238 | 17 | magic = AARCH64MAGIC; | 1239 | 17 | #endif | 1240 | 17 | break; | 1241 | | | 1242 | 17 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1243 | | #ifdef LOONGARCH64MAGIC | 1244 | | magic = LOONGARCH64MAGIC; | 1245 | | #endif | 1246 | 17 | break; | 1247 | | | 1248 | 37 | case IMAGE_FILE_MACHINE_THUMB: | 1249 | | #ifdef THUMBPEMAGIC | 1250 | | { | 1251 | | extern const bfd_target TARGET_LITTLE_SYM; | 1252 | | | 1253 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1254 | | magic = THUMBPEMAGIC; | 1255 | | } | 1256 | | #endif | 1257 | 37 | break; | 1258 | | | 1259 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1260 | | /* We no longer support PowerPC. */ | 1261 | 34 | default: | 1262 | 34 | _bfd_error_handler | 1263 | | /* xgettext:c-format */ | 1264 | 34 | (_("%pB: unrecognised machine type (0x%x)" | 1265 | 34 | " in Import Library Format archive"), | 1266 | 34 | abfd, machine); | 1267 | 34 | bfd_set_error (bfd_error_malformed_archive); | 1268 | | | 1269 | 34 | return NULL; | 1270 | 0 | break; | 1271 | 214 | } | 1272 | | | 1273 | 180 | if (magic == 0) | 1274 | 163 | { | 1275 | 163 | _bfd_error_handler | 1276 | | /* xgettext:c-format */ | 1277 | 163 | (_("%pB: recognised but unhandled machine type (0x%x)" | 1278 | 163 | " in Import Library Format archive"), | 1279 | 163 | abfd, machine); | 1280 | 163 | bfd_set_error (bfd_error_wrong_format); | 1281 | | | 1282 | 163 | return NULL; | 1283 | 163 | } | 1284 | | | 1285 | | /* We do not bother to check the date. | 1286 | | date = H_GET_32 (abfd, ptr); */ | 1287 | 17 | ptr += 4; | 1288 | | | 1289 | 17 | size = H_GET_32 (abfd, ptr); | 1290 | 17 | ptr += 4; | 1291 | | | 1292 | 17 | if (size == 0) | 1293 | 1 | { | 1294 | 1 | _bfd_error_handler | 1295 | 1 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1296 | 1 | bfd_set_error (bfd_error_malformed_archive); | 1297 | | | 1298 | 1 | return NULL; | 1299 | 1 | } | 1300 | | | 1301 | 16 | ordinal = H_GET_16 (abfd, ptr); | 1302 | 16 | ptr += 2; | 1303 | | | 1304 | 16 | types = H_GET_16 (abfd, ptr); | 1305 | | /* ptr += 2; */ | 1306 | | | 1307 | | /* Now read in the two strings that follow. */ | 1308 | 16 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1309 | 16 | if (ptr == NULL) | 1310 | 6 | return NULL; | 1311 | | | 1312 | 10 | symbol_name = (char *) ptr; | 1313 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1314 | 10 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1315 | | | 1316 | | /* Verify that the strings are null terminated. */ | 1317 | 10 | if (ptr[size - 1] != 0 | 1318 | 10 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1319 | 2 | { | 1320 | 2 | _bfd_error_handler | 1321 | 2 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1322 | 2 | bfd_set_error (bfd_error_malformed_archive); | 1323 | 2 | bfd_release (abfd, ptr); | 1324 | 2 | return NULL; | 1325 | 2 | } | 1326 | | | 1327 | | /* Now construct the bfd. */ | 1328 | 8 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1329 | 8 | source_dll, ordinal, types)) | 1330 | 3 | { | 1331 | 3 | bfd_release (abfd, ptr); | 1332 | 3 | return NULL; | 1333 | 3 | } | 1334 | | | 1335 | 5 | return pe_ILF_cleanup; | 1336 | 8 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_object_p pei-loongarch64.c:pe_ILF_object_p Line | Count | Source | 1167 | 195 | { | 1168 | 195 | bfd_byte buffer[14]; | 1169 | 195 | bfd_byte * ptr; | 1170 | 195 | char * symbol_name; | 1171 | 195 | char * source_dll; | 1172 | 195 | unsigned int machine; | 1173 | 195 | bfd_size_type size; | 1174 | 195 | unsigned int ordinal; | 1175 | 195 | unsigned int types; | 1176 | 195 | unsigned int magic; | 1177 | | | 1178 | | /* Upon entry the first six bytes of the ILF header have | 1179 | | already been read. Now read the rest of the header. */ | 1180 | 195 | if (bfd_read (buffer, 14, abfd) != 14) | 1181 | 5 | return NULL; | 1182 | | | 1183 | 190 | ptr = buffer; | 1184 | | | 1185 | 190 | machine = H_GET_16 (abfd, ptr); | 1186 | 190 | ptr += 2; | 1187 | | | 1188 | | /* Check that the machine type is recognised. */ | 1189 | 190 | magic = 0; | 1190 | | | 1191 | 190 | switch (machine) | 1192 | 190 | { | 1193 | 8 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1194 | 9 | case IMAGE_FILE_MACHINE_ALPHA: | 1195 | 9 | case IMAGE_FILE_MACHINE_ALPHA64: | 1196 | 10 | case IMAGE_FILE_MACHINE_IA64: | 1197 | 10 | break; | 1198 | | | 1199 | 28 | case IMAGE_FILE_MACHINE_I386: | 1200 | | #ifdef I386MAGIC | 1201 | | magic = I386MAGIC; | 1202 | | #endif | 1203 | 28 | break; | 1204 | | | 1205 | 18 | case IMAGE_FILE_MACHINE_AMD64: | 1206 | | #ifdef AMD64MAGIC | 1207 | | magic = AMD64MAGIC; | 1208 | | #endif | 1209 | 18 | break; | 1210 | | | 1211 | 1 | case IMAGE_FILE_MACHINE_R3000: | 1212 | 2 | case IMAGE_FILE_MACHINE_R4000: | 1213 | 3 | case IMAGE_FILE_MACHINE_R10000: | 1214 | | | 1215 | 4 | case IMAGE_FILE_MACHINE_MIPS16: | 1216 | 4 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1217 | 4 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1218 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1219 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1220 | | #endif | 1221 | 4 | break; | 1222 | | | 1223 | 30 | case IMAGE_FILE_MACHINE_SH3: | 1224 | 31 | case IMAGE_FILE_MACHINE_SH4: | 1225 | | #ifdef SH_ARCH_MAGIC_WINCE | 1226 | | magic = SH_ARCH_MAGIC_WINCE; | 1227 | | #endif | 1228 | 31 | break; | 1229 | | | 1230 | 2 | case IMAGE_FILE_MACHINE_ARM: | 1231 | | #ifdef ARMPEMAGIC | 1232 | | magic = ARMPEMAGIC; | 1233 | | #endif | 1234 | 2 | break; | 1235 | | | 1236 | 17 | case IMAGE_FILE_MACHINE_ARM64: | 1237 | | #ifdef AARCH64MAGIC | 1238 | | magic = AARCH64MAGIC; | 1239 | | #endif | 1240 | 17 | break; | 1241 | | | 1242 | 17 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1243 | 17 | #ifdef LOONGARCH64MAGIC | 1244 | 17 | magic = LOONGARCH64MAGIC; | 1245 | 17 | #endif | 1246 | 17 | break; | 1247 | | | 1248 | 29 | case IMAGE_FILE_MACHINE_THUMB: | 1249 | | #ifdef THUMBPEMAGIC | 1250 | | { | 1251 | | extern const bfd_target TARGET_LITTLE_SYM; | 1252 | | | 1253 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1254 | | magic = THUMBPEMAGIC; | 1255 | | } | 1256 | | #endif | 1257 | 29 | break; | 1258 | | | 1259 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1260 | | /* We no longer support PowerPC. */ | 1261 | 34 | default: | 1262 | 34 | _bfd_error_handler | 1263 | | /* xgettext:c-format */ | 1264 | 34 | (_("%pB: unrecognised machine type (0x%x)" | 1265 | 34 | " in Import Library Format archive"), | 1266 | 34 | abfd, machine); | 1267 | 34 | bfd_set_error (bfd_error_malformed_archive); | 1268 | | | 1269 | 34 | return NULL; | 1270 | 0 | break; | 1271 | 190 | } | 1272 | | | 1273 | 156 | if (magic == 0) | 1274 | 139 | { | 1275 | 139 | _bfd_error_handler | 1276 | | /* xgettext:c-format */ | 1277 | 139 | (_("%pB: recognised but unhandled machine type (0x%x)" | 1278 | 139 | " in Import Library Format archive"), | 1279 | 139 | abfd, machine); | 1280 | 139 | bfd_set_error (bfd_error_wrong_format); | 1281 | | | 1282 | 139 | return NULL; | 1283 | 139 | } | 1284 | | | 1285 | | /* We do not bother to check the date. | 1286 | | date = H_GET_32 (abfd, ptr); */ | 1287 | 17 | ptr += 4; | 1288 | | | 1289 | 17 | size = H_GET_32 (abfd, ptr); | 1290 | 17 | ptr += 4; | 1291 | | | 1292 | 17 | if (size == 0) | 1293 | 0 | { | 1294 | 0 | _bfd_error_handler | 1295 | 0 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1296 | 0 | bfd_set_error (bfd_error_malformed_archive); | 1297 | |
| 1298 | 0 | return NULL; | 1299 | 0 | } | 1300 | | | 1301 | 17 | ordinal = H_GET_16 (abfd, ptr); | 1302 | 17 | ptr += 2; | 1303 | | | 1304 | 17 | types = H_GET_16 (abfd, ptr); | 1305 | | /* ptr += 2; */ | 1306 | | | 1307 | | /* Now read in the two strings that follow. */ | 1308 | 17 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1309 | 17 | if (ptr == NULL) | 1310 | 4 | return NULL; | 1311 | | | 1312 | 13 | symbol_name = (char *) ptr; | 1313 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1314 | 13 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1315 | | | 1316 | | /* Verify that the strings are null terminated. */ | 1317 | 13 | if (ptr[size - 1] != 0 | 1318 | 13 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1319 | 2 | { | 1320 | 2 | _bfd_error_handler | 1321 | 2 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1322 | 2 | bfd_set_error (bfd_error_malformed_archive); | 1323 | 2 | bfd_release (abfd, ptr); | 1324 | 2 | return NULL; | 1325 | 2 | } | 1326 | | | 1327 | | /* Now construct the bfd. */ | 1328 | 11 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1329 | 11 | source_dll, ordinal, types)) | 1330 | 5 | { | 1331 | 5 | bfd_release (abfd, ptr); | 1332 | 5 | return NULL; | 1333 | 5 | } | 1334 | | | 1335 | 6 | return pe_ILF_cleanup; | 1336 | 11 | } |
pei-arm-wince.c:pe_ILF_object_p Line | Count | Source | 1167 | 247 | { | 1168 | 247 | bfd_byte buffer[14]; | 1169 | 247 | bfd_byte * ptr; | 1170 | 247 | char * symbol_name; | 1171 | 247 | char * source_dll; | 1172 | 247 | unsigned int machine; | 1173 | 247 | bfd_size_type size; | 1174 | 247 | unsigned int ordinal; | 1175 | 247 | unsigned int types; | 1176 | 247 | unsigned int magic; | 1177 | | | 1178 | | /* Upon entry the first six bytes of the ILF header have | 1179 | | already been read. Now read the rest of the header. */ | 1180 | 247 | if (bfd_read (buffer, 14, abfd) != 14) | 1181 | 6 | return NULL; | 1182 | | | 1183 | 241 | ptr = buffer; | 1184 | | | 1185 | 241 | machine = H_GET_16 (abfd, ptr); | 1186 | 241 | ptr += 2; | 1187 | | | 1188 | | /* Check that the machine type is recognised. */ | 1189 | 241 | magic = 0; | 1190 | | | 1191 | 241 | switch (machine) | 1192 | 241 | { | 1193 | 9 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1194 | 10 | case IMAGE_FILE_MACHINE_ALPHA: | 1195 | 10 | case IMAGE_FILE_MACHINE_ALPHA64: | 1196 | 11 | case IMAGE_FILE_MACHINE_IA64: | 1197 | 11 | break; | 1198 | | | 1199 | 28 | case IMAGE_FILE_MACHINE_I386: | 1200 | | #ifdef I386MAGIC | 1201 | | magic = I386MAGIC; | 1202 | | #endif | 1203 | 28 | break; | 1204 | | | 1205 | 18 | case IMAGE_FILE_MACHINE_AMD64: | 1206 | | #ifdef AMD64MAGIC | 1207 | | magic = AMD64MAGIC; | 1208 | | #endif | 1209 | 18 | break; | 1210 | | | 1211 | 1 | case IMAGE_FILE_MACHINE_R3000: | 1212 | 2 | case IMAGE_FILE_MACHINE_R4000: | 1213 | 3 | case IMAGE_FILE_MACHINE_R10000: | 1214 | | | 1215 | 4 | case IMAGE_FILE_MACHINE_MIPS16: | 1216 | 4 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1217 | 4 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1218 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1219 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1220 | | #endif | 1221 | 4 | break; | 1222 | | | 1223 | 46 | case IMAGE_FILE_MACHINE_SH3: | 1224 | 47 | case IMAGE_FILE_MACHINE_SH4: | 1225 | | #ifdef SH_ARCH_MAGIC_WINCE | 1226 | | magic = SH_ARCH_MAGIC_WINCE; | 1227 | | #endif | 1228 | 47 | break; | 1229 | | | 1230 | 25 | case IMAGE_FILE_MACHINE_ARM: | 1231 | 25 | #ifdef ARMPEMAGIC | 1232 | 25 | magic = ARMPEMAGIC; | 1233 | 25 | #endif | 1234 | 25 | break; | 1235 | | | 1236 | 17 | case IMAGE_FILE_MACHINE_ARM64: | 1237 | | #ifdef AARCH64MAGIC | 1238 | | magic = AARCH64MAGIC; | 1239 | | #endif | 1240 | 17 | break; | 1241 | | | 1242 | 17 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1243 | | #ifdef LOONGARCH64MAGIC | 1244 | | magic = LOONGARCH64MAGIC; | 1245 | | #endif | 1246 | 17 | break; | 1247 | | | 1248 | 29 | case IMAGE_FILE_MACHINE_THUMB: | 1249 | 29 | #ifdef THUMBPEMAGIC | 1250 | 29 | { | 1251 | 29 | extern const bfd_target TARGET_LITTLE_SYM; | 1252 | | | 1253 | 29 | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1254 | 29 | magic = THUMBPEMAGIC; | 1255 | 29 | } | 1256 | 29 | #endif | 1257 | 29 | break; | 1258 | | | 1259 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1260 | | /* We no longer support PowerPC. */ | 1261 | 45 | default: | 1262 | 45 | _bfd_error_handler | 1263 | | /* xgettext:c-format */ | 1264 | 45 | (_("%pB: unrecognised machine type (0x%x)" | 1265 | 45 | " in Import Library Format archive"), | 1266 | 45 | abfd, machine); | 1267 | 45 | bfd_set_error (bfd_error_malformed_archive); | 1268 | | | 1269 | 45 | return NULL; | 1270 | 0 | break; | 1271 | 241 | } | 1272 | | | 1273 | 196 | if (magic == 0) | 1274 | 142 | { | 1275 | 142 | _bfd_error_handler | 1276 | | /* xgettext:c-format */ | 1277 | 142 | (_("%pB: recognised but unhandled machine type (0x%x)" | 1278 | 142 | " in Import Library Format archive"), | 1279 | 142 | abfd, machine); | 1280 | 142 | bfd_set_error (bfd_error_wrong_format); | 1281 | | | 1282 | 142 | return NULL; | 1283 | 142 | } | 1284 | | | 1285 | | /* We do not bother to check the date. | 1286 | | date = H_GET_32 (abfd, ptr); */ | 1287 | 54 | ptr += 4; | 1288 | | | 1289 | 54 | size = H_GET_32 (abfd, ptr); | 1290 | 54 | ptr += 4; | 1291 | | | 1292 | 54 | if (size == 0) | 1293 | 1 | { | 1294 | 1 | _bfd_error_handler | 1295 | 1 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1296 | 1 | bfd_set_error (bfd_error_malformed_archive); | 1297 | | | 1298 | 1 | return NULL; | 1299 | 1 | } | 1300 | | | 1301 | 53 | ordinal = H_GET_16 (abfd, ptr); | 1302 | 53 | ptr += 2; | 1303 | | | 1304 | 53 | types = H_GET_16 (abfd, ptr); | 1305 | | /* ptr += 2; */ | 1306 | | | 1307 | | /* Now read in the two strings that follow. */ | 1308 | 53 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1309 | 53 | if (ptr == NULL) | 1310 | 35 | return NULL; | 1311 | | | 1312 | 18 | symbol_name = (char *) ptr; | 1313 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1314 | 18 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1315 | | | 1316 | | /* Verify that the strings are null terminated. */ | 1317 | 18 | if (ptr[size - 1] != 0 | 1318 | 18 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1319 | 4 | { | 1320 | 4 | _bfd_error_handler | 1321 | 4 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1322 | 4 | bfd_set_error (bfd_error_malformed_archive); | 1323 | 4 | bfd_release (abfd, ptr); | 1324 | 4 | return NULL; | 1325 | 4 | } | 1326 | | | 1327 | | /* Now construct the bfd. */ | 1328 | 14 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1329 | 14 | source_dll, ordinal, types)) | 1330 | 7 | { | 1331 | 7 | bfd_release (abfd, ptr); | 1332 | 7 | return NULL; | 1333 | 7 | } | 1334 | | | 1335 | 7 | return pe_ILF_cleanup; | 1336 | 14 | } |
pei-arm.c:pe_ILF_object_p Line | Count | Source | 1167 | 255 | { | 1168 | 255 | bfd_byte buffer[14]; | 1169 | 255 | bfd_byte * ptr; | 1170 | 255 | char * symbol_name; | 1171 | 255 | char * source_dll; | 1172 | 255 | unsigned int machine; | 1173 | 255 | bfd_size_type size; | 1174 | 255 | unsigned int ordinal; | 1175 | 255 | unsigned int types; | 1176 | 255 | unsigned int magic; | 1177 | | | 1178 | | /* Upon entry the first six bytes of the ILF header have | 1179 | | already been read. Now read the rest of the header. */ | 1180 | 255 | if (bfd_read (buffer, 14, abfd) != 14) | 1181 | 6 | return NULL; | 1182 | | | 1183 | 249 | ptr = buffer; | 1184 | | | 1185 | 249 | machine = H_GET_16 (abfd, ptr); | 1186 | 249 | ptr += 2; | 1187 | | | 1188 | | /* Check that the machine type is recognised. */ | 1189 | 249 | magic = 0; | 1190 | | | 1191 | 249 | switch (machine) | 1192 | 249 | { | 1193 | 9 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1194 | 10 | case IMAGE_FILE_MACHINE_ALPHA: | 1195 | 10 | case IMAGE_FILE_MACHINE_ALPHA64: | 1196 | 11 | case IMAGE_FILE_MACHINE_IA64: | 1197 | 11 | break; | 1198 | | | 1199 | 28 | case IMAGE_FILE_MACHINE_I386: | 1200 | | #ifdef I386MAGIC | 1201 | | magic = I386MAGIC; | 1202 | | #endif | 1203 | 28 | break; | 1204 | | | 1205 | 18 | case IMAGE_FILE_MACHINE_AMD64: | 1206 | | #ifdef AMD64MAGIC | 1207 | | magic = AMD64MAGIC; | 1208 | | #endif | 1209 | 18 | break; | 1210 | | | 1211 | 1 | case IMAGE_FILE_MACHINE_R3000: | 1212 | 2 | case IMAGE_FILE_MACHINE_R4000: | 1213 | 3 | case IMAGE_FILE_MACHINE_R10000: | 1214 | | | 1215 | 4 | case IMAGE_FILE_MACHINE_MIPS16: | 1216 | 4 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1217 | 4 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1218 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1219 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1220 | | #endif | 1221 | 4 | break; | 1222 | | | 1223 | 46 | case IMAGE_FILE_MACHINE_SH3: | 1224 | 47 | case IMAGE_FILE_MACHINE_SH4: | 1225 | | #ifdef SH_ARCH_MAGIC_WINCE | 1226 | | magic = SH_ARCH_MAGIC_WINCE; | 1227 | | #endif | 1228 | 47 | break; | 1229 | | | 1230 | 25 | case IMAGE_FILE_MACHINE_ARM: | 1231 | 25 | #ifdef ARMPEMAGIC | 1232 | 25 | magic = ARMPEMAGIC; | 1233 | 25 | #endif | 1234 | 25 | break; | 1235 | | | 1236 | 17 | case IMAGE_FILE_MACHINE_ARM64: | 1237 | | #ifdef AARCH64MAGIC | 1238 | | magic = AARCH64MAGIC; | 1239 | | #endif | 1240 | 17 | break; | 1241 | | | 1242 | 17 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1243 | | #ifdef LOONGARCH64MAGIC | 1244 | | magic = LOONGARCH64MAGIC; | 1245 | | #endif | 1246 | 17 | break; | 1247 | | | 1248 | 37 | case IMAGE_FILE_MACHINE_THUMB: | 1249 | 37 | #ifdef THUMBPEMAGIC | 1250 | 37 | { | 1251 | 37 | extern const bfd_target TARGET_LITTLE_SYM; | 1252 | | | 1253 | 37 | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1254 | 37 | magic = THUMBPEMAGIC; | 1255 | 37 | } | 1256 | 37 | #endif | 1257 | 37 | break; | 1258 | | | 1259 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1260 | | /* We no longer support PowerPC. */ | 1261 | 45 | default: | 1262 | 45 | _bfd_error_handler | 1263 | | /* xgettext:c-format */ | 1264 | 45 | (_("%pB: unrecognised machine type (0x%x)" | 1265 | 45 | " in Import Library Format archive"), | 1266 | 45 | abfd, machine); | 1267 | 45 | bfd_set_error (bfd_error_malformed_archive); | 1268 | | | 1269 | 45 | return NULL; | 1270 | 0 | break; | 1271 | 249 | } | 1272 | | | 1273 | 204 | if (magic == 0) | 1274 | 142 | { | 1275 | 142 | _bfd_error_handler | 1276 | | /* xgettext:c-format */ | 1277 | 142 | (_("%pB: recognised but unhandled machine type (0x%x)" | 1278 | 142 | " in Import Library Format archive"), | 1279 | 142 | abfd, machine); | 1280 | 142 | bfd_set_error (bfd_error_wrong_format); | 1281 | | | 1282 | 142 | return NULL; | 1283 | 142 | } | 1284 | | | 1285 | | /* We do not bother to check the date. | 1286 | | date = H_GET_32 (abfd, ptr); */ | 1287 | 62 | ptr += 4; | 1288 | | | 1289 | 62 | size = H_GET_32 (abfd, ptr); | 1290 | 62 | ptr += 4; | 1291 | | | 1292 | 62 | if (size == 0) | 1293 | 1 | { | 1294 | 1 | _bfd_error_handler | 1295 | 1 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1296 | 1 | bfd_set_error (bfd_error_malformed_archive); | 1297 | | | 1298 | 1 | return NULL; | 1299 | 1 | } | 1300 | | | 1301 | 61 | ordinal = H_GET_16 (abfd, ptr); | 1302 | 61 | ptr += 2; | 1303 | | | 1304 | 61 | types = H_GET_16 (abfd, ptr); | 1305 | | /* ptr += 2; */ | 1306 | | | 1307 | | /* Now read in the two strings that follow. */ | 1308 | 61 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1309 | 61 | if (ptr == NULL) | 1310 | 35 | return NULL; | 1311 | | | 1312 | 26 | symbol_name = (char *) ptr; | 1313 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1314 | 26 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1315 | | | 1316 | | /* Verify that the strings are null terminated. */ | 1317 | 26 | if (ptr[size - 1] != 0 | 1318 | 26 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1319 | 4 | { | 1320 | 4 | _bfd_error_handler | 1321 | 4 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1322 | 4 | bfd_set_error (bfd_error_malformed_archive); | 1323 | 4 | bfd_release (abfd, ptr); | 1324 | 4 | return NULL; | 1325 | 4 | } | 1326 | | | 1327 | | /* Now construct the bfd. */ | 1328 | 22 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1329 | 22 | source_dll, ordinal, types)) | 1330 | 7 | { | 1331 | 7 | bfd_release (abfd, ptr); | 1332 | 7 | return NULL; | 1333 | 7 | } | 1334 | | | 1335 | 15 | return pe_ILF_cleanup; | 1336 | 22 | } |
pei-mcore.c:pe_ILF_object_p Line | Count | Source | 1167 | 247 | { | 1168 | 247 | bfd_byte buffer[14]; | 1169 | 247 | bfd_byte * ptr; | 1170 | 247 | char * symbol_name; | 1171 | 247 | char * source_dll; | 1172 | 247 | unsigned int machine; | 1173 | 247 | bfd_size_type size; | 1174 | 247 | unsigned int ordinal; | 1175 | 247 | unsigned int types; | 1176 | 247 | unsigned int magic; | 1177 | | | 1178 | | /* Upon entry the first six bytes of the ILF header have | 1179 | | already been read. Now read the rest of the header. */ | 1180 | 247 | if (bfd_read (buffer, 14, abfd) != 14) | 1181 | 6 | return NULL; | 1182 | | | 1183 | 241 | ptr = buffer; | 1184 | | | 1185 | 241 | machine = H_GET_16 (abfd, ptr); | 1186 | 241 | ptr += 2; | 1187 | | | 1188 | | /* Check that the machine type is recognised. */ | 1189 | 241 | magic = 0; | 1190 | | | 1191 | 241 | switch (machine) | 1192 | 241 | { | 1193 | 9 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1194 | 10 | case IMAGE_FILE_MACHINE_ALPHA: | 1195 | 10 | case IMAGE_FILE_MACHINE_ALPHA64: | 1196 | 11 | case IMAGE_FILE_MACHINE_IA64: | 1197 | 11 | break; | 1198 | | | 1199 | 28 | case IMAGE_FILE_MACHINE_I386: | 1200 | | #ifdef I386MAGIC | 1201 | | magic = I386MAGIC; | 1202 | | #endif | 1203 | 28 | break; | 1204 | | | 1205 | 18 | case IMAGE_FILE_MACHINE_AMD64: | 1206 | | #ifdef AMD64MAGIC | 1207 | | magic = AMD64MAGIC; | 1208 | | #endif | 1209 | 18 | break; | 1210 | | | 1211 | 1 | case IMAGE_FILE_MACHINE_R3000: | 1212 | 2 | case IMAGE_FILE_MACHINE_R4000: | 1213 | 3 | case IMAGE_FILE_MACHINE_R10000: | 1214 | | | 1215 | 4 | case IMAGE_FILE_MACHINE_MIPS16: | 1216 | 4 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1217 | 4 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1218 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1219 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1220 | | #endif | 1221 | 4 | break; | 1222 | | | 1223 | 46 | case IMAGE_FILE_MACHINE_SH3: | 1224 | 47 | case IMAGE_FILE_MACHINE_SH4: | 1225 | | #ifdef SH_ARCH_MAGIC_WINCE | 1226 | | magic = SH_ARCH_MAGIC_WINCE; | 1227 | | #endif | 1228 | 47 | break; | 1229 | | | 1230 | 25 | case IMAGE_FILE_MACHINE_ARM: | 1231 | | #ifdef ARMPEMAGIC | 1232 | | magic = ARMPEMAGIC; | 1233 | | #endif | 1234 | 25 | break; | 1235 | | | 1236 | 17 | case IMAGE_FILE_MACHINE_ARM64: | 1237 | | #ifdef AARCH64MAGIC | 1238 | | magic = AARCH64MAGIC; | 1239 | | #endif | 1240 | 17 | break; | 1241 | | | 1242 | 17 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1243 | | #ifdef LOONGARCH64MAGIC | 1244 | | magic = LOONGARCH64MAGIC; | 1245 | | #endif | 1246 | 17 | break; | 1247 | | | 1248 | 29 | case IMAGE_FILE_MACHINE_THUMB: | 1249 | | #ifdef THUMBPEMAGIC | 1250 | | { | 1251 | | extern const bfd_target TARGET_LITTLE_SYM; | 1252 | | | 1253 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1254 | | magic = THUMBPEMAGIC; | 1255 | | } | 1256 | | #endif | 1257 | 29 | break; | 1258 | | | 1259 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1260 | | /* We no longer support PowerPC. */ | 1261 | 45 | default: | 1262 | 45 | _bfd_error_handler | 1263 | | /* xgettext:c-format */ | 1264 | 45 | (_("%pB: unrecognised machine type (0x%x)" | 1265 | 45 | " in Import Library Format archive"), | 1266 | 45 | abfd, machine); | 1267 | 45 | bfd_set_error (bfd_error_malformed_archive); | 1268 | | | 1269 | 45 | return NULL; | 1270 | 0 | break; | 1271 | 241 | } | 1272 | | | 1273 | 196 | if (magic == 0) | 1274 | 196 | { | 1275 | 196 | _bfd_error_handler | 1276 | | /* xgettext:c-format */ | 1277 | 196 | (_("%pB: recognised but unhandled machine type (0x%x)" | 1278 | 196 | " in Import Library Format archive"), | 1279 | 196 | abfd, machine); | 1280 | 196 | bfd_set_error (bfd_error_wrong_format); | 1281 | | | 1282 | 196 | return NULL; | 1283 | 196 | } | 1284 | | | 1285 | | /* We do not bother to check the date. | 1286 | | date = H_GET_32 (abfd, ptr); */ | 1287 | 0 | ptr += 4; | 1288 | |
| 1289 | 0 | size = H_GET_32 (abfd, ptr); | 1290 | 0 | ptr += 4; | 1291 | |
| 1292 | 0 | if (size == 0) | 1293 | 0 | { | 1294 | 0 | _bfd_error_handler | 1295 | 0 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1296 | 0 | bfd_set_error (bfd_error_malformed_archive); | 1297 | |
| 1298 | 0 | return NULL; | 1299 | 0 | } | 1300 | | | 1301 | 0 | ordinal = H_GET_16 (abfd, ptr); | 1302 | 0 | ptr += 2; | 1303 | |
| 1304 | 0 | types = H_GET_16 (abfd, ptr); | 1305 | | /* ptr += 2; */ | 1306 | | | 1307 | | /* Now read in the two strings that follow. */ | 1308 | 0 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1309 | 0 | if (ptr == NULL) | 1310 | 0 | return NULL; | 1311 | | | 1312 | 0 | symbol_name = (char *) ptr; | 1313 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1314 | 0 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1315 | | | 1316 | | /* Verify that the strings are null terminated. */ | 1317 | 0 | if (ptr[size - 1] != 0 | 1318 | 0 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1319 | 0 | { | 1320 | 0 | _bfd_error_handler | 1321 | 0 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1322 | 0 | bfd_set_error (bfd_error_malformed_archive); | 1323 | 0 | bfd_release (abfd, ptr); | 1324 | 0 | return NULL; | 1325 | 0 | } | 1326 | | | 1327 | | /* Now construct the bfd. */ | 1328 | 0 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1329 | 0 | source_dll, ordinal, types)) | 1330 | 0 | { | 1331 | 0 | bfd_release (abfd, ptr); | 1332 | 0 | return NULL; | 1333 | 0 | } | 1334 | | | 1335 | 0 | return pe_ILF_cleanup; | 1336 | 0 | } |
Line | Count | Source | 1167 | 211 | { | 1168 | 211 | bfd_byte buffer[14]; | 1169 | 211 | bfd_byte * ptr; | 1170 | 211 | char * symbol_name; | 1171 | 211 | char * source_dll; | 1172 | 211 | unsigned int machine; | 1173 | 211 | bfd_size_type size; | 1174 | 211 | unsigned int ordinal; | 1175 | 211 | unsigned int types; | 1176 | 211 | unsigned int magic; | 1177 | | | 1178 | | /* Upon entry the first six bytes of the ILF header have | 1179 | | already been read. Now read the rest of the header. */ | 1180 | 211 | if (bfd_read (buffer, 14, abfd) != 14) | 1181 | 5 | return NULL; | 1182 | | | 1183 | 206 | ptr = buffer; | 1184 | | | 1185 | 206 | machine = H_GET_16 (abfd, ptr); | 1186 | 206 | ptr += 2; | 1187 | | | 1188 | | /* Check that the machine type is recognised. */ | 1189 | 206 | magic = 0; | 1190 | | | 1191 | 206 | switch (machine) | 1192 | 206 | { | 1193 | 8 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1194 | 9 | case IMAGE_FILE_MACHINE_ALPHA: | 1195 | 9 | case IMAGE_FILE_MACHINE_ALPHA64: | 1196 | 10 | case IMAGE_FILE_MACHINE_IA64: | 1197 | 10 | break; | 1198 | | | 1199 | 28 | case IMAGE_FILE_MACHINE_I386: | 1200 | | #ifdef I386MAGIC | 1201 | | magic = I386MAGIC; | 1202 | | #endif | 1203 | 28 | break; | 1204 | | | 1205 | 18 | case IMAGE_FILE_MACHINE_AMD64: | 1206 | | #ifdef AMD64MAGIC | 1207 | | magic = AMD64MAGIC; | 1208 | | #endif | 1209 | 18 | break; | 1210 | | | 1211 | 1 | case IMAGE_FILE_MACHINE_R3000: | 1212 | 2 | case IMAGE_FILE_MACHINE_R4000: | 1213 | 3 | case IMAGE_FILE_MACHINE_R10000: | 1214 | | | 1215 | 4 | case IMAGE_FILE_MACHINE_MIPS16: | 1216 | 4 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1217 | 4 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1218 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1219 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1220 | | #endif | 1221 | 4 | break; | 1222 | | | 1223 | 46 | case IMAGE_FILE_MACHINE_SH3: | 1224 | 47 | case IMAGE_FILE_MACHINE_SH4: | 1225 | 47 | #ifdef SH_ARCH_MAGIC_WINCE | 1226 | 47 | magic = SH_ARCH_MAGIC_WINCE; | 1227 | 47 | #endif | 1228 | 47 | break; | 1229 | | | 1230 | 2 | case IMAGE_FILE_MACHINE_ARM: | 1231 | | #ifdef ARMPEMAGIC | 1232 | | magic = ARMPEMAGIC; | 1233 | | #endif | 1234 | 2 | break; | 1235 | | | 1236 | 17 | case IMAGE_FILE_MACHINE_ARM64: | 1237 | | #ifdef AARCH64MAGIC | 1238 | | magic = AARCH64MAGIC; | 1239 | | #endif | 1240 | 17 | break; | 1241 | | | 1242 | 17 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1243 | | #ifdef LOONGARCH64MAGIC | 1244 | | magic = LOONGARCH64MAGIC; | 1245 | | #endif | 1246 | 17 | break; | 1247 | | | 1248 | 29 | case IMAGE_FILE_MACHINE_THUMB: | 1249 | | #ifdef THUMBPEMAGIC | 1250 | | { | 1251 | | extern const bfd_target TARGET_LITTLE_SYM; | 1252 | | | 1253 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1254 | | magic = THUMBPEMAGIC; | 1255 | | } | 1256 | | #endif | 1257 | 29 | break; | 1258 | | | 1259 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1260 | | /* We no longer support PowerPC. */ | 1261 | 34 | default: | 1262 | 34 | _bfd_error_handler | 1263 | | /* xgettext:c-format */ | 1264 | 34 | (_("%pB: unrecognised machine type (0x%x)" | 1265 | 34 | " in Import Library Format archive"), | 1266 | 34 | abfd, machine); | 1267 | 34 | bfd_set_error (bfd_error_malformed_archive); | 1268 | | | 1269 | 34 | return NULL; | 1270 | 0 | break; | 1271 | 206 | } | 1272 | | | 1273 | 172 | if (magic == 0) | 1274 | 125 | { | 1275 | 125 | _bfd_error_handler | 1276 | | /* xgettext:c-format */ | 1277 | 125 | (_("%pB: recognised but unhandled machine type (0x%x)" | 1278 | 125 | " in Import Library Format archive"), | 1279 | 125 | abfd, machine); | 1280 | 125 | bfd_set_error (bfd_error_wrong_format); | 1281 | | | 1282 | 125 | return NULL; | 1283 | 125 | } | 1284 | | | 1285 | | /* We do not bother to check the date. | 1286 | | date = H_GET_32 (abfd, ptr); */ | 1287 | 47 | ptr += 4; | 1288 | | | 1289 | 47 | size = H_GET_32 (abfd, ptr); | 1290 | 47 | ptr += 4; | 1291 | | | 1292 | 47 | if (size == 0) | 1293 | 2 | { | 1294 | 2 | _bfd_error_handler | 1295 | 2 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1296 | 2 | bfd_set_error (bfd_error_malformed_archive); | 1297 | | | 1298 | 2 | return NULL; | 1299 | 2 | } | 1300 | | | 1301 | 45 | ordinal = H_GET_16 (abfd, ptr); | 1302 | 45 | ptr += 2; | 1303 | | | 1304 | 45 | types = H_GET_16 (abfd, ptr); | 1305 | | /* ptr += 2; */ | 1306 | | | 1307 | | /* Now read in the two strings that follow. */ | 1308 | 45 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1309 | 45 | if (ptr == NULL) | 1310 | 13 | return NULL; | 1311 | | | 1312 | 32 | symbol_name = (char *) ptr; | 1313 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1314 | 32 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1315 | | | 1316 | | /* Verify that the strings are null terminated. */ | 1317 | 32 | if (ptr[size - 1] != 0 | 1318 | 32 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1319 | 10 | { | 1320 | 10 | _bfd_error_handler | 1321 | 10 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1322 | 10 | bfd_set_error (bfd_error_malformed_archive); | 1323 | 10 | bfd_release (abfd, ptr); | 1324 | 10 | return NULL; | 1325 | 10 | } | 1326 | | | 1327 | | /* Now construct the bfd. */ | 1328 | 22 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1329 | 22 | source_dll, ordinal, types)) | 1330 | 5 | { | 1331 | 5 | bfd_release (abfd, ptr); | 1332 | 5 | return NULL; | 1333 | 5 | } | 1334 | | | 1335 | 17 | return pe_ILF_cleanup; | 1336 | 22 | } |
|
1337 | | |
1338 | | static void |
1339 | | pe_bfd_read_buildid (bfd *abfd) |
1340 | 1.73k | { |
1341 | 1.73k | pe_data_type *pe = pe_data (abfd); |
1342 | 1.73k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; |
1343 | 1.73k | asection *section; |
1344 | 1.73k | bfd_byte *data = 0; |
1345 | 1.73k | bfd_size_type dataoff; |
1346 | 1.73k | unsigned int i; |
1347 | 1.73k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; |
1348 | 1.73k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; |
1349 | | |
1350 | 1.73k | if (size == 0) |
1351 | 906 | return; |
1352 | | |
1353 | 824 | addr += extra->ImageBase; |
1354 | | |
1355 | | /* Search for the section containing the DebugDirectory. */ |
1356 | 3.80k | for (section = abfd->sections; section != NULL; section = section->next) |
1357 | 3.27k | { |
1358 | 3.27k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) |
1359 | 296 | break; |
1360 | 3.27k | } |
1361 | | |
1362 | 824 | if (section == NULL) |
1363 | 528 | return; |
1364 | | |
1365 | 296 | if (!(section->flags & SEC_HAS_CONTENTS)) |
1366 | 54 | return; |
1367 | | |
1368 | 242 | dataoff = addr - section->vma; |
1369 | | |
1370 | | /* PR 20605 and 22373: Make sure that the data is really there. |
1371 | | Note - since we are dealing with unsigned quantities we have |
1372 | | to be careful to check for potential overflows. */ |
1373 | 242 | if (dataoff >= section->size |
1374 | 242 | || size > section->size - dataoff) |
1375 | 65 | { |
1376 | 65 | _bfd_error_handler |
1377 | 65 | (_("%pB: error: debug data ends beyond end of debug directory"), |
1378 | 65 | abfd); |
1379 | 65 | return; |
1380 | 65 | } |
1381 | | |
1382 | | /* Read the whole section. */ |
1383 | 177 | if (!bfd_malloc_and_get_section (abfd, section, &data)) |
1384 | 127 | { |
1385 | 127 | free (data); |
1386 | 127 | return; |
1387 | 127 | } |
1388 | | |
1389 | | /* Search for a CodeView entry in the DebugDirectory */ |
1390 | 235 | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) |
1391 | 213 | { |
1392 | 213 | struct external_IMAGE_DEBUG_DIRECTORY *ext |
1393 | 213 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; |
1394 | 213 | struct internal_IMAGE_DEBUG_DIRECTORY idd; |
1395 | | |
1396 | 213 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); |
1397 | | |
1398 | 213 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) |
1399 | 28 | { |
1400 | 28 | char buffer[256 + 1]; |
1401 | 28 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; |
1402 | | |
1403 | | /* |
1404 | | The debug entry doesn't have to have to be in a section, in which |
1405 | | case AddressOfRawData is 0, so always use PointerToRawData. |
1406 | | */ |
1407 | 28 | if (_bfd_XXi_slurp_codeview_record (abfd, |
1408 | 28 | (file_ptr) idd.PointerToRawData, |
1409 | 28 | idd.SizeOfData, cvinfo, NULL)) |
1410 | 4 | { |
1411 | 4 | struct bfd_build_id* build_id = bfd_alloc (abfd, |
1412 | 4 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); |
1413 | 4 | if (build_id) |
1414 | 4 | { |
1415 | 4 | build_id->size = cvinfo->SignatureLength; |
1416 | 4 | memcpy(build_id->data, cvinfo->Signature, |
1417 | 4 | cvinfo->SignatureLength); |
1418 | 4 | abfd->build_id = build_id; |
1419 | 4 | } |
1420 | 4 | } |
1421 | 28 | break; |
1422 | 28 | } |
1423 | 213 | } |
1424 | | |
1425 | 50 | free (data); |
1426 | 50 | } pei-i386.c:pe_bfd_read_buildid Line | Count | Source | 1340 | 281 | { | 1341 | 281 | pe_data_type *pe = pe_data (abfd); | 1342 | 281 | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1343 | 281 | asection *section; | 1344 | 281 | bfd_byte *data = 0; | 1345 | 281 | bfd_size_type dataoff; | 1346 | 281 | unsigned int i; | 1347 | 281 | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1348 | 281 | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1349 | | | 1350 | 281 | if (size == 0) | 1351 | 171 | return; | 1352 | | | 1353 | 110 | addr += extra->ImageBase; | 1354 | | | 1355 | | /* Search for the section containing the DebugDirectory. */ | 1356 | 502 | for (section = abfd->sections; section != NULL; section = section->next) | 1357 | 452 | { | 1358 | 452 | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1359 | 60 | break; | 1360 | 452 | } | 1361 | | | 1362 | 110 | if (section == NULL) | 1363 | 50 | return; | 1364 | | | 1365 | 60 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1366 | 10 | return; | 1367 | | | 1368 | 50 | dataoff = addr - section->vma; | 1369 | | | 1370 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1371 | | Note - since we are dealing with unsigned quantities we have | 1372 | | to be careful to check for potential overflows. */ | 1373 | 50 | if (dataoff >= section->size | 1374 | 50 | || size > section->size - dataoff) | 1375 | 14 | { | 1376 | 14 | _bfd_error_handler | 1377 | 14 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1378 | 14 | abfd); | 1379 | 14 | return; | 1380 | 14 | } | 1381 | | | 1382 | | /* Read the whole section. */ | 1383 | 36 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1384 | 23 | { | 1385 | 23 | free (data); | 1386 | 23 | return; | 1387 | 23 | } | 1388 | | | 1389 | | /* Search for a CodeView entry in the DebugDirectory */ | 1390 | 63 | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1391 | 56 | { | 1392 | 56 | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1393 | 56 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1394 | 56 | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1395 | | | 1396 | 56 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1397 | | | 1398 | 56 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1399 | 6 | { | 1400 | 6 | char buffer[256 + 1]; | 1401 | 6 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1402 | | | 1403 | | /* | 1404 | | The debug entry doesn't have to have to be in a section, in which | 1405 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1406 | | */ | 1407 | 6 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1408 | 6 | (file_ptr) idd.PointerToRawData, | 1409 | 6 | idd.SizeOfData, cvinfo, NULL)) | 1410 | 1 | { | 1411 | 1 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1412 | 1 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1413 | 1 | if (build_id) | 1414 | 1 | { | 1415 | 1 | build_id->size = cvinfo->SignatureLength; | 1416 | 1 | memcpy(build_id->data, cvinfo->Signature, | 1417 | 1 | cvinfo->SignatureLength); | 1418 | 1 | abfd->build_id = build_id; | 1419 | 1 | } | 1420 | 1 | } | 1421 | 6 | break; | 1422 | 6 | } | 1423 | 56 | } | 1424 | | | 1425 | 13 | free (data); | 1426 | 13 | } |
pei-x86_64.c:pe_bfd_read_buildid Line | Count | Source | 1340 | 338 | { | 1341 | 338 | pe_data_type *pe = pe_data (abfd); | 1342 | 338 | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1343 | 338 | asection *section; | 1344 | 338 | bfd_byte *data = 0; | 1345 | 338 | bfd_size_type dataoff; | 1346 | 338 | unsigned int i; | 1347 | 338 | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1348 | 338 | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1349 | | | 1350 | 338 | if (size == 0) | 1351 | 131 | return; | 1352 | | | 1353 | 207 | addr += extra->ImageBase; | 1354 | | | 1355 | | /* Search for the section containing the DebugDirectory. */ | 1356 | 846 | for (section = abfd->sections; section != NULL; section = section->next) | 1357 | 677 | { | 1358 | 677 | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1359 | 38 | break; | 1360 | 677 | } | 1361 | | | 1362 | 207 | if (section == NULL) | 1363 | 169 | return; | 1364 | | | 1365 | 38 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1366 | 8 | return; | 1367 | | | 1368 | 30 | dataoff = addr - section->vma; | 1369 | | | 1370 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1371 | | Note - since we are dealing with unsigned quantities we have | 1372 | | to be careful to check for potential overflows. */ | 1373 | 30 | if (dataoff >= section->size | 1374 | 30 | || size > section->size - dataoff) | 1375 | 12 | { | 1376 | 12 | _bfd_error_handler | 1377 | 12 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1378 | 12 | abfd); | 1379 | 12 | return; | 1380 | 12 | } | 1381 | | | 1382 | | /* Read the whole section. */ | 1383 | 18 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1384 | 16 | { | 1385 | 16 | free (data); | 1386 | 16 | return; | 1387 | 16 | } | 1388 | | | 1389 | | /* Search for a CodeView entry in the DebugDirectory */ | 1390 | 3 | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1391 | 3 | { | 1392 | 3 | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1393 | 3 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1394 | 3 | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1395 | | | 1396 | 3 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1397 | | | 1398 | 3 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1399 | 2 | { | 1400 | 2 | char buffer[256 + 1]; | 1401 | 2 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1402 | | | 1403 | | /* | 1404 | | The debug entry doesn't have to have to be in a section, in which | 1405 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1406 | | */ | 1407 | 2 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1408 | 2 | (file_ptr) idd.PointerToRawData, | 1409 | 2 | idd.SizeOfData, cvinfo, NULL)) | 1410 | 1 | { | 1411 | 1 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1412 | 1 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1413 | 1 | if (build_id) | 1414 | 1 | { | 1415 | 1 | build_id->size = cvinfo->SignatureLength; | 1416 | 1 | memcpy(build_id->data, cvinfo->Signature, | 1417 | 1 | cvinfo->SignatureLength); | 1418 | 1 | abfd->build_id = build_id; | 1419 | 1 | } | 1420 | 1 | } | 1421 | 2 | break; | 1422 | 2 | } | 1423 | 3 | } | 1424 | | | 1425 | 2 | free (data); | 1426 | 2 | } |
pei-aarch64.c:pe_bfd_read_buildid Line | Count | Source | 1340 | 159 | { | 1341 | 159 | pe_data_type *pe = pe_data (abfd); | 1342 | 159 | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1343 | 159 | asection *section; | 1344 | 159 | bfd_byte *data = 0; | 1345 | 159 | bfd_size_type dataoff; | 1346 | 159 | unsigned int i; | 1347 | 159 | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1348 | 159 | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1349 | | | 1350 | 159 | if (size == 0) | 1351 | 62 | return; | 1352 | | | 1353 | 97 | addr += extra->ImageBase; | 1354 | | | 1355 | | /* Search for the section containing the DebugDirectory. */ | 1356 | 654 | for (section = abfd->sections; section != NULL; section = section->next) | 1357 | 575 | { | 1358 | 575 | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1359 | 18 | break; | 1360 | 575 | } | 1361 | | | 1362 | 97 | if (section == NULL) | 1363 | 79 | return; | 1364 | | | 1365 | 18 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1366 | 5 | return; | 1367 | | | 1368 | 13 | dataoff = addr - section->vma; | 1369 | | | 1370 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1371 | | Note - since we are dealing with unsigned quantities we have | 1372 | | to be careful to check for potential overflows. */ | 1373 | 13 | if (dataoff >= section->size | 1374 | 13 | || size > section->size - dataoff) | 1375 | 2 | { | 1376 | 2 | _bfd_error_handler | 1377 | 2 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1378 | 2 | abfd); | 1379 | 2 | return; | 1380 | 2 | } | 1381 | | | 1382 | | /* Read the whole section. */ | 1383 | 11 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1384 | 3 | { | 1385 | 3 | free (data); | 1386 | 3 | return; | 1387 | 3 | } | 1388 | | | 1389 | | /* Search for a CodeView entry in the DebugDirectory */ | 1390 | 44 | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1391 | 40 | { | 1392 | 40 | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1393 | 40 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1394 | 40 | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1395 | | | 1396 | 40 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1397 | | | 1398 | 40 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1399 | 4 | { | 1400 | 4 | char buffer[256 + 1]; | 1401 | 4 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1402 | | | 1403 | | /* | 1404 | | The debug entry doesn't have to have to be in a section, in which | 1405 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1406 | | */ | 1407 | 4 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1408 | 4 | (file_ptr) idd.PointerToRawData, | 1409 | 4 | idd.SizeOfData, cvinfo, NULL)) | 1410 | 0 | { | 1411 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1412 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1413 | 0 | if (build_id) | 1414 | 0 | { | 1415 | 0 | build_id->size = cvinfo->SignatureLength; | 1416 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1417 | 0 | cvinfo->SignatureLength); | 1418 | 0 | abfd->build_id = build_id; | 1419 | 0 | } | 1420 | 0 | } | 1421 | 4 | break; | 1422 | 4 | } | 1423 | 40 | } | 1424 | | | 1425 | 8 | free (data); | 1426 | 8 | } |
pei-ia64.c:pe_bfd_read_buildid Line | Count | Source | 1340 | 202 | { | 1341 | 202 | pe_data_type *pe = pe_data (abfd); | 1342 | 202 | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1343 | 202 | asection *section; | 1344 | 202 | bfd_byte *data = 0; | 1345 | 202 | bfd_size_type dataoff; | 1346 | 202 | unsigned int i; | 1347 | 202 | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1348 | 202 | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1349 | | | 1350 | 202 | if (size == 0) | 1351 | 133 | return; | 1352 | | | 1353 | 69 | addr += extra->ImageBase; | 1354 | | | 1355 | | /* Search for the section containing the DebugDirectory. */ | 1356 | 314 | for (section = abfd->sections; section != NULL; section = section->next) | 1357 | 263 | { | 1358 | 263 | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1359 | 18 | break; | 1360 | 263 | } | 1361 | | | 1362 | 69 | if (section == NULL) | 1363 | 51 | return; | 1364 | | | 1365 | 18 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1366 | 2 | return; | 1367 | | | 1368 | 16 | dataoff = addr - section->vma; | 1369 | | | 1370 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1371 | | Note - since we are dealing with unsigned quantities we have | 1372 | | to be careful to check for potential overflows. */ | 1373 | 16 | if (dataoff >= section->size | 1374 | 16 | || size > section->size - dataoff) | 1375 | 4 | { | 1376 | 4 | _bfd_error_handler | 1377 | 4 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1378 | 4 | abfd); | 1379 | 4 | return; | 1380 | 4 | } | 1381 | | | 1382 | | /* Read the whole section. */ | 1383 | 12 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1384 | 5 | { | 1385 | 5 | free (data); | 1386 | 5 | return; | 1387 | 5 | } | 1388 | | | 1389 | | /* Search for a CodeView entry in the DebugDirectory */ | 1390 | 37 | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1391 | 36 | { | 1392 | 36 | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1393 | 36 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1394 | 36 | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1395 | | | 1396 | 36 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1397 | | | 1398 | 36 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1399 | 6 | { | 1400 | 6 | char buffer[256 + 1]; | 1401 | 6 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1402 | | | 1403 | | /* | 1404 | | The debug entry doesn't have to have to be in a section, in which | 1405 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1406 | | */ | 1407 | 6 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1408 | 6 | (file_ptr) idd.PointerToRawData, | 1409 | 6 | idd.SizeOfData, cvinfo, NULL)) | 1410 | 0 | { | 1411 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1412 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1413 | 0 | if (build_id) | 1414 | 0 | { | 1415 | 0 | build_id->size = cvinfo->SignatureLength; | 1416 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1417 | 0 | cvinfo->SignatureLength); | 1418 | 0 | abfd->build_id = build_id; | 1419 | 0 | } | 1420 | 0 | } | 1421 | 6 | break; | 1422 | 6 | } | 1423 | 36 | } | 1424 | | | 1425 | 7 | free (data); | 1426 | 7 | } |
pei-loongarch64.c:pe_bfd_read_buildid Line | Count | Source | 1340 | 158 | { | 1341 | 158 | pe_data_type *pe = pe_data (abfd); | 1342 | 158 | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1343 | 158 | asection *section; | 1344 | 158 | bfd_byte *data = 0; | 1345 | 158 | bfd_size_type dataoff; | 1346 | 158 | unsigned int i; | 1347 | 158 | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1348 | 158 | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1349 | | | 1350 | 158 | if (size == 0) | 1351 | 109 | return; | 1352 | | | 1353 | 49 | addr += extra->ImageBase; | 1354 | | | 1355 | | /* Search for the section containing the DebugDirectory. */ | 1356 | 261 | for (section = abfd->sections; section != NULL; section = section->next) | 1357 | 224 | { | 1358 | 224 | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1359 | 12 | break; | 1360 | 224 | } | 1361 | | | 1362 | 49 | if (section == NULL) | 1363 | 37 | return; | 1364 | | | 1365 | 12 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1366 | 1 | return; | 1367 | | | 1368 | 11 | dataoff = addr - section->vma; | 1369 | | | 1370 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1371 | | Note - since we are dealing with unsigned quantities we have | 1372 | | to be careful to check for potential overflows. */ | 1373 | 11 | if (dataoff >= section->size | 1374 | 11 | || size > section->size - dataoff) | 1375 | 3 | { | 1376 | 3 | _bfd_error_handler | 1377 | 3 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1378 | 3 | abfd); | 1379 | 3 | return; | 1380 | 3 | } | 1381 | | | 1382 | | /* Read the whole section. */ | 1383 | 8 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1384 | 8 | { | 1385 | 8 | free (data); | 1386 | 8 | return; | 1387 | 8 | } | 1388 | | | 1389 | | /* Search for a CodeView entry in the DebugDirectory */ | 1390 | 0 | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1391 | 0 | { | 1392 | 0 | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1393 | 0 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1394 | 0 | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1395 | |
| 1396 | 0 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1397 | |
| 1398 | 0 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1399 | 0 | { | 1400 | 0 | char buffer[256 + 1]; | 1401 | 0 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1402 | | | 1403 | | /* | 1404 | | The debug entry doesn't have to have to be in a section, in which | 1405 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1406 | | */ | 1407 | 0 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1408 | 0 | (file_ptr) idd.PointerToRawData, | 1409 | 0 | idd.SizeOfData, cvinfo, NULL)) | 1410 | 0 | { | 1411 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1412 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1413 | 0 | if (build_id) | 1414 | 0 | { | 1415 | 0 | build_id->size = cvinfo->SignatureLength; | 1416 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1417 | 0 | cvinfo->SignatureLength); | 1418 | 0 | abfd->build_id = build_id; | 1419 | 0 | } | 1420 | 0 | } | 1421 | 0 | break; | 1422 | 0 | } | 1423 | 0 | } | 1424 | |
| 1425 | 0 | free (data); | 1426 | 0 | } |
pei-arm-wince.c:pe_bfd_read_buildid Line | Count | Source | 1340 | 124 | { | 1341 | 124 | pe_data_type *pe = pe_data (abfd); | 1342 | 124 | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1343 | 124 | asection *section; | 1344 | 124 | bfd_byte *data = 0; | 1345 | 124 | bfd_size_type dataoff; | 1346 | 124 | unsigned int i; | 1347 | 124 | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1348 | 124 | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1349 | | | 1350 | 124 | if (size == 0) | 1351 | 46 | return; | 1352 | | | 1353 | 78 | addr += extra->ImageBase; | 1354 | | | 1355 | | /* Search for the section containing the DebugDirectory. */ | 1356 | 222 | for (section = abfd->sections; section != NULL; section = section->next) | 1357 | 191 | { | 1358 | 191 | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1359 | 47 | break; | 1360 | 191 | } | 1361 | | | 1362 | 78 | if (section == NULL) | 1363 | 31 | return; | 1364 | | | 1365 | 47 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1366 | 4 | return; | 1367 | | | 1368 | 43 | dataoff = addr - section->vma; | 1369 | | | 1370 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1371 | | Note - since we are dealing with unsigned quantities we have | 1372 | | to be careful to check for potential overflows. */ | 1373 | 43 | if (dataoff >= section->size | 1374 | 43 | || size > section->size - dataoff) | 1375 | 4 | { | 1376 | 4 | _bfd_error_handler | 1377 | 4 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1378 | 4 | abfd); | 1379 | 4 | return; | 1380 | 4 | } | 1381 | | | 1382 | | /* Read the whole section. */ | 1383 | 39 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1384 | 34 | { | 1385 | 34 | free (data); | 1386 | 34 | return; | 1387 | 34 | } | 1388 | | | 1389 | | /* Search for a CodeView entry in the DebugDirectory */ | 1390 | 16 | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1391 | 13 | { | 1392 | 13 | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1393 | 13 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1394 | 13 | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1395 | | | 1396 | 13 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1397 | | | 1398 | 13 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1399 | 2 | { | 1400 | 2 | char buffer[256 + 1]; | 1401 | 2 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1402 | | | 1403 | | /* | 1404 | | The debug entry doesn't have to have to be in a section, in which | 1405 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1406 | | */ | 1407 | 2 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1408 | 2 | (file_ptr) idd.PointerToRawData, | 1409 | 2 | idd.SizeOfData, cvinfo, NULL)) | 1410 | 0 | { | 1411 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1412 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1413 | 0 | if (build_id) | 1414 | 0 | { | 1415 | 0 | build_id->size = cvinfo->SignatureLength; | 1416 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1417 | 0 | cvinfo->SignatureLength); | 1418 | 0 | abfd->build_id = build_id; | 1419 | 0 | } | 1420 | 0 | } | 1421 | 2 | break; | 1422 | 2 | } | 1423 | 13 | } | 1424 | | | 1425 | 5 | free (data); | 1426 | 5 | } |
pei-arm.c:pe_bfd_read_buildid Line | Count | Source | 1340 | 181 | { | 1341 | 181 | pe_data_type *pe = pe_data (abfd); | 1342 | 181 | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1343 | 181 | asection *section; | 1344 | 181 | bfd_byte *data = 0; | 1345 | 181 | bfd_size_type dataoff; | 1346 | 181 | unsigned int i; | 1347 | 181 | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1348 | 181 | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1349 | | | 1350 | 181 | if (size == 0) | 1351 | 84 | return; | 1352 | | | 1353 | 97 | addr += extra->ImageBase; | 1354 | | | 1355 | | /* Search for the section containing the DebugDirectory. */ | 1356 | 221 | for (section = abfd->sections; section != NULL; section = section->next) | 1357 | 169 | { | 1358 | 169 | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1359 | 45 | break; | 1360 | 169 | } | 1361 | | | 1362 | 97 | if (section == NULL) | 1363 | 52 | return; | 1364 | | | 1365 | 45 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1366 | 2 | return; | 1367 | | | 1368 | 43 | dataoff = addr - section->vma; | 1369 | | | 1370 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1371 | | Note - since we are dealing with unsigned quantities we have | 1372 | | to be careful to check for potential overflows. */ | 1373 | 43 | if (dataoff >= section->size | 1374 | 43 | || size > section->size - dataoff) | 1375 | 10 | { | 1376 | 10 | _bfd_error_handler | 1377 | 10 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1378 | 10 | abfd); | 1379 | 10 | return; | 1380 | 10 | } | 1381 | | | 1382 | | /* Read the whole section. */ | 1383 | 33 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1384 | 26 | { | 1385 | 26 | free (data); | 1386 | 26 | return; | 1387 | 26 | } | 1388 | | | 1389 | | /* Search for a CodeView entry in the DebugDirectory */ | 1390 | 36 | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1391 | 32 | { | 1392 | 32 | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1393 | 32 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1394 | 32 | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1395 | | | 1396 | 32 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1397 | | | 1398 | 32 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1399 | 3 | { | 1400 | 3 | char buffer[256 + 1]; | 1401 | 3 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1402 | | | 1403 | | /* | 1404 | | The debug entry doesn't have to have to be in a section, in which | 1405 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1406 | | */ | 1407 | 3 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1408 | 3 | (file_ptr) idd.PointerToRawData, | 1409 | 3 | idd.SizeOfData, cvinfo, NULL)) | 1410 | 2 | { | 1411 | 2 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1412 | 2 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1413 | 2 | if (build_id) | 1414 | 2 | { | 1415 | 2 | build_id->size = cvinfo->SignatureLength; | 1416 | 2 | memcpy(build_id->data, cvinfo->Signature, | 1417 | 2 | cvinfo->SignatureLength); | 1418 | 2 | abfd->build_id = build_id; | 1419 | 2 | } | 1420 | 2 | } | 1421 | 3 | break; | 1422 | 3 | } | 1423 | 32 | } | 1424 | | | 1425 | 7 | free (data); | 1426 | 7 | } |
pei-mcore.c:pe_bfd_read_buildid Line | Count | Source | 1340 | 143 | { | 1341 | 143 | pe_data_type *pe = pe_data (abfd); | 1342 | 143 | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1343 | 143 | asection *section; | 1344 | 143 | bfd_byte *data = 0; | 1345 | 143 | bfd_size_type dataoff; | 1346 | 143 | unsigned int i; | 1347 | 143 | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1348 | 143 | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1349 | | | 1350 | 143 | if (size == 0) | 1351 | 89 | return; | 1352 | | | 1353 | 54 | addr += extra->ImageBase; | 1354 | | | 1355 | | /* Search for the section containing the DebugDirectory. */ | 1356 | 383 | for (section = abfd->sections; section != NULL; section = section->next) | 1357 | 354 | { | 1358 | 354 | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1359 | 25 | break; | 1360 | 354 | } | 1361 | | | 1362 | 54 | if (section == NULL) | 1363 | 29 | return; | 1364 | | | 1365 | 25 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1366 | 2 | return; | 1367 | | | 1368 | 23 | dataoff = addr - section->vma; | 1369 | | | 1370 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1371 | | Note - since we are dealing with unsigned quantities we have | 1372 | | to be careful to check for potential overflows. */ | 1373 | 23 | if (dataoff >= section->size | 1374 | 23 | || size > section->size - dataoff) | 1375 | 14 | { | 1376 | 14 | _bfd_error_handler | 1377 | 14 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1378 | 14 | abfd); | 1379 | 14 | return; | 1380 | 14 | } | 1381 | | | 1382 | | /* Read the whole section. */ | 1383 | 9 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1384 | 4 | { | 1385 | 4 | free (data); | 1386 | 4 | return; | 1387 | 4 | } | 1388 | | | 1389 | | /* Search for a CodeView entry in the DebugDirectory */ | 1390 | 25 | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1391 | 24 | { | 1392 | 24 | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1393 | 24 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1394 | 24 | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1395 | | | 1396 | 24 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1397 | | | 1398 | 24 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1399 | 4 | { | 1400 | 4 | char buffer[256 + 1]; | 1401 | 4 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1402 | | | 1403 | | /* | 1404 | | The debug entry doesn't have to have to be in a section, in which | 1405 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1406 | | */ | 1407 | 4 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1408 | 4 | (file_ptr) idd.PointerToRawData, | 1409 | 4 | idd.SizeOfData, cvinfo, NULL)) | 1410 | 0 | { | 1411 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1412 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1413 | 0 | if (build_id) | 1414 | 0 | { | 1415 | 0 | build_id->size = cvinfo->SignatureLength; | 1416 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1417 | 0 | cvinfo->SignatureLength); | 1418 | 0 | abfd->build_id = build_id; | 1419 | 0 | } | 1420 | 0 | } | 1421 | 4 | break; | 1422 | 4 | } | 1423 | 24 | } | 1424 | | | 1425 | 5 | free (data); | 1426 | 5 | } |
pei-sh.c:pe_bfd_read_buildid Line | Count | Source | 1340 | 144 | { | 1341 | 144 | pe_data_type *pe = pe_data (abfd); | 1342 | 144 | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1343 | 144 | asection *section; | 1344 | 144 | bfd_byte *data = 0; | 1345 | 144 | bfd_size_type dataoff; | 1346 | 144 | unsigned int i; | 1347 | 144 | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1348 | 144 | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1349 | | | 1350 | 144 | if (size == 0) | 1351 | 81 | return; | 1352 | | | 1353 | 63 | addr += extra->ImageBase; | 1354 | | | 1355 | | /* Search for the section containing the DebugDirectory. */ | 1356 | 400 | for (section = abfd->sections; section != NULL; section = section->next) | 1357 | 370 | { | 1358 | 370 | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1359 | 33 | break; | 1360 | 370 | } | 1361 | | | 1362 | 63 | if (section == NULL) | 1363 | 30 | return; | 1364 | | | 1365 | 33 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1366 | 20 | return; | 1367 | | | 1368 | 13 | dataoff = addr - section->vma; | 1369 | | | 1370 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1371 | | Note - since we are dealing with unsigned quantities we have | 1372 | | to be careful to check for potential overflows. */ | 1373 | 13 | if (dataoff >= section->size | 1374 | 13 | || size > section->size - dataoff) | 1375 | 2 | { | 1376 | 2 | _bfd_error_handler | 1377 | 2 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1378 | 2 | abfd); | 1379 | 2 | return; | 1380 | 2 | } | 1381 | | | 1382 | | /* Read the whole section. */ | 1383 | 11 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1384 | 8 | { | 1385 | 8 | free (data); | 1386 | 8 | return; | 1387 | 8 | } | 1388 | | | 1389 | | /* Search for a CodeView entry in the DebugDirectory */ | 1390 | 11 | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1391 | 9 | { | 1392 | 9 | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1393 | 9 | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1394 | 9 | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1395 | | | 1396 | 9 | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1397 | | | 1398 | 9 | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1399 | 1 | { | 1400 | 1 | char buffer[256 + 1]; | 1401 | 1 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1402 | | | 1403 | | /* | 1404 | | The debug entry doesn't have to have to be in a section, in which | 1405 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1406 | | */ | 1407 | 1 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1408 | 1 | (file_ptr) idd.PointerToRawData, | 1409 | 1 | idd.SizeOfData, cvinfo, NULL)) | 1410 | 0 | { | 1411 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1412 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1413 | 0 | if (build_id) | 1414 | 0 | { | 1415 | 0 | build_id->size = cvinfo->SignatureLength; | 1416 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1417 | 0 | cvinfo->SignatureLength); | 1418 | 0 | abfd->build_id = build_id; | 1419 | 0 | } | 1420 | 0 | } | 1421 | 1 | break; | 1422 | 1 | } | 1423 | 9 | } | 1424 | | | 1425 | 3 | free (data); | 1426 | 3 | } |
|
1427 | | |
1428 | | static bfd_cleanup |
1429 | | pe_bfd_object_p (bfd * abfd) |
1430 | 161k | { |
1431 | 161k | bfd_byte buffer[6]; |
1432 | 161k | struct external_DOS_hdr dos_hdr; |
1433 | 161k | struct external_PEI_IMAGE_hdr image_hdr; |
1434 | 161k | struct internal_filehdr internal_f; |
1435 | 161k | struct internal_aouthdr internal_a; |
1436 | 161k | bfd_size_type opt_hdr_size; |
1437 | 161k | file_ptr offset; |
1438 | 161k | bfd_cleanup result; |
1439 | | |
1440 | | /* Detect if this a Microsoft Import Library Format element. */ |
1441 | | /* First read the beginning of the header. */ |
1442 | 161k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 |
1443 | 161k | || bfd_read (buffer, 6, abfd) != 6) |
1444 | 1.43k | { |
1445 | 1.43k | if (bfd_get_error () != bfd_error_system_call) |
1446 | 1.40k | bfd_set_error (bfd_error_wrong_format); |
1447 | 1.43k | return NULL; |
1448 | 1.43k | } |
1449 | | |
1450 | | /* Then check the magic and the version (only 0 is supported). */ |
1451 | 159k | if (H_GET_32 (abfd, buffer) == 0xffff0000 |
1452 | 159k | && H_GET_16 (abfd, buffer + 4) == 0) |
1453 | 1.78k | return pe_ILF_object_p (abfd); |
1454 | | |
1455 | 158k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 |
1456 | 158k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) |
1457 | 53.9k | { |
1458 | 53.9k | if (bfd_get_error () != bfd_error_system_call) |
1459 | 53.9k | bfd_set_error (bfd_error_wrong_format); |
1460 | 53.9k | return NULL; |
1461 | 53.9k | } |
1462 | | |
1463 | | /* There are really two magic numbers involved; the magic number |
1464 | | that says this is a NT executable (PEI) and the magic number that |
1465 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in |
1466 | | the e_magic field. The latter is stored in the f_magic field. |
1467 | | If the NT magic number isn't valid, the architecture magic number |
1468 | | could be mimicked by some other field (specifically, the number |
1469 | | of relocs in section 3). Since this routine can only be called |
1470 | | correctly for a PEI file, check the e_magic number here, and, if |
1471 | | it doesn't match, clobber the f_magic number so that we don't get |
1472 | | a false match. */ |
1473 | 104k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) |
1474 | 84.7k | { |
1475 | 84.7k | bfd_set_error (bfd_error_wrong_format); |
1476 | 84.7k | return NULL; |
1477 | 84.7k | } |
1478 | | |
1479 | 19.5k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); |
1480 | 19.5k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 |
1481 | 19.5k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) |
1482 | 35 | { |
1483 | 35 | if (bfd_get_error () != bfd_error_system_call) |
1484 | 35 | bfd_set_error (bfd_error_wrong_format); |
1485 | 35 | return NULL; |
1486 | 35 | } |
1487 | | |
1488 | 19.4k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) |
1489 | 481 | { |
1490 | 481 | bfd_set_error (bfd_error_wrong_format); |
1491 | 481 | return NULL; |
1492 | 481 | } |
1493 | | |
1494 | | /* Swap file header, so that we get the location for calling |
1495 | | real_object_p. */ |
1496 | 18.9k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); |
1497 | | |
1498 | 18.9k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) |
1499 | 18.9k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) |
1500 | 16.1k | { |
1501 | 16.1k | bfd_set_error (bfd_error_wrong_format); |
1502 | 16.1k | return NULL; |
1503 | 16.1k | } |
1504 | | |
1505 | 2.81k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, |
1506 | 2.81k | sizeof (internal_f.pe.dos_message)); |
1507 | | |
1508 | | /* Read the optional header, which has variable size. */ |
1509 | 2.81k | opt_hdr_size = internal_f.f_opthdr; |
1510 | | |
1511 | 2.81k | if (opt_hdr_size != 0) |
1512 | 2.25k | { |
1513 | 2.25k | bfd_size_type amt = opt_hdr_size; |
1514 | 2.25k | bfd_byte * opthdr; |
1515 | | |
1516 | | /* PR 17521 file: 230-131433-0.004. */ |
1517 | 2.25k | if (amt < sizeof (PEAOUTHDR)) |
1518 | 1.65k | amt = sizeof (PEAOUTHDR); |
1519 | | |
1520 | 2.25k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); |
1521 | 2.25k | if (opthdr == NULL) |
1522 | 29 | return NULL; |
1523 | 2.22k | if (amt > opt_hdr_size) |
1524 | 1.63k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); |
1525 | | |
1526 | 2.22k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); |
1527 | | |
1528 | 2.22k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; |
1529 | | |
1530 | | #ifdef ARM |
1531 | | /* Use Subsystem to distinguish between pei-arm-little and |
1532 | | pei-arm-wince-little. */ |
1533 | | #ifdef WINCE |
1534 | 335 | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) |
1535 | | #else |
1536 | 335 | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) |
1537 | 120 | #endif |
1538 | 335 | { |
1539 | 335 | bfd_set_error (bfd_error_wrong_format); |
1540 | 335 | return NULL; |
1541 | 335 | } |
1542 | 335 | #endif |
1543 | | |
1544 | 1.89k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment |
1545 | 1.89k | || a->SectionAlignment >= 0x80000000) |
1546 | 1.19k | { |
1547 | 1.19k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), |
1548 | 1.19k | abfd); |
1549 | 1.19k | a->SectionAlignment &= -a->SectionAlignment; |
1550 | 1.19k | if (a->SectionAlignment >= 0x80000000) |
1551 | 14 | a->SectionAlignment = 0x40000000; |
1552 | 1.19k | } |
1553 | | |
1554 | 1.89k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment |
1555 | 1.89k | || a->FileAlignment > a->SectionAlignment) |
1556 | 1.13k | { |
1557 | 1.13k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), |
1558 | 1.13k | abfd); |
1559 | 1.13k | a->FileAlignment &= -a->FileAlignment; |
1560 | 1.13k | if (a->FileAlignment > a->SectionAlignment) |
1561 | 576 | a->FileAlignment = a->SectionAlignment; |
1562 | 1.13k | } |
1563 | | |
1564 | 1.89k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) |
1565 | 1.10k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); |
1566 | 335 | } |
1567 | | |
1568 | 2.45k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, |
1569 | 2.45k | (opt_hdr_size != 0 |
1570 | 2.45k | ? &internal_a |
1571 | 2.45k | : (struct internal_aouthdr *) NULL)); |
1572 | | |
1573 | 2.45k | if (result) |
1574 | 1.73k | { |
1575 | | /* Now the whole header has been processed, see if there is a build-id */ |
1576 | 1.73k | pe_bfd_read_buildid(abfd); |
1577 | 1.73k | } |
1578 | | |
1579 | 2.45k | return result; |
1580 | 2.81k | } pei-i386.c:pe_bfd_object_p Line | Count | Source | 1430 | 14.6k | { | 1431 | 14.6k | bfd_byte buffer[6]; | 1432 | 14.6k | struct external_DOS_hdr dos_hdr; | 1433 | 14.6k | struct external_PEI_IMAGE_hdr image_hdr; | 1434 | 14.6k | struct internal_filehdr internal_f; | 1435 | 14.6k | struct internal_aouthdr internal_a; | 1436 | 14.6k | bfd_size_type opt_hdr_size; | 1437 | 14.6k | file_ptr offset; | 1438 | 14.6k | bfd_cleanup result; | 1439 | | | 1440 | | /* Detect if this a Microsoft Import Library Format element. */ | 1441 | | /* First read the beginning of the header. */ | 1442 | 14.6k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1443 | 14.6k | || bfd_read (buffer, 6, abfd) != 6) | 1444 | 130 | { | 1445 | 130 | if (bfd_get_error () != bfd_error_system_call) | 1446 | 128 | bfd_set_error (bfd_error_wrong_format); | 1447 | 130 | return NULL; | 1448 | 130 | } | 1449 | | | 1450 | | /* Then check the magic and the version (only 0 is supported). */ | 1451 | 14.4k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1452 | 14.4k | && H_GET_16 (abfd, buffer + 4) == 0) | 1453 | 211 | return pe_ILF_object_p (abfd); | 1454 | | | 1455 | 14.2k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1456 | 14.2k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1457 | 4.86k | { | 1458 | 4.86k | if (bfd_get_error () != bfd_error_system_call) | 1459 | 4.86k | bfd_set_error (bfd_error_wrong_format); | 1460 | 4.86k | return NULL; | 1461 | 4.86k | } | 1462 | | | 1463 | | /* There are really two magic numbers involved; the magic number | 1464 | | that says this is a NT executable (PEI) and the magic number that | 1465 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1466 | | the e_magic field. The latter is stored in the f_magic field. | 1467 | | If the NT magic number isn't valid, the architecture magic number | 1468 | | could be mimicked by some other field (specifically, the number | 1469 | | of relocs in section 3). Since this routine can only be called | 1470 | | correctly for a PEI file, check the e_magic number here, and, if | 1471 | | it doesn't match, clobber the f_magic number so that we don't get | 1472 | | a false match. */ | 1473 | 9.40k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1474 | 7.14k | { | 1475 | 7.14k | bfd_set_error (bfd_error_wrong_format); | 1476 | 7.14k | return NULL; | 1477 | 7.14k | } | 1478 | | | 1479 | 2.26k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1480 | 2.26k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1481 | 2.26k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1482 | 4 | { | 1483 | 4 | if (bfd_get_error () != bfd_error_system_call) | 1484 | 4 | bfd_set_error (bfd_error_wrong_format); | 1485 | 4 | return NULL; | 1486 | 4 | } | 1487 | | | 1488 | 2.25k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1489 | 32 | { | 1490 | 32 | bfd_set_error (bfd_error_wrong_format); | 1491 | 32 | return NULL; | 1492 | 32 | } | 1493 | | | 1494 | | /* Swap file header, so that we get the location for calling | 1495 | | real_object_p. */ | 1496 | 2.22k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1497 | | | 1498 | 2.22k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1499 | 2.22k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1500 | 1.87k | { | 1501 | 1.87k | bfd_set_error (bfd_error_wrong_format); | 1502 | 1.87k | return NULL; | 1503 | 1.87k | } | 1504 | | | 1505 | 355 | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1506 | 355 | sizeof (internal_f.pe.dos_message)); | 1507 | | | 1508 | | /* Read the optional header, which has variable size. */ | 1509 | 355 | opt_hdr_size = internal_f.f_opthdr; | 1510 | | | 1511 | 355 | if (opt_hdr_size != 0) | 1512 | 330 | { | 1513 | 330 | bfd_size_type amt = opt_hdr_size; | 1514 | 330 | bfd_byte * opthdr; | 1515 | | | 1516 | | /* PR 17521 file: 230-131433-0.004. */ | 1517 | 330 | if (amt < sizeof (PEAOUTHDR)) | 1518 | 193 | amt = sizeof (PEAOUTHDR); | 1519 | | | 1520 | 330 | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1521 | 330 | if (opthdr == NULL) | 1522 | 2 | return NULL; | 1523 | 328 | if (amt > opt_hdr_size) | 1524 | 191 | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1525 | | | 1526 | 328 | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1527 | | | 1528 | 328 | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1529 | | | 1530 | | #ifdef ARM | 1531 | | /* Use Subsystem to distinguish between pei-arm-little and | 1532 | | pei-arm-wince-little. */ | 1533 | | #ifdef WINCE | 1534 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1535 | | #else | 1536 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1537 | | #endif | 1538 | | { | 1539 | | bfd_set_error (bfd_error_wrong_format); | 1540 | | return NULL; | 1541 | | } | 1542 | | #endif | 1543 | | | 1544 | 328 | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1545 | 328 | || a->SectionAlignment >= 0x80000000) | 1546 | 170 | { | 1547 | 170 | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1548 | 170 | abfd); | 1549 | 170 | a->SectionAlignment &= -a->SectionAlignment; | 1550 | 170 | if (a->SectionAlignment >= 0x80000000) | 1551 | 2 | a->SectionAlignment = 0x40000000; | 1552 | 170 | } | 1553 | | | 1554 | 328 | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1555 | 328 | || a->FileAlignment > a->SectionAlignment) | 1556 | 176 | { | 1557 | 176 | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1558 | 176 | abfd); | 1559 | 176 | a->FileAlignment &= -a->FileAlignment; | 1560 | 176 | if (a->FileAlignment > a->SectionAlignment) | 1561 | 100 | a->FileAlignment = a->SectionAlignment; | 1562 | 176 | } | 1563 | | | 1564 | 328 | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1565 | 160 | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1566 | 328 | } | 1567 | | | 1568 | 353 | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1569 | 353 | (opt_hdr_size != 0 | 1570 | 353 | ? &internal_a | 1571 | 353 | : (struct internal_aouthdr *) NULL)); | 1572 | | | 1573 | 353 | if (result) | 1574 | 281 | { | 1575 | | /* Now the whole header has been processed, see if there is a build-id */ | 1576 | 281 | pe_bfd_read_buildid(abfd); | 1577 | 281 | } | 1578 | | | 1579 | 353 | return result; | 1580 | 355 | } |
pei-x86_64.c:pe_bfd_object_p Line | Count | Source | 1430 | 14.6k | { | 1431 | 14.6k | bfd_byte buffer[6]; | 1432 | 14.6k | struct external_DOS_hdr dos_hdr; | 1433 | 14.6k | struct external_PEI_IMAGE_hdr image_hdr; | 1434 | 14.6k | struct internal_filehdr internal_f; | 1435 | 14.6k | struct internal_aouthdr internal_a; | 1436 | 14.6k | bfd_size_type opt_hdr_size; | 1437 | 14.6k | file_ptr offset; | 1438 | 14.6k | bfd_cleanup result; | 1439 | | | 1440 | | /* Detect if this a Microsoft Import Library Format element. */ | 1441 | | /* First read the beginning of the header. */ | 1442 | 14.6k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1443 | 14.6k | || bfd_read (buffer, 6, abfd) != 6) | 1444 | 130 | { | 1445 | 130 | if (bfd_get_error () != bfd_error_system_call) | 1446 | 128 | bfd_set_error (bfd_error_wrong_format); | 1447 | 130 | return NULL; | 1448 | 130 | } | 1449 | | | 1450 | | /* Then check the magic and the version (only 0 is supported). */ | 1451 | 14.4k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1452 | 14.4k | && H_GET_16 (abfd, buffer + 4) == 0) | 1453 | 195 | return pe_ILF_object_p (abfd); | 1454 | | | 1455 | 14.2k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1456 | 14.2k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1457 | 4.86k | { | 1458 | 4.86k | if (bfd_get_error () != bfd_error_system_call) | 1459 | 4.86k | bfd_set_error (bfd_error_wrong_format); | 1460 | 4.86k | return NULL; | 1461 | 4.86k | } | 1462 | | | 1463 | | /* There are really two magic numbers involved; the magic number | 1464 | | that says this is a NT executable (PEI) and the magic number that | 1465 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1466 | | the e_magic field. The latter is stored in the f_magic field. | 1467 | | If the NT magic number isn't valid, the architecture magic number | 1468 | | could be mimicked by some other field (specifically, the number | 1469 | | of relocs in section 3). Since this routine can only be called | 1470 | | correctly for a PEI file, check the e_magic number here, and, if | 1471 | | it doesn't match, clobber the f_magic number so that we don't get | 1472 | | a false match. */ | 1473 | 9.41k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1474 | 7.15k | { | 1475 | 7.15k | bfd_set_error (bfd_error_wrong_format); | 1476 | 7.15k | return NULL; | 1477 | 7.15k | } | 1478 | | | 1479 | 2.25k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1480 | 2.25k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1481 | 2.25k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1482 | 4 | { | 1483 | 4 | if (bfd_get_error () != bfd_error_system_call) | 1484 | 4 | bfd_set_error (bfd_error_wrong_format); | 1485 | 4 | return NULL; | 1486 | 4 | } | 1487 | | | 1488 | 2.25k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1489 | 32 | { | 1490 | 32 | bfd_set_error (bfd_error_wrong_format); | 1491 | 32 | return NULL; | 1492 | 32 | } | 1493 | | | 1494 | | /* Swap file header, so that we get the location for calling | 1495 | | real_object_p. */ | 1496 | 2.21k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1497 | | | 1498 | 2.21k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1499 | 2.21k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1500 | 1.81k | { | 1501 | 1.81k | bfd_set_error (bfd_error_wrong_format); | 1502 | 1.81k | return NULL; | 1503 | 1.81k | } | 1504 | | | 1505 | 409 | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1506 | 409 | sizeof (internal_f.pe.dos_message)); | 1507 | | | 1508 | | /* Read the optional header, which has variable size. */ | 1509 | 409 | opt_hdr_size = internal_f.f_opthdr; | 1510 | | | 1511 | 409 | if (opt_hdr_size != 0) | 1512 | 348 | { | 1513 | 348 | bfd_size_type amt = opt_hdr_size; | 1514 | 348 | bfd_byte * opthdr; | 1515 | | | 1516 | | /* PR 17521 file: 230-131433-0.004. */ | 1517 | 348 | if (amt < sizeof (PEAOUTHDR)) | 1518 | 284 | amt = sizeof (PEAOUTHDR); | 1519 | | | 1520 | 348 | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1521 | 348 | if (opthdr == NULL) | 1522 | 2 | return NULL; | 1523 | 346 | if (amt > opt_hdr_size) | 1524 | 282 | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1525 | | | 1526 | 346 | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1527 | | | 1528 | 346 | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1529 | | | 1530 | | #ifdef ARM | 1531 | | /* Use Subsystem to distinguish between pei-arm-little and | 1532 | | pei-arm-wince-little. */ | 1533 | | #ifdef WINCE | 1534 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1535 | | #else | 1536 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1537 | | #endif | 1538 | | { | 1539 | | bfd_set_error (bfd_error_wrong_format); | 1540 | | return NULL; | 1541 | | } | 1542 | | #endif | 1543 | | | 1544 | 346 | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1545 | 346 | || a->SectionAlignment >= 0x80000000) | 1546 | 300 | { | 1547 | 300 | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1548 | 300 | abfd); | 1549 | 300 | a->SectionAlignment &= -a->SectionAlignment; | 1550 | 300 | if (a->SectionAlignment >= 0x80000000) | 1551 | 3 | a->SectionAlignment = 0x40000000; | 1552 | 300 | } | 1553 | | | 1554 | 346 | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1555 | 346 | || a->FileAlignment > a->SectionAlignment) | 1556 | 265 | { | 1557 | 265 | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1558 | 265 | abfd); | 1559 | 265 | a->FileAlignment &= -a->FileAlignment; | 1560 | 265 | if (a->FileAlignment > a->SectionAlignment) | 1561 | 90 | a->FileAlignment = a->SectionAlignment; | 1562 | 265 | } | 1563 | | | 1564 | 346 | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1565 | 249 | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1566 | 346 | } | 1567 | | | 1568 | 407 | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1569 | 407 | (opt_hdr_size != 0 | 1570 | 407 | ? &internal_a | 1571 | 407 | : (struct internal_aouthdr *) NULL)); | 1572 | | | 1573 | 407 | if (result) | 1574 | 338 | { | 1575 | | /* Now the whole header has been processed, see if there is a build-id */ | 1576 | 338 | pe_bfd_read_buildid(abfd); | 1577 | 338 | } | 1578 | | | 1579 | 407 | return result; | 1580 | 409 | } |
pei-aarch64.c:pe_bfd_object_p Line | Count | Source | 1430 | 14.4k | { | 1431 | 14.4k | bfd_byte buffer[6]; | 1432 | 14.4k | struct external_DOS_hdr dos_hdr; | 1433 | 14.4k | struct external_PEI_IMAGE_hdr image_hdr; | 1434 | 14.4k | struct internal_filehdr internal_f; | 1435 | 14.4k | struct internal_aouthdr internal_a; | 1436 | 14.4k | bfd_size_type opt_hdr_size; | 1437 | 14.4k | file_ptr offset; | 1438 | 14.4k | bfd_cleanup result; | 1439 | | | 1440 | | /* Detect if this a Microsoft Import Library Format element. */ | 1441 | | /* First read the beginning of the header. */ | 1442 | 14.4k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1443 | 14.4k | || bfd_read (buffer, 6, abfd) != 6) | 1444 | 130 | { | 1445 | 130 | if (bfd_get_error () != bfd_error_system_call) | 1446 | 128 | bfd_set_error (bfd_error_wrong_format); | 1447 | 130 | return NULL; | 1448 | 130 | } | 1449 | | | 1450 | | /* Then check the magic and the version (only 0 is supported). */ | 1451 | 14.3k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1452 | 14.3k | && H_GET_16 (abfd, buffer + 4) == 0) | 1453 | 219 | return pe_ILF_object_p (abfd); | 1454 | | | 1455 | 14.1k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1456 | 14.1k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1457 | 4.86k | { | 1458 | 4.86k | if (bfd_get_error () != bfd_error_system_call) | 1459 | 4.86k | bfd_set_error (bfd_error_wrong_format); | 1460 | 4.86k | return NULL; | 1461 | 4.86k | } | 1462 | | | 1463 | | /* There are really two magic numbers involved; the magic number | 1464 | | that says this is a NT executable (PEI) and the magic number that | 1465 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1466 | | the e_magic field. The latter is stored in the f_magic field. | 1467 | | If the NT magic number isn't valid, the architecture magic number | 1468 | | could be mimicked by some other field (specifically, the number | 1469 | | of relocs in section 3). Since this routine can only be called | 1470 | | correctly for a PEI file, check the e_magic number here, and, if | 1471 | | it doesn't match, clobber the f_magic number so that we don't get | 1472 | | a false match. */ | 1473 | 9.27k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1474 | 7.05k | { | 1475 | 7.05k | bfd_set_error (bfd_error_wrong_format); | 1476 | 7.05k | return NULL; | 1477 | 7.05k | } | 1478 | | | 1479 | 2.21k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1480 | 2.21k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1481 | 2.21k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1482 | 5 | { | 1483 | 5 | if (bfd_get_error () != bfd_error_system_call) | 1484 | 5 | bfd_set_error (bfd_error_wrong_format); | 1485 | 5 | return NULL; | 1486 | 5 | } | 1487 | | | 1488 | 2.21k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1489 | 107 | { | 1490 | 107 | bfd_set_error (bfd_error_wrong_format); | 1491 | 107 | return NULL; | 1492 | 107 | } | 1493 | | | 1494 | | /* Swap file header, so that we get the location for calling | 1495 | | real_object_p. */ | 1496 | 2.10k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1497 | | | 1498 | 2.10k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1499 | 2.10k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1500 | 1.87k | { | 1501 | 1.87k | bfd_set_error (bfd_error_wrong_format); | 1502 | 1.87k | return NULL; | 1503 | 1.87k | } | 1504 | | | 1505 | 231 | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1506 | 231 | sizeof (internal_f.pe.dos_message)); | 1507 | | | 1508 | | /* Read the optional header, which has variable size. */ | 1509 | 231 | opt_hdr_size = internal_f.f_opthdr; | 1510 | | | 1511 | 231 | if (opt_hdr_size != 0) | 1512 | 186 | { | 1513 | 186 | bfd_size_type amt = opt_hdr_size; | 1514 | 186 | bfd_byte * opthdr; | 1515 | | | 1516 | | /* PR 17521 file: 230-131433-0.004. */ | 1517 | 186 | if (amt < sizeof (PEAOUTHDR)) | 1518 | 47 | amt = sizeof (PEAOUTHDR); | 1519 | | | 1520 | 186 | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1521 | 186 | if (opthdr == NULL) | 1522 | 3 | return NULL; | 1523 | 183 | if (amt > opt_hdr_size) | 1524 | 45 | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1525 | | | 1526 | 183 | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1527 | | | 1528 | 183 | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1529 | | | 1530 | | #ifdef ARM | 1531 | | /* Use Subsystem to distinguish between pei-arm-little and | 1532 | | pei-arm-wince-little. */ | 1533 | | #ifdef WINCE | 1534 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1535 | | #else | 1536 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1537 | | #endif | 1538 | | { | 1539 | | bfd_set_error (bfd_error_wrong_format); | 1540 | | return NULL; | 1541 | | } | 1542 | | #endif | 1543 | | | 1544 | 183 | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1545 | 183 | || a->SectionAlignment >= 0x80000000) | 1546 | 127 | { | 1547 | 127 | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1548 | 127 | abfd); | 1549 | 127 | a->SectionAlignment &= -a->SectionAlignment; | 1550 | 127 | if (a->SectionAlignment >= 0x80000000) | 1551 | 1 | a->SectionAlignment = 0x40000000; | 1552 | 127 | } | 1553 | | | 1554 | 183 | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1555 | 183 | || a->FileAlignment > a->SectionAlignment) | 1556 | 147 | { | 1557 | 147 | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1558 | 147 | abfd); | 1559 | 147 | a->FileAlignment &= -a->FileAlignment; | 1560 | 147 | if (a->FileAlignment > a->SectionAlignment) | 1561 | 128 | a->FileAlignment = a->SectionAlignment; | 1562 | 147 | } | 1563 | | | 1564 | 183 | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1565 | 124 | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1566 | 183 | } | 1567 | | | 1568 | 228 | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1569 | 228 | (opt_hdr_size != 0 | 1570 | 228 | ? &internal_a | 1571 | 228 | : (struct internal_aouthdr *) NULL)); | 1572 | | | 1573 | 228 | if (result) | 1574 | 159 | { | 1575 | | /* Now the whole header has been processed, see if there is a build-id */ | 1576 | 159 | pe_bfd_read_buildid(abfd); | 1577 | 159 | } | 1578 | | | 1579 | 228 | return result; | 1580 | 231 | } |
pei-ia64.c:pe_bfd_object_p Line | Count | Source | 1430 | 1.68k | { | 1431 | 1.68k | bfd_byte buffer[6]; | 1432 | 1.68k | struct external_DOS_hdr dos_hdr; | 1433 | 1.68k | struct external_PEI_IMAGE_hdr image_hdr; | 1434 | 1.68k | struct internal_filehdr internal_f; | 1435 | 1.68k | struct internal_aouthdr internal_a; | 1436 | 1.68k | bfd_size_type opt_hdr_size; | 1437 | 1.68k | file_ptr offset; | 1438 | 1.68k | bfd_cleanup result; | 1439 | | | 1440 | | /* Detect if this a Microsoft Import Library Format element. */ | 1441 | | /* First read the beginning of the header. */ | 1442 | 1.68k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1443 | 1.68k | || bfd_read (buffer, 6, abfd) != 6) | 1444 | 0 | { | 1445 | 0 | if (bfd_get_error () != bfd_error_system_call) | 1446 | 0 | bfd_set_error (bfd_error_wrong_format); | 1447 | 0 | return NULL; | 1448 | 0 | } | 1449 | | | 1450 | | /* Then check the magic and the version (only 0 is supported). */ | 1451 | 1.68k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1452 | 1.68k | && H_GET_16 (abfd, buffer + 4) == 0) | 1453 | 0 | return pe_ILF_object_p (abfd); | 1454 | | | 1455 | 1.68k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1456 | 1.68k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1457 | 0 | { | 1458 | 0 | if (bfd_get_error () != bfd_error_system_call) | 1459 | 0 | bfd_set_error (bfd_error_wrong_format); | 1460 | 0 | return NULL; | 1461 | 0 | } | 1462 | | | 1463 | | /* There are really two magic numbers involved; the magic number | 1464 | | that says this is a NT executable (PEI) and the magic number that | 1465 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1466 | | the e_magic field. The latter is stored in the f_magic field. | 1467 | | If the NT magic number isn't valid, the architecture magic number | 1468 | | could be mimicked by some other field (specifically, the number | 1469 | | of relocs in section 3). Since this routine can only be called | 1470 | | correctly for a PEI file, check the e_magic number here, and, if | 1471 | | it doesn't match, clobber the f_magic number so that we don't get | 1472 | | a false match. */ | 1473 | 1.68k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1474 | 0 | { | 1475 | 0 | bfd_set_error (bfd_error_wrong_format); | 1476 | 0 | return NULL; | 1477 | 0 | } | 1478 | | | 1479 | 1.68k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1480 | 1.68k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1481 | 1.68k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1482 | 0 | { | 1483 | 0 | if (bfd_get_error () != bfd_error_system_call) | 1484 | 0 | bfd_set_error (bfd_error_wrong_format); | 1485 | 0 | return NULL; | 1486 | 0 | } | 1487 | | | 1488 | 1.68k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1489 | 0 | { | 1490 | 0 | bfd_set_error (bfd_error_wrong_format); | 1491 | 0 | return NULL; | 1492 | 0 | } | 1493 | | | 1494 | | /* Swap file header, so that we get the location for calling | 1495 | | real_object_p. */ | 1496 | 1.68k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1497 | | | 1498 | 1.68k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1499 | 1.68k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1500 | 1.40k | { | 1501 | 1.40k | bfd_set_error (bfd_error_wrong_format); | 1502 | 1.40k | return NULL; | 1503 | 1.40k | } | 1504 | | | 1505 | 279 | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1506 | 279 | sizeof (internal_f.pe.dos_message)); | 1507 | | | 1508 | | /* Read the optional header, which has variable size. */ | 1509 | 279 | opt_hdr_size = internal_f.f_opthdr; | 1510 | | | 1511 | 279 | if (opt_hdr_size != 0) | 1512 | 213 | { | 1513 | 213 | bfd_size_type amt = opt_hdr_size; | 1514 | 213 | bfd_byte * opthdr; | 1515 | | | 1516 | | /* PR 17521 file: 230-131433-0.004. */ | 1517 | 213 | if (amt < sizeof (PEAOUTHDR)) | 1518 | 171 | amt = sizeof (PEAOUTHDR); | 1519 | | | 1520 | 213 | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1521 | 213 | if (opthdr == NULL) | 1522 | 3 | return NULL; | 1523 | 210 | if (amt > opt_hdr_size) | 1524 | 168 | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1525 | | | 1526 | 210 | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1527 | | | 1528 | 210 | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1529 | | | 1530 | | #ifdef ARM | 1531 | | /* Use Subsystem to distinguish between pei-arm-little and | 1532 | | pei-arm-wince-little. */ | 1533 | | #ifdef WINCE | 1534 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1535 | | #else | 1536 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1537 | | #endif | 1538 | | { | 1539 | | bfd_set_error (bfd_error_wrong_format); | 1540 | | return NULL; | 1541 | | } | 1542 | | #endif | 1543 | | | 1544 | 210 | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1545 | 210 | || a->SectionAlignment >= 0x80000000) | 1546 | 97 | { | 1547 | 97 | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1548 | 97 | abfd); | 1549 | 97 | a->SectionAlignment &= -a->SectionAlignment; | 1550 | 97 | if (a->SectionAlignment >= 0x80000000) | 1551 | 2 | a->SectionAlignment = 0x40000000; | 1552 | 97 | } | 1553 | | | 1554 | 210 | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1555 | 210 | || a->FileAlignment > a->SectionAlignment) | 1556 | 101 | { | 1557 | 101 | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1558 | 101 | abfd); | 1559 | 101 | a->FileAlignment &= -a->FileAlignment; | 1560 | 101 | if (a->FileAlignment > a->SectionAlignment) | 1561 | 40 | a->FileAlignment = a->SectionAlignment; | 1562 | 101 | } | 1563 | | | 1564 | 210 | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1565 | 90 | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1566 | 210 | } | 1567 | | | 1568 | 276 | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1569 | 276 | (opt_hdr_size != 0 | 1570 | 276 | ? &internal_a | 1571 | 276 | : (struct internal_aouthdr *) NULL)); | 1572 | | | 1573 | 276 | if (result) | 1574 | 202 | { | 1575 | | /* Now the whole header has been processed, see if there is a build-id */ | 1576 | 202 | pe_bfd_read_buildid(abfd); | 1577 | 202 | } | 1578 | | | 1579 | 276 | return result; | 1580 | 279 | } |
pei-loongarch64.c:pe_bfd_object_p Line | Count | Source | 1430 | 14.4k | { | 1431 | 14.4k | bfd_byte buffer[6]; | 1432 | 14.4k | struct external_DOS_hdr dos_hdr; | 1433 | 14.4k | struct external_PEI_IMAGE_hdr image_hdr; | 1434 | 14.4k | struct internal_filehdr internal_f; | 1435 | 14.4k | struct internal_aouthdr internal_a; | 1436 | 14.4k | bfd_size_type opt_hdr_size; | 1437 | 14.4k | file_ptr offset; | 1438 | 14.4k | bfd_cleanup result; | 1439 | | | 1440 | | /* Detect if this a Microsoft Import Library Format element. */ | 1441 | | /* First read the beginning of the header. */ | 1442 | 14.4k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1443 | 14.4k | || bfd_read (buffer, 6, abfd) != 6) | 1444 | 130 | { | 1445 | 130 | if (bfd_get_error () != bfd_error_system_call) | 1446 | 128 | bfd_set_error (bfd_error_wrong_format); | 1447 | 130 | return NULL; | 1448 | 130 | } | 1449 | | | 1450 | | /* Then check the magic and the version (only 0 is supported). */ | 1451 | 14.3k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1452 | 14.3k | && H_GET_16 (abfd, buffer + 4) == 0) | 1453 | 195 | return pe_ILF_object_p (abfd); | 1454 | | | 1455 | 14.1k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1456 | 14.1k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1457 | 4.86k | { | 1458 | 4.86k | if (bfd_get_error () != bfd_error_system_call) | 1459 | 4.86k | bfd_set_error (bfd_error_wrong_format); | 1460 | 4.86k | return NULL; | 1461 | 4.86k | } | 1462 | | | 1463 | | /* There are really two magic numbers involved; the magic number | 1464 | | that says this is a NT executable (PEI) and the magic number that | 1465 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1466 | | the e_magic field. The latter is stored in the f_magic field. | 1467 | | If the NT magic number isn't valid, the architecture magic number | 1468 | | could be mimicked by some other field (specifically, the number | 1469 | | of relocs in section 3). Since this routine can only be called | 1470 | | correctly for a PEI file, check the e_magic number here, and, if | 1471 | | it doesn't match, clobber the f_magic number so that we don't get | 1472 | | a false match. */ | 1473 | 9.29k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1474 | 7.15k | { | 1475 | 7.15k | bfd_set_error (bfd_error_wrong_format); | 1476 | 7.15k | return NULL; | 1477 | 7.15k | } | 1478 | | | 1479 | 2.14k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1480 | 2.14k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1481 | 2.14k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1482 | 4 | { | 1483 | 4 | if (bfd_get_error () != bfd_error_system_call) | 1484 | 4 | bfd_set_error (bfd_error_wrong_format); | 1485 | 4 | return NULL; | 1486 | 4 | } | 1487 | | | 1488 | 2.13k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1489 | 32 | { | 1490 | 32 | bfd_set_error (bfd_error_wrong_format); | 1491 | 32 | return NULL; | 1492 | 32 | } | 1493 | | | 1494 | | /* Swap file header, so that we get the location for calling | 1495 | | real_object_p. */ | 1496 | 2.10k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1497 | | | 1498 | 2.10k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1499 | 2.10k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1500 | 1.85k | { | 1501 | 1.85k | bfd_set_error (bfd_error_wrong_format); | 1502 | 1.85k | return NULL; | 1503 | 1.85k | } | 1504 | | | 1505 | 246 | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1506 | 246 | sizeof (internal_f.pe.dos_message)); | 1507 | | | 1508 | | /* Read the optional header, which has variable size. */ | 1509 | 246 | opt_hdr_size = internal_f.f_opthdr; | 1510 | | | 1511 | 246 | if (opt_hdr_size != 0) | 1512 | 204 | { | 1513 | 204 | bfd_size_type amt = opt_hdr_size; | 1514 | 204 | bfd_byte * opthdr; | 1515 | | | 1516 | | /* PR 17521 file: 230-131433-0.004. */ | 1517 | 204 | if (amt < sizeof (PEAOUTHDR)) | 1518 | 111 | amt = sizeof (PEAOUTHDR); | 1519 | | | 1520 | 204 | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1521 | 204 | if (opthdr == NULL) | 1522 | 5 | return NULL; | 1523 | 199 | if (amt > opt_hdr_size) | 1524 | 107 | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1525 | | | 1526 | 199 | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1527 | | | 1528 | 199 | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1529 | | | 1530 | | #ifdef ARM | 1531 | | /* Use Subsystem to distinguish between pei-arm-little and | 1532 | | pei-arm-wince-little. */ | 1533 | | #ifdef WINCE | 1534 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1535 | | #else | 1536 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1537 | | #endif | 1538 | | { | 1539 | | bfd_set_error (bfd_error_wrong_format); | 1540 | | return NULL; | 1541 | | } | 1542 | | #endif | 1543 | | | 1544 | 199 | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1545 | 199 | || a->SectionAlignment >= 0x80000000) | 1546 | 143 | { | 1547 | 143 | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1548 | 143 | abfd); | 1549 | 143 | a->SectionAlignment &= -a->SectionAlignment; | 1550 | 143 | if (a->SectionAlignment >= 0x80000000) | 1551 | 3 | a->SectionAlignment = 0x40000000; | 1552 | 143 | } | 1553 | | | 1554 | 199 | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1555 | 199 | || a->FileAlignment > a->SectionAlignment) | 1556 | 106 | { | 1557 | 106 | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1558 | 106 | abfd); | 1559 | 106 | a->FileAlignment &= -a->FileAlignment; | 1560 | 106 | if (a->FileAlignment > a->SectionAlignment) | 1561 | 45 | a->FileAlignment = a->SectionAlignment; | 1562 | 106 | } | 1563 | | | 1564 | 199 | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1565 | 100 | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1566 | 199 | } | 1567 | | | 1568 | 241 | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1569 | 241 | (opt_hdr_size != 0 | 1570 | 241 | ? &internal_a | 1571 | 241 | : (struct internal_aouthdr *) NULL)); | 1572 | | | 1573 | 241 | if (result) | 1574 | 158 | { | 1575 | | /* Now the whole header has been processed, see if there is a build-id */ | 1576 | 158 | pe_bfd_read_buildid(abfd); | 1577 | 158 | } | 1578 | | | 1579 | 241 | return result; | 1580 | 246 | } |
pei-arm-wince.c:pe_bfd_object_p Line | Count | Source | 1430 | 28.9k | { | 1431 | 28.9k | bfd_byte buffer[6]; | 1432 | 28.9k | struct external_DOS_hdr dos_hdr; | 1433 | 28.9k | struct external_PEI_IMAGE_hdr image_hdr; | 1434 | 28.9k | struct internal_filehdr internal_f; | 1435 | 28.9k | struct internal_aouthdr internal_a; | 1436 | 28.9k | bfd_size_type opt_hdr_size; | 1437 | 28.9k | file_ptr offset; | 1438 | 28.9k | bfd_cleanup result; | 1439 | | | 1440 | | /* Detect if this a Microsoft Import Library Format element. */ | 1441 | | /* First read the beginning of the header. */ | 1442 | 28.9k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1443 | 28.9k | || bfd_read (buffer, 6, abfd) != 6) | 1444 | 260 | { | 1445 | 260 | if (bfd_get_error () != bfd_error_system_call) | 1446 | 256 | bfd_set_error (bfd_error_wrong_format); | 1447 | 260 | return NULL; | 1448 | 260 | } | 1449 | | | 1450 | | /* Then check the magic and the version (only 0 is supported). */ | 1451 | 28.7k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1452 | 28.7k | && H_GET_16 (abfd, buffer + 4) == 0) | 1453 | 247 | return pe_ILF_object_p (abfd); | 1454 | | | 1455 | 28.4k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1456 | 28.4k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1457 | 9.85k | { | 1458 | 9.85k | if (bfd_get_error () != bfd_error_system_call) | 1459 | 9.85k | bfd_set_error (bfd_error_wrong_format); | 1460 | 9.85k | return NULL; | 1461 | 9.85k | } | 1462 | | | 1463 | | /* There are really two magic numbers involved; the magic number | 1464 | | that says this is a NT executable (PEI) and the magic number that | 1465 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1466 | | the e_magic field. The latter is stored in the f_magic field. | 1467 | | If the NT magic number isn't valid, the architecture magic number | 1468 | | could be mimicked by some other field (specifically, the number | 1469 | | of relocs in section 3). Since this routine can only be called | 1470 | | correctly for a PEI file, check the e_magic number here, and, if | 1471 | | it doesn't match, clobber the f_magic number so that we don't get | 1472 | | a false match. */ | 1473 | 18.6k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1474 | 16.3k | { | 1475 | 16.3k | bfd_set_error (bfd_error_wrong_format); | 1476 | 16.3k | return NULL; | 1477 | 16.3k | } | 1478 | | | 1479 | 2.29k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1480 | 2.29k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1481 | 2.29k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1482 | 5 | { | 1483 | 5 | if (bfd_get_error () != bfd_error_system_call) | 1484 | 5 | bfd_set_error (bfd_error_wrong_format); | 1485 | 5 | return NULL; | 1486 | 5 | } | 1487 | | | 1488 | 2.28k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1489 | 107 | { | 1490 | 107 | bfd_set_error (bfd_error_wrong_format); | 1491 | 107 | return NULL; | 1492 | 107 | } | 1493 | | | 1494 | | /* Swap file header, so that we get the location for calling | 1495 | | real_object_p. */ | 1496 | 2.18k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1497 | | | 1498 | 2.18k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1499 | 2.18k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1500 | 1.75k | { | 1501 | 1.75k | bfd_set_error (bfd_error_wrong_format); | 1502 | 1.75k | return NULL; | 1503 | 1.75k | } | 1504 | | | 1505 | 426 | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1506 | 426 | sizeof (internal_f.pe.dos_message)); | 1507 | | | 1508 | | /* Read the optional header, which has variable size. */ | 1509 | 426 | opt_hdr_size = internal_f.f_opthdr; | 1510 | | | 1511 | 426 | if (opt_hdr_size != 0) | 1512 | 338 | { | 1513 | 338 | bfd_size_type amt = opt_hdr_size; | 1514 | 338 | bfd_byte * opthdr; | 1515 | | | 1516 | | /* PR 17521 file: 230-131433-0.004. */ | 1517 | 338 | if (amt < sizeof (PEAOUTHDR)) | 1518 | 278 | amt = sizeof (PEAOUTHDR); | 1519 | | | 1520 | 338 | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1521 | 338 | if (opthdr == NULL) | 1522 | 3 | return NULL; | 1523 | 335 | if (amt > opt_hdr_size) | 1524 | 276 | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1525 | | | 1526 | 335 | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1527 | | | 1528 | 335 | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1529 | | | 1530 | 335 | #ifdef ARM | 1531 | | /* Use Subsystem to distinguish between pei-arm-little and | 1532 | | pei-arm-wince-little. */ | 1533 | 335 | #ifdef WINCE | 1534 | 335 | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1535 | | #else | 1536 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1537 | | #endif | 1538 | 215 | { | 1539 | 215 | bfd_set_error (bfd_error_wrong_format); | 1540 | 215 | return NULL; | 1541 | 215 | } | 1542 | 120 | #endif | 1543 | | | 1544 | 120 | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1545 | 120 | || a->SectionAlignment >= 0x80000000) | 1546 | 65 | { | 1547 | 65 | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1548 | 65 | abfd); | 1549 | 65 | a->SectionAlignment &= -a->SectionAlignment; | 1550 | 65 | if (a->SectionAlignment >= 0x80000000) | 1551 | 0 | a->SectionAlignment = 0x40000000; | 1552 | 65 | } | 1553 | | | 1554 | 120 | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1555 | 120 | || a->FileAlignment > a->SectionAlignment) | 1556 | 66 | { | 1557 | 66 | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1558 | 66 | abfd); | 1559 | 66 | a->FileAlignment &= -a->FileAlignment; | 1560 | 66 | if (a->FileAlignment > a->SectionAlignment) | 1561 | 52 | a->FileAlignment = a->SectionAlignment; | 1562 | 66 | } | 1563 | | | 1564 | 120 | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1565 | 81 | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1566 | 120 | } | 1567 | | | 1568 | 208 | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1569 | 208 | (opt_hdr_size != 0 | 1570 | 208 | ? &internal_a | 1571 | 208 | : (struct internal_aouthdr *) NULL)); | 1572 | | | 1573 | 208 | if (result) | 1574 | 124 | { | 1575 | | /* Now the whole header has been processed, see if there is a build-id */ | 1576 | 124 | pe_bfd_read_buildid(abfd); | 1577 | 124 | } | 1578 | | | 1579 | 208 | return result; | 1580 | 426 | } |
pei-arm.c:pe_bfd_object_p Line | Count | Source | 1430 | 28.9k | { | 1431 | 28.9k | bfd_byte buffer[6]; | 1432 | 28.9k | struct external_DOS_hdr dos_hdr; | 1433 | 28.9k | struct external_PEI_IMAGE_hdr image_hdr; | 1434 | 28.9k | struct internal_filehdr internal_f; | 1435 | 28.9k | struct internal_aouthdr internal_a; | 1436 | 28.9k | bfd_size_type opt_hdr_size; | 1437 | 28.9k | file_ptr offset; | 1438 | 28.9k | bfd_cleanup result; | 1439 | | | 1440 | | /* Detect if this a Microsoft Import Library Format element. */ | 1441 | | /* First read the beginning of the header. */ | 1442 | 28.9k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1443 | 28.9k | || bfd_read (buffer, 6, abfd) != 6) | 1444 | 260 | { | 1445 | 260 | if (bfd_get_error () != bfd_error_system_call) | 1446 | 256 | bfd_set_error (bfd_error_wrong_format); | 1447 | 260 | return NULL; | 1448 | 260 | } | 1449 | | | 1450 | | /* Then check the magic and the version (only 0 is supported). */ | 1451 | 28.7k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1452 | 28.7k | && H_GET_16 (abfd, buffer + 4) == 0) | 1453 | 255 | return pe_ILF_object_p (abfd); | 1454 | | | 1455 | 28.4k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1456 | 28.4k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1457 | 9.85k | { | 1458 | 9.85k | if (bfd_get_error () != bfd_error_system_call) | 1459 | 9.85k | bfd_set_error (bfd_error_wrong_format); | 1460 | 9.85k | return NULL; | 1461 | 9.85k | } | 1462 | | | 1463 | | /* There are really two magic numbers involved; the magic number | 1464 | | that says this is a NT executable (PEI) and the magic number that | 1465 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1466 | | the e_magic field. The latter is stored in the f_magic field. | 1467 | | If the NT magic number isn't valid, the architecture magic number | 1468 | | could be mimicked by some other field (specifically, the number | 1469 | | of relocs in section 3). Since this routine can only be called | 1470 | | correctly for a PEI file, check the e_magic number here, and, if | 1471 | | it doesn't match, clobber the f_magic number so that we don't get | 1472 | | a false match. */ | 1473 | 18.6k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1474 | 16.3k | { | 1475 | 16.3k | bfd_set_error (bfd_error_wrong_format); | 1476 | 16.3k | return NULL; | 1477 | 16.3k | } | 1478 | | | 1479 | 2.29k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1480 | 2.29k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1481 | 2.29k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1482 | 5 | { | 1483 | 5 | if (bfd_get_error () != bfd_error_system_call) | 1484 | 5 | bfd_set_error (bfd_error_wrong_format); | 1485 | 5 | return NULL; | 1486 | 5 | } | 1487 | | | 1488 | 2.28k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1489 | 107 | { | 1490 | 107 | bfd_set_error (bfd_error_wrong_format); | 1491 | 107 | return NULL; | 1492 | 107 | } | 1493 | | | 1494 | | /* Swap file header, so that we get the location for calling | 1495 | | real_object_p. */ | 1496 | 2.18k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1497 | | | 1498 | 2.18k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1499 | 2.18k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1500 | 1.75k | { | 1501 | 1.75k | bfd_set_error (bfd_error_wrong_format); | 1502 | 1.75k | return NULL; | 1503 | 1.75k | } | 1504 | | | 1505 | 426 | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1506 | 426 | sizeof (internal_f.pe.dos_message)); | 1507 | | | 1508 | | /* Read the optional header, which has variable size. */ | 1509 | 426 | opt_hdr_size = internal_f.f_opthdr; | 1510 | | | 1511 | 426 | if (opt_hdr_size != 0) | 1512 | 338 | { | 1513 | 338 | bfd_size_type amt = opt_hdr_size; | 1514 | 338 | bfd_byte * opthdr; | 1515 | | | 1516 | | /* PR 17521 file: 230-131433-0.004. */ | 1517 | 338 | if (amt < sizeof (PEAOUTHDR)) | 1518 | 278 | amt = sizeof (PEAOUTHDR); | 1519 | | | 1520 | 338 | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1521 | 338 | if (opthdr == NULL) | 1522 | 3 | return NULL; | 1523 | 335 | if (amt > opt_hdr_size) | 1524 | 276 | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1525 | | | 1526 | 335 | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1527 | | | 1528 | 335 | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1529 | | | 1530 | 335 | #ifdef ARM | 1531 | | /* Use Subsystem to distinguish between pei-arm-little and | 1532 | | pei-arm-wince-little. */ | 1533 | | #ifdef WINCE | 1534 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1535 | | #else | 1536 | 335 | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1537 | 120 | #endif | 1538 | 120 | { | 1539 | 120 | bfd_set_error (bfd_error_wrong_format); | 1540 | 120 | return NULL; | 1541 | 120 | } | 1542 | 215 | #endif | 1543 | | | 1544 | 215 | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1545 | 215 | || a->SectionAlignment >= 0x80000000) | 1546 | 108 | { | 1547 | 108 | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1548 | 108 | abfd); | 1549 | 108 | a->SectionAlignment &= -a->SectionAlignment; | 1550 | 108 | if (a->SectionAlignment >= 0x80000000) | 1551 | 1 | a->SectionAlignment = 0x40000000; | 1552 | 108 | } | 1553 | | | 1554 | 215 | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1555 | 215 | || a->FileAlignment > a->SectionAlignment) | 1556 | 112 | { | 1557 | 112 | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1558 | 112 | abfd); | 1559 | 112 | a->FileAlignment &= -a->FileAlignment; | 1560 | 112 | if (a->FileAlignment > a->SectionAlignment) | 1561 | 44 | a->FileAlignment = a->SectionAlignment; | 1562 | 112 | } | 1563 | | | 1564 | 215 | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1565 | 109 | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1566 | 215 | } | 1567 | | | 1568 | 303 | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1569 | 303 | (opt_hdr_size != 0 | 1570 | 303 | ? &internal_a | 1571 | 303 | : (struct internal_aouthdr *) NULL)); | 1572 | | | 1573 | 303 | if (result) | 1574 | 181 | { | 1575 | | /* Now the whole header has been processed, see if there is a build-id */ | 1576 | 181 | pe_bfd_read_buildid(abfd); | 1577 | 181 | } | 1578 | | | 1579 | 303 | return result; | 1580 | 426 | } |
pei-mcore.c:pe_bfd_object_p Line | Count | Source | 1430 | 28.9k | { | 1431 | 28.9k | bfd_byte buffer[6]; | 1432 | 28.9k | struct external_DOS_hdr dos_hdr; | 1433 | 28.9k | struct external_PEI_IMAGE_hdr image_hdr; | 1434 | 28.9k | struct internal_filehdr internal_f; | 1435 | 28.9k | struct internal_aouthdr internal_a; | 1436 | 28.9k | bfd_size_type opt_hdr_size; | 1437 | 28.9k | file_ptr offset; | 1438 | 28.9k | bfd_cleanup result; | 1439 | | | 1440 | | /* Detect if this a Microsoft Import Library Format element. */ | 1441 | | /* First read the beginning of the header. */ | 1442 | 28.9k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1443 | 28.9k | || bfd_read (buffer, 6, abfd) != 6) | 1444 | 260 | { | 1445 | 260 | if (bfd_get_error () != bfd_error_system_call) | 1446 | 256 | bfd_set_error (bfd_error_wrong_format); | 1447 | 260 | return NULL; | 1448 | 260 | } | 1449 | | | 1450 | | /* Then check the magic and the version (only 0 is supported). */ | 1451 | 28.7k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1452 | 28.7k | && H_GET_16 (abfd, buffer + 4) == 0) | 1453 | 247 | return pe_ILF_object_p (abfd); | 1454 | | | 1455 | 28.4k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1456 | 28.4k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1457 | 9.85k | { | 1458 | 9.85k | if (bfd_get_error () != bfd_error_system_call) | 1459 | 9.85k | bfd_set_error (bfd_error_wrong_format); | 1460 | 9.85k | return NULL; | 1461 | 9.85k | } | 1462 | | | 1463 | | /* There are really two magic numbers involved; the magic number | 1464 | | that says this is a NT executable (PEI) and the magic number that | 1465 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1466 | | the e_magic field. The latter is stored in the f_magic field. | 1467 | | If the NT magic number isn't valid, the architecture magic number | 1468 | | could be mimicked by some other field (specifically, the number | 1469 | | of relocs in section 3). Since this routine can only be called | 1470 | | correctly for a PEI file, check the e_magic number here, and, if | 1471 | | it doesn't match, clobber the f_magic number so that we don't get | 1472 | | a false match. */ | 1473 | 18.6k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1474 | 16.4k | { | 1475 | 16.4k | bfd_set_error (bfd_error_wrong_format); | 1476 | 16.4k | return NULL; | 1477 | 16.4k | } | 1478 | | | 1479 | 2.21k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1480 | 2.21k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1481 | 2.21k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1482 | 4 | { | 1483 | 4 | if (bfd_get_error () != bfd_error_system_call) | 1484 | 4 | bfd_set_error (bfd_error_wrong_format); | 1485 | 4 | return NULL; | 1486 | 4 | } | 1487 | | | 1488 | 2.21k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1489 | 32 | { | 1490 | 32 | bfd_set_error (bfd_error_wrong_format); | 1491 | 32 | return NULL; | 1492 | 32 | } | 1493 | | | 1494 | | /* Swap file header, so that we get the location for calling | 1495 | | real_object_p. */ | 1496 | 2.18k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1497 | | | 1498 | 2.18k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1499 | 2.18k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1500 | 1.95k | { | 1501 | 1.95k | bfd_set_error (bfd_error_wrong_format); | 1502 | 1.95k | return NULL; | 1503 | 1.95k | } | 1504 | | | 1505 | 225 | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1506 | 225 | sizeof (internal_f.pe.dos_message)); | 1507 | | | 1508 | | /* Read the optional header, which has variable size. */ | 1509 | 225 | opt_hdr_size = internal_f.f_opthdr; | 1510 | | | 1511 | 225 | if (opt_hdr_size != 0) | 1512 | 110 | { | 1513 | 110 | bfd_size_type amt = opt_hdr_size; | 1514 | 110 | bfd_byte * opthdr; | 1515 | | | 1516 | | /* PR 17521 file: 230-131433-0.004. */ | 1517 | 110 | if (amt < sizeof (PEAOUTHDR)) | 1518 | 107 | amt = sizeof (PEAOUTHDR); | 1519 | | | 1520 | 110 | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1521 | 110 | if (opthdr == NULL) | 1522 | 4 | return NULL; | 1523 | 106 | if (amt > opt_hdr_size) | 1524 | 104 | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1525 | | | 1526 | 106 | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1527 | | | 1528 | 106 | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1529 | | | 1530 | | #ifdef ARM | 1531 | | /* Use Subsystem to distinguish between pei-arm-little and | 1532 | | pei-arm-wince-little. */ | 1533 | | #ifdef WINCE | 1534 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1535 | | #else | 1536 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1537 | | #endif | 1538 | | { | 1539 | | bfd_set_error (bfd_error_wrong_format); | 1540 | | return NULL; | 1541 | | } | 1542 | | #endif | 1543 | | | 1544 | 106 | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1545 | 106 | || a->SectionAlignment >= 0x80000000) | 1546 | 85 | { | 1547 | 85 | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1548 | 85 | abfd); | 1549 | 85 | a->SectionAlignment &= -a->SectionAlignment; | 1550 | 85 | if (a->SectionAlignment >= 0x80000000) | 1551 | 0 | a->SectionAlignment = 0x40000000; | 1552 | 85 | } | 1553 | | | 1554 | 106 | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1555 | 106 | || a->FileAlignment > a->SectionAlignment) | 1556 | 89 | { | 1557 | 89 | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1558 | 89 | abfd); | 1559 | 89 | a->FileAlignment &= -a->FileAlignment; | 1560 | 89 | if (a->FileAlignment > a->SectionAlignment) | 1561 | 54 | a->FileAlignment = a->SectionAlignment; | 1562 | 89 | } | 1563 | | | 1564 | 106 | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1565 | 84 | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1566 | 106 | } | 1567 | | | 1568 | 221 | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1569 | 221 | (opt_hdr_size != 0 | 1570 | 221 | ? &internal_a | 1571 | 221 | : (struct internal_aouthdr *) NULL)); | 1572 | | | 1573 | 221 | if (result) | 1574 | 143 | { | 1575 | | /* Now the whole header has been processed, see if there is a build-id */ | 1576 | 143 | pe_bfd_read_buildid(abfd); | 1577 | 143 | } | 1578 | | | 1579 | 221 | return result; | 1580 | 225 | } |
Line | Count | Source | 1430 | 14.4k | { | 1431 | 14.4k | bfd_byte buffer[6]; | 1432 | 14.4k | struct external_DOS_hdr dos_hdr; | 1433 | 14.4k | struct external_PEI_IMAGE_hdr image_hdr; | 1434 | 14.4k | struct internal_filehdr internal_f; | 1435 | 14.4k | struct internal_aouthdr internal_a; | 1436 | 14.4k | bfd_size_type opt_hdr_size; | 1437 | 14.4k | file_ptr offset; | 1438 | 14.4k | bfd_cleanup result; | 1439 | | | 1440 | | /* Detect if this a Microsoft Import Library Format element. */ | 1441 | | /* First read the beginning of the header. */ | 1442 | 14.4k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1443 | 14.4k | || bfd_read (buffer, 6, abfd) != 6) | 1444 | 130 | { | 1445 | 130 | if (bfd_get_error () != bfd_error_system_call) | 1446 | 128 | bfd_set_error (bfd_error_wrong_format); | 1447 | 130 | return NULL; | 1448 | 130 | } | 1449 | | | 1450 | | /* Then check the magic and the version (only 0 is supported). */ | 1451 | 14.3k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1452 | 14.3k | && H_GET_16 (abfd, buffer + 4) == 0) | 1453 | 211 | return pe_ILF_object_p (abfd); | 1454 | | | 1455 | 14.1k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1456 | 14.1k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1457 | 4.86k | { | 1458 | 4.86k | if (bfd_get_error () != bfd_error_system_call) | 1459 | 4.86k | bfd_set_error (bfd_error_wrong_format); | 1460 | 4.86k | return NULL; | 1461 | 4.86k | } | 1462 | | | 1463 | | /* There are really two magic numbers involved; the magic number | 1464 | | that says this is a NT executable (PEI) and the magic number that | 1465 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1466 | | the e_magic field. The latter is stored in the f_magic field. | 1467 | | If the NT magic number isn't valid, the architecture magic number | 1468 | | could be mimicked by some other field (specifically, the number | 1469 | | of relocs in section 3). Since this routine can only be called | 1470 | | correctly for a PEI file, check the e_magic number here, and, if | 1471 | | it doesn't match, clobber the f_magic number so that we don't get | 1472 | | a false match. */ | 1473 | 9.28k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1474 | 7.14k | { | 1475 | 7.14k | bfd_set_error (bfd_error_wrong_format); | 1476 | 7.14k | return NULL; | 1477 | 7.14k | } | 1478 | | | 1479 | 2.14k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1480 | 2.14k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1481 | 2.14k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1482 | 4 | { | 1483 | 4 | if (bfd_get_error () != bfd_error_system_call) | 1484 | 4 | bfd_set_error (bfd_error_wrong_format); | 1485 | 4 | return NULL; | 1486 | 4 | } | 1487 | | | 1488 | 2.13k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1489 | 32 | { | 1490 | 32 | bfd_set_error (bfd_error_wrong_format); | 1491 | 32 | return NULL; | 1492 | 32 | } | 1493 | | | 1494 | | /* Swap file header, so that we get the location for calling | 1495 | | real_object_p. */ | 1496 | 2.10k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1497 | | | 1498 | 2.10k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1499 | 2.10k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1500 | 1.88k | { | 1501 | 1.88k | bfd_set_error (bfd_error_wrong_format); | 1502 | 1.88k | return NULL; | 1503 | 1.88k | } | 1504 | | | 1505 | 222 | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1506 | 222 | sizeof (internal_f.pe.dos_message)); | 1507 | | | 1508 | | /* Read the optional header, which has variable size. */ | 1509 | 222 | opt_hdr_size = internal_f.f_opthdr; | 1510 | | | 1511 | 222 | if (opt_hdr_size != 0) | 1512 | 187 | { | 1513 | 187 | bfd_size_type amt = opt_hdr_size; | 1514 | 187 | bfd_byte * opthdr; | 1515 | | | 1516 | | /* PR 17521 file: 230-131433-0.004. */ | 1517 | 187 | if (amt < sizeof (PEAOUTHDR)) | 1518 | 185 | amt = sizeof (PEAOUTHDR); | 1519 | | | 1520 | 187 | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1521 | 187 | if (opthdr == NULL) | 1522 | 4 | return NULL; | 1523 | 183 | if (amt > opt_hdr_size) | 1524 | 181 | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1525 | | | 1526 | 183 | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1527 | | | 1528 | 183 | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1529 | | | 1530 | | #ifdef ARM | 1531 | | /* Use Subsystem to distinguish between pei-arm-little and | 1532 | | pei-arm-wince-little. */ | 1533 | | #ifdef WINCE | 1534 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1535 | | #else | 1536 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1537 | | #endif | 1538 | | { | 1539 | | bfd_set_error (bfd_error_wrong_format); | 1540 | | return NULL; | 1541 | | } | 1542 | | #endif | 1543 | | | 1544 | 183 | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1545 | 183 | || a->SectionAlignment >= 0x80000000) | 1546 | 98 | { | 1547 | 98 | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1548 | 98 | abfd); | 1549 | 98 | a->SectionAlignment &= -a->SectionAlignment; | 1550 | 98 | if (a->SectionAlignment >= 0x80000000) | 1551 | 2 | a->SectionAlignment = 0x40000000; | 1552 | 98 | } | 1553 | | | 1554 | 183 | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1555 | 183 | || a->FileAlignment > a->SectionAlignment) | 1556 | 71 | { | 1557 | 71 | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1558 | 71 | abfd); | 1559 | 71 | a->FileAlignment &= -a->FileAlignment; | 1560 | 71 | if (a->FileAlignment > a->SectionAlignment) | 1561 | 23 | a->FileAlignment = a->SectionAlignment; | 1562 | 71 | } | 1563 | | | 1564 | 183 | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1565 | 105 | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1566 | 183 | } | 1567 | | | 1568 | 218 | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1569 | 218 | (opt_hdr_size != 0 | 1570 | 218 | ? &internal_a | 1571 | 218 | : (struct internal_aouthdr *) NULL)); | 1572 | | | 1573 | 218 | if (result) | 1574 | 144 | { | 1575 | | /* Now the whole header has been processed, see if there is a build-id */ | 1576 | 144 | pe_bfd_read_buildid(abfd); | 1577 | 144 | } | 1578 | | | 1579 | 218 | return result; | 1580 | 222 | } |
|
1581 | | |
1582 | 1.68k | #define coff_object_p pe_bfd_object_p |
1583 | | #endif /* COFF_IMAGE_WITH_PE */ |