/src/binutils-gdb/bfd/peicode.h
Line | Count | Source |
1 | | /* Support for the generic parts of PE/PEI, for BFD. |
2 | | Copyright (C) 1995-2026 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 | | |
86 | | /* For the case of linking ELF objects into a PE binary. */ |
87 | | #undef TARGET_MERGE_SECTIONS |
88 | | #define TARGET_MERGE_SECTIONS true |
89 | | |
90 | | /* This structure contains static variables used by the ILF code. */ |
91 | | typedef asection * asection_ptr; |
92 | | |
93 | | typedef struct |
94 | | { |
95 | | bfd * abfd; |
96 | | bfd_byte * data; |
97 | | struct bfd_in_memory * bim; |
98 | | unsigned short magic; |
99 | | |
100 | | arelent * reltab; |
101 | | unsigned int relcount; |
102 | | |
103 | | coff_symbol_type * sym_cache; |
104 | | coff_symbol_type * sym_ptr; |
105 | | unsigned int sym_index; |
106 | | |
107 | | unsigned int * sym_table; |
108 | | unsigned int * table_ptr; |
109 | | |
110 | | combined_entry_type * native_syms; |
111 | | combined_entry_type * native_ptr; |
112 | | |
113 | | coff_symbol_type ** sym_ptr_table; |
114 | | coff_symbol_type ** sym_ptr_ptr; |
115 | | |
116 | | unsigned int sec_index; |
117 | | |
118 | | char * string_table; |
119 | | char * string_ptr; |
120 | | char * end_string_ptr; |
121 | | |
122 | | SYMENT * esym_table; |
123 | | SYMENT * esym_ptr; |
124 | | |
125 | | struct internal_reloc * int_reltab; |
126 | | } |
127 | | pe_ILF_vars; |
128 | | #endif /* COFF_IMAGE_WITH_PE */ |
129 | | |
130 | | bfd_cleanup coff_real_object_p |
131 | | (bfd *, unsigned, struct internal_filehdr *, struct internal_aouthdr *); |
132 | | |
133 | | #ifndef NO_COFF_RELOCS |
134 | | static void |
135 | | coff_swap_reloc_in (bfd *abfd, void *src, void *dst) |
136 | 54.0k | { |
137 | 54.0k | RELOC *reloc_src = (RELOC *) src; |
138 | 54.0k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; |
139 | | |
140 | 54.0k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); |
141 | 54.0k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); |
142 | 54.0k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); |
143 | | #ifdef SWAP_IN_RELOC_OFFSET |
144 | 22.3k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); |
145 | | #endif |
146 | 54.0k | } pei-i386.c:coff_swap_reloc_in Line | Count | Source | 136 | 3.11k | { | 137 | 3.11k | RELOC *reloc_src = (RELOC *) src; | 138 | 3.11k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 139 | | | 140 | 3.11k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 141 | 3.11k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 142 | 3.11k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 143 | | #ifdef SWAP_IN_RELOC_OFFSET | 144 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 145 | | #endif | 146 | 3.11k | } |
pe-x86_64.c:coff_swap_reloc_in Line | Count | Source | 136 | 2.10k | { | 137 | 2.10k | RELOC *reloc_src = (RELOC *) src; | 138 | 2.10k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 139 | | | 140 | 2.10k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 141 | 2.10k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 142 | 2.10k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 143 | | #ifdef SWAP_IN_RELOC_OFFSET | 144 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 145 | | #endif | 146 | 2.10k | } |
pei-x86_64.c:coff_swap_reloc_in Line | Count | Source | 136 | 4.28k | { | 137 | 4.28k | RELOC *reloc_src = (RELOC *) src; | 138 | 4.28k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 139 | | | 140 | 4.28k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 141 | 4.28k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 142 | 4.28k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 143 | | #ifdef SWAP_IN_RELOC_OFFSET | 144 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 145 | | #endif | 146 | 4.28k | } |
pe-aarch64.c:coff_swap_reloc_in Line | Count | Source | 136 | 6.86k | { | 137 | 6.86k | RELOC *reloc_src = (RELOC *) src; | 138 | 6.86k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 139 | | | 140 | 6.86k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 141 | 6.86k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 142 | 6.86k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 143 | | #ifdef SWAP_IN_RELOC_OFFSET | 144 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 145 | | #endif | 146 | 6.86k | } |
pei-aarch64.c:coff_swap_reloc_in Line | Count | Source | 136 | 3.74k | { | 137 | 3.74k | RELOC *reloc_src = (RELOC *) src; | 138 | 3.74k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 139 | | | 140 | 3.74k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 141 | 3.74k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 142 | 3.74k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 143 | | #ifdef SWAP_IN_RELOC_OFFSET | 144 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 145 | | #endif | 146 | 3.74k | } |
pei-ia64.c:coff_swap_reloc_in Line | Count | Source | 136 | 2.90k | { | 137 | 2.90k | RELOC *reloc_src = (RELOC *) src; | 138 | 2.90k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 139 | | | 140 | 2.90k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 141 | 2.90k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 142 | 2.90k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 143 | | #ifdef SWAP_IN_RELOC_OFFSET | 144 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 145 | | #endif | 146 | 2.90k | } |
pei-loongarch64.c:coff_swap_reloc_in Line | Count | Source | 136 | 2.52k | { | 137 | 2.52k | RELOC *reloc_src = (RELOC *) src; | 138 | 2.52k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 139 | | | 140 | 2.52k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 141 | 2.52k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 142 | 2.52k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 143 | 2.52k | #ifdef SWAP_IN_RELOC_OFFSET | 144 | 2.52k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 145 | 2.52k | #endif | 146 | 2.52k | } |
pei-riscv64.c:coff_swap_reloc_in Line | Count | Source | 136 | 3.44k | { | 137 | 3.44k | RELOC *reloc_src = (RELOC *) src; | 138 | 3.44k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 139 | | | 140 | 3.44k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 141 | 3.44k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 142 | 3.44k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 143 | 3.44k | #ifdef SWAP_IN_RELOC_OFFSET | 144 | 3.44k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 145 | 3.44k | #endif | 146 | 3.44k | } |
pe-arm-wince.c:coff_swap_reloc_in Line | Count | Source | 136 | 1.29k | { | 137 | 1.29k | RELOC *reloc_src = (RELOC *) src; | 138 | 1.29k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 139 | | | 140 | 1.29k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 141 | 1.29k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 142 | 1.29k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 143 | 1.29k | #ifdef SWAP_IN_RELOC_OFFSET | 144 | 1.29k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 145 | 1.29k | #endif | 146 | 1.29k | } |
pe-arm.c:coff_swap_reloc_in Line | Count | Source | 136 | 1.29k | { | 137 | 1.29k | RELOC *reloc_src = (RELOC *) src; | 138 | 1.29k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 139 | | | 140 | 1.29k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 141 | 1.29k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 142 | 1.29k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 143 | 1.29k | #ifdef SWAP_IN_RELOC_OFFSET | 144 | 1.29k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 145 | 1.29k | #endif | 146 | 1.29k | } |
pe-i386.c:coff_swap_reloc_in Line | Count | Source | 136 | 3.78k | { | 137 | 3.78k | RELOC *reloc_src = (RELOC *) src; | 138 | 3.78k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 139 | | | 140 | 3.78k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 141 | 3.78k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 142 | 3.78k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 143 | | #ifdef SWAP_IN_RELOC_OFFSET | 144 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 145 | | #endif | 146 | 3.78k | } |
pe-mcore.c:coff_swap_reloc_in Line | Count | Source | 136 | 3.12k | { | 137 | 3.12k | RELOC *reloc_src = (RELOC *) src; | 138 | 3.12k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 139 | | | 140 | 3.12k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 141 | 3.12k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 142 | 3.12k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 143 | 3.12k | #ifdef SWAP_IN_RELOC_OFFSET | 144 | 3.12k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 145 | 3.12k | #endif | 146 | 3.12k | } |
pe-sh.c:coff_swap_reloc_in Line | Count | Source | 136 | 2.39k | { | 137 | 2.39k | RELOC *reloc_src = (RELOC *) src; | 138 | 2.39k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 139 | | | 140 | 2.39k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 141 | 2.39k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 142 | 2.39k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 143 | | #ifdef SWAP_IN_RELOC_OFFSET | 144 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 145 | | #endif | 146 | 2.39k | } |
pei-arm-wince.c:coff_swap_reloc_in Line | Count | Source | 136 | 3.74k | { | 137 | 3.74k | RELOC *reloc_src = (RELOC *) src; | 138 | 3.74k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 139 | | | 140 | 3.74k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 141 | 3.74k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 142 | 3.74k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 143 | 3.74k | #ifdef SWAP_IN_RELOC_OFFSET | 144 | 3.74k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 145 | 3.74k | #endif | 146 | 3.74k | } |
pei-arm.c:coff_swap_reloc_in Line | Count | Source | 136 | 3.87k | { | 137 | 3.87k | RELOC *reloc_src = (RELOC *) src; | 138 | 3.87k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 139 | | | 140 | 3.87k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 141 | 3.87k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 142 | 3.87k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 143 | 3.87k | #ifdef SWAP_IN_RELOC_OFFSET | 144 | 3.87k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 145 | 3.87k | #endif | 146 | 3.87k | } |
pei-mcore.c:coff_swap_reloc_in Line | Count | Source | 136 | 3.02k | { | 137 | 3.02k | RELOC *reloc_src = (RELOC *) src; | 138 | 3.02k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 139 | | | 140 | 3.02k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 141 | 3.02k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 142 | 3.02k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 143 | 3.02k | #ifdef SWAP_IN_RELOC_OFFSET | 144 | 3.02k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 145 | 3.02k | #endif | 146 | 3.02k | } |
pei-sh.c:coff_swap_reloc_in Line | Count | Source | 136 | 2.50k | { | 137 | 2.50k | RELOC *reloc_src = (RELOC *) src; | 138 | 2.50k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 139 | | | 140 | 2.50k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 141 | 2.50k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 142 | 2.50k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 143 | | #ifdef SWAP_IN_RELOC_OFFSET | 144 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 145 | | #endif | 146 | 2.50k | } |
|
147 | | |
148 | | static unsigned int |
149 | | coff_swap_reloc_out (bfd *abfd, void *src, void *dst) |
150 | 0 | { |
151 | 0 | struct internal_reloc *reloc_src = (struct internal_reloc *) src; |
152 | 0 | struct external_reloc *reloc_dst = (struct external_reloc *) dst; |
153 | |
|
154 | 0 | H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr); |
155 | 0 | H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx); |
156 | 0 | H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type); |
157 | |
|
158 | | #ifdef SWAP_OUT_RELOC_OFFSET |
159 | 0 | SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset); |
160 | | #endif |
161 | | #ifdef SWAP_OUT_RELOC_EXTRA |
162 | | SWAP_OUT_RELOC_EXTRA (abfd, reloc_src, reloc_dst); |
163 | | #endif |
164 | 0 | return RELSZ; |
165 | 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: pei-riscv64.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 |
166 | | #endif /* not NO_COFF_RELOCS */ |
167 | | |
168 | | #ifdef COFF_IMAGE_WITH_PE |
169 | | #undef FILHDR |
170 | 415k | #define FILHDR struct external_PEI_IMAGE_hdr |
171 | | #endif |
172 | | |
173 | | static void |
174 | | coff_swap_filehdr_in (bfd *abfd, void *src, void *dst) |
175 | 1.79M | { |
176 | 1.79M | FILHDR *filehdr_src = (FILHDR *) src; |
177 | 1.79M | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; |
178 | | |
179 | 1.79M | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); |
180 | 1.79M | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); |
181 | 1.79M | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); |
182 | 1.79M | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); |
183 | 1.79M | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); |
184 | 1.79M | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); |
185 | | |
186 | | /* Other people's tools sometimes generate headers with an nsyms but |
187 | | a zero symptr. */ |
188 | 1.79M | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) |
189 | 173k | { |
190 | 173k | filehdr_dst->f_nsyms = 0; |
191 | 173k | filehdr_dst->f_flags |= F_LSYMS; |
192 | 173k | } |
193 | | |
194 | 1.79M | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); |
195 | 1.79M | } pei-i386.c:coff_swap_filehdr_in Line | Count | Source | 175 | 47.2k | { | 176 | 47.2k | FILHDR *filehdr_src = (FILHDR *) src; | 177 | 47.2k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 178 | | | 179 | 47.2k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 180 | 47.2k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 181 | 47.2k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 182 | 47.2k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 183 | 47.2k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 184 | 47.2k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 185 | | | 186 | | /* Other people's tools sometimes generate headers with an nsyms but | 187 | | a zero symptr. */ | 188 | 47.2k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 189 | 4.57k | { | 190 | 4.57k | filehdr_dst->f_nsyms = 0; | 191 | 4.57k | filehdr_dst->f_flags |= F_LSYMS; | 192 | 4.57k | } | 193 | | | 194 | 47.2k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 195 | 47.2k | } |
pe-x86_64.c:coff_swap_filehdr_in Line | Count | Source | 175 | 147k | { | 176 | 147k | FILHDR *filehdr_src = (FILHDR *) src; | 177 | 147k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 178 | | | 179 | 147k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 180 | 147k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 181 | 147k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 182 | 147k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 183 | 147k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 184 | 147k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 185 | | | 186 | | /* Other people's tools sometimes generate headers with an nsyms but | 187 | | a zero symptr. */ | 188 | 147k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 189 | 14.8k | { | 190 | 14.8k | filehdr_dst->f_nsyms = 0; | 191 | 14.8k | filehdr_dst->f_flags |= F_LSYMS; | 192 | 14.8k | } | 193 | | | 194 | 147k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 195 | 147k | } |
pei-x86_64.c:coff_swap_filehdr_in Line | Count | Source | 175 | 45.8k | { | 176 | 45.8k | FILHDR *filehdr_src = (FILHDR *) src; | 177 | 45.8k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 178 | | | 179 | 45.8k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 180 | 45.8k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 181 | 45.8k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 182 | 45.8k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 183 | 45.8k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 184 | 45.8k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 185 | | | 186 | | /* Other people's tools sometimes generate headers with an nsyms but | 187 | | a zero symptr. */ | 188 | 45.8k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 189 | 4.27k | { | 190 | 4.27k | filehdr_dst->f_nsyms = 0; | 191 | 4.27k | filehdr_dst->f_flags |= F_LSYMS; | 192 | 4.27k | } | 193 | | | 194 | 45.8k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 195 | 45.8k | } |
pe-aarch64.c:coff_swap_filehdr_in Line | Count | Source | 175 | 145k | { | 176 | 145k | FILHDR *filehdr_src = (FILHDR *) src; | 177 | 145k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 178 | | | 179 | 145k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 180 | 145k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 181 | 145k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 182 | 145k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 183 | 145k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 184 | 145k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 185 | | | 186 | | /* Other people's tools sometimes generate headers with an nsyms but | 187 | | a zero symptr. */ | 188 | 145k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 189 | 14.7k | { | 190 | 14.7k | filehdr_dst->f_nsyms = 0; | 191 | 14.7k | filehdr_dst->f_flags |= F_LSYMS; | 192 | 14.7k | } | 193 | | | 194 | 145k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 195 | 145k | } |
pei-aarch64.c:coff_swap_filehdr_in Line | Count | Source | 175 | 44.4k | { | 176 | 44.4k | FILHDR *filehdr_src = (FILHDR *) src; | 177 | 44.4k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 178 | | | 179 | 44.4k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 180 | 44.4k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 181 | 44.4k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 182 | 44.4k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 183 | 44.4k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 184 | 44.4k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 185 | | | 186 | | /* Other people's tools sometimes generate headers with an nsyms but | 187 | | a zero symptr. */ | 188 | 44.4k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 189 | 4.20k | { | 190 | 4.20k | filehdr_dst->f_nsyms = 0; | 191 | 4.20k | filehdr_dst->f_flags |= F_LSYMS; | 192 | 4.20k | } | 193 | | | 194 | 44.4k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 195 | 44.4k | } |
pei-ia64.c:coff_swap_filehdr_in Line | Count | Source | 175 | 14.4k | { | 176 | 14.4k | FILHDR *filehdr_src = (FILHDR *) src; | 177 | 14.4k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 178 | | | 179 | 14.4k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 180 | 14.4k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 181 | 14.4k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 182 | 14.4k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 183 | 14.4k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 184 | 14.4k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 185 | | | 186 | | /* Other people's tools sometimes generate headers with an nsyms but | 187 | | a zero symptr. */ | 188 | 14.4k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 189 | 542 | { | 190 | 542 | filehdr_dst->f_nsyms = 0; | 191 | 542 | filehdr_dst->f_flags |= F_LSYMS; | 192 | 542 | } | 193 | | | 194 | 14.4k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 195 | 14.4k | } |
pei-loongarch64.c:coff_swap_filehdr_in Line | Count | Source | 175 | 44.2k | { | 176 | 44.2k | FILHDR *filehdr_src = (FILHDR *) src; | 177 | 44.2k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 178 | | | 179 | 44.2k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 180 | 44.2k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 181 | 44.2k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 182 | 44.2k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 183 | 44.2k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 184 | 44.2k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 185 | | | 186 | | /* Other people's tools sometimes generate headers with an nsyms but | 187 | | a zero symptr. */ | 188 | 44.2k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 189 | 4.25k | { | 190 | 4.25k | filehdr_dst->f_nsyms = 0; | 191 | 4.25k | filehdr_dst->f_flags |= F_LSYMS; | 192 | 4.25k | } | 193 | | | 194 | 44.2k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 195 | 44.2k | } |
pei-riscv64.c:coff_swap_filehdr_in Line | Count | Source | 175 | 44.1k | { | 176 | 44.1k | FILHDR *filehdr_src = (FILHDR *) src; | 177 | 44.1k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 178 | | | 179 | 44.1k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 180 | 44.1k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 181 | 44.1k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 182 | 44.1k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 183 | 44.1k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 184 | 44.1k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 185 | | | 186 | | /* Other people's tools sometimes generate headers with an nsyms but | 187 | | a zero symptr. */ | 188 | 44.1k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 189 | 4.12k | { | 190 | 4.12k | filehdr_dst->f_nsyms = 0; | 191 | 4.12k | filehdr_dst->f_flags |= F_LSYMS; | 192 | 4.12k | } | 193 | | | 194 | 44.1k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 195 | 44.1k | } |
pe-arm-wince.c:coff_swap_filehdr_in Line | Count | Source | 175 | 267k | { | 176 | 267k | FILHDR *filehdr_src = (FILHDR *) src; | 177 | 267k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 178 | | | 179 | 267k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 180 | 267k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 181 | 267k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 182 | 267k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 183 | 267k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 184 | 267k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 185 | | | 186 | | /* Other people's tools sometimes generate headers with an nsyms but | 187 | | a zero symptr. */ | 188 | 267k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 189 | 25.7k | { | 190 | 25.7k | filehdr_dst->f_nsyms = 0; | 191 | 25.7k | filehdr_dst->f_flags |= F_LSYMS; | 192 | 25.7k | } | 193 | | | 194 | 267k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 195 | 267k | } |
pe-arm.c:coff_swap_filehdr_in Line | Count | Source | 175 | 267k | { | 176 | 267k | FILHDR *filehdr_src = (FILHDR *) src; | 177 | 267k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 178 | | | 179 | 267k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 180 | 267k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 181 | 267k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 182 | 267k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 183 | 267k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 184 | 267k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 185 | | | 186 | | /* Other people's tools sometimes generate headers with an nsyms but | 187 | | a zero symptr. */ | 188 | 267k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 189 | 25.7k | { | 190 | 25.7k | filehdr_dst->f_nsyms = 0; | 191 | 25.7k | filehdr_dst->f_flags |= F_LSYMS; | 192 | 25.7k | } | 193 | | | 194 | 267k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 195 | 267k | } |
pe-i386.c:coff_swap_filehdr_in Line | Count | Source | 175 | 145k | { | 176 | 145k | FILHDR *filehdr_src = (FILHDR *) src; | 177 | 145k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 178 | | | 179 | 145k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 180 | 145k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 181 | 145k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 182 | 145k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 183 | 145k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 184 | 145k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 185 | | | 186 | | /* Other people's tools sometimes generate headers with an nsyms but | 187 | | a zero symptr. */ | 188 | 145k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 189 | 14.8k | { | 190 | 14.8k | filehdr_dst->f_nsyms = 0; | 191 | 14.8k | filehdr_dst->f_flags |= F_LSYMS; | 192 | 14.8k | } | 193 | | | 194 | 145k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 195 | 145k | } |
pe-mcore.c:coff_swap_filehdr_in Line | Count | Source | 175 | 267k | { | 176 | 267k | FILHDR *filehdr_src = (FILHDR *) src; | 177 | 267k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 178 | | | 179 | 267k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 180 | 267k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 181 | 267k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 182 | 267k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 183 | 267k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 184 | 267k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 185 | | | 186 | | /* Other people's tools sometimes generate headers with an nsyms but | 187 | | a zero symptr. */ | 188 | 267k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 189 | 25.9k | { | 190 | 25.9k | filehdr_dst->f_nsyms = 0; | 191 | 25.9k | filehdr_dst->f_flags |= F_LSYMS; | 192 | 25.9k | } | 193 | | | 194 | 267k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 195 | 267k | } |
pe-sh.c:coff_swap_filehdr_in Line | Count | Source | 175 | 135k | { | 176 | 135k | FILHDR *filehdr_src = (FILHDR *) src; | 177 | 135k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 178 | | | 179 | 135k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 180 | 135k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 181 | 135k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 182 | 135k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 183 | 135k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 184 | 135k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 185 | | | 186 | | /* Other people's tools sometimes generate headers with an nsyms but | 187 | | a zero symptr. */ | 188 | 135k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 189 | 13.1k | { | 190 | 13.1k | filehdr_dst->f_nsyms = 0; | 191 | 13.1k | filehdr_dst->f_flags |= F_LSYMS; | 192 | 13.1k | } | 193 | | | 194 | 135k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 195 | 135k | } |
pei-arm-wince.c:coff_swap_filehdr_in Line | Count | Source | 175 | 43.8k | { | 176 | 43.8k | FILHDR *filehdr_src = (FILHDR *) src; | 177 | 43.8k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 178 | | | 179 | 43.8k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 180 | 43.8k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 181 | 43.8k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 182 | 43.8k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 183 | 43.8k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 184 | 43.8k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 185 | | | 186 | | /* Other people's tools sometimes generate headers with an nsyms but | 187 | | a zero symptr. */ | 188 | 43.8k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 189 | 4.16k | { | 190 | 4.16k | filehdr_dst->f_nsyms = 0; | 191 | 4.16k | filehdr_dst->f_flags |= F_LSYMS; | 192 | 4.16k | } | 193 | | | 194 | 43.8k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 195 | 43.8k | } |
pei-arm.c:coff_swap_filehdr_in Line | Count | Source | 175 | 44.0k | { | 176 | 44.0k | FILHDR *filehdr_src = (FILHDR *) src; | 177 | 44.0k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 178 | | | 179 | 44.0k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 180 | 44.0k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 181 | 44.0k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 182 | 44.0k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 183 | 44.0k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 184 | 44.0k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 185 | | | 186 | | /* Other people's tools sometimes generate headers with an nsyms but | 187 | | a zero symptr. */ | 188 | 44.0k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 189 | 4.18k | { | 190 | 4.18k | filehdr_dst->f_nsyms = 0; | 191 | 4.18k | filehdr_dst->f_flags |= F_LSYMS; | 192 | 4.18k | } | 193 | | | 194 | 44.0k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 195 | 44.0k | } |
pei-mcore.c:coff_swap_filehdr_in Line | Count | Source | 175 | 43.6k | { | 176 | 43.6k | FILHDR *filehdr_src = (FILHDR *) src; | 177 | 43.6k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 178 | | | 179 | 43.6k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 180 | 43.6k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 181 | 43.6k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 182 | 43.6k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 183 | 43.6k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 184 | 43.6k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 185 | | | 186 | | /* Other people's tools sometimes generate headers with an nsyms but | 187 | | a zero symptr. */ | 188 | 43.6k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 189 | 4.12k | { | 190 | 4.12k | filehdr_dst->f_nsyms = 0; | 191 | 4.12k | filehdr_dst->f_flags |= F_LSYMS; | 192 | 4.12k | } | 193 | | | 194 | 43.6k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 195 | 43.6k | } |
pei-sh.c:coff_swap_filehdr_in Line | Count | Source | 175 | 43.6k | { | 176 | 43.6k | FILHDR *filehdr_src = (FILHDR *) src; | 177 | 43.6k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 178 | | | 179 | 43.6k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 180 | 43.6k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 181 | 43.6k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 182 | 43.6k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 183 | 43.6k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 184 | 43.6k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 185 | | | 186 | | /* Other people's tools sometimes generate headers with an nsyms but | 187 | | a zero symptr. */ | 188 | 43.6k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 189 | 4.12k | { | 190 | 4.12k | filehdr_dst->f_nsyms = 0; | 191 | 4.12k | filehdr_dst->f_flags |= F_LSYMS; | 192 | 4.12k | } | 193 | | | 194 | 43.6k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 195 | 43.6k | } |
|
196 | | |
197 | | #ifdef COFF_IMAGE_WITH_PE |
198 | | # define coff_swap_filehdr_out _bfd_XXi_only_swap_filehdr_out |
199 | | #elif defined COFF_WITH_peAArch64 |
200 | | # define coff_swap_filehdr_out _bfd_XX_only_swap_filehdr_out |
201 | | #elif defined COFF_WITH_pex64 |
202 | | # define coff_swap_filehdr_out _bfd_pex64_only_swap_filehdr_out |
203 | | #elif defined COFF_WITH_pep |
204 | | # define coff_swap_filehdr_out _bfd_pep_only_swap_filehdr_out |
205 | | #else |
206 | | # define coff_swap_filehdr_out _bfd_pe_only_swap_filehdr_out |
207 | | #endif |
208 | | |
209 | | static void |
210 | | coff_swap_scnhdr_in (bfd *abfd, void *ext, void *in) |
211 | 731k | { |
212 | 731k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; |
213 | 731k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; |
214 | | |
215 | 731k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); |
216 | | |
217 | 731k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); |
218 | 731k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); |
219 | 731k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); |
220 | 731k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); |
221 | 731k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); |
222 | 731k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); |
223 | 731k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); |
224 | | |
225 | | /* MS handles overflow of line numbers by carrying into the reloc |
226 | | field (it appears). Since it's supposed to be zero for PE |
227 | | *IMAGE* format, that's safe. This is still a bit iffy. */ |
228 | | #ifdef COFF_IMAGE_WITH_PE |
229 | 506k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) |
230 | 506k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); |
231 | | scnhdr_int->s_nreloc = 0; |
232 | | #else |
233 | 225k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); |
234 | 225k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); |
235 | | #endif |
236 | | |
237 | 731k | if (scnhdr_int->s_vaddr != 0) |
238 | 470k | { |
239 | 470k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; |
240 | | /* Do not cut upper 32-bits for 64-bit vma. */ |
241 | | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ |
242 | | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) |
243 | | scnhdr_int->s_vaddr &= 0xffffffff; |
244 | | #endif |
245 | 470k | } |
246 | | |
247 | 731k | #ifndef COFF_NO_HACK_SCNHDR_SIZE |
248 | | /* If this section holds uninitialized data and is from an object file |
249 | | or from an executable image that has not initialized the field, |
250 | | or if the image is an executable file and the physical size is padded, |
251 | | use the virtual size (stored in s_paddr) instead. */ |
252 | 731k | if (scnhdr_int->s_paddr > 0 |
253 | 521k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 |
254 | 125k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) |
255 | 475k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) |
256 | | /* This code used to set scnhdr_int->s_paddr to 0. However, |
257 | | coff_set_alignment_hook stores s_paddr in virt_size, which |
258 | | only works if it correctly holds the virtual size of the |
259 | | section. */ |
260 | 148k | scnhdr_int->s_size = scnhdr_int->s_paddr; |
261 | 731k | #endif |
262 | 731k | } pei-i386.c:coff_swap_scnhdr_in Line | Count | Source | 211 | 52.2k | { | 212 | 52.2k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 213 | 52.2k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 214 | | | 215 | 52.2k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 216 | | | 217 | 52.2k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 218 | 52.2k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 219 | 52.2k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 220 | 52.2k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 221 | 52.2k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 222 | 52.2k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 223 | 52.2k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 224 | | | 225 | | /* MS handles overflow of line numbers by carrying into the reloc | 226 | | field (it appears). Since it's supposed to be zero for PE | 227 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 228 | 52.2k | #ifdef COFF_IMAGE_WITH_PE | 229 | 52.2k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 230 | 52.2k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 231 | 52.2k | scnhdr_int->s_nreloc = 0; | 232 | | #else | 233 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 234 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 235 | | #endif | 236 | | | 237 | 52.2k | if (scnhdr_int->s_vaddr != 0) | 238 | 33.2k | { | 239 | 33.2k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 240 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 241 | 33.2k | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 242 | 33.2k | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 243 | 33.2k | scnhdr_int->s_vaddr &= 0xffffffff; | 244 | 33.2k | #endif | 245 | 33.2k | } | 246 | | | 247 | 52.2k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 248 | | /* If this section holds uninitialized data and is from an object file | 249 | | or from an executable image that has not initialized the field, | 250 | | or if the image is an executable file and the physical size is padded, | 251 | | use the virtual size (stored in s_paddr) instead. */ | 252 | 52.2k | if (scnhdr_int->s_paddr > 0 | 253 | 37.8k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 254 | 8.91k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 255 | 36.5k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 256 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 257 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 258 | | only works if it correctly holds the virtual size of the | 259 | | section. */ | 260 | 14.3k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 261 | 52.2k | #endif | 262 | 52.2k | } |
pe-x86_64.c:coff_swap_scnhdr_in Line | Count | Source | 211 | 49.3k | { | 212 | 49.3k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 213 | 49.3k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 214 | | | 215 | 49.3k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 216 | | | 217 | 49.3k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 218 | 49.3k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 219 | 49.3k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 220 | 49.3k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 221 | 49.3k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 222 | 49.3k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 223 | 49.3k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 224 | | | 225 | | /* MS handles overflow of line numbers by carrying into the reloc | 226 | | field (it appears). Since it's supposed to be zero for PE | 227 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 228 | | #ifdef COFF_IMAGE_WITH_PE | 229 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 230 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 231 | | scnhdr_int->s_nreloc = 0; | 232 | | #else | 233 | 49.3k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 234 | 49.3k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 235 | 49.3k | #endif | 236 | | | 237 | 49.3k | if (scnhdr_int->s_vaddr != 0) | 238 | 27.7k | { | 239 | 27.7k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 240 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 241 | | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 242 | | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 243 | | scnhdr_int->s_vaddr &= 0xffffffff; | 244 | | #endif | 245 | 27.7k | } | 246 | | | 247 | 49.3k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 248 | | /* If this section holds uninitialized data and is from an object file | 249 | | or from an executable image that has not initialized the field, | 250 | | or if the image is an executable file and the physical size is padded, | 251 | | use the virtual size (stored in s_paddr) instead. */ | 252 | 49.3k | if (scnhdr_int->s_paddr > 0 | 253 | 28.5k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 254 | 5.14k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 255 | 23.4k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 256 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 257 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 258 | | only works if it correctly holds the virtual size of the | 259 | | section. */ | 260 | 5.14k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 261 | 49.3k | #endif | 262 | 49.3k | } |
pei-x86_64.c:coff_swap_scnhdr_in Line | Count | Source | 211 | 51.7k | { | 212 | 51.7k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 213 | 51.7k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 214 | | | 215 | 51.7k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 216 | | | 217 | 51.7k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 218 | 51.7k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 219 | 51.7k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 220 | 51.7k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 221 | 51.7k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 222 | 51.7k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 223 | 51.7k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 224 | | | 225 | | /* MS handles overflow of line numbers by carrying into the reloc | 226 | | field (it appears). Since it's supposed to be zero for PE | 227 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 228 | 51.7k | #ifdef COFF_IMAGE_WITH_PE | 229 | 51.7k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 230 | 51.7k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 231 | 51.7k | scnhdr_int->s_nreloc = 0; | 232 | | #else | 233 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 234 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 235 | | #endif | 236 | | | 237 | 51.7k | if (scnhdr_int->s_vaddr != 0) | 238 | 33.6k | { | 239 | 33.6k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 240 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 241 | | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 242 | | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 243 | | scnhdr_int->s_vaddr &= 0xffffffff; | 244 | | #endif | 245 | 33.6k | } | 246 | | | 247 | 51.7k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 248 | | /* If this section holds uninitialized data and is from an object file | 249 | | or from an executable image that has not initialized the field, | 250 | | or if the image is an executable file and the physical size is padded, | 251 | | use the virtual size (stored in s_paddr) instead. */ | 252 | 51.7k | if (scnhdr_int->s_paddr > 0 | 253 | 36.6k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 254 | 7.94k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 255 | 35.4k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 256 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 257 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 258 | | only works if it correctly holds the virtual size of the | 259 | | section. */ | 260 | 12.7k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 261 | 51.7k | #endif | 262 | 51.7k | } |
pe-aarch64.c:coff_swap_scnhdr_in Line | Count | Source | 211 | 31.5k | { | 212 | 31.5k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 213 | 31.5k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 214 | | | 215 | 31.5k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 216 | | | 217 | 31.5k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 218 | 31.5k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 219 | 31.5k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 220 | 31.5k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 221 | 31.5k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 222 | 31.5k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 223 | 31.5k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 224 | | | 225 | | /* MS handles overflow of line numbers by carrying into the reloc | 226 | | field (it appears). Since it's supposed to be zero for PE | 227 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 228 | | #ifdef COFF_IMAGE_WITH_PE | 229 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 230 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 231 | | scnhdr_int->s_nreloc = 0; | 232 | | #else | 233 | 31.5k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 234 | 31.5k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 235 | 31.5k | #endif | 236 | | | 237 | 31.5k | if (scnhdr_int->s_vaddr != 0) | 238 | 18.6k | { | 239 | 18.6k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 240 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 241 | | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 242 | | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 243 | | scnhdr_int->s_vaddr &= 0xffffffff; | 244 | | #endif | 245 | 18.6k | } | 246 | | | 247 | 31.5k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 248 | | /* If this section holds uninitialized data and is from an object file | 249 | | or from an executable image that has not initialized the field, | 250 | | or if the image is an executable file and the physical size is padded, | 251 | | use the virtual size (stored in s_paddr) instead. */ | 252 | 31.5k | if (scnhdr_int->s_paddr > 0 | 253 | 21.0k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 254 | 4.50k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 255 | 16.5k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 256 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 257 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 258 | | only works if it correctly holds the virtual size of the | 259 | | section. */ | 260 | 4.50k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 261 | 31.5k | #endif | 262 | 31.5k | } |
pei-aarch64.c:coff_swap_scnhdr_in Line | Count | Source | 211 | 62.8k | { | 212 | 62.8k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 213 | 62.8k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 214 | | | 215 | 62.8k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 216 | | | 217 | 62.8k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 218 | 62.8k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 219 | 62.8k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 220 | 62.8k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 221 | 62.8k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 222 | 62.8k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 223 | 62.8k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 224 | | | 225 | | /* MS handles overflow of line numbers by carrying into the reloc | 226 | | field (it appears). Since it's supposed to be zero for PE | 227 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 228 | 62.8k | #ifdef COFF_IMAGE_WITH_PE | 229 | 62.8k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 230 | 62.8k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 231 | 62.8k | scnhdr_int->s_nreloc = 0; | 232 | | #else | 233 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 234 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 235 | | #endif | 236 | | | 237 | 62.8k | if (scnhdr_int->s_vaddr != 0) | 238 | 44.4k | { | 239 | 44.4k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 240 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 241 | | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 242 | | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 243 | | scnhdr_int->s_vaddr &= 0xffffffff; | 244 | | #endif | 245 | 44.4k | } | 246 | | | 247 | 62.8k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 248 | | /* If this section holds uninitialized data and is from an object file | 249 | | or from an executable image that has not initialized the field, | 250 | | or if the image is an executable file and the physical size is padded, | 251 | | use the virtual size (stored in s_paddr) instead. */ | 252 | 62.8k | if (scnhdr_int->s_paddr > 0 | 253 | 45.3k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 254 | 9.76k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 255 | 43.2k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 256 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 257 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 258 | | only works if it correctly holds the virtual size of the | 259 | | section. */ | 260 | 16.2k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 261 | 62.8k | #endif | 262 | 62.8k | } |
pei-ia64.c:coff_swap_scnhdr_in Line | Count | Source | 211 | 45.5k | { | 212 | 45.5k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 213 | 45.5k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 214 | | | 215 | 45.5k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 216 | | | 217 | 45.5k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 218 | 45.5k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 219 | 45.5k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 220 | 45.5k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 221 | 45.5k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 222 | 45.5k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 223 | 45.5k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 224 | | | 225 | | /* MS handles overflow of line numbers by carrying into the reloc | 226 | | field (it appears). Since it's supposed to be zero for PE | 227 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 228 | 45.5k | #ifdef COFF_IMAGE_WITH_PE | 229 | 45.5k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 230 | 45.5k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 231 | 45.5k | scnhdr_int->s_nreloc = 0; | 232 | | #else | 233 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 234 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 235 | | #endif | 236 | | | 237 | 45.5k | if (scnhdr_int->s_vaddr != 0) | 238 | 29.3k | { | 239 | 29.3k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 240 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 241 | 29.3k | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 242 | 29.3k | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 243 | 29.3k | scnhdr_int->s_vaddr &= 0xffffffff; | 244 | 29.3k | #endif | 245 | 29.3k | } | 246 | | | 247 | 45.5k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 248 | | /* If this section holds uninitialized data and is from an object file | 249 | | or from an executable image that has not initialized the field, | 250 | | or if the image is an executable file and the physical size is padded, | 251 | | use the virtual size (stored in s_paddr) instead. */ | 252 | 45.5k | if (scnhdr_int->s_paddr > 0 | 253 | 32.4k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 254 | 8.79k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 255 | 30.8k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 256 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 257 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 258 | | only works if it correctly holds the virtual size of the | 259 | | section. */ | 260 | 11.0k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 261 | 45.5k | #endif | 262 | 45.5k | } |
pei-loongarch64.c:coff_swap_scnhdr_in Line | Count | Source | 211 | 51.6k | { | 212 | 51.6k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 213 | 51.6k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 214 | | | 215 | 51.6k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 216 | | | 217 | 51.6k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 218 | 51.6k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 219 | 51.6k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 220 | 51.6k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 221 | 51.6k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 222 | 51.6k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 223 | 51.6k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 224 | | | 225 | | /* MS handles overflow of line numbers by carrying into the reloc | 226 | | field (it appears). Since it's supposed to be zero for PE | 227 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 228 | 51.6k | #ifdef COFF_IMAGE_WITH_PE | 229 | 51.6k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 230 | 51.6k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 231 | 51.6k | scnhdr_int->s_nreloc = 0; | 232 | | #else | 233 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 234 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 235 | | #endif | 236 | | | 237 | 51.6k | if (scnhdr_int->s_vaddr != 0) | 238 | 35.2k | { | 239 | 35.2k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 240 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 241 | | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 242 | | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 243 | | scnhdr_int->s_vaddr &= 0xffffffff; | 244 | | #endif | 245 | 35.2k | } | 246 | | | 247 | 51.6k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 248 | | /* If this section holds uninitialized data and is from an object file | 249 | | or from an executable image that has not initialized the field, | 250 | | or if the image is an executable file and the physical size is padded, | 251 | | use the virtual size (stored in s_paddr) instead. */ | 252 | 51.6k | if (scnhdr_int->s_paddr > 0 | 253 | 39.2k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 254 | 11.9k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 255 | 37.7k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 256 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 257 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 258 | | only works if it correctly holds the virtual size of the | 259 | | section. */ | 260 | 10.9k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 261 | 51.6k | #endif | 262 | 51.6k | } |
pei-riscv64.c:coff_swap_scnhdr_in Line | Count | Source | 211 | 51.7k | { | 212 | 51.7k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 213 | 51.7k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 214 | | | 215 | 51.7k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 216 | | | 217 | 51.7k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 218 | 51.7k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 219 | 51.7k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 220 | 51.7k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 221 | 51.7k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 222 | 51.7k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 223 | 51.7k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 224 | | | 225 | | /* MS handles overflow of line numbers by carrying into the reloc | 226 | | field (it appears). Since it's supposed to be zero for PE | 227 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 228 | 51.7k | #ifdef COFF_IMAGE_WITH_PE | 229 | 51.7k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 230 | 51.7k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 231 | 51.7k | scnhdr_int->s_nreloc = 0; | 232 | | #else | 233 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 234 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 235 | | #endif | 236 | | | 237 | 51.7k | if (scnhdr_int->s_vaddr != 0) | 238 | 32.2k | { | 239 | 32.2k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 240 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 241 | | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 242 | | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 243 | | scnhdr_int->s_vaddr &= 0xffffffff; | 244 | | #endif | 245 | 32.2k | } | 246 | | | 247 | 51.7k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 248 | | /* If this section holds uninitialized data and is from an object file | 249 | | or from an executable image that has not initialized the field, | 250 | | or if the image is an executable file and the physical size is padded, | 251 | | use the virtual size (stored in s_paddr) instead. */ | 252 | 51.7k | if (scnhdr_int->s_paddr > 0 | 253 | 37.2k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 254 | 10.3k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 255 | 36.2k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 256 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 257 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 258 | | only works if it correctly holds the virtual size of the | 259 | | section. */ | 260 | 9.81k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 261 | 51.7k | #endif | 262 | 51.7k | } |
pe-arm-wince.c:coff_swap_scnhdr_in Line | Count | Source | 211 | 19.7k | { | 212 | 19.7k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 213 | 19.7k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 214 | | | 215 | 19.7k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 216 | | | 217 | 19.7k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 218 | 19.7k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 219 | 19.7k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 220 | 19.7k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 221 | 19.7k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 222 | 19.7k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 223 | 19.7k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 224 | | | 225 | | /* MS handles overflow of line numbers by carrying into the reloc | 226 | | field (it appears). Since it's supposed to be zero for PE | 227 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 228 | | #ifdef COFF_IMAGE_WITH_PE | 229 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 230 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 231 | | scnhdr_int->s_nreloc = 0; | 232 | | #else | 233 | 19.7k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 234 | 19.7k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 235 | 19.7k | #endif | 236 | | | 237 | 19.7k | if (scnhdr_int->s_vaddr != 0) | 238 | 12.6k | { | 239 | 12.6k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 240 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 241 | 12.6k | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 242 | 12.6k | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 243 | 12.6k | scnhdr_int->s_vaddr &= 0xffffffff; | 244 | 12.6k | #endif | 245 | 12.6k | } | 246 | | | 247 | 19.7k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 248 | | /* If this section holds uninitialized data and is from an object file | 249 | | or from an executable image that has not initialized the field, | 250 | | or if the image is an executable file and the physical size is padded, | 251 | | use the virtual size (stored in s_paddr) instead. */ | 252 | 19.7k | if (scnhdr_int->s_paddr > 0 | 253 | 13.9k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 254 | 3.13k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 255 | 10.8k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 256 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 257 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 258 | | only works if it correctly holds the virtual size of the | 259 | | section. */ | 260 | 3.13k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 261 | 19.7k | #endif | 262 | 19.7k | } |
pe-arm.c:coff_swap_scnhdr_in Line | Count | Source | 211 | 19.7k | { | 212 | 19.7k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 213 | 19.7k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 214 | | | 215 | 19.7k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 216 | | | 217 | 19.7k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 218 | 19.7k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 219 | 19.7k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 220 | 19.7k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 221 | 19.7k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 222 | 19.7k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 223 | 19.7k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 224 | | | 225 | | /* MS handles overflow of line numbers by carrying into the reloc | 226 | | field (it appears). Since it's supposed to be zero for PE | 227 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 228 | | #ifdef COFF_IMAGE_WITH_PE | 229 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 230 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 231 | | scnhdr_int->s_nreloc = 0; | 232 | | #else | 233 | 19.7k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 234 | 19.7k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 235 | 19.7k | #endif | 236 | | | 237 | 19.7k | if (scnhdr_int->s_vaddr != 0) | 238 | 12.6k | { | 239 | 12.6k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 240 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 241 | 12.6k | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 242 | 12.6k | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 243 | 12.6k | scnhdr_int->s_vaddr &= 0xffffffff; | 244 | 12.6k | #endif | 245 | 12.6k | } | 246 | | | 247 | 19.7k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 248 | | /* If this section holds uninitialized data and is from an object file | 249 | | or from an executable image that has not initialized the field, | 250 | | or if the image is an executable file and the physical size is padded, | 251 | | use the virtual size (stored in s_paddr) instead. */ | 252 | 19.7k | if (scnhdr_int->s_paddr > 0 | 253 | 13.9k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 254 | 3.13k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 255 | 10.8k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 256 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 257 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 258 | | only works if it correctly holds the virtual size of the | 259 | | section. */ | 260 | 3.13k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 261 | 19.7k | #endif | 262 | 19.7k | } |
pe-i386.c:coff_swap_scnhdr_in Line | Count | Source | 211 | 46.1k | { | 212 | 46.1k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 213 | 46.1k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 214 | | | 215 | 46.1k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 216 | | | 217 | 46.1k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 218 | 46.1k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 219 | 46.1k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 220 | 46.1k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 221 | 46.1k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 222 | 46.1k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 223 | 46.1k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 224 | | | 225 | | /* MS handles overflow of line numbers by carrying into the reloc | 226 | | field (it appears). Since it's supposed to be zero for PE | 227 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 228 | | #ifdef COFF_IMAGE_WITH_PE | 229 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 230 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 231 | | scnhdr_int->s_nreloc = 0; | 232 | | #else | 233 | 46.1k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 234 | 46.1k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 235 | 46.1k | #endif | 236 | | | 237 | 46.1k | if (scnhdr_int->s_vaddr != 0) | 238 | 29.8k | { | 239 | 29.8k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 240 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 241 | 29.8k | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 242 | 29.8k | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 243 | 29.8k | scnhdr_int->s_vaddr &= 0xffffffff; | 244 | 29.8k | #endif | 245 | 29.8k | } | 246 | | | 247 | 46.1k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 248 | | /* If this section holds uninitialized data and is from an object file | 249 | | or from an executable image that has not initialized the field, | 250 | | or if the image is an executable file and the physical size is padded, | 251 | | use the virtual size (stored in s_paddr) instead. */ | 252 | 46.1k | if (scnhdr_int->s_paddr > 0 | 253 | 33.2k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 254 | 7.24k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 255 | 26.0k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 256 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 257 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 258 | | only works if it correctly holds the virtual size of the | 259 | | section. */ | 260 | 7.24k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 261 | 46.1k | #endif | 262 | 46.1k | } |
pe-mcore.c:coff_swap_scnhdr_in Line | Count | Source | 211 | 23.1k | { | 212 | 23.1k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 213 | 23.1k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 214 | | | 215 | 23.1k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 216 | | | 217 | 23.1k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 218 | 23.1k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 219 | 23.1k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 220 | 23.1k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 221 | 23.1k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 222 | 23.1k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 223 | 23.1k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 224 | | | 225 | | /* MS handles overflow of line numbers by carrying into the reloc | 226 | | field (it appears). Since it's supposed to be zero for PE | 227 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 228 | | #ifdef COFF_IMAGE_WITH_PE | 229 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 230 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 231 | | scnhdr_int->s_nreloc = 0; | 232 | | #else | 233 | 23.1k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 234 | 23.1k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 235 | 23.1k | #endif | 236 | | | 237 | 23.1k | if (scnhdr_int->s_vaddr != 0) | 238 | 14.7k | { | 239 | 14.7k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 240 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 241 | 14.7k | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 242 | 14.7k | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 243 | 14.7k | scnhdr_int->s_vaddr &= 0xffffffff; | 244 | 14.7k | #endif | 245 | 14.7k | } | 246 | | | 247 | 23.1k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 248 | | /* If this section holds uninitialized data and is from an object file | 249 | | or from an executable image that has not initialized the field, | 250 | | or if the image is an executable file and the physical size is padded, | 251 | | use the virtual size (stored in s_paddr) instead. */ | 252 | 23.1k | if (scnhdr_int->s_paddr > 0 | 253 | 16.7k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 254 | 3.37k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 255 | 13.3k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 256 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 257 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 258 | | only works if it correctly holds the virtual size of the | 259 | | section. */ | 260 | 3.37k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 261 | 23.1k | #endif | 262 | 23.1k | } |
pe-sh.c:coff_swap_scnhdr_in Line | Count | Source | 211 | 35.5k | { | 212 | 35.5k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 213 | 35.5k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 214 | | | 215 | 35.5k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 216 | | | 217 | 35.5k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 218 | 35.5k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 219 | 35.5k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 220 | 35.5k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 221 | 35.5k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 222 | 35.5k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 223 | 35.5k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 224 | | | 225 | | /* MS handles overflow of line numbers by carrying into the reloc | 226 | | field (it appears). Since it's supposed to be zero for PE | 227 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 228 | | #ifdef COFF_IMAGE_WITH_PE | 229 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 230 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 231 | | scnhdr_int->s_nreloc = 0; | 232 | | #else | 233 | 35.5k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 234 | 35.5k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 235 | 35.5k | #endif | 236 | | | 237 | 35.5k | if (scnhdr_int->s_vaddr != 0) | 238 | 22.4k | { | 239 | 22.4k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 240 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 241 | 22.4k | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 242 | 22.4k | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 243 | 22.4k | scnhdr_int->s_vaddr &= 0xffffffff; | 244 | 22.4k | #endif | 245 | 22.4k | } | 246 | | | 247 | 35.5k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 248 | | /* If this section holds uninitialized data and is from an object file | 249 | | or from an executable image that has not initialized the field, | 250 | | or if the image is an executable file and the physical size is padded, | 251 | | use the virtual size (stored in s_paddr) instead. */ | 252 | 35.5k | if (scnhdr_int->s_paddr > 0 | 253 | 25.0k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 254 | 5.57k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 255 | 19.4k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 256 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 257 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 258 | | only works if it correctly holds the virtual size of the | 259 | | section. */ | 260 | 5.57k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 261 | 35.5k | #endif | 262 | 35.5k | } |
pei-arm-wince.c:coff_swap_scnhdr_in Line | Count | Source | 211 | 41.0k | { | 212 | 41.0k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 213 | 41.0k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 214 | | | 215 | 41.0k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 216 | | | 217 | 41.0k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 218 | 41.0k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 219 | 41.0k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 220 | 41.0k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 221 | 41.0k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 222 | 41.0k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 223 | 41.0k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 224 | | | 225 | | /* MS handles overflow of line numbers by carrying into the reloc | 226 | | field (it appears). Since it's supposed to be zero for PE | 227 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 228 | 41.0k | #ifdef COFF_IMAGE_WITH_PE | 229 | 41.0k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 230 | 41.0k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 231 | 41.0k | scnhdr_int->s_nreloc = 0; | 232 | | #else | 233 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 234 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 235 | | #endif | 236 | | | 237 | 41.0k | if (scnhdr_int->s_vaddr != 0) | 238 | 26.2k | { | 239 | 26.2k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 240 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 241 | 26.2k | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 242 | 26.2k | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 243 | 26.2k | scnhdr_int->s_vaddr &= 0xffffffff; | 244 | 26.2k | #endif | 245 | 26.2k | } | 246 | | | 247 | 41.0k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 248 | | /* If this section holds uninitialized data and is from an object file | 249 | | or from an executable image that has not initialized the field, | 250 | | or if the image is an executable file and the physical size is padded, | 251 | | use the virtual size (stored in s_paddr) instead. */ | 252 | 41.0k | if (scnhdr_int->s_paddr > 0 | 253 | 31.1k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 254 | 8.80k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 255 | 29.8k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 256 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 257 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 258 | | only works if it correctly holds the virtual size of the | 259 | | section. */ | 260 | 9.42k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 261 | 41.0k | #endif | 262 | 41.0k | } |
pei-arm.c:coff_swap_scnhdr_in Line | Count | Source | 211 | 56.4k | { | 212 | 56.4k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 213 | 56.4k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 214 | | | 215 | 56.4k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 216 | | | 217 | 56.4k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 218 | 56.4k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 219 | 56.4k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 220 | 56.4k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 221 | 56.4k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 222 | 56.4k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 223 | 56.4k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 224 | | | 225 | | /* MS handles overflow of line numbers by carrying into the reloc | 226 | | field (it appears). Since it's supposed to be zero for PE | 227 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 228 | 56.4k | #ifdef COFF_IMAGE_WITH_PE | 229 | 56.4k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 230 | 56.4k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 231 | 56.4k | scnhdr_int->s_nreloc = 0; | 232 | | #else | 233 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 234 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 235 | | #endif | 236 | | | 237 | 56.4k | if (scnhdr_int->s_vaddr != 0) | 238 | 34.6k | { | 239 | 34.6k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 240 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 241 | 34.6k | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 242 | 34.6k | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 243 | 34.6k | scnhdr_int->s_vaddr &= 0xffffffff; | 244 | 34.6k | #endif | 245 | 34.6k | } | 246 | | | 247 | 56.4k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 248 | | /* If this section holds uninitialized data and is from an object file | 249 | | or from an executable image that has not initialized the field, | 250 | | or if the image is an executable file and the physical size is padded, | 251 | | use the virtual size (stored in s_paddr) instead. */ | 252 | 56.4k | if (scnhdr_int->s_paddr > 0 | 253 | 39.7k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 254 | 10.4k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 255 | 38.2k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 256 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 257 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 258 | | only works if it correctly holds the virtual size of the | 259 | | section. */ | 260 | 11.5k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 261 | 56.4k | #endif | 262 | 56.4k | } |
pei-mcore.c:coff_swap_scnhdr_in Line | Count | Source | 211 | 52.1k | { | 212 | 52.1k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 213 | 52.1k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 214 | | | 215 | 52.1k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 216 | | | 217 | 52.1k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 218 | 52.1k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 219 | 52.1k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 220 | 52.1k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 221 | 52.1k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 222 | 52.1k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 223 | 52.1k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 224 | | | 225 | | /* MS handles overflow of line numbers by carrying into the reloc | 226 | | field (it appears). Since it's supposed to be zero for PE | 227 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 228 | 52.1k | #ifdef COFF_IMAGE_WITH_PE | 229 | 52.1k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 230 | 52.1k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 231 | 52.1k | scnhdr_int->s_nreloc = 0; | 232 | | #else | 233 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 234 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 235 | | #endif | 236 | | | 237 | 52.1k | if (scnhdr_int->s_vaddr != 0) | 238 | 34.6k | { | 239 | 34.6k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 240 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 241 | 34.6k | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 242 | 34.6k | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 243 | 34.6k | scnhdr_int->s_vaddr &= 0xffffffff; | 244 | 34.6k | #endif | 245 | 34.6k | } | 246 | | | 247 | 52.1k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 248 | | /* If this section holds uninitialized data and is from an object file | 249 | | or from an executable image that has not initialized the field, | 250 | | or if the image is an executable file and the physical size is padded, | 251 | | use the virtual size (stored in s_paddr) instead. */ | 252 | 52.1k | if (scnhdr_int->s_paddr > 0 | 253 | 38.9k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 254 | 8.17k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 255 | 37.7k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 256 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 257 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 258 | | only works if it correctly holds the virtual size of the | 259 | | section. */ | 260 | 10.2k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 261 | 52.1k | #endif | 262 | 52.1k | } |
pei-sh.c:coff_swap_scnhdr_in Line | Count | Source | 211 | 41.3k | { | 212 | 41.3k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 213 | 41.3k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 214 | | | 215 | 41.3k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 216 | | | 217 | 41.3k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 218 | 41.3k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 219 | 41.3k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 220 | 41.3k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 221 | 41.3k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 222 | 41.3k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 223 | 41.3k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 224 | | | 225 | | /* MS handles overflow of line numbers by carrying into the reloc | 226 | | field (it appears). Since it's supposed to be zero for PE | 227 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 228 | 41.3k | #ifdef COFF_IMAGE_WITH_PE | 229 | 41.3k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 230 | 41.3k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 231 | 41.3k | scnhdr_int->s_nreloc = 0; | 232 | | #else | 233 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 234 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 235 | | #endif | 236 | | | 237 | 41.3k | if (scnhdr_int->s_vaddr != 0) | 238 | 27.6k | { | 239 | 27.6k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 240 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 241 | 27.6k | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 242 | 27.6k | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 243 | 27.6k | scnhdr_int->s_vaddr &= 0xffffffff; | 244 | 27.6k | #endif | 245 | 27.6k | } | 246 | | | 247 | 41.3k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 248 | | /* If this section holds uninitialized data and is from an object file | 249 | | or from an executable image that has not initialized the field, | 250 | | or if the image is an executable file and the physical size is padded, | 251 | | use the virtual size (stored in s_paddr) instead. */ | 252 | 41.3k | if (scnhdr_int->s_paddr > 0 | 253 | 30.6k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 254 | 8.34k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 255 | 29.6k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 256 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 257 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 258 | | only works if it correctly holds the virtual size of the | 259 | | section. */ | 260 | 10.1k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 261 | 41.3k | #endif | 262 | 41.3k | } |
|
263 | | |
264 | | static bool |
265 | | pe_mkobject (bfd *abfd) |
266 | 85.9k | { |
267 | | /* Some x86 code followed by an ascii string. */ |
268 | 85.9k | static const char default_dos_message[64] = { |
269 | 85.9k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, |
270 | 85.9k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, |
271 | 85.9k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, |
272 | 85.9k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, |
273 | 85.9k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, |
274 | 85.9k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, |
275 | 85.9k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, |
276 | 85.9k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
277 | | |
278 | 85.9k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); |
279 | 85.9k | abfd->tdata.pe_obj_data = pe; |
280 | 85.9k | if (pe == NULL) |
281 | 0 | return false; |
282 | | |
283 | 85.9k | pe->coff.pe = 1; |
284 | | |
285 | | /* in_reloc_p is architecture dependent. */ |
286 | 85.9k | pe->in_reloc_p = in_reloc_p; |
287 | | |
288 | 85.9k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); |
289 | | |
290 | 85.9k | bfd_coff_long_section_names (abfd) |
291 | 85.9k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; |
292 | | |
293 | 85.9k | return true; |
294 | 85.9k | } Line | Count | Source | 266 | 9.59k | { | 267 | | /* Some x86 code followed by an ascii string. */ | 268 | 9.59k | static const char default_dos_message[64] = { | 269 | 9.59k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 270 | 9.59k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 271 | 9.59k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 272 | 9.59k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 273 | 9.59k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 274 | 9.59k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 275 | 9.59k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 276 | 9.59k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 277 | | | 278 | 9.59k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 279 | 9.59k | abfd->tdata.pe_obj_data = pe; | 280 | 9.59k | if (pe == NULL) | 281 | 0 | return false; | 282 | | | 283 | 9.59k | pe->coff.pe = 1; | 284 | | | 285 | | /* in_reloc_p is architecture dependent. */ | 286 | 9.59k | pe->in_reloc_p = in_reloc_p; | 287 | | | 288 | 9.59k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 289 | | | 290 | 9.59k | bfd_coff_long_section_names (abfd) | 291 | 9.59k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 292 | | | 293 | | return true; | 294 | 9.59k | } |
Line | Count | Source | 266 | 6.60k | { | 267 | | /* Some x86 code followed by an ascii string. */ | 268 | 6.60k | static const char default_dos_message[64] = { | 269 | 6.60k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 270 | 6.60k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 271 | 6.60k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 272 | 6.60k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 273 | 6.60k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 274 | 6.60k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 275 | 6.60k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 276 | 6.60k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 277 | | | 278 | 6.60k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 279 | 6.60k | abfd->tdata.pe_obj_data = pe; | 280 | 6.60k | if (pe == NULL) | 281 | 0 | return false; | 282 | | | 283 | 6.60k | pe->coff.pe = 1; | 284 | | | 285 | | /* in_reloc_p is architecture dependent. */ | 286 | 6.60k | pe->in_reloc_p = in_reloc_p; | 287 | | | 288 | 6.60k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 289 | | | 290 | 6.60k | bfd_coff_long_section_names (abfd) | 291 | 6.60k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 292 | | | 293 | | return true; | 294 | 6.60k | } |
Line | Count | Source | 266 | 6.83k | { | 267 | | /* Some x86 code followed by an ascii string. */ | 268 | 6.83k | static const char default_dos_message[64] = { | 269 | 6.83k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 270 | 6.83k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 271 | 6.83k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 272 | 6.83k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 273 | 6.83k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 274 | 6.83k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 275 | 6.83k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 276 | 6.83k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 277 | | | 278 | 6.83k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 279 | 6.83k | abfd->tdata.pe_obj_data = pe; | 280 | 6.83k | if (pe == NULL) | 281 | 0 | return false; | 282 | | | 283 | 6.83k | pe->coff.pe = 1; | 284 | | | 285 | | /* in_reloc_p is architecture dependent. */ | 286 | 6.83k | pe->in_reloc_p = in_reloc_p; | 287 | | | 288 | 6.83k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 289 | | | 290 | 6.83k | bfd_coff_long_section_names (abfd) | 291 | 6.83k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 292 | | | 293 | | return true; | 294 | 6.83k | } |
Line | Count | Source | 266 | 3.20k | { | 267 | | /* Some x86 code followed by an ascii string. */ | 268 | 3.20k | static const char default_dos_message[64] = { | 269 | 3.20k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 270 | 3.20k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 271 | 3.20k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 272 | 3.20k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 273 | 3.20k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 274 | 3.20k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 275 | 3.20k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 276 | 3.20k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 277 | | | 278 | 3.20k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 279 | 3.20k | abfd->tdata.pe_obj_data = pe; | 280 | 3.20k | if (pe == NULL) | 281 | 0 | return false; | 282 | | | 283 | 3.20k | pe->coff.pe = 1; | 284 | | | 285 | | /* in_reloc_p is architecture dependent. */ | 286 | 3.20k | pe->in_reloc_p = in_reloc_p; | 287 | | | 288 | 3.20k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 289 | | | 290 | 3.20k | bfd_coff_long_section_names (abfd) | 291 | 3.20k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 292 | | | 293 | | return true; | 294 | 3.20k | } |
pei-aarch64.c:pe_mkobject Line | Count | Source | 266 | 6.77k | { | 267 | | /* Some x86 code followed by an ascii string. */ | 268 | 6.77k | static const char default_dos_message[64] = { | 269 | 6.77k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 270 | 6.77k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 271 | 6.77k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 272 | 6.77k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 273 | 6.77k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 274 | 6.77k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 275 | 6.77k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 276 | 6.77k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 277 | | | 278 | 6.77k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 279 | 6.77k | abfd->tdata.pe_obj_data = pe; | 280 | 6.77k | if (pe == NULL) | 281 | 0 | return false; | 282 | | | 283 | 6.77k | pe->coff.pe = 1; | 284 | | | 285 | | /* in_reloc_p is architecture dependent. */ | 286 | 6.77k | pe->in_reloc_p = in_reloc_p; | 287 | | | 288 | 6.77k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 289 | | | 290 | 6.77k | bfd_coff_long_section_names (abfd) | 291 | 6.77k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 292 | | | 293 | | return true; | 294 | 6.77k | } |
Line | Count | Source | 266 | 4.98k | { | 267 | | /* Some x86 code followed by an ascii string. */ | 268 | 4.98k | static const char default_dos_message[64] = { | 269 | 4.98k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 270 | 4.98k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 271 | 4.98k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 272 | 4.98k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 273 | 4.98k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 274 | 4.98k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 275 | 4.98k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 276 | 4.98k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 277 | | | 278 | 4.98k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 279 | 4.98k | abfd->tdata.pe_obj_data = pe; | 280 | 4.98k | if (pe == NULL) | 281 | 0 | return false; | 282 | | | 283 | 4.98k | pe->coff.pe = 1; | 284 | | | 285 | | /* in_reloc_p is architecture dependent. */ | 286 | 4.98k | pe->in_reloc_p = in_reloc_p; | 287 | | | 288 | 4.98k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 289 | | | 290 | 4.98k | bfd_coff_long_section_names (abfd) | 291 | 4.98k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 292 | | | 293 | | return true; | 294 | 4.98k | } |
pei-loongarch64.c:pe_mkobject Line | Count | Source | 266 | 5.57k | { | 267 | | /* Some x86 code followed by an ascii string. */ | 268 | 5.57k | static const char default_dos_message[64] = { | 269 | 5.57k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 270 | 5.57k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 271 | 5.57k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 272 | 5.57k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 273 | 5.57k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 274 | 5.57k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 275 | 5.57k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 276 | 5.57k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 277 | | | 278 | 5.57k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 279 | 5.57k | abfd->tdata.pe_obj_data = pe; | 280 | 5.57k | if (pe == NULL) | 281 | 0 | return false; | 282 | | | 283 | 5.57k | pe->coff.pe = 1; | 284 | | | 285 | | /* in_reloc_p is architecture dependent. */ | 286 | 5.57k | pe->in_reloc_p = in_reloc_p; | 287 | | | 288 | 5.57k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 289 | | | 290 | 5.57k | bfd_coff_long_section_names (abfd) | 291 | 5.57k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 292 | | | 293 | | return true; | 294 | 5.57k | } |
pei-riscv64.c:pe_mkobject Line | Count | Source | 266 | 5.35k | { | 267 | | /* Some x86 code followed by an ascii string. */ | 268 | 5.35k | static const char default_dos_message[64] = { | 269 | 5.35k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 270 | 5.35k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 271 | 5.35k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 272 | 5.35k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 273 | 5.35k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 274 | 5.35k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 275 | 5.35k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 276 | 5.35k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 277 | | | 278 | 5.35k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 279 | 5.35k | abfd->tdata.pe_obj_data = pe; | 280 | 5.35k | if (pe == NULL) | 281 | 0 | return false; | 282 | | | 283 | 5.35k | pe->coff.pe = 1; | 284 | | | 285 | | /* in_reloc_p is architecture dependent. */ | 286 | 5.35k | pe->in_reloc_p = in_reloc_p; | 287 | | | 288 | 5.35k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 289 | | | 290 | 5.35k | bfd_coff_long_section_names (abfd) | 291 | 5.35k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 292 | | | 293 | | return true; | 294 | 5.35k | } |
pe-arm-wince.c:pe_mkobject Line | Count | Source | 266 | 2.05k | { | 267 | | /* Some x86 code followed by an ascii string. */ | 268 | 2.05k | static const char default_dos_message[64] = { | 269 | 2.05k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 270 | 2.05k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 271 | 2.05k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 272 | 2.05k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 273 | 2.05k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 274 | 2.05k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 275 | 2.05k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 276 | 2.05k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 277 | | | 278 | 2.05k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 279 | 2.05k | abfd->tdata.pe_obj_data = pe; | 280 | 2.05k | if (pe == NULL) | 281 | 0 | return false; | 282 | | | 283 | 2.05k | pe->coff.pe = 1; | 284 | | | 285 | | /* in_reloc_p is architecture dependent. */ | 286 | 2.05k | pe->in_reloc_p = in_reloc_p; | 287 | | | 288 | 2.05k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 289 | | | 290 | 2.05k | bfd_coff_long_section_names (abfd) | 291 | 2.05k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 292 | | | 293 | | return true; | 294 | 2.05k | } |
Line | Count | Source | 266 | 2.05k | { | 267 | | /* Some x86 code followed by an ascii string. */ | 268 | 2.05k | static const char default_dos_message[64] = { | 269 | 2.05k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 270 | 2.05k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 271 | 2.05k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 272 | 2.05k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 273 | 2.05k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 274 | 2.05k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 275 | 2.05k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 276 | 2.05k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 277 | | | 278 | 2.05k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 279 | 2.05k | abfd->tdata.pe_obj_data = pe; | 280 | 2.05k | if (pe == NULL) | 281 | 0 | return false; | 282 | | | 283 | 2.05k | pe->coff.pe = 1; | 284 | | | 285 | | /* in_reloc_p is architecture dependent. */ | 286 | 2.05k | pe->in_reloc_p = in_reloc_p; | 287 | | | 288 | 2.05k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 289 | | | 290 | 2.05k | bfd_coff_long_section_names (abfd) | 291 | 2.05k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 292 | | | 293 | | return true; | 294 | 2.05k | } |
Line | Count | Source | 266 | 6.67k | { | 267 | | /* Some x86 code followed by an ascii string. */ | 268 | 6.67k | static const char default_dos_message[64] = { | 269 | 6.67k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 270 | 6.67k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 271 | 6.67k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 272 | 6.67k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 273 | 6.67k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 274 | 6.67k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 275 | 6.67k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 276 | 6.67k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 277 | | | 278 | 6.67k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 279 | 6.67k | abfd->tdata.pe_obj_data = pe; | 280 | 6.67k | if (pe == NULL) | 281 | 0 | return false; | 282 | | | 283 | 6.67k | pe->coff.pe = 1; | 284 | | | 285 | | /* in_reloc_p is architecture dependent. */ | 286 | 6.67k | pe->in_reloc_p = in_reloc_p; | 287 | | | 288 | 6.67k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 289 | | | 290 | 6.67k | bfd_coff_long_section_names (abfd) | 291 | 6.67k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 292 | | | 293 | | return true; | 294 | 6.67k | } |
Line | Count | Source | 266 | 2.68k | { | 267 | | /* Some x86 code followed by an ascii string. */ | 268 | 2.68k | static const char default_dos_message[64] = { | 269 | 2.68k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 270 | 2.68k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 271 | 2.68k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 272 | 2.68k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 273 | 2.68k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 274 | 2.68k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 275 | 2.68k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 276 | 2.68k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 277 | | | 278 | 2.68k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 279 | 2.68k | abfd->tdata.pe_obj_data = pe; | 280 | 2.68k | if (pe == NULL) | 281 | 0 | return false; | 282 | | | 283 | 2.68k | pe->coff.pe = 1; | 284 | | | 285 | | /* in_reloc_p is architecture dependent. */ | 286 | 2.68k | pe->in_reloc_p = in_reloc_p; | 287 | | | 288 | 2.68k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 289 | | | 290 | 2.68k | bfd_coff_long_section_names (abfd) | 291 | 2.68k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 292 | | | 293 | | return true; | 294 | 2.68k | } |
Line | Count | Source | 266 | 3.80k | { | 267 | | /* Some x86 code followed by an ascii string. */ | 268 | 3.80k | static const char default_dos_message[64] = { | 269 | 3.80k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 270 | 3.80k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 271 | 3.80k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 272 | 3.80k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 273 | 3.80k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 274 | 3.80k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 275 | 3.80k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 276 | 3.80k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 277 | | | 278 | 3.80k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 279 | 3.80k | abfd->tdata.pe_obj_data = pe; | 280 | 3.80k | if (pe == NULL) | 281 | 0 | return false; | 282 | | | 283 | 3.80k | pe->coff.pe = 1; | 284 | | | 285 | | /* in_reloc_p is architecture dependent. */ | 286 | 3.80k | pe->in_reloc_p = in_reloc_p; | 287 | | | 288 | 3.80k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 289 | | | 290 | 3.80k | bfd_coff_long_section_names (abfd) | 291 | 3.80k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 292 | | | 293 | | return true; | 294 | 3.80k | } |
pei-arm-wince.c:pe_mkobject Line | Count | Source | 266 | 4.86k | { | 267 | | /* Some x86 code followed by an ascii string. */ | 268 | 4.86k | static const char default_dos_message[64] = { | 269 | 4.86k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 270 | 4.86k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 271 | 4.86k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 272 | 4.86k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 273 | 4.86k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 274 | 4.86k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 275 | 4.86k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 276 | 4.86k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 277 | | | 278 | 4.86k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 279 | 4.86k | abfd->tdata.pe_obj_data = pe; | 280 | 4.86k | if (pe == NULL) | 281 | 0 | return false; | 282 | | | 283 | 4.86k | pe->coff.pe = 1; | 284 | | | 285 | | /* in_reloc_p is architecture dependent. */ | 286 | 4.86k | pe->in_reloc_p = in_reloc_p; | 287 | | | 288 | 4.86k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 289 | | | 290 | 4.86k | bfd_coff_long_section_names (abfd) | 291 | 4.86k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 292 | | | 293 | | return true; | 294 | 4.86k | } |
Line | Count | Source | 266 | 5.90k | { | 267 | | /* Some x86 code followed by an ascii string. */ | 268 | 5.90k | static const char default_dos_message[64] = { | 269 | 5.90k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 270 | 5.90k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 271 | 5.90k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 272 | 5.90k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 273 | 5.90k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 274 | 5.90k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 275 | 5.90k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 276 | 5.90k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 277 | | | 278 | 5.90k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 279 | 5.90k | abfd->tdata.pe_obj_data = pe; | 280 | 5.90k | if (pe == NULL) | 281 | 0 | return false; | 282 | | | 283 | 5.90k | pe->coff.pe = 1; | 284 | | | 285 | | /* in_reloc_p is architecture dependent. */ | 286 | 5.90k | pe->in_reloc_p = in_reloc_p; | 287 | | | 288 | 5.90k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 289 | | | 290 | 5.90k | bfd_coff_long_section_names (abfd) | 291 | 5.90k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 292 | | | 293 | | return true; | 294 | 5.90k | } |
Line | Count | Source | 266 | 4.53k | { | 267 | | /* Some x86 code followed by an ascii string. */ | 268 | 4.53k | static const char default_dos_message[64] = { | 269 | 4.53k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 270 | 4.53k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 271 | 4.53k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 272 | 4.53k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 273 | 4.53k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 274 | 4.53k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 275 | 4.53k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 276 | 4.53k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 277 | | | 278 | 4.53k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 279 | 4.53k | abfd->tdata.pe_obj_data = pe; | 280 | 4.53k | if (pe == NULL) | 281 | 0 | return false; | 282 | | | 283 | 4.53k | pe->coff.pe = 1; | 284 | | | 285 | | /* in_reloc_p is architecture dependent. */ | 286 | 4.53k | pe->in_reloc_p = in_reloc_p; | 287 | | | 288 | 4.53k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 289 | | | 290 | 4.53k | bfd_coff_long_section_names (abfd) | 291 | 4.53k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 292 | | | 293 | | return true; | 294 | 4.53k | } |
Line | Count | Source | 266 | 4.47k | { | 267 | | /* Some x86 code followed by an ascii string. */ | 268 | 4.47k | static const char default_dos_message[64] = { | 269 | 4.47k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 270 | 4.47k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 271 | 4.47k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 272 | 4.47k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 273 | 4.47k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 274 | 4.47k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 275 | 4.47k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 276 | 4.47k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 277 | | | 278 | 4.47k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 279 | 4.47k | abfd->tdata.pe_obj_data = pe; | 280 | 4.47k | if (pe == NULL) | 281 | 0 | return false; | 282 | | | 283 | 4.47k | pe->coff.pe = 1; | 284 | | | 285 | | /* in_reloc_p is architecture dependent. */ | 286 | 4.47k | pe->in_reloc_p = in_reloc_p; | 287 | | | 288 | 4.47k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 289 | | | 290 | 4.47k | bfd_coff_long_section_names (abfd) | 291 | 4.47k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 292 | | | 293 | | return true; | 294 | 4.47k | } |
|
295 | | |
296 | | /* Create the COFF backend specific information. */ |
297 | | |
298 | | static void * |
299 | | pe_mkobject_hook (bfd *abfd, |
300 | | void *filehdr, |
301 | | void *aouthdr ATTRIBUTE_UNUSED) |
302 | 84.9k | { |
303 | 84.9k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; |
304 | 84.9k | pe_data_type *pe; |
305 | | |
306 | 84.9k | if (! pe_mkobject (abfd)) |
307 | 0 | return NULL; |
308 | | |
309 | 84.9k | pe = pe_data (abfd); |
310 | 84.9k | pe->coff.sym_filepos = internal_f->f_symptr; |
311 | | /* These members communicate important constants about the symbol |
312 | | table to GDB's symbol-reading code. These `constants' |
313 | | unfortunately vary among coff implementations... */ |
314 | 84.9k | pe->coff.local_n_btmask = N_BTMASK; |
315 | 84.9k | pe->coff.local_n_btshft = N_BTSHFT; |
316 | 84.9k | pe->coff.local_n_tmask = N_TMASK; |
317 | 84.9k | pe->coff.local_n_tshift = N_TSHIFT; |
318 | 84.9k | pe->coff.local_symesz = SYMESZ; |
319 | 84.9k | pe->coff.local_auxesz = AUXESZ; |
320 | 84.9k | pe->coff.local_linesz = LINESZ; |
321 | | |
322 | 84.9k | pe->coff.timestamp = internal_f->f_timdat; |
323 | | |
324 | 84.9k | obj_raw_syment_count (abfd) = |
325 | 84.9k | obj_conv_table_size (abfd) = |
326 | 84.9k | internal_f->f_nsyms; |
327 | | |
328 | 84.9k | pe->real_flags = internal_f->f_flags; |
329 | | |
330 | 84.9k | if ((internal_f->f_flags & F_DLL) != 0) |
331 | 26.0k | pe->dll = 1; |
332 | | |
333 | 84.9k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) |
334 | 61.1k | abfd->flags |= HAS_DEBUG; |
335 | | |
336 | | #ifdef COFF_IMAGE_WITH_PE |
337 | 58.2k | if (aouthdr) |
338 | 32.4k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; |
339 | | #endif |
340 | | |
341 | | #ifdef ARM |
342 | 14.7k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) |
343 | 0 | coff_data (abfd) ->flags = 0; |
344 | | #endif |
345 | | |
346 | 84.9k | memcpy (pe->dos_message, internal_f->pe.dos_message, |
347 | 84.9k | sizeof (pe->dos_message)); |
348 | | |
349 | 84.9k | return (void *) pe; |
350 | 84.9k | } pei-i386.c:pe_mkobject_hook Line | Count | Source | 302 | 9.53k | { | 303 | 9.53k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 304 | 9.53k | pe_data_type *pe; | 305 | | | 306 | 9.53k | if (! pe_mkobject (abfd)) | 307 | 0 | return NULL; | 308 | | | 309 | 9.53k | pe = pe_data (abfd); | 310 | 9.53k | pe->coff.sym_filepos = internal_f->f_symptr; | 311 | | /* These members communicate important constants about the symbol | 312 | | table to GDB's symbol-reading code. These `constants' | 313 | | unfortunately vary among coff implementations... */ | 314 | 9.53k | pe->coff.local_n_btmask = N_BTMASK; | 315 | 9.53k | pe->coff.local_n_btshft = N_BTSHFT; | 316 | 9.53k | pe->coff.local_n_tmask = N_TMASK; | 317 | 9.53k | pe->coff.local_n_tshift = N_TSHIFT; | 318 | 9.53k | pe->coff.local_symesz = SYMESZ; | 319 | 9.53k | pe->coff.local_auxesz = AUXESZ; | 320 | 9.53k | pe->coff.local_linesz = LINESZ; | 321 | | | 322 | 9.53k | pe->coff.timestamp = internal_f->f_timdat; | 323 | | | 324 | 9.53k | obj_raw_syment_count (abfd) = | 325 | 9.53k | obj_conv_table_size (abfd) = | 326 | 9.53k | internal_f->f_nsyms; | 327 | | | 328 | 9.53k | pe->real_flags = internal_f->f_flags; | 329 | | | 330 | 9.53k | if ((internal_f->f_flags & F_DLL) != 0) | 331 | 2.29k | pe->dll = 1; | 332 | | | 333 | 9.53k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 334 | 7.69k | abfd->flags |= HAS_DEBUG; | 335 | | | 336 | 9.53k | #ifdef COFF_IMAGE_WITH_PE | 337 | 9.53k | if (aouthdr) | 338 | 4.30k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 339 | 9.53k | #endif | 340 | | | 341 | | #ifdef ARM | 342 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 343 | | coff_data (abfd) ->flags = 0; | 344 | | #endif | 345 | | | 346 | 9.53k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 347 | 9.53k | sizeof (pe->dos_message)); | 348 | | | 349 | 9.53k | return (void *) pe; | 350 | 9.53k | } |
pe-x86_64.c:pe_mkobject_hook Line | Count | Source | 302 | 6.49k | { | 303 | 6.49k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 304 | 6.49k | pe_data_type *pe; | 305 | | | 306 | 6.49k | if (! pe_mkobject (abfd)) | 307 | 0 | return NULL; | 308 | | | 309 | 6.49k | pe = pe_data (abfd); | 310 | 6.49k | pe->coff.sym_filepos = internal_f->f_symptr; | 311 | | /* These members communicate important constants about the symbol | 312 | | table to GDB's symbol-reading code. These `constants' | 313 | | unfortunately vary among coff implementations... */ | 314 | 6.49k | pe->coff.local_n_btmask = N_BTMASK; | 315 | 6.49k | pe->coff.local_n_btshft = N_BTSHFT; | 316 | 6.49k | pe->coff.local_n_tmask = N_TMASK; | 317 | 6.49k | pe->coff.local_n_tshift = N_TSHIFT; | 318 | 6.49k | pe->coff.local_symesz = SYMESZ; | 319 | 6.49k | pe->coff.local_auxesz = AUXESZ; | 320 | 6.49k | pe->coff.local_linesz = LINESZ; | 321 | | | 322 | 6.49k | pe->coff.timestamp = internal_f->f_timdat; | 323 | | | 324 | 6.49k | obj_raw_syment_count (abfd) = | 325 | 6.49k | obj_conv_table_size (abfd) = | 326 | 6.49k | internal_f->f_nsyms; | 327 | | | 328 | 6.49k | pe->real_flags = internal_f->f_flags; | 329 | | | 330 | 6.49k | if ((internal_f->f_flags & F_DLL) != 0) | 331 | 1.49k | pe->dll = 1; | 332 | | | 333 | 6.49k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 334 | 5.05k | abfd->flags |= HAS_DEBUG; | 335 | | | 336 | | #ifdef COFF_IMAGE_WITH_PE | 337 | | if (aouthdr) | 338 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 339 | | #endif | 340 | | | 341 | | #ifdef ARM | 342 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 343 | | coff_data (abfd) ->flags = 0; | 344 | | #endif | 345 | | | 346 | 6.49k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 347 | 6.49k | sizeof (pe->dos_message)); | 348 | | | 349 | 6.49k | return (void *) pe; | 350 | 6.49k | } |
pei-x86_64.c:pe_mkobject_hook Line | Count | Source | 302 | 6.75k | { | 303 | 6.75k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 304 | 6.75k | pe_data_type *pe; | 305 | | | 306 | 6.75k | if (! pe_mkobject (abfd)) | 307 | 0 | return NULL; | 308 | | | 309 | 6.75k | pe = pe_data (abfd); | 310 | 6.75k | pe->coff.sym_filepos = internal_f->f_symptr; | 311 | | /* These members communicate important constants about the symbol | 312 | | table to GDB's symbol-reading code. These `constants' | 313 | | unfortunately vary among coff implementations... */ | 314 | 6.75k | pe->coff.local_n_btmask = N_BTMASK; | 315 | 6.75k | pe->coff.local_n_btshft = N_BTSHFT; | 316 | 6.75k | pe->coff.local_n_tmask = N_TMASK; | 317 | 6.75k | pe->coff.local_n_tshift = N_TSHIFT; | 318 | 6.75k | pe->coff.local_symesz = SYMESZ; | 319 | 6.75k | pe->coff.local_auxesz = AUXESZ; | 320 | 6.75k | pe->coff.local_linesz = LINESZ; | 321 | | | 322 | 6.75k | pe->coff.timestamp = internal_f->f_timdat; | 323 | | | 324 | 6.75k | obj_raw_syment_count (abfd) = | 325 | 6.75k | obj_conv_table_size (abfd) = | 326 | 6.75k | internal_f->f_nsyms; | 327 | | | 328 | 6.75k | pe->real_flags = internal_f->f_flags; | 329 | | | 330 | 6.75k | if ((internal_f->f_flags & F_DLL) != 0) | 331 | 2.83k | pe->dll = 1; | 332 | | | 333 | 6.75k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 334 | 4.28k | abfd->flags |= HAS_DEBUG; | 335 | | | 336 | 6.75k | #ifdef COFF_IMAGE_WITH_PE | 337 | 6.75k | if (aouthdr) | 338 | 3.92k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 339 | 6.75k | #endif | 340 | | | 341 | | #ifdef ARM | 342 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 343 | | coff_data (abfd) ->flags = 0; | 344 | | #endif | 345 | | | 346 | 6.75k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 347 | 6.75k | sizeof (pe->dos_message)); | 348 | | | 349 | 6.75k | return (void *) pe; | 350 | 6.75k | } |
pe-aarch64.c:pe_mkobject_hook Line | Count | Source | 302 | 3.12k | { | 303 | 3.12k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 304 | 3.12k | pe_data_type *pe; | 305 | | | 306 | 3.12k | if (! pe_mkobject (abfd)) | 307 | 0 | return NULL; | 308 | | | 309 | 3.12k | pe = pe_data (abfd); | 310 | 3.12k | pe->coff.sym_filepos = internal_f->f_symptr; | 311 | | /* These members communicate important constants about the symbol | 312 | | table to GDB's symbol-reading code. These `constants' | 313 | | unfortunately vary among coff implementations... */ | 314 | 3.12k | pe->coff.local_n_btmask = N_BTMASK; | 315 | 3.12k | pe->coff.local_n_btshft = N_BTSHFT; | 316 | 3.12k | pe->coff.local_n_tmask = N_TMASK; | 317 | 3.12k | pe->coff.local_n_tshift = N_TSHIFT; | 318 | 3.12k | pe->coff.local_symesz = SYMESZ; | 319 | 3.12k | pe->coff.local_auxesz = AUXESZ; | 320 | 3.12k | pe->coff.local_linesz = LINESZ; | 321 | | | 322 | 3.12k | pe->coff.timestamp = internal_f->f_timdat; | 323 | | | 324 | 3.12k | obj_raw_syment_count (abfd) = | 325 | 3.12k | obj_conv_table_size (abfd) = | 326 | 3.12k | internal_f->f_nsyms; | 327 | | | 328 | 3.12k | pe->real_flags = internal_f->f_flags; | 329 | | | 330 | 3.12k | if ((internal_f->f_flags & F_DLL) != 0) | 331 | 924 | pe->dll = 1; | 332 | | | 333 | 3.12k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 334 | 2.40k | abfd->flags |= HAS_DEBUG; | 335 | | | 336 | | #ifdef COFF_IMAGE_WITH_PE | 337 | | if (aouthdr) | 338 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 339 | | #endif | 340 | | | 341 | | #ifdef ARM | 342 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 343 | | coff_data (abfd) ->flags = 0; | 344 | | #endif | 345 | | | 346 | 3.12k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 347 | 3.12k | sizeof (pe->dos_message)); | 348 | | | 349 | 3.12k | return (void *) pe; | 350 | 3.12k | } |
pei-aarch64.c:pe_mkobject_hook Line | Count | Source | 302 | 6.74k | { | 303 | 6.74k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 304 | 6.74k | pe_data_type *pe; | 305 | | | 306 | 6.74k | if (! pe_mkobject (abfd)) | 307 | 0 | return NULL; | 308 | | | 309 | 6.74k | pe = pe_data (abfd); | 310 | 6.74k | pe->coff.sym_filepos = internal_f->f_symptr; | 311 | | /* These members communicate important constants about the symbol | 312 | | table to GDB's symbol-reading code. These `constants' | 313 | | unfortunately vary among coff implementations... */ | 314 | 6.74k | pe->coff.local_n_btmask = N_BTMASK; | 315 | 6.74k | pe->coff.local_n_btshft = N_BTSHFT; | 316 | 6.74k | pe->coff.local_n_tmask = N_TMASK; | 317 | 6.74k | pe->coff.local_n_tshift = N_TSHIFT; | 318 | 6.74k | pe->coff.local_symesz = SYMESZ; | 319 | 6.74k | pe->coff.local_auxesz = AUXESZ; | 320 | 6.74k | pe->coff.local_linesz = LINESZ; | 321 | | | 322 | 6.74k | pe->coff.timestamp = internal_f->f_timdat; | 323 | | | 324 | 6.74k | obj_raw_syment_count (abfd) = | 325 | 6.74k | obj_conv_table_size (abfd) = | 326 | 6.74k | internal_f->f_nsyms; | 327 | | | 328 | 6.74k | pe->real_flags = internal_f->f_flags; | 329 | | | 330 | 6.74k | if ((internal_f->f_flags & F_DLL) != 0) | 331 | 1.67k | pe->dll = 1; | 332 | | | 333 | 6.74k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 334 | 5.27k | abfd->flags |= HAS_DEBUG; | 335 | | | 336 | 6.74k | #ifdef COFF_IMAGE_WITH_PE | 337 | 6.74k | if (aouthdr) | 338 | 5.02k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 339 | 6.74k | #endif | 340 | | | 341 | | #ifdef ARM | 342 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 343 | | coff_data (abfd) ->flags = 0; | 344 | | #endif | 345 | | | 346 | 6.74k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 347 | 6.74k | sizeof (pe->dos_message)); | 348 | | | 349 | 6.74k | return (void *) pe; | 350 | 6.74k | } |
pei-ia64.c:pe_mkobject_hook Line | Count | Source | 302 | 4.92k | { | 303 | 4.92k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 304 | 4.92k | pe_data_type *pe; | 305 | | | 306 | 4.92k | if (! pe_mkobject (abfd)) | 307 | 0 | return NULL; | 308 | | | 309 | 4.92k | pe = pe_data (abfd); | 310 | 4.92k | pe->coff.sym_filepos = internal_f->f_symptr; | 311 | | /* These members communicate important constants about the symbol | 312 | | table to GDB's symbol-reading code. These `constants' | 313 | | unfortunately vary among coff implementations... */ | 314 | 4.92k | pe->coff.local_n_btmask = N_BTMASK; | 315 | 4.92k | pe->coff.local_n_btshft = N_BTSHFT; | 316 | 4.92k | pe->coff.local_n_tmask = N_TMASK; | 317 | 4.92k | pe->coff.local_n_tshift = N_TSHIFT; | 318 | 4.92k | pe->coff.local_symesz = SYMESZ; | 319 | 4.92k | pe->coff.local_auxesz = AUXESZ; | 320 | 4.92k | pe->coff.local_linesz = LINESZ; | 321 | | | 322 | 4.92k | pe->coff.timestamp = internal_f->f_timdat; | 323 | | | 324 | 4.92k | obj_raw_syment_count (abfd) = | 325 | 4.92k | obj_conv_table_size (abfd) = | 326 | 4.92k | internal_f->f_nsyms; | 327 | | | 328 | 4.92k | pe->real_flags = internal_f->f_flags; | 329 | | | 330 | 4.92k | if ((internal_f->f_flags & F_DLL) != 0) | 331 | 1.60k | pe->dll = 1; | 332 | | | 333 | 4.92k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 334 | 3.20k | abfd->flags |= HAS_DEBUG; | 335 | | | 336 | 4.92k | #ifdef COFF_IMAGE_WITH_PE | 337 | 4.92k | if (aouthdr) | 338 | 2.11k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 339 | 4.92k | #endif | 340 | | | 341 | | #ifdef ARM | 342 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 343 | | coff_data (abfd) ->flags = 0; | 344 | | #endif | 345 | | | 346 | 4.92k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 347 | 4.92k | sizeof (pe->dos_message)); | 348 | | | 349 | 4.92k | return (void *) pe; | 350 | 4.92k | } |
pei-loongarch64.c:pe_mkobject_hook Line | Count | Source | 302 | 5.49k | { | 303 | 5.49k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 304 | 5.49k | pe_data_type *pe; | 305 | | | 306 | 5.49k | if (! pe_mkobject (abfd)) | 307 | 0 | return NULL; | 308 | | | 309 | 5.49k | pe = pe_data (abfd); | 310 | 5.49k | pe->coff.sym_filepos = internal_f->f_symptr; | 311 | | /* These members communicate important constants about the symbol | 312 | | table to GDB's symbol-reading code. These `constants' | 313 | | unfortunately vary among coff implementations... */ | 314 | 5.49k | pe->coff.local_n_btmask = N_BTMASK; | 315 | 5.49k | pe->coff.local_n_btshft = N_BTSHFT; | 316 | 5.49k | pe->coff.local_n_tmask = N_TMASK; | 317 | 5.49k | pe->coff.local_n_tshift = N_TSHIFT; | 318 | 5.49k | pe->coff.local_symesz = SYMESZ; | 319 | 5.49k | pe->coff.local_auxesz = AUXESZ; | 320 | 5.49k | pe->coff.local_linesz = LINESZ; | 321 | | | 322 | 5.49k | pe->coff.timestamp = internal_f->f_timdat; | 323 | | | 324 | 5.49k | obj_raw_syment_count (abfd) = | 325 | 5.49k | obj_conv_table_size (abfd) = | 326 | 5.49k | internal_f->f_nsyms; | 327 | | | 328 | 5.49k | pe->real_flags = internal_f->f_flags; | 329 | | | 330 | 5.49k | if ((internal_f->f_flags & F_DLL) != 0) | 331 | 1.51k | pe->dll = 1; | 332 | | | 333 | 5.49k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 334 | 3.86k | abfd->flags |= HAS_DEBUG; | 335 | | | 336 | 5.49k | #ifdef COFF_IMAGE_WITH_PE | 337 | 5.49k | if (aouthdr) | 338 | 3.62k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 339 | 5.49k | #endif | 340 | | | 341 | | #ifdef ARM | 342 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 343 | | coff_data (abfd) ->flags = 0; | 344 | | #endif | 345 | | | 346 | 5.49k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 347 | 5.49k | sizeof (pe->dos_message)); | 348 | | | 349 | 5.49k | return (void *) pe; | 350 | 5.49k | } |
pei-riscv64.c:pe_mkobject_hook Line | Count | Source | 302 | 5.21k | { | 303 | 5.21k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 304 | 5.21k | pe_data_type *pe; | 305 | | | 306 | 5.21k | if (! pe_mkobject (abfd)) | 307 | 0 | return NULL; | 308 | | | 309 | 5.21k | pe = pe_data (abfd); | 310 | 5.21k | pe->coff.sym_filepos = internal_f->f_symptr; | 311 | | /* These members communicate important constants about the symbol | 312 | | table to GDB's symbol-reading code. These `constants' | 313 | | unfortunately vary among coff implementations... */ | 314 | 5.21k | pe->coff.local_n_btmask = N_BTMASK; | 315 | 5.21k | pe->coff.local_n_btshft = N_BTSHFT; | 316 | 5.21k | pe->coff.local_n_tmask = N_TMASK; | 317 | 5.21k | pe->coff.local_n_tshift = N_TSHIFT; | 318 | 5.21k | pe->coff.local_symesz = SYMESZ; | 319 | 5.21k | pe->coff.local_auxesz = AUXESZ; | 320 | 5.21k | pe->coff.local_linesz = LINESZ; | 321 | | | 322 | 5.21k | pe->coff.timestamp = internal_f->f_timdat; | 323 | | | 324 | 5.21k | obj_raw_syment_count (abfd) = | 325 | 5.21k | obj_conv_table_size (abfd) = | 326 | 5.21k | internal_f->f_nsyms; | 327 | | | 328 | 5.21k | pe->real_flags = internal_f->f_flags; | 329 | | | 330 | 5.21k | if ((internal_f->f_flags & F_DLL) != 0) | 331 | 1.55k | pe->dll = 1; | 332 | | | 333 | 5.21k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 334 | 3.71k | abfd->flags |= HAS_DEBUG; | 335 | | | 336 | 5.21k | #ifdef COFF_IMAGE_WITH_PE | 337 | 5.21k | if (aouthdr) | 338 | 3.76k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 339 | 5.21k | #endif | 340 | | | 341 | | #ifdef ARM | 342 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 343 | | coff_data (abfd) ->flags = 0; | 344 | | #endif | 345 | | | 346 | 5.21k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 347 | 5.21k | sizeof (pe->dos_message)); | 348 | | | 349 | 5.21k | return (void *) pe; | 350 | 5.21k | } |
pe-arm-wince.c:pe_mkobject_hook Line | Count | Source | 302 | 2.05k | { | 303 | 2.05k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 304 | 2.05k | pe_data_type *pe; | 305 | | | 306 | 2.05k | if (! pe_mkobject (abfd)) | 307 | 0 | return NULL; | 308 | | | 309 | 2.05k | pe = pe_data (abfd); | 310 | 2.05k | pe->coff.sym_filepos = internal_f->f_symptr; | 311 | | /* These members communicate important constants about the symbol | 312 | | table to GDB's symbol-reading code. These `constants' | 313 | | unfortunately vary among coff implementations... */ | 314 | 2.05k | pe->coff.local_n_btmask = N_BTMASK; | 315 | 2.05k | pe->coff.local_n_btshft = N_BTSHFT; | 316 | 2.05k | pe->coff.local_n_tmask = N_TMASK; | 317 | 2.05k | pe->coff.local_n_tshift = N_TSHIFT; | 318 | 2.05k | pe->coff.local_symesz = SYMESZ; | 319 | 2.05k | pe->coff.local_auxesz = AUXESZ; | 320 | 2.05k | pe->coff.local_linesz = LINESZ; | 321 | | | 322 | 2.05k | pe->coff.timestamp = internal_f->f_timdat; | 323 | | | 324 | 2.05k | obj_raw_syment_count (abfd) = | 325 | 2.05k | obj_conv_table_size (abfd) = | 326 | 2.05k | internal_f->f_nsyms; | 327 | | | 328 | 2.05k | pe->real_flags = internal_f->f_flags; | 329 | | | 330 | 2.05k | if ((internal_f->f_flags & F_DLL) != 0) | 331 | 553 | pe->dll = 1; | 332 | | | 333 | 2.05k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 334 | 1.48k | abfd->flags |= HAS_DEBUG; | 335 | | | 336 | | #ifdef COFF_IMAGE_WITH_PE | 337 | | if (aouthdr) | 338 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 339 | | #endif | 340 | | | 341 | 2.05k | #ifdef ARM | 342 | 2.05k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 343 | 0 | coff_data (abfd) ->flags = 0; | 344 | 2.05k | #endif | 345 | | | 346 | 2.05k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 347 | 2.05k | sizeof (pe->dos_message)); | 348 | | | 349 | 2.05k | return (void *) pe; | 350 | 2.05k | } |
pe-arm.c:pe_mkobject_hook Line | Count | Source | 302 | 2.05k | { | 303 | 2.05k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 304 | 2.05k | pe_data_type *pe; | 305 | | | 306 | 2.05k | if (! pe_mkobject (abfd)) | 307 | 0 | return NULL; | 308 | | | 309 | 2.05k | pe = pe_data (abfd); | 310 | 2.05k | pe->coff.sym_filepos = internal_f->f_symptr; | 311 | | /* These members communicate important constants about the symbol | 312 | | table to GDB's symbol-reading code. These `constants' | 313 | | unfortunately vary among coff implementations... */ | 314 | 2.05k | pe->coff.local_n_btmask = N_BTMASK; | 315 | 2.05k | pe->coff.local_n_btshft = N_BTSHFT; | 316 | 2.05k | pe->coff.local_n_tmask = N_TMASK; | 317 | 2.05k | pe->coff.local_n_tshift = N_TSHIFT; | 318 | 2.05k | pe->coff.local_symesz = SYMESZ; | 319 | 2.05k | pe->coff.local_auxesz = AUXESZ; | 320 | 2.05k | pe->coff.local_linesz = LINESZ; | 321 | | | 322 | 2.05k | pe->coff.timestamp = internal_f->f_timdat; | 323 | | | 324 | 2.05k | obj_raw_syment_count (abfd) = | 325 | 2.05k | obj_conv_table_size (abfd) = | 326 | 2.05k | internal_f->f_nsyms; | 327 | | | 328 | 2.05k | pe->real_flags = internal_f->f_flags; | 329 | | | 330 | 2.05k | if ((internal_f->f_flags & F_DLL) != 0) | 331 | 553 | pe->dll = 1; | 332 | | | 333 | 2.05k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 334 | 1.48k | abfd->flags |= HAS_DEBUG; | 335 | | | 336 | | #ifdef COFF_IMAGE_WITH_PE | 337 | | if (aouthdr) | 338 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 339 | | #endif | 340 | | | 341 | 2.05k | #ifdef ARM | 342 | 2.05k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 343 | 0 | coff_data (abfd) ->flags = 0; | 344 | 2.05k | #endif | 345 | | | 346 | 2.05k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 347 | 2.05k | sizeof (pe->dos_message)); | 348 | | | 349 | 2.05k | return (void *) pe; | 350 | 2.05k | } |
pe-i386.c:pe_mkobject_hook Line | Count | Source | 302 | 6.64k | { | 303 | 6.64k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 304 | 6.64k | pe_data_type *pe; | 305 | | | 306 | 6.64k | if (! pe_mkobject (abfd)) | 307 | 0 | return NULL; | 308 | | | 309 | 6.64k | pe = pe_data (abfd); | 310 | 6.64k | pe->coff.sym_filepos = internal_f->f_symptr; | 311 | | /* These members communicate important constants about the symbol | 312 | | table to GDB's symbol-reading code. These `constants' | 313 | | unfortunately vary among coff implementations... */ | 314 | 6.64k | pe->coff.local_n_btmask = N_BTMASK; | 315 | 6.64k | pe->coff.local_n_btshft = N_BTSHFT; | 316 | 6.64k | pe->coff.local_n_tmask = N_TMASK; | 317 | 6.64k | pe->coff.local_n_tshift = N_TSHIFT; | 318 | 6.64k | pe->coff.local_symesz = SYMESZ; | 319 | 6.64k | pe->coff.local_auxesz = AUXESZ; | 320 | 6.64k | pe->coff.local_linesz = LINESZ; | 321 | | | 322 | 6.64k | pe->coff.timestamp = internal_f->f_timdat; | 323 | | | 324 | 6.64k | obj_raw_syment_count (abfd) = | 325 | 6.64k | obj_conv_table_size (abfd) = | 326 | 6.64k | internal_f->f_nsyms; | 327 | | | 328 | 6.64k | pe->real_flags = internal_f->f_flags; | 329 | | | 330 | 6.64k | if ((internal_f->f_flags & F_DLL) != 0) | 331 | 1.83k | pe->dll = 1; | 332 | | | 333 | 6.64k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 334 | 4.69k | abfd->flags |= HAS_DEBUG; | 335 | | | 336 | | #ifdef COFF_IMAGE_WITH_PE | 337 | | if (aouthdr) | 338 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 339 | | #endif | 340 | | | 341 | | #ifdef ARM | 342 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 343 | | coff_data (abfd) ->flags = 0; | 344 | | #endif | 345 | | | 346 | 6.64k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 347 | 6.64k | sizeof (pe->dos_message)); | 348 | | | 349 | 6.64k | return (void *) pe; | 350 | 6.64k | } |
pe-mcore.c:pe_mkobject_hook Line | Count | Source | 302 | 2.63k | { | 303 | 2.63k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 304 | 2.63k | pe_data_type *pe; | 305 | | | 306 | 2.63k | if (! pe_mkobject (abfd)) | 307 | 0 | return NULL; | 308 | | | 309 | 2.63k | pe = pe_data (abfd); | 310 | 2.63k | pe->coff.sym_filepos = internal_f->f_symptr; | 311 | | /* These members communicate important constants about the symbol | 312 | | table to GDB's symbol-reading code. These `constants' | 313 | | unfortunately vary among coff implementations... */ | 314 | 2.63k | pe->coff.local_n_btmask = N_BTMASK; | 315 | 2.63k | pe->coff.local_n_btshft = N_BTSHFT; | 316 | 2.63k | pe->coff.local_n_tmask = N_TMASK; | 317 | 2.63k | pe->coff.local_n_tshift = N_TSHIFT; | 318 | 2.63k | pe->coff.local_symesz = SYMESZ; | 319 | 2.63k | pe->coff.local_auxesz = AUXESZ; | 320 | 2.63k | pe->coff.local_linesz = LINESZ; | 321 | | | 322 | 2.63k | pe->coff.timestamp = internal_f->f_timdat; | 323 | | | 324 | 2.63k | obj_raw_syment_count (abfd) = | 325 | 2.63k | obj_conv_table_size (abfd) = | 326 | 2.63k | internal_f->f_nsyms; | 327 | | | 328 | 2.63k | pe->real_flags = internal_f->f_flags; | 329 | | | 330 | 2.63k | if ((internal_f->f_flags & F_DLL) != 0) | 331 | 917 | pe->dll = 1; | 332 | | | 333 | 2.63k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 334 | 2.12k | abfd->flags |= HAS_DEBUG; | 335 | | | 336 | | #ifdef COFF_IMAGE_WITH_PE | 337 | | if (aouthdr) | 338 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 339 | | #endif | 340 | | | 341 | | #ifdef ARM | 342 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 343 | | coff_data (abfd) ->flags = 0; | 344 | | #endif | 345 | | | 346 | 2.63k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 347 | 2.63k | sizeof (pe->dos_message)); | 348 | | | 349 | 2.63k | return (void *) pe; | 350 | 2.63k | } |
Line | Count | Source | 302 | 3.76k | { | 303 | 3.76k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 304 | 3.76k | pe_data_type *pe; | 305 | | | 306 | 3.76k | if (! pe_mkobject (abfd)) | 307 | 0 | return NULL; | 308 | | | 309 | 3.76k | pe = pe_data (abfd); | 310 | 3.76k | pe->coff.sym_filepos = internal_f->f_symptr; | 311 | | /* These members communicate important constants about the symbol | 312 | | table to GDB's symbol-reading code. These `constants' | 313 | | unfortunately vary among coff implementations... */ | 314 | 3.76k | pe->coff.local_n_btmask = N_BTMASK; | 315 | 3.76k | pe->coff.local_n_btshft = N_BTSHFT; | 316 | 3.76k | pe->coff.local_n_tmask = N_TMASK; | 317 | 3.76k | pe->coff.local_n_tshift = N_TSHIFT; | 318 | 3.76k | pe->coff.local_symesz = SYMESZ; | 319 | 3.76k | pe->coff.local_auxesz = AUXESZ; | 320 | 3.76k | pe->coff.local_linesz = LINESZ; | 321 | | | 322 | 3.76k | pe->coff.timestamp = internal_f->f_timdat; | 323 | | | 324 | 3.76k | obj_raw_syment_count (abfd) = | 325 | 3.76k | obj_conv_table_size (abfd) = | 326 | 3.76k | internal_f->f_nsyms; | 327 | | | 328 | 3.76k | pe->real_flags = internal_f->f_flags; | 329 | | | 330 | 3.76k | if ((internal_f->f_flags & F_DLL) != 0) | 331 | 1.17k | pe->dll = 1; | 332 | | | 333 | 3.76k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 334 | 2.92k | abfd->flags |= HAS_DEBUG; | 335 | | | 336 | | #ifdef COFF_IMAGE_WITH_PE | 337 | | if (aouthdr) | 338 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 339 | | #endif | 340 | | | 341 | | #ifdef ARM | 342 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 343 | | coff_data (abfd) ->flags = 0; | 344 | | #endif | 345 | | | 346 | 3.76k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 347 | 3.76k | sizeof (pe->dos_message)); | 348 | | | 349 | 3.76k | return (void *) pe; | 350 | 3.76k | } |
pei-arm-wince.c:pe_mkobject_hook Line | Count | Source | 302 | 4.83k | { | 303 | 4.83k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 304 | 4.83k | pe_data_type *pe; | 305 | | | 306 | 4.83k | if (! pe_mkobject (abfd)) | 307 | 0 | return NULL; | 308 | | | 309 | 4.83k | pe = pe_data (abfd); | 310 | 4.83k | pe->coff.sym_filepos = internal_f->f_symptr; | 311 | | /* These members communicate important constants about the symbol | 312 | | table to GDB's symbol-reading code. These `constants' | 313 | | unfortunately vary among coff implementations... */ | 314 | 4.83k | pe->coff.local_n_btmask = N_BTMASK; | 315 | 4.83k | pe->coff.local_n_btshft = N_BTSHFT; | 316 | 4.83k | pe->coff.local_n_tmask = N_TMASK; | 317 | 4.83k | pe->coff.local_n_tshift = N_TSHIFT; | 318 | 4.83k | pe->coff.local_symesz = SYMESZ; | 319 | 4.83k | pe->coff.local_auxesz = AUXESZ; | 320 | 4.83k | pe->coff.local_linesz = LINESZ; | 321 | | | 322 | 4.83k | pe->coff.timestamp = internal_f->f_timdat; | 323 | | | 324 | 4.83k | obj_raw_syment_count (abfd) = | 325 | 4.83k | obj_conv_table_size (abfd) = | 326 | 4.83k | internal_f->f_nsyms; | 327 | | | 328 | 4.83k | pe->real_flags = internal_f->f_flags; | 329 | | | 330 | 4.83k | if ((internal_f->f_flags & F_DLL) != 0) | 331 | 1.65k | pe->dll = 1; | 332 | | | 333 | 4.83k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 334 | 3.24k | abfd->flags |= HAS_DEBUG; | 335 | | | 336 | 4.83k | #ifdef COFF_IMAGE_WITH_PE | 337 | 4.83k | if (aouthdr) | 338 | 1.78k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 339 | 4.83k | #endif | 340 | | | 341 | 4.83k | #ifdef ARM | 342 | 4.83k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 343 | 0 | coff_data (abfd) ->flags = 0; | 344 | 4.83k | #endif | 345 | | | 346 | 4.83k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 347 | 4.83k | sizeof (pe->dos_message)); | 348 | | | 349 | 4.83k | return (void *) pe; | 350 | 4.83k | } |
pei-arm.c:pe_mkobject_hook Line | Count | Source | 302 | 5.83k | { | 303 | 5.83k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 304 | 5.83k | pe_data_type *pe; | 305 | | | 306 | 5.83k | if (! pe_mkobject (abfd)) | 307 | 0 | return NULL; | 308 | | | 309 | 5.83k | pe = pe_data (abfd); | 310 | 5.83k | pe->coff.sym_filepos = internal_f->f_symptr; | 311 | | /* These members communicate important constants about the symbol | 312 | | table to GDB's symbol-reading code. These `constants' | 313 | | unfortunately vary among coff implementations... */ | 314 | 5.83k | pe->coff.local_n_btmask = N_BTMASK; | 315 | 5.83k | pe->coff.local_n_btshft = N_BTSHFT; | 316 | 5.83k | pe->coff.local_n_tmask = N_TMASK; | 317 | 5.83k | pe->coff.local_n_tshift = N_TSHIFT; | 318 | 5.83k | pe->coff.local_symesz = SYMESZ; | 319 | 5.83k | pe->coff.local_auxesz = AUXESZ; | 320 | 5.83k | pe->coff.local_linesz = LINESZ; | 321 | | | 322 | 5.83k | pe->coff.timestamp = internal_f->f_timdat; | 323 | | | 324 | 5.83k | obj_raw_syment_count (abfd) = | 325 | 5.83k | obj_conv_table_size (abfd) = | 326 | 5.83k | internal_f->f_nsyms; | 327 | | | 328 | 5.83k | pe->real_flags = internal_f->f_flags; | 329 | | | 330 | 5.83k | if ((internal_f->f_flags & F_DLL) != 0) | 331 | 1.89k | pe->dll = 1; | 332 | | | 333 | 5.83k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 334 | 4.13k | abfd->flags |= HAS_DEBUG; | 335 | | | 336 | 5.83k | #ifdef COFF_IMAGE_WITH_PE | 337 | 5.83k | if (aouthdr) | 338 | 2.78k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 339 | 5.83k | #endif | 340 | | | 341 | 5.83k | #ifdef ARM | 342 | 5.83k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 343 | 0 | coff_data (abfd) ->flags = 0; | 344 | 5.83k | #endif | 345 | | | 346 | 5.83k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 347 | 5.83k | sizeof (pe->dos_message)); | 348 | | | 349 | 5.83k | return (void *) pe; | 350 | 5.83k | } |
pei-mcore.c:pe_mkobject_hook Line | Count | Source | 302 | 4.47k | { | 303 | 4.47k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 304 | 4.47k | pe_data_type *pe; | 305 | | | 306 | 4.47k | if (! pe_mkobject (abfd)) | 307 | 0 | return NULL; | 308 | | | 309 | 4.47k | pe = pe_data (abfd); | 310 | 4.47k | pe->coff.sym_filepos = internal_f->f_symptr; | 311 | | /* These members communicate important constants about the symbol | 312 | | table to GDB's symbol-reading code. These `constants' | 313 | | unfortunately vary among coff implementations... */ | 314 | 4.47k | pe->coff.local_n_btmask = N_BTMASK; | 315 | 4.47k | pe->coff.local_n_btshft = N_BTSHFT; | 316 | 4.47k | pe->coff.local_n_tmask = N_TMASK; | 317 | 4.47k | pe->coff.local_n_tshift = N_TSHIFT; | 318 | 4.47k | pe->coff.local_symesz = SYMESZ; | 319 | 4.47k | pe->coff.local_auxesz = AUXESZ; | 320 | 4.47k | pe->coff.local_linesz = LINESZ; | 321 | | | 322 | 4.47k | pe->coff.timestamp = internal_f->f_timdat; | 323 | | | 324 | 4.47k | obj_raw_syment_count (abfd) = | 325 | 4.47k | obj_conv_table_size (abfd) = | 326 | 4.47k | internal_f->f_nsyms; | 327 | | | 328 | 4.47k | pe->real_flags = internal_f->f_flags; | 329 | | | 330 | 4.47k | if ((internal_f->f_flags & F_DLL) != 0) | 331 | 1.76k | pe->dll = 1; | 332 | | | 333 | 4.47k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 334 | 2.84k | abfd->flags |= HAS_DEBUG; | 335 | | | 336 | 4.47k | #ifdef COFF_IMAGE_WITH_PE | 337 | 4.47k | if (aouthdr) | 338 | 2.55k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 339 | 4.47k | #endif | 340 | | | 341 | | #ifdef ARM | 342 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 343 | | coff_data (abfd) ->flags = 0; | 344 | | #endif | 345 | | | 346 | 4.47k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 347 | 4.47k | sizeof (pe->dos_message)); | 348 | | | 349 | 4.47k | return (void *) pe; | 350 | 4.47k | } |
pei-sh.c:pe_mkobject_hook Line | Count | Source | 302 | 4.39k | { | 303 | 4.39k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 304 | 4.39k | pe_data_type *pe; | 305 | | | 306 | 4.39k | if (! pe_mkobject (abfd)) | 307 | 0 | return NULL; | 308 | | | 309 | 4.39k | pe = pe_data (abfd); | 310 | 4.39k | pe->coff.sym_filepos = internal_f->f_symptr; | 311 | | /* These members communicate important constants about the symbol | 312 | | table to GDB's symbol-reading code. These `constants' | 313 | | unfortunately vary among coff implementations... */ | 314 | 4.39k | pe->coff.local_n_btmask = N_BTMASK; | 315 | 4.39k | pe->coff.local_n_btshft = N_BTSHFT; | 316 | 4.39k | pe->coff.local_n_tmask = N_TMASK; | 317 | 4.39k | pe->coff.local_n_tshift = N_TSHIFT; | 318 | 4.39k | pe->coff.local_symesz = SYMESZ; | 319 | 4.39k | pe->coff.local_auxesz = AUXESZ; | 320 | 4.39k | pe->coff.local_linesz = LINESZ; | 321 | | | 322 | 4.39k | pe->coff.timestamp = internal_f->f_timdat; | 323 | | | 324 | 4.39k | obj_raw_syment_count (abfd) = | 325 | 4.39k | obj_conv_table_size (abfd) = | 326 | 4.39k | internal_f->f_nsyms; | 327 | | | 328 | 4.39k | pe->real_flags = internal_f->f_flags; | 329 | | | 330 | 4.39k | if ((internal_f->f_flags & F_DLL) != 0) | 331 | 1.80k | pe->dll = 1; | 332 | | | 333 | 4.39k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 334 | 2.71k | abfd->flags |= HAS_DEBUG; | 335 | | | 336 | 4.39k | #ifdef COFF_IMAGE_WITH_PE | 337 | 4.39k | if (aouthdr) | 338 | 2.53k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 339 | 4.39k | #endif | 340 | | | 341 | | #ifdef ARM | 342 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 343 | | coff_data (abfd) ->flags = 0; | 344 | | #endif | 345 | | | 346 | 4.39k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 347 | 4.39k | sizeof (pe->dos_message)); | 348 | | | 349 | 4.39k | return (void *) pe; | 350 | 4.39k | } |
|
351 | | |
352 | | static bool |
353 | | pe_print_private_bfd_data (bfd *abfd, void *vfile) |
354 | 3.99k | { |
355 | 3.99k | FILE *file = (FILE *) vfile; |
356 | | |
357 | 3.99k | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) |
358 | 0 | return false; |
359 | | |
360 | 3.99k | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) |
361 | 3.83k | return true; |
362 | | |
363 | 159 | fputc ('\n', file); |
364 | | |
365 | 159 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); |
366 | 3.99k | } pei-i386.c:pe_print_private_bfd_data Line | Count | Source | 354 | 106 | { | 355 | 106 | FILE *file = (FILE *) vfile; | 356 | | | 357 | 106 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 358 | 0 | return false; | 359 | | | 360 | 106 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 361 | 106 | return true; | 362 | | | 363 | 0 | fputc ('\n', file); | 364 | |
| 365 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 366 | 106 | } |
pe-x86_64.c:pe_print_private_bfd_data Line | Count | Source | 354 | 150 | { | 355 | 150 | FILE *file = (FILE *) vfile; | 356 | | | 357 | 150 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 358 | 0 | return false; | 359 | | | 360 | 150 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 361 | 150 | return true; | 362 | | | 363 | 0 | fputc ('\n', file); | 364 | |
| 365 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 366 | 150 | } |
pei-x86_64.c:pe_print_private_bfd_data Line | Count | Source | 354 | 82 | { | 355 | 82 | FILE *file = (FILE *) vfile; | 356 | | | 357 | 82 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 358 | 0 | return false; | 359 | | | 360 | 82 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 361 | 82 | return true; | 362 | | | 363 | 0 | fputc ('\n', file); | 364 | |
| 365 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 366 | 82 | } |
pe-aarch64.c:pe_print_private_bfd_data Line | Count | Source | 354 | 448 | { | 355 | 448 | FILE *file = (FILE *) vfile; | 356 | | | 357 | 448 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 358 | 0 | return false; | 359 | | | 360 | 448 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 361 | 448 | return true; | 362 | | | 363 | 0 | fputc ('\n', file); | 364 | |
| 365 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 366 | 448 | } |
pei-aarch64.c:pe_print_private_bfd_data Line | Count | Source | 354 | 2.26k | { | 355 | 2.26k | FILE *file = (FILE *) vfile; | 356 | | | 357 | 2.26k | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 358 | 0 | return false; | 359 | | | 360 | 2.26k | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 361 | 2.26k | return true; | 362 | | | 363 | 0 | fputc ('\n', file); | 364 | |
| 365 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 366 | 2.26k | } |
pei-ia64.c:pe_print_private_bfd_data Line | Count | Source | 354 | 218 | { | 355 | 218 | FILE *file = (FILE *) vfile; | 356 | | | 357 | 218 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 358 | 0 | return false; | 359 | | | 360 | 218 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 361 | 218 | return true; | 362 | | | 363 | 0 | fputc ('\n', file); | 364 | |
| 365 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 366 | 218 | } |
pei-loongarch64.c:pe_print_private_bfd_data Line | Count | Source | 354 | 104 | { | 355 | 104 | FILE *file = (FILE *) vfile; | 356 | | | 357 | 104 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 358 | 0 | return false; | 359 | | | 360 | 104 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 361 | 104 | return true; | 362 | | | 363 | 0 | fputc ('\n', file); | 364 | |
| 365 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 366 | 104 | } |
pei-riscv64.c:pe_print_private_bfd_data Line | Count | Source | 354 | 208 | { | 355 | 208 | FILE *file = (FILE *) vfile; | 356 | | | 357 | 208 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 358 | 0 | return false; | 359 | | | 360 | 208 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 361 | 208 | return true; | 362 | | | 363 | 0 | fputc ('\n', file); | 364 | |
| 365 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 366 | 208 | } |
Unexecuted instantiation: pe-arm-wince.c:pe_print_private_bfd_data Unexecuted instantiation: pe-arm.c:pe_print_private_bfd_data pe-i386.c:pe_print_private_bfd_data Line | Count | Source | 354 | 43 | { | 355 | 43 | FILE *file = (FILE *) vfile; | 356 | | | 357 | 43 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 358 | 0 | return false; | 359 | | | 360 | 43 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 361 | 43 | return true; | 362 | | | 363 | 0 | fputc ('\n', file); | 364 | |
| 365 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 366 | 43 | } |
pe-mcore.c:pe_print_private_bfd_data Line | Count | Source | 354 | 32 | { | 355 | 32 | FILE *file = (FILE *) vfile; | 356 | | | 357 | 32 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 358 | 0 | return false; | 359 | | | 360 | 32 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 361 | 32 | return true; | 362 | | | 363 | 0 | fputc ('\n', file); | 364 | |
| 365 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 366 | 32 | } |
pe-sh.c:pe_print_private_bfd_data Line | Count | Source | 354 | 54 | { | 355 | 54 | FILE *file = (FILE *) vfile; | 356 | | | 357 | 54 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 358 | 0 | return false; | 359 | | | 360 | 54 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 361 | 54 | return true; | 362 | | | 363 | 0 | fputc ('\n', file); | 364 | |
| 365 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 366 | 54 | } |
pei-arm-wince.c:pe_print_private_bfd_data Line | Count | Source | 354 | 12 | { | 355 | 12 | FILE *file = (FILE *) vfile; | 356 | | | 357 | 12 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 358 | 0 | return false; | 359 | | | 360 | 12 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 361 | 0 | return true; | 362 | | | 363 | 12 | fputc ('\n', file); | 364 | | | 365 | 12 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 366 | 12 | } |
pei-arm.c:pe_print_private_bfd_data Line | Count | Source | 354 | 147 | { | 355 | 147 | FILE *file = (FILE *) vfile; | 356 | | | 357 | 147 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 358 | 0 | return false; | 359 | | | 360 | 147 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 361 | 0 | return true; | 362 | | | 363 | 147 | fputc ('\n', file); | 364 | | | 365 | 147 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 366 | 147 | } |
pei-mcore.c:pe_print_private_bfd_data Line | Count | Source | 354 | 64 | { | 355 | 64 | FILE *file = (FILE *) vfile; | 356 | | | 357 | 64 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 358 | 0 | return false; | 359 | | | 360 | 64 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 361 | 64 | return true; | 362 | | | 363 | 0 | fputc ('\n', file); | 364 | |
| 365 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 366 | 64 | } |
pei-sh.c:pe_print_private_bfd_data Line | Count | Source | 354 | 62 | { | 355 | 62 | FILE *file = (FILE *) vfile; | 356 | | | 357 | 62 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 358 | 0 | return false; | 359 | | | 360 | 62 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 361 | 62 | return true; | 362 | | | 363 | 0 | fputc ('\n', file); | 364 | |
| 365 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 366 | 62 | } |
|
367 | | |
368 | | /* Copy any private info we understand from the input bfd |
369 | | to the output bfd. */ |
370 | | |
371 | | static bool |
372 | | pe_bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd) |
373 | 79 | { |
374 | | /* PR binutils/716: Copy the large address aware flag. |
375 | | XXX: Should we be copying other flags or other fields in the pe_data() |
376 | | structure ? */ |
377 | 79 | if (pe_data (obfd) != NULL |
378 | 79 | && pe_data (ibfd) != NULL |
379 | 79 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) |
380 | 24 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; |
381 | | |
382 | 79 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) |
383 | 2 | return false; |
384 | | |
385 | 77 | if (pe_saved_coff_bfd_copy_private_bfd_data) |
386 | 11 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); |
387 | | |
388 | 66 | return true; |
389 | 77 | } pei-i386.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 373 | 5 | { | 374 | | /* PR binutils/716: Copy the large address aware flag. | 375 | | XXX: Should we be copying other flags or other fields in the pe_data() | 376 | | structure ? */ | 377 | 5 | if (pe_data (obfd) != NULL | 378 | 5 | && pe_data (ibfd) != NULL | 379 | 5 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 380 | 0 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 381 | | | 382 | 5 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 383 | 0 | return false; | 384 | | | 385 | 5 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 386 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 387 | | | 388 | 5 | return true; | 389 | 5 | } |
pe-x86_64.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 373 | 13 | { | 374 | | /* PR binutils/716: Copy the large address aware flag. | 375 | | XXX: Should we be copying other flags or other fields in the pe_data() | 376 | | structure ? */ | 377 | 13 | if (pe_data (obfd) != NULL | 378 | 13 | && pe_data (ibfd) != NULL | 379 | 13 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 380 | 2 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 381 | | | 382 | 13 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 383 | 0 | return false; | 384 | | | 385 | 13 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 386 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 387 | | | 388 | 13 | return true; | 389 | 13 | } |
pei-x86_64.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 373 | 18 | { | 374 | | /* PR binutils/716: Copy the large address aware flag. | 375 | | XXX: Should we be copying other flags or other fields in the pe_data() | 376 | | structure ? */ | 377 | 18 | if (pe_data (obfd) != NULL | 378 | 18 | && pe_data (ibfd) != NULL | 379 | 18 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 380 | 4 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 381 | | | 382 | 18 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 383 | 0 | return false; | 384 | | | 385 | 18 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 386 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 387 | | | 388 | 18 | return true; | 389 | 18 | } |
pe-aarch64.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 373 | 4 | { | 374 | | /* PR binutils/716: Copy the large address aware flag. | 375 | | XXX: Should we be copying other flags or other fields in the pe_data() | 376 | | structure ? */ | 377 | 4 | if (pe_data (obfd) != NULL | 378 | 4 | && pe_data (ibfd) != NULL | 379 | 4 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 380 | 0 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 381 | | | 382 | 4 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 383 | 0 | return false; | 384 | | | 385 | 4 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 386 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 387 | | | 388 | 4 | return true; | 389 | 4 | } |
Unexecuted instantiation: pei-aarch64.c:pe_bfd_copy_private_bfd_data pei-ia64.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 373 | 4 | { | 374 | | /* PR binutils/716: Copy the large address aware flag. | 375 | | XXX: Should we be copying other flags or other fields in the pe_data() | 376 | | structure ? */ | 377 | 4 | if (pe_data (obfd) != NULL | 378 | 4 | && pe_data (ibfd) != NULL | 379 | 4 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 380 | 4 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 381 | | | 382 | 4 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 383 | 2 | return false; | 384 | | | 385 | 2 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 386 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 387 | | | 388 | 2 | return true; | 389 | 2 | } |
Unexecuted instantiation: pei-loongarch64.c:pe_bfd_copy_private_bfd_data pei-riscv64.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 373 | 5 | { | 374 | | /* PR binutils/716: Copy the large address aware flag. | 375 | | XXX: Should we be copying other flags or other fields in the pe_data() | 376 | | structure ? */ | 377 | 5 | if (pe_data (obfd) != NULL | 378 | 5 | && pe_data (ibfd) != NULL | 379 | 5 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 380 | 0 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 381 | | | 382 | 5 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 383 | 0 | return false; | 384 | | | 385 | 5 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 386 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 387 | | | 388 | 5 | return true; | 389 | 5 | } |
Unexecuted instantiation: pe-arm-wince.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pe-arm.c:pe_bfd_copy_private_bfd_data pe-i386.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 373 | 1 | { | 374 | | /* PR binutils/716: Copy the large address aware flag. | 375 | | XXX: Should we be copying other flags or other fields in the pe_data() | 376 | | structure ? */ | 377 | 1 | if (pe_data (obfd) != NULL | 378 | 1 | && pe_data (ibfd) != NULL | 379 | 1 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 380 | 0 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 381 | | | 382 | 1 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 383 | 0 | return false; | 384 | | | 385 | 1 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 386 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 387 | | | 388 | 1 | return true; | 389 | 1 | } |
pe-mcore.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 373 | 1 | { | 374 | | /* PR binutils/716: Copy the large address aware flag. | 375 | | XXX: Should we be copying other flags or other fields in the pe_data() | 376 | | structure ? */ | 377 | 1 | if (pe_data (obfd) != NULL | 378 | 1 | && pe_data (ibfd) != NULL | 379 | 1 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 380 | 1 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 381 | | | 382 | 1 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 383 | 0 | return false; | 384 | | | 385 | 1 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 386 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 387 | | | 388 | 1 | return true; | 389 | 1 | } |
pe-sh.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 373 | 9 | { | 374 | | /* PR binutils/716: Copy the large address aware flag. | 375 | | XXX: Should we be copying other flags or other fields in the pe_data() | 376 | | structure ? */ | 377 | 9 | if (pe_data (obfd) != NULL | 378 | 9 | && pe_data (ibfd) != NULL | 379 | 9 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 380 | 0 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 381 | | | 382 | 9 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 383 | 0 | return false; | 384 | | | 385 | 9 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 386 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 387 | | | 388 | 9 | return true; | 389 | 9 | } |
pei-arm-wince.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 373 | 2 | { | 374 | | /* PR binutils/716: Copy the large address aware flag. | 375 | | XXX: Should we be copying other flags or other fields in the pe_data() | 376 | | structure ? */ | 377 | 2 | if (pe_data (obfd) != NULL | 378 | 2 | && pe_data (ibfd) != NULL | 379 | 2 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 380 | 2 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 381 | | | 382 | 2 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 383 | 0 | return false; | 384 | | | 385 | 2 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 386 | 2 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 387 | | | 388 | 0 | return true; | 389 | 2 | } |
pei-arm.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 373 | 9 | { | 374 | | /* PR binutils/716: Copy the large address aware flag. | 375 | | XXX: Should we be copying other flags or other fields in the pe_data() | 376 | | structure ? */ | 377 | 9 | if (pe_data (obfd) != NULL | 378 | 9 | && pe_data (ibfd) != NULL | 379 | 9 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 380 | 8 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 381 | | | 382 | 9 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 383 | 0 | return false; | 384 | | | 385 | 9 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 386 | 9 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 387 | | | 388 | 0 | return true; | 389 | 9 | } |
pei-mcore.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 373 | 2 | { | 374 | | /* PR binutils/716: Copy the large address aware flag. | 375 | | XXX: Should we be copying other flags or other fields in the pe_data() | 376 | | structure ? */ | 377 | 2 | if (pe_data (obfd) != NULL | 378 | 2 | && pe_data (ibfd) != NULL | 379 | 2 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 380 | 2 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 381 | | | 382 | 2 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 383 | 0 | return false; | 384 | | | 385 | 2 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 386 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 387 | | | 388 | 2 | return true; | 389 | 2 | } |
pei-sh.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 373 | 6 | { | 374 | | /* PR binutils/716: Copy the large address aware flag. | 375 | | XXX: Should we be copying other flags or other fields in the pe_data() | 376 | | structure ? */ | 377 | 6 | if (pe_data (obfd) != NULL | 378 | 6 | && pe_data (ibfd) != NULL | 379 | 6 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 380 | 1 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 381 | | | 382 | 6 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 383 | 0 | return false; | 384 | | | 385 | 6 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 386 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 387 | | | 388 | 6 | return true; | 389 | 6 | } |
|
390 | | |
391 | | #define coff_bfd_copy_private_section_data \ |
392 | | _bfd_XX_bfd_copy_private_section_data |
393 | | |
394 | | #define coff_get_symbol_info _bfd_XX_get_symbol_info |
395 | | |
396 | | #ifdef COFF_IMAGE_WITH_PE |
397 | | |
398 | | /* Code to handle Microsoft's Import Library Format. |
399 | | Also known as LINK6 format. |
400 | | Documentation about this format can be found at: |
401 | | |
402 | | https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#import-library-format */ |
403 | | |
404 | | /* The following constants specify the sizes of the various data |
405 | | structures that we have to create in order to build a bfd describing |
406 | | an ILF object file. The final "+ 1" in the definitions of SIZEOF_IDATA6 |
407 | | and SIZEOF_IDATA7 below is to allow for the possibility that we might |
408 | | need a padding byte in order to ensure 16 bit alignment for the section's |
409 | | contents. |
410 | | |
411 | | The value for SIZEOF_ILF_STRINGS is computed as follows: |
412 | | |
413 | | There will be NUM_ILF_SECTIONS section symbols. Allow 9 characters |
414 | | per symbol for their names (longest section name is .idata$x). |
415 | | |
416 | | There will be two symbols for the imported value, one the symbol name |
417 | | and one with _imp__ prefixed. Allowing for the terminating nul's this |
418 | | is strlen (symbol_name) * 2 + 8 + 21 + strlen (source_dll). |
419 | | |
420 | | The strings in the string table must start STRING__SIZE_SIZE bytes into |
421 | | the table in order to for the string lookup code in coffgen/coffcode to |
422 | | work. */ |
423 | 3.55k | #define NUM_ILF_RELOCS 8 |
424 | 11.8k | #define NUM_ILF_SECTIONS 6 |
425 | 8.89k | #define NUM_ILF_SYMS (2 + NUM_ILF_SECTIONS) |
426 | | |
427 | 1.77k | #define SIZEOF_ILF_SYMS (NUM_ILF_SYMS * sizeof (*vars.sym_cache)) |
428 | 1.77k | #define SIZEOF_ILF_SYM_TABLE (NUM_ILF_SYMS * sizeof (*vars.sym_table)) |
429 | 1.77k | #define SIZEOF_ILF_NATIVE_SYMS (NUM_ILF_SYMS * sizeof (*vars.native_syms)) |
430 | 1.77k | #define SIZEOF_ILF_SYM_PTR_TABLE (NUM_ILF_SYMS * sizeof (*vars.sym_ptr_table)) |
431 | 1.77k | #define SIZEOF_ILF_EXT_SYMS (NUM_ILF_SYMS * sizeof (*vars.esym_table)) |
432 | 1.77k | #define SIZEOF_ILF_RELOCS (NUM_ILF_RELOCS * sizeof (*vars.reltab)) |
433 | 1.77k | #define SIZEOF_ILF_INT_RELOCS (NUM_ILF_RELOCS * sizeof (*vars.int_reltab)) |
434 | 1.77k | #define SIZEOF_ILF_STRINGS (strlen (symbol_name) * 2 + 8 \ |
435 | 1.77k | + 21 + strlen (source_dll) \ |
436 | 1.77k | + NUM_ILF_SECTIONS * 9 \ |
437 | 1.77k | + STRING_SIZE_SIZE) |
438 | 1.18k | #define SIZEOF_IDATA2 (5 * 4) |
439 | | |
440 | | /* For PEx64 idata4 & 5 have thumb size of 8 bytes. */ |
441 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) |
442 | 465 | #define SIZEOF_IDATA4 (2 * 4) |
443 | 465 | #define SIZEOF_IDATA5 (2 * 4) |
444 | | #else |
445 | 1.31k | #define SIZEOF_IDATA4 (1 * 4) |
446 | 1.31k | #define SIZEOF_IDATA5 (1 * 4) |
447 | | #endif |
448 | | |
449 | 1.60k | #define SIZEOF_IDATA6 (2 + strlen (import_name) + 1 + 1) |
450 | 1.18k | #define SIZEOF_IDATA7 (strlen (source_dll) + 1 + 1) |
451 | 1.18k | #define SIZEOF_ILF_SECTIONS (NUM_ILF_SECTIONS \ |
452 | 1.18k | * sizeof (struct coff_section_tdata)) |
453 | | |
454 | | #define ILF_DATA_SIZE \ |
455 | 1.18k | + SIZEOF_ILF_SYMS \ |
456 | 1.18k | + SIZEOF_ILF_SYM_TABLE \ |
457 | 1.18k | + SIZEOF_ILF_NATIVE_SYMS \ |
458 | 1.18k | + SIZEOF_ILF_SYM_PTR_TABLE \ |
459 | 1.18k | + SIZEOF_ILF_EXT_SYMS \ |
460 | 1.18k | + SIZEOF_ILF_RELOCS \ |
461 | 1.18k | + SIZEOF_ILF_INT_RELOCS \ |
462 | 1.18k | + SIZEOF_ILF_STRINGS \ |
463 | 1.18k | + SIZEOF_IDATA2 \ |
464 | 1.18k | + SIZEOF_IDATA4 \ |
465 | 1.18k | + SIZEOF_IDATA5 \ |
466 | 1.18k | + SIZEOF_IDATA6 \ |
467 | 1.18k | + SIZEOF_IDATA7 \ |
468 | 1.18k | + SIZEOF_ILF_SECTIONS \ |
469 | 1.18k | + MAX_TEXT_SECTION_SIZE |
470 | | |
471 | | /* Create an empty relocation against the given symbol. */ |
472 | | |
473 | | static void |
474 | | pe_ILF_make_a_symbol_reloc (pe_ILF_vars * vars, |
475 | | bfd_vma address, |
476 | | bfd_reloc_code_real_type reloc, |
477 | | struct bfd_symbol ** sym, |
478 | | unsigned int sym_index) |
479 | 1.06k | { |
480 | 1.06k | arelent *entry; |
481 | 1.06k | struct internal_reloc *internal; |
482 | | |
483 | 1.06k | entry = vars->reltab + vars->relcount; |
484 | 1.06k | internal = vars->int_reltab + vars->relcount; |
485 | | |
486 | 1.06k | entry->address = address; |
487 | 1.06k | entry->addend = 0; |
488 | 1.06k | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); |
489 | 1.06k | entry->sym_ptr_ptr = sym; |
490 | | |
491 | 1.06k | internal->r_vaddr = address; |
492 | 1.06k | internal->r_symndx = sym_index; |
493 | 1.06k | internal->r_type = entry->howto ? entry->howto->type : 0; |
494 | | |
495 | 1.06k | vars->relcount ++; |
496 | | |
497 | 1.06k | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); |
498 | 1.06k | } pei-i386.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 479 | 153 | { | 480 | 153 | arelent *entry; | 481 | 153 | struct internal_reloc *internal; | 482 | | | 483 | 153 | entry = vars->reltab + vars->relcount; | 484 | 153 | internal = vars->int_reltab + vars->relcount; | 485 | | | 486 | 153 | entry->address = address; | 487 | 153 | entry->addend = 0; | 488 | 153 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 489 | 153 | entry->sym_ptr_ptr = sym; | 490 | | | 491 | 153 | internal->r_vaddr = address; | 492 | 153 | internal->r_symndx = sym_index; | 493 | 153 | internal->r_type = entry->howto ? entry->howto->type : 0; | 494 | | | 495 | 153 | vars->relcount ++; | 496 | | | 497 | 153 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 498 | 153 | } |
pei-x86_64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 479 | 166 | { | 480 | 166 | arelent *entry; | 481 | 166 | struct internal_reloc *internal; | 482 | | | 483 | 166 | entry = vars->reltab + vars->relcount; | 484 | 166 | internal = vars->int_reltab + vars->relcount; | 485 | | | 486 | 166 | entry->address = address; | 487 | 166 | entry->addend = 0; | 488 | 166 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 489 | 166 | entry->sym_ptr_ptr = sym; | 490 | | | 491 | 166 | internal->r_vaddr = address; | 492 | 166 | internal->r_symndx = sym_index; | 493 | 166 | internal->r_type = entry->howto ? entry->howto->type : 0; | 494 | | | 495 | 166 | vars->relcount ++; | 496 | | | 497 | 166 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 498 | 166 | } |
pei-aarch64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 479 | 120 | { | 480 | 120 | arelent *entry; | 481 | 120 | struct internal_reloc *internal; | 482 | | | 483 | 120 | entry = vars->reltab + vars->relcount; | 484 | 120 | internal = vars->int_reltab + vars->relcount; | 485 | | | 486 | 120 | entry->address = address; | 487 | 120 | entry->addend = 0; | 488 | 120 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 489 | 120 | entry->sym_ptr_ptr = sym; | 490 | | | 491 | 120 | internal->r_vaddr = address; | 492 | 120 | internal->r_symndx = sym_index; | 493 | 120 | internal->r_type = entry->howto ? entry->howto->type : 0; | 494 | | | 495 | 120 | vars->relcount ++; | 496 | | | 497 | 120 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 498 | 120 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_symbol_reloc pei-loongarch64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 479 | 133 | { | 480 | 133 | arelent *entry; | 481 | 133 | struct internal_reloc *internal; | 482 | | | 483 | 133 | entry = vars->reltab + vars->relcount; | 484 | 133 | internal = vars->int_reltab + vars->relcount; | 485 | | | 486 | 133 | entry->address = address; | 487 | 133 | entry->addend = 0; | 488 | 133 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 489 | 133 | entry->sym_ptr_ptr = sym; | 490 | | | 491 | 133 | internal->r_vaddr = address; | 492 | 133 | internal->r_symndx = sym_index; | 493 | 133 | internal->r_type = entry->howto ? entry->howto->type : 0; | 494 | | | 495 | 133 | vars->relcount ++; | 496 | | | 497 | 133 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 498 | 133 | } |
pei-riscv64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 479 | 120 | { | 480 | 120 | arelent *entry; | 481 | 120 | struct internal_reloc *internal; | 482 | | | 483 | 120 | entry = vars->reltab + vars->relcount; | 484 | 120 | internal = vars->int_reltab + vars->relcount; | 485 | | | 486 | 120 | entry->address = address; | 487 | 120 | entry->addend = 0; | 488 | 120 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 489 | 120 | entry->sym_ptr_ptr = sym; | 490 | | | 491 | 120 | internal->r_vaddr = address; | 492 | 120 | internal->r_symndx = sym_index; | 493 | 120 | internal->r_type = entry->howto ? entry->howto->type : 0; | 494 | | | 495 | 120 | vars->relcount ++; | 496 | | | 497 | 120 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 498 | 120 | } |
pei-arm-wince.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 479 | 109 | { | 480 | 109 | arelent *entry; | 481 | 109 | struct internal_reloc *internal; | 482 | | | 483 | 109 | entry = vars->reltab + vars->relcount; | 484 | 109 | internal = vars->int_reltab + vars->relcount; | 485 | | | 486 | 109 | entry->address = address; | 487 | 109 | entry->addend = 0; | 488 | 109 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 489 | 109 | entry->sym_ptr_ptr = sym; | 490 | | | 491 | 109 | internal->r_vaddr = address; | 492 | 109 | internal->r_symndx = sym_index; | 493 | 109 | internal->r_type = entry->howto ? entry->howto->type : 0; | 494 | | | 495 | 109 | vars->relcount ++; | 496 | | | 497 | 109 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 498 | 109 | } |
pei-arm.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 479 | 112 | { | 480 | 112 | arelent *entry; | 481 | 112 | struct internal_reloc *internal; | 482 | | | 483 | 112 | entry = vars->reltab + vars->relcount; | 484 | 112 | internal = vars->int_reltab + vars->relcount; | 485 | | | 486 | 112 | entry->address = address; | 487 | 112 | entry->addend = 0; | 488 | 112 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 489 | 112 | entry->sym_ptr_ptr = sym; | 490 | | | 491 | 112 | internal->r_vaddr = address; | 492 | 112 | internal->r_symndx = sym_index; | 493 | 112 | internal->r_type = entry->howto ? entry->howto->type : 0; | 494 | | | 495 | 112 | vars->relcount ++; | 496 | | | 497 | 112 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 498 | 112 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_symbol_reloc pei-sh.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 479 | 149 | { | 480 | 149 | arelent *entry; | 481 | 149 | struct internal_reloc *internal; | 482 | | | 483 | 149 | entry = vars->reltab + vars->relcount; | 484 | 149 | internal = vars->int_reltab + vars->relcount; | 485 | | | 486 | 149 | entry->address = address; | 487 | 149 | entry->addend = 0; | 488 | 149 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 489 | 149 | entry->sym_ptr_ptr = sym; | 490 | | | 491 | 149 | internal->r_vaddr = address; | 492 | 149 | internal->r_symndx = sym_index; | 493 | 149 | internal->r_type = entry->howto ? entry->howto->type : 0; | 494 | | | 495 | 149 | vars->relcount ++; | 496 | | | 497 | 149 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 498 | 149 | } |
|
499 | | |
500 | | /* Create an empty relocation against the given section. */ |
501 | | |
502 | | static void |
503 | | pe_ILF_make_a_reloc (pe_ILF_vars * vars, |
504 | | bfd_vma address, |
505 | | bfd_reloc_code_real_type reloc, |
506 | | asection_ptr sec) |
507 | 840 | { |
508 | 840 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, &sec->symbol, |
509 | 840 | coff_section_data (vars->abfd, sec)->i); |
510 | 840 | } pei-i386.c:pe_ILF_make_a_reloc Line | Count | Source | 507 | 112 | { | 508 | 112 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, &sec->symbol, | 509 | 112 | coff_section_data (vars->abfd, sec)->i); | 510 | 112 | } |
pei-x86_64.c:pe_ILF_make_a_reloc Line | Count | Source | 507 | 136 | { | 508 | 136 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, &sec->symbol, | 509 | 136 | coff_section_data (vars->abfd, sec)->i); | 510 | 136 | } |
pei-aarch64.c:pe_ILF_make_a_reloc Line | Count | Source | 507 | 92 | { | 508 | 92 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, &sec->symbol, | 509 | 92 | coff_section_data (vars->abfd, sec)->i); | 510 | 92 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_reloc pei-loongarch64.c:pe_ILF_make_a_reloc Line | Count | Source | 507 | 108 | { | 508 | 108 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, &sec->symbol, | 509 | 108 | coff_section_data (vars->abfd, sec)->i); | 510 | 108 | } |
pei-riscv64.c:pe_ILF_make_a_reloc Line | Count | Source | 507 | 104 | { | 508 | 104 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, &sec->symbol, | 509 | 104 | coff_section_data (vars->abfd, sec)->i); | 510 | 104 | } |
pei-arm-wince.c:pe_ILF_make_a_reloc Line | Count | Source | 507 | 80 | { | 508 | 80 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, &sec->symbol, | 509 | 80 | coff_section_data (vars->abfd, sec)->i); | 510 | 80 | } |
pei-arm.c:pe_ILF_make_a_reloc Line | Count | Source | 507 | 82 | { | 508 | 82 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, &sec->symbol, | 509 | 82 | coff_section_data (vars->abfd, sec)->i); | 510 | 82 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_reloc pei-sh.c:pe_ILF_make_a_reloc Line | Count | Source | 507 | 126 | { | 508 | 126 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, &sec->symbol, | 509 | 126 | coff_section_data (vars->abfd, sec)->i); | 510 | 126 | } |
|
511 | | |
512 | | /* Move the queued relocs into the given section. */ |
513 | | |
514 | | static void |
515 | | pe_ILF_save_relocs (pe_ILF_vars *vars, |
516 | | asection_ptr sec) |
517 | 1.06k | { |
518 | | /* Make sure that there is somewhere to store the internal relocs. */ |
519 | 1.06k | if (coff_section_data (vars->abfd, sec) == NULL) |
520 | | /* We should probably return an error indication here. */ |
521 | 0 | abort (); |
522 | | |
523 | 1.06k | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; |
524 | | |
525 | 1.06k | sec->relocation = vars->reltab; |
526 | 1.06k | sec->reloc_count = vars->relcount; |
527 | 1.06k | sec->flags |= SEC_RELOC; |
528 | | |
529 | 1.06k | vars->reltab += vars->relcount; |
530 | 1.06k | vars->int_reltab += vars->relcount; |
531 | 1.06k | vars->relcount = 0; |
532 | | |
533 | 1.06k | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); |
534 | 1.06k | } pei-i386.c:pe_ILF_save_relocs Line | Count | Source | 517 | 153 | { | 518 | | /* Make sure that there is somewhere to store the internal relocs. */ | 519 | 153 | if (coff_section_data (vars->abfd, sec) == NULL) | 520 | | /* We should probably return an error indication here. */ | 521 | 0 | abort (); | 522 | | | 523 | 153 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 524 | | | 525 | 153 | sec->relocation = vars->reltab; | 526 | 153 | sec->reloc_count = vars->relcount; | 527 | 153 | sec->flags |= SEC_RELOC; | 528 | | | 529 | 153 | vars->reltab += vars->relcount; | 530 | 153 | vars->int_reltab += vars->relcount; | 531 | 153 | vars->relcount = 0; | 532 | | | 533 | 153 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 534 | 153 | } |
pei-x86_64.c:pe_ILF_save_relocs Line | Count | Source | 517 | 166 | { | 518 | | /* Make sure that there is somewhere to store the internal relocs. */ | 519 | 166 | if (coff_section_data (vars->abfd, sec) == NULL) | 520 | | /* We should probably return an error indication here. */ | 521 | 0 | abort (); | 522 | | | 523 | 166 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 524 | | | 525 | 166 | sec->relocation = vars->reltab; | 526 | 166 | sec->reloc_count = vars->relcount; | 527 | 166 | sec->flags |= SEC_RELOC; | 528 | | | 529 | 166 | vars->reltab += vars->relcount; | 530 | 166 | vars->int_reltab += vars->relcount; | 531 | 166 | vars->relcount = 0; | 532 | | | 533 | 166 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 534 | 166 | } |
pei-aarch64.c:pe_ILF_save_relocs Line | Count | Source | 517 | 120 | { | 518 | | /* Make sure that there is somewhere to store the internal relocs. */ | 519 | 120 | if (coff_section_data (vars->abfd, sec) == NULL) | 520 | | /* We should probably return an error indication here. */ | 521 | 0 | abort (); | 522 | | | 523 | 120 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 524 | | | 525 | 120 | sec->relocation = vars->reltab; | 526 | 120 | sec->reloc_count = vars->relcount; | 527 | 120 | sec->flags |= SEC_RELOC; | 528 | | | 529 | 120 | vars->reltab += vars->relcount; | 530 | 120 | vars->int_reltab += vars->relcount; | 531 | 120 | vars->relcount = 0; | 532 | | | 533 | 120 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 534 | 120 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_save_relocs pei-loongarch64.c:pe_ILF_save_relocs Line | Count | Source | 517 | 133 | { | 518 | | /* Make sure that there is somewhere to store the internal relocs. */ | 519 | 133 | if (coff_section_data (vars->abfd, sec) == NULL) | 520 | | /* We should probably return an error indication here. */ | 521 | 0 | abort (); | 522 | | | 523 | 133 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 524 | | | 525 | 133 | sec->relocation = vars->reltab; | 526 | 133 | sec->reloc_count = vars->relcount; | 527 | 133 | sec->flags |= SEC_RELOC; | 528 | | | 529 | 133 | vars->reltab += vars->relcount; | 530 | 133 | vars->int_reltab += vars->relcount; | 531 | 133 | vars->relcount = 0; | 532 | | | 533 | 133 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 534 | 133 | } |
pei-riscv64.c:pe_ILF_save_relocs Line | Count | Source | 517 | 120 | { | 518 | | /* Make sure that there is somewhere to store the internal relocs. */ | 519 | 120 | if (coff_section_data (vars->abfd, sec) == NULL) | 520 | | /* We should probably return an error indication here. */ | 521 | 0 | abort (); | 522 | | | 523 | 120 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 524 | | | 525 | 120 | sec->relocation = vars->reltab; | 526 | 120 | sec->reloc_count = vars->relcount; | 527 | 120 | sec->flags |= SEC_RELOC; | 528 | | | 529 | 120 | vars->reltab += vars->relcount; | 530 | 120 | vars->int_reltab += vars->relcount; | 531 | 120 | vars->relcount = 0; | 532 | | | 533 | 120 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 534 | 120 | } |
pei-arm-wince.c:pe_ILF_save_relocs Line | Count | Source | 517 | 109 | { | 518 | | /* Make sure that there is somewhere to store the internal relocs. */ | 519 | 109 | if (coff_section_data (vars->abfd, sec) == NULL) | 520 | | /* We should probably return an error indication here. */ | 521 | 0 | abort (); | 522 | | | 523 | 109 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 524 | | | 525 | 109 | sec->relocation = vars->reltab; | 526 | 109 | sec->reloc_count = vars->relcount; | 527 | 109 | sec->flags |= SEC_RELOC; | 528 | | | 529 | 109 | vars->reltab += vars->relcount; | 530 | 109 | vars->int_reltab += vars->relcount; | 531 | 109 | vars->relcount = 0; | 532 | | | 533 | 109 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 534 | 109 | } |
pei-arm.c:pe_ILF_save_relocs Line | Count | Source | 517 | 112 | { | 518 | | /* Make sure that there is somewhere to store the internal relocs. */ | 519 | 112 | if (coff_section_data (vars->abfd, sec) == NULL) | 520 | | /* We should probably return an error indication here. */ | 521 | 0 | abort (); | 522 | | | 523 | 112 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 524 | | | 525 | 112 | sec->relocation = vars->reltab; | 526 | 112 | sec->reloc_count = vars->relcount; | 527 | 112 | sec->flags |= SEC_RELOC; | 528 | | | 529 | 112 | vars->reltab += vars->relcount; | 530 | 112 | vars->int_reltab += vars->relcount; | 531 | 112 | vars->relcount = 0; | 532 | | | 533 | 112 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 534 | 112 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_save_relocs pei-sh.c:pe_ILF_save_relocs Line | Count | Source | 517 | 149 | { | 518 | | /* Make sure that there is somewhere to store the internal relocs. */ | 519 | 149 | if (coff_section_data (vars->abfd, sec) == NULL) | 520 | | /* We should probably return an error indication here. */ | 521 | 0 | abort (); | 522 | | | 523 | 149 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 524 | | | 525 | 149 | sec->relocation = vars->reltab; | 526 | 149 | sec->reloc_count = vars->relcount; | 527 | 149 | sec->flags |= SEC_RELOC; | 528 | | | 529 | 149 | vars->reltab += vars->relcount; | 530 | 149 | vars->int_reltab += vars->relcount; | 531 | 149 | vars->relcount = 0; | 532 | | | 533 | 149 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 534 | 149 | } |
|
535 | | |
536 | | /* Create a global symbol and add it to the relevant tables. */ |
537 | | |
538 | | static void |
539 | | pe_ILF_make_a_symbol (pe_ILF_vars * vars, |
540 | | const char * prefix, |
541 | | const char * symbol_name, |
542 | | asection_ptr section, |
543 | | flagword extra_flags) |
544 | 3.30k | { |
545 | 3.30k | coff_symbol_type *sym; |
546 | 3.30k | combined_entry_type *ent; |
547 | 3.30k | SYMENT *esym; |
548 | 3.30k | unsigned short sclass; |
549 | | |
550 | 3.30k | if (extra_flags & BSF_LOCAL) |
551 | 1.82k | sclass = C_STAT; |
552 | 1.47k | else |
553 | 1.47k | sclass = C_EXT; |
554 | | |
555 | | #ifdef THUMBPEMAGIC |
556 | 701 | if (vars->magic == THUMBPEMAGIC) |
557 | 316 | { |
558 | 316 | if (extra_flags & BSF_FUNCTION) |
559 | 24 | sclass = C_THUMBEXTFUNC; |
560 | 292 | else if (extra_flags & BSF_LOCAL) |
561 | 176 | sclass = C_THUMBSTAT; |
562 | 116 | else |
563 | 116 | sclass = C_THUMBEXT; |
564 | 316 | } |
565 | | #endif |
566 | | |
567 | 3.30k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); |
568 | | |
569 | 3.30k | sym = vars->sym_ptr; |
570 | 3.30k | ent = vars->native_ptr; |
571 | 3.30k | esym = vars->esym_ptr; |
572 | | |
573 | | /* Copy the symbol's name into the string table. */ |
574 | 3.30k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); |
575 | | |
576 | 3.30k | if (section == NULL) |
577 | 554 | section = bfd_und_section_ptr; |
578 | | |
579 | | /* Initialise the external symbol. */ |
580 | 3.30k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, |
581 | 3.30k | esym->e.e.e_offset); |
582 | 3.30k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); |
583 | 3.30k | esym->e_sclass[0] = sclass; |
584 | | |
585 | | /* The following initialisations are unnecessary - the memory is |
586 | | zero initialised. They are just kept here as reminders. */ |
587 | | |
588 | | /* Initialise the internal symbol structure. */ |
589 | 3.30k | ent->u.syment.n_sclass = sclass; |
590 | 3.30k | ent->u.syment.n_scnum = section->target_index; |
591 | 3.30k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; |
592 | 3.30k | ent->is_sym = true; |
593 | | |
594 | 3.30k | sym->symbol.the_bfd = vars->abfd; |
595 | 3.30k | sym->symbol.name = vars->string_ptr; |
596 | 3.30k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; |
597 | 3.30k | sym->symbol.section = section; |
598 | 3.30k | sym->native = ent; |
599 | | |
600 | 3.30k | *vars->table_ptr = vars->sym_index; |
601 | 3.30k | *vars->sym_ptr_ptr = sym; |
602 | | |
603 | | /* Adjust pointers for the next symbol. */ |
604 | 3.30k | vars->sym_index ++; |
605 | 3.30k | vars->sym_ptr ++; |
606 | 3.30k | vars->sym_ptr_ptr ++; |
607 | 3.30k | vars->table_ptr ++; |
608 | 3.30k | vars->native_ptr ++; |
609 | 3.30k | vars->esym_ptr ++; |
610 | 3.30k | vars->string_ptr += len + 1; |
611 | | |
612 | 3.30k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); |
613 | 3.30k | } pei-i386.c:pe_ILF_make_a_symbol Line | Count | Source | 544 | 465 | { | 545 | 465 | coff_symbol_type *sym; | 546 | 465 | combined_entry_type *ent; | 547 | 465 | SYMENT *esym; | 548 | 465 | unsigned short sclass; | 549 | | | 550 | 465 | if (extra_flags & BSF_LOCAL) | 551 | 253 | sclass = C_STAT; | 552 | 212 | else | 553 | 212 | sclass = C_EXT; | 554 | | | 555 | | #ifdef THUMBPEMAGIC | 556 | | if (vars->magic == THUMBPEMAGIC) | 557 | | { | 558 | | if (extra_flags & BSF_FUNCTION) | 559 | | sclass = C_THUMBEXTFUNC; | 560 | | else if (extra_flags & BSF_LOCAL) | 561 | | sclass = C_THUMBSTAT; | 562 | | else | 563 | | sclass = C_THUMBEXT; | 564 | | } | 565 | | #endif | 566 | | | 567 | 465 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 568 | | | 569 | 465 | sym = vars->sym_ptr; | 570 | 465 | ent = vars->native_ptr; | 571 | 465 | esym = vars->esym_ptr; | 572 | | | 573 | | /* Copy the symbol's name into the string table. */ | 574 | 465 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 575 | | | 576 | 465 | if (section == NULL) | 577 | 75 | section = bfd_und_section_ptr; | 578 | | | 579 | | /* Initialise the external symbol. */ | 580 | 465 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 581 | 465 | esym->e.e.e_offset); | 582 | 465 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 583 | 465 | esym->e_sclass[0] = sclass; | 584 | | | 585 | | /* The following initialisations are unnecessary - the memory is | 586 | | zero initialised. They are just kept here as reminders. */ | 587 | | | 588 | | /* Initialise the internal symbol structure. */ | 589 | 465 | ent->u.syment.n_sclass = sclass; | 590 | 465 | ent->u.syment.n_scnum = section->target_index; | 591 | 465 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 592 | 465 | ent->is_sym = true; | 593 | | | 594 | 465 | sym->symbol.the_bfd = vars->abfd; | 595 | 465 | sym->symbol.name = vars->string_ptr; | 596 | 465 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 597 | 465 | sym->symbol.section = section; | 598 | 465 | sym->native = ent; | 599 | | | 600 | 465 | *vars->table_ptr = vars->sym_index; | 601 | 465 | *vars->sym_ptr_ptr = sym; | 602 | | | 603 | | /* Adjust pointers for the next symbol. */ | 604 | 465 | vars->sym_index ++; | 605 | 465 | vars->sym_ptr ++; | 606 | 465 | vars->sym_ptr_ptr ++; | 607 | 465 | vars->table_ptr ++; | 608 | 465 | vars->native_ptr ++; | 609 | 465 | vars->esym_ptr ++; | 610 | 465 | vars->string_ptr += len + 1; | 611 | | | 612 | 465 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 613 | 465 | } |
pei-x86_64.c:pe_ILF_make_a_symbol Line | Count | Source | 544 | 505 | { | 545 | 505 | coff_symbol_type *sym; | 546 | 505 | combined_entry_type *ent; | 547 | 505 | SYMENT *esym; | 548 | 505 | unsigned short sclass; | 549 | | | 550 | 505 | if (extra_flags & BSF_LOCAL) | 551 | 278 | sclass = C_STAT; | 552 | 227 | else | 553 | 227 | sclass = C_EXT; | 554 | | | 555 | | #ifdef THUMBPEMAGIC | 556 | | if (vars->magic == THUMBPEMAGIC) | 557 | | { | 558 | | if (extra_flags & BSF_FUNCTION) | 559 | | sclass = C_THUMBEXTFUNC; | 560 | | else if (extra_flags & BSF_LOCAL) | 561 | | sclass = C_THUMBSTAT; | 562 | | else | 563 | | sclass = C_THUMBEXT; | 564 | | } | 565 | | #endif | 566 | | | 567 | 505 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 568 | | | 569 | 505 | sym = vars->sym_ptr; | 570 | 505 | ent = vars->native_ptr; | 571 | 505 | esym = vars->esym_ptr; | 572 | | | 573 | | /* Copy the symbol's name into the string table. */ | 574 | 505 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 575 | | | 576 | 505 | if (section == NULL) | 577 | 85 | section = bfd_und_section_ptr; | 578 | | | 579 | | /* Initialise the external symbol. */ | 580 | 505 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 581 | 505 | esym->e.e.e_offset); | 582 | 505 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 583 | 505 | esym->e_sclass[0] = sclass; | 584 | | | 585 | | /* The following initialisations are unnecessary - the memory is | 586 | | zero initialised. They are just kept here as reminders. */ | 587 | | | 588 | | /* Initialise the internal symbol structure. */ | 589 | 505 | ent->u.syment.n_sclass = sclass; | 590 | 505 | ent->u.syment.n_scnum = section->target_index; | 591 | 505 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 592 | 505 | ent->is_sym = true; | 593 | | | 594 | 505 | sym->symbol.the_bfd = vars->abfd; | 595 | 505 | sym->symbol.name = vars->string_ptr; | 596 | 505 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 597 | 505 | sym->symbol.section = section; | 598 | 505 | sym->native = ent; | 599 | | | 600 | 505 | *vars->table_ptr = vars->sym_index; | 601 | 505 | *vars->sym_ptr_ptr = sym; | 602 | | | 603 | | /* Adjust pointers for the next symbol. */ | 604 | 505 | vars->sym_index ++; | 605 | 505 | vars->sym_ptr ++; | 606 | 505 | vars->sym_ptr_ptr ++; | 607 | 505 | vars->table_ptr ++; | 608 | 505 | vars->native_ptr ++; | 609 | 505 | vars->esym_ptr ++; | 610 | 505 | vars->string_ptr += len + 1; | 611 | | | 612 | 505 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 613 | 505 | } |
pei-aarch64.c:pe_ILF_make_a_symbol Line | Count | Source | 544 | 367 | { | 545 | 367 | coff_symbol_type *sym; | 546 | 367 | combined_entry_type *ent; | 547 | 367 | SYMENT *esym; | 548 | 367 | unsigned short sclass; | 549 | | | 550 | 367 | if (extra_flags & BSF_LOCAL) | 551 | 204 | sclass = C_STAT; | 552 | 163 | else | 553 | 163 | sclass = C_EXT; | 554 | | | 555 | | #ifdef THUMBPEMAGIC | 556 | | if (vars->magic == THUMBPEMAGIC) | 557 | | { | 558 | | if (extra_flags & BSF_FUNCTION) | 559 | | sclass = C_THUMBEXTFUNC; | 560 | | else if (extra_flags & BSF_LOCAL) | 561 | | sclass = C_THUMBSTAT; | 562 | | else | 563 | | sclass = C_THUMBEXT; | 564 | | } | 565 | | #endif | 566 | | | 567 | 367 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 568 | | | 569 | 367 | sym = vars->sym_ptr; | 570 | 367 | ent = vars->native_ptr; | 571 | 367 | esym = vars->esym_ptr; | 572 | | | 573 | | /* Copy the symbol's name into the string table. */ | 574 | 367 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 575 | | | 576 | 367 | if (section == NULL) | 577 | 62 | section = bfd_und_section_ptr; | 578 | | | 579 | | /* Initialise the external symbol. */ | 580 | 367 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 581 | 367 | esym->e.e.e_offset); | 582 | 367 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 583 | 367 | esym->e_sclass[0] = sclass; | 584 | | | 585 | | /* The following initialisations are unnecessary - the memory is | 586 | | zero initialised. They are just kept here as reminders. */ | 587 | | | 588 | | /* Initialise the internal symbol structure. */ | 589 | 367 | ent->u.syment.n_sclass = sclass; | 590 | 367 | ent->u.syment.n_scnum = section->target_index; | 591 | 367 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 592 | 367 | ent->is_sym = true; | 593 | | | 594 | 367 | sym->symbol.the_bfd = vars->abfd; | 595 | 367 | sym->symbol.name = vars->string_ptr; | 596 | 367 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 597 | 367 | sym->symbol.section = section; | 598 | 367 | sym->native = ent; | 599 | | | 600 | 367 | *vars->table_ptr = vars->sym_index; | 601 | 367 | *vars->sym_ptr_ptr = sym; | 602 | | | 603 | | /* Adjust pointers for the next symbol. */ | 604 | 367 | vars->sym_index ++; | 605 | 367 | vars->sym_ptr ++; | 606 | 367 | vars->sym_ptr_ptr ++; | 607 | 367 | vars->table_ptr ++; | 608 | 367 | vars->native_ptr ++; | 609 | 367 | vars->esym_ptr ++; | 610 | 367 | vars->string_ptr += len + 1; | 611 | | | 612 | 367 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 613 | 367 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_symbol pei-loongarch64.c:pe_ILF_make_a_symbol Line | Count | Source | 544 | 413 | { | 545 | 413 | coff_symbol_type *sym; | 546 | 413 | combined_entry_type *ent; | 547 | 413 | SYMENT *esym; | 548 | 413 | unsigned short sclass; | 549 | | | 550 | 413 | if (extra_flags & BSF_LOCAL) | 551 | 231 | sclass = C_STAT; | 552 | 182 | else | 553 | 182 | sclass = C_EXT; | 554 | | | 555 | | #ifdef THUMBPEMAGIC | 556 | | if (vars->magic == THUMBPEMAGIC) | 557 | | { | 558 | | if (extra_flags & BSF_FUNCTION) | 559 | | sclass = C_THUMBEXTFUNC; | 560 | | else if (extra_flags & BSF_LOCAL) | 561 | | sclass = C_THUMBSTAT; | 562 | | else | 563 | | sclass = C_THUMBEXT; | 564 | | } | 565 | | #endif | 566 | | | 567 | 413 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 568 | | | 569 | 413 | sym = vars->sym_ptr; | 570 | 413 | ent = vars->native_ptr; | 571 | 413 | esym = vars->esym_ptr; | 572 | | | 573 | | /* Copy the symbol's name into the string table. */ | 574 | 413 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 575 | | | 576 | 413 | if (section == NULL) | 577 | 72 | section = bfd_und_section_ptr; | 578 | | | 579 | | /* Initialise the external symbol. */ | 580 | 413 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 581 | 413 | esym->e.e.e_offset); | 582 | 413 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 583 | 413 | esym->e_sclass[0] = sclass; | 584 | | | 585 | | /* The following initialisations are unnecessary - the memory is | 586 | | zero initialised. They are just kept here as reminders. */ | 587 | | | 588 | | /* Initialise the internal symbol structure. */ | 589 | 413 | ent->u.syment.n_sclass = sclass; | 590 | 413 | ent->u.syment.n_scnum = section->target_index; | 591 | 413 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 592 | 413 | ent->is_sym = true; | 593 | | | 594 | 413 | sym->symbol.the_bfd = vars->abfd; | 595 | 413 | sym->symbol.name = vars->string_ptr; | 596 | 413 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 597 | 413 | sym->symbol.section = section; | 598 | 413 | sym->native = ent; | 599 | | | 600 | 413 | *vars->table_ptr = vars->sym_index; | 601 | 413 | *vars->sym_ptr_ptr = sym; | 602 | | | 603 | | /* Adjust pointers for the next symbol. */ | 604 | 413 | vars->sym_index ++; | 605 | 413 | vars->sym_ptr ++; | 606 | 413 | vars->sym_ptr_ptr ++; | 607 | 413 | vars->table_ptr ++; | 608 | 413 | vars->native_ptr ++; | 609 | 413 | vars->esym_ptr ++; | 610 | 413 | vars->string_ptr += len + 1; | 611 | | | 612 | 413 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 613 | 413 | } |
pei-riscv64.c:pe_ILF_make_a_symbol Line | Count | Source | 544 | 394 | { | 545 | 394 | coff_symbol_type *sym; | 546 | 394 | combined_entry_type *ent; | 547 | 394 | SYMENT *esym; | 548 | 394 | unsigned short sclass; | 549 | | | 550 | 394 | if (extra_flags & BSF_LOCAL) | 551 | 212 | sclass = C_STAT; | 552 | 182 | else | 553 | 182 | sclass = C_EXT; | 554 | | | 555 | | #ifdef THUMBPEMAGIC | 556 | | if (vars->magic == THUMBPEMAGIC) | 557 | | { | 558 | | if (extra_flags & BSF_FUNCTION) | 559 | | sclass = C_THUMBEXTFUNC; | 560 | | else if (extra_flags & BSF_LOCAL) | 561 | | sclass = C_THUMBSTAT; | 562 | | else | 563 | | sclass = C_THUMBEXT; | 564 | | } | 565 | | #endif | 566 | | | 567 | 394 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 568 | | | 569 | 394 | sym = vars->sym_ptr; | 570 | 394 | ent = vars->native_ptr; | 571 | 394 | esym = vars->esym_ptr; | 572 | | | 573 | | /* Copy the symbol's name into the string table. */ | 574 | 394 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 575 | | | 576 | 394 | if (section == NULL) | 577 | 67 | section = bfd_und_section_ptr; | 578 | | | 579 | | /* Initialise the external symbol. */ | 580 | 394 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 581 | 394 | esym->e.e.e_offset); | 582 | 394 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 583 | 394 | esym->e_sclass[0] = sclass; | 584 | | | 585 | | /* The following initialisations are unnecessary - the memory is | 586 | | zero initialised. They are just kept here as reminders. */ | 587 | | | 588 | | /* Initialise the internal symbol structure. */ | 589 | 394 | ent->u.syment.n_sclass = sclass; | 590 | 394 | ent->u.syment.n_scnum = section->target_index; | 591 | 394 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 592 | 394 | ent->is_sym = true; | 593 | | | 594 | 394 | sym->symbol.the_bfd = vars->abfd; | 595 | 394 | sym->symbol.name = vars->string_ptr; | 596 | 394 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 597 | 394 | sym->symbol.section = section; | 598 | 394 | sym->native = ent; | 599 | | | 600 | 394 | *vars->table_ptr = vars->sym_index; | 601 | 394 | *vars->sym_ptr_ptr = sym; | 602 | | | 603 | | /* Adjust pointers for the next symbol. */ | 604 | 394 | vars->sym_index ++; | 605 | 394 | vars->sym_ptr ++; | 606 | 394 | vars->sym_ptr_ptr ++; | 607 | 394 | vars->table_ptr ++; | 608 | 394 | vars->native_ptr ++; | 609 | 394 | vars->esym_ptr ++; | 610 | 394 | vars->string_ptr += len + 1; | 611 | | | 612 | 394 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 613 | 394 | } |
pei-arm-wince.c:pe_ILF_make_a_symbol Line | Count | Source | 544 | 345 | { | 545 | 345 | coff_symbol_type *sym; | 546 | 345 | combined_entry_type *ent; | 547 | 345 | SYMENT *esym; | 548 | 345 | unsigned short sclass; | 549 | | | 550 | 345 | if (extra_flags & BSF_LOCAL) | 551 | 195 | sclass = C_STAT; | 552 | 150 | else | 553 | 150 | sclass = C_EXT; | 554 | | | 555 | 345 | #ifdef THUMBPEMAGIC | 556 | 345 | if (vars->magic == THUMBPEMAGIC) | 557 | 158 | { | 558 | 158 | if (extra_flags & BSF_FUNCTION) | 559 | 12 | sclass = C_THUMBEXTFUNC; | 560 | 146 | else if (extra_flags & BSF_LOCAL) | 561 | 88 | sclass = C_THUMBSTAT; | 562 | 58 | else | 563 | 58 | sclass = C_THUMBEXT; | 564 | 158 | } | 565 | 345 | #endif | 566 | | | 567 | 345 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 568 | | | 569 | 345 | sym = vars->sym_ptr; | 570 | 345 | ent = vars->native_ptr; | 571 | 345 | esym = vars->esym_ptr; | 572 | | | 573 | | /* Copy the symbol's name into the string table. */ | 574 | 345 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 575 | | | 576 | 345 | if (section == NULL) | 577 | 56 | section = bfd_und_section_ptr; | 578 | | | 579 | | /* Initialise the external symbol. */ | 580 | 345 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 581 | 345 | esym->e.e.e_offset); | 582 | 345 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 583 | 345 | esym->e_sclass[0] = sclass; | 584 | | | 585 | | /* The following initialisations are unnecessary - the memory is | 586 | | zero initialised. They are just kept here as reminders. */ | 587 | | | 588 | | /* Initialise the internal symbol structure. */ | 589 | 345 | ent->u.syment.n_sclass = sclass; | 590 | 345 | ent->u.syment.n_scnum = section->target_index; | 591 | 345 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 592 | 345 | ent->is_sym = true; | 593 | | | 594 | 345 | sym->symbol.the_bfd = vars->abfd; | 595 | 345 | sym->symbol.name = vars->string_ptr; | 596 | 345 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 597 | 345 | sym->symbol.section = section; | 598 | 345 | sym->native = ent; | 599 | | | 600 | 345 | *vars->table_ptr = vars->sym_index; | 601 | 345 | *vars->sym_ptr_ptr = sym; | 602 | | | 603 | | /* Adjust pointers for the next symbol. */ | 604 | 345 | vars->sym_index ++; | 605 | 345 | vars->sym_ptr ++; | 606 | 345 | vars->sym_ptr_ptr ++; | 607 | 345 | vars->table_ptr ++; | 608 | 345 | vars->native_ptr ++; | 609 | 345 | vars->esym_ptr ++; | 610 | 345 | vars->string_ptr += len + 1; | 611 | | | 612 | 345 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 613 | 345 | } |
pei-arm.c:pe_ILF_make_a_symbol Line | Count | Source | 544 | 356 | { | 545 | 356 | coff_symbol_type *sym; | 546 | 356 | combined_entry_type *ent; | 547 | 356 | SYMENT *esym; | 548 | 356 | unsigned short sclass; | 549 | | | 550 | 356 | if (extra_flags & BSF_LOCAL) | 551 | 201 | sclass = C_STAT; | 552 | 155 | else | 553 | 155 | sclass = C_EXT; | 554 | | | 555 | 356 | #ifdef THUMBPEMAGIC | 556 | 356 | if (vars->magic == THUMBPEMAGIC) | 557 | 158 | { | 558 | 158 | if (extra_flags & BSF_FUNCTION) | 559 | 12 | sclass = C_THUMBEXTFUNC; | 560 | 146 | else if (extra_flags & BSF_LOCAL) | 561 | 88 | sclass = C_THUMBSTAT; | 562 | 58 | else | 563 | 58 | sclass = C_THUMBEXT; | 564 | 158 | } | 565 | 356 | #endif | 566 | | | 567 | 356 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 568 | | | 569 | 356 | sym = vars->sym_ptr; | 570 | 356 | ent = vars->native_ptr; | 571 | 356 | esym = vars->esym_ptr; | 572 | | | 573 | | /* Copy the symbol's name into the string table. */ | 574 | 356 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 575 | | | 576 | 356 | if (section == NULL) | 577 | 58 | section = bfd_und_section_ptr; | 578 | | | 579 | | /* Initialise the external symbol. */ | 580 | 356 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 581 | 356 | esym->e.e.e_offset); | 582 | 356 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 583 | 356 | esym->e_sclass[0] = sclass; | 584 | | | 585 | | /* The following initialisations are unnecessary - the memory is | 586 | | zero initialised. They are just kept here as reminders. */ | 587 | | | 588 | | /* Initialise the internal symbol structure. */ | 589 | 356 | ent->u.syment.n_sclass = sclass; | 590 | 356 | ent->u.syment.n_scnum = section->target_index; | 591 | 356 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 592 | 356 | ent->is_sym = true; | 593 | | | 594 | 356 | sym->symbol.the_bfd = vars->abfd; | 595 | 356 | sym->symbol.name = vars->string_ptr; | 596 | 356 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 597 | 356 | sym->symbol.section = section; | 598 | 356 | sym->native = ent; | 599 | | | 600 | 356 | *vars->table_ptr = vars->sym_index; | 601 | 356 | *vars->sym_ptr_ptr = sym; | 602 | | | 603 | | /* Adjust pointers for the next symbol. */ | 604 | 356 | vars->sym_index ++; | 605 | 356 | vars->sym_ptr ++; | 606 | 356 | vars->sym_ptr_ptr ++; | 607 | 356 | vars->table_ptr ++; | 608 | 356 | vars->native_ptr ++; | 609 | 356 | vars->esym_ptr ++; | 610 | 356 | vars->string_ptr += len + 1; | 611 | | | 612 | 356 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 613 | 356 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_symbol pei-sh.c:pe_ILF_make_a_symbol Line | Count | Source | 544 | 459 | { | 545 | 459 | coff_symbol_type *sym; | 546 | 459 | combined_entry_type *ent; | 547 | 459 | SYMENT *esym; | 548 | 459 | unsigned short sclass; | 549 | | | 550 | 459 | if (extra_flags & BSF_LOCAL) | 551 | 254 | sclass = C_STAT; | 552 | 205 | else | 553 | 205 | sclass = C_EXT; | 554 | | | 555 | | #ifdef THUMBPEMAGIC | 556 | | if (vars->magic == THUMBPEMAGIC) | 557 | | { | 558 | | if (extra_flags & BSF_FUNCTION) | 559 | | sclass = C_THUMBEXTFUNC; | 560 | | else if (extra_flags & BSF_LOCAL) | 561 | | sclass = C_THUMBSTAT; | 562 | | else | 563 | | sclass = C_THUMBEXT; | 564 | | } | 565 | | #endif | 566 | | | 567 | 459 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 568 | | | 569 | 459 | sym = vars->sym_ptr; | 570 | 459 | ent = vars->native_ptr; | 571 | 459 | esym = vars->esym_ptr; | 572 | | | 573 | | /* Copy the symbol's name into the string table. */ | 574 | 459 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 575 | | | 576 | 459 | if (section == NULL) | 577 | 79 | section = bfd_und_section_ptr; | 578 | | | 579 | | /* Initialise the external symbol. */ | 580 | 459 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 581 | 459 | esym->e.e.e_offset); | 582 | 459 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 583 | 459 | esym->e_sclass[0] = sclass; | 584 | | | 585 | | /* The following initialisations are unnecessary - the memory is | 586 | | zero initialised. They are just kept here as reminders. */ | 587 | | | 588 | | /* Initialise the internal symbol structure. */ | 589 | 459 | ent->u.syment.n_sclass = sclass; | 590 | 459 | ent->u.syment.n_scnum = section->target_index; | 591 | 459 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 592 | 459 | ent->is_sym = true; | 593 | | | 594 | 459 | sym->symbol.the_bfd = vars->abfd; | 595 | 459 | sym->symbol.name = vars->string_ptr; | 596 | 459 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 597 | 459 | sym->symbol.section = section; | 598 | 459 | sym->native = ent; | 599 | | | 600 | 459 | *vars->table_ptr = vars->sym_index; | 601 | 459 | *vars->sym_ptr_ptr = sym; | 602 | | | 603 | | /* Adjust pointers for the next symbol. */ | 604 | 459 | vars->sym_index ++; | 605 | 459 | vars->sym_ptr ++; | 606 | 459 | vars->sym_ptr_ptr ++; | 607 | 459 | vars->table_ptr ++; | 608 | 459 | vars->native_ptr ++; | 609 | 459 | vars->esym_ptr ++; | 610 | 459 | vars->string_ptr += len + 1; | 611 | | | 612 | 459 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 613 | 459 | } |
|
614 | | |
615 | | /* Create a section. */ |
616 | | |
617 | | static asection_ptr |
618 | | pe_ILF_make_a_section (pe_ILF_vars * vars, |
619 | | const char * name, |
620 | | unsigned int size, |
621 | | flagword extra_flags) |
622 | 1.82k | { |
623 | 1.82k | asection_ptr sec; |
624 | 1.82k | flagword flags; |
625 | 1.82k | intptr_t alignment; |
626 | | |
627 | 1.82k | sec = bfd_make_section_old_way (vars->abfd, name); |
628 | 1.82k | if (sec == NULL) |
629 | 0 | return NULL; |
630 | | |
631 | 1.82k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; |
632 | | |
633 | 1.82k | bfd_set_section_flags (sec, flags | extra_flags); |
634 | | |
635 | 1.82k | bfd_set_section_alignment (sec, 2); |
636 | | |
637 | | /* Check that we will not run out of space. */ |
638 | 1.82k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); |
639 | | |
640 | | /* Set the section size and contents. The actual |
641 | | contents are filled in by our parent. */ |
642 | 1.82k | bfd_set_section_size (sec, (bfd_size_type) size); |
643 | 1.82k | sec->contents = vars->data; |
644 | 1.82k | sec->target_index = vars->sec_index ++; |
645 | | |
646 | | /* Advance data pointer in the vars structure. */ |
647 | 1.82k | vars->data += size; |
648 | | |
649 | | /* Skip the padding byte if it was not needed. |
650 | | The logic here is that if the string length is odd, |
651 | | then the entire string length, including the null byte, |
652 | | is even and so the extra, padding byte, is not needed. */ |
653 | 1.82k | if (size & 1) |
654 | 197 | vars->data --; |
655 | | |
656 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we |
657 | | preserve host alignment requirements. The BFD_ASSERTs in this |
658 | | functions will warn us if we run out of room, but we should |
659 | | already have enough padding built in to ILF_DATA_SIZE. */ |
660 | 1.82k | #if GCC_VERSION >= 3000 |
661 | 1.82k | alignment = __alignof__ (struct coff_section_tdata); |
662 | | #else |
663 | | alignment = 8; |
664 | | #endif |
665 | 1.82k | vars->data |
666 | 1.82k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); |
667 | | |
668 | | /* Create a coff_section_tdata structure for our use. */ |
669 | 1.82k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; |
670 | 1.82k | vars->data += sizeof (struct coff_section_tdata); |
671 | | |
672 | 1.82k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); |
673 | | |
674 | | /* Create a symbol to refer to this section. */ |
675 | 1.82k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); |
676 | | |
677 | | /* Cache the index to the symbol in the coff_section_data structure. */ |
678 | 1.82k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; |
679 | | |
680 | 1.82k | return sec; |
681 | 1.82k | } pei-i386.c:pe_ILF_make_a_section Line | Count | Source | 622 | 253 | { | 623 | 253 | asection_ptr sec; | 624 | 253 | flagword flags; | 625 | 253 | intptr_t alignment; | 626 | | | 627 | 253 | sec = bfd_make_section_old_way (vars->abfd, name); | 628 | 253 | if (sec == NULL) | 629 | 0 | return NULL; | 630 | | | 631 | 253 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 632 | | | 633 | 253 | bfd_set_section_flags (sec, flags | extra_flags); | 634 | | | 635 | 253 | bfd_set_section_alignment (sec, 2); | 636 | | | 637 | | /* Check that we will not run out of space. */ | 638 | 253 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 639 | | | 640 | | /* Set the section size and contents. The actual | 641 | | contents are filled in by our parent. */ | 642 | 253 | bfd_set_section_size (sec, (bfd_size_type) size); | 643 | 253 | sec->contents = vars->data; | 644 | 253 | sec->target_index = vars->sec_index ++; | 645 | | | 646 | | /* Advance data pointer in the vars structure. */ | 647 | 253 | vars->data += size; | 648 | | | 649 | | /* Skip the padding byte if it was not needed. | 650 | | The logic here is that if the string length is odd, | 651 | | then the entire string length, including the null byte, | 652 | | is even and so the extra, padding byte, is not needed. */ | 653 | 253 | if (size & 1) | 654 | 24 | vars->data --; | 655 | | | 656 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 657 | | preserve host alignment requirements. The BFD_ASSERTs in this | 658 | | functions will warn us if we run out of room, but we should | 659 | | already have enough padding built in to ILF_DATA_SIZE. */ | 660 | 253 | #if GCC_VERSION >= 3000 | 661 | 253 | alignment = __alignof__ (struct coff_section_tdata); | 662 | | #else | 663 | | alignment = 8; | 664 | | #endif | 665 | 253 | vars->data | 666 | 253 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 667 | | | 668 | | /* Create a coff_section_tdata structure for our use. */ | 669 | 253 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 670 | 253 | vars->data += sizeof (struct coff_section_tdata); | 671 | | | 672 | 253 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 673 | | | 674 | | /* Create a symbol to refer to this section. */ | 675 | 253 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 676 | | | 677 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 678 | 253 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 679 | | | 680 | 253 | return sec; | 681 | 253 | } |
pei-x86_64.c:pe_ILF_make_a_section Line | Count | Source | 622 | 278 | { | 623 | 278 | asection_ptr sec; | 624 | 278 | flagword flags; | 625 | 278 | intptr_t alignment; | 626 | | | 627 | 278 | sec = bfd_make_section_old_way (vars->abfd, name); | 628 | 278 | if (sec == NULL) | 629 | 0 | return NULL; | 630 | | | 631 | 278 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 632 | | | 633 | 278 | bfd_set_section_flags (sec, flags | extra_flags); | 634 | | | 635 | 278 | bfd_set_section_alignment (sec, 2); | 636 | | | 637 | | /* Check that we will not run out of space. */ | 638 | 278 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 639 | | | 640 | | /* Set the section size and contents. The actual | 641 | | contents are filled in by our parent. */ | 642 | 278 | bfd_set_section_size (sec, (bfd_size_type) size); | 643 | 278 | sec->contents = vars->data; | 644 | 278 | sec->target_index = vars->sec_index ++; | 645 | | | 646 | | /* Advance data pointer in the vars structure. */ | 647 | 278 | vars->data += size; | 648 | | | 649 | | /* Skip the padding byte if it was not needed. | 650 | | The logic here is that if the string length is odd, | 651 | | then the entire string length, including the null byte, | 652 | | is even and so the extra, padding byte, is not needed. */ | 653 | 278 | if (size & 1) | 654 | 29 | vars->data --; | 655 | | | 656 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 657 | | preserve host alignment requirements. The BFD_ASSERTs in this | 658 | | functions will warn us if we run out of room, but we should | 659 | | already have enough padding built in to ILF_DATA_SIZE. */ | 660 | 278 | #if GCC_VERSION >= 3000 | 661 | 278 | alignment = __alignof__ (struct coff_section_tdata); | 662 | | #else | 663 | | alignment = 8; | 664 | | #endif | 665 | 278 | vars->data | 666 | 278 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 667 | | | 668 | | /* Create a coff_section_tdata structure for our use. */ | 669 | 278 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 670 | 278 | vars->data += sizeof (struct coff_section_tdata); | 671 | | | 672 | 278 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 673 | | | 674 | | /* Create a symbol to refer to this section. */ | 675 | 278 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 676 | | | 677 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 678 | 278 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 679 | | | 680 | 278 | return sec; | 681 | 278 | } |
pei-aarch64.c:pe_ILF_make_a_section Line | Count | Source | 622 | 204 | { | 623 | 204 | asection_ptr sec; | 624 | 204 | flagword flags; | 625 | 204 | intptr_t alignment; | 626 | | | 627 | 204 | sec = bfd_make_section_old_way (vars->abfd, name); | 628 | 204 | if (sec == NULL) | 629 | 0 | return NULL; | 630 | | | 631 | 204 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 632 | | | 633 | 204 | bfd_set_section_flags (sec, flags | extra_flags); | 634 | | | 635 | 204 | bfd_set_section_alignment (sec, 2); | 636 | | | 637 | | /* Check that we will not run out of space. */ | 638 | 204 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 639 | | | 640 | | /* Set the section size and contents. The actual | 641 | | contents are filled in by our parent. */ | 642 | 204 | bfd_set_section_size (sec, (bfd_size_type) size); | 643 | 204 | sec->contents = vars->data; | 644 | 204 | sec->target_index = vars->sec_index ++; | 645 | | | 646 | | /* Advance data pointer in the vars structure. */ | 647 | 204 | vars->data += size; | 648 | | | 649 | | /* Skip the padding byte if it was not needed. | 650 | | The logic here is that if the string length is odd, | 651 | | then the entire string length, including the null byte, | 652 | | is even and so the extra, padding byte, is not needed. */ | 653 | 204 | if (size & 1) | 654 | 28 | vars->data --; | 655 | | | 656 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 657 | | preserve host alignment requirements. The BFD_ASSERTs in this | 658 | | functions will warn us if we run out of room, but we should | 659 | | already have enough padding built in to ILF_DATA_SIZE. */ | 660 | 204 | #if GCC_VERSION >= 3000 | 661 | 204 | alignment = __alignof__ (struct coff_section_tdata); | 662 | | #else | 663 | | alignment = 8; | 664 | | #endif | 665 | 204 | vars->data | 666 | 204 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 667 | | | 668 | | /* Create a coff_section_tdata structure for our use. */ | 669 | 204 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 670 | 204 | vars->data += sizeof (struct coff_section_tdata); | 671 | | | 672 | 204 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 673 | | | 674 | | /* Create a symbol to refer to this section. */ | 675 | 204 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 676 | | | 677 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 678 | 204 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 679 | | | 680 | 204 | return sec; | 681 | 204 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_section pei-loongarch64.c:pe_ILF_make_a_section Line | Count | Source | 622 | 231 | { | 623 | 231 | asection_ptr sec; | 624 | 231 | flagword flags; | 625 | 231 | intptr_t alignment; | 626 | | | 627 | 231 | sec = bfd_make_section_old_way (vars->abfd, name); | 628 | 231 | if (sec == NULL) | 629 | 0 | return NULL; | 630 | | | 631 | 231 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 632 | | | 633 | 231 | bfd_set_section_flags (sec, flags | extra_flags); | 634 | | | 635 | 231 | bfd_set_section_alignment (sec, 2); | 636 | | | 637 | | /* Check that we will not run out of space. */ | 638 | 231 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 639 | | | 640 | | /* Set the section size and contents. The actual | 641 | | contents are filled in by our parent. */ | 642 | 231 | bfd_set_section_size (sec, (bfd_size_type) size); | 643 | 231 | sec->contents = vars->data; | 644 | 231 | sec->target_index = vars->sec_index ++; | 645 | | | 646 | | /* Advance data pointer in the vars structure. */ | 647 | 231 | vars->data += size; | 648 | | | 649 | | /* Skip the padding byte if it was not needed. | 650 | | The logic here is that if the string length is odd, | 651 | | then the entire string length, including the null byte, | 652 | | is even and so the extra, padding byte, is not needed. */ | 653 | 231 | if (size & 1) | 654 | 31 | vars->data --; | 655 | | | 656 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 657 | | preserve host alignment requirements. The BFD_ASSERTs in this | 658 | | functions will warn us if we run out of room, but we should | 659 | | already have enough padding built in to ILF_DATA_SIZE. */ | 660 | 231 | #if GCC_VERSION >= 3000 | 661 | 231 | alignment = __alignof__ (struct coff_section_tdata); | 662 | | #else | 663 | | alignment = 8; | 664 | | #endif | 665 | 231 | vars->data | 666 | 231 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 667 | | | 668 | | /* Create a coff_section_tdata structure for our use. */ | 669 | 231 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 670 | 231 | vars->data += sizeof (struct coff_section_tdata); | 671 | | | 672 | 231 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 673 | | | 674 | | /* Create a symbol to refer to this section. */ | 675 | 231 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 676 | | | 677 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 678 | 231 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 679 | | | 680 | 231 | return sec; | 681 | 231 | } |
pei-riscv64.c:pe_ILF_make_a_section Line | Count | Source | 622 | 212 | { | 623 | 212 | asection_ptr sec; | 624 | 212 | flagword flags; | 625 | 212 | intptr_t alignment; | 626 | | | 627 | 212 | sec = bfd_make_section_old_way (vars->abfd, name); | 628 | 212 | if (sec == NULL) | 629 | 0 | return NULL; | 630 | | | 631 | 212 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 632 | | | 633 | 212 | bfd_set_section_flags (sec, flags | extra_flags); | 634 | | | 635 | 212 | bfd_set_section_alignment (sec, 2); | 636 | | | 637 | | /* Check that we will not run out of space. */ | 638 | 212 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 639 | | | 640 | | /* Set the section size and contents. The actual | 641 | | contents are filled in by our parent. */ | 642 | 212 | bfd_set_section_size (sec, (bfd_size_type) size); | 643 | 212 | sec->contents = vars->data; | 644 | 212 | sec->target_index = vars->sec_index ++; | 645 | | | 646 | | /* Advance data pointer in the vars structure. */ | 647 | 212 | vars->data += size; | 648 | | | 649 | | /* Skip the padding byte if it was not needed. | 650 | | The logic here is that if the string length is odd, | 651 | | then the entire string length, including the null byte, | 652 | | is even and so the extra, padding byte, is not needed. */ | 653 | 212 | if (size & 1) | 654 | 23 | vars->data --; | 655 | | | 656 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 657 | | preserve host alignment requirements. The BFD_ASSERTs in this | 658 | | functions will warn us if we run out of room, but we should | 659 | | already have enough padding built in to ILF_DATA_SIZE. */ | 660 | 212 | #if GCC_VERSION >= 3000 | 661 | 212 | alignment = __alignof__ (struct coff_section_tdata); | 662 | | #else | 663 | | alignment = 8; | 664 | | #endif | 665 | 212 | vars->data | 666 | 212 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 667 | | | 668 | | /* Create a coff_section_tdata structure for our use. */ | 669 | 212 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 670 | 212 | vars->data += sizeof (struct coff_section_tdata); | 671 | | | 672 | 212 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 673 | | | 674 | | /* Create a symbol to refer to this section. */ | 675 | 212 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 676 | | | 677 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 678 | 212 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 679 | | | 680 | 212 | return sec; | 681 | 212 | } |
pei-arm-wince.c:pe_ILF_make_a_section Line | Count | Source | 622 | 195 | { | 623 | 195 | asection_ptr sec; | 624 | 195 | flagword flags; | 625 | 195 | intptr_t alignment; | 626 | | | 627 | 195 | sec = bfd_make_section_old_way (vars->abfd, name); | 628 | 195 | if (sec == NULL) | 629 | 0 | return NULL; | 630 | | | 631 | 195 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 632 | | | 633 | 195 | bfd_set_section_flags (sec, flags | extra_flags); | 634 | | | 635 | 195 | bfd_set_section_alignment (sec, 2); | 636 | | | 637 | | /* Check that we will not run out of space. */ | 638 | 195 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 639 | | | 640 | | /* Set the section size and contents. The actual | 641 | | contents are filled in by our parent. */ | 642 | 195 | bfd_set_section_size (sec, (bfd_size_type) size); | 643 | 195 | sec->contents = vars->data; | 644 | 195 | sec->target_index = vars->sec_index ++; | 645 | | | 646 | | /* Advance data pointer in the vars structure. */ | 647 | 195 | vars->data += size; | 648 | | | 649 | | /* Skip the padding byte if it was not needed. | 650 | | The logic here is that if the string length is odd, | 651 | | then the entire string length, including the null byte, | 652 | | is even and so the extra, padding byte, is not needed. */ | 653 | 195 | if (size & 1) | 654 | 22 | vars->data --; | 655 | | | 656 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 657 | | preserve host alignment requirements. The BFD_ASSERTs in this | 658 | | functions will warn us if we run out of room, but we should | 659 | | already have enough padding built in to ILF_DATA_SIZE. */ | 660 | 195 | #if GCC_VERSION >= 3000 | 661 | 195 | alignment = __alignof__ (struct coff_section_tdata); | 662 | | #else | 663 | | alignment = 8; | 664 | | #endif | 665 | 195 | vars->data | 666 | 195 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 667 | | | 668 | | /* Create a coff_section_tdata structure for our use. */ | 669 | 195 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 670 | 195 | vars->data += sizeof (struct coff_section_tdata); | 671 | | | 672 | 195 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 673 | | | 674 | | /* Create a symbol to refer to this section. */ | 675 | 195 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 676 | | | 677 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 678 | 195 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 679 | | | 680 | 195 | return sec; | 681 | 195 | } |
pei-arm.c:pe_ILF_make_a_section Line | Count | Source | 622 | 201 | { | 623 | 201 | asection_ptr sec; | 624 | 201 | flagword flags; | 625 | 201 | intptr_t alignment; | 626 | | | 627 | 201 | sec = bfd_make_section_old_way (vars->abfd, name); | 628 | 201 | if (sec == NULL) | 629 | 0 | return NULL; | 630 | | | 631 | 201 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 632 | | | 633 | 201 | bfd_set_section_flags (sec, flags | extra_flags); | 634 | | | 635 | 201 | bfd_set_section_alignment (sec, 2); | 636 | | | 637 | | /* Check that we will not run out of space. */ | 638 | 201 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 639 | | | 640 | | /* Set the section size and contents. The actual | 641 | | contents are filled in by our parent. */ | 642 | 201 | bfd_set_section_size (sec, (bfd_size_type) size); | 643 | 201 | sec->contents = vars->data; | 644 | 201 | sec->target_index = vars->sec_index ++; | 645 | | | 646 | | /* Advance data pointer in the vars structure. */ | 647 | 201 | vars->data += size; | 648 | | | 649 | | /* Skip the padding byte if it was not needed. | 650 | | The logic here is that if the string length is odd, | 651 | | then the entire string length, including the null byte, | 652 | | is even and so the extra, padding byte, is not needed. */ | 653 | 201 | if (size & 1) | 654 | 22 | vars->data --; | 655 | | | 656 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 657 | | preserve host alignment requirements. The BFD_ASSERTs in this | 658 | | functions will warn us if we run out of room, but we should | 659 | | already have enough padding built in to ILF_DATA_SIZE. */ | 660 | 201 | #if GCC_VERSION >= 3000 | 661 | 201 | alignment = __alignof__ (struct coff_section_tdata); | 662 | | #else | 663 | | alignment = 8; | 664 | | #endif | 665 | 201 | vars->data | 666 | 201 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 667 | | | 668 | | /* Create a coff_section_tdata structure for our use. */ | 669 | 201 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 670 | 201 | vars->data += sizeof (struct coff_section_tdata); | 671 | | | 672 | 201 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 673 | | | 674 | | /* Create a symbol to refer to this section. */ | 675 | 201 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 676 | | | 677 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 678 | 201 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 679 | | | 680 | 201 | return sec; | 681 | 201 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_section pei-sh.c:pe_ILF_make_a_section Line | Count | Source | 622 | 254 | { | 623 | 254 | asection_ptr sec; | 624 | 254 | flagword flags; | 625 | 254 | intptr_t alignment; | 626 | | | 627 | 254 | sec = bfd_make_section_old_way (vars->abfd, name); | 628 | 254 | if (sec == NULL) | 629 | 0 | return NULL; | 630 | | | 631 | 254 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 632 | | | 633 | 254 | bfd_set_section_flags (sec, flags | extra_flags); | 634 | | | 635 | 254 | bfd_set_section_alignment (sec, 2); | 636 | | | 637 | | /* Check that we will not run out of space. */ | 638 | 254 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 639 | | | 640 | | /* Set the section size and contents. The actual | 641 | | contents are filled in by our parent. */ | 642 | 254 | bfd_set_section_size (sec, (bfd_size_type) size); | 643 | 254 | sec->contents = vars->data; | 644 | 254 | sec->target_index = vars->sec_index ++; | 645 | | | 646 | | /* Advance data pointer in the vars structure. */ | 647 | 254 | vars->data += size; | 648 | | | 649 | | /* Skip the padding byte if it was not needed. | 650 | | The logic here is that if the string length is odd, | 651 | | then the entire string length, including the null byte, | 652 | | is even and so the extra, padding byte, is not needed. */ | 653 | 254 | if (size & 1) | 654 | 18 | vars->data --; | 655 | | | 656 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 657 | | preserve host alignment requirements. The BFD_ASSERTs in this | 658 | | functions will warn us if we run out of room, but we should | 659 | | already have enough padding built in to ILF_DATA_SIZE. */ | 660 | 254 | #if GCC_VERSION >= 3000 | 661 | 254 | alignment = __alignof__ (struct coff_section_tdata); | 662 | | #else | 663 | | alignment = 8; | 664 | | #endif | 665 | 254 | vars->data | 666 | 254 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 667 | | | 668 | | /* Create a coff_section_tdata structure for our use. */ | 669 | 254 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 670 | 254 | vars->data += sizeof (struct coff_section_tdata); | 671 | | | 672 | 254 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 673 | | | 674 | | /* Create a symbol to refer to this section. */ | 675 | 254 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 676 | | | 677 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 678 | 254 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 679 | | | 680 | 254 | return sec; | 681 | 254 | } |
|
682 | | |
683 | | /* This structure contains the code that goes into the .text section |
684 | | in order to perform a jump into the DLL lookup table. The entries |
685 | | in the table are index by the magic number used to represent the |
686 | | machine type in the PE file. The contents of the data[] arrays in |
687 | | these entries are stolen from the jtab[] arrays in ld/pe-dll.c. |
688 | | The SIZE field says how many bytes in the DATA array are actually |
689 | | used. The OFFSET field says where in the data array the address |
690 | | of the .idata$5 section should be placed. */ |
691 | 1.18k | #define MAX_TEXT_SECTION_SIZE 32 |
692 | | |
693 | | typedef struct |
694 | | { |
695 | | unsigned short magic; |
696 | | unsigned char data[MAX_TEXT_SECTION_SIZE]; |
697 | | unsigned int size; |
698 | | unsigned int offset; |
699 | | } |
700 | | jump_table; |
701 | | |
702 | | static const jump_table jtab[] = |
703 | | { |
704 | | #ifdef I386MAGIC |
705 | | { I386MAGIC, |
706 | | { 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90 }, |
707 | | 8, 2 |
708 | | }, |
709 | | #endif |
710 | | |
711 | | #ifdef AMD64MAGIC |
712 | | { AMD64MAGIC, |
713 | | { 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90 }, |
714 | | 8, 2 |
715 | | }, |
716 | | #endif |
717 | | |
718 | | #ifdef MC68MAGIC |
719 | | { MC68MAGIC, |
720 | | { /* XXX fill me in */ }, |
721 | | 0, 0 |
722 | | }, |
723 | | #endif |
724 | | |
725 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
726 | | { MIPS_ARCH_MAGIC_WINCE, |
727 | | { 0x00, 0x00, 0x08, 0x3c, 0x00, 0x00, 0x08, 0x8d, |
728 | | 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }, |
729 | | 16, 0 |
730 | | }, |
731 | | #endif |
732 | | |
733 | | #ifdef SH_ARCH_MAGIC_WINCE |
734 | | { SH_ARCH_MAGIC_WINCE, |
735 | | { 0x01, 0xd0, 0x02, 0x60, 0x2b, 0x40, |
736 | | 0x09, 0x00, 0x00, 0x00, 0x00, 0x00 }, |
737 | | 12, 8 |
738 | | }, |
739 | | #endif |
740 | | |
741 | | #ifdef AARCH64MAGIC |
742 | | /* We don't currently support jumping to DLLs, so if |
743 | | someone does try emit a runtime trap. Through UDF #0. */ |
744 | | { AARCH64MAGIC, |
745 | | { 0x00, 0x00, 0x00, 0x00 }, |
746 | | 4, 0 |
747 | | }, |
748 | | |
749 | | #endif |
750 | | |
751 | | #ifdef ARMPEMAGIC |
752 | | { ARMPEMAGIC, |
753 | | { 0x00, 0xc0, 0x9f, 0xe5, 0x00, 0xf0, |
754 | | 0x9c, 0xe5, 0x00, 0x00, 0x00, 0x00}, |
755 | | 12, 8 |
756 | | }, |
757 | | #endif |
758 | | |
759 | | #ifdef THUMBPEMAGIC |
760 | | { THUMBPEMAGIC, |
761 | | { 0x40, 0xb4, 0x02, 0x4e, 0x36, 0x68, 0xb4, 0x46, |
762 | | 0x40, 0xbc, 0x60, 0x47, 0x00, 0x00, 0x00, 0x00 }, |
763 | | 16, 12 |
764 | | }, |
765 | | #endif |
766 | | |
767 | | #ifdef LOONGARCH64MAGIC |
768 | | /* We don't currently support jumping to DLLs, so if |
769 | | someone does try emit a runtime trap. Through BREAK 0. */ |
770 | | { LOONGARCH64MAGIC, |
771 | | { 0x00, 0x00, 0x2a, 0x00 }, |
772 | | 4, 0 |
773 | | }, |
774 | | |
775 | | #endif |
776 | | |
777 | | #ifdef RISCV64MAGIC |
778 | | /* We don't currently support jumping to DLLs, so if |
779 | | someone does try emit a runtime trap. Through EBREAK. */ |
780 | | { RISCV64MAGIC, |
781 | | { 0x73, 0x00, 0x10, 0x00 }, |
782 | | 4, 0 |
783 | | }, |
784 | | |
785 | | #endif |
786 | | |
787 | | { 0, { 0 }, 0, 0 } |
788 | | }; |
789 | | |
790 | | #ifndef NUM_ENTRIES |
791 | 222 | #define NUM_ENTRIES(a) (sizeof (a) / sizeof (a)[0]) |
792 | | #endif |
793 | | |
794 | | /* Build a full BFD from the information supplied in a ILF object. */ |
795 | | |
796 | | static bool |
797 | | pe_ILF_build_a_bfd (bfd * abfd, |
798 | | unsigned int magic, |
799 | | char * symbol_name, |
800 | | char * source_dll, |
801 | | unsigned int ordinal, |
802 | | unsigned int types, |
803 | | char * import_name) |
804 | 742 | { |
805 | 742 | bfd_byte * ptr; |
806 | 742 | pe_ILF_vars vars; |
807 | 742 | struct internal_filehdr internal_f; |
808 | 742 | unsigned int import_type; |
809 | 742 | unsigned int import_name_type; |
810 | 742 | asection_ptr id4, id5, id6 = NULL, text = NULL; |
811 | 742 | coff_symbol_type ** imp_sym; |
812 | 742 | unsigned int imp_index; |
813 | 742 | intptr_t alignment; |
814 | | |
815 | | /* Decode and verify the types field of the ILF structure. */ |
816 | 742 | import_type = types & 0x3; |
817 | 742 | import_name_type = (types & 0x1c) >> 2; |
818 | | |
819 | 742 | switch (import_type) |
820 | 742 | { |
821 | 297 | case IMPORT_CODE: |
822 | 516 | case IMPORT_DATA: |
823 | 690 | case IMPORT_CONST: |
824 | 690 | break; |
825 | | |
826 | 52 | default: |
827 | | /* xgettext:c-format */ |
828 | 52 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), |
829 | 52 | abfd, import_type); |
830 | 52 | return false; |
831 | 742 | } |
832 | | |
833 | 690 | switch (import_name_type) |
834 | 690 | { |
835 | 173 | case IMPORT_ORDINAL: |
836 | 231 | case IMPORT_NAME: |
837 | 345 | case IMPORT_NAME_NOPREFIX: |
838 | 547 | case IMPORT_NAME_UNDECORATE: |
839 | 547 | import_name = symbol_name; |
840 | 547 | break; |
841 | | |
842 | 113 | case IMPORT_NAME_EXPORTAS: |
843 | 113 | if (!import_name || !import_name[0]) |
844 | 67 | { |
845 | 67 | _bfd_error_handler (_("%pB: missing import name for " |
846 | 67 | "IMPORT_NAME_EXPORTAS for %s"), |
847 | 67 | abfd, symbol_name); |
848 | 67 | return false; |
849 | 67 | } |
850 | 46 | break; |
851 | | |
852 | 46 | default: |
853 | | /* xgettext:c-format */ |
854 | 30 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), |
855 | 30 | abfd, import_name_type); |
856 | 30 | return false; |
857 | 690 | } |
858 | | |
859 | | /* Initialise local variables. |
860 | | |
861 | | Note these are kept in a structure rather than being |
862 | | declared as statics since bfd frowns on global variables. |
863 | | |
864 | | We are going to construct the contents of the BFD in memory, |
865 | | so allocate all the space that we will need right now. */ |
866 | 593 | vars.bim |
867 | 593 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); |
868 | 593 | if (vars.bim == NULL) |
869 | 0 | return false; |
870 | | |
871 | 593 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); |
872 | 593 | vars.bim->buffer = ptr; |
873 | 593 | vars.bim->size = ILF_DATA_SIZE; |
874 | 593 | if (ptr == NULL) |
875 | 0 | goto error_return; |
876 | | |
877 | | /* Initialise the pointers to regions of the memory and the |
878 | | other contents of the pe_ILF_vars structure as well. */ |
879 | 593 | vars.sym_cache = (coff_symbol_type *) ptr; |
880 | 593 | vars.sym_ptr = (coff_symbol_type *) ptr; |
881 | 593 | vars.sym_index = 0; |
882 | 593 | ptr += SIZEOF_ILF_SYMS; |
883 | | |
884 | 593 | vars.sym_table = (unsigned int *) ptr; |
885 | 593 | vars.table_ptr = (unsigned int *) ptr; |
886 | 593 | ptr += SIZEOF_ILF_SYM_TABLE; |
887 | | |
888 | 593 | vars.native_syms = (combined_entry_type *) ptr; |
889 | 593 | vars.native_ptr = (combined_entry_type *) ptr; |
890 | 593 | ptr += SIZEOF_ILF_NATIVE_SYMS; |
891 | | |
892 | 593 | vars.sym_ptr_table = (coff_symbol_type **) ptr; |
893 | 593 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; |
894 | 593 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; |
895 | | |
896 | 593 | vars.esym_table = (SYMENT *) ptr; |
897 | 593 | vars.esym_ptr = (SYMENT *) ptr; |
898 | 593 | ptr += SIZEOF_ILF_EXT_SYMS; |
899 | | |
900 | 593 | vars.reltab = (arelent *) ptr; |
901 | 593 | vars.relcount = 0; |
902 | 593 | ptr += SIZEOF_ILF_RELOCS; |
903 | | |
904 | 593 | vars.int_reltab = (struct internal_reloc *) ptr; |
905 | 593 | ptr += SIZEOF_ILF_INT_RELOCS; |
906 | | |
907 | 593 | vars.string_table = (char *) ptr; |
908 | 593 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; |
909 | 593 | ptr += SIZEOF_ILF_STRINGS; |
910 | 593 | vars.end_string_ptr = (char *) ptr; |
911 | | |
912 | | /* The remaining space in bim->buffer is used |
913 | | by the pe_ILF_make_a_section() function. */ |
914 | | |
915 | | /* PR 18758: Make sure that the data area is sufficiently aligned for |
916 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence |
917 | | the test of GCC_VERSION. For other compilers we assume 8 byte |
918 | | alignment. */ |
919 | 593 | #if GCC_VERSION >= 3000 |
920 | 593 | alignment = __alignof__ (struct coff_section_tdata); |
921 | | #else |
922 | | alignment = 8; |
923 | | #endif |
924 | 593 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); |
925 | | |
926 | 593 | vars.data = ptr; |
927 | 593 | vars.abfd = abfd; |
928 | 593 | vars.sec_index = 0; |
929 | 593 | vars.magic = magic; |
930 | | |
931 | | /* Create the initial .idata$<n> sections: |
932 | | [.idata$2: Import Directory Table -- not needed] |
933 | | .idata$4: Import Lookup Table |
934 | | .idata$5: Import Address Table |
935 | | |
936 | | Note we do not create a .idata$3 section as this is |
937 | | created for us by the linker script. */ |
938 | 593 | id4 = pe_ILF_make_a_section (&vars, ".idata$4", SIZEOF_IDATA4, 0); |
939 | 593 | id5 = pe_ILF_make_a_section (&vars, ".idata$5", SIZEOF_IDATA5, 0); |
940 | 593 | if (id4 == NULL || id5 == NULL) |
941 | 0 | goto error_return; |
942 | | |
943 | | /* Fill in the contents of these sections. */ |
944 | 593 | if (import_name_type == IMPORT_ORDINAL) |
945 | 173 | { |
946 | 173 | if (ordinal == 0) |
947 | | /* See PR 20907 for a reproducer. */ |
948 | 39 | goto error_return; |
949 | | |
950 | | #if (defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) \ |
951 | | || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64)) |
952 | 66 | ((unsigned int *) id4->contents)[0] = ordinal; |
953 | 66 | ((unsigned int *) id4->contents)[1] = 0x80000000; |
954 | 66 | ((unsigned int *) id5->contents)[0] = ordinal; |
955 | 66 | ((unsigned int *) id5->contents)[1] = 0x80000000; |
956 | | #else |
957 | 68 | ((unsigned int *) id4->contents)[0] = ordinal | 0x80000000; |
958 | 68 | ((unsigned int *) id5->contents)[0] = ordinal | 0x80000000; |
959 | 68 | #endif |
960 | 68 | } |
961 | 420 | else |
962 | 420 | { |
963 | 420 | char *symbol; |
964 | 420 | unsigned int len; |
965 | | |
966 | | /* Create .idata$6 - the Hint Name Table. */ |
967 | 420 | id6 = pe_ILF_make_a_section (&vars, ".idata$6", SIZEOF_IDATA6, 0); |
968 | 420 | if (id6 == NULL) |
969 | 0 | goto error_return; |
970 | | |
971 | | /* If necessary, trim the import symbol name. */ |
972 | 420 | symbol = import_name; |
973 | | |
974 | | /* As used by MS compiler, '_', '@', and '?' are alternative |
975 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, |
976 | | '@' used for fastcall (in C), '_' everywhere else. Only one |
977 | | of these is used for a symbol. We strip this leading char for |
978 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the |
979 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ |
980 | | |
981 | 420 | if (import_name_type != IMPORT_NAME |
982 | 362 | && import_name_type != IMPORT_NAME_EXPORTAS) |
983 | 316 | { |
984 | 316 | char c = symbol[0]; |
985 | | |
986 | | /* Check that we don't remove for targets with empty |
987 | | USER_LABEL_PREFIX the leading underscore. */ |
988 | 316 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) |
989 | 306 | || c == '@' || c == '?') |
990 | 84 | symbol++; |
991 | 316 | } |
992 | | |
993 | 420 | len = strlen (symbol); |
994 | 420 | if (import_name_type == IMPORT_NAME_UNDECORATE) |
995 | 202 | { |
996 | | /* Truncate at the first '@'. */ |
997 | 202 | char *at = strchr (symbol, '@'); |
998 | | |
999 | 202 | if (at != NULL) |
1000 | 46 | len = at - symbol; |
1001 | 202 | } |
1002 | | |
1003 | 420 | id6->contents[0] = ordinal & 0xff; |
1004 | 420 | id6->contents[1] = ordinal >> 8; |
1005 | | |
1006 | 420 | memcpy ((char *) id6->contents + 2, symbol, len); |
1007 | 420 | id6->contents[len + 2] = '\0'; |
1008 | 420 | } |
1009 | | |
1010 | 554 | if (import_name_type != IMPORT_ORDINAL) |
1011 | 420 | { |
1012 | 420 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); |
1013 | 420 | pe_ILF_save_relocs (&vars, id4); |
1014 | | |
1015 | 420 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); |
1016 | 420 | pe_ILF_save_relocs (&vars, id5); |
1017 | 420 | } |
1018 | | |
1019 | | /* Create an import symbol. */ |
1020 | 554 | pe_ILF_make_a_symbol (&vars, "__imp_", symbol_name, id5, 0); |
1021 | 554 | imp_sym = vars.sym_ptr_ptr - 1; |
1022 | 554 | imp_index = vars.sym_index - 1; |
1023 | | |
1024 | | /* Create extra sections depending upon the type of import we are |
1025 | | dealing with. */ |
1026 | 554 | switch (import_type) |
1027 | 554 | { |
1028 | 0 | int i; |
1029 | | |
1030 | 222 | case IMPORT_CODE: |
1031 | | /* CODE functions are special, in that they get a trampoline that |
1032 | | jumps to the main import symbol. Create a .text section to hold it. |
1033 | | First we need to look up its contents in the jump table. */ |
1034 | 479 | for (i = NUM_ENTRIES (jtab); i--;) |
1035 | 479 | { |
1036 | 479 | if (jtab[i].size == 0) |
1037 | 222 | continue; |
1038 | 257 | if (jtab[i].magic == magic) |
1039 | 222 | break; |
1040 | 257 | } |
1041 | | /* If we did not find a matching entry something is wrong. */ |
1042 | 222 | if (i < 0) |
1043 | 0 | abort (); |
1044 | | |
1045 | | /* Create the .text section. */ |
1046 | 222 | text = pe_ILF_make_a_section (&vars, ".text", jtab[i].size, SEC_CODE); |
1047 | 222 | if (text == NULL) |
1048 | 0 | goto error_return; |
1049 | | |
1050 | | /* Copy in the jump code. */ |
1051 | 222 | memcpy (text->contents, jtab[i].data, jtab[i].size); |
1052 | | |
1053 | | /* Create a reloc for the data in the text section. */ |
1054 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
1055 | | if (magic == MIPS_ARCH_MAGIC_WINCE) |
1056 | | { |
1057 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, |
1058 | | (struct bfd_symbol **) imp_sym, |
1059 | | imp_index); |
1060 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); |
1061 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, |
1062 | | (struct bfd_symbol **) imp_sym, |
1063 | | imp_index); |
1064 | | } |
1065 | | else |
1066 | | #endif |
1067 | | #ifdef AMD64MAGIC |
1068 | 30 | if (magic == AMD64MAGIC) |
1069 | 30 | { |
1070 | 30 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, |
1071 | 30 | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, |
1072 | 30 | imp_index); |
1073 | 30 | } |
1074 | 0 | else |
1075 | 0 | #endif |
1076 | 0 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, |
1077 | 0 | BFD_RELOC_32, (asymbol **) imp_sym, |
1078 | 0 | imp_index); |
1079 | | |
1080 | 222 | pe_ILF_save_relocs (&vars, text); |
1081 | 222 | break; |
1082 | | |
1083 | 186 | case IMPORT_DATA: |
1084 | 332 | case IMPORT_CONST: |
1085 | 332 | break; |
1086 | | |
1087 | 0 | default: |
1088 | | /* XXX code not yet written. */ |
1089 | 0 | abort (); |
1090 | 554 | } |
1091 | | |
1092 | | /* Now create a symbol describing the imported value. */ |
1093 | 554 | switch (import_type) |
1094 | 554 | { |
1095 | 222 | case IMPORT_CODE: |
1096 | 222 | pe_ILF_make_a_symbol (&vars, "", symbol_name, text, |
1097 | 222 | BSF_NOT_AT_END | BSF_FUNCTION); |
1098 | | |
1099 | 222 | break; |
1100 | | |
1101 | 186 | case IMPORT_DATA: |
1102 | | /* Nothing to do here. */ |
1103 | 186 | break; |
1104 | | |
1105 | 146 | case IMPORT_CONST: |
1106 | 146 | pe_ILF_make_a_symbol (&vars, "", symbol_name, id5, 0); |
1107 | 146 | break; |
1108 | | |
1109 | 0 | default: |
1110 | | /* XXX code not yet written. */ |
1111 | 0 | abort (); |
1112 | 554 | } |
1113 | | |
1114 | | /* Create an import symbol for the DLL, without the .dll suffix. */ |
1115 | 554 | ptr = (bfd_byte *) strrchr (source_dll, '.'); |
1116 | 554 | if (ptr) |
1117 | 81 | *ptr = 0; |
1118 | 554 | pe_ILF_make_a_symbol (&vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); |
1119 | 554 | if (ptr) |
1120 | 81 | *ptr = '.'; |
1121 | | |
1122 | | /* Initialise the bfd. */ |
1123 | 554 | memset (&internal_f, 0, sizeof (internal_f)); |
1124 | | |
1125 | 554 | internal_f.f_magic = magic; |
1126 | 554 | internal_f.f_symptr = 0; |
1127 | 554 | internal_f.f_nsyms = 0; |
1128 | 554 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ |
1129 | | |
1130 | 554 | if (!bfd_set_start_address (abfd, (bfd_vma) 0) |
1131 | 554 | || !bfd_coff_set_arch_mach_hook (abfd, &internal_f)) |
1132 | 0 | goto error_return; |
1133 | | |
1134 | 554 | if (bfd_coff_mkobject_hook (abfd, (void *) &internal_f, NULL) == NULL) |
1135 | 0 | goto error_return; |
1136 | | |
1137 | 554 | obj_pe (abfd) = true; |
1138 | | #ifdef THUMBPEMAGIC |
1139 | 114 | if (vars.magic == THUMBPEMAGIC) |
1140 | | /* Stop some linker warnings about thumb code not supporting |
1141 | | interworking. */ |
1142 | 54 | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; |
1143 | | #endif |
1144 | | |
1145 | | /* Switch from file contents to memory contents. */ |
1146 | 554 | bfd_cache_close (abfd); |
1147 | | |
1148 | 554 | abfd->iostream = (void *) vars.bim; |
1149 | 554 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; |
1150 | 554 | abfd->iovec = &_bfd_memory_iovec; |
1151 | 554 | abfd->where = 0; |
1152 | 554 | abfd->origin = 0; |
1153 | 554 | abfd->size = 0; |
1154 | 554 | obj_sym_filepos (abfd) = 0; |
1155 | | |
1156 | | /* Point the bfd at the symbol table. */ |
1157 | 554 | obj_symbols (abfd) = vars.sym_cache; |
1158 | 554 | abfd->symcount = vars.sym_index; |
1159 | | |
1160 | 554 | obj_raw_syments (abfd) = vars.native_syms; |
1161 | 554 | obj_raw_syment_count (abfd) = vars.sym_index; |
1162 | 554 | obj_coff_keep_raw_syms (abfd) = true; |
1163 | | |
1164 | 554 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; |
1165 | 554 | obj_coff_keep_syms (abfd) = true; |
1166 | | |
1167 | 554 | obj_convert (abfd) = vars.sym_table; |
1168 | 554 | obj_conv_table_size (abfd) = vars.sym_index; |
1169 | | |
1170 | 554 | obj_coff_strings (abfd) = vars.string_table; |
1171 | 554 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; |
1172 | 554 | obj_coff_keep_strings (abfd) = true; |
1173 | | |
1174 | 554 | return true; |
1175 | | |
1176 | 39 | error_return: |
1177 | 39 | free (vars.bim->buffer); |
1178 | 39 | free (vars.bim); |
1179 | 39 | return false; |
1180 | 554 | } pei-i386.c:pe_ILF_build_a_bfd Line | Count | Source | 804 | 94 | { | 805 | 94 | bfd_byte * ptr; | 806 | 94 | pe_ILF_vars vars; | 807 | 94 | struct internal_filehdr internal_f; | 808 | 94 | unsigned int import_type; | 809 | 94 | unsigned int import_name_type; | 810 | 94 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 811 | 94 | coff_symbol_type ** imp_sym; | 812 | 94 | unsigned int imp_index; | 813 | 94 | intptr_t alignment; | 814 | | | 815 | | /* Decode and verify the types field of the ILF structure. */ | 816 | 94 | import_type = types & 0x3; | 817 | 94 | import_name_type = (types & 0x1c) >> 2; | 818 | | | 819 | 94 | switch (import_type) | 820 | 94 | { | 821 | 49 | case IMPORT_CODE: | 822 | 62 | case IMPORT_DATA: | 823 | 89 | case IMPORT_CONST: | 824 | 89 | break; | 825 | | | 826 | 5 | default: | 827 | | /* xgettext:c-format */ | 828 | 5 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 829 | 5 | abfd, import_type); | 830 | 5 | return false; | 831 | 94 | } | 832 | | | 833 | 89 | switch (import_name_type) | 834 | 89 | { | 835 | 22 | case IMPORT_ORDINAL: | 836 | 27 | case IMPORT_NAME: | 837 | 46 | case IMPORT_NAME_NOPREFIX: | 838 | 70 | case IMPORT_NAME_UNDECORATE: | 839 | 70 | import_name = symbol_name; | 840 | 70 | break; | 841 | | | 842 | 15 | case IMPORT_NAME_EXPORTAS: | 843 | 15 | if (!import_name || !import_name[0]) | 844 | 7 | { | 845 | 7 | _bfd_error_handler (_("%pB: missing import name for " | 846 | 7 | "IMPORT_NAME_EXPORTAS for %s"), | 847 | 7 | abfd, symbol_name); | 848 | 7 | return false; | 849 | 7 | } | 850 | 8 | break; | 851 | | | 852 | 8 | default: | 853 | | /* xgettext:c-format */ | 854 | 4 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 855 | 4 | abfd, import_name_type); | 856 | 4 | return false; | 857 | 89 | } | 858 | | | 859 | | /* Initialise local variables. | 860 | | | 861 | | Note these are kept in a structure rather than being | 862 | | declared as statics since bfd frowns on global variables. | 863 | | | 864 | | We are going to construct the contents of the BFD in memory, | 865 | | so allocate all the space that we will need right now. */ | 866 | 78 | vars.bim | 867 | 78 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 868 | 78 | if (vars.bim == NULL) | 869 | 0 | return false; | 870 | | | 871 | 78 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 872 | 78 | vars.bim->buffer = ptr; | 873 | 78 | vars.bim->size = ILF_DATA_SIZE; | 874 | 78 | if (ptr == NULL) | 875 | 0 | goto error_return; | 876 | | | 877 | | /* Initialise the pointers to regions of the memory and the | 878 | | other contents of the pe_ILF_vars structure as well. */ | 879 | 78 | vars.sym_cache = (coff_symbol_type *) ptr; | 880 | 78 | vars.sym_ptr = (coff_symbol_type *) ptr; | 881 | 78 | vars.sym_index = 0; | 882 | 78 | ptr += SIZEOF_ILF_SYMS; | 883 | | | 884 | 78 | vars.sym_table = (unsigned int *) ptr; | 885 | 78 | vars.table_ptr = (unsigned int *) ptr; | 886 | 78 | ptr += SIZEOF_ILF_SYM_TABLE; | 887 | | | 888 | 78 | vars.native_syms = (combined_entry_type *) ptr; | 889 | 78 | vars.native_ptr = (combined_entry_type *) ptr; | 890 | 78 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 891 | | | 892 | 78 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 893 | 78 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 894 | 78 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 895 | | | 896 | 78 | vars.esym_table = (SYMENT *) ptr; | 897 | 78 | vars.esym_ptr = (SYMENT *) ptr; | 898 | 78 | ptr += SIZEOF_ILF_EXT_SYMS; | 899 | | | 900 | 78 | vars.reltab = (arelent *) ptr; | 901 | 78 | vars.relcount = 0; | 902 | 78 | ptr += SIZEOF_ILF_RELOCS; | 903 | | | 904 | 78 | vars.int_reltab = (struct internal_reloc *) ptr; | 905 | 78 | ptr += SIZEOF_ILF_INT_RELOCS; | 906 | | | 907 | 78 | vars.string_table = (char *) ptr; | 908 | 78 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 909 | 78 | ptr += SIZEOF_ILF_STRINGS; | 910 | 78 | vars.end_string_ptr = (char *) ptr; | 911 | | | 912 | | /* The remaining space in bim->buffer is used | 913 | | by the pe_ILF_make_a_section() function. */ | 914 | | | 915 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 916 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 917 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 918 | | alignment. */ | 919 | 78 | #if GCC_VERSION >= 3000 | 920 | 78 | alignment = __alignof__ (struct coff_section_tdata); | 921 | | #else | 922 | | alignment = 8; | 923 | | #endif | 924 | 78 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 925 | | | 926 | 78 | vars.data = ptr; | 927 | 78 | vars.abfd = abfd; | 928 | 78 | vars.sec_index = 0; | 929 | 78 | vars.magic = magic; | 930 | | | 931 | | /* Create the initial .idata$<n> sections: | 932 | | [.idata$2: Import Directory Table -- not needed] | 933 | | .idata$4: Import Lookup Table | 934 | | .idata$5: Import Address Table | 935 | | | 936 | | Note we do not create a .idata$3 section as this is | 937 | | created for us by the linker script. */ | 938 | 78 | id4 = pe_ILF_make_a_section (&vars, ".idata$4", SIZEOF_IDATA4, 0); | 939 | 78 | id5 = pe_ILF_make_a_section (&vars, ".idata$5", SIZEOF_IDATA5, 0); | 940 | 78 | if (id4 == NULL || id5 == NULL) | 941 | 0 | goto error_return; | 942 | | | 943 | | /* Fill in the contents of these sections. */ | 944 | 78 | if (import_name_type == IMPORT_ORDINAL) | 945 | 22 | { | 946 | 22 | if (ordinal == 0) | 947 | | /* See PR 20907 for a reproducer. */ | 948 | 3 | goto error_return; | 949 | | | 950 | | #if (defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) \ | 951 | | || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64)) | 952 | | ((unsigned int *) id4->contents)[0] = ordinal; | 953 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 954 | | ((unsigned int *) id5->contents)[0] = ordinal; | 955 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 956 | | #else | 957 | 19 | ((unsigned int *) id4->contents)[0] = ordinal | 0x80000000; | 958 | 19 | ((unsigned int *) id5->contents)[0] = ordinal | 0x80000000; | 959 | 19 | #endif | 960 | 19 | } | 961 | 56 | else | 962 | 56 | { | 963 | 56 | char *symbol; | 964 | 56 | unsigned int len; | 965 | | | 966 | | /* Create .idata$6 - the Hint Name Table. */ | 967 | 56 | id6 = pe_ILF_make_a_section (&vars, ".idata$6", SIZEOF_IDATA6, 0); | 968 | 56 | if (id6 == NULL) | 969 | 0 | goto error_return; | 970 | | | 971 | | /* If necessary, trim the import symbol name. */ | 972 | 56 | symbol = import_name; | 973 | | | 974 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 975 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 976 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 977 | | of these is used for a symbol. We strip this leading char for | 978 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 979 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 980 | | | 981 | 56 | if (import_name_type != IMPORT_NAME | 982 | 51 | && import_name_type != IMPORT_NAME_EXPORTAS) | 983 | 43 | { | 984 | 43 | char c = symbol[0]; | 985 | | | 986 | | /* Check that we don't remove for targets with empty | 987 | | USER_LABEL_PREFIX the leading underscore. */ | 988 | 43 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 989 | 41 | || c == '@' || c == '?') | 990 | 15 | symbol++; | 991 | 43 | } | 992 | | | 993 | 56 | len = strlen (symbol); | 994 | 56 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 995 | 24 | { | 996 | | /* Truncate at the first '@'. */ | 997 | 24 | char *at = strchr (symbol, '@'); | 998 | | | 999 | 24 | if (at != NULL) | 1000 | 5 | len = at - symbol; | 1001 | 24 | } | 1002 | | | 1003 | 56 | id6->contents[0] = ordinal & 0xff; | 1004 | 56 | id6->contents[1] = ordinal >> 8; | 1005 | | | 1006 | 56 | memcpy ((char *) id6->contents + 2, symbol, len); | 1007 | 56 | id6->contents[len + 2] = '\0'; | 1008 | 56 | } | 1009 | | | 1010 | 75 | if (import_name_type != IMPORT_ORDINAL) | 1011 | 56 | { | 1012 | 56 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1013 | 56 | pe_ILF_save_relocs (&vars, id4); | 1014 | | | 1015 | 56 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1016 | 56 | pe_ILF_save_relocs (&vars, id5); | 1017 | 56 | } | 1018 | | | 1019 | | /* Create an import symbol. */ | 1020 | 75 | pe_ILF_make_a_symbol (&vars, "__imp_", symbol_name, id5, 0); | 1021 | 75 | imp_sym = vars.sym_ptr_ptr - 1; | 1022 | 75 | imp_index = vars.sym_index - 1; | 1023 | | | 1024 | | /* Create extra sections depending upon the type of import we are | 1025 | | dealing with. */ | 1026 | 75 | switch (import_type) | 1027 | 75 | { | 1028 | 0 | int i; | 1029 | | | 1030 | 41 | case IMPORT_CODE: | 1031 | | /* CODE functions are special, in that they get a trampoline that | 1032 | | jumps to the main import symbol. Create a .text section to hold it. | 1033 | | First we need to look up its contents in the jump table. */ | 1034 | 82 | for (i = NUM_ENTRIES (jtab); i--;) | 1035 | 82 | { | 1036 | 82 | if (jtab[i].size == 0) | 1037 | 41 | continue; | 1038 | 41 | if (jtab[i].magic == magic) | 1039 | 41 | break; | 1040 | 41 | } | 1041 | | /* If we did not find a matching entry something is wrong. */ | 1042 | 41 | if (i < 0) | 1043 | 0 | abort (); | 1044 | | | 1045 | | /* Create the .text section. */ | 1046 | 41 | text = pe_ILF_make_a_section (&vars, ".text", jtab[i].size, SEC_CODE); | 1047 | 41 | if (text == NULL) | 1048 | 0 | goto error_return; | 1049 | | | 1050 | | /* Copy in the jump code. */ | 1051 | 41 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1052 | | | 1053 | | /* Create a reloc for the data in the text section. */ | 1054 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1055 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1056 | | { | 1057 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1058 | | (struct bfd_symbol **) imp_sym, | 1059 | | imp_index); | 1060 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1061 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1062 | | (struct bfd_symbol **) imp_sym, | 1063 | | imp_index); | 1064 | | } | 1065 | | else | 1066 | | #endif | 1067 | | #ifdef AMD64MAGIC | 1068 | | if (magic == AMD64MAGIC) | 1069 | | { | 1070 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1071 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1072 | | imp_index); | 1073 | | } | 1074 | | else | 1075 | | #endif | 1076 | 41 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1077 | 41 | BFD_RELOC_32, (asymbol **) imp_sym, | 1078 | 41 | imp_index); | 1079 | | | 1080 | 41 | pe_ILF_save_relocs (&vars, text); | 1081 | 41 | break; | 1082 | | | 1083 | 13 | case IMPORT_DATA: | 1084 | 34 | case IMPORT_CONST: | 1085 | 34 | break; | 1086 | | | 1087 | 0 | default: | 1088 | | /* XXX code not yet written. */ | 1089 | 0 | abort (); | 1090 | 75 | } | 1091 | | | 1092 | | /* Now create a symbol describing the imported value. */ | 1093 | 75 | switch (import_type) | 1094 | 75 | { | 1095 | 41 | case IMPORT_CODE: | 1096 | 41 | pe_ILF_make_a_symbol (&vars, "", symbol_name, text, | 1097 | 41 | BSF_NOT_AT_END | BSF_FUNCTION); | 1098 | | | 1099 | 41 | break; | 1100 | | | 1101 | 13 | case IMPORT_DATA: | 1102 | | /* Nothing to do here. */ | 1103 | 13 | break; | 1104 | | | 1105 | 21 | case IMPORT_CONST: | 1106 | 21 | pe_ILF_make_a_symbol (&vars, "", symbol_name, id5, 0); | 1107 | 21 | break; | 1108 | | | 1109 | 0 | default: | 1110 | | /* XXX code not yet written. */ | 1111 | 0 | abort (); | 1112 | 75 | } | 1113 | | | 1114 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1115 | 75 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1116 | 75 | if (ptr) | 1117 | 11 | *ptr = 0; | 1118 | 75 | pe_ILF_make_a_symbol (&vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1119 | 75 | if (ptr) | 1120 | 11 | *ptr = '.'; | 1121 | | | 1122 | | /* Initialise the bfd. */ | 1123 | 75 | memset (&internal_f, 0, sizeof (internal_f)); | 1124 | | | 1125 | 75 | internal_f.f_magic = magic; | 1126 | 75 | internal_f.f_symptr = 0; | 1127 | 75 | internal_f.f_nsyms = 0; | 1128 | 75 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1129 | | | 1130 | 75 | if (!bfd_set_start_address (abfd, (bfd_vma) 0) | 1131 | 75 | || !bfd_coff_set_arch_mach_hook (abfd, &internal_f)) | 1132 | 0 | goto error_return; | 1133 | | | 1134 | 75 | if (bfd_coff_mkobject_hook (abfd, (void *) &internal_f, NULL) == NULL) | 1135 | 0 | goto error_return; | 1136 | | | 1137 | 75 | obj_pe (abfd) = true; | 1138 | | #ifdef THUMBPEMAGIC | 1139 | | if (vars.magic == THUMBPEMAGIC) | 1140 | | /* Stop some linker warnings about thumb code not supporting | 1141 | | interworking. */ | 1142 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1143 | | #endif | 1144 | | | 1145 | | /* Switch from file contents to memory contents. */ | 1146 | 75 | bfd_cache_close (abfd); | 1147 | | | 1148 | 75 | abfd->iostream = (void *) vars.bim; | 1149 | 75 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1150 | 75 | abfd->iovec = &_bfd_memory_iovec; | 1151 | 75 | abfd->where = 0; | 1152 | 75 | abfd->origin = 0; | 1153 | 75 | abfd->size = 0; | 1154 | 75 | obj_sym_filepos (abfd) = 0; | 1155 | | | 1156 | | /* Point the bfd at the symbol table. */ | 1157 | 75 | obj_symbols (abfd) = vars.sym_cache; | 1158 | 75 | abfd->symcount = vars.sym_index; | 1159 | | | 1160 | 75 | obj_raw_syments (abfd) = vars.native_syms; | 1161 | 75 | obj_raw_syment_count (abfd) = vars.sym_index; | 1162 | 75 | obj_coff_keep_raw_syms (abfd) = true; | 1163 | | | 1164 | 75 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1165 | 75 | obj_coff_keep_syms (abfd) = true; | 1166 | | | 1167 | 75 | obj_convert (abfd) = vars.sym_table; | 1168 | 75 | obj_conv_table_size (abfd) = vars.sym_index; | 1169 | | | 1170 | 75 | obj_coff_strings (abfd) = vars.string_table; | 1171 | 75 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1172 | 75 | obj_coff_keep_strings (abfd) = true; | 1173 | | | 1174 | 75 | return true; | 1175 | | | 1176 | 3 | error_return: | 1177 | 3 | free (vars.bim->buffer); | 1178 | 3 | free (vars.bim); | 1179 | | return false; | 1180 | 75 | } |
pei-x86_64.c:pe_ILF_build_a_bfd Line | Count | Source | 804 | 109 | { | 805 | 109 | bfd_byte * ptr; | 806 | 109 | pe_ILF_vars vars; | 807 | 109 | struct internal_filehdr internal_f; | 808 | 109 | unsigned int import_type; | 809 | 109 | unsigned int import_name_type; | 810 | 109 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 811 | 109 | coff_symbol_type ** imp_sym; | 812 | 109 | unsigned int imp_index; | 813 | 109 | intptr_t alignment; | 814 | | | 815 | | /* Decode and verify the types field of the ILF structure. */ | 816 | 109 | import_type = types & 0x3; | 817 | 109 | import_name_type = (types & 0x1c) >> 2; | 818 | | | 819 | 109 | switch (import_type) | 820 | 109 | { | 821 | 38 | case IMPORT_CODE: | 822 | 69 | case IMPORT_DATA: | 823 | 103 | case IMPORT_CONST: | 824 | 103 | break; | 825 | | | 826 | 6 | default: | 827 | | /* xgettext:c-format */ | 828 | 6 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 829 | 6 | abfd, import_type); | 830 | 6 | return false; | 831 | 109 | } | 832 | | | 833 | 103 | switch (import_name_type) | 834 | 103 | { | 835 | 22 | case IMPORT_ORDINAL: | 836 | 30 | case IMPORT_NAME: | 837 | 44 | case IMPORT_NAME_NOPREFIX: | 838 | 82 | case IMPORT_NAME_UNDECORATE: | 839 | 82 | import_name = symbol_name; | 840 | 82 | break; | 841 | | | 842 | 16 | case IMPORT_NAME_EXPORTAS: | 843 | 16 | if (!import_name || !import_name[0]) | 844 | 8 | { | 845 | 8 | _bfd_error_handler (_("%pB: missing import name for " | 846 | 8 | "IMPORT_NAME_EXPORTAS for %s"), | 847 | 8 | abfd, symbol_name); | 848 | 8 | return false; | 849 | 8 | } | 850 | 8 | break; | 851 | | | 852 | 8 | default: | 853 | | /* xgettext:c-format */ | 854 | 5 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 855 | 5 | abfd, import_name_type); | 856 | 5 | return false; | 857 | 103 | } | 858 | | | 859 | | /* Initialise local variables. | 860 | | | 861 | | Note these are kept in a structure rather than being | 862 | | declared as statics since bfd frowns on global variables. | 863 | | | 864 | | We are going to construct the contents of the BFD in memory, | 865 | | so allocate all the space that we will need right now. */ | 866 | 90 | vars.bim | 867 | 90 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 868 | 90 | if (vars.bim == NULL) | 869 | 0 | return false; | 870 | | | 871 | 90 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 872 | 90 | vars.bim->buffer = ptr; | 873 | 90 | vars.bim->size = ILF_DATA_SIZE; | 874 | 90 | if (ptr == NULL) | 875 | 0 | goto error_return; | 876 | | | 877 | | /* Initialise the pointers to regions of the memory and the | 878 | | other contents of the pe_ILF_vars structure as well. */ | 879 | 90 | vars.sym_cache = (coff_symbol_type *) ptr; | 880 | 90 | vars.sym_ptr = (coff_symbol_type *) ptr; | 881 | 90 | vars.sym_index = 0; | 882 | 90 | ptr += SIZEOF_ILF_SYMS; | 883 | | | 884 | 90 | vars.sym_table = (unsigned int *) ptr; | 885 | 90 | vars.table_ptr = (unsigned int *) ptr; | 886 | 90 | ptr += SIZEOF_ILF_SYM_TABLE; | 887 | | | 888 | 90 | vars.native_syms = (combined_entry_type *) ptr; | 889 | 90 | vars.native_ptr = (combined_entry_type *) ptr; | 890 | 90 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 891 | | | 892 | 90 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 893 | 90 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 894 | 90 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 895 | | | 896 | 90 | vars.esym_table = (SYMENT *) ptr; | 897 | 90 | vars.esym_ptr = (SYMENT *) ptr; | 898 | 90 | ptr += SIZEOF_ILF_EXT_SYMS; | 899 | | | 900 | 90 | vars.reltab = (arelent *) ptr; | 901 | 90 | vars.relcount = 0; | 902 | 90 | ptr += SIZEOF_ILF_RELOCS; | 903 | | | 904 | 90 | vars.int_reltab = (struct internal_reloc *) ptr; | 905 | 90 | ptr += SIZEOF_ILF_INT_RELOCS; | 906 | | | 907 | 90 | vars.string_table = (char *) ptr; | 908 | 90 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 909 | 90 | ptr += SIZEOF_ILF_STRINGS; | 910 | 90 | vars.end_string_ptr = (char *) ptr; | 911 | | | 912 | | /* The remaining space in bim->buffer is used | 913 | | by the pe_ILF_make_a_section() function. */ | 914 | | | 915 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 916 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 917 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 918 | | alignment. */ | 919 | 90 | #if GCC_VERSION >= 3000 | 920 | 90 | alignment = __alignof__ (struct coff_section_tdata); | 921 | | #else | 922 | | alignment = 8; | 923 | | #endif | 924 | 90 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 925 | | | 926 | 90 | vars.data = ptr; | 927 | 90 | vars.abfd = abfd; | 928 | 90 | vars.sec_index = 0; | 929 | 90 | vars.magic = magic; | 930 | | | 931 | | /* Create the initial .idata$<n> sections: | 932 | | [.idata$2: Import Directory Table -- not needed] | 933 | | .idata$4: Import Lookup Table | 934 | | .idata$5: Import Address Table | 935 | | | 936 | | Note we do not create a .idata$3 section as this is | 937 | | created for us by the linker script. */ | 938 | 90 | id4 = pe_ILF_make_a_section (&vars, ".idata$4", SIZEOF_IDATA4, 0); | 939 | 90 | id5 = pe_ILF_make_a_section (&vars, ".idata$5", SIZEOF_IDATA5, 0); | 940 | 90 | if (id4 == NULL || id5 == NULL) | 941 | 0 | goto error_return; | 942 | | | 943 | | /* Fill in the contents of these sections. */ | 944 | 90 | if (import_name_type == IMPORT_ORDINAL) | 945 | 22 | { | 946 | 22 | if (ordinal == 0) | 947 | | /* See PR 20907 for a reproducer. */ | 948 | 5 | goto error_return; | 949 | | | 950 | 17 | #if (defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) \ | 951 | 17 | || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64)) | 952 | 17 | ((unsigned int *) id4->contents)[0] = ordinal; | 953 | 17 | ((unsigned int *) id4->contents)[1] = 0x80000000; | 954 | 17 | ((unsigned int *) id5->contents)[0] = ordinal; | 955 | 17 | ((unsigned int *) id5->contents)[1] = 0x80000000; | 956 | | #else | 957 | | ((unsigned int *) id4->contents)[0] = ordinal | 0x80000000; | 958 | | ((unsigned int *) id5->contents)[0] = ordinal | 0x80000000; | 959 | | #endif | 960 | 17 | } | 961 | 68 | else | 962 | 68 | { | 963 | 68 | char *symbol; | 964 | 68 | unsigned int len; | 965 | | | 966 | | /* Create .idata$6 - the Hint Name Table. */ | 967 | 68 | id6 = pe_ILF_make_a_section (&vars, ".idata$6", SIZEOF_IDATA6, 0); | 968 | 68 | if (id6 == NULL) | 969 | 0 | goto error_return; | 970 | | | 971 | | /* If necessary, trim the import symbol name. */ | 972 | 68 | symbol = import_name; | 973 | | | 974 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 975 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 976 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 977 | | of these is used for a symbol. We strip this leading char for | 978 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 979 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 980 | | | 981 | 68 | if (import_name_type != IMPORT_NAME | 982 | 60 | && import_name_type != IMPORT_NAME_EXPORTAS) | 983 | 52 | { | 984 | 52 | char c = symbol[0]; | 985 | | | 986 | | /* Check that we don't remove for targets with empty | 987 | | USER_LABEL_PREFIX the leading underscore. */ | 988 | 52 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 989 | 52 | || c == '@' || c == '?') | 990 | 10 | symbol++; | 991 | 52 | } | 992 | | | 993 | 68 | len = strlen (symbol); | 994 | 68 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 995 | 38 | { | 996 | | /* Truncate at the first '@'. */ | 997 | 38 | char *at = strchr (symbol, '@'); | 998 | | | 999 | 38 | if (at != NULL) | 1000 | 17 | len = at - symbol; | 1001 | 38 | } | 1002 | | | 1003 | 68 | id6->contents[0] = ordinal & 0xff; | 1004 | 68 | id6->contents[1] = ordinal >> 8; | 1005 | | | 1006 | 68 | memcpy ((char *) id6->contents + 2, symbol, len); | 1007 | 68 | id6->contents[len + 2] = '\0'; | 1008 | 68 | } | 1009 | | | 1010 | 85 | if (import_name_type != IMPORT_ORDINAL) | 1011 | 68 | { | 1012 | 68 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1013 | 68 | pe_ILF_save_relocs (&vars, id4); | 1014 | | | 1015 | 68 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1016 | 68 | pe_ILF_save_relocs (&vars, id5); | 1017 | 68 | } | 1018 | | | 1019 | | /* Create an import symbol. */ | 1020 | 85 | pe_ILF_make_a_symbol (&vars, "__imp_", symbol_name, id5, 0); | 1021 | 85 | imp_sym = vars.sym_ptr_ptr - 1; | 1022 | 85 | imp_index = vars.sym_index - 1; | 1023 | | | 1024 | | /* Create extra sections depending upon the type of import we are | 1025 | | dealing with. */ | 1026 | 85 | switch (import_type) | 1027 | 85 | { | 1028 | 0 | int i; | 1029 | | | 1030 | 30 | case IMPORT_CODE: | 1031 | | /* CODE functions are special, in that they get a trampoline that | 1032 | | jumps to the main import symbol. Create a .text section to hold it. | 1033 | | First we need to look up its contents in the jump table. */ | 1034 | 60 | for (i = NUM_ENTRIES (jtab); i--;) | 1035 | 60 | { | 1036 | 60 | if (jtab[i].size == 0) | 1037 | 30 | continue; | 1038 | 30 | if (jtab[i].magic == magic) | 1039 | 30 | break; | 1040 | 30 | } | 1041 | | /* If we did not find a matching entry something is wrong. */ | 1042 | 30 | if (i < 0) | 1043 | 0 | abort (); | 1044 | | | 1045 | | /* Create the .text section. */ | 1046 | 30 | text = pe_ILF_make_a_section (&vars, ".text", jtab[i].size, SEC_CODE); | 1047 | 30 | if (text == NULL) | 1048 | 0 | goto error_return; | 1049 | | | 1050 | | /* Copy in the jump code. */ | 1051 | 30 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1052 | | | 1053 | | /* Create a reloc for the data in the text section. */ | 1054 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1055 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1056 | | { | 1057 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1058 | | (struct bfd_symbol **) imp_sym, | 1059 | | imp_index); | 1060 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1061 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1062 | | (struct bfd_symbol **) imp_sym, | 1063 | | imp_index); | 1064 | | } | 1065 | | else | 1066 | | #endif | 1067 | 30 | #ifdef AMD64MAGIC | 1068 | 30 | if (magic == AMD64MAGIC) | 1069 | 30 | { | 1070 | 30 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1071 | 30 | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1072 | 30 | imp_index); | 1073 | 30 | } | 1074 | 0 | else | 1075 | 0 | #endif | 1076 | 0 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1077 | 0 | BFD_RELOC_32, (asymbol **) imp_sym, | 1078 | 0 | imp_index); | 1079 | | | 1080 | 30 | pe_ILF_save_relocs (&vars, text); | 1081 | 30 | break; | 1082 | | | 1083 | 28 | case IMPORT_DATA: | 1084 | 55 | case IMPORT_CONST: | 1085 | 55 | break; | 1086 | | | 1087 | 0 | default: | 1088 | | /* XXX code not yet written. */ | 1089 | 0 | abort (); | 1090 | 85 | } | 1091 | | | 1092 | | /* Now create a symbol describing the imported value. */ | 1093 | 85 | switch (import_type) | 1094 | 85 | { | 1095 | 30 | case IMPORT_CODE: | 1096 | 30 | pe_ILF_make_a_symbol (&vars, "", symbol_name, text, | 1097 | 30 | BSF_NOT_AT_END | BSF_FUNCTION); | 1098 | | | 1099 | 30 | break; | 1100 | | | 1101 | 28 | case IMPORT_DATA: | 1102 | | /* Nothing to do here. */ | 1103 | 28 | break; | 1104 | | | 1105 | 27 | case IMPORT_CONST: | 1106 | 27 | pe_ILF_make_a_symbol (&vars, "", symbol_name, id5, 0); | 1107 | 27 | break; | 1108 | | | 1109 | 0 | default: | 1110 | | /* XXX code not yet written. */ | 1111 | 0 | abort (); | 1112 | 85 | } | 1113 | | | 1114 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1115 | 85 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1116 | 85 | if (ptr) | 1117 | 9 | *ptr = 0; | 1118 | 85 | pe_ILF_make_a_symbol (&vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1119 | 85 | if (ptr) | 1120 | 9 | *ptr = '.'; | 1121 | | | 1122 | | /* Initialise the bfd. */ | 1123 | 85 | memset (&internal_f, 0, sizeof (internal_f)); | 1124 | | | 1125 | 85 | internal_f.f_magic = magic; | 1126 | 85 | internal_f.f_symptr = 0; | 1127 | 85 | internal_f.f_nsyms = 0; | 1128 | 85 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1129 | | | 1130 | 85 | if (!bfd_set_start_address (abfd, (bfd_vma) 0) | 1131 | 85 | || !bfd_coff_set_arch_mach_hook (abfd, &internal_f)) | 1132 | 0 | goto error_return; | 1133 | | | 1134 | 85 | if (bfd_coff_mkobject_hook (abfd, (void *) &internal_f, NULL) == NULL) | 1135 | 0 | goto error_return; | 1136 | | | 1137 | 85 | obj_pe (abfd) = true; | 1138 | | #ifdef THUMBPEMAGIC | 1139 | | if (vars.magic == THUMBPEMAGIC) | 1140 | | /* Stop some linker warnings about thumb code not supporting | 1141 | | interworking. */ | 1142 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1143 | | #endif | 1144 | | | 1145 | | /* Switch from file contents to memory contents. */ | 1146 | 85 | bfd_cache_close (abfd); | 1147 | | | 1148 | 85 | abfd->iostream = (void *) vars.bim; | 1149 | 85 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1150 | 85 | abfd->iovec = &_bfd_memory_iovec; | 1151 | 85 | abfd->where = 0; | 1152 | 85 | abfd->origin = 0; | 1153 | 85 | abfd->size = 0; | 1154 | 85 | obj_sym_filepos (abfd) = 0; | 1155 | | | 1156 | | /* Point the bfd at the symbol table. */ | 1157 | 85 | obj_symbols (abfd) = vars.sym_cache; | 1158 | 85 | abfd->symcount = vars.sym_index; | 1159 | | | 1160 | 85 | obj_raw_syments (abfd) = vars.native_syms; | 1161 | 85 | obj_raw_syment_count (abfd) = vars.sym_index; | 1162 | 85 | obj_coff_keep_raw_syms (abfd) = true; | 1163 | | | 1164 | 85 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1165 | 85 | obj_coff_keep_syms (abfd) = true; | 1166 | | | 1167 | 85 | obj_convert (abfd) = vars.sym_table; | 1168 | 85 | obj_conv_table_size (abfd) = vars.sym_index; | 1169 | | | 1170 | 85 | obj_coff_strings (abfd) = vars.string_table; | 1171 | 85 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1172 | 85 | obj_coff_keep_strings (abfd) = true; | 1173 | | | 1174 | 85 | return true; | 1175 | | | 1176 | 5 | error_return: | 1177 | 5 | free (vars.bim->buffer); | 1178 | 5 | free (vars.bim); | 1179 | | return false; | 1180 | 85 | } |
pei-aarch64.c:pe_ILF_build_a_bfd Line | Count | Source | 804 | 77 | { | 805 | 77 | bfd_byte * ptr; | 806 | 77 | pe_ILF_vars vars; | 807 | 77 | struct internal_filehdr internal_f; | 808 | 77 | unsigned int import_type; | 809 | 77 | unsigned int import_name_type; | 810 | 77 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 811 | 77 | coff_symbol_type ** imp_sym; | 812 | 77 | unsigned int imp_index; | 813 | 77 | intptr_t alignment; | 814 | | | 815 | | /* Decode and verify the types field of the ILF structure. */ | 816 | 77 | import_type = types & 0x3; | 817 | 77 | import_name_type = (types & 0x1c) >> 2; | 818 | | | 819 | 77 | switch (import_type) | 820 | 77 | { | 821 | 37 | case IMPORT_CODE: | 822 | 61 | case IMPORT_DATA: | 823 | 74 | case IMPORT_CONST: | 824 | 74 | break; | 825 | | | 826 | 3 | default: | 827 | | /* xgettext:c-format */ | 828 | 3 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 829 | 3 | abfd, import_type); | 830 | 3 | return false; | 831 | 77 | } | 832 | | | 833 | 74 | switch (import_name_type) | 834 | 74 | { | 835 | 19 | case IMPORT_ORDINAL: | 836 | 28 | case IMPORT_NAME: | 837 | 37 | case IMPORT_NAME_NOPREFIX: | 838 | 60 | case IMPORT_NAME_UNDECORATE: | 839 | 60 | import_name = symbol_name; | 840 | 60 | break; | 841 | | | 842 | 11 | case IMPORT_NAME_EXPORTAS: | 843 | 11 | if (!import_name || !import_name[0]) | 844 | 6 | { | 845 | 6 | _bfd_error_handler (_("%pB: missing import name for " | 846 | 6 | "IMPORT_NAME_EXPORTAS for %s"), | 847 | 6 | abfd, symbol_name); | 848 | 6 | return false; | 849 | 6 | } | 850 | 5 | break; | 851 | | | 852 | 5 | default: | 853 | | /* xgettext:c-format */ | 854 | 3 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 855 | 3 | abfd, import_name_type); | 856 | 3 | return false; | 857 | 74 | } | 858 | | | 859 | | /* Initialise local variables. | 860 | | | 861 | | Note these are kept in a structure rather than being | 862 | | declared as statics since bfd frowns on global variables. | 863 | | | 864 | | We are going to construct the contents of the BFD in memory, | 865 | | so allocate all the space that we will need right now. */ | 866 | 65 | vars.bim | 867 | 65 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 868 | 65 | if (vars.bim == NULL) | 869 | 0 | return false; | 870 | | | 871 | 65 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 872 | 65 | vars.bim->buffer = ptr; | 873 | 65 | vars.bim->size = ILF_DATA_SIZE; | 874 | 65 | if (ptr == NULL) | 875 | 0 | goto error_return; | 876 | | | 877 | | /* Initialise the pointers to regions of the memory and the | 878 | | other contents of the pe_ILF_vars structure as well. */ | 879 | 65 | vars.sym_cache = (coff_symbol_type *) ptr; | 880 | 65 | vars.sym_ptr = (coff_symbol_type *) ptr; | 881 | 65 | vars.sym_index = 0; | 882 | 65 | ptr += SIZEOF_ILF_SYMS; | 883 | | | 884 | 65 | vars.sym_table = (unsigned int *) ptr; | 885 | 65 | vars.table_ptr = (unsigned int *) ptr; | 886 | 65 | ptr += SIZEOF_ILF_SYM_TABLE; | 887 | | | 888 | 65 | vars.native_syms = (combined_entry_type *) ptr; | 889 | 65 | vars.native_ptr = (combined_entry_type *) ptr; | 890 | 65 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 891 | | | 892 | 65 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 893 | 65 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 894 | 65 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 895 | | | 896 | 65 | vars.esym_table = (SYMENT *) ptr; | 897 | 65 | vars.esym_ptr = (SYMENT *) ptr; | 898 | 65 | ptr += SIZEOF_ILF_EXT_SYMS; | 899 | | | 900 | 65 | vars.reltab = (arelent *) ptr; | 901 | 65 | vars.relcount = 0; | 902 | 65 | ptr += SIZEOF_ILF_RELOCS; | 903 | | | 904 | 65 | vars.int_reltab = (struct internal_reloc *) ptr; | 905 | 65 | ptr += SIZEOF_ILF_INT_RELOCS; | 906 | | | 907 | 65 | vars.string_table = (char *) ptr; | 908 | 65 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 909 | 65 | ptr += SIZEOF_ILF_STRINGS; | 910 | 65 | vars.end_string_ptr = (char *) ptr; | 911 | | | 912 | | /* The remaining space in bim->buffer is used | 913 | | by the pe_ILF_make_a_section() function. */ | 914 | | | 915 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 916 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 917 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 918 | | alignment. */ | 919 | 65 | #if GCC_VERSION >= 3000 | 920 | 65 | alignment = __alignof__ (struct coff_section_tdata); | 921 | | #else | 922 | | alignment = 8; | 923 | | #endif | 924 | 65 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 925 | | | 926 | 65 | vars.data = ptr; | 927 | 65 | vars.abfd = abfd; | 928 | 65 | vars.sec_index = 0; | 929 | 65 | vars.magic = magic; | 930 | | | 931 | | /* Create the initial .idata$<n> sections: | 932 | | [.idata$2: Import Directory Table -- not needed] | 933 | | .idata$4: Import Lookup Table | 934 | | .idata$5: Import Address Table | 935 | | | 936 | | Note we do not create a .idata$3 section as this is | 937 | | created for us by the linker script. */ | 938 | 65 | id4 = pe_ILF_make_a_section (&vars, ".idata$4", SIZEOF_IDATA4, 0); | 939 | 65 | id5 = pe_ILF_make_a_section (&vars, ".idata$5", SIZEOF_IDATA5, 0); | 940 | 65 | if (id4 == NULL || id5 == NULL) | 941 | 0 | goto error_return; | 942 | | | 943 | | /* Fill in the contents of these sections. */ | 944 | 65 | if (import_name_type == IMPORT_ORDINAL) | 945 | 19 | { | 946 | 19 | if (ordinal == 0) | 947 | | /* See PR 20907 for a reproducer. */ | 948 | 3 | goto error_return; | 949 | | | 950 | 16 | #if (defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) \ | 951 | 16 | || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64)) | 952 | 16 | ((unsigned int *) id4->contents)[0] = ordinal; | 953 | 16 | ((unsigned int *) id4->contents)[1] = 0x80000000; | 954 | 16 | ((unsigned int *) id5->contents)[0] = ordinal; | 955 | 16 | ((unsigned int *) id5->contents)[1] = 0x80000000; | 956 | | #else | 957 | | ((unsigned int *) id4->contents)[0] = ordinal | 0x80000000; | 958 | | ((unsigned int *) id5->contents)[0] = ordinal | 0x80000000; | 959 | | #endif | 960 | 16 | } | 961 | 46 | else | 962 | 46 | { | 963 | 46 | char *symbol; | 964 | 46 | unsigned int len; | 965 | | | 966 | | /* Create .idata$6 - the Hint Name Table. */ | 967 | 46 | id6 = pe_ILF_make_a_section (&vars, ".idata$6", SIZEOF_IDATA6, 0); | 968 | 46 | if (id6 == NULL) | 969 | 0 | goto error_return; | 970 | | | 971 | | /* If necessary, trim the import symbol name. */ | 972 | 46 | symbol = import_name; | 973 | | | 974 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 975 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 976 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 977 | | of these is used for a symbol. We strip this leading char for | 978 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 979 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 980 | | | 981 | 46 | if (import_name_type != IMPORT_NAME | 982 | 37 | && import_name_type != IMPORT_NAME_EXPORTAS) | 983 | 32 | { | 984 | 32 | char c = symbol[0]; | 985 | | | 986 | | /* Check that we don't remove for targets with empty | 987 | | USER_LABEL_PREFIX the leading underscore. */ | 988 | 32 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 989 | 32 | || c == '@' || c == '?') | 990 | 10 | symbol++; | 991 | 32 | } | 992 | | | 993 | 46 | len = strlen (symbol); | 994 | 46 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 995 | 23 | { | 996 | | /* Truncate at the first '@'. */ | 997 | 23 | char *at = strchr (symbol, '@'); | 998 | | | 999 | 23 | if (at != NULL) | 1000 | 5 | len = at - symbol; | 1001 | 23 | } | 1002 | | | 1003 | 46 | id6->contents[0] = ordinal & 0xff; | 1004 | 46 | id6->contents[1] = ordinal >> 8; | 1005 | | | 1006 | 46 | memcpy ((char *) id6->contents + 2, symbol, len); | 1007 | 46 | id6->contents[len + 2] = '\0'; | 1008 | 46 | } | 1009 | | | 1010 | 62 | if (import_name_type != IMPORT_ORDINAL) | 1011 | 46 | { | 1012 | 46 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1013 | 46 | pe_ILF_save_relocs (&vars, id4); | 1014 | | | 1015 | 46 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1016 | 46 | pe_ILF_save_relocs (&vars, id5); | 1017 | 46 | } | 1018 | | | 1019 | | /* Create an import symbol. */ | 1020 | 62 | pe_ILF_make_a_symbol (&vars, "__imp_", symbol_name, id5, 0); | 1021 | 62 | imp_sym = vars.sym_ptr_ptr - 1; | 1022 | 62 | imp_index = vars.sym_index - 1; | 1023 | | | 1024 | | /* Create extra sections depending upon the type of import we are | 1025 | | dealing with. */ | 1026 | 62 | switch (import_type) | 1027 | 62 | { | 1028 | 0 | int i; | 1029 | | | 1030 | 28 | case IMPORT_CODE: | 1031 | | /* CODE functions are special, in that they get a trampoline that | 1032 | | jumps to the main import symbol. Create a .text section to hold it. | 1033 | | First we need to look up its contents in the jump table. */ | 1034 | 56 | for (i = NUM_ENTRIES (jtab); i--;) | 1035 | 56 | { | 1036 | 56 | if (jtab[i].size == 0) | 1037 | 28 | continue; | 1038 | 28 | if (jtab[i].magic == magic) | 1039 | 28 | break; | 1040 | 28 | } | 1041 | | /* If we did not find a matching entry something is wrong. */ | 1042 | 28 | if (i < 0) | 1043 | 0 | abort (); | 1044 | | | 1045 | | /* Create the .text section. */ | 1046 | 28 | text = pe_ILF_make_a_section (&vars, ".text", jtab[i].size, SEC_CODE); | 1047 | 28 | if (text == NULL) | 1048 | 0 | goto error_return; | 1049 | | | 1050 | | /* Copy in the jump code. */ | 1051 | 28 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1052 | | | 1053 | | /* Create a reloc for the data in the text section. */ | 1054 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1055 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1056 | | { | 1057 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1058 | | (struct bfd_symbol **) imp_sym, | 1059 | | imp_index); | 1060 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1061 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1062 | | (struct bfd_symbol **) imp_sym, | 1063 | | imp_index); | 1064 | | } | 1065 | | else | 1066 | | #endif | 1067 | | #ifdef AMD64MAGIC | 1068 | | if (magic == AMD64MAGIC) | 1069 | | { | 1070 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1071 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1072 | | imp_index); | 1073 | | } | 1074 | | else | 1075 | | #endif | 1076 | 28 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1077 | 28 | BFD_RELOC_32, (asymbol **) imp_sym, | 1078 | 28 | imp_index); | 1079 | | | 1080 | 28 | pe_ILF_save_relocs (&vars, text); | 1081 | 28 | break; | 1082 | | | 1083 | 23 | case IMPORT_DATA: | 1084 | 34 | case IMPORT_CONST: | 1085 | 34 | break; | 1086 | | | 1087 | 0 | default: | 1088 | | /* XXX code not yet written. */ | 1089 | 0 | abort (); | 1090 | 62 | } | 1091 | | | 1092 | | /* Now create a symbol describing the imported value. */ | 1093 | 62 | switch (import_type) | 1094 | 62 | { | 1095 | 28 | case IMPORT_CODE: | 1096 | 28 | pe_ILF_make_a_symbol (&vars, "", symbol_name, text, | 1097 | 28 | BSF_NOT_AT_END | BSF_FUNCTION); | 1098 | | | 1099 | 28 | break; | 1100 | | | 1101 | 23 | case IMPORT_DATA: | 1102 | | /* Nothing to do here. */ | 1103 | 23 | break; | 1104 | | | 1105 | 11 | case IMPORT_CONST: | 1106 | 11 | pe_ILF_make_a_symbol (&vars, "", symbol_name, id5, 0); | 1107 | 11 | break; | 1108 | | | 1109 | 0 | default: | 1110 | | /* XXX code not yet written. */ | 1111 | 0 | abort (); | 1112 | 62 | } | 1113 | | | 1114 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1115 | 62 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1116 | 62 | if (ptr) | 1117 | 13 | *ptr = 0; | 1118 | 62 | pe_ILF_make_a_symbol (&vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1119 | 62 | if (ptr) | 1120 | 13 | *ptr = '.'; | 1121 | | | 1122 | | /* Initialise the bfd. */ | 1123 | 62 | memset (&internal_f, 0, sizeof (internal_f)); | 1124 | | | 1125 | 62 | internal_f.f_magic = magic; | 1126 | 62 | internal_f.f_symptr = 0; | 1127 | 62 | internal_f.f_nsyms = 0; | 1128 | 62 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1129 | | | 1130 | 62 | if (!bfd_set_start_address (abfd, (bfd_vma) 0) | 1131 | 62 | || !bfd_coff_set_arch_mach_hook (abfd, &internal_f)) | 1132 | 0 | goto error_return; | 1133 | | | 1134 | 62 | if (bfd_coff_mkobject_hook (abfd, (void *) &internal_f, NULL) == NULL) | 1135 | 0 | goto error_return; | 1136 | | | 1137 | 62 | obj_pe (abfd) = true; | 1138 | | #ifdef THUMBPEMAGIC | 1139 | | if (vars.magic == THUMBPEMAGIC) | 1140 | | /* Stop some linker warnings about thumb code not supporting | 1141 | | interworking. */ | 1142 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1143 | | #endif | 1144 | | | 1145 | | /* Switch from file contents to memory contents. */ | 1146 | 62 | bfd_cache_close (abfd); | 1147 | | | 1148 | 62 | abfd->iostream = (void *) vars.bim; | 1149 | 62 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1150 | 62 | abfd->iovec = &_bfd_memory_iovec; | 1151 | 62 | abfd->where = 0; | 1152 | 62 | abfd->origin = 0; | 1153 | 62 | abfd->size = 0; | 1154 | 62 | obj_sym_filepos (abfd) = 0; | 1155 | | | 1156 | | /* Point the bfd at the symbol table. */ | 1157 | 62 | obj_symbols (abfd) = vars.sym_cache; | 1158 | 62 | abfd->symcount = vars.sym_index; | 1159 | | | 1160 | 62 | obj_raw_syments (abfd) = vars.native_syms; | 1161 | 62 | obj_raw_syment_count (abfd) = vars.sym_index; | 1162 | 62 | obj_coff_keep_raw_syms (abfd) = true; | 1163 | | | 1164 | 62 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1165 | 62 | obj_coff_keep_syms (abfd) = true; | 1166 | | | 1167 | 62 | obj_convert (abfd) = vars.sym_table; | 1168 | 62 | obj_conv_table_size (abfd) = vars.sym_index; | 1169 | | | 1170 | 62 | obj_coff_strings (abfd) = vars.string_table; | 1171 | 62 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1172 | 62 | obj_coff_keep_strings (abfd) = true; | 1173 | | | 1174 | 62 | return true; | 1175 | | | 1176 | 3 | error_return: | 1177 | 3 | free (vars.bim->buffer); | 1178 | 3 | free (vars.bim); | 1179 | | return false; | 1180 | 62 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_build_a_bfd pei-loongarch64.c:pe_ILF_build_a_bfd Line | Count | Source | 804 | 91 | { | 805 | 91 | bfd_byte * ptr; | 806 | 91 | pe_ILF_vars vars; | 807 | 91 | struct internal_filehdr internal_f; | 808 | 91 | unsigned int import_type; | 809 | 91 | unsigned int import_name_type; | 810 | 91 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 811 | 91 | coff_symbol_type ** imp_sym; | 812 | 91 | unsigned int imp_index; | 813 | 91 | intptr_t alignment; | 814 | | | 815 | | /* Decode and verify the types field of the ILF structure. */ | 816 | 91 | import_type = types & 0x3; | 817 | 91 | import_name_type = (types & 0x1c) >> 2; | 818 | | | 819 | 91 | switch (import_type) | 820 | 91 | { | 821 | 32 | case IMPORT_CODE: | 822 | 69 | case IMPORT_DATA: | 823 | 87 | case IMPORT_CONST: | 824 | 87 | break; | 825 | | | 826 | 4 | default: | 827 | | /* xgettext:c-format */ | 828 | 4 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 829 | 4 | abfd, import_type); | 830 | 4 | return false; | 831 | 91 | } | 832 | | | 833 | 87 | switch (import_name_type) | 834 | 87 | { | 835 | 22 | case IMPORT_ORDINAL: | 836 | 27 | case IMPORT_NAME: | 837 | 39 | case IMPORT_NAME_NOPREFIX: | 838 | 72 | case IMPORT_NAME_UNDECORATE: | 839 | 72 | import_name = symbol_name; | 840 | 72 | break; | 841 | | | 842 | 12 | case IMPORT_NAME_EXPORTAS: | 843 | 12 | if (!import_name || !import_name[0]) | 844 | 8 | { | 845 | 8 | _bfd_error_handler (_("%pB: missing import name for " | 846 | 8 | "IMPORT_NAME_EXPORTAS for %s"), | 847 | 8 | abfd, symbol_name); | 848 | 8 | return false; | 849 | 8 | } | 850 | 4 | break; | 851 | | | 852 | 4 | default: | 853 | | /* xgettext:c-format */ | 854 | 3 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 855 | 3 | abfd, import_name_type); | 856 | 3 | return false; | 857 | 87 | } | 858 | | | 859 | | /* Initialise local variables. | 860 | | | 861 | | Note these are kept in a structure rather than being | 862 | | declared as statics since bfd frowns on global variables. | 863 | | | 864 | | We are going to construct the contents of the BFD in memory, | 865 | | so allocate all the space that we will need right now. */ | 866 | 76 | vars.bim | 867 | 76 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 868 | 76 | if (vars.bim == NULL) | 869 | 0 | return false; | 870 | | | 871 | 76 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 872 | 76 | vars.bim->buffer = ptr; | 873 | 76 | vars.bim->size = ILF_DATA_SIZE; | 874 | 76 | if (ptr == NULL) | 875 | 0 | goto error_return; | 876 | | | 877 | | /* Initialise the pointers to regions of the memory and the | 878 | | other contents of the pe_ILF_vars structure as well. */ | 879 | 76 | vars.sym_cache = (coff_symbol_type *) ptr; | 880 | 76 | vars.sym_ptr = (coff_symbol_type *) ptr; | 881 | 76 | vars.sym_index = 0; | 882 | 76 | ptr += SIZEOF_ILF_SYMS; | 883 | | | 884 | 76 | vars.sym_table = (unsigned int *) ptr; | 885 | 76 | vars.table_ptr = (unsigned int *) ptr; | 886 | 76 | ptr += SIZEOF_ILF_SYM_TABLE; | 887 | | | 888 | 76 | vars.native_syms = (combined_entry_type *) ptr; | 889 | 76 | vars.native_ptr = (combined_entry_type *) ptr; | 890 | 76 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 891 | | | 892 | 76 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 893 | 76 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 894 | 76 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 895 | | | 896 | 76 | vars.esym_table = (SYMENT *) ptr; | 897 | 76 | vars.esym_ptr = (SYMENT *) ptr; | 898 | 76 | ptr += SIZEOF_ILF_EXT_SYMS; | 899 | | | 900 | 76 | vars.reltab = (arelent *) ptr; | 901 | 76 | vars.relcount = 0; | 902 | 76 | ptr += SIZEOF_ILF_RELOCS; | 903 | | | 904 | 76 | vars.int_reltab = (struct internal_reloc *) ptr; | 905 | 76 | ptr += SIZEOF_ILF_INT_RELOCS; | 906 | | | 907 | 76 | vars.string_table = (char *) ptr; | 908 | 76 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 909 | 76 | ptr += SIZEOF_ILF_STRINGS; | 910 | 76 | vars.end_string_ptr = (char *) ptr; | 911 | | | 912 | | /* The remaining space in bim->buffer is used | 913 | | by the pe_ILF_make_a_section() function. */ | 914 | | | 915 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 916 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 917 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 918 | | alignment. */ | 919 | 76 | #if GCC_VERSION >= 3000 | 920 | 76 | alignment = __alignof__ (struct coff_section_tdata); | 921 | | #else | 922 | | alignment = 8; | 923 | | #endif | 924 | 76 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 925 | | | 926 | 76 | vars.data = ptr; | 927 | 76 | vars.abfd = abfd; | 928 | 76 | vars.sec_index = 0; | 929 | 76 | vars.magic = magic; | 930 | | | 931 | | /* Create the initial .idata$<n> sections: | 932 | | [.idata$2: Import Directory Table -- not needed] | 933 | | .idata$4: Import Lookup Table | 934 | | .idata$5: Import Address Table | 935 | | | 936 | | Note we do not create a .idata$3 section as this is | 937 | | created for us by the linker script. */ | 938 | 76 | id4 = pe_ILF_make_a_section (&vars, ".idata$4", SIZEOF_IDATA4, 0); | 939 | 76 | id5 = pe_ILF_make_a_section (&vars, ".idata$5", SIZEOF_IDATA5, 0); | 940 | 76 | if (id4 == NULL || id5 == NULL) | 941 | 0 | goto error_return; | 942 | | | 943 | | /* Fill in the contents of these sections. */ | 944 | 76 | if (import_name_type == IMPORT_ORDINAL) | 945 | 22 | { | 946 | 22 | if (ordinal == 0) | 947 | | /* See PR 20907 for a reproducer. */ | 948 | 4 | goto error_return; | 949 | | | 950 | 18 | #if (defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) \ | 951 | 18 | || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64)) | 952 | 18 | ((unsigned int *) id4->contents)[0] = ordinal; | 953 | 18 | ((unsigned int *) id4->contents)[1] = 0x80000000; | 954 | 18 | ((unsigned int *) id5->contents)[0] = ordinal; | 955 | 18 | ((unsigned int *) id5->contents)[1] = 0x80000000; | 956 | | #else | 957 | | ((unsigned int *) id4->contents)[0] = ordinal | 0x80000000; | 958 | | ((unsigned int *) id5->contents)[0] = ordinal | 0x80000000; | 959 | | #endif | 960 | 18 | } | 961 | 54 | else | 962 | 54 | { | 963 | 54 | char *symbol; | 964 | 54 | unsigned int len; | 965 | | | 966 | | /* Create .idata$6 - the Hint Name Table. */ | 967 | 54 | id6 = pe_ILF_make_a_section (&vars, ".idata$6", SIZEOF_IDATA6, 0); | 968 | 54 | if (id6 == NULL) | 969 | 0 | goto error_return; | 970 | | | 971 | | /* If necessary, trim the import symbol name. */ | 972 | 54 | symbol = import_name; | 973 | | | 974 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 975 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 976 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 977 | | of these is used for a symbol. We strip this leading char for | 978 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 979 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 980 | | | 981 | 54 | if (import_name_type != IMPORT_NAME | 982 | 49 | && import_name_type != IMPORT_NAME_EXPORTAS) | 983 | 45 | { | 984 | 45 | char c = symbol[0]; | 985 | | | 986 | | /* Check that we don't remove for targets with empty | 987 | | USER_LABEL_PREFIX the leading underscore. */ | 988 | 45 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 989 | 45 | || c == '@' || c == '?') | 990 | 10 | symbol++; | 991 | 45 | } | 992 | | | 993 | 54 | len = strlen (symbol); | 994 | 54 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 995 | 33 | { | 996 | | /* Truncate at the first '@'. */ | 997 | 33 | char *at = strchr (symbol, '@'); | 998 | | | 999 | 33 | if (at != NULL) | 1000 | 6 | len = at - symbol; | 1001 | 33 | } | 1002 | | | 1003 | 54 | id6->contents[0] = ordinal & 0xff; | 1004 | 54 | id6->contents[1] = ordinal >> 8; | 1005 | | | 1006 | 54 | memcpy ((char *) id6->contents + 2, symbol, len); | 1007 | 54 | id6->contents[len + 2] = '\0'; | 1008 | 54 | } | 1009 | | | 1010 | 72 | if (import_name_type != IMPORT_ORDINAL) | 1011 | 54 | { | 1012 | 54 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1013 | 54 | pe_ILF_save_relocs (&vars, id4); | 1014 | | | 1015 | 54 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1016 | 54 | pe_ILF_save_relocs (&vars, id5); | 1017 | 54 | } | 1018 | | | 1019 | | /* Create an import symbol. */ | 1020 | 72 | pe_ILF_make_a_symbol (&vars, "__imp_", symbol_name, id5, 0); | 1021 | 72 | imp_sym = vars.sym_ptr_ptr - 1; | 1022 | 72 | imp_index = vars.sym_index - 1; | 1023 | | | 1024 | | /* Create extra sections depending upon the type of import we are | 1025 | | dealing with. */ | 1026 | 72 | switch (import_type) | 1027 | 72 | { | 1028 | 0 | int i; | 1029 | | | 1030 | 25 | case IMPORT_CODE: | 1031 | | /* CODE functions are special, in that they get a trampoline that | 1032 | | jumps to the main import symbol. Create a .text section to hold it. | 1033 | | First we need to look up its contents in the jump table. */ | 1034 | 50 | for (i = NUM_ENTRIES (jtab); i--;) | 1035 | 50 | { | 1036 | 50 | if (jtab[i].size == 0) | 1037 | 25 | continue; | 1038 | 25 | if (jtab[i].magic == magic) | 1039 | 25 | break; | 1040 | 25 | } | 1041 | | /* If we did not find a matching entry something is wrong. */ | 1042 | 25 | if (i < 0) | 1043 | 0 | abort (); | 1044 | | | 1045 | | /* Create the .text section. */ | 1046 | 25 | text = pe_ILF_make_a_section (&vars, ".text", jtab[i].size, SEC_CODE); | 1047 | 25 | if (text == NULL) | 1048 | 0 | goto error_return; | 1049 | | | 1050 | | /* Copy in the jump code. */ | 1051 | 25 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1052 | | | 1053 | | /* Create a reloc for the data in the text section. */ | 1054 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1055 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1056 | | { | 1057 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1058 | | (struct bfd_symbol **) imp_sym, | 1059 | | imp_index); | 1060 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1061 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1062 | | (struct bfd_symbol **) imp_sym, | 1063 | | imp_index); | 1064 | | } | 1065 | | else | 1066 | | #endif | 1067 | | #ifdef AMD64MAGIC | 1068 | | if (magic == AMD64MAGIC) | 1069 | | { | 1070 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1071 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1072 | | imp_index); | 1073 | | } | 1074 | | else | 1075 | | #endif | 1076 | 25 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1077 | 25 | BFD_RELOC_32, (asymbol **) imp_sym, | 1078 | 25 | imp_index); | 1079 | | | 1080 | 25 | pe_ILF_save_relocs (&vars, text); | 1081 | 25 | break; | 1082 | | | 1083 | 34 | case IMPORT_DATA: | 1084 | 47 | case IMPORT_CONST: | 1085 | 47 | break; | 1086 | | | 1087 | 0 | default: | 1088 | | /* XXX code not yet written. */ | 1089 | 0 | abort (); | 1090 | 72 | } | 1091 | | | 1092 | | /* Now create a symbol describing the imported value. */ | 1093 | 72 | switch (import_type) | 1094 | 72 | { | 1095 | 25 | case IMPORT_CODE: | 1096 | 25 | pe_ILF_make_a_symbol (&vars, "", symbol_name, text, | 1097 | 25 | BSF_NOT_AT_END | BSF_FUNCTION); | 1098 | | | 1099 | 25 | break; | 1100 | | | 1101 | 34 | case IMPORT_DATA: | 1102 | | /* Nothing to do here. */ | 1103 | 34 | break; | 1104 | | | 1105 | 13 | case IMPORT_CONST: | 1106 | 13 | pe_ILF_make_a_symbol (&vars, "", symbol_name, id5, 0); | 1107 | 13 | break; | 1108 | | | 1109 | 0 | default: | 1110 | | /* XXX code not yet written. */ | 1111 | 0 | abort (); | 1112 | 72 | } | 1113 | | | 1114 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1115 | 72 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1116 | 72 | if (ptr) | 1117 | 10 | *ptr = 0; | 1118 | 72 | pe_ILF_make_a_symbol (&vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1119 | 72 | if (ptr) | 1120 | 10 | *ptr = '.'; | 1121 | | | 1122 | | /* Initialise the bfd. */ | 1123 | 72 | memset (&internal_f, 0, sizeof (internal_f)); | 1124 | | | 1125 | 72 | internal_f.f_magic = magic; | 1126 | 72 | internal_f.f_symptr = 0; | 1127 | 72 | internal_f.f_nsyms = 0; | 1128 | 72 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1129 | | | 1130 | 72 | if (!bfd_set_start_address (abfd, (bfd_vma) 0) | 1131 | 72 | || !bfd_coff_set_arch_mach_hook (abfd, &internal_f)) | 1132 | 0 | goto error_return; | 1133 | | | 1134 | 72 | if (bfd_coff_mkobject_hook (abfd, (void *) &internal_f, NULL) == NULL) | 1135 | 0 | goto error_return; | 1136 | | | 1137 | 72 | obj_pe (abfd) = true; | 1138 | | #ifdef THUMBPEMAGIC | 1139 | | if (vars.magic == THUMBPEMAGIC) | 1140 | | /* Stop some linker warnings about thumb code not supporting | 1141 | | interworking. */ | 1142 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1143 | | #endif | 1144 | | | 1145 | | /* Switch from file contents to memory contents. */ | 1146 | 72 | bfd_cache_close (abfd); | 1147 | | | 1148 | 72 | abfd->iostream = (void *) vars.bim; | 1149 | 72 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1150 | 72 | abfd->iovec = &_bfd_memory_iovec; | 1151 | 72 | abfd->where = 0; | 1152 | 72 | abfd->origin = 0; | 1153 | 72 | abfd->size = 0; | 1154 | 72 | obj_sym_filepos (abfd) = 0; | 1155 | | | 1156 | | /* Point the bfd at the symbol table. */ | 1157 | 72 | obj_symbols (abfd) = vars.sym_cache; | 1158 | 72 | abfd->symcount = vars.sym_index; | 1159 | | | 1160 | 72 | obj_raw_syments (abfd) = vars.native_syms; | 1161 | 72 | obj_raw_syment_count (abfd) = vars.sym_index; | 1162 | 72 | obj_coff_keep_raw_syms (abfd) = true; | 1163 | | | 1164 | 72 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1165 | 72 | obj_coff_keep_syms (abfd) = true; | 1166 | | | 1167 | 72 | obj_convert (abfd) = vars.sym_table; | 1168 | 72 | obj_conv_table_size (abfd) = vars.sym_index; | 1169 | | | 1170 | 72 | obj_coff_strings (abfd) = vars.string_table; | 1171 | 72 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1172 | 72 | obj_coff_keep_strings (abfd) = true; | 1173 | | | 1174 | 72 | return true; | 1175 | | | 1176 | 4 | error_return: | 1177 | 4 | free (vars.bim->buffer); | 1178 | 4 | free (vars.bim); | 1179 | | return false; | 1180 | 72 | } |
pei-riscv64.c:pe_ILF_build_a_bfd Line | Count | Source | 804 | 85 | { | 805 | 85 | bfd_byte * ptr; | 806 | 85 | pe_ILF_vars vars; | 807 | 85 | struct internal_filehdr internal_f; | 808 | 85 | unsigned int import_type; | 809 | 85 | unsigned int import_name_type; | 810 | 85 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 811 | 85 | coff_symbol_type ** imp_sym; | 812 | 85 | unsigned int imp_index; | 813 | 85 | intptr_t alignment; | 814 | | | 815 | | /* Decode and verify the types field of the ILF structure. */ | 816 | 85 | import_type = types & 0x3; | 817 | 85 | import_name_type = (types & 0x1c) >> 2; | 818 | | | 819 | 85 | switch (import_type) | 820 | 85 | { | 821 | 25 | case IMPORT_CODE: | 822 | 46 | case IMPORT_DATA: | 823 | 80 | case IMPORT_CONST: | 824 | 80 | break; | 825 | | | 826 | 5 | default: | 827 | | /* xgettext:c-format */ | 828 | 5 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 829 | 5 | abfd, import_type); | 830 | 5 | return false; | 831 | 85 | } | 832 | | | 833 | 80 | switch (import_name_type) | 834 | 80 | { | 835 | 20 | case IMPORT_ORDINAL: | 836 | 26 | case IMPORT_NAME: | 837 | 35 | case IMPORT_NAME_NOPREFIX: | 838 | 66 | case IMPORT_NAME_UNDECORATE: | 839 | 66 | import_name = symbol_name; | 840 | 66 | break; | 841 | | | 842 | 12 | case IMPORT_NAME_EXPORTAS: | 843 | 12 | if (!import_name || !import_name[0]) | 844 | 6 | { | 845 | 6 | _bfd_error_handler (_("%pB: missing import name for " | 846 | 6 | "IMPORT_NAME_EXPORTAS for %s"), | 847 | 6 | abfd, symbol_name); | 848 | 6 | return false; | 849 | 6 | } | 850 | 6 | break; | 851 | | | 852 | 6 | default: | 853 | | /* xgettext:c-format */ | 854 | 2 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 855 | 2 | abfd, import_name_type); | 856 | 2 | return false; | 857 | 80 | } | 858 | | | 859 | | /* Initialise local variables. | 860 | | | 861 | | Note these are kept in a structure rather than being | 862 | | declared as statics since bfd frowns on global variables. | 863 | | | 864 | | We are going to construct the contents of the BFD in memory, | 865 | | so allocate all the space that we will need right now. */ | 866 | 72 | vars.bim | 867 | 72 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 868 | 72 | if (vars.bim == NULL) | 869 | 0 | return false; | 870 | | | 871 | 72 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 872 | 72 | vars.bim->buffer = ptr; | 873 | 72 | vars.bim->size = ILF_DATA_SIZE; | 874 | 72 | if (ptr == NULL) | 875 | 0 | goto error_return; | 876 | | | 877 | | /* Initialise the pointers to regions of the memory and the | 878 | | other contents of the pe_ILF_vars structure as well. */ | 879 | 72 | vars.sym_cache = (coff_symbol_type *) ptr; | 880 | 72 | vars.sym_ptr = (coff_symbol_type *) ptr; | 881 | 72 | vars.sym_index = 0; | 882 | 72 | ptr += SIZEOF_ILF_SYMS; | 883 | | | 884 | 72 | vars.sym_table = (unsigned int *) ptr; | 885 | 72 | vars.table_ptr = (unsigned int *) ptr; | 886 | 72 | ptr += SIZEOF_ILF_SYM_TABLE; | 887 | | | 888 | 72 | vars.native_syms = (combined_entry_type *) ptr; | 889 | 72 | vars.native_ptr = (combined_entry_type *) ptr; | 890 | 72 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 891 | | | 892 | 72 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 893 | 72 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 894 | 72 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 895 | | | 896 | 72 | vars.esym_table = (SYMENT *) ptr; | 897 | 72 | vars.esym_ptr = (SYMENT *) ptr; | 898 | 72 | ptr += SIZEOF_ILF_EXT_SYMS; | 899 | | | 900 | 72 | vars.reltab = (arelent *) ptr; | 901 | 72 | vars.relcount = 0; | 902 | 72 | ptr += SIZEOF_ILF_RELOCS; | 903 | | | 904 | 72 | vars.int_reltab = (struct internal_reloc *) ptr; | 905 | 72 | ptr += SIZEOF_ILF_INT_RELOCS; | 906 | | | 907 | 72 | vars.string_table = (char *) ptr; | 908 | 72 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 909 | 72 | ptr += SIZEOF_ILF_STRINGS; | 910 | 72 | vars.end_string_ptr = (char *) ptr; | 911 | | | 912 | | /* The remaining space in bim->buffer is used | 913 | | by the pe_ILF_make_a_section() function. */ | 914 | | | 915 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 916 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 917 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 918 | | alignment. */ | 919 | 72 | #if GCC_VERSION >= 3000 | 920 | 72 | alignment = __alignof__ (struct coff_section_tdata); | 921 | | #else | 922 | | alignment = 8; | 923 | | #endif | 924 | 72 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 925 | | | 926 | 72 | vars.data = ptr; | 927 | 72 | vars.abfd = abfd; | 928 | 72 | vars.sec_index = 0; | 929 | 72 | vars.magic = magic; | 930 | | | 931 | | /* Create the initial .idata$<n> sections: | 932 | | [.idata$2: Import Directory Table -- not needed] | 933 | | .idata$4: Import Lookup Table | 934 | | .idata$5: Import Address Table | 935 | | | 936 | | Note we do not create a .idata$3 section as this is | 937 | | created for us by the linker script. */ | 938 | 72 | id4 = pe_ILF_make_a_section (&vars, ".idata$4", SIZEOF_IDATA4, 0); | 939 | 72 | id5 = pe_ILF_make_a_section (&vars, ".idata$5", SIZEOF_IDATA5, 0); | 940 | 72 | if (id4 == NULL || id5 == NULL) | 941 | 0 | goto error_return; | 942 | | | 943 | | /* Fill in the contents of these sections. */ | 944 | 72 | if (import_name_type == IMPORT_ORDINAL) | 945 | 20 | { | 946 | 20 | if (ordinal == 0) | 947 | | /* See PR 20907 for a reproducer. */ | 948 | 5 | goto error_return; | 949 | | | 950 | 15 | #if (defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) \ | 951 | 15 | || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64)) | 952 | 15 | ((unsigned int *) id4->contents)[0] = ordinal; | 953 | 15 | ((unsigned int *) id4->contents)[1] = 0x80000000; | 954 | 15 | ((unsigned int *) id5->contents)[0] = ordinal; | 955 | 15 | ((unsigned int *) id5->contents)[1] = 0x80000000; | 956 | | #else | 957 | | ((unsigned int *) id4->contents)[0] = ordinal | 0x80000000; | 958 | | ((unsigned int *) id5->contents)[0] = ordinal | 0x80000000; | 959 | | #endif | 960 | 15 | } | 961 | 52 | else | 962 | 52 | { | 963 | 52 | char *symbol; | 964 | 52 | unsigned int len; | 965 | | | 966 | | /* Create .idata$6 - the Hint Name Table. */ | 967 | 52 | id6 = pe_ILF_make_a_section (&vars, ".idata$6", SIZEOF_IDATA6, 0); | 968 | 52 | if (id6 == NULL) | 969 | 0 | goto error_return; | 970 | | | 971 | | /* If necessary, trim the import symbol name. */ | 972 | 52 | symbol = import_name; | 973 | | | 974 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 975 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 976 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 977 | | of these is used for a symbol. We strip this leading char for | 978 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 979 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 980 | | | 981 | 52 | if (import_name_type != IMPORT_NAME | 982 | 46 | && import_name_type != IMPORT_NAME_EXPORTAS) | 983 | 40 | { | 984 | 40 | char c = symbol[0]; | 985 | | | 986 | | /* Check that we don't remove for targets with empty | 987 | | USER_LABEL_PREFIX the leading underscore. */ | 988 | 40 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 989 | 40 | || c == '@' || c == '?') | 990 | 11 | symbol++; | 991 | 40 | } | 992 | | | 993 | 52 | len = strlen (symbol); | 994 | 52 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 995 | 31 | { | 996 | | /* Truncate at the first '@'. */ | 997 | 31 | char *at = strchr (symbol, '@'); | 998 | | | 999 | 31 | if (at != NULL) | 1000 | 5 | len = at - symbol; | 1001 | 31 | } | 1002 | | | 1003 | 52 | id6->contents[0] = ordinal & 0xff; | 1004 | 52 | id6->contents[1] = ordinal >> 8; | 1005 | | | 1006 | 52 | memcpy ((char *) id6->contents + 2, symbol, len); | 1007 | 52 | id6->contents[len + 2] = '\0'; | 1008 | 52 | } | 1009 | | | 1010 | 67 | if (import_name_type != IMPORT_ORDINAL) | 1011 | 52 | { | 1012 | 52 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1013 | 52 | pe_ILF_save_relocs (&vars, id4); | 1014 | | | 1015 | 52 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1016 | 52 | pe_ILF_save_relocs (&vars, id5); | 1017 | 52 | } | 1018 | | | 1019 | | /* Create an import symbol. */ | 1020 | 67 | pe_ILF_make_a_symbol (&vars, "__imp_", symbol_name, id5, 0); | 1021 | 67 | imp_sym = vars.sym_ptr_ptr - 1; | 1022 | 67 | imp_index = vars.sym_index - 1; | 1023 | | | 1024 | | /* Create extra sections depending upon the type of import we are | 1025 | | dealing with. */ | 1026 | 67 | switch (import_type) | 1027 | 67 | { | 1028 | 0 | int i; | 1029 | | | 1030 | 16 | case IMPORT_CODE: | 1031 | | /* CODE functions are special, in that they get a trampoline that | 1032 | | jumps to the main import symbol. Create a .text section to hold it. | 1033 | | First we need to look up its contents in the jump table. */ | 1034 | 32 | for (i = NUM_ENTRIES (jtab); i--;) | 1035 | 32 | { | 1036 | 32 | if (jtab[i].size == 0) | 1037 | 16 | continue; | 1038 | 16 | if (jtab[i].magic == magic) | 1039 | 16 | break; | 1040 | 16 | } | 1041 | | /* If we did not find a matching entry something is wrong. */ | 1042 | 16 | if (i < 0) | 1043 | 0 | abort (); | 1044 | | | 1045 | | /* Create the .text section. */ | 1046 | 16 | text = pe_ILF_make_a_section (&vars, ".text", jtab[i].size, SEC_CODE); | 1047 | 16 | if (text == NULL) | 1048 | 0 | goto error_return; | 1049 | | | 1050 | | /* Copy in the jump code. */ | 1051 | 16 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1052 | | | 1053 | | /* Create a reloc for the data in the text section. */ | 1054 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1055 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1056 | | { | 1057 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1058 | | (struct bfd_symbol **) imp_sym, | 1059 | | imp_index); | 1060 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1061 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1062 | | (struct bfd_symbol **) imp_sym, | 1063 | | imp_index); | 1064 | | } | 1065 | | else | 1066 | | #endif | 1067 | | #ifdef AMD64MAGIC | 1068 | | if (magic == AMD64MAGIC) | 1069 | | { | 1070 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1071 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1072 | | imp_index); | 1073 | | } | 1074 | | else | 1075 | | #endif | 1076 | 16 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1077 | 16 | BFD_RELOC_32, (asymbol **) imp_sym, | 1078 | 16 | imp_index); | 1079 | | | 1080 | 16 | pe_ILF_save_relocs (&vars, text); | 1081 | 16 | break; | 1082 | | | 1083 | 19 | case IMPORT_DATA: | 1084 | 51 | case IMPORT_CONST: | 1085 | 51 | break; | 1086 | | | 1087 | 0 | default: | 1088 | | /* XXX code not yet written. */ | 1089 | 0 | abort (); | 1090 | 67 | } | 1091 | | | 1092 | | /* Now create a symbol describing the imported value. */ | 1093 | 67 | switch (import_type) | 1094 | 67 | { | 1095 | 16 | case IMPORT_CODE: | 1096 | 16 | pe_ILF_make_a_symbol (&vars, "", symbol_name, text, | 1097 | 16 | BSF_NOT_AT_END | BSF_FUNCTION); | 1098 | | | 1099 | 16 | break; | 1100 | | | 1101 | 19 | case IMPORT_DATA: | 1102 | | /* Nothing to do here. */ | 1103 | 19 | break; | 1104 | | | 1105 | 32 | case IMPORT_CONST: | 1106 | 32 | pe_ILF_make_a_symbol (&vars, "", symbol_name, id5, 0); | 1107 | 32 | break; | 1108 | | | 1109 | 0 | default: | 1110 | | /* XXX code not yet written. */ | 1111 | 0 | abort (); | 1112 | 67 | } | 1113 | | | 1114 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1115 | 67 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1116 | 67 | if (ptr) | 1117 | 10 | *ptr = 0; | 1118 | 67 | pe_ILF_make_a_symbol (&vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1119 | 67 | if (ptr) | 1120 | 10 | *ptr = '.'; | 1121 | | | 1122 | | /* Initialise the bfd. */ | 1123 | 67 | memset (&internal_f, 0, sizeof (internal_f)); | 1124 | | | 1125 | 67 | internal_f.f_magic = magic; | 1126 | 67 | internal_f.f_symptr = 0; | 1127 | 67 | internal_f.f_nsyms = 0; | 1128 | 67 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1129 | | | 1130 | 67 | if (!bfd_set_start_address (abfd, (bfd_vma) 0) | 1131 | 67 | || !bfd_coff_set_arch_mach_hook (abfd, &internal_f)) | 1132 | 0 | goto error_return; | 1133 | | | 1134 | 67 | if (bfd_coff_mkobject_hook (abfd, (void *) &internal_f, NULL) == NULL) | 1135 | 0 | goto error_return; | 1136 | | | 1137 | 67 | obj_pe (abfd) = true; | 1138 | | #ifdef THUMBPEMAGIC | 1139 | | if (vars.magic == THUMBPEMAGIC) | 1140 | | /* Stop some linker warnings about thumb code not supporting | 1141 | | interworking. */ | 1142 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1143 | | #endif | 1144 | | | 1145 | | /* Switch from file contents to memory contents. */ | 1146 | 67 | bfd_cache_close (abfd); | 1147 | | | 1148 | 67 | abfd->iostream = (void *) vars.bim; | 1149 | 67 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1150 | 67 | abfd->iovec = &_bfd_memory_iovec; | 1151 | 67 | abfd->where = 0; | 1152 | 67 | abfd->origin = 0; | 1153 | 67 | abfd->size = 0; | 1154 | 67 | obj_sym_filepos (abfd) = 0; | 1155 | | | 1156 | | /* Point the bfd at the symbol table. */ | 1157 | 67 | obj_symbols (abfd) = vars.sym_cache; | 1158 | 67 | abfd->symcount = vars.sym_index; | 1159 | | | 1160 | 67 | obj_raw_syments (abfd) = vars.native_syms; | 1161 | 67 | obj_raw_syment_count (abfd) = vars.sym_index; | 1162 | 67 | obj_coff_keep_raw_syms (abfd) = true; | 1163 | | | 1164 | 67 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1165 | 67 | obj_coff_keep_syms (abfd) = true; | 1166 | | | 1167 | 67 | obj_convert (abfd) = vars.sym_table; | 1168 | 67 | obj_conv_table_size (abfd) = vars.sym_index; | 1169 | | | 1170 | 67 | obj_coff_strings (abfd) = vars.string_table; | 1171 | 67 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1172 | 67 | obj_coff_keep_strings (abfd) = true; | 1173 | | | 1174 | 67 | return true; | 1175 | | | 1176 | 5 | error_return: | 1177 | 5 | free (vars.bim->buffer); | 1178 | 5 | free (vars.bim); | 1179 | | return false; | 1180 | 67 | } |
pei-arm-wince.c:pe_ILF_build_a_bfd Line | Count | Source | 804 | 83 | { | 805 | 83 | bfd_byte * ptr; | 806 | 83 | pe_ILF_vars vars; | 807 | 83 | struct internal_filehdr internal_f; | 808 | 83 | unsigned int import_type; | 809 | 83 | unsigned int import_name_type; | 810 | 83 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 811 | 83 | coff_symbol_type ** imp_sym; | 812 | 83 | unsigned int imp_index; | 813 | 83 | intptr_t alignment; | 814 | | | 815 | | /* Decode and verify the types field of the ILF structure. */ | 816 | 83 | import_type = types & 0x3; | 817 | 83 | import_name_type = (types & 0x1c) >> 2; | 818 | | | 819 | 83 | switch (import_type) | 820 | 83 | { | 821 | 39 | case IMPORT_CODE: | 822 | 67 | case IMPORT_DATA: | 823 | 78 | case IMPORT_CONST: | 824 | 78 | break; | 825 | | | 826 | 5 | default: | 827 | | /* xgettext:c-format */ | 828 | 5 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 829 | 5 | abfd, import_type); | 830 | 5 | return false; | 831 | 83 | } | 832 | | | 833 | 78 | switch (import_name_type) | 834 | 78 | { | 835 | 23 | case IMPORT_ORDINAL: | 836 | 27 | case IMPORT_NAME: | 837 | 41 | case IMPORT_NAME_NOPREFIX: | 838 | 60 | case IMPORT_NAME_UNDECORATE: | 839 | 60 | import_name = symbol_name; | 840 | 60 | break; | 841 | | | 842 | 14 | case IMPORT_NAME_EXPORTAS: | 843 | 14 | if (!import_name || !import_name[0]) | 844 | 11 | { | 845 | 11 | _bfd_error_handler (_("%pB: missing import name for " | 846 | 11 | "IMPORT_NAME_EXPORTAS for %s"), | 847 | 11 | abfd, symbol_name); | 848 | 11 | return false; | 849 | 11 | } | 850 | 3 | break; | 851 | | | 852 | 4 | default: | 853 | | /* xgettext:c-format */ | 854 | 4 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 855 | 4 | abfd, import_name_type); | 856 | 4 | return false; | 857 | 78 | } | 858 | | | 859 | | /* Initialise local variables. | 860 | | | 861 | | Note these are kept in a structure rather than being | 862 | | declared as statics since bfd frowns on global variables. | 863 | | | 864 | | We are going to construct the contents of the BFD in memory, | 865 | | so allocate all the space that we will need right now. */ | 866 | 63 | vars.bim | 867 | 63 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 868 | 63 | if (vars.bim == NULL) | 869 | 0 | return false; | 870 | | | 871 | 63 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 872 | 63 | vars.bim->buffer = ptr; | 873 | 63 | vars.bim->size = ILF_DATA_SIZE; | 874 | 63 | if (ptr == NULL) | 875 | 0 | goto error_return; | 876 | | | 877 | | /* Initialise the pointers to regions of the memory and the | 878 | | other contents of the pe_ILF_vars structure as well. */ | 879 | 63 | vars.sym_cache = (coff_symbol_type *) ptr; | 880 | 63 | vars.sym_ptr = (coff_symbol_type *) ptr; | 881 | 63 | vars.sym_index = 0; | 882 | 63 | ptr += SIZEOF_ILF_SYMS; | 883 | | | 884 | 63 | vars.sym_table = (unsigned int *) ptr; | 885 | 63 | vars.table_ptr = (unsigned int *) ptr; | 886 | 63 | ptr += SIZEOF_ILF_SYM_TABLE; | 887 | | | 888 | 63 | vars.native_syms = (combined_entry_type *) ptr; | 889 | 63 | vars.native_ptr = (combined_entry_type *) ptr; | 890 | 63 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 891 | | | 892 | 63 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 893 | 63 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 894 | 63 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 895 | | | 896 | 63 | vars.esym_table = (SYMENT *) ptr; | 897 | 63 | vars.esym_ptr = (SYMENT *) ptr; | 898 | 63 | ptr += SIZEOF_ILF_EXT_SYMS; | 899 | | | 900 | 63 | vars.reltab = (arelent *) ptr; | 901 | 63 | vars.relcount = 0; | 902 | 63 | ptr += SIZEOF_ILF_RELOCS; | 903 | | | 904 | 63 | vars.int_reltab = (struct internal_reloc *) ptr; | 905 | 63 | ptr += SIZEOF_ILF_INT_RELOCS; | 906 | | | 907 | 63 | vars.string_table = (char *) ptr; | 908 | 63 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 909 | 63 | ptr += SIZEOF_ILF_STRINGS; | 910 | 63 | vars.end_string_ptr = (char *) ptr; | 911 | | | 912 | | /* The remaining space in bim->buffer is used | 913 | | by the pe_ILF_make_a_section() function. */ | 914 | | | 915 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 916 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 917 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 918 | | alignment. */ | 919 | 63 | #if GCC_VERSION >= 3000 | 920 | 63 | alignment = __alignof__ (struct coff_section_tdata); | 921 | | #else | 922 | | alignment = 8; | 923 | | #endif | 924 | 63 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 925 | | | 926 | 63 | vars.data = ptr; | 927 | 63 | vars.abfd = abfd; | 928 | 63 | vars.sec_index = 0; | 929 | 63 | vars.magic = magic; | 930 | | | 931 | | /* Create the initial .idata$<n> sections: | 932 | | [.idata$2: Import Directory Table -- not needed] | 933 | | .idata$4: Import Lookup Table | 934 | | .idata$5: Import Address Table | 935 | | | 936 | | Note we do not create a .idata$3 section as this is | 937 | | created for us by the linker script. */ | 938 | 63 | id4 = pe_ILF_make_a_section (&vars, ".idata$4", SIZEOF_IDATA4, 0); | 939 | 63 | id5 = pe_ILF_make_a_section (&vars, ".idata$5", SIZEOF_IDATA5, 0); | 940 | 63 | if (id4 == NULL || id5 == NULL) | 941 | 0 | goto error_return; | 942 | | | 943 | | /* Fill in the contents of these sections. */ | 944 | 63 | if (import_name_type == IMPORT_ORDINAL) | 945 | 23 | { | 946 | 23 | if (ordinal == 0) | 947 | | /* See PR 20907 for a reproducer. */ | 948 | 7 | goto error_return; | 949 | | | 950 | | #if (defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) \ | 951 | | || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64)) | 952 | | ((unsigned int *) id4->contents)[0] = ordinal; | 953 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 954 | | ((unsigned int *) id5->contents)[0] = ordinal; | 955 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 956 | | #else | 957 | 16 | ((unsigned int *) id4->contents)[0] = ordinal | 0x80000000; | 958 | 16 | ((unsigned int *) id5->contents)[0] = ordinal | 0x80000000; | 959 | 16 | #endif | 960 | 16 | } | 961 | 40 | else | 962 | 40 | { | 963 | 40 | char *symbol; | 964 | 40 | unsigned int len; | 965 | | | 966 | | /* Create .idata$6 - the Hint Name Table. */ | 967 | 40 | id6 = pe_ILF_make_a_section (&vars, ".idata$6", SIZEOF_IDATA6, 0); | 968 | 40 | if (id6 == NULL) | 969 | 0 | goto error_return; | 970 | | | 971 | | /* If necessary, trim the import symbol name. */ | 972 | 40 | symbol = import_name; | 973 | | | 974 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 975 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 976 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 977 | | of these is used for a symbol. We strip this leading char for | 978 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 979 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 980 | | | 981 | 40 | if (import_name_type != IMPORT_NAME | 982 | 36 | && import_name_type != IMPORT_NAME_EXPORTAS) | 983 | 33 | { | 984 | 33 | char c = symbol[0]; | 985 | | | 986 | | /* Check that we don't remove for targets with empty | 987 | | USER_LABEL_PREFIX the leading underscore. */ | 988 | 33 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 989 | 33 | || c == '@' || c == '?') | 990 | 5 | symbol++; | 991 | 33 | } | 992 | | | 993 | 40 | len = strlen (symbol); | 994 | 40 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 995 | 19 | { | 996 | | /* Truncate at the first '@'. */ | 997 | 19 | char *at = strchr (symbol, '@'); | 998 | | | 999 | 19 | if (at != NULL) | 1000 | 2 | len = at - symbol; | 1001 | 19 | } | 1002 | | | 1003 | 40 | id6->contents[0] = ordinal & 0xff; | 1004 | 40 | id6->contents[1] = ordinal >> 8; | 1005 | | | 1006 | 40 | memcpy ((char *) id6->contents + 2, symbol, len); | 1007 | 40 | id6->contents[len + 2] = '\0'; | 1008 | 40 | } | 1009 | | | 1010 | 56 | if (import_name_type != IMPORT_ORDINAL) | 1011 | 40 | { | 1012 | 40 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1013 | 40 | pe_ILF_save_relocs (&vars, id4); | 1014 | | | 1015 | 40 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1016 | 40 | pe_ILF_save_relocs (&vars, id5); | 1017 | 40 | } | 1018 | | | 1019 | | /* Create an import symbol. */ | 1020 | 56 | pe_ILF_make_a_symbol (&vars, "__imp_", symbol_name, id5, 0); | 1021 | 56 | imp_sym = vars.sym_ptr_ptr - 1; | 1022 | 56 | imp_index = vars.sym_index - 1; | 1023 | | | 1024 | | /* Create extra sections depending upon the type of import we are | 1025 | | dealing with. */ | 1026 | 56 | switch (import_type) | 1027 | 56 | { | 1028 | 0 | int i; | 1029 | | | 1030 | 29 | case IMPORT_CODE: | 1031 | | /* CODE functions are special, in that they get a trampoline that | 1032 | | jumps to the main import symbol. Create a .text section to hold it. | 1033 | | First we need to look up its contents in the jump table. */ | 1034 | 75 | for (i = NUM_ENTRIES (jtab); i--;) | 1035 | 75 | { | 1036 | 75 | if (jtab[i].size == 0) | 1037 | 29 | continue; | 1038 | 46 | if (jtab[i].magic == magic) | 1039 | 29 | break; | 1040 | 46 | } | 1041 | | /* If we did not find a matching entry something is wrong. */ | 1042 | 29 | if (i < 0) | 1043 | 0 | abort (); | 1044 | | | 1045 | | /* Create the .text section. */ | 1046 | 29 | text = pe_ILF_make_a_section (&vars, ".text", jtab[i].size, SEC_CODE); | 1047 | 29 | if (text == NULL) | 1048 | 0 | goto error_return; | 1049 | | | 1050 | | /* Copy in the jump code. */ | 1051 | 29 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1052 | | | 1053 | | /* Create a reloc for the data in the text section. */ | 1054 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1055 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1056 | | { | 1057 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1058 | | (struct bfd_symbol **) imp_sym, | 1059 | | imp_index); | 1060 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1061 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1062 | | (struct bfd_symbol **) imp_sym, | 1063 | | imp_index); | 1064 | | } | 1065 | | else | 1066 | | #endif | 1067 | | #ifdef AMD64MAGIC | 1068 | | if (magic == AMD64MAGIC) | 1069 | | { | 1070 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1071 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1072 | | imp_index); | 1073 | | } | 1074 | | else | 1075 | | #endif | 1076 | 29 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1077 | 29 | BFD_RELOC_32, (asymbol **) imp_sym, | 1078 | 29 | imp_index); | 1079 | | | 1080 | 29 | pe_ILF_save_relocs (&vars, text); | 1081 | 29 | break; | 1082 | | | 1083 | 18 | case IMPORT_DATA: | 1084 | 27 | case IMPORT_CONST: | 1085 | 27 | break; | 1086 | | | 1087 | 0 | default: | 1088 | | /* XXX code not yet written. */ | 1089 | 0 | abort (); | 1090 | 56 | } | 1091 | | | 1092 | | /* Now create a symbol describing the imported value. */ | 1093 | 56 | switch (import_type) | 1094 | 56 | { | 1095 | 29 | case IMPORT_CODE: | 1096 | 29 | pe_ILF_make_a_symbol (&vars, "", symbol_name, text, | 1097 | 29 | BSF_NOT_AT_END | BSF_FUNCTION); | 1098 | | | 1099 | 29 | break; | 1100 | | | 1101 | 18 | case IMPORT_DATA: | 1102 | | /* Nothing to do here. */ | 1103 | 18 | break; | 1104 | | | 1105 | 9 | case IMPORT_CONST: | 1106 | 9 | pe_ILF_make_a_symbol (&vars, "", symbol_name, id5, 0); | 1107 | 9 | break; | 1108 | | | 1109 | 0 | default: | 1110 | | /* XXX code not yet written. */ | 1111 | 0 | abort (); | 1112 | 56 | } | 1113 | | | 1114 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1115 | 56 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1116 | 56 | if (ptr) | 1117 | 6 | *ptr = 0; | 1118 | 56 | pe_ILF_make_a_symbol (&vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1119 | 56 | if (ptr) | 1120 | 6 | *ptr = '.'; | 1121 | | | 1122 | | /* Initialise the bfd. */ | 1123 | 56 | memset (&internal_f, 0, sizeof (internal_f)); | 1124 | | | 1125 | 56 | internal_f.f_magic = magic; | 1126 | 56 | internal_f.f_symptr = 0; | 1127 | 56 | internal_f.f_nsyms = 0; | 1128 | 56 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1129 | | | 1130 | 56 | if (!bfd_set_start_address (abfd, (bfd_vma) 0) | 1131 | 56 | || !bfd_coff_set_arch_mach_hook (abfd, &internal_f)) | 1132 | 0 | goto error_return; | 1133 | | | 1134 | 56 | if (bfd_coff_mkobject_hook (abfd, (void *) &internal_f, NULL) == NULL) | 1135 | 0 | goto error_return; | 1136 | | | 1137 | 56 | obj_pe (abfd) = true; | 1138 | 56 | #ifdef THUMBPEMAGIC | 1139 | 56 | if (vars.magic == THUMBPEMAGIC) | 1140 | | /* Stop some linker warnings about thumb code not supporting | 1141 | | interworking. */ | 1142 | 27 | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1143 | 56 | #endif | 1144 | | | 1145 | | /* Switch from file contents to memory contents. */ | 1146 | 56 | bfd_cache_close (abfd); | 1147 | | | 1148 | 56 | abfd->iostream = (void *) vars.bim; | 1149 | 56 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1150 | 56 | abfd->iovec = &_bfd_memory_iovec; | 1151 | 56 | abfd->where = 0; | 1152 | 56 | abfd->origin = 0; | 1153 | 56 | abfd->size = 0; | 1154 | 56 | obj_sym_filepos (abfd) = 0; | 1155 | | | 1156 | | /* Point the bfd at the symbol table. */ | 1157 | 56 | obj_symbols (abfd) = vars.sym_cache; | 1158 | 56 | abfd->symcount = vars.sym_index; | 1159 | | | 1160 | 56 | obj_raw_syments (abfd) = vars.native_syms; | 1161 | 56 | obj_raw_syment_count (abfd) = vars.sym_index; | 1162 | 56 | obj_coff_keep_raw_syms (abfd) = true; | 1163 | | | 1164 | 56 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1165 | 56 | obj_coff_keep_syms (abfd) = true; | 1166 | | | 1167 | 56 | obj_convert (abfd) = vars.sym_table; | 1168 | 56 | obj_conv_table_size (abfd) = vars.sym_index; | 1169 | | | 1170 | 56 | obj_coff_strings (abfd) = vars.string_table; | 1171 | 56 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1172 | 56 | obj_coff_keep_strings (abfd) = true; | 1173 | | | 1174 | 56 | return true; | 1175 | | | 1176 | 7 | error_return: | 1177 | 7 | free (vars.bim->buffer); | 1178 | 7 | free (vars.bim); | 1179 | | return false; | 1180 | 56 | } |
pei-arm.c:pe_ILF_build_a_bfd Line | Count | Source | 804 | 85 | { | 805 | 85 | bfd_byte * ptr; | 806 | 85 | pe_ILF_vars vars; | 807 | 85 | struct internal_filehdr internal_f; | 808 | 85 | unsigned int import_type; | 809 | 85 | unsigned int import_name_type; | 810 | 85 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 811 | 85 | coff_symbol_type ** imp_sym; | 812 | 85 | unsigned int imp_index; | 813 | 85 | intptr_t alignment; | 814 | | | 815 | | /* Decode and verify the types field of the ILF structure. */ | 816 | 85 | import_type = types & 0x3; | 817 | 85 | import_name_type = (types & 0x1c) >> 2; | 818 | | | 819 | 85 | switch (import_type) | 820 | 85 | { | 821 | 40 | case IMPORT_CODE: | 822 | 69 | case IMPORT_DATA: | 823 | 80 | case IMPORT_CONST: | 824 | 80 | break; | 825 | | | 826 | 5 | default: | 827 | | /* xgettext:c-format */ | 828 | 5 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 829 | 5 | abfd, import_type); | 830 | 5 | return false; | 831 | 85 | } | 832 | | | 833 | 80 | switch (import_name_type) | 834 | 80 | { | 835 | 24 | case IMPORT_ORDINAL: | 836 | 28 | case IMPORT_NAME: | 837 | 42 | case IMPORT_NAME_NOPREFIX: | 838 | 62 | case IMPORT_NAME_UNDECORATE: | 839 | 62 | import_name = symbol_name; | 840 | 62 | break; | 841 | | | 842 | 14 | case IMPORT_NAME_EXPORTAS: | 843 | 14 | if (!import_name || !import_name[0]) | 844 | 11 | { | 845 | 11 | _bfd_error_handler (_("%pB: missing import name for " | 846 | 11 | "IMPORT_NAME_EXPORTAS for %s"), | 847 | 11 | abfd, symbol_name); | 848 | 11 | return false; | 849 | 11 | } | 850 | 3 | break; | 851 | | | 852 | 4 | default: | 853 | | /* xgettext:c-format */ | 854 | 4 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 855 | 4 | abfd, import_name_type); | 856 | 4 | return false; | 857 | 80 | } | 858 | | | 859 | | /* Initialise local variables. | 860 | | | 861 | | Note these are kept in a structure rather than being | 862 | | declared as statics since bfd frowns on global variables. | 863 | | | 864 | | We are going to construct the contents of the BFD in memory, | 865 | | so allocate all the space that we will need right now. */ | 866 | 65 | vars.bim | 867 | 65 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 868 | 65 | if (vars.bim == NULL) | 869 | 0 | return false; | 870 | | | 871 | 65 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 872 | 65 | vars.bim->buffer = ptr; | 873 | 65 | vars.bim->size = ILF_DATA_SIZE; | 874 | 65 | if (ptr == NULL) | 875 | 0 | goto error_return; | 876 | | | 877 | | /* Initialise the pointers to regions of the memory and the | 878 | | other contents of the pe_ILF_vars structure as well. */ | 879 | 65 | vars.sym_cache = (coff_symbol_type *) ptr; | 880 | 65 | vars.sym_ptr = (coff_symbol_type *) ptr; | 881 | 65 | vars.sym_index = 0; | 882 | 65 | ptr += SIZEOF_ILF_SYMS; | 883 | | | 884 | 65 | vars.sym_table = (unsigned int *) ptr; | 885 | 65 | vars.table_ptr = (unsigned int *) ptr; | 886 | 65 | ptr += SIZEOF_ILF_SYM_TABLE; | 887 | | | 888 | 65 | vars.native_syms = (combined_entry_type *) ptr; | 889 | 65 | vars.native_ptr = (combined_entry_type *) ptr; | 890 | 65 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 891 | | | 892 | 65 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 893 | 65 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 894 | 65 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 895 | | | 896 | 65 | vars.esym_table = (SYMENT *) ptr; | 897 | 65 | vars.esym_ptr = (SYMENT *) ptr; | 898 | 65 | ptr += SIZEOF_ILF_EXT_SYMS; | 899 | | | 900 | 65 | vars.reltab = (arelent *) ptr; | 901 | 65 | vars.relcount = 0; | 902 | 65 | ptr += SIZEOF_ILF_RELOCS; | 903 | | | 904 | 65 | vars.int_reltab = (struct internal_reloc *) ptr; | 905 | 65 | ptr += SIZEOF_ILF_INT_RELOCS; | 906 | | | 907 | 65 | vars.string_table = (char *) ptr; | 908 | 65 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 909 | 65 | ptr += SIZEOF_ILF_STRINGS; | 910 | 65 | vars.end_string_ptr = (char *) ptr; | 911 | | | 912 | | /* The remaining space in bim->buffer is used | 913 | | by the pe_ILF_make_a_section() function. */ | 914 | | | 915 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 916 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 917 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 918 | | alignment. */ | 919 | 65 | #if GCC_VERSION >= 3000 | 920 | 65 | alignment = __alignof__ (struct coff_section_tdata); | 921 | | #else | 922 | | alignment = 8; | 923 | | #endif | 924 | 65 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 925 | | | 926 | 65 | vars.data = ptr; | 927 | 65 | vars.abfd = abfd; | 928 | 65 | vars.sec_index = 0; | 929 | 65 | vars.magic = magic; | 930 | | | 931 | | /* Create the initial .idata$<n> sections: | 932 | | [.idata$2: Import Directory Table -- not needed] | 933 | | .idata$4: Import Lookup Table | 934 | | .idata$5: Import Address Table | 935 | | | 936 | | Note we do not create a .idata$3 section as this is | 937 | | created for us by the linker script. */ | 938 | 65 | id4 = pe_ILF_make_a_section (&vars, ".idata$4", SIZEOF_IDATA4, 0); | 939 | 65 | id5 = pe_ILF_make_a_section (&vars, ".idata$5", SIZEOF_IDATA5, 0); | 940 | 65 | if (id4 == NULL || id5 == NULL) | 941 | 0 | goto error_return; | 942 | | | 943 | | /* Fill in the contents of these sections. */ | 944 | 65 | if (import_name_type == IMPORT_ORDINAL) | 945 | 24 | { | 946 | 24 | if (ordinal == 0) | 947 | | /* See PR 20907 for a reproducer. */ | 948 | 7 | goto error_return; | 949 | | | 950 | | #if (defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) \ | 951 | | || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64)) | 952 | | ((unsigned int *) id4->contents)[0] = ordinal; | 953 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 954 | | ((unsigned int *) id5->contents)[0] = ordinal; | 955 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 956 | | #else | 957 | 17 | ((unsigned int *) id4->contents)[0] = ordinal | 0x80000000; | 958 | 17 | ((unsigned int *) id5->contents)[0] = ordinal | 0x80000000; | 959 | 17 | #endif | 960 | 17 | } | 961 | 41 | else | 962 | 41 | { | 963 | 41 | char *symbol; | 964 | 41 | unsigned int len; | 965 | | | 966 | | /* Create .idata$6 - the Hint Name Table. */ | 967 | 41 | id6 = pe_ILF_make_a_section (&vars, ".idata$6", SIZEOF_IDATA6, 0); | 968 | 41 | if (id6 == NULL) | 969 | 0 | goto error_return; | 970 | | | 971 | | /* If necessary, trim the import symbol name. */ | 972 | 41 | symbol = import_name; | 973 | | | 974 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 975 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 976 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 977 | | of these is used for a symbol. We strip this leading char for | 978 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 979 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 980 | | | 981 | 41 | if (import_name_type != IMPORT_NAME | 982 | 37 | && import_name_type != IMPORT_NAME_EXPORTAS) | 983 | 34 | { | 984 | 34 | char c = symbol[0]; | 985 | | | 986 | | /* Check that we don't remove for targets with empty | 987 | | USER_LABEL_PREFIX the leading underscore. */ | 988 | 34 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 989 | 31 | || c == '@' || c == '?') | 990 | 8 | symbol++; | 991 | 34 | } | 992 | | | 993 | 41 | len = strlen (symbol); | 994 | 41 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 995 | 20 | { | 996 | | /* Truncate at the first '@'. */ | 997 | 20 | char *at = strchr (symbol, '@'); | 998 | | | 999 | 20 | if (at != NULL) | 1000 | 2 | len = at - symbol; | 1001 | 20 | } | 1002 | | | 1003 | 41 | id6->contents[0] = ordinal & 0xff; | 1004 | 41 | id6->contents[1] = ordinal >> 8; | 1005 | | | 1006 | 41 | memcpy ((char *) id6->contents + 2, symbol, len); | 1007 | 41 | id6->contents[len + 2] = '\0'; | 1008 | 41 | } | 1009 | | | 1010 | 58 | if (import_name_type != IMPORT_ORDINAL) | 1011 | 41 | { | 1012 | 41 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1013 | 41 | pe_ILF_save_relocs (&vars, id4); | 1014 | | | 1015 | 41 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1016 | 41 | pe_ILF_save_relocs (&vars, id5); | 1017 | 41 | } | 1018 | | | 1019 | | /* Create an import symbol. */ | 1020 | 58 | pe_ILF_make_a_symbol (&vars, "__imp_", symbol_name, id5, 0); | 1021 | 58 | imp_sym = vars.sym_ptr_ptr - 1; | 1022 | 58 | imp_index = vars.sym_index - 1; | 1023 | | | 1024 | | /* Create extra sections depending upon the type of import we are | 1025 | | dealing with. */ | 1026 | 58 | switch (import_type) | 1027 | 58 | { | 1028 | 0 | int i; | 1029 | | | 1030 | 30 | case IMPORT_CODE: | 1031 | | /* CODE functions are special, in that they get a trampoline that | 1032 | | jumps to the main import symbol. Create a .text section to hold it. | 1033 | | First we need to look up its contents in the jump table. */ | 1034 | 78 | for (i = NUM_ENTRIES (jtab); i--;) | 1035 | 78 | { | 1036 | 78 | if (jtab[i].size == 0) | 1037 | 30 | continue; | 1038 | 48 | if (jtab[i].magic == magic) | 1039 | 30 | break; | 1040 | 48 | } | 1041 | | /* If we did not find a matching entry something is wrong. */ | 1042 | 30 | if (i < 0) | 1043 | 0 | abort (); | 1044 | | | 1045 | | /* Create the .text section. */ | 1046 | 30 | text = pe_ILF_make_a_section (&vars, ".text", jtab[i].size, SEC_CODE); | 1047 | 30 | if (text == NULL) | 1048 | 0 | goto error_return; | 1049 | | | 1050 | | /* Copy in the jump code. */ | 1051 | 30 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1052 | | | 1053 | | /* Create a reloc for the data in the text section. */ | 1054 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1055 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1056 | | { | 1057 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1058 | | (struct bfd_symbol **) imp_sym, | 1059 | | imp_index); | 1060 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1061 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1062 | | (struct bfd_symbol **) imp_sym, | 1063 | | imp_index); | 1064 | | } | 1065 | | else | 1066 | | #endif | 1067 | | #ifdef AMD64MAGIC | 1068 | | if (magic == AMD64MAGIC) | 1069 | | { | 1070 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1071 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1072 | | imp_index); | 1073 | | } | 1074 | | else | 1075 | | #endif | 1076 | 30 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1077 | 30 | BFD_RELOC_32, (asymbol **) imp_sym, | 1078 | 30 | imp_index); | 1079 | | | 1080 | 30 | pe_ILF_save_relocs (&vars, text); | 1081 | 30 | break; | 1082 | | | 1083 | 19 | case IMPORT_DATA: | 1084 | 28 | case IMPORT_CONST: | 1085 | 28 | break; | 1086 | | | 1087 | 0 | default: | 1088 | | /* XXX code not yet written. */ | 1089 | 0 | abort (); | 1090 | 58 | } | 1091 | | | 1092 | | /* Now create a symbol describing the imported value. */ | 1093 | 58 | switch (import_type) | 1094 | 58 | { | 1095 | 30 | case IMPORT_CODE: | 1096 | 30 | pe_ILF_make_a_symbol (&vars, "", symbol_name, text, | 1097 | 30 | BSF_NOT_AT_END | BSF_FUNCTION); | 1098 | | | 1099 | 30 | break; | 1100 | | | 1101 | 19 | case IMPORT_DATA: | 1102 | | /* Nothing to do here. */ | 1103 | 19 | break; | 1104 | | | 1105 | 9 | case IMPORT_CONST: | 1106 | 9 | pe_ILF_make_a_symbol (&vars, "", symbol_name, id5, 0); | 1107 | 9 | break; | 1108 | | | 1109 | 0 | default: | 1110 | | /* XXX code not yet written. */ | 1111 | 0 | abort (); | 1112 | 58 | } | 1113 | | | 1114 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1115 | 58 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1116 | 58 | if (ptr) | 1117 | 6 | *ptr = 0; | 1118 | 58 | pe_ILF_make_a_symbol (&vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1119 | 58 | if (ptr) | 1120 | 6 | *ptr = '.'; | 1121 | | | 1122 | | /* Initialise the bfd. */ | 1123 | 58 | memset (&internal_f, 0, sizeof (internal_f)); | 1124 | | | 1125 | 58 | internal_f.f_magic = magic; | 1126 | 58 | internal_f.f_symptr = 0; | 1127 | 58 | internal_f.f_nsyms = 0; | 1128 | 58 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1129 | | | 1130 | 58 | if (!bfd_set_start_address (abfd, (bfd_vma) 0) | 1131 | 58 | || !bfd_coff_set_arch_mach_hook (abfd, &internal_f)) | 1132 | 0 | goto error_return; | 1133 | | | 1134 | 58 | if (bfd_coff_mkobject_hook (abfd, (void *) &internal_f, NULL) == NULL) | 1135 | 0 | goto error_return; | 1136 | | | 1137 | 58 | obj_pe (abfd) = true; | 1138 | 58 | #ifdef THUMBPEMAGIC | 1139 | 58 | if (vars.magic == THUMBPEMAGIC) | 1140 | | /* Stop some linker warnings about thumb code not supporting | 1141 | | interworking. */ | 1142 | 27 | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1143 | 58 | #endif | 1144 | | | 1145 | | /* Switch from file contents to memory contents. */ | 1146 | 58 | bfd_cache_close (abfd); | 1147 | | | 1148 | 58 | abfd->iostream = (void *) vars.bim; | 1149 | 58 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1150 | 58 | abfd->iovec = &_bfd_memory_iovec; | 1151 | 58 | abfd->where = 0; | 1152 | 58 | abfd->origin = 0; | 1153 | 58 | abfd->size = 0; | 1154 | 58 | obj_sym_filepos (abfd) = 0; | 1155 | | | 1156 | | /* Point the bfd at the symbol table. */ | 1157 | 58 | obj_symbols (abfd) = vars.sym_cache; | 1158 | 58 | abfd->symcount = vars.sym_index; | 1159 | | | 1160 | 58 | obj_raw_syments (abfd) = vars.native_syms; | 1161 | 58 | obj_raw_syment_count (abfd) = vars.sym_index; | 1162 | 58 | obj_coff_keep_raw_syms (abfd) = true; | 1163 | | | 1164 | 58 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1165 | 58 | obj_coff_keep_syms (abfd) = true; | 1166 | | | 1167 | 58 | obj_convert (abfd) = vars.sym_table; | 1168 | 58 | obj_conv_table_size (abfd) = vars.sym_index; | 1169 | | | 1170 | 58 | obj_coff_strings (abfd) = vars.string_table; | 1171 | 58 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1172 | 58 | obj_coff_keep_strings (abfd) = true; | 1173 | | | 1174 | 58 | return true; | 1175 | | | 1176 | 7 | error_return: | 1177 | 7 | free (vars.bim->buffer); | 1178 | 7 | free (vars.bim); | 1179 | | return false; | 1180 | 58 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_build_a_bfd pei-sh.c:pe_ILF_build_a_bfd Line | Count | Source | 804 | 118 | { | 805 | 118 | bfd_byte * ptr; | 806 | 118 | pe_ILF_vars vars; | 807 | 118 | struct internal_filehdr internal_f; | 808 | 118 | unsigned int import_type; | 809 | 118 | unsigned int import_name_type; | 810 | 118 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 811 | 118 | coff_symbol_type ** imp_sym; | 812 | 118 | unsigned int imp_index; | 813 | 118 | intptr_t alignment; | 814 | | | 815 | | /* Decode and verify the types field of the ILF structure. */ | 816 | 118 | import_type = types & 0x3; | 817 | 118 | import_name_type = (types & 0x1c) >> 2; | 818 | | | 819 | 118 | switch (import_type) | 820 | 118 | { | 821 | 37 | case IMPORT_CODE: | 822 | 73 | case IMPORT_DATA: | 823 | 99 | case IMPORT_CONST: | 824 | 99 | break; | 825 | | | 826 | 19 | default: | 827 | | /* xgettext:c-format */ | 828 | 19 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 829 | 19 | abfd, import_type); | 830 | 19 | return false; | 831 | 118 | } | 832 | | | 833 | 99 | switch (import_name_type) | 834 | 99 | { | 835 | 21 | case IMPORT_ORDINAL: | 836 | 38 | case IMPORT_NAME: | 837 | 61 | case IMPORT_NAME_NOPREFIX: | 838 | 75 | case IMPORT_NAME_UNDECORATE: | 839 | 75 | import_name = symbol_name; | 840 | 75 | break; | 841 | | | 842 | 19 | case IMPORT_NAME_EXPORTAS: | 843 | 19 | if (!import_name || !import_name[0]) | 844 | 10 | { | 845 | 10 | _bfd_error_handler (_("%pB: missing import name for " | 846 | 10 | "IMPORT_NAME_EXPORTAS for %s"), | 847 | 10 | abfd, symbol_name); | 848 | 10 | return false; | 849 | 10 | } | 850 | 9 | break; | 851 | | | 852 | 9 | default: | 853 | | /* xgettext:c-format */ | 854 | 5 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 855 | 5 | abfd, import_name_type); | 856 | 5 | return false; | 857 | 99 | } | 858 | | | 859 | | /* Initialise local variables. | 860 | | | 861 | | Note these are kept in a structure rather than being | 862 | | declared as statics since bfd frowns on global variables. | 863 | | | 864 | | We are going to construct the contents of the BFD in memory, | 865 | | so allocate all the space that we will need right now. */ | 866 | 84 | vars.bim | 867 | 84 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 868 | 84 | if (vars.bim == NULL) | 869 | 0 | return false; | 870 | | | 871 | 84 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 872 | 84 | vars.bim->buffer = ptr; | 873 | 84 | vars.bim->size = ILF_DATA_SIZE; | 874 | 84 | if (ptr == NULL) | 875 | 0 | goto error_return; | 876 | | | 877 | | /* Initialise the pointers to regions of the memory and the | 878 | | other contents of the pe_ILF_vars structure as well. */ | 879 | 84 | vars.sym_cache = (coff_symbol_type *) ptr; | 880 | 84 | vars.sym_ptr = (coff_symbol_type *) ptr; | 881 | 84 | vars.sym_index = 0; | 882 | 84 | ptr += SIZEOF_ILF_SYMS; | 883 | | | 884 | 84 | vars.sym_table = (unsigned int *) ptr; | 885 | 84 | vars.table_ptr = (unsigned int *) ptr; | 886 | 84 | ptr += SIZEOF_ILF_SYM_TABLE; | 887 | | | 888 | 84 | vars.native_syms = (combined_entry_type *) ptr; | 889 | 84 | vars.native_ptr = (combined_entry_type *) ptr; | 890 | 84 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 891 | | | 892 | 84 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 893 | 84 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 894 | 84 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 895 | | | 896 | 84 | vars.esym_table = (SYMENT *) ptr; | 897 | 84 | vars.esym_ptr = (SYMENT *) ptr; | 898 | 84 | ptr += SIZEOF_ILF_EXT_SYMS; | 899 | | | 900 | 84 | vars.reltab = (arelent *) ptr; | 901 | 84 | vars.relcount = 0; | 902 | 84 | ptr += SIZEOF_ILF_RELOCS; | 903 | | | 904 | 84 | vars.int_reltab = (struct internal_reloc *) ptr; | 905 | 84 | ptr += SIZEOF_ILF_INT_RELOCS; | 906 | | | 907 | 84 | vars.string_table = (char *) ptr; | 908 | 84 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 909 | 84 | ptr += SIZEOF_ILF_STRINGS; | 910 | 84 | vars.end_string_ptr = (char *) ptr; | 911 | | | 912 | | /* The remaining space in bim->buffer is used | 913 | | by the pe_ILF_make_a_section() function. */ | 914 | | | 915 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 916 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 917 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 918 | | alignment. */ | 919 | 84 | #if GCC_VERSION >= 3000 | 920 | 84 | alignment = __alignof__ (struct coff_section_tdata); | 921 | | #else | 922 | | alignment = 8; | 923 | | #endif | 924 | 84 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 925 | | | 926 | 84 | vars.data = ptr; | 927 | 84 | vars.abfd = abfd; | 928 | 84 | vars.sec_index = 0; | 929 | 84 | vars.magic = magic; | 930 | | | 931 | | /* Create the initial .idata$<n> sections: | 932 | | [.idata$2: Import Directory Table -- not needed] | 933 | | .idata$4: Import Lookup Table | 934 | | .idata$5: Import Address Table | 935 | | | 936 | | Note we do not create a .idata$3 section as this is | 937 | | created for us by the linker script. */ | 938 | 84 | id4 = pe_ILF_make_a_section (&vars, ".idata$4", SIZEOF_IDATA4, 0); | 939 | 84 | id5 = pe_ILF_make_a_section (&vars, ".idata$5", SIZEOF_IDATA5, 0); | 940 | 84 | if (id4 == NULL || id5 == NULL) | 941 | 0 | goto error_return; | 942 | | | 943 | | /* Fill in the contents of these sections. */ | 944 | 84 | if (import_name_type == IMPORT_ORDINAL) | 945 | 21 | { | 946 | 21 | if (ordinal == 0) | 947 | | /* See PR 20907 for a reproducer. */ | 948 | 5 | goto error_return; | 949 | | | 950 | | #if (defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) \ | 951 | | || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64)) | 952 | | ((unsigned int *) id4->contents)[0] = ordinal; | 953 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 954 | | ((unsigned int *) id5->contents)[0] = ordinal; | 955 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 956 | | #else | 957 | 16 | ((unsigned int *) id4->contents)[0] = ordinal | 0x80000000; | 958 | 16 | ((unsigned int *) id5->contents)[0] = ordinal | 0x80000000; | 959 | 16 | #endif | 960 | 16 | } | 961 | 63 | else | 962 | 63 | { | 963 | 63 | char *symbol; | 964 | 63 | unsigned int len; | 965 | | | 966 | | /* Create .idata$6 - the Hint Name Table. */ | 967 | 63 | id6 = pe_ILF_make_a_section (&vars, ".idata$6", SIZEOF_IDATA6, 0); | 968 | 63 | if (id6 == NULL) | 969 | 0 | goto error_return; | 970 | | | 971 | | /* If necessary, trim the import symbol name. */ | 972 | 63 | symbol = import_name; | 973 | | | 974 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 975 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 976 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 977 | | of these is used for a symbol. We strip this leading char for | 978 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 979 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 980 | | | 981 | 63 | if (import_name_type != IMPORT_NAME | 982 | 46 | && import_name_type != IMPORT_NAME_EXPORTAS) | 983 | 37 | { | 984 | 37 | char c = symbol[0]; | 985 | | | 986 | | /* Check that we don't remove for targets with empty | 987 | | USER_LABEL_PREFIX the leading underscore. */ | 988 | 37 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 989 | 32 | || c == '@' || c == '?') | 990 | 15 | symbol++; | 991 | 37 | } | 992 | | | 993 | 63 | len = strlen (symbol); | 994 | 63 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 995 | 14 | { | 996 | | /* Truncate at the first '@'. */ | 997 | 14 | char *at = strchr (symbol, '@'); | 998 | | | 999 | 14 | if (at != NULL) | 1000 | 4 | len = at - symbol; | 1001 | 14 | } | 1002 | | | 1003 | 63 | id6->contents[0] = ordinal & 0xff; | 1004 | 63 | id6->contents[1] = ordinal >> 8; | 1005 | | | 1006 | 63 | memcpy ((char *) id6->contents + 2, symbol, len); | 1007 | 63 | id6->contents[len + 2] = '\0'; | 1008 | 63 | } | 1009 | | | 1010 | 79 | if (import_name_type != IMPORT_ORDINAL) | 1011 | 63 | { | 1012 | 63 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1013 | 63 | pe_ILF_save_relocs (&vars, id4); | 1014 | | | 1015 | 63 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1016 | 63 | pe_ILF_save_relocs (&vars, id5); | 1017 | 63 | } | 1018 | | | 1019 | | /* Create an import symbol. */ | 1020 | 79 | pe_ILF_make_a_symbol (&vars, "__imp_", symbol_name, id5, 0); | 1021 | 79 | imp_sym = vars.sym_ptr_ptr - 1; | 1022 | 79 | imp_index = vars.sym_index - 1; | 1023 | | | 1024 | | /* Create extra sections depending upon the type of import we are | 1025 | | dealing with. */ | 1026 | 79 | switch (import_type) | 1027 | 79 | { | 1028 | 0 | int i; | 1029 | | | 1030 | 23 | case IMPORT_CODE: | 1031 | | /* CODE functions are special, in that they get a trampoline that | 1032 | | jumps to the main import symbol. Create a .text section to hold it. | 1033 | | First we need to look up its contents in the jump table. */ | 1034 | 46 | for (i = NUM_ENTRIES (jtab); i--;) | 1035 | 46 | { | 1036 | 46 | if (jtab[i].size == 0) | 1037 | 23 | continue; | 1038 | 23 | if (jtab[i].magic == magic) | 1039 | 23 | break; | 1040 | 23 | } | 1041 | | /* If we did not find a matching entry something is wrong. */ | 1042 | 23 | if (i < 0) | 1043 | 0 | abort (); | 1044 | | | 1045 | | /* Create the .text section. */ | 1046 | 23 | text = pe_ILF_make_a_section (&vars, ".text", jtab[i].size, SEC_CODE); | 1047 | 23 | if (text == NULL) | 1048 | 0 | goto error_return; | 1049 | | | 1050 | | /* Copy in the jump code. */ | 1051 | 23 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1052 | | | 1053 | | /* Create a reloc for the data in the text section. */ | 1054 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1055 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1056 | | { | 1057 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1058 | | (struct bfd_symbol **) imp_sym, | 1059 | | imp_index); | 1060 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1061 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1062 | | (struct bfd_symbol **) imp_sym, | 1063 | | imp_index); | 1064 | | } | 1065 | | else | 1066 | | #endif | 1067 | | #ifdef AMD64MAGIC | 1068 | | if (magic == AMD64MAGIC) | 1069 | | { | 1070 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1071 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1072 | | imp_index); | 1073 | | } | 1074 | | else | 1075 | | #endif | 1076 | 23 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1077 | 23 | BFD_RELOC_32, (asymbol **) imp_sym, | 1078 | 23 | imp_index); | 1079 | | | 1080 | 23 | pe_ILF_save_relocs (&vars, text); | 1081 | 23 | break; | 1082 | | | 1083 | 32 | case IMPORT_DATA: | 1084 | 56 | case IMPORT_CONST: | 1085 | 56 | break; | 1086 | | | 1087 | 0 | default: | 1088 | | /* XXX code not yet written. */ | 1089 | 0 | abort (); | 1090 | 79 | } | 1091 | | | 1092 | | /* Now create a symbol describing the imported value. */ | 1093 | 79 | switch (import_type) | 1094 | 79 | { | 1095 | 23 | case IMPORT_CODE: | 1096 | 23 | pe_ILF_make_a_symbol (&vars, "", symbol_name, text, | 1097 | 23 | BSF_NOT_AT_END | BSF_FUNCTION); | 1098 | | | 1099 | 23 | break; | 1100 | | | 1101 | 32 | case IMPORT_DATA: | 1102 | | /* Nothing to do here. */ | 1103 | 32 | break; | 1104 | | | 1105 | 24 | case IMPORT_CONST: | 1106 | 24 | pe_ILF_make_a_symbol (&vars, "", symbol_name, id5, 0); | 1107 | 24 | break; | 1108 | | | 1109 | 0 | default: | 1110 | | /* XXX code not yet written. */ | 1111 | 0 | abort (); | 1112 | 79 | } | 1113 | | | 1114 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1115 | 79 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1116 | 79 | if (ptr) | 1117 | 16 | *ptr = 0; | 1118 | 79 | pe_ILF_make_a_symbol (&vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1119 | 79 | if (ptr) | 1120 | 16 | *ptr = '.'; | 1121 | | | 1122 | | /* Initialise the bfd. */ | 1123 | 79 | memset (&internal_f, 0, sizeof (internal_f)); | 1124 | | | 1125 | 79 | internal_f.f_magic = magic; | 1126 | 79 | internal_f.f_symptr = 0; | 1127 | 79 | internal_f.f_nsyms = 0; | 1128 | 79 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1129 | | | 1130 | 79 | if (!bfd_set_start_address (abfd, (bfd_vma) 0) | 1131 | 79 | || !bfd_coff_set_arch_mach_hook (abfd, &internal_f)) | 1132 | 0 | goto error_return; | 1133 | | | 1134 | 79 | if (bfd_coff_mkobject_hook (abfd, (void *) &internal_f, NULL) == NULL) | 1135 | 0 | goto error_return; | 1136 | | | 1137 | 79 | obj_pe (abfd) = true; | 1138 | | #ifdef THUMBPEMAGIC | 1139 | | if (vars.magic == THUMBPEMAGIC) | 1140 | | /* Stop some linker warnings about thumb code not supporting | 1141 | | interworking. */ | 1142 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1143 | | #endif | 1144 | | | 1145 | | /* Switch from file contents to memory contents. */ | 1146 | 79 | bfd_cache_close (abfd); | 1147 | | | 1148 | 79 | abfd->iostream = (void *) vars.bim; | 1149 | 79 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1150 | 79 | abfd->iovec = &_bfd_memory_iovec; | 1151 | 79 | abfd->where = 0; | 1152 | 79 | abfd->origin = 0; | 1153 | 79 | abfd->size = 0; | 1154 | 79 | obj_sym_filepos (abfd) = 0; | 1155 | | | 1156 | | /* Point the bfd at the symbol table. */ | 1157 | 79 | obj_symbols (abfd) = vars.sym_cache; | 1158 | 79 | abfd->symcount = vars.sym_index; | 1159 | | | 1160 | 79 | obj_raw_syments (abfd) = vars.native_syms; | 1161 | 79 | obj_raw_syment_count (abfd) = vars.sym_index; | 1162 | 79 | obj_coff_keep_raw_syms (abfd) = true; | 1163 | | | 1164 | 79 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1165 | 79 | obj_coff_keep_syms (abfd) = true; | 1166 | | | 1167 | 79 | obj_convert (abfd) = vars.sym_table; | 1168 | 79 | obj_conv_table_size (abfd) = vars.sym_index; | 1169 | | | 1170 | 79 | obj_coff_strings (abfd) = vars.string_table; | 1171 | 79 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1172 | 79 | obj_coff_keep_strings (abfd) = true; | 1173 | | | 1174 | 79 | return true; | 1175 | | | 1176 | 5 | error_return: | 1177 | 5 | free (vars.bim->buffer); | 1178 | 5 | free (vars.bim); | 1179 | | return false; | 1180 | 79 | } |
|
1181 | | |
1182 | | /* Cleanup function, returned from check_format hook. */ |
1183 | | |
1184 | | static void |
1185 | | pe_ILF_cleanup (bfd *abfd) |
1186 | 38 | { |
1187 | 38 | coff_object_cleanup (abfd); |
1188 | | |
1189 | 38 | struct bfd_in_memory *bim = abfd->iostream; |
1190 | 38 | free (bim->buffer); |
1191 | 38 | free (bim); |
1192 | 38 | abfd->iostream = NULL; |
1193 | 38 | } Unexecuted instantiation: pei-i386.c:pe_ILF_cleanup Unexecuted instantiation: pei-x86_64.c:pe_ILF_cleanup Unexecuted instantiation: pei-aarch64.c:pe_ILF_cleanup Unexecuted instantiation: pei-ia64.c:pe_ILF_cleanup Unexecuted instantiation: pei-loongarch64.c:pe_ILF_cleanup Unexecuted instantiation: pei-riscv64.c:pe_ILF_cleanup pei-arm-wince.c:pe_ILF_cleanup Line | Count | Source | 1186 | 19 | { | 1187 | 19 | coff_object_cleanup (abfd); | 1188 | | | 1189 | 19 | struct bfd_in_memory *bim = abfd->iostream; | 1190 | 19 | free (bim->buffer); | 1191 | 19 | free (bim); | 1192 | | abfd->iostream = NULL; | 1193 | 19 | } |
Line | Count | Source | 1186 | 19 | { | 1187 | 19 | coff_object_cleanup (abfd); | 1188 | | | 1189 | 19 | struct bfd_in_memory *bim = abfd->iostream; | 1190 | 19 | free (bim->buffer); | 1191 | 19 | free (bim); | 1192 | | abfd->iostream = NULL; | 1193 | 19 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_cleanup Unexecuted instantiation: pei-sh.c:pe_ILF_cleanup |
1194 | | |
1195 | | /* We have detected an Import Library Format archive element. |
1196 | | Decode the element and return the appropriate target. */ |
1197 | | |
1198 | | static bfd_cleanup |
1199 | | pe_ILF_object_p (bfd *abfd) |
1200 | 17.5k | { |
1201 | 17.5k | bfd_byte buffer[14]; |
1202 | 17.5k | bfd_byte * ptr; |
1203 | 17.5k | char * symbol_name; |
1204 | 17.5k | char * source_dll; |
1205 | 17.5k | char * import_name; |
1206 | 17.5k | unsigned int machine; |
1207 | 17.5k | bfd_size_type size; |
1208 | 17.5k | unsigned int ordinal; |
1209 | 17.5k | unsigned int types; |
1210 | 17.5k | unsigned int magic; |
1211 | | |
1212 | | /* Upon entry the first six bytes of the ILF header have |
1213 | | already been read. Now read the rest of the header. */ |
1214 | 17.5k | if (bfd_read (buffer, 14, abfd) != 14) |
1215 | 339 | return NULL; |
1216 | | |
1217 | 17.2k | ptr = buffer; |
1218 | | |
1219 | 17.2k | machine = H_GET_16 (abfd, ptr); |
1220 | 17.2k | ptr += 2; |
1221 | | |
1222 | | /* Check that the machine type is recognised. */ |
1223 | 17.2k | magic = 0; |
1224 | | |
1225 | 17.2k | switch (machine) |
1226 | 17.2k | { |
1227 | 99 | case IMAGE_FILE_MACHINE_UNKNOWN: |
1228 | 126 | case IMAGE_FILE_MACHINE_ALPHA: |
1229 | 153 | case IMAGE_FILE_MACHINE_ALPHA64: |
1230 | 180 | case IMAGE_FILE_MACHINE_IA64: |
1231 | 180 | break; |
1232 | | |
1233 | 1.61k | case IMAGE_FILE_MACHINE_I386: |
1234 | | #ifdef I386MAGIC |
1235 | 209 | magic = I386MAGIC; |
1236 | | #endif |
1237 | 1.61k | break; |
1238 | | |
1239 | 1.61k | case IMAGE_FILE_MACHINE_AMD64: |
1240 | | #ifdef AMD64MAGIC |
1241 | 214 | magic = AMD64MAGIC; |
1242 | | #endif |
1243 | 1.61k | break; |
1244 | | |
1245 | 45 | case IMAGE_FILE_MACHINE_R3000: |
1246 | 63 | case IMAGE_FILE_MACHINE_R4000: |
1247 | 90 | case IMAGE_FILE_MACHINE_R10000: |
1248 | | |
1249 | 99 | case IMAGE_FILE_MACHINE_MIPS16: |
1250 | 126 | case IMAGE_FILE_MACHINE_MIPSFPU: |
1251 | 153 | case IMAGE_FILE_MACHINE_MIPSFPU16: |
1252 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
1253 | | magic = MIPS_ARCH_MAGIC_WINCE; |
1254 | | #endif |
1255 | 153 | break; |
1256 | | |
1257 | 1.41k | case IMAGE_FILE_MACHINE_SH3: |
1258 | 2.23k | case IMAGE_FILE_MACHINE_SH4: |
1259 | | #ifdef SH_ARCH_MAGIC_WINCE |
1260 | 281 | magic = SH_ARCH_MAGIC_WINCE; |
1261 | | #endif |
1262 | 2.23k | break; |
1263 | | |
1264 | 1.03k | case IMAGE_FILE_MACHINE_ARM: |
1265 | | #ifdef ARMPEMAGIC |
1266 | 286 | magic = ARMPEMAGIC; |
1267 | | #endif |
1268 | 1.03k | break; |
1269 | | |
1270 | 1.69k | case IMAGE_FILE_MACHINE_ARM64: |
1271 | | #ifdef AARCH64MAGIC |
1272 | 211 | magic = AARCH64MAGIC; |
1273 | | #endif |
1274 | 1.69k | break; |
1275 | | |
1276 | 1.86k | case IMAGE_FILE_MACHINE_LOONGARCH64: |
1277 | | #ifdef LOONGARCH64MAGIC |
1278 | 236 | magic = LOONGARCH64MAGIC; |
1279 | | #endif |
1280 | 1.86k | break; |
1281 | | |
1282 | 1.55k | case IMAGE_FILE_MACHINE_RISCV64: |
1283 | | #ifdef RISCV64MAGIC |
1284 | 198 | magic = RISCV64MAGIC; |
1285 | | #endif |
1286 | 1.55k | break; |
1287 | | |
1288 | 1.15k | case IMAGE_FILE_MACHINE_THUMB: |
1289 | | #ifdef THUMBPEMAGIC |
1290 | | { |
1291 | | extern const bfd_target TARGET_LITTLE_SYM; |
1292 | | |
1293 | 258 | if (abfd->xvec == &TARGET_LITTLE_SYM) |
1294 | 256 | magic = THUMBPEMAGIC; |
1295 | | } |
1296 | | #endif |
1297 | 1.15k | break; |
1298 | | |
1299 | 0 | case IMAGE_FILE_MACHINE_POWERPC: |
1300 | | /* We no longer support PowerPC. */ |
1301 | 4.13k | default: |
1302 | 4.13k | _bfd_error_handler |
1303 | | /* xgettext:c-format */ |
1304 | 4.13k | (_("%pB: unrecognised machine type (0x%x)" |
1305 | 4.13k | " in Import Library Format archive"), |
1306 | 4.13k | abfd, machine); |
1307 | 4.13k | bfd_set_error (bfd_error_malformed_archive); |
1308 | | |
1309 | 4.13k | return NULL; |
1310 | 0 | break; |
1311 | 17.2k | } |
1312 | | |
1313 | 13.1k | if (magic == 0) |
1314 | 11.2k | { |
1315 | 11.2k | _bfd_error_handler |
1316 | | /* xgettext:c-format */ |
1317 | 11.2k | (_("%pB: recognised but unhandled machine type (0x%x)" |
1318 | 11.2k | " in Import Library Format archive"), |
1319 | 11.2k | abfd, machine); |
1320 | 11.2k | bfd_set_error (bfd_error_wrong_format); |
1321 | | |
1322 | 11.2k | return NULL; |
1323 | 11.2k | } |
1324 | | |
1325 | | /* We do not bother to check the date. |
1326 | | date = H_GET_32 (abfd, ptr); */ |
1327 | 1.89k | ptr += 4; |
1328 | | |
1329 | 1.89k | size = H_GET_32 (abfd, ptr); |
1330 | 1.89k | ptr += 4; |
1331 | | |
1332 | 1.89k | if (size == 0) |
1333 | 42 | { |
1334 | 42 | _bfd_error_handler |
1335 | 42 | (_("%pB: size field is zero in Import Library Format header"), abfd); |
1336 | 42 | bfd_set_error (bfd_error_malformed_archive); |
1337 | | |
1338 | 42 | return NULL; |
1339 | 42 | } |
1340 | | |
1341 | 1.84k | ordinal = H_GET_16 (abfd, ptr); |
1342 | 1.84k | ptr += 2; |
1343 | | |
1344 | 1.84k | types = H_GET_16 (abfd, ptr); |
1345 | | /* ptr += 2; */ |
1346 | | |
1347 | | /* Now read in the two strings that follow. */ |
1348 | 1.84k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); |
1349 | 1.84k | if (ptr == NULL) |
1350 | 979 | return NULL; |
1351 | | |
1352 | 870 | symbol_name = (char *) ptr; |
1353 | | /* See PR 20905 for an example of where the strnlen is necessary. */ |
1354 | 870 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; |
1355 | | |
1356 | | /* Verify that the strings are null terminated. */ |
1357 | 870 | if (ptr[size - 1] != 0 |
1358 | 770 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) |
1359 | 128 | { |
1360 | 128 | _bfd_error_handler |
1361 | 128 | (_("%pB: string not null terminated in ILF object file"), abfd); |
1362 | 128 | bfd_set_error (bfd_error_malformed_archive); |
1363 | 128 | bfd_release (abfd, ptr); |
1364 | 128 | return NULL; |
1365 | 128 | } |
1366 | | |
1367 | | /* An ILF file may contain a third string, after source_dll; this is |
1368 | | used for IMPORT_NAME_EXPORTAS. We know from above that the whole |
1369 | | block of data is null terminated, ptr[size-1]==0, but we don't |
1370 | | know how many individual null terminated strings we have in there. |
1371 | | |
1372 | | First find the end of source_dll. */ |
1373 | 742 | import_name = source_dll + strlen (source_dll) + 1; |
1374 | 742 | if ((bfd_byte *) import_name >= ptr + size) |
1375 | 230 | { |
1376 | | /* If this points at the end of the ptr+size block, we only had |
1377 | | two strings. */ |
1378 | 230 | import_name = NULL; |
1379 | 230 | } |
1380 | | |
1381 | | /* Now construct the bfd. */ |
1382 | 742 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, |
1383 | 742 | source_dll, ordinal, types, |
1384 | 742 | import_name)) |
1385 | 188 | { |
1386 | 188 | bfd_release (abfd, ptr); |
1387 | 188 | return NULL; |
1388 | 188 | } |
1389 | | |
1390 | 554 | return pe_ILF_cleanup; |
1391 | 742 | } pei-i386.c:pe_ILF_object_p Line | Count | Source | 1200 | 1.94k | { | 1201 | 1.94k | bfd_byte buffer[14]; | 1202 | 1.94k | bfd_byte * ptr; | 1203 | 1.94k | char * symbol_name; | 1204 | 1.94k | char * source_dll; | 1205 | 1.94k | char * import_name; | 1206 | 1.94k | unsigned int machine; | 1207 | 1.94k | bfd_size_type size; | 1208 | 1.94k | unsigned int ordinal; | 1209 | 1.94k | unsigned int types; | 1210 | 1.94k | unsigned int magic; | 1211 | | | 1212 | | /* Upon entry the first six bytes of the ILF header have | 1213 | | already been read. Now read the rest of the header. */ | 1214 | 1.94k | if (bfd_read (buffer, 14, abfd) != 14) | 1215 | 35 | return NULL; | 1216 | | | 1217 | 1.90k | ptr = buffer; | 1218 | | | 1219 | 1.90k | machine = H_GET_16 (abfd, ptr); | 1220 | 1.90k | ptr += 2; | 1221 | | | 1222 | | /* Check that the machine type is recognised. */ | 1223 | 1.90k | magic = 0; | 1224 | | | 1225 | 1.90k | switch (machine) | 1226 | 1.90k | { | 1227 | 11 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1228 | 14 | case IMAGE_FILE_MACHINE_ALPHA: | 1229 | 17 | case IMAGE_FILE_MACHINE_ALPHA64: | 1230 | 20 | case IMAGE_FILE_MACHINE_IA64: | 1231 | 20 | break; | 1232 | | | 1233 | 209 | case IMAGE_FILE_MACHINE_I386: | 1234 | 209 | #ifdef I386MAGIC | 1235 | 209 | magic = I386MAGIC; | 1236 | 209 | #endif | 1237 | 209 | break; | 1238 | | | 1239 | 175 | case IMAGE_FILE_MACHINE_AMD64: | 1240 | | #ifdef AMD64MAGIC | 1241 | | magic = AMD64MAGIC; | 1242 | | #endif | 1243 | 175 | break; | 1244 | | | 1245 | 5 | case IMAGE_FILE_MACHINE_R3000: | 1246 | 7 | case IMAGE_FILE_MACHINE_R4000: | 1247 | 10 | case IMAGE_FILE_MACHINE_R10000: | 1248 | | | 1249 | 11 | case IMAGE_FILE_MACHINE_MIPS16: | 1250 | 14 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1251 | 17 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1252 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1253 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1254 | | #endif | 1255 | 17 | break; | 1256 | | | 1257 | 155 | case IMAGE_FILE_MACHINE_SH3: | 1258 | 245 | case IMAGE_FILE_MACHINE_SH4: | 1259 | | #ifdef SH_ARCH_MAGIC_WINCE | 1260 | | magic = SH_ARCH_MAGIC_WINCE; | 1261 | | #endif | 1262 | 245 | break; | 1263 | | | 1264 | 101 | case IMAGE_FILE_MACHINE_ARM: | 1265 | | #ifdef ARMPEMAGIC | 1266 | | magic = ARMPEMAGIC; | 1267 | | #endif | 1268 | 101 | break; | 1269 | | | 1270 | 186 | case IMAGE_FILE_MACHINE_ARM64: | 1271 | | #ifdef AARCH64MAGIC | 1272 | | magic = AARCH64MAGIC; | 1273 | | #endif | 1274 | 186 | break; | 1275 | | | 1276 | 204 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1277 | | #ifdef LOONGARCH64MAGIC | 1278 | | magic = LOONGARCH64MAGIC; | 1279 | | #endif | 1280 | 204 | break; | 1281 | | | 1282 | 170 | case IMAGE_FILE_MACHINE_RISCV64: | 1283 | | #ifdef RISCV64MAGIC | 1284 | | magic = RISCV64MAGIC; | 1285 | | #endif | 1286 | 170 | break; | 1287 | | | 1288 | 128 | case IMAGE_FILE_MACHINE_THUMB: | 1289 | | #ifdef THUMBPEMAGIC | 1290 | | { | 1291 | | extern const bfd_target TARGET_LITTLE_SYM; | 1292 | | | 1293 | | if (abfd->xvec == &TARGET_LITTLE_SYM) | 1294 | | magic = THUMBPEMAGIC; | 1295 | | } | 1296 | | #endif | 1297 | 128 | break; | 1298 | | | 1299 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1300 | | /* We no longer support PowerPC. */ | 1301 | 452 | default: | 1302 | 452 | _bfd_error_handler | 1303 | | /* xgettext:c-format */ | 1304 | 452 | (_("%pB: unrecognised machine type (0x%x)" | 1305 | 452 | " in Import Library Format archive"), | 1306 | 452 | abfd, machine); | 1307 | 452 | bfd_set_error (bfd_error_malformed_archive); | 1308 | | | 1309 | 452 | return NULL; | 1310 | 0 | break; | 1311 | 1.90k | } | 1312 | | | 1313 | 1.45k | if (magic == 0) | 1314 | 1.24k | { | 1315 | 1.24k | _bfd_error_handler | 1316 | | /* xgettext:c-format */ | 1317 | 1.24k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1318 | 1.24k | " in Import Library Format archive"), | 1319 | 1.24k | abfd, machine); | 1320 | 1.24k | bfd_set_error (bfd_error_wrong_format); | 1321 | | | 1322 | 1.24k | return NULL; | 1323 | 1.24k | } | 1324 | | | 1325 | | /* We do not bother to check the date. | 1326 | | date = H_GET_32 (abfd, ptr); */ | 1327 | 209 | ptr += 4; | 1328 | | | 1329 | 209 | size = H_GET_32 (abfd, ptr); | 1330 | 209 | ptr += 4; | 1331 | | | 1332 | 209 | if (size == 0) | 1333 | 5 | { | 1334 | 5 | _bfd_error_handler | 1335 | 5 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1336 | 5 | bfd_set_error (bfd_error_malformed_archive); | 1337 | | | 1338 | 5 | return NULL; | 1339 | 5 | } | 1340 | | | 1341 | 204 | ordinal = H_GET_16 (abfd, ptr); | 1342 | 204 | ptr += 2; | 1343 | | | 1344 | 204 | types = H_GET_16 (abfd, ptr); | 1345 | | /* ptr += 2; */ | 1346 | | | 1347 | | /* Now read in the two strings that follow. */ | 1348 | 204 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1349 | 204 | if (ptr == NULL) | 1350 | 101 | return NULL; | 1351 | | | 1352 | 103 | symbol_name = (char *) ptr; | 1353 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1354 | 103 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1355 | | | 1356 | | /* Verify that the strings are null terminated. */ | 1357 | 103 | if (ptr[size - 1] != 0 | 1358 | 97 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1359 | 9 | { | 1360 | 9 | _bfd_error_handler | 1361 | 9 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1362 | 9 | bfd_set_error (bfd_error_malformed_archive); | 1363 | 9 | bfd_release (abfd, ptr); | 1364 | 9 | return NULL; | 1365 | 9 | } | 1366 | | | 1367 | | /* An ILF file may contain a third string, after source_dll; this is | 1368 | | used for IMPORT_NAME_EXPORTAS. We know from above that the whole | 1369 | | block of data is null terminated, ptr[size-1]==0, but we don't | 1370 | | know how many individual null terminated strings we have in there. | 1371 | | | 1372 | | First find the end of source_dll. */ | 1373 | 94 | import_name = source_dll + strlen (source_dll) + 1; | 1374 | 94 | if ((bfd_byte *) import_name >= ptr + size) | 1375 | 27 | { | 1376 | | /* If this points at the end of the ptr+size block, we only had | 1377 | | two strings. */ | 1378 | 27 | import_name = NULL; | 1379 | 27 | } | 1380 | | | 1381 | | /* Now construct the bfd. */ | 1382 | 94 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1383 | 94 | source_dll, ordinal, types, | 1384 | 94 | import_name)) | 1385 | 19 | { | 1386 | 19 | bfd_release (abfd, ptr); | 1387 | 19 | return NULL; | 1388 | 19 | } | 1389 | | | 1390 | 75 | return pe_ILF_cleanup; | 1391 | 94 | } |
pei-x86_64.c:pe_ILF_object_p Line | Count | Source | 1200 | 1.94k | { | 1201 | 1.94k | bfd_byte buffer[14]; | 1202 | 1.94k | bfd_byte * ptr; | 1203 | 1.94k | char * symbol_name; | 1204 | 1.94k | char * source_dll; | 1205 | 1.94k | char * import_name; | 1206 | 1.94k | unsigned int machine; | 1207 | 1.94k | bfd_size_type size; | 1208 | 1.94k | unsigned int ordinal; | 1209 | 1.94k | unsigned int types; | 1210 | 1.94k | unsigned int magic; | 1211 | | | 1212 | | /* Upon entry the first six bytes of the ILF header have | 1213 | | already been read. Now read the rest of the header. */ | 1214 | 1.94k | if (bfd_read (buffer, 14, abfd) != 14) | 1215 | 35 | return NULL; | 1216 | | | 1217 | 1.90k | ptr = buffer; | 1218 | | | 1219 | 1.90k | machine = H_GET_16 (abfd, ptr); | 1220 | 1.90k | ptr += 2; | 1221 | | | 1222 | | /* Check that the machine type is recognised. */ | 1223 | 1.90k | magic = 0; | 1224 | | | 1225 | 1.90k | switch (machine) | 1226 | 1.90k | { | 1227 | 11 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1228 | 14 | case IMAGE_FILE_MACHINE_ALPHA: | 1229 | 17 | case IMAGE_FILE_MACHINE_ALPHA64: | 1230 | 20 | case IMAGE_FILE_MACHINE_IA64: | 1231 | 20 | break; | 1232 | | | 1233 | 175 | case IMAGE_FILE_MACHINE_I386: | 1234 | | #ifdef I386MAGIC | 1235 | | magic = I386MAGIC; | 1236 | | #endif | 1237 | 175 | break; | 1238 | | | 1239 | 214 | case IMAGE_FILE_MACHINE_AMD64: | 1240 | 214 | #ifdef AMD64MAGIC | 1241 | 214 | magic = AMD64MAGIC; | 1242 | 214 | #endif | 1243 | 214 | break; | 1244 | | | 1245 | 5 | case IMAGE_FILE_MACHINE_R3000: | 1246 | 7 | case IMAGE_FILE_MACHINE_R4000: | 1247 | 10 | case IMAGE_FILE_MACHINE_R10000: | 1248 | | | 1249 | 11 | case IMAGE_FILE_MACHINE_MIPS16: | 1250 | 14 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1251 | 17 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1252 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1253 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1254 | | #endif | 1255 | 17 | break; | 1256 | | | 1257 | 152 | case IMAGE_FILE_MACHINE_SH3: | 1258 | 241 | case IMAGE_FILE_MACHINE_SH4: | 1259 | | #ifdef SH_ARCH_MAGIC_WINCE | 1260 | | magic = SH_ARCH_MAGIC_WINCE; | 1261 | | #endif | 1262 | 241 | break; | 1263 | | | 1264 | 101 | case IMAGE_FILE_MACHINE_ARM: | 1265 | | #ifdef ARMPEMAGIC | 1266 | | magic = ARMPEMAGIC; | 1267 | | #endif | 1268 | 101 | break; | 1269 | | | 1270 | 186 | case IMAGE_FILE_MACHINE_ARM64: | 1271 | | #ifdef AARCH64MAGIC | 1272 | | magic = AARCH64MAGIC; | 1273 | | #endif | 1274 | 186 | break; | 1275 | | | 1276 | 204 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1277 | | #ifdef LOONGARCH64MAGIC | 1278 | | magic = LOONGARCH64MAGIC; | 1279 | | #endif | 1280 | 204 | break; | 1281 | | | 1282 | 169 | case IMAGE_FILE_MACHINE_RISCV64: | 1283 | | #ifdef RISCV64MAGIC | 1284 | | magic = RISCV64MAGIC; | 1285 | | #endif | 1286 | 169 | break; | 1287 | | | 1288 | 128 | case IMAGE_FILE_MACHINE_THUMB: | 1289 | | #ifdef THUMBPEMAGIC | 1290 | | { | 1291 | | extern const bfd_target TARGET_LITTLE_SYM; | 1292 | | | 1293 | | if (abfd->xvec == &TARGET_LITTLE_SYM) | 1294 | | magic = THUMBPEMAGIC; | 1295 | | } | 1296 | | #endif | 1297 | 128 | break; | 1298 | | | 1299 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1300 | | /* We no longer support PowerPC. */ | 1301 | 452 | default: | 1302 | 452 | _bfd_error_handler | 1303 | | /* xgettext:c-format */ | 1304 | 452 | (_("%pB: unrecognised machine type (0x%x)" | 1305 | 452 | " in Import Library Format archive"), | 1306 | 452 | abfd, machine); | 1307 | 452 | bfd_set_error (bfd_error_malformed_archive); | 1308 | | | 1309 | 452 | return NULL; | 1310 | 0 | break; | 1311 | 1.90k | } | 1312 | | | 1313 | 1.45k | if (magic == 0) | 1314 | 1.24k | { | 1315 | 1.24k | _bfd_error_handler | 1316 | | /* xgettext:c-format */ | 1317 | 1.24k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1318 | 1.24k | " in Import Library Format archive"), | 1319 | 1.24k | abfd, machine); | 1320 | 1.24k | bfd_set_error (bfd_error_wrong_format); | 1321 | | | 1322 | 1.24k | return NULL; | 1323 | 1.24k | } | 1324 | | | 1325 | | /* We do not bother to check the date. | 1326 | | date = H_GET_32 (abfd, ptr); */ | 1327 | 214 | ptr += 4; | 1328 | | | 1329 | 214 | size = H_GET_32 (abfd, ptr); | 1330 | 214 | ptr += 4; | 1331 | | | 1332 | 214 | if (size == 0) | 1333 | 5 | { | 1334 | 5 | _bfd_error_handler | 1335 | 5 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1336 | 5 | bfd_set_error (bfd_error_malformed_archive); | 1337 | | | 1338 | 5 | return NULL; | 1339 | 5 | } | 1340 | | | 1341 | 209 | ordinal = H_GET_16 (abfd, ptr); | 1342 | 209 | ptr += 2; | 1343 | | | 1344 | 209 | types = H_GET_16 (abfd, ptr); | 1345 | | /* ptr += 2; */ | 1346 | | | 1347 | | /* Now read in the two strings that follow. */ | 1348 | 209 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1349 | 209 | if (ptr == NULL) | 1350 | 90 | return NULL; | 1351 | | | 1352 | 119 | symbol_name = (char *) ptr; | 1353 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1354 | 119 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1355 | | | 1356 | | /* Verify that the strings are null terminated. */ | 1357 | 119 | if (ptr[size - 1] != 0 | 1358 | 114 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1359 | 10 | { | 1360 | 10 | _bfd_error_handler | 1361 | 10 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1362 | 10 | bfd_set_error (bfd_error_malformed_archive); | 1363 | 10 | bfd_release (abfd, ptr); | 1364 | 10 | return NULL; | 1365 | 10 | } | 1366 | | | 1367 | | /* An ILF file may contain a third string, after source_dll; this is | 1368 | | used for IMPORT_NAME_EXPORTAS. We know from above that the whole | 1369 | | block of data is null terminated, ptr[size-1]==0, but we don't | 1370 | | know how many individual null terminated strings we have in there. | 1371 | | | 1372 | | First find the end of source_dll. */ | 1373 | 109 | import_name = source_dll + strlen (source_dll) + 1; | 1374 | 109 | if ((bfd_byte *) import_name >= ptr + size) | 1375 | 24 | { | 1376 | | /* If this points at the end of the ptr+size block, we only had | 1377 | | two strings. */ | 1378 | 24 | import_name = NULL; | 1379 | 24 | } | 1380 | | | 1381 | | /* Now construct the bfd. */ | 1382 | 109 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1383 | 109 | source_dll, ordinal, types, | 1384 | 109 | import_name)) | 1385 | 24 | { | 1386 | 24 | bfd_release (abfd, ptr); | 1387 | 24 | return NULL; | 1388 | 24 | } | 1389 | | | 1390 | 85 | return pe_ILF_cleanup; | 1391 | 109 | } |
pei-aarch64.c:pe_ILF_object_p Line | Count | Source | 1200 | 1.93k | { | 1201 | 1.93k | bfd_byte buffer[14]; | 1202 | 1.93k | bfd_byte * ptr; | 1203 | 1.93k | char * symbol_name; | 1204 | 1.93k | char * source_dll; | 1205 | 1.93k | char * import_name; | 1206 | 1.93k | unsigned int machine; | 1207 | 1.93k | bfd_size_type size; | 1208 | 1.93k | unsigned int ordinal; | 1209 | 1.93k | unsigned int types; | 1210 | 1.93k | unsigned int magic; | 1211 | | | 1212 | | /* Upon entry the first six bytes of the ILF header have | 1213 | | already been read. Now read the rest of the header. */ | 1214 | 1.93k | if (bfd_read (buffer, 14, abfd) != 14) | 1215 | 35 | return NULL; | 1216 | | | 1217 | 1.90k | ptr = buffer; | 1218 | | | 1219 | 1.90k | machine = H_GET_16 (abfd, ptr); | 1220 | 1.90k | ptr += 2; | 1221 | | | 1222 | | /* Check that the machine type is recognised. */ | 1223 | 1.90k | magic = 0; | 1224 | | | 1225 | 1.90k | switch (machine) | 1226 | 1.90k | { | 1227 | 11 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1228 | 14 | case IMAGE_FILE_MACHINE_ALPHA: | 1229 | 17 | case IMAGE_FILE_MACHINE_ALPHA64: | 1230 | 20 | case IMAGE_FILE_MACHINE_IA64: | 1231 | 20 | break; | 1232 | | | 1233 | 176 | case IMAGE_FILE_MACHINE_I386: | 1234 | | #ifdef I386MAGIC | 1235 | | magic = I386MAGIC; | 1236 | | #endif | 1237 | 176 | break; | 1238 | | | 1239 | 175 | case IMAGE_FILE_MACHINE_AMD64: | 1240 | | #ifdef AMD64MAGIC | 1241 | | magic = AMD64MAGIC; | 1242 | | #endif | 1243 | 175 | break; | 1244 | | | 1245 | 5 | case IMAGE_FILE_MACHINE_R3000: | 1246 | 7 | case IMAGE_FILE_MACHINE_R4000: | 1247 | 10 | case IMAGE_FILE_MACHINE_R10000: | 1248 | | | 1249 | 11 | case IMAGE_FILE_MACHINE_MIPS16: | 1250 | 14 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1251 | 17 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1252 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1253 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1254 | | #endif | 1255 | 17 | break; | 1256 | | | 1257 | 155 | case IMAGE_FILE_MACHINE_SH3: | 1258 | 245 | case IMAGE_FILE_MACHINE_SH4: | 1259 | | #ifdef SH_ARCH_MAGIC_WINCE | 1260 | | magic = SH_ARCH_MAGIC_WINCE; | 1261 | | #endif | 1262 | 245 | break; | 1263 | | | 1264 | 103 | case IMAGE_FILE_MACHINE_ARM: | 1265 | | #ifdef ARMPEMAGIC | 1266 | | magic = ARMPEMAGIC; | 1267 | | #endif | 1268 | 103 | break; | 1269 | | | 1270 | 211 | case IMAGE_FILE_MACHINE_ARM64: | 1271 | 211 | #ifdef AARCH64MAGIC | 1272 | 211 | magic = AARCH64MAGIC; | 1273 | 211 | #endif | 1274 | 211 | break; | 1275 | | | 1276 | 204 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1277 | | #ifdef LOONGARCH64MAGIC | 1278 | | magic = LOONGARCH64MAGIC; | 1279 | | #endif | 1280 | 204 | break; | 1281 | | | 1282 | 170 | case IMAGE_FILE_MACHINE_RISCV64: | 1283 | | #ifdef RISCV64MAGIC | 1284 | | magic = RISCV64MAGIC; | 1285 | | #endif | 1286 | 170 | break; | 1287 | | | 1288 | 128 | case IMAGE_FILE_MACHINE_THUMB: | 1289 | | #ifdef THUMBPEMAGIC | 1290 | | { | 1291 | | extern const bfd_target TARGET_LITTLE_SYM; | 1292 | | | 1293 | | if (abfd->xvec == &TARGET_LITTLE_SYM) | 1294 | | magic = THUMBPEMAGIC; | 1295 | | } | 1296 | | #endif | 1297 | 128 | break; | 1298 | | | 1299 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1300 | | /* We no longer support PowerPC. */ | 1301 | 452 | default: | 1302 | 452 | _bfd_error_handler | 1303 | | /* xgettext:c-format */ | 1304 | 452 | (_("%pB: unrecognised machine type (0x%x)" | 1305 | 452 | " in Import Library Format archive"), | 1306 | 452 | abfd, machine); | 1307 | 452 | bfd_set_error (bfd_error_malformed_archive); | 1308 | | | 1309 | 452 | return NULL; | 1310 | 0 | break; | 1311 | 1.90k | } | 1312 | | | 1313 | 1.44k | if (magic == 0) | 1314 | 1.23k | { | 1315 | 1.23k | _bfd_error_handler | 1316 | | /* xgettext:c-format */ | 1317 | 1.23k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1318 | 1.23k | " in Import Library Format archive"), | 1319 | 1.23k | abfd, machine); | 1320 | 1.23k | bfd_set_error (bfd_error_wrong_format); | 1321 | | | 1322 | 1.23k | return NULL; | 1323 | 1.23k | } | 1324 | | | 1325 | | /* We do not bother to check the date. | 1326 | | date = H_GET_32 (abfd, ptr); */ | 1327 | 211 | ptr += 4; | 1328 | | | 1329 | 211 | size = H_GET_32 (abfd, ptr); | 1330 | 211 | ptr += 4; | 1331 | | | 1332 | 211 | if (size == 0) | 1333 | 5 | { | 1334 | 5 | _bfd_error_handler | 1335 | 5 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1336 | 5 | bfd_set_error (bfd_error_malformed_archive); | 1337 | | | 1338 | 5 | return NULL; | 1339 | 5 | } | 1340 | | | 1341 | 206 | ordinal = H_GET_16 (abfd, ptr); | 1342 | 206 | ptr += 2; | 1343 | | | 1344 | 206 | types = H_GET_16 (abfd, ptr); | 1345 | | /* ptr += 2; */ | 1346 | | | 1347 | | /* Now read in the two strings that follow. */ | 1348 | 206 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1349 | 206 | if (ptr == NULL) | 1350 | 123 | return NULL; | 1351 | | | 1352 | 83 | symbol_name = (char *) ptr; | 1353 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1354 | 83 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1355 | | | 1356 | | /* Verify that the strings are null terminated. */ | 1357 | 83 | if (ptr[size - 1] != 0 | 1358 | 80 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1359 | 6 | { | 1360 | 6 | _bfd_error_handler | 1361 | 6 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1362 | 6 | bfd_set_error (bfd_error_malformed_archive); | 1363 | 6 | bfd_release (abfd, ptr); | 1364 | 6 | return NULL; | 1365 | 6 | } | 1366 | | | 1367 | | /* An ILF file may contain a third string, after source_dll; this is | 1368 | | used for IMPORT_NAME_EXPORTAS. We know from above that the whole | 1369 | | block of data is null terminated, ptr[size-1]==0, but we don't | 1370 | | know how many individual null terminated strings we have in there. | 1371 | | | 1372 | | First find the end of source_dll. */ | 1373 | 77 | import_name = source_dll + strlen (source_dll) + 1; | 1374 | 77 | if ((bfd_byte *) import_name >= ptr + size) | 1375 | 21 | { | 1376 | | /* If this points at the end of the ptr+size block, we only had | 1377 | | two strings. */ | 1378 | 21 | import_name = NULL; | 1379 | 21 | } | 1380 | | | 1381 | | /* Now construct the bfd. */ | 1382 | 77 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1383 | 77 | source_dll, ordinal, types, | 1384 | 77 | import_name)) | 1385 | 15 | { | 1386 | 15 | bfd_release (abfd, ptr); | 1387 | 15 | return NULL; | 1388 | 15 | } | 1389 | | | 1390 | 62 | return pe_ILF_cleanup; | 1391 | 77 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_object_p pei-loongarch64.c:pe_ILF_object_p Line | Count | Source | 1200 | 1.93k | { | 1201 | 1.93k | bfd_byte buffer[14]; | 1202 | 1.93k | bfd_byte * ptr; | 1203 | 1.93k | char * symbol_name; | 1204 | 1.93k | char * source_dll; | 1205 | 1.93k | char * import_name; | 1206 | 1.93k | unsigned int machine; | 1207 | 1.93k | bfd_size_type size; | 1208 | 1.93k | unsigned int ordinal; | 1209 | 1.93k | unsigned int types; | 1210 | 1.93k | unsigned int magic; | 1211 | | | 1212 | | /* Upon entry the first six bytes of the ILF header have | 1213 | | already been read. Now read the rest of the header. */ | 1214 | 1.93k | if (bfd_read (buffer, 14, abfd) != 14) | 1215 | 35 | return NULL; | 1216 | | | 1217 | 1.89k | ptr = buffer; | 1218 | | | 1219 | 1.89k | machine = H_GET_16 (abfd, ptr); | 1220 | 1.89k | ptr += 2; | 1221 | | | 1222 | | /* Check that the machine type is recognised. */ | 1223 | 1.89k | magic = 0; | 1224 | | | 1225 | 1.89k | switch (machine) | 1226 | 1.89k | { | 1227 | 11 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1228 | 14 | case IMAGE_FILE_MACHINE_ALPHA: | 1229 | 17 | case IMAGE_FILE_MACHINE_ALPHA64: | 1230 | 20 | case IMAGE_FILE_MACHINE_IA64: | 1231 | 20 | break; | 1232 | | | 1233 | 175 | case IMAGE_FILE_MACHINE_I386: | 1234 | | #ifdef I386MAGIC | 1235 | | magic = I386MAGIC; | 1236 | | #endif | 1237 | 175 | break; | 1238 | | | 1239 | 174 | case IMAGE_FILE_MACHINE_AMD64: | 1240 | | #ifdef AMD64MAGIC | 1241 | | magic = AMD64MAGIC; | 1242 | | #endif | 1243 | 174 | break; | 1244 | | | 1245 | 5 | case IMAGE_FILE_MACHINE_R3000: | 1246 | 7 | case IMAGE_FILE_MACHINE_R4000: | 1247 | 10 | case IMAGE_FILE_MACHINE_R10000: | 1248 | | | 1249 | 11 | case IMAGE_FILE_MACHINE_MIPS16: | 1250 | 14 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1251 | 17 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1252 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1253 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1254 | | #endif | 1255 | 17 | break; | 1256 | | | 1257 | 152 | case IMAGE_FILE_MACHINE_SH3: | 1258 | 241 | case IMAGE_FILE_MACHINE_SH4: | 1259 | | #ifdef SH_ARCH_MAGIC_WINCE | 1260 | | magic = SH_ARCH_MAGIC_WINCE; | 1261 | | #endif | 1262 | 241 | break; | 1263 | | | 1264 | 101 | case IMAGE_FILE_MACHINE_ARM: | 1265 | | #ifdef ARMPEMAGIC | 1266 | | magic = ARMPEMAGIC; | 1267 | | #endif | 1268 | 101 | break; | 1269 | | | 1270 | 186 | case IMAGE_FILE_MACHINE_ARM64: | 1271 | | #ifdef AARCH64MAGIC | 1272 | | magic = AARCH64MAGIC; | 1273 | | #endif | 1274 | 186 | break; | 1275 | | | 1276 | 236 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1277 | 236 | #ifdef LOONGARCH64MAGIC | 1278 | 236 | magic = LOONGARCH64MAGIC; | 1279 | 236 | #endif | 1280 | 236 | break; | 1281 | | | 1282 | 169 | case IMAGE_FILE_MACHINE_RISCV64: | 1283 | | #ifdef RISCV64MAGIC | 1284 | | magic = RISCV64MAGIC; | 1285 | | #endif | 1286 | 169 | break; | 1287 | | | 1288 | 128 | case IMAGE_FILE_MACHINE_THUMB: | 1289 | | #ifdef THUMBPEMAGIC | 1290 | | { | 1291 | | extern const bfd_target TARGET_LITTLE_SYM; | 1292 | | | 1293 | | if (abfd->xvec == &TARGET_LITTLE_SYM) | 1294 | | magic = THUMBPEMAGIC; | 1295 | | } | 1296 | | #endif | 1297 | 128 | break; | 1298 | | | 1299 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1300 | | /* We no longer support PowerPC. */ | 1301 | 452 | default: | 1302 | 452 | _bfd_error_handler | 1303 | | /* xgettext:c-format */ | 1304 | 452 | (_("%pB: unrecognised machine type (0x%x)" | 1305 | 452 | " in Import Library Format archive"), | 1306 | 452 | abfd, machine); | 1307 | 452 | bfd_set_error (bfd_error_malformed_archive); | 1308 | | | 1309 | 452 | return NULL; | 1310 | 0 | break; | 1311 | 1.89k | } | 1312 | | | 1313 | 1.44k | if (magic == 0) | 1314 | 1.21k | { | 1315 | 1.21k | _bfd_error_handler | 1316 | | /* xgettext:c-format */ | 1317 | 1.21k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1318 | 1.21k | " in Import Library Format archive"), | 1319 | 1.21k | abfd, machine); | 1320 | 1.21k | bfd_set_error (bfd_error_wrong_format); | 1321 | | | 1322 | 1.21k | return NULL; | 1323 | 1.21k | } | 1324 | | | 1325 | | /* We do not bother to check the date. | 1326 | | date = H_GET_32 (abfd, ptr); */ | 1327 | 236 | ptr += 4; | 1328 | | | 1329 | 236 | size = H_GET_32 (abfd, ptr); | 1330 | 236 | ptr += 4; | 1331 | | | 1332 | 236 | if (size == 0) | 1333 | 5 | { | 1334 | 5 | _bfd_error_handler | 1335 | 5 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1336 | 5 | bfd_set_error (bfd_error_malformed_archive); | 1337 | | | 1338 | 5 | return NULL; | 1339 | 5 | } | 1340 | | | 1341 | 231 | ordinal = H_GET_16 (abfd, ptr); | 1342 | 231 | ptr += 2; | 1343 | | | 1344 | 231 | types = H_GET_16 (abfd, ptr); | 1345 | | /* ptr += 2; */ | 1346 | | | 1347 | | /* Now read in the two strings that follow. */ | 1348 | 231 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1349 | 231 | if (ptr == NULL) | 1350 | 130 | return NULL; | 1351 | | | 1352 | 101 | symbol_name = (char *) ptr; | 1353 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1354 | 101 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1355 | | | 1356 | | /* Verify that the strings are null terminated. */ | 1357 | 101 | if (ptr[size - 1] != 0 | 1358 | 94 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1359 | 10 | { | 1360 | 10 | _bfd_error_handler | 1361 | 10 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1362 | 10 | bfd_set_error (bfd_error_malformed_archive); | 1363 | 10 | bfd_release (abfd, ptr); | 1364 | 10 | return NULL; | 1365 | 10 | } | 1366 | | | 1367 | | /* An ILF file may contain a third string, after source_dll; this is | 1368 | | used for IMPORT_NAME_EXPORTAS. We know from above that the whole | 1369 | | block of data is null terminated, ptr[size-1]==0, but we don't | 1370 | | know how many individual null terminated strings we have in there. | 1371 | | | 1372 | | First find the end of source_dll. */ | 1373 | 91 | import_name = source_dll + strlen (source_dll) + 1; | 1374 | 91 | if ((bfd_byte *) import_name >= ptr + size) | 1375 | 19 | { | 1376 | | /* If this points at the end of the ptr+size block, we only had | 1377 | | two strings. */ | 1378 | 19 | import_name = NULL; | 1379 | 19 | } | 1380 | | | 1381 | | /* Now construct the bfd. */ | 1382 | 91 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1383 | 91 | source_dll, ordinal, types, | 1384 | 91 | import_name)) | 1385 | 19 | { | 1386 | 19 | bfd_release (abfd, ptr); | 1387 | 19 | return NULL; | 1388 | 19 | } | 1389 | | | 1390 | 72 | return pe_ILF_cleanup; | 1391 | 91 | } |
pei-riscv64.c:pe_ILF_object_p Line | Count | Source | 1200 | 1.93k | { | 1201 | 1.93k | bfd_byte buffer[14]; | 1202 | 1.93k | bfd_byte * ptr; | 1203 | 1.93k | char * symbol_name; | 1204 | 1.93k | char * source_dll; | 1205 | 1.93k | char * import_name; | 1206 | 1.93k | unsigned int machine; | 1207 | 1.93k | bfd_size_type size; | 1208 | 1.93k | unsigned int ordinal; | 1209 | 1.93k | unsigned int types; | 1210 | 1.93k | unsigned int magic; | 1211 | | | 1212 | | /* Upon entry the first six bytes of the ILF header have | 1213 | | already been read. Now read the rest of the header. */ | 1214 | 1.93k | if (bfd_read (buffer, 14, abfd) != 14) | 1215 | 35 | return NULL; | 1216 | | | 1217 | 1.90k | ptr = buffer; | 1218 | | | 1219 | 1.90k | machine = H_GET_16 (abfd, ptr); | 1220 | 1.90k | ptr += 2; | 1221 | | | 1222 | | /* Check that the machine type is recognised. */ | 1223 | 1.90k | magic = 0; | 1224 | | | 1225 | 1.90k | switch (machine) | 1226 | 1.90k | { | 1227 | 11 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1228 | 14 | case IMAGE_FILE_MACHINE_ALPHA: | 1229 | 17 | case IMAGE_FILE_MACHINE_ALPHA64: | 1230 | 20 | case IMAGE_FILE_MACHINE_IA64: | 1231 | 20 | break; | 1232 | | | 1233 | 175 | case IMAGE_FILE_MACHINE_I386: | 1234 | | #ifdef I386MAGIC | 1235 | | magic = I386MAGIC; | 1236 | | #endif | 1237 | 175 | break; | 1238 | | | 1239 | 175 | case IMAGE_FILE_MACHINE_AMD64: | 1240 | | #ifdef AMD64MAGIC | 1241 | | magic = AMD64MAGIC; | 1242 | | #endif | 1243 | 175 | break; | 1244 | | | 1245 | 5 | case IMAGE_FILE_MACHINE_R3000: | 1246 | 7 | case IMAGE_FILE_MACHINE_R4000: | 1247 | 10 | case IMAGE_FILE_MACHINE_R10000: | 1248 | | | 1249 | 11 | case IMAGE_FILE_MACHINE_MIPS16: | 1250 | 14 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1251 | 17 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1252 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1253 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1254 | | #endif | 1255 | 17 | break; | 1256 | | | 1257 | 155 | case IMAGE_FILE_MACHINE_SH3: | 1258 | 245 | case IMAGE_FILE_MACHINE_SH4: | 1259 | | #ifdef SH_ARCH_MAGIC_WINCE | 1260 | | magic = SH_ARCH_MAGIC_WINCE; | 1261 | | #endif | 1262 | 245 | break; | 1263 | | | 1264 | 101 | case IMAGE_FILE_MACHINE_ARM: | 1265 | | #ifdef ARMPEMAGIC | 1266 | | magic = ARMPEMAGIC; | 1267 | | #endif | 1268 | 101 | break; | 1269 | | | 1270 | 186 | case IMAGE_FILE_MACHINE_ARM64: | 1271 | | #ifdef AARCH64MAGIC | 1272 | | magic = AARCH64MAGIC; | 1273 | | #endif | 1274 | 186 | break; | 1275 | | | 1276 | 204 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1277 | | #ifdef LOONGARCH64MAGIC | 1278 | | magic = LOONGARCH64MAGIC; | 1279 | | #endif | 1280 | 204 | break; | 1281 | | | 1282 | 198 | case IMAGE_FILE_MACHINE_RISCV64: | 1283 | 198 | #ifdef RISCV64MAGIC | 1284 | 198 | magic = RISCV64MAGIC; | 1285 | 198 | #endif | 1286 | 198 | break; | 1287 | | | 1288 | 128 | case IMAGE_FILE_MACHINE_THUMB: | 1289 | | #ifdef THUMBPEMAGIC | 1290 | | { | 1291 | | extern const bfd_target TARGET_LITTLE_SYM; | 1292 | | | 1293 | | if (abfd->xvec == &TARGET_LITTLE_SYM) | 1294 | | magic = THUMBPEMAGIC; | 1295 | | } | 1296 | | #endif | 1297 | 128 | break; | 1298 | | | 1299 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1300 | | /* We no longer support PowerPC. */ | 1301 | 452 | default: | 1302 | 452 | _bfd_error_handler | 1303 | | /* xgettext:c-format */ | 1304 | 452 | (_("%pB: unrecognised machine type (0x%x)" | 1305 | 452 | " in Import Library Format archive"), | 1306 | 452 | abfd, machine); | 1307 | 452 | bfd_set_error (bfd_error_malformed_archive); | 1308 | | | 1309 | 452 | return NULL; | 1310 | 0 | break; | 1311 | 1.90k | } | 1312 | | | 1313 | 1.44k | if (magic == 0) | 1314 | 1.25k | { | 1315 | 1.25k | _bfd_error_handler | 1316 | | /* xgettext:c-format */ | 1317 | 1.25k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1318 | 1.25k | " in Import Library Format archive"), | 1319 | 1.25k | abfd, machine); | 1320 | 1.25k | bfd_set_error (bfd_error_wrong_format); | 1321 | | | 1322 | 1.25k | return NULL; | 1323 | 1.25k | } | 1324 | | | 1325 | | /* We do not bother to check the date. | 1326 | | date = H_GET_32 (abfd, ptr); */ | 1327 | 198 | ptr += 4; | 1328 | | | 1329 | 198 | size = H_GET_32 (abfd, ptr); | 1330 | 198 | ptr += 4; | 1331 | | | 1332 | 198 | if (size == 0) | 1333 | 3 | { | 1334 | 3 | _bfd_error_handler | 1335 | 3 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1336 | 3 | bfd_set_error (bfd_error_malformed_archive); | 1337 | | | 1338 | 3 | return NULL; | 1339 | 3 | } | 1340 | | | 1341 | 195 | ordinal = H_GET_16 (abfd, ptr); | 1342 | 195 | ptr += 2; | 1343 | | | 1344 | 195 | types = H_GET_16 (abfd, ptr); | 1345 | | /* ptr += 2; */ | 1346 | | | 1347 | | /* Now read in the two strings that follow. */ | 1348 | 195 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1349 | 195 | if (ptr == NULL) | 1350 | 102 | return NULL; | 1351 | | | 1352 | 93 | symbol_name = (char *) ptr; | 1353 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1354 | 93 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1355 | | | 1356 | | /* Verify that the strings are null terminated. */ | 1357 | 93 | if (ptr[size - 1] != 0 | 1358 | 88 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1359 | 8 | { | 1360 | 8 | _bfd_error_handler | 1361 | 8 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1362 | 8 | bfd_set_error (bfd_error_malformed_archive); | 1363 | 8 | bfd_release (abfd, ptr); | 1364 | 8 | return NULL; | 1365 | 8 | } | 1366 | | | 1367 | | /* An ILF file may contain a third string, after source_dll; this is | 1368 | | used for IMPORT_NAME_EXPORTAS. We know from above that the whole | 1369 | | block of data is null terminated, ptr[size-1]==0, but we don't | 1370 | | know how many individual null terminated strings we have in there. | 1371 | | | 1372 | | First find the end of source_dll. */ | 1373 | 85 | import_name = source_dll + strlen (source_dll) + 1; | 1374 | 85 | if ((bfd_byte *) import_name >= ptr + size) | 1375 | 21 | { | 1376 | | /* If this points at the end of the ptr+size block, we only had | 1377 | | two strings. */ | 1378 | 21 | import_name = NULL; | 1379 | 21 | } | 1380 | | | 1381 | | /* Now construct the bfd. */ | 1382 | 85 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1383 | 85 | source_dll, ordinal, types, | 1384 | 85 | import_name)) | 1385 | 18 | { | 1386 | 18 | bfd_release (abfd, ptr); | 1387 | 18 | return NULL; | 1388 | 18 | } | 1389 | | | 1390 | 67 | return pe_ILF_cleanup; | 1391 | 85 | } |
pei-arm-wince.c:pe_ILF_object_p Line | Count | Source | 1200 | 1.98k | { | 1201 | 1.98k | bfd_byte buffer[14]; | 1202 | 1.98k | bfd_byte * ptr; | 1203 | 1.98k | char * symbol_name; | 1204 | 1.98k | char * source_dll; | 1205 | 1.98k | char * import_name; | 1206 | 1.98k | unsigned int machine; | 1207 | 1.98k | bfd_size_type size; | 1208 | 1.98k | unsigned int ordinal; | 1209 | 1.98k | unsigned int types; | 1210 | 1.98k | unsigned int magic; | 1211 | | | 1212 | | /* Upon entry the first six bytes of the ILF header have | 1213 | | already been read. Now read the rest of the header. */ | 1214 | 1.98k | if (bfd_read (buffer, 14, abfd) != 14) | 1215 | 43 | return NULL; | 1216 | | | 1217 | 1.93k | ptr = buffer; | 1218 | | | 1219 | 1.93k | machine = H_GET_16 (abfd, ptr); | 1220 | 1.93k | ptr += 2; | 1221 | | | 1222 | | /* Check that the machine type is recognised. */ | 1223 | 1.93k | magic = 0; | 1224 | | | 1225 | 1.93k | switch (machine) | 1226 | 1.93k | { | 1227 | 11 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1228 | 14 | case IMAGE_FILE_MACHINE_ALPHA: | 1229 | 17 | case IMAGE_FILE_MACHINE_ALPHA64: | 1230 | 20 | case IMAGE_FILE_MACHINE_IA64: | 1231 | 20 | break; | 1232 | | | 1233 | 176 | case IMAGE_FILE_MACHINE_I386: | 1234 | | #ifdef I386MAGIC | 1235 | | magic = I386MAGIC; | 1236 | | #endif | 1237 | 176 | break; | 1238 | | | 1239 | 175 | case IMAGE_FILE_MACHINE_AMD64: | 1240 | | #ifdef AMD64MAGIC | 1241 | | magic = AMD64MAGIC; | 1242 | | #endif | 1243 | 175 | break; | 1244 | | | 1245 | 5 | case IMAGE_FILE_MACHINE_R3000: | 1246 | 7 | case IMAGE_FILE_MACHINE_R4000: | 1247 | 10 | case IMAGE_FILE_MACHINE_R10000: | 1248 | | | 1249 | 11 | case IMAGE_FILE_MACHINE_MIPS16: | 1250 | 14 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1251 | 17 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1252 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1253 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1254 | | #endif | 1255 | 17 | break; | 1256 | | | 1257 | 155 | case IMAGE_FILE_MACHINE_SH3: | 1258 | 245 | case IMAGE_FILE_MACHINE_SH4: | 1259 | | #ifdef SH_ARCH_MAGIC_WINCE | 1260 | | magic = SH_ARCH_MAGIC_WINCE; | 1261 | | #endif | 1262 | 245 | break; | 1263 | | | 1264 | 142 | case IMAGE_FILE_MACHINE_ARM: | 1265 | 142 | #ifdef ARMPEMAGIC | 1266 | 142 | magic = ARMPEMAGIC; | 1267 | 142 | #endif | 1268 | 142 | break; | 1269 | | | 1270 | 186 | case IMAGE_FILE_MACHINE_ARM64: | 1271 | | #ifdef AARCH64MAGIC | 1272 | | magic = AARCH64MAGIC; | 1273 | | #endif | 1274 | 186 | break; | 1275 | | | 1276 | 204 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1277 | | #ifdef LOONGARCH64MAGIC | 1278 | | magic = LOONGARCH64MAGIC; | 1279 | | #endif | 1280 | 204 | break; | 1281 | | | 1282 | 170 | case IMAGE_FILE_MACHINE_RISCV64: | 1283 | | #ifdef RISCV64MAGIC | 1284 | | magic = RISCV64MAGIC; | 1285 | | #endif | 1286 | 170 | break; | 1287 | | | 1288 | 129 | case IMAGE_FILE_MACHINE_THUMB: | 1289 | 129 | #ifdef THUMBPEMAGIC | 1290 | 129 | { | 1291 | 129 | extern const bfd_target TARGET_LITTLE_SYM; | 1292 | | | 1293 | 129 | if (abfd->xvec == &TARGET_LITTLE_SYM) | 1294 | 128 | magic = THUMBPEMAGIC; | 1295 | 129 | } | 1296 | 129 | #endif | 1297 | 129 | break; | 1298 | | | 1299 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1300 | | /* We no longer support PowerPC. */ | 1301 | 475 | default: | 1302 | 475 | _bfd_error_handler | 1303 | | /* xgettext:c-format */ | 1304 | 475 | (_("%pB: unrecognised machine type (0x%x)" | 1305 | 475 | " in Import Library Format archive"), | 1306 | 475 | abfd, machine); | 1307 | 475 | bfd_set_error (bfd_error_malformed_archive); | 1308 | | | 1309 | 475 | return NULL; | 1310 | 0 | break; | 1311 | 1.93k | } | 1312 | | | 1313 | 1.46k | if (magic == 0) | 1314 | 1.19k | { | 1315 | 1.19k | _bfd_error_handler | 1316 | | /* xgettext:c-format */ | 1317 | 1.19k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1318 | 1.19k | " in Import Library Format archive"), | 1319 | 1.19k | abfd, machine); | 1320 | 1.19k | bfd_set_error (bfd_error_wrong_format); | 1321 | | | 1322 | 1.19k | return NULL; | 1323 | 1.19k | } | 1324 | | | 1325 | | /* We do not bother to check the date. | 1326 | | date = H_GET_32 (abfd, ptr); */ | 1327 | 270 | ptr += 4; | 1328 | | | 1329 | 270 | size = H_GET_32 (abfd, ptr); | 1330 | 270 | ptr += 4; | 1331 | | | 1332 | 270 | if (size == 0) | 1333 | 5 | { | 1334 | 5 | _bfd_error_handler | 1335 | 5 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1336 | 5 | bfd_set_error (bfd_error_malformed_archive); | 1337 | | | 1338 | 5 | return NULL; | 1339 | 5 | } | 1340 | | | 1341 | 265 | ordinal = H_GET_16 (abfd, ptr); | 1342 | 265 | ptr += 2; | 1343 | | | 1344 | 265 | types = H_GET_16 (abfd, ptr); | 1345 | | /* ptr += 2; */ | 1346 | | | 1347 | | /* Now read in the two strings that follow. */ | 1348 | 265 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1349 | 265 | if (ptr == NULL) | 1350 | 160 | return NULL; | 1351 | | | 1352 | 105 | symbol_name = (char *) ptr; | 1353 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1354 | 105 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1355 | | | 1356 | | /* Verify that the strings are null terminated. */ | 1357 | 105 | if (ptr[size - 1] != 0 | 1358 | 86 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1359 | 22 | { | 1360 | 22 | _bfd_error_handler | 1361 | 22 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1362 | 22 | bfd_set_error (bfd_error_malformed_archive); | 1363 | 22 | bfd_release (abfd, ptr); | 1364 | 22 | return NULL; | 1365 | 22 | } | 1366 | | | 1367 | | /* An ILF file may contain a third string, after source_dll; this is | 1368 | | used for IMPORT_NAME_EXPORTAS. We know from above that the whole | 1369 | | block of data is null terminated, ptr[size-1]==0, but we don't | 1370 | | know how many individual null terminated strings we have in there. | 1371 | | | 1372 | | First find the end of source_dll. */ | 1373 | 83 | import_name = source_dll + strlen (source_dll) + 1; | 1374 | 83 | if ((bfd_byte *) import_name >= ptr + size) | 1375 | 37 | { | 1376 | | /* If this points at the end of the ptr+size block, we only had | 1377 | | two strings. */ | 1378 | 37 | import_name = NULL; | 1379 | 37 | } | 1380 | | | 1381 | | /* Now construct the bfd. */ | 1382 | 83 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1383 | 83 | source_dll, ordinal, types, | 1384 | 83 | import_name)) | 1385 | 27 | { | 1386 | 27 | bfd_release (abfd, ptr); | 1387 | 27 | return NULL; | 1388 | 27 | } | 1389 | | | 1390 | 56 | return pe_ILF_cleanup; | 1391 | 83 | } |
pei-arm.c:pe_ILF_object_p Line | Count | Source | 1200 | 1.98k | { | 1201 | 1.98k | bfd_byte buffer[14]; | 1202 | 1.98k | bfd_byte * ptr; | 1203 | 1.98k | char * symbol_name; | 1204 | 1.98k | char * source_dll; | 1205 | 1.98k | char * import_name; | 1206 | 1.98k | unsigned int machine; | 1207 | 1.98k | bfd_size_type size; | 1208 | 1.98k | unsigned int ordinal; | 1209 | 1.98k | unsigned int types; | 1210 | 1.98k | unsigned int magic; | 1211 | | | 1212 | | /* Upon entry the first six bytes of the ILF header have | 1213 | | already been read. Now read the rest of the header. */ | 1214 | 1.98k | if (bfd_read (buffer, 14, abfd) != 14) | 1215 | 43 | return NULL; | 1216 | | | 1217 | 1.94k | ptr = buffer; | 1218 | | | 1219 | 1.94k | machine = H_GET_16 (abfd, ptr); | 1220 | 1.94k | ptr += 2; | 1221 | | | 1222 | | /* Check that the machine type is recognised. */ | 1223 | 1.94k | magic = 0; | 1224 | | | 1225 | 1.94k | switch (machine) | 1226 | 1.94k | { | 1227 | 11 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1228 | 14 | case IMAGE_FILE_MACHINE_ALPHA: | 1229 | 17 | case IMAGE_FILE_MACHINE_ALPHA64: | 1230 | 20 | case IMAGE_FILE_MACHINE_IA64: | 1231 | 20 | break; | 1232 | | | 1233 | 176 | case IMAGE_FILE_MACHINE_I386: | 1234 | | #ifdef I386MAGIC | 1235 | | magic = I386MAGIC; | 1236 | | #endif | 1237 | 176 | break; | 1238 | | | 1239 | 175 | case IMAGE_FILE_MACHINE_AMD64: | 1240 | | #ifdef AMD64MAGIC | 1241 | | magic = AMD64MAGIC; | 1242 | | #endif | 1243 | 175 | break; | 1244 | | | 1245 | 5 | case IMAGE_FILE_MACHINE_R3000: | 1246 | 7 | case IMAGE_FILE_MACHINE_R4000: | 1247 | 10 | case IMAGE_FILE_MACHINE_R10000: | 1248 | | | 1249 | 11 | case IMAGE_FILE_MACHINE_MIPS16: | 1250 | 14 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1251 | 17 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1252 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1253 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1254 | | #endif | 1255 | 17 | break; | 1256 | | | 1257 | 155 | case IMAGE_FILE_MACHINE_SH3: | 1258 | 245 | case IMAGE_FILE_MACHINE_SH4: | 1259 | | #ifdef SH_ARCH_MAGIC_WINCE | 1260 | | magic = SH_ARCH_MAGIC_WINCE; | 1261 | | #endif | 1262 | 245 | break; | 1263 | | | 1264 | 144 | case IMAGE_FILE_MACHINE_ARM: | 1265 | 144 | #ifdef ARMPEMAGIC | 1266 | 144 | magic = ARMPEMAGIC; | 1267 | 144 | #endif | 1268 | 144 | break; | 1269 | | | 1270 | 186 | case IMAGE_FILE_MACHINE_ARM64: | 1271 | | #ifdef AARCH64MAGIC | 1272 | | magic = AARCH64MAGIC; | 1273 | | #endif | 1274 | 186 | break; | 1275 | | | 1276 | 204 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1277 | | #ifdef LOONGARCH64MAGIC | 1278 | | magic = LOONGARCH64MAGIC; | 1279 | | #endif | 1280 | 204 | break; | 1281 | | | 1282 | 170 | case IMAGE_FILE_MACHINE_RISCV64: | 1283 | | #ifdef RISCV64MAGIC | 1284 | | magic = RISCV64MAGIC; | 1285 | | #endif | 1286 | 170 | break; | 1287 | | | 1288 | 129 | case IMAGE_FILE_MACHINE_THUMB: | 1289 | 129 | #ifdef THUMBPEMAGIC | 1290 | 129 | { | 1291 | 129 | extern const bfd_target TARGET_LITTLE_SYM; | 1292 | | | 1293 | 129 | if (abfd->xvec == &TARGET_LITTLE_SYM) | 1294 | 128 | magic = THUMBPEMAGIC; | 1295 | 129 | } | 1296 | 129 | #endif | 1297 | 129 | break; | 1298 | | | 1299 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1300 | | /* We no longer support PowerPC. */ | 1301 | 475 | default: | 1302 | 475 | _bfd_error_handler | 1303 | | /* xgettext:c-format */ | 1304 | 475 | (_("%pB: unrecognised machine type (0x%x)" | 1305 | 475 | " in Import Library Format archive"), | 1306 | 475 | abfd, machine); | 1307 | 475 | bfd_set_error (bfd_error_malformed_archive); | 1308 | | | 1309 | 475 | return NULL; | 1310 | 0 | break; | 1311 | 1.94k | } | 1312 | | | 1313 | 1.46k | if (magic == 0) | 1314 | 1.19k | { | 1315 | 1.19k | _bfd_error_handler | 1316 | | /* xgettext:c-format */ | 1317 | 1.19k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1318 | 1.19k | " in Import Library Format archive"), | 1319 | 1.19k | abfd, machine); | 1320 | 1.19k | bfd_set_error (bfd_error_wrong_format); | 1321 | | | 1322 | 1.19k | return NULL; | 1323 | 1.19k | } | 1324 | | | 1325 | | /* We do not bother to check the date. | 1326 | | date = H_GET_32 (abfd, ptr); */ | 1327 | 272 | ptr += 4; | 1328 | | | 1329 | 272 | size = H_GET_32 (abfd, ptr); | 1330 | 272 | ptr += 4; | 1331 | | | 1332 | 272 | if (size == 0) | 1333 | 5 | { | 1334 | 5 | _bfd_error_handler | 1335 | 5 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1336 | 5 | bfd_set_error (bfd_error_malformed_archive); | 1337 | | | 1338 | 5 | return NULL; | 1339 | 5 | } | 1340 | | | 1341 | 267 | ordinal = H_GET_16 (abfd, ptr); | 1342 | 267 | ptr += 2; | 1343 | | | 1344 | 267 | types = H_GET_16 (abfd, ptr); | 1345 | | /* ptr += 2; */ | 1346 | | | 1347 | | /* Now read in the two strings that follow. */ | 1348 | 267 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1349 | 267 | if (ptr == NULL) | 1350 | 160 | return NULL; | 1351 | | | 1352 | 107 | symbol_name = (char *) ptr; | 1353 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1354 | 107 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1355 | | | 1356 | | /* Verify that the strings are null terminated. */ | 1357 | 107 | if (ptr[size - 1] != 0 | 1358 | 88 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1359 | 22 | { | 1360 | 22 | _bfd_error_handler | 1361 | 22 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1362 | 22 | bfd_set_error (bfd_error_malformed_archive); | 1363 | 22 | bfd_release (abfd, ptr); | 1364 | 22 | return NULL; | 1365 | 22 | } | 1366 | | | 1367 | | /* An ILF file may contain a third string, after source_dll; this is | 1368 | | used for IMPORT_NAME_EXPORTAS. We know from above that the whole | 1369 | | block of data is null terminated, ptr[size-1]==0, but we don't | 1370 | | know how many individual null terminated strings we have in there. | 1371 | | | 1372 | | First find the end of source_dll. */ | 1373 | 85 | import_name = source_dll + strlen (source_dll) + 1; | 1374 | 85 | if ((bfd_byte *) import_name >= ptr + size) | 1375 | 39 | { | 1376 | | /* If this points at the end of the ptr+size block, we only had | 1377 | | two strings. */ | 1378 | 39 | import_name = NULL; | 1379 | 39 | } | 1380 | | | 1381 | | /* Now construct the bfd. */ | 1382 | 85 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1383 | 85 | source_dll, ordinal, types, | 1384 | 85 | import_name)) | 1385 | 27 | { | 1386 | 27 | bfd_release (abfd, ptr); | 1387 | 27 | return NULL; | 1388 | 27 | } | 1389 | | | 1390 | 58 | return pe_ILF_cleanup; | 1391 | 85 | } |
pei-mcore.c:pe_ILF_object_p Line | Count | Source | 1200 | 1.98k | { | 1201 | 1.98k | bfd_byte buffer[14]; | 1202 | 1.98k | bfd_byte * ptr; | 1203 | 1.98k | char * symbol_name; | 1204 | 1.98k | char * source_dll; | 1205 | 1.98k | char * import_name; | 1206 | 1.98k | unsigned int machine; | 1207 | 1.98k | bfd_size_type size; | 1208 | 1.98k | unsigned int ordinal; | 1209 | 1.98k | unsigned int types; | 1210 | 1.98k | unsigned int magic; | 1211 | | | 1212 | | /* Upon entry the first six bytes of the ILF header have | 1213 | | already been read. Now read the rest of the header. */ | 1214 | 1.98k | if (bfd_read (buffer, 14, abfd) != 14) | 1215 | 43 | return NULL; | 1216 | | | 1217 | 1.93k | ptr = buffer; | 1218 | | | 1219 | 1.93k | machine = H_GET_16 (abfd, ptr); | 1220 | 1.93k | ptr += 2; | 1221 | | | 1222 | | /* Check that the machine type is recognised. */ | 1223 | 1.93k | magic = 0; | 1224 | | | 1225 | 1.93k | switch (machine) | 1226 | 1.93k | { | 1227 | 11 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1228 | 14 | case IMAGE_FILE_MACHINE_ALPHA: | 1229 | 17 | case IMAGE_FILE_MACHINE_ALPHA64: | 1230 | 20 | case IMAGE_FILE_MACHINE_IA64: | 1231 | 20 | break; | 1232 | | | 1233 | 175 | case IMAGE_FILE_MACHINE_I386: | 1234 | | #ifdef I386MAGIC | 1235 | | magic = I386MAGIC; | 1236 | | #endif | 1237 | 175 | break; | 1238 | | | 1239 | 175 | case IMAGE_FILE_MACHINE_AMD64: | 1240 | | #ifdef AMD64MAGIC | 1241 | | magic = AMD64MAGIC; | 1242 | | #endif | 1243 | 175 | break; | 1244 | | | 1245 | 5 | case IMAGE_FILE_MACHINE_R3000: | 1246 | 7 | case IMAGE_FILE_MACHINE_R4000: | 1247 | 10 | case IMAGE_FILE_MACHINE_R10000: | 1248 | | | 1249 | 11 | case IMAGE_FILE_MACHINE_MIPS16: | 1250 | 14 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1251 | 17 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1252 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1253 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1254 | | #endif | 1255 | 17 | break; | 1256 | | | 1257 | 155 | case IMAGE_FILE_MACHINE_SH3: | 1258 | 245 | case IMAGE_FILE_MACHINE_SH4: | 1259 | | #ifdef SH_ARCH_MAGIC_WINCE | 1260 | | magic = SH_ARCH_MAGIC_WINCE; | 1261 | | #endif | 1262 | 245 | break; | 1263 | | | 1264 | 142 | case IMAGE_FILE_MACHINE_ARM: | 1265 | | #ifdef ARMPEMAGIC | 1266 | | magic = ARMPEMAGIC; | 1267 | | #endif | 1268 | 142 | break; | 1269 | | | 1270 | 186 | case IMAGE_FILE_MACHINE_ARM64: | 1271 | | #ifdef AARCH64MAGIC | 1272 | | magic = AARCH64MAGIC; | 1273 | | #endif | 1274 | 186 | break; | 1275 | | | 1276 | 204 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1277 | | #ifdef LOONGARCH64MAGIC | 1278 | | magic = LOONGARCH64MAGIC; | 1279 | | #endif | 1280 | 204 | break; | 1281 | | | 1282 | 170 | case IMAGE_FILE_MACHINE_RISCV64: | 1283 | | #ifdef RISCV64MAGIC | 1284 | | magic = RISCV64MAGIC; | 1285 | | #endif | 1286 | 170 | break; | 1287 | | | 1288 | 129 | case IMAGE_FILE_MACHINE_THUMB: | 1289 | | #ifdef THUMBPEMAGIC | 1290 | | { | 1291 | | extern const bfd_target TARGET_LITTLE_SYM; | 1292 | | | 1293 | | if (abfd->xvec == &TARGET_LITTLE_SYM) | 1294 | | magic = THUMBPEMAGIC; | 1295 | | } | 1296 | | #endif | 1297 | 129 | break; | 1298 | | | 1299 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1300 | | /* We no longer support PowerPC. */ | 1301 | 475 | default: | 1302 | 475 | _bfd_error_handler | 1303 | | /* xgettext:c-format */ | 1304 | 475 | (_("%pB: unrecognised machine type (0x%x)" | 1305 | 475 | " in Import Library Format archive"), | 1306 | 475 | abfd, machine); | 1307 | 475 | bfd_set_error (bfd_error_malformed_archive); | 1308 | | | 1309 | 475 | return NULL; | 1310 | 0 | break; | 1311 | 1.93k | } | 1312 | | | 1313 | 1.46k | if (magic == 0) | 1314 | 1.46k | { | 1315 | 1.46k | _bfd_error_handler | 1316 | | /* xgettext:c-format */ | 1317 | 1.46k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1318 | 1.46k | " in Import Library Format archive"), | 1319 | 1.46k | abfd, machine); | 1320 | 1.46k | bfd_set_error (bfd_error_wrong_format); | 1321 | | | 1322 | 1.46k | return NULL; | 1323 | 1.46k | } | 1324 | | | 1325 | | /* We do not bother to check the date. | 1326 | | date = H_GET_32 (abfd, ptr); */ | 1327 | 0 | ptr += 4; | 1328 | |
| 1329 | 0 | size = H_GET_32 (abfd, ptr); | 1330 | 0 | ptr += 4; | 1331 | |
| 1332 | 0 | if (size == 0) | 1333 | 0 | { | 1334 | 0 | _bfd_error_handler | 1335 | 0 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1336 | 0 | bfd_set_error (bfd_error_malformed_archive); | 1337 | |
| 1338 | 0 | return NULL; | 1339 | 0 | } | 1340 | | | 1341 | 0 | ordinal = H_GET_16 (abfd, ptr); | 1342 | 0 | ptr += 2; | 1343 | |
| 1344 | 0 | types = H_GET_16 (abfd, ptr); | 1345 | | /* ptr += 2; */ | 1346 | | | 1347 | | /* Now read in the two strings that follow. */ | 1348 | 0 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1349 | 0 | if (ptr == NULL) | 1350 | 0 | return NULL; | 1351 | | | 1352 | 0 | symbol_name = (char *) ptr; | 1353 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1354 | 0 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1355 | | | 1356 | | /* Verify that the strings are null terminated. */ | 1357 | 0 | if (ptr[size - 1] != 0 | 1358 | 0 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1359 | 0 | { | 1360 | 0 | _bfd_error_handler | 1361 | 0 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1362 | 0 | bfd_set_error (bfd_error_malformed_archive); | 1363 | 0 | bfd_release (abfd, ptr); | 1364 | 0 | return NULL; | 1365 | 0 | } | 1366 | | | 1367 | | /* An ILF file may contain a third string, after source_dll; this is | 1368 | | used for IMPORT_NAME_EXPORTAS. We know from above that the whole | 1369 | | block of data is null terminated, ptr[size-1]==0, but we don't | 1370 | | know how many individual null terminated strings we have in there. | 1371 | | | 1372 | | First find the end of source_dll. */ | 1373 | 0 | import_name = source_dll + strlen (source_dll) + 1; | 1374 | 0 | if ((bfd_byte *) import_name >= ptr + size) | 1375 | 0 | { | 1376 | | /* If this points at the end of the ptr+size block, we only had | 1377 | | two strings. */ | 1378 | 0 | import_name = NULL; | 1379 | 0 | } | 1380 | | | 1381 | | /* Now construct the bfd. */ | 1382 | 0 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1383 | 0 | source_dll, ordinal, types, | 1384 | 0 | import_name)) | 1385 | 0 | { | 1386 | 0 | bfd_release (abfd, ptr); | 1387 | 0 | return NULL; | 1388 | 0 | } | 1389 | | | 1390 | 0 | return pe_ILF_cleanup; | 1391 | 0 | } |
Line | Count | Source | 1200 | 1.94k | { | 1201 | 1.94k | bfd_byte buffer[14]; | 1202 | 1.94k | bfd_byte * ptr; | 1203 | 1.94k | char * symbol_name; | 1204 | 1.94k | char * source_dll; | 1205 | 1.94k | char * import_name; | 1206 | 1.94k | unsigned int machine; | 1207 | 1.94k | bfd_size_type size; | 1208 | 1.94k | unsigned int ordinal; | 1209 | 1.94k | unsigned int types; | 1210 | 1.94k | unsigned int magic; | 1211 | | | 1212 | | /* Upon entry the first six bytes of the ILF header have | 1213 | | already been read. Now read the rest of the header. */ | 1214 | 1.94k | if (bfd_read (buffer, 14, abfd) != 14) | 1215 | 35 | return NULL; | 1216 | | | 1217 | 1.90k | ptr = buffer; | 1218 | | | 1219 | 1.90k | machine = H_GET_16 (abfd, ptr); | 1220 | 1.90k | ptr += 2; | 1221 | | | 1222 | | /* Check that the machine type is recognised. */ | 1223 | 1.90k | magic = 0; | 1224 | | | 1225 | 1.90k | switch (machine) | 1226 | 1.90k | { | 1227 | 11 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1228 | 14 | case IMAGE_FILE_MACHINE_ALPHA: | 1229 | 17 | case IMAGE_FILE_MACHINE_ALPHA64: | 1230 | 20 | case IMAGE_FILE_MACHINE_IA64: | 1231 | 20 | break; | 1232 | | | 1233 | 175 | case IMAGE_FILE_MACHINE_I386: | 1234 | | #ifdef I386MAGIC | 1235 | | magic = I386MAGIC; | 1236 | | #endif | 1237 | 175 | break; | 1238 | | | 1239 | 175 | case IMAGE_FILE_MACHINE_AMD64: | 1240 | | #ifdef AMD64MAGIC | 1241 | | magic = AMD64MAGIC; | 1242 | | #endif | 1243 | 175 | break; | 1244 | | | 1245 | 5 | case IMAGE_FILE_MACHINE_R3000: | 1246 | 7 | case IMAGE_FILE_MACHINE_R4000: | 1247 | 10 | case IMAGE_FILE_MACHINE_R10000: | 1248 | | | 1249 | 11 | case IMAGE_FILE_MACHINE_MIPS16: | 1250 | 14 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1251 | 17 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1252 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1253 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1254 | | #endif | 1255 | 17 | break; | 1256 | | | 1257 | 176 | case IMAGE_FILE_MACHINE_SH3: | 1258 | 281 | case IMAGE_FILE_MACHINE_SH4: | 1259 | 281 | #ifdef SH_ARCH_MAGIC_WINCE | 1260 | 281 | magic = SH_ARCH_MAGIC_WINCE; | 1261 | 281 | #endif | 1262 | 281 | break; | 1263 | | | 1264 | 101 | case IMAGE_FILE_MACHINE_ARM: | 1265 | | #ifdef ARMPEMAGIC | 1266 | | magic = ARMPEMAGIC; | 1267 | | #endif | 1268 | 101 | break; | 1269 | | | 1270 | 186 | case IMAGE_FILE_MACHINE_ARM64: | 1271 | | #ifdef AARCH64MAGIC | 1272 | | magic = AARCH64MAGIC; | 1273 | | #endif | 1274 | 186 | break; | 1275 | | | 1276 | 204 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1277 | | #ifdef LOONGARCH64MAGIC | 1278 | | magic = LOONGARCH64MAGIC; | 1279 | | #endif | 1280 | 204 | break; | 1281 | | | 1282 | 169 | case IMAGE_FILE_MACHINE_RISCV64: | 1283 | | #ifdef RISCV64MAGIC | 1284 | | magic = RISCV64MAGIC; | 1285 | | #endif | 1286 | 169 | break; | 1287 | | | 1288 | 128 | case IMAGE_FILE_MACHINE_THUMB: | 1289 | | #ifdef THUMBPEMAGIC | 1290 | | { | 1291 | | extern const bfd_target TARGET_LITTLE_SYM; | 1292 | | | 1293 | | if (abfd->xvec == &TARGET_LITTLE_SYM) | 1294 | | magic = THUMBPEMAGIC; | 1295 | | } | 1296 | | #endif | 1297 | 128 | break; | 1298 | | | 1299 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1300 | | /* We no longer support PowerPC. */ | 1301 | 452 | default: | 1302 | 452 | _bfd_error_handler | 1303 | | /* xgettext:c-format */ | 1304 | 452 | (_("%pB: unrecognised machine type (0x%x)" | 1305 | 452 | " in Import Library Format archive"), | 1306 | 452 | abfd, machine); | 1307 | 452 | bfd_set_error (bfd_error_malformed_archive); | 1308 | | | 1309 | 452 | return NULL; | 1310 | 0 | break; | 1311 | 1.90k | } | 1312 | | | 1313 | 1.45k | if (magic == 0) | 1314 | 1.17k | { | 1315 | 1.17k | _bfd_error_handler | 1316 | | /* xgettext:c-format */ | 1317 | 1.17k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1318 | 1.17k | " in Import Library Format archive"), | 1319 | 1.17k | abfd, machine); | 1320 | 1.17k | bfd_set_error (bfd_error_wrong_format); | 1321 | | | 1322 | 1.17k | return NULL; | 1323 | 1.17k | } | 1324 | | | 1325 | | /* We do not bother to check the date. | 1326 | | date = H_GET_32 (abfd, ptr); */ | 1327 | 281 | ptr += 4; | 1328 | | | 1329 | 281 | size = H_GET_32 (abfd, ptr); | 1330 | 281 | ptr += 4; | 1331 | | | 1332 | 281 | if (size == 0) | 1333 | 9 | { | 1334 | 9 | _bfd_error_handler | 1335 | 9 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1336 | 9 | bfd_set_error (bfd_error_malformed_archive); | 1337 | | | 1338 | 9 | return NULL; | 1339 | 9 | } | 1340 | | | 1341 | 272 | ordinal = H_GET_16 (abfd, ptr); | 1342 | 272 | ptr += 2; | 1343 | | | 1344 | 272 | types = H_GET_16 (abfd, ptr); | 1345 | | /* ptr += 2; */ | 1346 | | | 1347 | | /* Now read in the two strings that follow. */ | 1348 | 272 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1349 | 272 | if (ptr == NULL) | 1350 | 113 | return NULL; | 1351 | | | 1352 | 159 | symbol_name = (char *) ptr; | 1353 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1354 | 159 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1355 | | | 1356 | | /* Verify that the strings are null terminated. */ | 1357 | 159 | if (ptr[size - 1] != 0 | 1358 | 123 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1359 | 41 | { | 1360 | 41 | _bfd_error_handler | 1361 | 41 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1362 | 41 | bfd_set_error (bfd_error_malformed_archive); | 1363 | 41 | bfd_release (abfd, ptr); | 1364 | 41 | return NULL; | 1365 | 41 | } | 1366 | | | 1367 | | /* An ILF file may contain a third string, after source_dll; this is | 1368 | | used for IMPORT_NAME_EXPORTAS. We know from above that the whole | 1369 | | block of data is null terminated, ptr[size-1]==0, but we don't | 1370 | | know how many individual null terminated strings we have in there. | 1371 | | | 1372 | | First find the end of source_dll. */ | 1373 | 118 | import_name = source_dll + strlen (source_dll) + 1; | 1374 | 118 | if ((bfd_byte *) import_name >= ptr + size) | 1375 | 42 | { | 1376 | | /* If this points at the end of the ptr+size block, we only had | 1377 | | two strings. */ | 1378 | 42 | import_name = NULL; | 1379 | 42 | } | 1380 | | | 1381 | | /* Now construct the bfd. */ | 1382 | 118 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1383 | 118 | source_dll, ordinal, types, | 1384 | 118 | import_name)) | 1385 | 39 | { | 1386 | 39 | bfd_release (abfd, ptr); | 1387 | 39 | return NULL; | 1388 | 39 | } | 1389 | | | 1390 | 79 | return pe_ILF_cleanup; | 1391 | 118 | } |
|
1392 | | |
1393 | | static void |
1394 | | pe_bfd_read_buildid (bfd *abfd) |
1395 | 37.9k | { |
1396 | 37.9k | pe_data_type *pe = pe_data (abfd); |
1397 | 37.9k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; |
1398 | 37.9k | asection *section; |
1399 | 37.9k | bfd_byte *data = 0; |
1400 | 37.9k | bfd_size_type dataoff; |
1401 | 37.9k | unsigned int i; |
1402 | 37.9k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; |
1403 | 37.9k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; |
1404 | | |
1405 | 37.9k | if (size == 0) |
1406 | 22.3k | return; |
1407 | | |
1408 | 15.5k | addr += extra->ImageBase; |
1409 | | |
1410 | | /* Search for the section containing the DebugDirectory. */ |
1411 | 106k | for (section = abfd->sections; section != NULL; section = section->next) |
1412 | 99.3k | { |
1413 | 99.3k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) |
1414 | 7.95k | break; |
1415 | 99.3k | } |
1416 | | |
1417 | 15.5k | if (section == NULL) |
1418 | 7.62k | return; |
1419 | | |
1420 | 7.95k | if (!(section->flags & SEC_HAS_CONTENTS)) |
1421 | 323 | return; |
1422 | | |
1423 | 7.63k | dataoff = addr - section->vma; |
1424 | | |
1425 | | /* PR 20605 and 22373: Make sure that the data is really there. |
1426 | | Note - since we are dealing with unsigned quantities we have |
1427 | | to be careful to check for potential overflows. */ |
1428 | 7.63k | if (dataoff >= section->size |
1429 | 7.63k | || size > section->size - dataoff) |
1430 | 2.68k | { |
1431 | 2.68k | _bfd_error_handler |
1432 | 2.68k | (_("%pB: error: debug data ends beyond end of debug directory"), |
1433 | 2.68k | abfd); |
1434 | 2.68k | return; |
1435 | 2.68k | } |
1436 | | |
1437 | | /* Read the whole section. */ |
1438 | 4.94k | if (!bfd_malloc_and_get_section (abfd, section, &data)) |
1439 | 1.48k | { |
1440 | 1.48k | free (data); |
1441 | 1.48k | return; |
1442 | 1.48k | } |
1443 | | |
1444 | | /* Search for a CodeView entry in the DebugDirectory */ |
1445 | 237k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) |
1446 | 235k | { |
1447 | 235k | struct external_IMAGE_DEBUG_DIRECTORY *ext |
1448 | 235k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; |
1449 | 235k | struct internal_IMAGE_DEBUG_DIRECTORY idd; |
1450 | | |
1451 | 235k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); |
1452 | | |
1453 | 235k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) |
1454 | 1.44k | { |
1455 | 1.44k | char buffer[256 + 1]; |
1456 | 1.44k | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; |
1457 | | |
1458 | | /* |
1459 | | The debug entry doesn't have to have to be in a section, in which |
1460 | | case AddressOfRawData is 0, so always use PointerToRawData. |
1461 | | */ |
1462 | 1.44k | if (_bfd_XXi_slurp_codeview_record (abfd, |
1463 | 1.44k | (file_ptr) idd.PointerToRawData, |
1464 | 1.44k | idd.SizeOfData, cvinfo, NULL)) |
1465 | 107 | { |
1466 | 107 | struct bfd_build_id *build_id; |
1467 | 107 | size_t bidlen = sizeof (*build_id) + cvinfo->SignatureLength; |
1468 | | |
1469 | 107 | build_id = bfd_alloc (abfd, bidlen); |
1470 | 107 | if (build_id) |
1471 | 107 | { |
1472 | 107 | build_id->size = cvinfo->SignatureLength; |
1473 | 107 | memcpy(build_id->data, cvinfo->Signature, |
1474 | 107 | cvinfo->SignatureLength); |
1475 | 107 | abfd->build_id = build_id; |
1476 | 107 | } |
1477 | 107 | } |
1478 | 1.44k | break; |
1479 | 1.44k | } |
1480 | 235k | } |
1481 | | |
1482 | 3.45k | free (data); |
1483 | 3.45k | } pei-i386.c:pe_bfd_read_buildid Line | Count | Source | 1395 | 8.21k | { | 1396 | 8.21k | pe_data_type *pe = pe_data (abfd); | 1397 | 8.21k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1398 | 8.21k | asection *section; | 1399 | 8.21k | bfd_byte *data = 0; | 1400 | 8.21k | bfd_size_type dataoff; | 1401 | 8.21k | unsigned int i; | 1402 | 8.21k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1403 | 8.21k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1404 | | | 1405 | 8.21k | if (size == 0) | 1406 | 6.36k | return; | 1407 | | | 1408 | 1.84k | addr += extra->ImageBase; | 1409 | | | 1410 | | /* Search for the section containing the DebugDirectory. */ | 1411 | 11.3k | for (section = abfd->sections; section != NULL; section = section->next) | 1412 | 10.3k | { | 1413 | 10.3k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1414 | 855 | break; | 1415 | 10.3k | } | 1416 | | | 1417 | 1.84k | if (section == NULL) | 1418 | 993 | return; | 1419 | | | 1420 | 855 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1421 | 50 | return; | 1422 | | | 1423 | 805 | dataoff = addr - section->vma; | 1424 | | | 1425 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1426 | | Note - since we are dealing with unsigned quantities we have | 1427 | | to be careful to check for potential overflows. */ | 1428 | 805 | if (dataoff >= section->size | 1429 | 805 | || size > section->size - dataoff) | 1430 | 335 | { | 1431 | 335 | _bfd_error_handler | 1432 | 335 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1433 | 335 | abfd); | 1434 | 335 | return; | 1435 | 335 | } | 1436 | | | 1437 | | /* Read the whole section. */ | 1438 | 470 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1439 | 174 | { | 1440 | 174 | free (data); | 1441 | 174 | return; | 1442 | 174 | } | 1443 | | | 1444 | | /* Search for a CodeView entry in the DebugDirectory */ | 1445 | 7.29k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1446 | 7.16k | { | 1447 | 7.16k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1448 | 7.16k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1449 | 7.16k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1450 | | | 1451 | 7.16k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1452 | | | 1453 | 7.16k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1454 | 166 | { | 1455 | 166 | char buffer[256 + 1]; | 1456 | 166 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1457 | | | 1458 | | /* | 1459 | | The debug entry doesn't have to have to be in a section, in which | 1460 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1461 | | */ | 1462 | 166 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1463 | 166 | (file_ptr) idd.PointerToRawData, | 1464 | 166 | idd.SizeOfData, cvinfo, NULL)) | 1465 | 14 | { | 1466 | 14 | struct bfd_build_id *build_id; | 1467 | 14 | size_t bidlen = sizeof (*build_id) + cvinfo->SignatureLength; | 1468 | | | 1469 | 14 | build_id = bfd_alloc (abfd, bidlen); | 1470 | 14 | if (build_id) | 1471 | 14 | { | 1472 | 14 | build_id->size = cvinfo->SignatureLength; | 1473 | 14 | memcpy(build_id->data, cvinfo->Signature, | 1474 | 14 | cvinfo->SignatureLength); | 1475 | 14 | abfd->build_id = build_id; | 1476 | 14 | } | 1477 | 14 | } | 1478 | 166 | break; | 1479 | 166 | } | 1480 | 7.16k | } | 1481 | | | 1482 | 296 | free (data); | 1483 | 296 | } |
pei-x86_64.c:pe_bfd_read_buildid Line | Count | Source | 1395 | 5.23k | { | 1396 | 5.23k | pe_data_type *pe = pe_data (abfd); | 1397 | 5.23k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1398 | 5.23k | asection *section; | 1399 | 5.23k | bfd_byte *data = 0; | 1400 | 5.23k | bfd_size_type dataoff; | 1401 | 5.23k | unsigned int i; | 1402 | 5.23k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1403 | 5.23k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1404 | | | 1405 | 5.23k | if (size == 0) | 1406 | 3.50k | return; | 1407 | | | 1408 | 1.72k | addr += extra->ImageBase; | 1409 | | | 1410 | | /* Search for the section containing the DebugDirectory. */ | 1411 | 17.5k | for (section = abfd->sections; section != NULL; section = section->next) | 1412 | 16.5k | { | 1413 | 16.5k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1414 | 783 | break; | 1415 | 16.5k | } | 1416 | | | 1417 | 1.72k | if (section == NULL) | 1418 | 942 | return; | 1419 | | | 1420 | 783 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1421 | 30 | return; | 1422 | | | 1423 | 753 | dataoff = addr - section->vma; | 1424 | | | 1425 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1426 | | Note - since we are dealing with unsigned quantities we have | 1427 | | to be careful to check for potential overflows. */ | 1428 | 753 | if (dataoff >= section->size | 1429 | 753 | || size > section->size - dataoff) | 1430 | 195 | { | 1431 | 195 | _bfd_error_handler | 1432 | 195 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1433 | 195 | abfd); | 1434 | 195 | return; | 1435 | 195 | } | 1436 | | | 1437 | | /* Read the whole section. */ | 1438 | 558 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1439 | 177 | { | 1440 | 177 | free (data); | 1441 | 177 | return; | 1442 | 177 | } | 1443 | | | 1444 | | /* Search for a CodeView entry in the DebugDirectory */ | 1445 | 10.6k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1446 | 10.5k | { | 1447 | 10.5k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1448 | 10.5k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1449 | 10.5k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1450 | | | 1451 | 10.5k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1452 | | | 1453 | 10.5k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1454 | 286 | { | 1455 | 286 | char buffer[256 + 1]; | 1456 | 286 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1457 | | | 1458 | | /* | 1459 | | The debug entry doesn't have to have to be in a section, in which | 1460 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1461 | | */ | 1462 | 286 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1463 | 286 | (file_ptr) idd.PointerToRawData, | 1464 | 286 | idd.SizeOfData, cvinfo, NULL)) | 1465 | 32 | { | 1466 | 32 | struct bfd_build_id *build_id; | 1467 | 32 | size_t bidlen = sizeof (*build_id) + cvinfo->SignatureLength; | 1468 | | | 1469 | 32 | build_id = bfd_alloc (abfd, bidlen); | 1470 | 32 | if (build_id) | 1471 | 32 | { | 1472 | 32 | build_id->size = cvinfo->SignatureLength; | 1473 | 32 | memcpy(build_id->data, cvinfo->Signature, | 1474 | 32 | cvinfo->SignatureLength); | 1475 | 32 | abfd->build_id = build_id; | 1476 | 32 | } | 1477 | 32 | } | 1478 | 286 | break; | 1479 | 286 | } | 1480 | 10.5k | } | 1481 | | | 1482 | 381 | free (data); | 1483 | 381 | } |
pei-aarch64.c:pe_bfd_read_buildid Line | Count | Source | 1395 | 4.75k | { | 1396 | 4.75k | pe_data_type *pe = pe_data (abfd); | 1397 | 4.75k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1398 | 4.75k | asection *section; | 1399 | 4.75k | bfd_byte *data = 0; | 1400 | 4.75k | bfd_size_type dataoff; | 1401 | 4.75k | unsigned int i; | 1402 | 4.75k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1403 | 4.75k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1404 | | | 1405 | 4.75k | if (size == 0) | 1406 | 1.67k | return; | 1407 | | | 1408 | 3.08k | addr += extra->ImageBase; | 1409 | | | 1410 | | /* Search for the section containing the DebugDirectory. */ | 1411 | 18.8k | for (section = abfd->sections; section != NULL; section = section->next) | 1412 | 18.0k | { | 1413 | 18.0k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1414 | 2.21k | break; | 1415 | 18.0k | } | 1416 | | | 1417 | 3.08k | if (section == NULL) | 1418 | 872 | return; | 1419 | | | 1420 | 2.21k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1421 | 23 | return; | 1422 | | | 1423 | 2.19k | dataoff = addr - section->vma; | 1424 | | | 1425 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1426 | | Note - since we are dealing with unsigned quantities we have | 1427 | | to be careful to check for potential overflows. */ | 1428 | 2.19k | if (dataoff >= section->size | 1429 | 2.19k | || size > section->size - dataoff) | 1430 | 284 | { | 1431 | 284 | _bfd_error_handler | 1432 | 284 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1433 | 284 | abfd); | 1434 | 284 | return; | 1435 | 284 | } | 1436 | | | 1437 | | /* Read the whole section. */ | 1438 | 1.90k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1439 | 273 | { | 1440 | 273 | free (data); | 1441 | 273 | return; | 1442 | 273 | } | 1443 | | | 1444 | | /* Search for a CodeView entry in the DebugDirectory */ | 1445 | 192k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1446 | 191k | { | 1447 | 191k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1448 | 191k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1449 | 191k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1450 | | | 1451 | 191k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1452 | | | 1453 | 191k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1454 | 407 | { | 1455 | 407 | char buffer[256 + 1]; | 1456 | 407 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1457 | | | 1458 | | /* | 1459 | | The debug entry doesn't have to have to be in a section, in which | 1460 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1461 | | */ | 1462 | 407 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1463 | 407 | (file_ptr) idd.PointerToRawData, | 1464 | 407 | idd.SizeOfData, cvinfo, NULL)) | 1465 | 7 | { | 1466 | 7 | struct bfd_build_id *build_id; | 1467 | 7 | size_t bidlen = sizeof (*build_id) + cvinfo->SignatureLength; | 1468 | | | 1469 | 7 | build_id = bfd_alloc (abfd, bidlen); | 1470 | 7 | if (build_id) | 1471 | 7 | { | 1472 | 7 | build_id->size = cvinfo->SignatureLength; | 1473 | 7 | memcpy(build_id->data, cvinfo->Signature, | 1474 | 7 | cvinfo->SignatureLength); | 1475 | 7 | abfd->build_id = build_id; | 1476 | 7 | } | 1477 | 7 | } | 1478 | 407 | break; | 1479 | 407 | } | 1480 | 191k | } | 1481 | | | 1482 | 1.63k | free (data); | 1483 | 1.63k | } |
pei-ia64.c:pe_bfd_read_buildid Line | Count | Source | 1395 | 2.99k | { | 1396 | 2.99k | pe_data_type *pe = pe_data (abfd); | 1397 | 2.99k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1398 | 2.99k | asection *section; | 1399 | 2.99k | bfd_byte *data = 0; | 1400 | 2.99k | bfd_size_type dataoff; | 1401 | 2.99k | unsigned int i; | 1402 | 2.99k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1403 | 2.99k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1404 | | | 1405 | 2.99k | if (size == 0) | 1406 | 2.20k | return; | 1407 | | | 1408 | 787 | addr += extra->ImageBase; | 1409 | | | 1410 | | /* Search for the section containing the DebugDirectory. */ | 1411 | 4.62k | for (section = abfd->sections; section != NULL; section = section->next) | 1412 | 4.14k | { | 1413 | 4.14k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1414 | 299 | break; | 1415 | 4.14k | } | 1416 | | | 1417 | 787 | if (section == NULL) | 1418 | 488 | return; | 1419 | | | 1420 | 299 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1421 | 16 | return; | 1422 | | | 1423 | 283 | dataoff = addr - section->vma; | 1424 | | | 1425 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1426 | | Note - since we are dealing with unsigned quantities we have | 1427 | | to be careful to check for potential overflows. */ | 1428 | 283 | if (dataoff >= section->size | 1429 | 283 | || size > section->size - dataoff) | 1430 | 80 | { | 1431 | 80 | _bfd_error_handler | 1432 | 80 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1433 | 80 | abfd); | 1434 | 80 | return; | 1435 | 80 | } | 1436 | | | 1437 | | /* Read the whole section. */ | 1438 | 203 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1439 | 48 | { | 1440 | 48 | free (data); | 1441 | 48 | return; | 1442 | 48 | } | 1443 | | | 1444 | | /* Search for a CodeView entry in the DebugDirectory */ | 1445 | 4.02k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1446 | 3.98k | { | 1447 | 3.98k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1448 | 3.98k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1449 | 3.98k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1450 | | | 1451 | 3.98k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1452 | | | 1453 | 3.98k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1454 | 114 | { | 1455 | 114 | char buffer[256 + 1]; | 1456 | 114 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1457 | | | 1458 | | /* | 1459 | | The debug entry doesn't have to have to be in a section, in which | 1460 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1461 | | */ | 1462 | 114 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1463 | 114 | (file_ptr) idd.PointerToRawData, | 1464 | 114 | idd.SizeOfData, cvinfo, NULL)) | 1465 | 1 | { | 1466 | 1 | struct bfd_build_id *build_id; | 1467 | 1 | size_t bidlen = sizeof (*build_id) + cvinfo->SignatureLength; | 1468 | | | 1469 | 1 | build_id = bfd_alloc (abfd, bidlen); | 1470 | 1 | if (build_id) | 1471 | 1 | { | 1472 | 1 | build_id->size = cvinfo->SignatureLength; | 1473 | 1 | memcpy(build_id->data, cvinfo->Signature, | 1474 | 1 | cvinfo->SignatureLength); | 1475 | 1 | abfd->build_id = build_id; | 1476 | 1 | } | 1477 | 1 | } | 1478 | 114 | break; | 1479 | 114 | } | 1480 | 3.98k | } | 1481 | | | 1482 | 155 | free (data); | 1483 | 155 | } |
pei-loongarch64.c:pe_bfd_read_buildid Line | Count | Source | 1395 | 3.45k | { | 1396 | 3.45k | pe_data_type *pe = pe_data (abfd); | 1397 | 3.45k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1398 | 3.45k | asection *section; | 1399 | 3.45k | bfd_byte *data = 0; | 1400 | 3.45k | bfd_size_type dataoff; | 1401 | 3.45k | unsigned int i; | 1402 | 3.45k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1403 | 3.45k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1404 | | | 1405 | 3.45k | if (size == 0) | 1406 | 1.83k | return; | 1407 | | | 1408 | 1.61k | addr += extra->ImageBase; | 1409 | | | 1410 | | /* Search for the section containing the DebugDirectory. */ | 1411 | 12.3k | for (section = abfd->sections; section != NULL; section = section->next) | 1412 | 11.3k | { | 1413 | 11.3k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1414 | 687 | break; | 1415 | 11.3k | } | 1416 | | | 1417 | 1.61k | if (section == NULL) | 1418 | 925 | return; | 1419 | | | 1420 | 687 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1421 | 24 | return; | 1422 | | | 1423 | 663 | dataoff = addr - section->vma; | 1424 | | | 1425 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1426 | | Note - since we are dealing with unsigned quantities we have | 1427 | | to be careful to check for potential overflows. */ | 1428 | 663 | if (dataoff >= section->size | 1429 | 663 | || size > section->size - dataoff) | 1430 | 314 | { | 1431 | 314 | _bfd_error_handler | 1432 | 314 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1433 | 314 | abfd); | 1434 | 314 | return; | 1435 | 314 | } | 1436 | | | 1437 | | /* Read the whole section. */ | 1438 | 349 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1439 | 119 | { | 1440 | 119 | free (data); | 1441 | 119 | return; | 1442 | 119 | } | 1443 | | | 1444 | | /* Search for a CodeView entry in the DebugDirectory */ | 1445 | 6.94k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1446 | 6.83k | { | 1447 | 6.83k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1448 | 6.83k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1449 | 6.83k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1450 | | | 1451 | 6.83k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1452 | | | 1453 | 6.83k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1454 | 126 | { | 1455 | 126 | char buffer[256 + 1]; | 1456 | 126 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1457 | | | 1458 | | /* | 1459 | | The debug entry doesn't have to have to be in a section, in which | 1460 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1461 | | */ | 1462 | 126 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1463 | 126 | (file_ptr) idd.PointerToRawData, | 1464 | 126 | idd.SizeOfData, cvinfo, NULL)) | 1465 | 6 | { | 1466 | 6 | struct bfd_build_id *build_id; | 1467 | 6 | size_t bidlen = sizeof (*build_id) + cvinfo->SignatureLength; | 1468 | | | 1469 | 6 | build_id = bfd_alloc (abfd, bidlen); | 1470 | 6 | if (build_id) | 1471 | 6 | { | 1472 | 6 | build_id->size = cvinfo->SignatureLength; | 1473 | 6 | memcpy(build_id->data, cvinfo->Signature, | 1474 | 6 | cvinfo->SignatureLength); | 1475 | 6 | abfd->build_id = build_id; | 1476 | 6 | } | 1477 | 6 | } | 1478 | 126 | break; | 1479 | 126 | } | 1480 | 6.83k | } | 1481 | | | 1482 | 230 | free (data); | 1483 | 230 | } |
pei-riscv64.c:pe_bfd_read_buildid Line | Count | Source | 1395 | 3.12k | { | 1396 | 3.12k | pe_data_type *pe = pe_data (abfd); | 1397 | 3.12k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1398 | 3.12k | asection *section; | 1399 | 3.12k | bfd_byte *data = 0; | 1400 | 3.12k | bfd_size_type dataoff; | 1401 | 3.12k | unsigned int i; | 1402 | 3.12k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1403 | 3.12k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1404 | | | 1405 | 3.12k | if (size == 0) | 1406 | 1.64k | return; | 1407 | | | 1408 | 1.47k | addr += extra->ImageBase; | 1409 | | | 1410 | | /* Search for the section containing the DebugDirectory. */ | 1411 | 13.8k | for (section = abfd->sections; section != NULL; section = section->next) | 1412 | 12.8k | { | 1413 | 12.8k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1414 | 519 | break; | 1415 | 12.8k | } | 1416 | | | 1417 | 1.47k | if (section == NULL) | 1418 | 960 | return; | 1419 | | | 1420 | 519 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1421 | 37 | return; | 1422 | | | 1423 | 482 | dataoff = addr - section->vma; | 1424 | | | 1425 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1426 | | Note - since we are dealing with unsigned quantities we have | 1427 | | to be careful to check for potential overflows. */ | 1428 | 482 | if (dataoff >= section->size | 1429 | 482 | || size > section->size - dataoff) | 1430 | 223 | { | 1431 | 223 | _bfd_error_handler | 1432 | 223 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1433 | 223 | abfd); | 1434 | 223 | return; | 1435 | 223 | } | 1436 | | | 1437 | | /* Read the whole section. */ | 1438 | 259 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1439 | 115 | { | 1440 | 115 | free (data); | 1441 | 115 | return; | 1442 | 115 | } | 1443 | | | 1444 | | /* Search for a CodeView entry in the DebugDirectory */ | 1445 | 1.53k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1446 | 1.48k | { | 1447 | 1.48k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1448 | 1.48k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1449 | 1.48k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1450 | | | 1451 | 1.48k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1452 | | | 1453 | 1.48k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1454 | 96 | { | 1455 | 96 | char buffer[256 + 1]; | 1456 | 96 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1457 | | | 1458 | | /* | 1459 | | The debug entry doesn't have to have to be in a section, in which | 1460 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1461 | | */ | 1462 | 96 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1463 | 96 | (file_ptr) idd.PointerToRawData, | 1464 | 96 | idd.SizeOfData, cvinfo, NULL)) | 1465 | 5 | { | 1466 | 5 | struct bfd_build_id *build_id; | 1467 | 5 | size_t bidlen = sizeof (*build_id) + cvinfo->SignatureLength; | 1468 | | | 1469 | 5 | build_id = bfd_alloc (abfd, bidlen); | 1470 | 5 | if (build_id) | 1471 | 5 | { | 1472 | 5 | build_id->size = cvinfo->SignatureLength; | 1473 | 5 | memcpy(build_id->data, cvinfo->Signature, | 1474 | 5 | cvinfo->SignatureLength); | 1475 | 5 | abfd->build_id = build_id; | 1476 | 5 | } | 1477 | 5 | } | 1478 | 96 | break; | 1479 | 96 | } | 1480 | 1.48k | } | 1481 | | | 1482 | 144 | free (data); | 1483 | 144 | } |
pei-arm-wince.c:pe_bfd_read_buildid Line | Count | Source | 1395 | 2.07k | { | 1396 | 2.07k | pe_data_type *pe = pe_data (abfd); | 1397 | 2.07k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1398 | 2.07k | asection *section; | 1399 | 2.07k | bfd_byte *data = 0; | 1400 | 2.07k | bfd_size_type dataoff; | 1401 | 2.07k | unsigned int i; | 1402 | 2.07k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1403 | 2.07k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1404 | | | 1405 | 2.07k | if (size == 0) | 1406 | 761 | return; | 1407 | | | 1408 | 1.31k | addr += extra->ImageBase; | 1409 | | | 1410 | | /* Search for the section containing the DebugDirectory. */ | 1411 | 4.78k | for (section = abfd->sections; section != NULL; section = section->next) | 1412 | 4.13k | { | 1413 | 4.13k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1414 | 667 | break; | 1415 | 4.13k | } | 1416 | | | 1417 | 1.31k | if (section == NULL) | 1418 | 647 | return; | 1419 | | | 1420 | 667 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1421 | 29 | return; | 1422 | | | 1423 | 638 | dataoff = addr - section->vma; | 1424 | | | 1425 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1426 | | Note - since we are dealing with unsigned quantities we have | 1427 | | to be careful to check for potential overflows. */ | 1428 | 638 | if (dataoff >= section->size | 1429 | 638 | || size > section->size - dataoff) | 1430 | 382 | { | 1431 | 382 | _bfd_error_handler | 1432 | 382 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1433 | 382 | abfd); | 1434 | 382 | return; | 1435 | 382 | } | 1436 | | | 1437 | | /* Read the whole section. */ | 1438 | 256 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1439 | 144 | { | 1440 | 144 | free (data); | 1441 | 144 | return; | 1442 | 144 | } | 1443 | | | 1444 | | /* Search for a CodeView entry in the DebugDirectory */ | 1445 | 1.91k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1446 | 1.85k | { | 1447 | 1.85k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1448 | 1.85k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1449 | 1.85k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1450 | | | 1451 | 1.85k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1452 | | | 1453 | 1.85k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1454 | 51 | { | 1455 | 51 | char buffer[256 + 1]; | 1456 | 51 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1457 | | | 1458 | | /* | 1459 | | The debug entry doesn't have to have to be in a section, in which | 1460 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1461 | | */ | 1462 | 51 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1463 | 51 | (file_ptr) idd.PointerToRawData, | 1464 | 51 | idd.SizeOfData, cvinfo, NULL)) | 1465 | 4 | { | 1466 | 4 | struct bfd_build_id *build_id; | 1467 | 4 | size_t bidlen = sizeof (*build_id) + cvinfo->SignatureLength; | 1468 | | | 1469 | 4 | build_id = bfd_alloc (abfd, bidlen); | 1470 | 4 | if (build_id) | 1471 | 4 | { | 1472 | 4 | build_id->size = cvinfo->SignatureLength; | 1473 | 4 | memcpy(build_id->data, cvinfo->Signature, | 1474 | 4 | cvinfo->SignatureLength); | 1475 | 4 | abfd->build_id = build_id; | 1476 | 4 | } | 1477 | 4 | } | 1478 | 51 | break; | 1479 | 51 | } | 1480 | 1.85k | } | 1481 | | | 1482 | 112 | free (data); | 1483 | 112 | } |
pei-arm.c:pe_bfd_read_buildid Line | Count | Source | 1395 | 2.72k | { | 1396 | 2.72k | pe_data_type *pe = pe_data (abfd); | 1397 | 2.72k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1398 | 2.72k | asection *section; | 1399 | 2.72k | bfd_byte *data = 0; | 1400 | 2.72k | bfd_size_type dataoff; | 1401 | 2.72k | unsigned int i; | 1402 | 2.72k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1403 | 2.72k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1404 | | | 1405 | 2.72k | if (size == 0) | 1406 | 1.37k | return; | 1407 | | | 1408 | 1.35k | addr += extra->ImageBase; | 1409 | | | 1410 | | /* Search for the section containing the DebugDirectory. */ | 1411 | 9.07k | for (section = abfd->sections; section != NULL; section = section->next) | 1412 | 8.47k | { | 1413 | 8.47k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1414 | 741 | break; | 1415 | 8.47k | } | 1416 | | | 1417 | 1.35k | if (section == NULL) | 1418 | 609 | return; | 1419 | | | 1420 | 741 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1421 | 37 | return; | 1422 | | | 1423 | 704 | dataoff = addr - section->vma; | 1424 | | | 1425 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1426 | | Note - since we are dealing with unsigned quantities we have | 1427 | | to be careful to check for potential overflows. */ | 1428 | 704 | if (dataoff >= section->size | 1429 | 704 | || size > section->size - dataoff) | 1430 | 308 | { | 1431 | 308 | _bfd_error_handler | 1432 | 308 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1433 | 308 | abfd); | 1434 | 308 | return; | 1435 | 308 | } | 1436 | | | 1437 | | /* Read the whole section. */ | 1438 | 396 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1439 | 158 | { | 1440 | 158 | free (data); | 1441 | 158 | return; | 1442 | 158 | } | 1443 | | | 1444 | | /* Search for a CodeView entry in the DebugDirectory */ | 1445 | 4.03k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1446 | 3.87k | { | 1447 | 3.87k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1448 | 3.87k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1449 | 3.87k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1450 | | | 1451 | 3.87k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1452 | | | 1453 | 3.87k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1454 | 81 | { | 1455 | 81 | char buffer[256 + 1]; | 1456 | 81 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1457 | | | 1458 | | /* | 1459 | | The debug entry doesn't have to have to be in a section, in which | 1460 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1461 | | */ | 1462 | 81 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1463 | 81 | (file_ptr) idd.PointerToRawData, | 1464 | 81 | idd.SizeOfData, cvinfo, NULL)) | 1465 | 31 | { | 1466 | 31 | struct bfd_build_id *build_id; | 1467 | 31 | size_t bidlen = sizeof (*build_id) + cvinfo->SignatureLength; | 1468 | | | 1469 | 31 | build_id = bfd_alloc (abfd, bidlen); | 1470 | 31 | if (build_id) | 1471 | 31 | { | 1472 | 31 | build_id->size = cvinfo->SignatureLength; | 1473 | 31 | memcpy(build_id->data, cvinfo->Signature, | 1474 | 31 | cvinfo->SignatureLength); | 1475 | 31 | abfd->build_id = build_id; | 1476 | 31 | } | 1477 | 31 | } | 1478 | 81 | break; | 1479 | 81 | } | 1480 | 3.87k | } | 1481 | | | 1482 | 238 | free (data); | 1483 | 238 | } |
pei-mcore.c:pe_bfd_read_buildid Line | Count | Source | 1395 | 2.74k | { | 1396 | 2.74k | pe_data_type *pe = pe_data (abfd); | 1397 | 2.74k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1398 | 2.74k | asection *section; | 1399 | 2.74k | bfd_byte *data = 0; | 1400 | 2.74k | bfd_size_type dataoff; | 1401 | 2.74k | unsigned int i; | 1402 | 2.74k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1403 | 2.74k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1404 | | | 1405 | 2.74k | if (size == 0) | 1406 | 1.53k | return; | 1407 | | | 1408 | 1.20k | addr += extra->ImageBase; | 1409 | | | 1410 | | /* Search for the section containing the DebugDirectory. */ | 1411 | 8.19k | for (section = abfd->sections; section != NULL; section = section->next) | 1412 | 7.62k | { | 1413 | 7.62k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1414 | 641 | break; | 1415 | 7.62k | } | 1416 | | | 1417 | 1.20k | if (section == NULL) | 1418 | 568 | return; | 1419 | | | 1420 | 641 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1421 | 40 | return; | 1422 | | | 1423 | 601 | dataoff = addr - section->vma; | 1424 | | | 1425 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1426 | | Note - since we are dealing with unsigned quantities we have | 1427 | | to be careful to check for potential overflows. */ | 1428 | 601 | if (dataoff >= section->size | 1429 | 601 | || size > section->size - dataoff) | 1430 | 312 | { | 1431 | 312 | _bfd_error_handler | 1432 | 312 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1433 | 312 | abfd); | 1434 | 312 | return; | 1435 | 312 | } | 1436 | | | 1437 | | /* Read the whole section. */ | 1438 | 289 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1439 | 173 | { | 1440 | 173 | free (data); | 1441 | 173 | return; | 1442 | 173 | } | 1443 | | | 1444 | | /* Search for a CodeView entry in the DebugDirectory */ | 1445 | 3.45k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1446 | 3.39k | { | 1447 | 3.39k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1448 | 3.39k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1449 | 3.39k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1450 | | | 1451 | 3.39k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1452 | | | 1453 | 3.39k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1454 | 55 | { | 1455 | 55 | char buffer[256 + 1]; | 1456 | 55 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1457 | | | 1458 | | /* | 1459 | | The debug entry doesn't have to have to be in a section, in which | 1460 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1461 | | */ | 1462 | 55 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1463 | 55 | (file_ptr) idd.PointerToRawData, | 1464 | 55 | idd.SizeOfData, cvinfo, NULL)) | 1465 | 3 | { | 1466 | 3 | struct bfd_build_id *build_id; | 1467 | 3 | size_t bidlen = sizeof (*build_id) + cvinfo->SignatureLength; | 1468 | | | 1469 | 3 | build_id = bfd_alloc (abfd, bidlen); | 1470 | 3 | if (build_id) | 1471 | 3 | { | 1472 | 3 | build_id->size = cvinfo->SignatureLength; | 1473 | 3 | memcpy(build_id->data, cvinfo->Signature, | 1474 | 3 | cvinfo->SignatureLength); | 1475 | 3 | abfd->build_id = build_id; | 1476 | 3 | } | 1477 | 3 | } | 1478 | 55 | break; | 1479 | 55 | } | 1480 | 3.39k | } | 1481 | | | 1482 | 116 | free (data); | 1483 | 116 | } |
pei-sh.c:pe_bfd_read_buildid Line | Count | Source | 1395 | 2.64k | { | 1396 | 2.64k | pe_data_type *pe = pe_data (abfd); | 1397 | 2.64k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1398 | 2.64k | asection *section; | 1399 | 2.64k | bfd_byte *data = 0; | 1400 | 2.64k | bfd_size_type dataoff; | 1401 | 2.64k | unsigned int i; | 1402 | 2.64k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1403 | 2.64k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1404 | | | 1405 | 2.64k | if (size == 0) | 1406 | 1.48k | return; | 1407 | | | 1408 | 1.16k | addr += extra->ImageBase; | 1409 | | | 1410 | | /* Search for the section containing the DebugDirectory. */ | 1411 | 6.39k | for (section = abfd->sections; section != NULL; section = section->next) | 1412 | 5.77k | { | 1413 | 5.77k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1414 | 547 | break; | 1415 | 5.77k | } | 1416 | | | 1417 | 1.16k | if (section == NULL) | 1418 | 616 | return; | 1419 | | | 1420 | 547 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1421 | 37 | return; | 1422 | | | 1423 | 510 | dataoff = addr - section->vma; | 1424 | | | 1425 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1426 | | Note - since we are dealing with unsigned quantities we have | 1427 | | to be careful to check for potential overflows. */ | 1428 | 510 | if (dataoff >= section->size | 1429 | 510 | || size > section->size - dataoff) | 1430 | 254 | { | 1431 | 254 | _bfd_error_handler | 1432 | 254 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1433 | 254 | abfd); | 1434 | 254 | return; | 1435 | 254 | } | 1436 | | | 1437 | | /* Read the whole section. */ | 1438 | 256 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1439 | 105 | { | 1440 | 105 | free (data); | 1441 | 105 | return; | 1442 | 105 | } | 1443 | | | 1444 | | /* Search for a CodeView entry in the DebugDirectory */ | 1445 | 5.07k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1446 | 4.99k | { | 1447 | 4.99k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1448 | 4.99k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1449 | 4.99k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1450 | | | 1451 | 4.99k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1452 | | | 1453 | 4.99k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1454 | 64 | { | 1455 | 64 | char buffer[256 + 1]; | 1456 | 64 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1457 | | | 1458 | | /* | 1459 | | The debug entry doesn't have to have to be in a section, in which | 1460 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1461 | | */ | 1462 | 64 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1463 | 64 | (file_ptr) idd.PointerToRawData, | 1464 | 64 | idd.SizeOfData, cvinfo, NULL)) | 1465 | 4 | { | 1466 | 4 | struct bfd_build_id *build_id; | 1467 | 4 | size_t bidlen = sizeof (*build_id) + cvinfo->SignatureLength; | 1468 | | | 1469 | 4 | build_id = bfd_alloc (abfd, bidlen); | 1470 | 4 | if (build_id) | 1471 | 4 | { | 1472 | 4 | build_id->size = cvinfo->SignatureLength; | 1473 | 4 | memcpy(build_id->data, cvinfo->Signature, | 1474 | 4 | cvinfo->SignatureLength); | 1475 | 4 | abfd->build_id = build_id; | 1476 | 4 | } | 1477 | 4 | } | 1478 | 64 | break; | 1479 | 64 | } | 1480 | 4.99k | } | 1481 | | | 1482 | 151 | free (data); | 1483 | 151 | } |
|
1484 | | |
1485 | | static bfd_cleanup |
1486 | | pe_bfd_object_p (bfd *abfd) |
1487 | 1.72M | { |
1488 | 1.72M | bfd_byte buffer[6]; |
1489 | 1.72M | struct external_DOS_hdr dos_hdr; |
1490 | 1.72M | struct external_PEI_IMAGE_hdr image_hdr; |
1491 | 1.72M | struct internal_filehdr internal_f; |
1492 | 1.72M | struct internal_aouthdr internal_a; |
1493 | 1.72M | bfd_size_type opt_hdr_size; |
1494 | 1.72M | file_ptr offset; |
1495 | 1.72M | bfd_cleanup result; |
1496 | | |
1497 | | /* Detect if this a Microsoft Import Library Format element. */ |
1498 | | /* First read the beginning of the header. */ |
1499 | 1.72M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 |
1500 | 1.72M | || bfd_read (buffer, 6, abfd) != 6) |
1501 | 12.0k | { |
1502 | 12.0k | if (bfd_get_error () != bfd_error_system_call) |
1503 | 11.7k | bfd_set_error (bfd_error_wrong_format); |
1504 | 12.0k | return NULL; |
1505 | 12.0k | } |
1506 | | |
1507 | | /* Then check the magic and the version (only 0 is supported). */ |
1508 | 1.70M | if (H_GET_32 (abfd, buffer) == 0xffff0000 |
1509 | 21.1k | && H_GET_16 (abfd, buffer + 4) == 0) |
1510 | 17.5k | return pe_ILF_object_p (abfd); |
1511 | | |
1512 | 1.69M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 |
1513 | 1.69M | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) |
1514 | 350k | { |
1515 | 350k | if (bfd_get_error () != bfd_error_system_call) |
1516 | 350k | bfd_set_error (bfd_error_wrong_format); |
1517 | 350k | return NULL; |
1518 | 350k | } |
1519 | | |
1520 | | /* There are really two magic numbers involved; the magic number |
1521 | | that says this is a NT executable (PEI) and the magic number that |
1522 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in |
1523 | | the e_magic field. The latter is stored in the f_magic field. |
1524 | | If the NT magic number isn't valid, the architecture magic number |
1525 | | could be mimicked by some other field (specifically, the number |
1526 | | of relocs in section 3). Since this routine can only be called |
1527 | | correctly for a PEI file, check the e_magic number here, and, if |
1528 | | it doesn't match, clobber the f_magic number so that we don't get |
1529 | | a false match. */ |
1530 | 1.34M | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) |
1531 | 919k | { |
1532 | 919k | bfd_set_error (bfd_error_wrong_format); |
1533 | 919k | return NULL; |
1534 | 919k | } |
1535 | | |
1536 | 422k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); |
1537 | 422k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 |
1538 | 422k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) |
1539 | 2.73k | { |
1540 | 2.73k | if (bfd_get_error () != bfd_error_system_call) |
1541 | 2.73k | bfd_set_error (bfd_error_wrong_format); |
1542 | 2.73k | return NULL; |
1543 | 2.73k | } |
1544 | | |
1545 | 419k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) |
1546 | 3.84k | { |
1547 | 3.84k | bfd_set_error (bfd_error_wrong_format); |
1548 | 3.84k | return NULL; |
1549 | 3.84k | } |
1550 | | |
1551 | | /* Swap file header, so that we get the location for calling |
1552 | | real_object_p. */ |
1553 | 415k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); |
1554 | | |
1555 | 415k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) |
1556 | 61.7k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) |
1557 | 354k | { |
1558 | 354k | bfd_set_error (bfd_error_wrong_format); |
1559 | 354k | return NULL; |
1560 | 354k | } |
1561 | | |
1562 | 61.5k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, |
1563 | 61.5k | sizeof (internal_f.pe.dos_message)); |
1564 | | |
1565 | | /* Read the optional header, which has variable size. */ |
1566 | 61.5k | opt_hdr_size = internal_f.f_opthdr; |
1567 | | |
1568 | 61.5k | if (opt_hdr_size != 0) |
1569 | 36.2k | { |
1570 | 36.2k | bfd_size_type amt = opt_hdr_size; |
1571 | 36.2k | bfd_byte *opthdr; |
1572 | | |
1573 | | /* PR 17521 file: 230-131433-0.004. */ |
1574 | 36.2k | if (amt < sizeof (PEAOUTHDR)) |
1575 | 33.0k | amt = sizeof (PEAOUTHDR); |
1576 | | |
1577 | 36.2k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); |
1578 | 36.2k | if (opthdr == NULL) |
1579 | 270 | return NULL; |
1580 | 35.9k | if (amt > opt_hdr_size) |
1581 | 32.7k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); |
1582 | | |
1583 | 35.9k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); |
1584 | | |
1585 | 35.9k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; |
1586 | | |
1587 | | #ifdef ARM |
1588 | | /* Use Subsystem to distinguish between pei-arm-little and |
1589 | | pei-arm-wince-little. */ |
1590 | | #ifdef WINCE |
1591 | 4.02k | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) |
1592 | | #else |
1593 | 4.13k | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) |
1594 | 1.35k | #endif |
1595 | 3.58k | { |
1596 | 3.58k | bfd_set_error (bfd_error_wrong_format); |
1597 | 3.58k | return NULL; |
1598 | 3.58k | } |
1599 | 4.56k | #endif |
1600 | | |
1601 | 32.4k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment |
1602 | 14.9k | || a->SectionAlignment >= 0x80000000) |
1603 | 17.7k | { |
1604 | 17.7k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), |
1605 | 17.7k | abfd); |
1606 | 17.7k | a->SectionAlignment &= -a->SectionAlignment; |
1607 | 17.7k | if (a->SectionAlignment >= 0x80000000) |
1608 | 285 | a->SectionAlignment = 0x40000000; |
1609 | 17.7k | } |
1610 | | |
1611 | 32.4k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment |
1612 | 15.8k | || a->FileAlignment > a->SectionAlignment) |
1613 | 21.6k | { |
1614 | 21.6k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), |
1615 | 21.6k | abfd); |
1616 | 21.6k | a->FileAlignment &= -a->FileAlignment; |
1617 | 21.6k | if (a->FileAlignment > a->SectionAlignment) |
1618 | 15.1k | a->FileAlignment = a->SectionAlignment; |
1619 | 21.6k | } |
1620 | | |
1621 | 32.4k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) |
1622 | 17.7k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); |
1623 | 4.56k | } |
1624 | | |
1625 | 57.6k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, |
1626 | 57.6k | (opt_hdr_size != 0 |
1627 | 57.6k | ? &internal_a |
1628 | 57.6k | : (struct internal_aouthdr *) NULL)); |
1629 | | |
1630 | 57.6k | if (result) |
1631 | 37.9k | { |
1632 | | /* Now the whole header has been processed, see if there is a build-id */ |
1633 | 37.9k | pe_bfd_read_buildid(abfd); |
1634 | 37.9k | } |
1635 | | |
1636 | 57.6k | return result; |
1637 | 61.5k | } pei-i386.c:pe_bfd_object_p Line | Count | Source | 1487 | 152k | { | 1488 | 152k | bfd_byte buffer[6]; | 1489 | 152k | struct external_DOS_hdr dos_hdr; | 1490 | 152k | struct external_PEI_IMAGE_hdr image_hdr; | 1491 | 152k | struct internal_filehdr internal_f; | 1492 | 152k | struct internal_aouthdr internal_a; | 1493 | 152k | bfd_size_type opt_hdr_size; | 1494 | 152k | file_ptr offset; | 1495 | 152k | bfd_cleanup result; | 1496 | | | 1497 | | /* Detect if this a Microsoft Import Library Format element. */ | 1498 | | /* First read the beginning of the header. */ | 1499 | 152k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1500 | 152k | || bfd_read (buffer, 6, abfd) != 6) | 1501 | 1.01k | { | 1502 | 1.01k | if (bfd_get_error () != bfd_error_system_call) | 1503 | 978 | bfd_set_error (bfd_error_wrong_format); | 1504 | 1.01k | return NULL; | 1505 | 1.01k | } | 1506 | | | 1507 | | /* Then check the magic and the version (only 0 is supported). */ | 1508 | 151k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1509 | 2.34k | && H_GET_16 (abfd, buffer + 4) == 0) | 1510 | 1.94k | return pe_ILF_object_p (abfd); | 1511 | | | 1512 | 149k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1513 | 149k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1514 | 30.4k | { | 1515 | 30.4k | if (bfd_get_error () != bfd_error_system_call) | 1516 | 30.4k | bfd_set_error (bfd_error_wrong_format); | 1517 | 30.4k | return NULL; | 1518 | 30.4k | } | 1519 | | | 1520 | | /* There are really two magic numbers involved; the magic number | 1521 | | that says this is a NT executable (PEI) and the magic number that | 1522 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1523 | | the e_magic field. The latter is stored in the f_magic field. | 1524 | | If the NT magic number isn't valid, the architecture magic number | 1525 | | could be mimicked by some other field (specifically, the number | 1526 | | of relocs in section 3). Since this routine can only be called | 1527 | | correctly for a PEI file, check the e_magic number here, and, if | 1528 | | it doesn't match, clobber the f_magic number so that we don't get | 1529 | | a false match. */ | 1530 | 118k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1531 | 71.0k | { | 1532 | 71.0k | bfd_set_error (bfd_error_wrong_format); | 1533 | 71.0k | return NULL; | 1534 | 71.0k | } | 1535 | | | 1536 | 47.5k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1537 | 47.5k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1538 | 47.5k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1539 | 119 | { | 1540 | 119 | if (bfd_get_error () != bfd_error_system_call) | 1541 | 119 | bfd_set_error (bfd_error_wrong_format); | 1542 | 119 | return NULL; | 1543 | 119 | } | 1544 | | | 1545 | 47.4k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1546 | 221 | { | 1547 | 221 | bfd_set_error (bfd_error_wrong_format); | 1548 | 221 | return NULL; | 1549 | 221 | } | 1550 | | | 1551 | | /* Swap file header, so that we get the location for calling | 1552 | | real_object_p. */ | 1553 | 47.2k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1554 | | | 1555 | 47.2k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1556 | 9.50k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1557 | 37.7k | { | 1558 | 37.7k | bfd_set_error (bfd_error_wrong_format); | 1559 | 37.7k | return NULL; | 1560 | 37.7k | } | 1561 | | | 1562 | 9.48k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1563 | 9.48k | sizeof (internal_f.pe.dos_message)); | 1564 | | | 1565 | | /* Read the optional header, which has variable size. */ | 1566 | 9.48k | opt_hdr_size = internal_f.f_opthdr; | 1567 | | | 1568 | 9.48k | if (opt_hdr_size != 0) | 1569 | 4.33k | { | 1570 | 4.33k | bfd_size_type amt = opt_hdr_size; | 1571 | 4.33k | bfd_byte *opthdr; | 1572 | | | 1573 | | /* PR 17521 file: 230-131433-0.004. */ | 1574 | 4.33k | if (amt < sizeof (PEAOUTHDR)) | 1575 | 3.52k | amt = sizeof (PEAOUTHDR); | 1576 | | | 1577 | 4.33k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1578 | 4.33k | if (opthdr == NULL) | 1579 | 29 | return NULL; | 1580 | 4.30k | if (amt > opt_hdr_size) | 1581 | 3.49k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1582 | | | 1583 | 4.30k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1584 | | | 1585 | 4.30k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1586 | | | 1587 | | #ifdef ARM | 1588 | | /* Use Subsystem to distinguish between pei-arm-little and | 1589 | | pei-arm-wince-little. */ | 1590 | | #ifdef WINCE | 1591 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1592 | | #else | 1593 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1594 | | #endif | 1595 | | { | 1596 | | bfd_set_error (bfd_error_wrong_format); | 1597 | | return NULL; | 1598 | | } | 1599 | | #endif | 1600 | | | 1601 | 4.30k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1602 | 1.93k | || a->SectionAlignment >= 0x80000000) | 1603 | 2.41k | { | 1604 | 2.41k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1605 | 2.41k | abfd); | 1606 | 2.41k | a->SectionAlignment &= -a->SectionAlignment; | 1607 | 2.41k | if (a->SectionAlignment >= 0x80000000) | 1608 | 44 | a->SectionAlignment = 0x40000000; | 1609 | 2.41k | } | 1610 | | | 1611 | 4.30k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1612 | 2.02k | || a->FileAlignment > a->SectionAlignment) | 1613 | 2.80k | { | 1614 | 2.80k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1615 | 2.80k | abfd); | 1616 | 2.80k | a->FileAlignment &= -a->FileAlignment; | 1617 | 2.80k | if (a->FileAlignment > a->SectionAlignment) | 1618 | 1.85k | a->FileAlignment = a->SectionAlignment; | 1619 | 2.80k | } | 1620 | | | 1621 | 4.30k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1622 | 2.40k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1623 | 4.30k | } | 1624 | | | 1625 | 9.46k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1626 | 9.46k | (opt_hdr_size != 0 | 1627 | 9.46k | ? &internal_a | 1628 | 9.46k | : (struct internal_aouthdr *) NULL)); | 1629 | | | 1630 | 9.46k | if (result) | 1631 | 8.21k | { | 1632 | | /* Now the whole header has been processed, see if there is a build-id */ | 1633 | 8.21k | pe_bfd_read_buildid(abfd); | 1634 | 8.21k | } | 1635 | | | 1636 | 9.46k | return result; | 1637 | 9.48k | } |
pei-x86_64.c:pe_bfd_object_p Line | Count | Source | 1487 | 150k | { | 1488 | 150k | bfd_byte buffer[6]; | 1489 | 150k | struct external_DOS_hdr dos_hdr; | 1490 | 150k | struct external_PEI_IMAGE_hdr image_hdr; | 1491 | 150k | struct internal_filehdr internal_f; | 1492 | 150k | struct internal_aouthdr internal_a; | 1493 | 150k | bfd_size_type opt_hdr_size; | 1494 | 150k | file_ptr offset; | 1495 | 150k | bfd_cleanup result; | 1496 | | | 1497 | | /* Detect if this a Microsoft Import Library Format element. */ | 1498 | | /* First read the beginning of the header. */ | 1499 | 150k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1500 | 150k | || bfd_read (buffer, 6, abfd) != 6) | 1501 | 1.01k | { | 1502 | 1.01k | if (bfd_get_error () != bfd_error_system_call) | 1503 | 978 | bfd_set_error (bfd_error_wrong_format); | 1504 | 1.01k | return NULL; | 1505 | 1.01k | } | 1506 | | | 1507 | | /* Then check the magic and the version (only 0 is supported). */ | 1508 | 149k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1509 | 2.34k | && H_GET_16 (abfd, buffer + 4) == 0) | 1510 | 1.94k | return pe_ILF_object_p (abfd); | 1511 | | | 1512 | 147k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1513 | 147k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1514 | 30.4k | { | 1515 | 30.4k | if (bfd_get_error () != bfd_error_system_call) | 1516 | 30.4k | bfd_set_error (bfd_error_wrong_format); | 1517 | 30.4k | return NULL; | 1518 | 30.4k | } | 1519 | | | 1520 | | /* There are really two magic numbers involved; the magic number | 1521 | | that says this is a NT executable (PEI) and the magic number that | 1522 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1523 | | the e_magic field. The latter is stored in the f_magic field. | 1524 | | If the NT magic number isn't valid, the architecture magic number | 1525 | | could be mimicked by some other field (specifically, the number | 1526 | | of relocs in section 3). Since this routine can only be called | 1527 | | correctly for a PEI file, check the e_magic number here, and, if | 1528 | | it doesn't match, clobber the f_magic number so that we don't get | 1529 | | a false match. */ | 1530 | 117k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1531 | 71.0k | { | 1532 | 71.0k | bfd_set_error (bfd_error_wrong_format); | 1533 | 71.0k | return NULL; | 1534 | 71.0k | } | 1535 | | | 1536 | 46.2k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1537 | 46.2k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1538 | 46.2k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1539 | 119 | { | 1540 | 119 | if (bfd_get_error () != bfd_error_system_call) | 1541 | 119 | bfd_set_error (bfd_error_wrong_format); | 1542 | 119 | return NULL; | 1543 | 119 | } | 1544 | | | 1545 | 46.0k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1546 | 221 | { | 1547 | 221 | bfd_set_error (bfd_error_wrong_format); | 1548 | 221 | return NULL; | 1549 | 221 | } | 1550 | | | 1551 | | /* Swap file header, so that we get the location for calling | 1552 | | real_object_p. */ | 1553 | 45.8k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1554 | | | 1555 | 45.8k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1556 | 6.71k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1557 | 39.1k | { | 1558 | 39.1k | bfd_set_error (bfd_error_wrong_format); | 1559 | 39.1k | return NULL; | 1560 | 39.1k | } | 1561 | | | 1562 | 6.70k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1563 | 6.70k | sizeof (internal_f.pe.dos_message)); | 1564 | | | 1565 | | /* Read the optional header, which has variable size. */ | 1566 | 6.70k | opt_hdr_size = internal_f.f_opthdr; | 1567 | | | 1568 | 6.70k | if (opt_hdr_size != 0) | 1569 | 3.95k | { | 1570 | 3.95k | bfd_size_type amt = opt_hdr_size; | 1571 | 3.95k | bfd_byte *opthdr; | 1572 | | | 1573 | | /* PR 17521 file: 230-131433-0.004. */ | 1574 | 3.95k | if (amt < sizeof (PEAOUTHDR)) | 1575 | 3.72k | amt = sizeof (PEAOUTHDR); | 1576 | | | 1577 | 3.95k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1578 | 3.95k | if (opthdr == NULL) | 1579 | 29 | return NULL; | 1580 | 3.92k | if (amt > opt_hdr_size) | 1581 | 3.70k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1582 | | | 1583 | 3.92k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1584 | | | 1585 | 3.92k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1586 | | | 1587 | | #ifdef ARM | 1588 | | /* Use Subsystem to distinguish between pei-arm-little and | 1589 | | pei-arm-wince-little. */ | 1590 | | #ifdef WINCE | 1591 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1592 | | #else | 1593 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1594 | | #endif | 1595 | | { | 1596 | | bfd_set_error (bfd_error_wrong_format); | 1597 | | return NULL; | 1598 | | } | 1599 | | #endif | 1600 | | | 1601 | 3.92k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1602 | 2.21k | || a->SectionAlignment >= 0x80000000) | 1603 | 1.75k | { | 1604 | 1.75k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1605 | 1.75k | abfd); | 1606 | 1.75k | a->SectionAlignment &= -a->SectionAlignment; | 1607 | 1.75k | if (a->SectionAlignment >= 0x80000000) | 1608 | 40 | a->SectionAlignment = 0x40000000; | 1609 | 1.75k | } | 1610 | | | 1611 | 3.92k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1612 | 1.98k | || a->FileAlignment > a->SectionAlignment) | 1613 | 2.36k | { | 1614 | 2.36k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1615 | 2.36k | abfd); | 1616 | 2.36k | a->FileAlignment &= -a->FileAlignment; | 1617 | 2.36k | if (a->FileAlignment > a->SectionAlignment) | 1618 | 1.20k | a->FileAlignment = a->SectionAlignment; | 1619 | 2.36k | } | 1620 | | | 1621 | 3.92k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1622 | 1.86k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1623 | 3.92k | } | 1624 | | | 1625 | 6.67k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1626 | 6.67k | (opt_hdr_size != 0 | 1627 | 6.67k | ? &internal_a | 1628 | 6.67k | : (struct internal_aouthdr *) NULL)); | 1629 | | | 1630 | 6.67k | if (result) | 1631 | 5.23k | { | 1632 | | /* Now the whole header has been processed, see if there is a build-id */ | 1633 | 5.23k | pe_bfd_read_buildid(abfd); | 1634 | 5.23k | } | 1635 | | | 1636 | 6.67k | return result; | 1637 | 6.70k | } |
pei-aarch64.c:pe_bfd_object_p Line | Count | Source | 1487 | 148k | { | 1488 | 148k | bfd_byte buffer[6]; | 1489 | 148k | struct external_DOS_hdr dos_hdr; | 1490 | 148k | struct external_PEI_IMAGE_hdr image_hdr; | 1491 | 148k | struct internal_filehdr internal_f; | 1492 | 148k | struct internal_aouthdr internal_a; | 1493 | 148k | bfd_size_type opt_hdr_size; | 1494 | 148k | file_ptr offset; | 1495 | 148k | bfd_cleanup result; | 1496 | | | 1497 | | /* Detect if this a Microsoft Import Library Format element. */ | 1498 | | /* First read the beginning of the header. */ | 1499 | 148k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1500 | 148k | || bfd_read (buffer, 6, abfd) != 6) | 1501 | 1.01k | { | 1502 | 1.01k | if (bfd_get_error () != bfd_error_system_call) | 1503 | 978 | bfd_set_error (bfd_error_wrong_format); | 1504 | 1.01k | return NULL; | 1505 | 1.01k | } | 1506 | | | 1507 | | /* Then check the magic and the version (only 0 is supported). */ | 1508 | 147k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1509 | 2.34k | && H_GET_16 (abfd, buffer + 4) == 0) | 1510 | 1.93k | return pe_ILF_object_p (abfd); | 1511 | | | 1512 | 145k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1513 | 145k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1514 | 30.4k | { | 1515 | 30.4k | if (bfd_get_error () != bfd_error_system_call) | 1516 | 30.4k | bfd_set_error (bfd_error_wrong_format); | 1517 | 30.4k | return NULL; | 1518 | 30.4k | } | 1519 | | | 1520 | | /* There are really two magic numbers involved; the magic number | 1521 | | that says this is a NT executable (PEI) and the magic number that | 1522 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1523 | | the e_magic field. The latter is stored in the f_magic field. | 1524 | | If the NT magic number isn't valid, the architecture magic number | 1525 | | could be mimicked by some other field (specifically, the number | 1526 | | of relocs in section 3). Since this routine can only be called | 1527 | | correctly for a PEI file, check the e_magic number here, and, if | 1528 | | it doesn't match, clobber the f_magic number so that we don't get | 1529 | | a false match. */ | 1530 | 115k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1531 | 69.4k | { | 1532 | 69.4k | bfd_set_error (bfd_error_wrong_format); | 1533 | 69.4k | return NULL; | 1534 | 69.4k | } | 1535 | | | 1536 | 45.9k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1537 | 45.9k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1538 | 45.9k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1539 | 678 | { | 1540 | 678 | if (bfd_get_error () != bfd_error_system_call) | 1541 | 678 | bfd_set_error (bfd_error_wrong_format); | 1542 | 678 | return NULL; | 1543 | 678 | } | 1544 | | | 1545 | 45.3k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1546 | 846 | { | 1547 | 846 | bfd_set_error (bfd_error_wrong_format); | 1548 | 846 | return NULL; | 1549 | 846 | } | 1550 | | | 1551 | | /* Swap file header, so that we get the location for calling | 1552 | | real_object_p. */ | 1553 | 44.4k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1554 | | | 1555 | 44.4k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1556 | 6.72k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1557 | 37.7k | { | 1558 | 37.7k | bfd_set_error (bfd_error_wrong_format); | 1559 | 37.7k | return NULL; | 1560 | 37.7k | } | 1561 | | | 1562 | 6.70k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1563 | 6.70k | sizeof (internal_f.pe.dos_message)); | 1564 | | | 1565 | | /* Read the optional header, which has variable size. */ | 1566 | 6.70k | opt_hdr_size = internal_f.f_opthdr; | 1567 | | | 1568 | 6.70k | if (opt_hdr_size != 0) | 1569 | 5.05k | { | 1570 | 5.05k | bfd_size_type amt = opt_hdr_size; | 1571 | 5.05k | bfd_byte *opthdr; | 1572 | | | 1573 | | /* PR 17521 file: 230-131433-0.004. */ | 1574 | 5.05k | if (amt < sizeof (PEAOUTHDR)) | 1575 | 4.73k | amt = sizeof (PEAOUTHDR); | 1576 | | | 1577 | 5.05k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1578 | 5.05k | if (opthdr == NULL) | 1579 | 22 | return NULL; | 1580 | 5.02k | if (amt > opt_hdr_size) | 1581 | 4.71k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1582 | | | 1583 | 5.02k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1584 | | | 1585 | 5.02k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1586 | | | 1587 | | #ifdef ARM | 1588 | | /* Use Subsystem to distinguish between pei-arm-little and | 1589 | | pei-arm-wince-little. */ | 1590 | | #ifdef WINCE | 1591 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1592 | | #else | 1593 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1594 | | #endif | 1595 | | { | 1596 | | bfd_set_error (bfd_error_wrong_format); | 1597 | | return NULL; | 1598 | | } | 1599 | | #endif | 1600 | | | 1601 | 5.02k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1602 | 1.69k | || a->SectionAlignment >= 0x80000000) | 1603 | 3.34k | { | 1604 | 3.34k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1605 | 3.34k | abfd); | 1606 | 3.34k | a->SectionAlignment &= -a->SectionAlignment; | 1607 | 3.34k | if (a->SectionAlignment >= 0x80000000) | 1608 | 12 | a->SectionAlignment = 0x40000000; | 1609 | 3.34k | } | 1610 | | | 1611 | 5.02k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1612 | 3.41k | || a->FileAlignment > a->SectionAlignment) | 1613 | 3.82k | { | 1614 | 3.82k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1615 | 3.82k | abfd); | 1616 | 3.82k | a->FileAlignment &= -a->FileAlignment; | 1617 | 3.82k | if (a->FileAlignment > a->SectionAlignment) | 1618 | 3.00k | a->FileAlignment = a->SectionAlignment; | 1619 | 3.82k | } | 1620 | | | 1621 | 5.02k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1622 | 2.10k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1623 | 5.02k | } | 1624 | | | 1625 | 6.68k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1626 | 6.68k | (opt_hdr_size != 0 | 1627 | 6.68k | ? &internal_a | 1628 | 6.68k | : (struct internal_aouthdr *) NULL)); | 1629 | | | 1630 | 6.68k | if (result) | 1631 | 4.75k | { | 1632 | | /* Now the whole header has been processed, see if there is a build-id */ | 1633 | 4.75k | pe_bfd_read_buildid(abfd); | 1634 | 4.75k | } | 1635 | | | 1636 | 6.68k | return result; | 1637 | 6.70k | } |
pei-ia64.c:pe_bfd_object_p Line | Count | Source | 1487 | 14.4k | { | 1488 | 14.4k | bfd_byte buffer[6]; | 1489 | 14.4k | struct external_DOS_hdr dos_hdr; | 1490 | 14.4k | struct external_PEI_IMAGE_hdr image_hdr; | 1491 | 14.4k | struct internal_filehdr internal_f; | 1492 | 14.4k | struct internal_aouthdr internal_a; | 1493 | 14.4k | bfd_size_type opt_hdr_size; | 1494 | 14.4k | file_ptr offset; | 1495 | 14.4k | bfd_cleanup result; | 1496 | | | 1497 | | /* Detect if this a Microsoft Import Library Format element. */ | 1498 | | /* First read the beginning of the header. */ | 1499 | 14.4k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1500 | 14.4k | || bfd_read (buffer, 6, abfd) != 6) | 1501 | 0 | { | 1502 | 0 | if (bfd_get_error () != bfd_error_system_call) | 1503 | 0 | bfd_set_error (bfd_error_wrong_format); | 1504 | 0 | return NULL; | 1505 | 0 | } | 1506 | | | 1507 | | /* Then check the magic and the version (only 0 is supported). */ | 1508 | 14.4k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1509 | 0 | && H_GET_16 (abfd, buffer + 4) == 0) | 1510 | 0 | return pe_ILF_object_p (abfd); | 1511 | | | 1512 | 14.4k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1513 | 14.4k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1514 | 0 | { | 1515 | 0 | if (bfd_get_error () != bfd_error_system_call) | 1516 | 0 | bfd_set_error (bfd_error_wrong_format); | 1517 | 0 | return NULL; | 1518 | 0 | } | 1519 | | | 1520 | | /* There are really two magic numbers involved; the magic number | 1521 | | that says this is a NT executable (PEI) and the magic number that | 1522 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1523 | | the e_magic field. The latter is stored in the f_magic field. | 1524 | | If the NT magic number isn't valid, the architecture magic number | 1525 | | could be mimicked by some other field (specifically, the number | 1526 | | of relocs in section 3). Since this routine can only be called | 1527 | | correctly for a PEI file, check the e_magic number here, and, if | 1528 | | it doesn't match, clobber the f_magic number so that we don't get | 1529 | | a false match. */ | 1530 | 14.4k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1531 | 0 | { | 1532 | 0 | bfd_set_error (bfd_error_wrong_format); | 1533 | 0 | return NULL; | 1534 | 0 | } | 1535 | | | 1536 | 14.4k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1537 | 14.4k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1538 | 14.4k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1539 | 0 | { | 1540 | 0 | if (bfd_get_error () != bfd_error_system_call) | 1541 | 0 | bfd_set_error (bfd_error_wrong_format); | 1542 | 0 | return NULL; | 1543 | 0 | } | 1544 | | | 1545 | 14.4k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1546 | 0 | { | 1547 | 0 | bfd_set_error (bfd_error_wrong_format); | 1548 | 0 | return NULL; | 1549 | 0 | } | 1550 | | | 1551 | | /* Swap file header, so that we get the location for calling | 1552 | | real_object_p. */ | 1553 | 14.4k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1554 | | | 1555 | 14.4k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1556 | 4.96k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1557 | 9.50k | { | 1558 | 9.50k | bfd_set_error (bfd_error_wrong_format); | 1559 | 9.50k | return NULL; | 1560 | 9.50k | } | 1561 | | | 1562 | 4.95k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1563 | 4.95k | sizeof (internal_f.pe.dos_message)); | 1564 | | | 1565 | | /* Read the optional header, which has variable size. */ | 1566 | 4.95k | opt_hdr_size = internal_f.f_opthdr; | 1567 | | | 1568 | 4.95k | if (opt_hdr_size != 0) | 1569 | 2.14k | { | 1570 | 2.14k | bfd_size_type amt = opt_hdr_size; | 1571 | 2.14k | bfd_byte *opthdr; | 1572 | | | 1573 | | /* PR 17521 file: 230-131433-0.004. */ | 1574 | 2.14k | if (amt < sizeof (PEAOUTHDR)) | 1575 | 2.02k | amt = sizeof (PEAOUTHDR); | 1576 | | | 1577 | 2.14k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1578 | 2.14k | if (opthdr == NULL) | 1579 | 33 | return NULL; | 1580 | 2.11k | if (amt > opt_hdr_size) | 1581 | 1.99k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1582 | | | 1583 | 2.11k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1584 | | | 1585 | 2.11k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1586 | | | 1587 | | #ifdef ARM | 1588 | | /* Use Subsystem to distinguish between pei-arm-little and | 1589 | | pei-arm-wince-little. */ | 1590 | | #ifdef WINCE | 1591 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1592 | | #else | 1593 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1594 | | #endif | 1595 | | { | 1596 | | bfd_set_error (bfd_error_wrong_format); | 1597 | | return NULL; | 1598 | | } | 1599 | | #endif | 1600 | | | 1601 | 2.11k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1602 | 958 | || a->SectionAlignment >= 0x80000000) | 1603 | 1.17k | { | 1604 | 1.17k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1605 | 1.17k | abfd); | 1606 | 1.17k | a->SectionAlignment &= -a->SectionAlignment; | 1607 | 1.17k | if (a->SectionAlignment >= 0x80000000) | 1608 | 20 | a->SectionAlignment = 0x40000000; | 1609 | 1.17k | } | 1610 | | | 1611 | 2.11k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1612 | 926 | || a->FileAlignment > a->SectionAlignment) | 1613 | 1.50k | { | 1614 | 1.50k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1615 | 1.50k | abfd); | 1616 | 1.50k | a->FileAlignment &= -a->FileAlignment; | 1617 | 1.50k | if (a->FileAlignment > a->SectionAlignment) | 1618 | 861 | a->FileAlignment = a->SectionAlignment; | 1619 | 1.50k | } | 1620 | | | 1621 | 2.11k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1622 | 1.27k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1623 | 2.11k | } | 1624 | | | 1625 | 4.92k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1626 | 4.92k | (opt_hdr_size != 0 | 1627 | 4.92k | ? &internal_a | 1628 | 4.92k | : (struct internal_aouthdr *) NULL)); | 1629 | | | 1630 | 4.92k | if (result) | 1631 | 2.99k | { | 1632 | | /* Now the whole header has been processed, see if there is a build-id */ | 1633 | 2.99k | pe_bfd_read_buildid(abfd); | 1634 | 2.99k | } | 1635 | | | 1636 | 4.92k | return result; | 1637 | 4.95k | } |
pei-loongarch64.c:pe_bfd_object_p Line | Count | Source | 1487 | 149k | { | 1488 | 149k | bfd_byte buffer[6]; | 1489 | 149k | struct external_DOS_hdr dos_hdr; | 1490 | 149k | struct external_PEI_IMAGE_hdr image_hdr; | 1491 | 149k | struct internal_filehdr internal_f; | 1492 | 149k | struct internal_aouthdr internal_a; | 1493 | 149k | bfd_size_type opt_hdr_size; | 1494 | 149k | file_ptr offset; | 1495 | 149k | bfd_cleanup result; | 1496 | | | 1497 | | /* Detect if this a Microsoft Import Library Format element. */ | 1498 | | /* First read the beginning of the header. */ | 1499 | 149k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1500 | 149k | || bfd_read (buffer, 6, abfd) != 6) | 1501 | 1.01k | { | 1502 | 1.01k | if (bfd_get_error () != bfd_error_system_call) | 1503 | 978 | bfd_set_error (bfd_error_wrong_format); | 1504 | 1.01k | return NULL; | 1505 | 1.01k | } | 1506 | | | 1507 | | /* Then check the magic and the version (only 0 is supported). */ | 1508 | 148k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1509 | 2.33k | && H_GET_16 (abfd, buffer + 4) == 0) | 1510 | 1.93k | return pe_ILF_object_p (abfd); | 1511 | | | 1512 | 146k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1513 | 146k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1514 | 30.4k | { | 1515 | 30.4k | if (bfd_get_error () != bfd_error_system_call) | 1516 | 30.4k | bfd_set_error (bfd_error_wrong_format); | 1517 | 30.4k | return NULL; | 1518 | 30.4k | } | 1519 | | | 1520 | | /* There are really two magic numbers involved; the magic number | 1521 | | that says this is a NT executable (PEI) and the magic number that | 1522 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1523 | | the e_magic field. The latter is stored in the f_magic field. | 1524 | | If the NT magic number isn't valid, the architecture magic number | 1525 | | could be mimicked by some other field (specifically, the number | 1526 | | of relocs in section 3). Since this routine can only be called | 1527 | | correctly for a PEI file, check the e_magic number here, and, if | 1528 | | it doesn't match, clobber the f_magic number so that we don't get | 1529 | | a false match. */ | 1530 | 115k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1531 | 71.0k | { | 1532 | 71.0k | bfd_set_error (bfd_error_wrong_format); | 1533 | 71.0k | return NULL; | 1534 | 71.0k | } | 1535 | | | 1536 | 44.5k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1537 | 44.5k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1538 | 44.5k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1539 | 119 | { | 1540 | 119 | if (bfd_get_error () != bfd_error_system_call) | 1541 | 119 | bfd_set_error (bfd_error_wrong_format); | 1542 | 119 | return NULL; | 1543 | 119 | } | 1544 | | | 1545 | 44.4k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1546 | 221 | { | 1547 | 221 | bfd_set_error (bfd_error_wrong_format); | 1548 | 221 | return NULL; | 1549 | 221 | } | 1550 | | | 1551 | | /* Swap file header, so that we get the location for calling | 1552 | | real_object_p. */ | 1553 | 44.2k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1554 | | | 1555 | 44.2k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1556 | 5.45k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1557 | 38.7k | { | 1558 | 38.7k | bfd_set_error (bfd_error_wrong_format); | 1559 | 38.7k | return NULL; | 1560 | 38.7k | } | 1561 | | | 1562 | 5.45k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1563 | 5.45k | sizeof (internal_f.pe.dos_message)); | 1564 | | | 1565 | | /* Read the optional header, which has variable size. */ | 1566 | 5.45k | opt_hdr_size = internal_f.f_opthdr; | 1567 | | | 1568 | 5.45k | if (opt_hdr_size != 0) | 1569 | 3.65k | { | 1570 | 3.65k | bfd_size_type amt = opt_hdr_size; | 1571 | 3.65k | bfd_byte *opthdr; | 1572 | | | 1573 | | /* PR 17521 file: 230-131433-0.004. */ | 1574 | 3.65k | if (amt < sizeof (PEAOUTHDR)) | 1575 | 3.35k | amt = sizeof (PEAOUTHDR); | 1576 | | | 1577 | 3.65k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1578 | 3.65k | if (opthdr == NULL) | 1579 | 28 | return NULL; | 1580 | 3.62k | if (amt > opt_hdr_size) | 1581 | 3.32k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1582 | | | 1583 | 3.62k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1584 | | | 1585 | 3.62k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1586 | | | 1587 | | #ifdef ARM | 1588 | | /* Use Subsystem to distinguish between pei-arm-little and | 1589 | | pei-arm-wince-little. */ | 1590 | | #ifdef WINCE | 1591 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1592 | | #else | 1593 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1594 | | #endif | 1595 | | { | 1596 | | bfd_set_error (bfd_error_wrong_format); | 1597 | | return NULL; | 1598 | | } | 1599 | | #endif | 1600 | | | 1601 | 3.62k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1602 | 2.02k | || a->SectionAlignment >= 0x80000000) | 1603 | 1.61k | { | 1604 | 1.61k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1605 | 1.61k | abfd); | 1606 | 1.61k | a->SectionAlignment &= -a->SectionAlignment; | 1607 | 1.61k | if (a->SectionAlignment >= 0x80000000) | 1608 | 17 | a->SectionAlignment = 0x40000000; | 1609 | 1.61k | } | 1610 | | | 1611 | 3.62k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1612 | 1.62k | || a->FileAlignment > a->SectionAlignment) | 1613 | 2.38k | { | 1614 | 2.38k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1615 | 2.38k | abfd); | 1616 | 2.38k | a->FileAlignment &= -a->FileAlignment; | 1617 | 2.38k | if (a->FileAlignment > a->SectionAlignment) | 1618 | 1.34k | a->FileAlignment = a->SectionAlignment; | 1619 | 2.38k | } | 1620 | | | 1621 | 3.62k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1622 | 2.16k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1623 | 3.62k | } | 1624 | | | 1625 | 5.42k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1626 | 5.42k | (opt_hdr_size != 0 | 1627 | 5.42k | ? &internal_a | 1628 | 5.42k | : (struct internal_aouthdr *) NULL)); | 1629 | | | 1630 | 5.42k | if (result) | 1631 | 3.45k | { | 1632 | | /* Now the whole header has been processed, see if there is a build-id */ | 1633 | 3.45k | pe_bfd_read_buildid(abfd); | 1634 | 3.45k | } | 1635 | | | 1636 | 5.42k | return result; | 1637 | 5.45k | } |
pei-riscv64.c:pe_bfd_object_p Line | Count | Source | 1487 | 148k | { | 1488 | 148k | bfd_byte buffer[6]; | 1489 | 148k | struct external_DOS_hdr dos_hdr; | 1490 | 148k | struct external_PEI_IMAGE_hdr image_hdr; | 1491 | 148k | struct internal_filehdr internal_f; | 1492 | 148k | struct internal_aouthdr internal_a; | 1493 | 148k | bfd_size_type opt_hdr_size; | 1494 | 148k | file_ptr offset; | 1495 | 148k | bfd_cleanup result; | 1496 | | | 1497 | | /* Detect if this a Microsoft Import Library Format element. */ | 1498 | | /* First read the beginning of the header. */ | 1499 | 148k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1500 | 148k | || bfd_read (buffer, 6, abfd) != 6) | 1501 | 1.01k | { | 1502 | 1.01k | if (bfd_get_error () != bfd_error_system_call) | 1503 | 978 | bfd_set_error (bfd_error_wrong_format); | 1504 | 1.01k | return NULL; | 1505 | 1.01k | } | 1506 | | | 1507 | | /* Then check the magic and the version (only 0 is supported). */ | 1508 | 147k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1509 | 2.34k | && H_GET_16 (abfd, buffer + 4) == 0) | 1510 | 1.93k | return pe_ILF_object_p (abfd); | 1511 | | | 1512 | 146k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1513 | 146k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1514 | 30.4k | { | 1515 | 30.4k | if (bfd_get_error () != bfd_error_system_call) | 1516 | 30.4k | bfd_set_error (bfd_error_wrong_format); | 1517 | 30.4k | return NULL; | 1518 | 30.4k | } | 1519 | | | 1520 | | /* There are really two magic numbers involved; the magic number | 1521 | | that says this is a NT executable (PEI) and the magic number that | 1522 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1523 | | the e_magic field. The latter is stored in the f_magic field. | 1524 | | If the NT magic number isn't valid, the architecture magic number | 1525 | | could be mimicked by some other field (specifically, the number | 1526 | | of relocs in section 3). Since this routine can only be called | 1527 | | correctly for a PEI file, check the e_magic number here, and, if | 1528 | | it doesn't match, clobber the f_magic number so that we don't get | 1529 | | a false match. */ | 1530 | 115k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1531 | 71.0k | { | 1532 | 71.0k | bfd_set_error (bfd_error_wrong_format); | 1533 | 71.0k | return NULL; | 1534 | 71.0k | } | 1535 | | | 1536 | 44.4k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1537 | 44.4k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1538 | 44.4k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1539 | 119 | { | 1540 | 119 | if (bfd_get_error () != bfd_error_system_call) | 1541 | 119 | bfd_set_error (bfd_error_wrong_format); | 1542 | 119 | return NULL; | 1543 | 119 | } | 1544 | | | 1545 | 44.3k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1546 | 221 | { | 1547 | 221 | bfd_set_error (bfd_error_wrong_format); | 1548 | 221 | return NULL; | 1549 | 221 | } | 1550 | | | 1551 | | /* Swap file header, so that we get the location for calling | 1552 | | real_object_p. */ | 1553 | 44.1k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1554 | | | 1555 | 44.1k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1556 | 5.18k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1557 | 38.9k | { | 1558 | 38.9k | bfd_set_error (bfd_error_wrong_format); | 1559 | 38.9k | return NULL; | 1560 | 38.9k | } | 1561 | | | 1562 | 5.17k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1563 | 5.17k | sizeof (internal_f.pe.dos_message)); | 1564 | | | 1565 | | /* Read the optional header, which has variable size. */ | 1566 | 5.17k | opt_hdr_size = internal_f.f_opthdr; | 1567 | | | 1568 | 5.17k | if (opt_hdr_size != 0) | 1569 | 3.78k | { | 1570 | 3.78k | bfd_size_type amt = opt_hdr_size; | 1571 | 3.78k | bfd_byte *opthdr; | 1572 | | | 1573 | | /* PR 17521 file: 230-131433-0.004. */ | 1574 | 3.78k | if (amt < sizeof (PEAOUTHDR)) | 1575 | 3.36k | amt = sizeof (PEAOUTHDR); | 1576 | | | 1577 | 3.78k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1578 | 3.78k | if (opthdr == NULL) | 1579 | 24 | return NULL; | 1580 | 3.76k | if (amt > opt_hdr_size) | 1581 | 3.34k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1582 | | | 1583 | 3.76k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1584 | | | 1585 | 3.76k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1586 | | | 1587 | | #ifdef ARM | 1588 | | /* Use Subsystem to distinguish between pei-arm-little and | 1589 | | pei-arm-wince-little. */ | 1590 | | #ifdef WINCE | 1591 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1592 | | #else | 1593 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1594 | | #endif | 1595 | | { | 1596 | | bfd_set_error (bfd_error_wrong_format); | 1597 | | return NULL; | 1598 | | } | 1599 | | #endif | 1600 | | | 1601 | 3.76k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1602 | 2.18k | || a->SectionAlignment >= 0x80000000) | 1603 | 1.60k | { | 1604 | 1.60k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1605 | 1.60k | abfd); | 1606 | 1.60k | a->SectionAlignment &= -a->SectionAlignment; | 1607 | 1.60k | if (a->SectionAlignment >= 0x80000000) | 1608 | 24 | a->SectionAlignment = 0x40000000; | 1609 | 1.60k | } | 1610 | | | 1611 | 3.76k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1612 | 1.76k | || a->FileAlignment > a->SectionAlignment) | 1613 | 2.28k | { | 1614 | 2.28k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1615 | 2.28k | abfd); | 1616 | 2.28k | a->FileAlignment &= -a->FileAlignment; | 1617 | 2.28k | if (a->FileAlignment > a->SectionAlignment) | 1618 | 1.57k | a->FileAlignment = a->SectionAlignment; | 1619 | 2.28k | } | 1620 | | | 1621 | 3.76k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1622 | 2.13k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1623 | 3.76k | } | 1624 | | | 1625 | 5.15k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1626 | 5.15k | (opt_hdr_size != 0 | 1627 | 5.15k | ? &internal_a | 1628 | 5.15k | : (struct internal_aouthdr *) NULL)); | 1629 | | | 1630 | 5.15k | if (result) | 1631 | 3.12k | { | 1632 | | /* Now the whole header has been processed, see if there is a build-id */ | 1633 | 3.12k | pe_bfd_read_buildid(abfd); | 1634 | 3.12k | } | 1635 | | | 1636 | 5.15k | return result; | 1637 | 5.17k | } |
pei-arm-wince.c:pe_bfd_object_p Line | Count | Source | 1487 | 272k | { | 1488 | 272k | bfd_byte buffer[6]; | 1489 | 272k | struct external_DOS_hdr dos_hdr; | 1490 | 272k | struct external_PEI_IMAGE_hdr image_hdr; | 1491 | 272k | struct internal_filehdr internal_f; | 1492 | 272k | struct internal_aouthdr internal_a; | 1493 | 272k | bfd_size_type opt_hdr_size; | 1494 | 272k | file_ptr offset; | 1495 | 272k | bfd_cleanup result; | 1496 | | | 1497 | | /* Detect if this a Microsoft Import Library Format element. */ | 1498 | | /* First read the beginning of the header. */ | 1499 | 272k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1500 | 272k | || bfd_read (buffer, 6, abfd) != 6) | 1501 | 2.01k | { | 1502 | 2.01k | if (bfd_get_error () != bfd_error_system_call) | 1503 | 1.94k | bfd_set_error (bfd_error_wrong_format); | 1504 | 2.01k | return NULL; | 1505 | 2.01k | } | 1506 | | | 1507 | | /* Then check the magic and the version (only 0 is supported). */ | 1508 | 270k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1509 | 2.37k | && H_GET_16 (abfd, buffer + 4) == 0) | 1510 | 1.98k | return pe_ILF_object_p (abfd); | 1511 | | | 1512 | 268k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1513 | 268k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1514 | 56.7k | { | 1515 | 56.7k | if (bfd_get_error () != bfd_error_system_call) | 1516 | 56.7k | bfd_set_error (bfd_error_wrong_format); | 1517 | 56.7k | return NULL; | 1518 | 56.7k | } | 1519 | | | 1520 | | /* There are really two magic numbers involved; the magic number | 1521 | | that says this is a NT executable (PEI) and the magic number that | 1522 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1523 | | the e_magic field. The latter is stored in the f_magic field. | 1524 | | If the NT magic number isn't valid, the architecture magic number | 1525 | | could be mimicked by some other field (specifically, the number | 1526 | | of relocs in section 3). Since this routine can only be called | 1527 | | correctly for a PEI file, check the e_magic number here, and, if | 1528 | | it doesn't match, clobber the f_magic number so that we don't get | 1529 | | a false match. */ | 1530 | 212k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1531 | 166k | { | 1532 | 166k | bfd_set_error (bfd_error_wrong_format); | 1533 | 166k | return NULL; | 1534 | 166k | } | 1535 | | | 1536 | 45.3k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1537 | 45.3k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1538 | 45.3k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1539 | 671 | { | 1540 | 671 | if (bfd_get_error () != bfd_error_system_call) | 1541 | 671 | bfd_set_error (bfd_error_wrong_format); | 1542 | 671 | return NULL; | 1543 | 671 | } | 1544 | | | 1545 | 44.7k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1546 | 833 | { | 1547 | 833 | bfd_set_error (bfd_error_wrong_format); | 1548 | 833 | return NULL; | 1549 | 833 | } | 1550 | | | 1551 | | /* Swap file header, so that we get the location for calling | 1552 | | real_object_p. */ | 1553 | 43.8k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1554 | | | 1555 | 43.8k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1556 | 7.09k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1557 | 36.8k | { | 1558 | 36.8k | bfd_set_error (bfd_error_wrong_format); | 1559 | 36.8k | return NULL; | 1560 | 36.8k | } | 1561 | | | 1562 | 7.04k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1563 | 7.04k | sizeof (internal_f.pe.dos_message)); | 1564 | | | 1565 | | /* Read the optional header, which has variable size. */ | 1566 | 7.04k | opt_hdr_size = internal_f.f_opthdr; | 1567 | | | 1568 | 7.04k | if (opt_hdr_size != 0) | 1569 | 4.04k | { | 1570 | 4.04k | bfd_size_type amt = opt_hdr_size; | 1571 | 4.04k | bfd_byte *opthdr; | 1572 | | | 1573 | | /* PR 17521 file: 230-131433-0.004. */ | 1574 | 4.04k | if (amt < sizeof (PEAOUTHDR)) | 1575 | 3.68k | amt = sizeof (PEAOUTHDR); | 1576 | | | 1577 | 4.04k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1578 | 4.04k | if (opthdr == NULL) | 1579 | 28 | return NULL; | 1580 | 4.02k | if (amt > opt_hdr_size) | 1581 | 3.65k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1582 | | | 1583 | 4.02k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1584 | | | 1585 | 4.02k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1586 | | | 1587 | 4.02k | #ifdef ARM | 1588 | | /* Use Subsystem to distinguish between pei-arm-little and | 1589 | | pei-arm-wince-little. */ | 1590 | 4.02k | #ifdef WINCE | 1591 | 4.02k | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1592 | | #else | 1593 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1594 | | #endif | 1595 | 2.23k | { | 1596 | 2.23k | bfd_set_error (bfd_error_wrong_format); | 1597 | 2.23k | return NULL; | 1598 | 2.23k | } | 1599 | 1.78k | #endif | 1600 | | | 1601 | 1.78k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1602 | 314 | || a->SectionAlignment >= 0x80000000) | 1603 | 1.51k | { | 1604 | 1.51k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1605 | 1.51k | abfd); | 1606 | 1.51k | a->SectionAlignment &= -a->SectionAlignment; | 1607 | 1.51k | if (a->SectionAlignment >= 0x80000000) | 1608 | 43 | a->SectionAlignment = 0x40000000; | 1609 | 1.51k | } | 1610 | | | 1611 | 1.78k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1612 | 366 | || a->FileAlignment > a->SectionAlignment) | 1613 | 1.62k | { | 1614 | 1.62k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1615 | 1.62k | abfd); | 1616 | 1.62k | a->FileAlignment &= -a->FileAlignment; | 1617 | 1.62k | if (a->FileAlignment > a->SectionAlignment) | 1618 | 1.37k | a->FileAlignment = a->SectionAlignment; | 1619 | 1.62k | } | 1620 | | | 1621 | 1.78k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1622 | 1.42k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1623 | 1.78k | } | 1624 | | | 1625 | 4.78k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1626 | 4.78k | (opt_hdr_size != 0 | 1627 | 4.78k | ? &internal_a | 1628 | 4.78k | : (struct internal_aouthdr *) NULL)); | 1629 | | | 1630 | 4.78k | if (result) | 1631 | 2.07k | { | 1632 | | /* Now the whole header has been processed, see if there is a build-id */ | 1633 | 2.07k | pe_bfd_read_buildid(abfd); | 1634 | 2.07k | } | 1635 | | | 1636 | 4.78k | return result; | 1637 | 7.04k | } |
pei-arm.c:pe_bfd_object_p Line | Count | Source | 1487 | 273k | { | 1488 | 273k | bfd_byte buffer[6]; | 1489 | 273k | struct external_DOS_hdr dos_hdr; | 1490 | 273k | struct external_PEI_IMAGE_hdr image_hdr; | 1491 | 273k | struct internal_filehdr internal_f; | 1492 | 273k | struct internal_aouthdr internal_a; | 1493 | 273k | bfd_size_type opt_hdr_size; | 1494 | 273k | file_ptr offset; | 1495 | 273k | bfd_cleanup result; | 1496 | | | 1497 | | /* Detect if this a Microsoft Import Library Format element. */ | 1498 | | /* First read the beginning of the header. */ | 1499 | 273k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1500 | 273k | || bfd_read (buffer, 6, abfd) != 6) | 1501 | 2.01k | { | 1502 | 2.01k | if (bfd_get_error () != bfd_error_system_call) | 1503 | 1.94k | bfd_set_error (bfd_error_wrong_format); | 1504 | 2.01k | return NULL; | 1505 | 2.01k | } | 1506 | | | 1507 | | /* Then check the magic and the version (only 0 is supported). */ | 1508 | 271k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1509 | 2.37k | && H_GET_16 (abfd, buffer + 4) == 0) | 1510 | 1.98k | return pe_ILF_object_p (abfd); | 1511 | | | 1512 | 269k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1513 | 269k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1514 | 56.7k | { | 1515 | 56.7k | if (bfd_get_error () != bfd_error_system_call) | 1516 | 56.7k | bfd_set_error (bfd_error_wrong_format); | 1517 | 56.7k | return NULL; | 1518 | 56.7k | } | 1519 | | | 1520 | | /* There are really two magic numbers involved; the magic number | 1521 | | that says this is a NT executable (PEI) and the magic number that | 1522 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1523 | | the e_magic field. The latter is stored in the f_magic field. | 1524 | | If the NT magic number isn't valid, the architecture magic number | 1525 | | could be mimicked by some other field (specifically, the number | 1526 | | of relocs in section 3). Since this routine can only be called | 1527 | | correctly for a PEI file, check the e_magic number here, and, if | 1528 | | it doesn't match, clobber the f_magic number so that we don't get | 1529 | | a false match. */ | 1530 | 212k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1531 | 166k | { | 1532 | 166k | bfd_set_error (bfd_error_wrong_format); | 1533 | 166k | return NULL; | 1534 | 166k | } | 1535 | | | 1536 | 45.5k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1537 | 45.5k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1538 | 45.5k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1539 | 671 | { | 1540 | 671 | if (bfd_get_error () != bfd_error_system_call) | 1541 | 671 | bfd_set_error (bfd_error_wrong_format); | 1542 | 671 | return NULL; | 1543 | 671 | } | 1544 | | | 1545 | 44.8k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1546 | 833 | { | 1547 | 833 | bfd_set_error (bfd_error_wrong_format); | 1548 | 833 | return NULL; | 1549 | 833 | } | 1550 | | | 1551 | | /* Swap file header, so that we get the location for calling | 1552 | | real_object_p. */ | 1553 | 44.0k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1554 | | | 1555 | 44.0k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1556 | 7.20k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1557 | 36.8k | { | 1558 | 36.8k | bfd_set_error (bfd_error_wrong_format); | 1559 | 36.8k | return NULL; | 1560 | 36.8k | } | 1561 | | | 1562 | 7.15k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1563 | 7.15k | sizeof (internal_f.pe.dos_message)); | 1564 | | | 1565 | | /* Read the optional header, which has variable size. */ | 1566 | 7.15k | opt_hdr_size = internal_f.f_opthdr; | 1567 | | | 1568 | 7.15k | if (opt_hdr_size != 0) | 1569 | 4.15k | { | 1570 | 4.15k | bfd_size_type amt = opt_hdr_size; | 1571 | 4.15k | bfd_byte *opthdr; | 1572 | | | 1573 | | /* PR 17521 file: 230-131433-0.004. */ | 1574 | 4.15k | if (amt < sizeof (PEAOUTHDR)) | 1575 | 3.78k | amt = sizeof (PEAOUTHDR); | 1576 | | | 1577 | 4.15k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1578 | 4.15k | if (opthdr == NULL) | 1579 | 28 | return NULL; | 1580 | 4.13k | if (amt > opt_hdr_size) | 1581 | 3.76k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1582 | | | 1583 | 4.13k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1584 | | | 1585 | 4.13k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1586 | | | 1587 | 4.13k | #ifdef ARM | 1588 | | /* Use Subsystem to distinguish between pei-arm-little and | 1589 | | pei-arm-wince-little. */ | 1590 | | #ifdef WINCE | 1591 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1592 | | #else | 1593 | 4.13k | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1594 | 1.35k | #endif | 1595 | 1.35k | { | 1596 | 1.35k | bfd_set_error (bfd_error_wrong_format); | 1597 | 1.35k | return NULL; | 1598 | 1.35k | } | 1599 | 2.78k | #endif | 1600 | | | 1601 | 2.78k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1602 | 1.20k | || a->SectionAlignment >= 0x80000000) | 1603 | 1.61k | { | 1604 | 1.61k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1605 | 1.61k | abfd); | 1606 | 1.61k | a->SectionAlignment &= -a->SectionAlignment; | 1607 | 1.61k | if (a->SectionAlignment >= 0x80000000) | 1608 | 37 | a->SectionAlignment = 0x40000000; | 1609 | 1.61k | } | 1610 | | | 1611 | 2.78k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1612 | 1.34k | || a->FileAlignment > a->SectionAlignment) | 1613 | 1.71k | { | 1614 | 1.71k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1615 | 1.71k | abfd); | 1616 | 1.71k | a->FileAlignment &= -a->FileAlignment; | 1617 | 1.71k | if (a->FileAlignment > a->SectionAlignment) | 1618 | 1.38k | a->FileAlignment = a->SectionAlignment; | 1619 | 1.71k | } | 1620 | | | 1621 | 2.78k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1622 | 1.46k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1623 | 2.78k | } | 1624 | | | 1625 | 5.77k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1626 | 5.77k | (opt_hdr_size != 0 | 1627 | 5.77k | ? &internal_a | 1628 | 5.77k | : (struct internal_aouthdr *) NULL)); | 1629 | | | 1630 | 5.77k | if (result) | 1631 | 2.72k | { | 1632 | | /* Now the whole header has been processed, see if there is a build-id */ | 1633 | 2.72k | pe_bfd_read_buildid(abfd); | 1634 | 2.72k | } | 1635 | | | 1636 | 5.77k | return result; | 1637 | 7.15k | } |
pei-mcore.c:pe_bfd_object_p Line | Count | Source | 1487 | 273k | { | 1488 | 273k | bfd_byte buffer[6]; | 1489 | 273k | struct external_DOS_hdr dos_hdr; | 1490 | 273k | struct external_PEI_IMAGE_hdr image_hdr; | 1491 | 273k | struct internal_filehdr internal_f; | 1492 | 273k | struct internal_aouthdr internal_a; | 1493 | 273k | bfd_size_type opt_hdr_size; | 1494 | 273k | file_ptr offset; | 1495 | 273k | bfd_cleanup result; | 1496 | | | 1497 | | /* Detect if this a Microsoft Import Library Format element. */ | 1498 | | /* First read the beginning of the header. */ | 1499 | 273k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1500 | 273k | || bfd_read (buffer, 6, abfd) != 6) | 1501 | 2.01k | { | 1502 | 2.01k | if (bfd_get_error () != bfd_error_system_call) | 1503 | 1.94k | bfd_set_error (bfd_error_wrong_format); | 1504 | 2.01k | return NULL; | 1505 | 2.01k | } | 1506 | | | 1507 | | /* Then check the magic and the version (only 0 is supported). */ | 1508 | 271k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1509 | 2.37k | && H_GET_16 (abfd, buffer + 4) == 0) | 1510 | 1.98k | return pe_ILF_object_p (abfd); | 1511 | | | 1512 | 269k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1513 | 269k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1514 | 56.7k | { | 1515 | 56.7k | if (bfd_get_error () != bfd_error_system_call) | 1516 | 56.7k | bfd_set_error (bfd_error_wrong_format); | 1517 | 56.7k | return NULL; | 1518 | 56.7k | } | 1519 | | | 1520 | | /* There are really two magic numbers involved; the magic number | 1521 | | that says this is a NT executable (PEI) and the magic number that | 1522 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1523 | | the e_magic field. The latter is stored in the f_magic field. | 1524 | | If the NT magic number isn't valid, the architecture magic number | 1525 | | could be mimicked by some other field (specifically, the number | 1526 | | of relocs in section 3). Since this routine can only be called | 1527 | | correctly for a PEI file, check the e_magic number here, and, if | 1528 | | it doesn't match, clobber the f_magic number so that we don't get | 1529 | | a false match. */ | 1530 | 212k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1531 | 168k | { | 1532 | 168k | bfd_set_error (bfd_error_wrong_format); | 1533 | 168k | return NULL; | 1534 | 168k | } | 1535 | | | 1536 | 44.0k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1537 | 44.0k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1538 | 44.0k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1539 | 120 | { | 1540 | 120 | if (bfd_get_error () != bfd_error_system_call) | 1541 | 120 | bfd_set_error (bfd_error_wrong_format); | 1542 | 120 | return NULL; | 1543 | 120 | } | 1544 | | | 1545 | 43.8k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1546 | 223 | { | 1547 | 223 | bfd_set_error (bfd_error_wrong_format); | 1548 | 223 | return NULL; | 1549 | 223 | } | 1550 | | | 1551 | | /* Swap file header, so that we get the location for calling | 1552 | | real_object_p. */ | 1553 | 43.6k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1554 | | | 1555 | 43.6k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1556 | 4.51k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1557 | 39.1k | { | 1558 | 39.1k | bfd_set_error (bfd_error_wrong_format); | 1559 | 39.1k | return NULL; | 1560 | 39.1k | } | 1561 | | | 1562 | 4.49k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1563 | 4.49k | sizeof (internal_f.pe.dos_message)); | 1564 | | | 1565 | | /* Read the optional header, which has variable size. */ | 1566 | 4.49k | opt_hdr_size = internal_f.f_opthdr; | 1567 | | | 1568 | 4.49k | if (opt_hdr_size != 0) | 1569 | 2.57k | { | 1570 | 2.57k | bfd_size_type amt = opt_hdr_size; | 1571 | 2.57k | bfd_byte *opthdr; | 1572 | | | 1573 | | /* PR 17521 file: 230-131433-0.004. */ | 1574 | 2.57k | if (amt < sizeof (PEAOUTHDR)) | 1575 | 2.42k | amt = sizeof (PEAOUTHDR); | 1576 | | | 1577 | 2.57k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1578 | 2.57k | if (opthdr == NULL) | 1579 | 24 | return NULL; | 1580 | 2.55k | if (amt > opt_hdr_size) | 1581 | 2.40k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1582 | | | 1583 | 2.55k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1584 | | | 1585 | 2.55k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1586 | | | 1587 | | #ifdef ARM | 1588 | | /* Use Subsystem to distinguish between pei-arm-little and | 1589 | | pei-arm-wince-little. */ | 1590 | | #ifdef WINCE | 1591 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1592 | | #else | 1593 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1594 | | #endif | 1595 | | { | 1596 | | bfd_set_error (bfd_error_wrong_format); | 1597 | | return NULL; | 1598 | | } | 1599 | | #endif | 1600 | | | 1601 | 2.55k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1602 | 1.08k | || a->SectionAlignment >= 0x80000000) | 1603 | 1.50k | { | 1604 | 1.50k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1605 | 1.50k | abfd); | 1606 | 1.50k | a->SectionAlignment &= -a->SectionAlignment; | 1607 | 1.50k | if (a->SectionAlignment >= 0x80000000) | 1608 | 32 | a->SectionAlignment = 0x40000000; | 1609 | 1.50k | } | 1610 | | | 1611 | 2.55k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1612 | 1.19k | || a->FileAlignment > a->SectionAlignment) | 1613 | 1.65k | { | 1614 | 1.65k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1615 | 1.65k | abfd); | 1616 | 1.65k | a->FileAlignment &= -a->FileAlignment; | 1617 | 1.65k | if (a->FileAlignment > a->SectionAlignment) | 1618 | 1.40k | a->FileAlignment = a->SectionAlignment; | 1619 | 1.65k | } | 1620 | | | 1621 | 2.55k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1622 | 1.47k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1623 | 2.55k | } | 1624 | | | 1625 | 4.47k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1626 | 4.47k | (opt_hdr_size != 0 | 1627 | 4.47k | ? &internal_a | 1628 | 4.47k | : (struct internal_aouthdr *) NULL)); | 1629 | | | 1630 | 4.47k | if (result) | 1631 | 2.74k | { | 1632 | | /* Now the whole header has been processed, see if there is a build-id */ | 1633 | 2.74k | pe_bfd_read_buildid(abfd); | 1634 | 2.74k | } | 1635 | | | 1636 | 4.47k | return result; | 1637 | 4.49k | } |
Line | Count | Source | 1487 | 138k | { | 1488 | 138k | bfd_byte buffer[6]; | 1489 | 138k | struct external_DOS_hdr dos_hdr; | 1490 | 138k | struct external_PEI_IMAGE_hdr image_hdr; | 1491 | 138k | struct internal_filehdr internal_f; | 1492 | 138k | struct internal_aouthdr internal_a; | 1493 | 138k | bfd_size_type opt_hdr_size; | 1494 | 138k | file_ptr offset; | 1495 | 138k | bfd_cleanup result; | 1496 | | | 1497 | | /* Detect if this a Microsoft Import Library Format element. */ | 1498 | | /* First read the beginning of the header. */ | 1499 | 138k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1500 | 138k | || bfd_read (buffer, 6, abfd) != 6) | 1501 | 1.00k | { | 1502 | 1.00k | if (bfd_get_error () != bfd_error_system_call) | 1503 | 971 | bfd_set_error (bfd_error_wrong_format); | 1504 | 1.00k | return NULL; | 1505 | 1.00k | } | 1506 | | | 1507 | | /* Then check the magic and the version (only 0 is supported). */ | 1508 | 137k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1509 | 2.32k | && H_GET_16 (abfd, buffer + 4) == 0) | 1510 | 1.94k | return pe_ILF_object_p (abfd); | 1511 | | | 1512 | 135k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1513 | 135k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1514 | 27.5k | { | 1515 | 27.5k | if (bfd_get_error () != bfd_error_system_call) | 1516 | 27.5k | bfd_set_error (bfd_error_wrong_format); | 1517 | 27.5k | return NULL; | 1518 | 27.5k | } | 1519 | | | 1520 | | /* There are really two magic numbers involved; the magic number | 1521 | | that says this is a NT executable (PEI) and the magic number that | 1522 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1523 | | the e_magic field. The latter is stored in the f_magic field. | 1524 | | If the NT magic number isn't valid, the architecture magic number | 1525 | | could be mimicked by some other field (specifically, the number | 1526 | | of relocs in section 3). Since this routine can only be called | 1527 | | correctly for a PEI file, check the e_magic number here, and, if | 1528 | | it doesn't match, clobber the f_magic number so that we don't get | 1529 | | a false match. */ | 1530 | 108k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1531 | 64.1k | { | 1532 | 64.1k | bfd_set_error (bfd_error_wrong_format); | 1533 | 64.1k | return NULL; | 1534 | 64.1k | } | 1535 | | | 1536 | 44.0k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1537 | 44.0k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1538 | 44.0k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1539 | 119 | { | 1540 | 119 | if (bfd_get_error () != bfd_error_system_call) | 1541 | 119 | bfd_set_error (bfd_error_wrong_format); | 1542 | 119 | return NULL; | 1543 | 119 | } | 1544 | | | 1545 | 43.9k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1546 | 221 | { | 1547 | 221 | bfd_set_error (bfd_error_wrong_format); | 1548 | 221 | return NULL; | 1549 | 221 | } | 1550 | | | 1551 | | /* Swap file header, so that we get the location for calling | 1552 | | real_object_p. */ | 1553 | 43.6k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1554 | | | 1555 | 43.6k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1556 | 4.36k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1557 | 39.3k | { | 1558 | 39.3k | bfd_set_error (bfd_error_wrong_format); | 1559 | 39.3k | return NULL; | 1560 | 39.3k | } | 1561 | | | 1562 | 4.34k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1563 | 4.34k | sizeof (internal_f.pe.dos_message)); | 1564 | | | 1565 | | /* Read the optional header, which has variable size. */ | 1566 | 4.34k | opt_hdr_size = internal_f.f_opthdr; | 1567 | | | 1568 | 4.34k | if (opt_hdr_size != 0) | 1569 | 2.55k | { | 1570 | 2.55k | bfd_size_type amt = opt_hdr_size; | 1571 | 2.55k | bfd_byte *opthdr; | 1572 | | | 1573 | | /* PR 17521 file: 230-131433-0.004. */ | 1574 | 2.55k | if (amt < sizeof (PEAOUTHDR)) | 1575 | 2.38k | amt = sizeof (PEAOUTHDR); | 1576 | | | 1577 | 2.55k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1578 | 2.55k | if (opthdr == NULL) | 1579 | 25 | return NULL; | 1580 | 2.53k | if (amt > opt_hdr_size) | 1581 | 2.36k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1582 | | | 1583 | 2.53k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1584 | | | 1585 | 2.53k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1586 | | | 1587 | | #ifdef ARM | 1588 | | /* Use Subsystem to distinguish between pei-arm-little and | 1589 | | pei-arm-wince-little. */ | 1590 | | #ifdef WINCE | 1591 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1592 | | #else | 1593 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1594 | | #endif | 1595 | | { | 1596 | | bfd_set_error (bfd_error_wrong_format); | 1597 | | return NULL; | 1598 | | } | 1599 | | #endif | 1600 | | | 1601 | 2.53k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1602 | 1.30k | || a->SectionAlignment >= 0x80000000) | 1603 | 1.24k | { | 1604 | 1.24k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1605 | 1.24k | abfd); | 1606 | 1.24k | a->SectionAlignment &= -a->SectionAlignment; | 1607 | 1.24k | if (a->SectionAlignment >= 0x80000000) | 1608 | 16 | a->SectionAlignment = 0x40000000; | 1609 | 1.24k | } | 1610 | | | 1611 | 2.53k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1612 | 1.23k | || a->FileAlignment > a->SectionAlignment) | 1613 | 1.51k | { | 1614 | 1.51k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1615 | 1.51k | abfd); | 1616 | 1.51k | a->FileAlignment &= -a->FileAlignment; | 1617 | 1.51k | if (a->FileAlignment > a->SectionAlignment) | 1618 | 1.17k | a->FileAlignment = a->SectionAlignment; | 1619 | 1.51k | } | 1620 | | | 1621 | 2.53k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1622 | 1.40k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1623 | 2.53k | } | 1624 | | | 1625 | 4.31k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1626 | 4.31k | (opt_hdr_size != 0 | 1627 | 4.31k | ? &internal_a | 1628 | 4.31k | : (struct internal_aouthdr *) NULL)); | 1629 | | | 1630 | 4.31k | if (result) | 1631 | 2.64k | { | 1632 | | /* Now the whole header has been processed, see if there is a build-id */ | 1633 | 2.64k | pe_bfd_read_buildid(abfd); | 1634 | 2.64k | } | 1635 | | | 1636 | 4.31k | return result; | 1637 | 4.34k | } |
|
1638 | | |
1639 | 14.4k | #define coff_object_p pe_bfd_object_p |
1640 | | #endif /* COFF_IMAGE_WITH_PE */ |