/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 | 65.6k | { |
137 | 65.6k | RELOC *reloc_src = src; |
138 | 65.6k | struct internal_reloc *reloc_dst = dst; |
139 | | |
140 | 65.6k | memset (reloc_dst, 0, sizeof (*reloc_dst)); |
141 | 65.6k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); |
142 | 65.6k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); |
143 | 65.6k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); |
144 | | #ifdef SWAP_IN_RELOC_OFFSET |
145 | 28.3k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); |
146 | | #endif |
147 | 65.6k | } pei-i386.c:coff_swap_reloc_in Line | Count | Source | 136 | 3.73k | { | 137 | 3.73k | RELOC *reloc_src = src; | 138 | 3.73k | struct internal_reloc *reloc_dst = dst; | 139 | | | 140 | 3.73k | memset (reloc_dst, 0, sizeof (*reloc_dst)); | 141 | 3.73k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 142 | 3.73k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 143 | 3.73k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 144 | | #ifdef SWAP_IN_RELOC_OFFSET | 145 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 146 | | #endif | 147 | 3.73k | } |
pe-x86_64.c:coff_swap_reloc_in Line | Count | Source | 136 | 4.54k | { | 137 | 4.54k | RELOC *reloc_src = src; | 138 | 4.54k | struct internal_reloc *reloc_dst = dst; | 139 | | | 140 | 4.54k | memset (reloc_dst, 0, sizeof (*reloc_dst)); | 141 | 4.54k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 142 | 4.54k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 143 | 4.54k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 144 | | #ifdef SWAP_IN_RELOC_OFFSET | 145 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 146 | | #endif | 147 | 4.54k | } |
pei-x86_64.c:coff_swap_reloc_in Line | Count | Source | 136 | 5.35k | { | 137 | 5.35k | RELOC *reloc_src = src; | 138 | 5.35k | struct internal_reloc *reloc_dst = dst; | 139 | | | 140 | 5.35k | memset (reloc_dst, 0, sizeof (*reloc_dst)); | 141 | 5.35k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 142 | 5.35k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 143 | 5.35k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 144 | | #ifdef SWAP_IN_RELOC_OFFSET | 145 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 146 | | #endif | 147 | 5.35k | } |
pe-aarch64.c:coff_swap_reloc_in Line | Count | Source | 136 | 6.93k | { | 137 | 6.93k | RELOC *reloc_src = src; | 138 | 6.93k | struct internal_reloc *reloc_dst = dst; | 139 | | | 140 | 6.93k | memset (reloc_dst, 0, sizeof (*reloc_dst)); | 141 | 6.93k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 142 | 6.93k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 143 | 6.93k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 144 | | #ifdef SWAP_IN_RELOC_OFFSET | 145 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 146 | | #endif | 147 | 6.93k | } |
pei-aarch64.c:coff_swap_reloc_in Line | Count | Source | 136 | 4.57k | { | 137 | 4.57k | RELOC *reloc_src = src; | 138 | 4.57k | struct internal_reloc *reloc_dst = dst; | 139 | | | 140 | 4.57k | memset (reloc_dst, 0, sizeof (*reloc_dst)); | 141 | 4.57k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 142 | 4.57k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 143 | 4.57k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 144 | | #ifdef SWAP_IN_RELOC_OFFSET | 145 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 146 | | #endif | 147 | 4.57k | } |
pei-ia64.c:coff_swap_reloc_in Line | Count | Source | 136 | 3.57k | { | 137 | 3.57k | RELOC *reloc_src = src; | 138 | 3.57k | struct internal_reloc *reloc_dst = dst; | 139 | | | 140 | 3.57k | memset (reloc_dst, 0, sizeof (*reloc_dst)); | 141 | 3.57k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 142 | 3.57k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 143 | 3.57k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 144 | | #ifdef SWAP_IN_RELOC_OFFSET | 145 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 146 | | #endif | 147 | 3.57k | } |
pei-loongarch64.c:coff_swap_reloc_in Line | Count | Source | 136 | 4.12k | { | 137 | 4.12k | RELOC *reloc_src = src; | 138 | 4.12k | struct internal_reloc *reloc_dst = dst; | 139 | | | 140 | 4.12k | memset (reloc_dst, 0, sizeof (*reloc_dst)); | 141 | 4.12k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 142 | 4.12k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 143 | 4.12k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 144 | 4.12k | #ifdef SWAP_IN_RELOC_OFFSET | 145 | 4.12k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 146 | 4.12k | #endif | 147 | 4.12k | } |
pei-riscv64.c:coff_swap_reloc_in Line | Count | Source | 136 | 3.82k | { | 137 | 3.82k | RELOC *reloc_src = src; | 138 | 3.82k | struct internal_reloc *reloc_dst = dst; | 139 | | | 140 | 3.82k | memset (reloc_dst, 0, sizeof (*reloc_dst)); | 141 | 3.82k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 142 | 3.82k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 143 | 3.82k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 144 | 3.82k | #ifdef SWAP_IN_RELOC_OFFSET | 145 | 3.82k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 146 | 3.82k | #endif | 147 | 3.82k | } |
pe-arm-wince.c:coff_swap_reloc_in Line | Count | Source | 136 | 1.62k | { | 137 | 1.62k | RELOC *reloc_src = src; | 138 | 1.62k | struct internal_reloc *reloc_dst = dst; | 139 | | | 140 | 1.62k | memset (reloc_dst, 0, sizeof (*reloc_dst)); | 141 | 1.62k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 142 | 1.62k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 143 | 1.62k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 144 | 1.62k | #ifdef SWAP_IN_RELOC_OFFSET | 145 | 1.62k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 146 | 1.62k | #endif | 147 | 1.62k | } |
pe-arm.c:coff_swap_reloc_in Line | Count | Source | 136 | 1.62k | { | 137 | 1.62k | RELOC *reloc_src = src; | 138 | 1.62k | struct internal_reloc *reloc_dst = dst; | 139 | | | 140 | 1.62k | memset (reloc_dst, 0, sizeof (*reloc_dst)); | 141 | 1.62k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 142 | 1.62k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 143 | 1.62k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 144 | 1.62k | #ifdef SWAP_IN_RELOC_OFFSET | 145 | 1.62k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 146 | 1.62k | #endif | 147 | 1.62k | } |
pe-i386.c:coff_swap_reloc_in Line | Count | Source | 136 | 2.11k | { | 137 | 2.11k | RELOC *reloc_src = src; | 138 | 2.11k | struct internal_reloc *reloc_dst = dst; | 139 | | | 140 | 2.11k | memset (reloc_dst, 0, sizeof (*reloc_dst)); | 141 | 2.11k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 142 | 2.11k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 143 | 2.11k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 144 | | #ifdef SWAP_IN_RELOC_OFFSET | 145 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 146 | | #endif | 147 | 2.11k | } |
pe-mcore.c:coff_swap_reloc_in Line | Count | Source | 136 | 4.23k | { | 137 | 4.23k | RELOC *reloc_src = src; | 138 | 4.23k | struct internal_reloc *reloc_dst = dst; | 139 | | | 140 | 4.23k | memset (reloc_dst, 0, sizeof (*reloc_dst)); | 141 | 4.23k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 142 | 4.23k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 143 | 4.23k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 144 | 4.23k | #ifdef SWAP_IN_RELOC_OFFSET | 145 | 4.23k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 146 | 4.23k | #endif | 147 | 4.23k | } |
pe-sh.c:coff_swap_reloc_in Line | Count | Source | 136 | 3.48k | { | 137 | 3.48k | RELOC *reloc_src = src; | 138 | 3.48k | struct internal_reloc *reloc_dst = dst; | 139 | | | 140 | 3.48k | memset (reloc_dst, 0, sizeof (*reloc_dst)); | 141 | 3.48k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 142 | 3.48k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 143 | 3.48k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 144 | | #ifdef SWAP_IN_RELOC_OFFSET | 145 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 146 | | #endif | 147 | 3.48k | } |
pei-arm-wince.c:coff_swap_reloc_in Line | Count | Source | 136 | 4.31k | { | 137 | 4.31k | RELOC *reloc_src = src; | 138 | 4.31k | struct internal_reloc *reloc_dst = dst; | 139 | | | 140 | 4.31k | memset (reloc_dst, 0, sizeof (*reloc_dst)); | 141 | 4.31k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 142 | 4.31k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 143 | 4.31k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 144 | 4.31k | #ifdef SWAP_IN_RELOC_OFFSET | 145 | 4.31k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 146 | 4.31k | #endif | 147 | 4.31k | } |
pei-arm.c:coff_swap_reloc_in Line | Count | Source | 136 | 4.78k | { | 137 | 4.78k | RELOC *reloc_src = src; | 138 | 4.78k | struct internal_reloc *reloc_dst = dst; | 139 | | | 140 | 4.78k | memset (reloc_dst, 0, sizeof (*reloc_dst)); | 141 | 4.78k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 142 | 4.78k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 143 | 4.78k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 144 | 4.78k | #ifdef SWAP_IN_RELOC_OFFSET | 145 | 4.78k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 146 | 4.78k | #endif | 147 | 4.78k | } |
pei-mcore.c:coff_swap_reloc_in Line | Count | Source | 136 | 3.82k | { | 137 | 3.82k | RELOC *reloc_src = src; | 138 | 3.82k | struct internal_reloc *reloc_dst = dst; | 139 | | | 140 | 3.82k | memset (reloc_dst, 0, sizeof (*reloc_dst)); | 141 | 3.82k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 142 | 3.82k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 143 | 3.82k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 144 | 3.82k | #ifdef SWAP_IN_RELOC_OFFSET | 145 | 3.82k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 146 | 3.82k | #endif | 147 | 3.82k | } |
pei-sh.c:coff_swap_reloc_in Line | Count | Source | 136 | 2.97k | { | 137 | 2.97k | RELOC *reloc_src = src; | 138 | 2.97k | struct internal_reloc *reloc_dst = dst; | 139 | | | 140 | 2.97k | memset (reloc_dst, 0, sizeof (*reloc_dst)); | 141 | 2.97k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 142 | 2.97k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 143 | 2.97k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 144 | | #ifdef SWAP_IN_RELOC_OFFSET | 145 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 146 | | #endif | 147 | 2.97k | } |
|
148 | | |
149 | | static unsigned int |
150 | | coff_swap_reloc_out (bfd *abfd, void *src, void *dst) |
151 | 121 | { |
152 | 121 | struct internal_reloc *reloc_src = (struct internal_reloc *) src; |
153 | 121 | struct external_reloc *reloc_dst = (struct external_reloc *) dst; |
154 | | |
155 | 121 | H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr); |
156 | 121 | H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx); |
157 | 121 | H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type); |
158 | | |
159 | | #ifdef SWAP_OUT_RELOC_OFFSET |
160 | 52 | SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset); |
161 | | #endif |
162 | | #ifdef SWAP_OUT_RELOC_EXTRA |
163 | | SWAP_OUT_RELOC_EXTRA (abfd, reloc_src, reloc_dst); |
164 | | #endif |
165 | 121 | return RELSZ; |
166 | 121 | } pei-i386.c:coff_swap_reloc_out Line | Count | Source | 151 | 20 | { | 152 | 20 | struct internal_reloc *reloc_src = (struct internal_reloc *) src; | 153 | 20 | struct external_reloc *reloc_dst = (struct external_reloc *) dst; | 154 | | | 155 | 20 | H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr); | 156 | 20 | H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx); | 157 | 20 | H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type); | 158 | | | 159 | | #ifdef SWAP_OUT_RELOC_OFFSET | 160 | | SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset); | 161 | | #endif | 162 | | #ifdef SWAP_OUT_RELOC_EXTRA | 163 | | SWAP_OUT_RELOC_EXTRA (abfd, reloc_src, reloc_dst); | 164 | | #endif | 165 | 20 | return RELSZ; | 166 | 20 | } |
pe-x86_64.c:coff_swap_reloc_out Line | Count | Source | 151 | 2 | { | 152 | 2 | struct internal_reloc *reloc_src = (struct internal_reloc *) src; | 153 | 2 | struct external_reloc *reloc_dst = (struct external_reloc *) dst; | 154 | | | 155 | 2 | H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr); | 156 | 2 | H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx); | 157 | 2 | H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type); | 158 | | | 159 | | #ifdef SWAP_OUT_RELOC_OFFSET | 160 | | SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset); | 161 | | #endif | 162 | | #ifdef SWAP_OUT_RELOC_EXTRA | 163 | | SWAP_OUT_RELOC_EXTRA (abfd, reloc_src, reloc_dst); | 164 | | #endif | 165 | 2 | return RELSZ; | 166 | 2 | } |
pei-x86_64.c:coff_swap_reloc_out Line | Count | Source | 151 | 12 | { | 152 | 12 | struct internal_reloc *reloc_src = (struct internal_reloc *) src; | 153 | 12 | struct external_reloc *reloc_dst = (struct external_reloc *) dst; | 154 | | | 155 | 12 | H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr); | 156 | 12 | H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx); | 157 | 12 | H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type); | 158 | | | 159 | | #ifdef SWAP_OUT_RELOC_OFFSET | 160 | | SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset); | 161 | | #endif | 162 | | #ifdef SWAP_OUT_RELOC_EXTRA | 163 | | SWAP_OUT_RELOC_EXTRA (abfd, reloc_src, reloc_dst); | 164 | | #endif | 165 | 12 | return RELSZ; | 166 | 12 | } |
pe-aarch64.c:coff_swap_reloc_out Line | Count | Source | 151 | 2 | { | 152 | 2 | struct internal_reloc *reloc_src = (struct internal_reloc *) src; | 153 | 2 | struct external_reloc *reloc_dst = (struct external_reloc *) dst; | 154 | | | 155 | 2 | H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr); | 156 | 2 | H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx); | 157 | 2 | H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type); | 158 | | | 159 | | #ifdef SWAP_OUT_RELOC_OFFSET | 160 | | SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset); | 161 | | #endif | 162 | | #ifdef SWAP_OUT_RELOC_EXTRA | 163 | | SWAP_OUT_RELOC_EXTRA (abfd, reloc_src, reloc_dst); | 164 | | #endif | 165 | 2 | return RELSZ; | 166 | 2 | } |
pei-aarch64.c:coff_swap_reloc_out Line | Count | Source | 151 | 15 | { | 152 | 15 | struct internal_reloc *reloc_src = (struct internal_reloc *) src; | 153 | 15 | struct external_reloc *reloc_dst = (struct external_reloc *) dst; | 154 | | | 155 | 15 | H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr); | 156 | 15 | H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx); | 157 | 15 | H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type); | 158 | | | 159 | | #ifdef SWAP_OUT_RELOC_OFFSET | 160 | | SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset); | 161 | | #endif | 162 | | #ifdef SWAP_OUT_RELOC_EXTRA | 163 | | SWAP_OUT_RELOC_EXTRA (abfd, reloc_src, reloc_dst); | 164 | | #endif | 165 | 15 | return RELSZ; | 166 | 15 | } |
Unexecuted instantiation: pei-ia64.c:coff_swap_reloc_out pei-loongarch64.c:coff_swap_reloc_out Line | Count | Source | 151 | 27 | { | 152 | 27 | struct internal_reloc *reloc_src = (struct internal_reloc *) src; | 153 | 27 | struct external_reloc *reloc_dst = (struct external_reloc *) dst; | 154 | | | 155 | 27 | H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr); | 156 | 27 | H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx); | 157 | 27 | H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type); | 158 | | | 159 | 27 | #ifdef SWAP_OUT_RELOC_OFFSET | 160 | 27 | SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset); | 161 | 27 | #endif | 162 | | #ifdef SWAP_OUT_RELOC_EXTRA | 163 | | SWAP_OUT_RELOC_EXTRA (abfd, reloc_src, reloc_dst); | 164 | | #endif | 165 | 27 | return RELSZ; | 166 | 27 | } |
pei-riscv64.c:coff_swap_reloc_out Line | Count | Source | 151 | 15 | { | 152 | 15 | struct internal_reloc *reloc_src = (struct internal_reloc *) src; | 153 | 15 | struct external_reloc *reloc_dst = (struct external_reloc *) dst; | 154 | | | 155 | 15 | H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr); | 156 | 15 | H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx); | 157 | 15 | H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type); | 158 | | | 159 | 15 | #ifdef SWAP_OUT_RELOC_OFFSET | 160 | 15 | SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset); | 161 | 15 | #endif | 162 | | #ifdef SWAP_OUT_RELOC_EXTRA | 163 | | SWAP_OUT_RELOC_EXTRA (abfd, reloc_src, reloc_dst); | 164 | | #endif | 165 | 15 | return RELSZ; | 166 | 15 | } |
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 pe-mcore.c:coff_swap_reloc_out Line | Count | Source | 151 | 7 | { | 152 | 7 | struct internal_reloc *reloc_src = (struct internal_reloc *) src; | 153 | 7 | struct external_reloc *reloc_dst = (struct external_reloc *) dst; | 154 | | | 155 | 7 | H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr); | 156 | 7 | H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx); | 157 | 7 | H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type); | 158 | | | 159 | 7 | #ifdef SWAP_OUT_RELOC_OFFSET | 160 | 7 | SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset); | 161 | 7 | #endif | 162 | | #ifdef SWAP_OUT_RELOC_EXTRA | 163 | | SWAP_OUT_RELOC_EXTRA (abfd, reloc_src, reloc_dst); | 164 | | #endif | 165 | 7 | return RELSZ; | 166 | 7 | } |
Unexecuted instantiation: pe-sh.c:coff_swap_reloc_out Unexecuted instantiation: pei-arm-wince.c:coff_swap_reloc_out pei-arm.c:coff_swap_reloc_out Line | Count | Source | 151 | 3 | { | 152 | 3 | struct internal_reloc *reloc_src = (struct internal_reloc *) src; | 153 | 3 | struct external_reloc *reloc_dst = (struct external_reloc *) dst; | 154 | | | 155 | 3 | H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr); | 156 | 3 | H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx); | 157 | 3 | H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type); | 158 | | | 159 | 3 | #ifdef SWAP_OUT_RELOC_OFFSET | 160 | 3 | SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset); | 161 | 3 | #endif | 162 | | #ifdef SWAP_OUT_RELOC_EXTRA | 163 | | SWAP_OUT_RELOC_EXTRA (abfd, reloc_src, reloc_dst); | 164 | | #endif | 165 | 3 | return RELSZ; | 166 | 3 | } |
Unexecuted instantiation: pei-mcore.c:coff_swap_reloc_out pei-sh.c:coff_swap_reloc_out Line | Count | Source | 151 | 18 | { | 152 | 18 | struct internal_reloc *reloc_src = (struct internal_reloc *) src; | 153 | 18 | struct external_reloc *reloc_dst = (struct external_reloc *) dst; | 154 | | | 155 | 18 | H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr); | 156 | 18 | H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx); | 157 | 18 | H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type); | 158 | | | 159 | | #ifdef SWAP_OUT_RELOC_OFFSET | 160 | | SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset); | 161 | | #endif | 162 | | #ifdef SWAP_OUT_RELOC_EXTRA | 163 | | SWAP_OUT_RELOC_EXTRA (abfd, reloc_src, reloc_dst); | 164 | | #endif | 165 | 18 | return RELSZ; | 166 | 18 | } |
|
167 | | #endif /* not NO_COFF_RELOCS */ |
168 | | |
169 | | #ifdef COFF_IMAGE_WITH_PE |
170 | | #undef FILHDR |
171 | 492k | #define FILHDR struct external_PEI_IMAGE_hdr |
172 | | #endif |
173 | | |
174 | | static void |
175 | | coff_swap_filehdr_in (bfd *abfd, void *src, void *dst) |
176 | 2.47M | { |
177 | 2.47M | FILHDR *filehdr_src = (FILHDR *) src; |
178 | 2.47M | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; |
179 | | |
180 | 2.47M | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); |
181 | 2.47M | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); |
182 | 2.47M | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); |
183 | 2.47M | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); |
184 | 2.47M | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); |
185 | 2.47M | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); |
186 | | |
187 | | /* Other people's tools sometimes generate headers with an nsyms but |
188 | | a zero symptr. */ |
189 | 2.47M | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) |
190 | 257k | { |
191 | 257k | filehdr_dst->f_nsyms = 0; |
192 | 257k | filehdr_dst->f_flags |= F_LSYMS; |
193 | 257k | } |
194 | | |
195 | 2.47M | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); |
196 | 2.47M | } pei-i386.c:coff_swap_filehdr_in Line | Count | Source | 176 | 55.6k | { | 177 | 55.6k | FILHDR *filehdr_src = (FILHDR *) src; | 178 | 55.6k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 179 | | | 180 | 55.6k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 181 | 55.6k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 182 | 55.6k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 183 | 55.6k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 184 | 55.6k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 185 | 55.6k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 186 | | | 187 | | /* Other people's tools sometimes generate headers with an nsyms but | 188 | | a zero symptr. */ | 189 | 55.6k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 190 | 5.50k | { | 191 | 5.50k | filehdr_dst->f_nsyms = 0; | 192 | 5.50k | filehdr_dst->f_flags |= F_LSYMS; | 193 | 5.50k | } | 194 | | | 195 | 55.6k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 196 | 55.6k | } |
pe-x86_64.c:coff_swap_filehdr_in Line | Count | Source | 176 | 217k | { | 177 | 217k | FILHDR *filehdr_src = (FILHDR *) src; | 178 | 217k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 179 | | | 180 | 217k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 181 | 217k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 182 | 217k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 183 | 217k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 184 | 217k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 185 | 217k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 186 | | | 187 | | /* Other people's tools sometimes generate headers with an nsyms but | 188 | | a zero symptr. */ | 189 | 217k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 190 | 24.0k | { | 191 | 24.0k | filehdr_dst->f_nsyms = 0; | 192 | 24.0k | filehdr_dst->f_flags |= F_LSYMS; | 193 | 24.0k | } | 194 | | | 195 | 217k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 196 | 217k | } |
pei-x86_64.c:coff_swap_filehdr_in Line | Count | Source | 176 | 54.5k | { | 177 | 54.5k | FILHDR *filehdr_src = (FILHDR *) src; | 178 | 54.5k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 179 | | | 180 | 54.5k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 181 | 54.5k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 182 | 54.5k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 183 | 54.5k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 184 | 54.5k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 185 | 54.5k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 186 | | | 187 | | /* Other people's tools sometimes generate headers with an nsyms but | 188 | | a zero symptr. */ | 189 | 54.5k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 190 | 5.38k | { | 191 | 5.38k | filehdr_dst->f_nsyms = 0; | 192 | 5.38k | filehdr_dst->f_flags |= F_LSYMS; | 193 | 5.38k | } | 194 | | | 195 | 54.5k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 196 | 54.5k | } |
pe-aarch64.c:coff_swap_filehdr_in Line | Count | Source | 176 | 217k | { | 177 | 217k | FILHDR *filehdr_src = (FILHDR *) src; | 178 | 217k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 179 | | | 180 | 217k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 181 | 217k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 182 | 217k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 183 | 217k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 184 | 217k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 185 | 217k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 186 | | | 187 | | /* Other people's tools sometimes generate headers with an nsyms but | 188 | | a zero symptr. */ | 189 | 217k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 190 | 24.1k | { | 191 | 24.1k | filehdr_dst->f_nsyms = 0; | 192 | 24.1k | filehdr_dst->f_flags |= F_LSYMS; | 193 | 24.1k | } | 194 | | | 195 | 217k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 196 | 217k | } |
pei-aarch64.c:coff_swap_filehdr_in Line | Count | Source | 176 | 52.7k | { | 177 | 52.7k | FILHDR *filehdr_src = (FILHDR *) src; | 178 | 52.7k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 179 | | | 180 | 52.7k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 181 | 52.7k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 182 | 52.7k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 183 | 52.7k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 184 | 52.7k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 185 | 52.7k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 186 | | | 187 | | /* Other people's tools sometimes generate headers with an nsyms but | 188 | | a zero symptr. */ | 189 | 52.7k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 190 | 5.14k | { | 191 | 5.14k | filehdr_dst->f_nsyms = 0; | 192 | 5.14k | filehdr_dst->f_flags |= F_LSYMS; | 193 | 5.14k | } | 194 | | | 195 | 52.7k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 196 | 52.7k | } |
pei-ia64.c:coff_swap_filehdr_in Line | Count | Source | 176 | 16.9k | { | 177 | 16.9k | FILHDR *filehdr_src = (FILHDR *) src; | 178 | 16.9k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 179 | | | 180 | 16.9k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 181 | 16.9k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 182 | 16.9k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 183 | 16.9k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 184 | 16.9k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 185 | 16.9k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 186 | | | 187 | | /* Other people's tools sometimes generate headers with an nsyms but | 188 | | a zero symptr. */ | 189 | 16.9k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 190 | 711 | { | 191 | 711 | filehdr_dst->f_nsyms = 0; | 192 | 711 | filehdr_dst->f_flags |= F_LSYMS; | 193 | 711 | } | 194 | | | 195 | 16.9k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 196 | 16.9k | } |
pei-loongarch64.c:coff_swap_filehdr_in Line | Count | Source | 176 | 53.3k | { | 177 | 53.3k | FILHDR *filehdr_src = (FILHDR *) src; | 178 | 53.3k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 179 | | | 180 | 53.3k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 181 | 53.3k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 182 | 53.3k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 183 | 53.3k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 184 | 53.3k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 185 | 53.3k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 186 | | | 187 | | /* Other people's tools sometimes generate headers with an nsyms but | 188 | | a zero symptr. */ | 189 | 53.3k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 190 | 5.24k | { | 191 | 5.24k | filehdr_dst->f_nsyms = 0; | 192 | 5.24k | filehdr_dst->f_flags |= F_LSYMS; | 193 | 5.24k | } | 194 | | | 195 | 53.3k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 196 | 53.3k | } |
pei-riscv64.c:coff_swap_filehdr_in Line | Count | Source | 176 | 53.4k | { | 177 | 53.4k | FILHDR *filehdr_src = (FILHDR *) src; | 178 | 53.4k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 179 | | | 180 | 53.4k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 181 | 53.4k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 182 | 53.4k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 183 | 53.4k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 184 | 53.4k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 185 | 53.4k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 186 | | | 187 | | /* Other people's tools sometimes generate headers with an nsyms but | 188 | | a zero symptr. */ | 189 | 53.4k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 190 | 5.15k | { | 191 | 5.15k | filehdr_dst->f_nsyms = 0; | 192 | 5.15k | filehdr_dst->f_flags |= F_LSYMS; | 193 | 5.15k | } | 194 | | | 195 | 53.4k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 196 | 53.4k | } |
pe-arm-wince.c:coff_swap_filehdr_in Line | Count | Source | 176 | 378k | { | 177 | 378k | FILHDR *filehdr_src = (FILHDR *) src; | 178 | 378k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 179 | | | 180 | 378k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 181 | 378k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 182 | 378k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 183 | 378k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 184 | 378k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 185 | 378k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 186 | | | 187 | | /* Other people's tools sometimes generate headers with an nsyms but | 188 | | a zero symptr. */ | 189 | 378k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 190 | 39.3k | { | 191 | 39.3k | filehdr_dst->f_nsyms = 0; | 192 | 39.3k | filehdr_dst->f_flags |= F_LSYMS; | 193 | 39.3k | } | 194 | | | 195 | 378k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 196 | 378k | } |
pe-arm.c:coff_swap_filehdr_in Line | Count | Source | 176 | 378k | { | 177 | 378k | FILHDR *filehdr_src = (FILHDR *) src; | 178 | 378k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 179 | | | 180 | 378k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 181 | 378k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 182 | 378k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 183 | 378k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 184 | 378k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 185 | 378k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 186 | | | 187 | | /* Other people's tools sometimes generate headers with an nsyms but | 188 | | a zero symptr. */ | 189 | 378k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 190 | 39.3k | { | 191 | 39.3k | filehdr_dst->f_nsyms = 0; | 192 | 39.3k | filehdr_dst->f_flags |= F_LSYMS; | 193 | 39.3k | } | 194 | | | 195 | 378k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 196 | 378k | } |
pe-i386.c:coff_swap_filehdr_in Line | Count | Source | 176 | 217k | { | 177 | 217k | FILHDR *filehdr_src = (FILHDR *) src; | 178 | 217k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 179 | | | 180 | 217k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 181 | 217k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 182 | 217k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 183 | 217k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 184 | 217k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 185 | 217k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 186 | | | 187 | | /* Other people's tools sometimes generate headers with an nsyms but | 188 | | a zero symptr. */ | 189 | 217k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 190 | 24.0k | { | 191 | 24.0k | filehdr_dst->f_nsyms = 0; | 192 | 24.0k | filehdr_dst->f_flags |= F_LSYMS; | 193 | 24.0k | } | 194 | | | 195 | 217k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 196 | 217k | } |
pe-mcore.c:coff_swap_filehdr_in Line | Count | Source | 176 | 378k | { | 177 | 378k | FILHDR *filehdr_src = (FILHDR *) src; | 178 | 378k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 179 | | | 180 | 378k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 181 | 378k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 182 | 378k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 183 | 378k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 184 | 378k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 185 | 378k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 186 | | | 187 | | /* Other people's tools sometimes generate headers with an nsyms but | 188 | | a zero symptr. */ | 189 | 378k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 190 | 39.3k | { | 191 | 39.3k | filehdr_dst->f_nsyms = 0; | 192 | 39.3k | filehdr_dst->f_flags |= F_LSYMS; | 193 | 39.3k | } | 194 | | | 195 | 378k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 196 | 378k | } |
pe-sh.c:coff_swap_filehdr_in Line | Count | Source | 176 | 190k | { | 177 | 190k | FILHDR *filehdr_src = (FILHDR *) src; | 178 | 190k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 179 | | | 180 | 190k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 181 | 190k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 182 | 190k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 183 | 190k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 184 | 190k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 185 | 190k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 186 | | | 187 | | /* Other people's tools sometimes generate headers with an nsyms but | 188 | | a zero symptr. */ | 189 | 190k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 190 | 19.7k | { | 191 | 19.7k | filehdr_dst->f_nsyms = 0; | 192 | 19.7k | filehdr_dst->f_flags |= F_LSYMS; | 193 | 19.7k | } | 194 | | | 195 | 190k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 196 | 190k | } |
pei-arm-wince.c:coff_swap_filehdr_in Line | Count | Source | 176 | 50.7k | { | 177 | 50.7k | FILHDR *filehdr_src = (FILHDR *) src; | 178 | 50.7k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 179 | | | 180 | 50.7k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 181 | 50.7k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 182 | 50.7k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 183 | 50.7k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 184 | 50.7k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 185 | 50.7k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 186 | | | 187 | | /* Other people's tools sometimes generate headers with an nsyms but | 188 | | a zero symptr. */ | 189 | 50.7k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 190 | 5.05k | { | 191 | 5.05k | filehdr_dst->f_nsyms = 0; | 192 | 5.05k | filehdr_dst->f_flags |= F_LSYMS; | 193 | 5.05k | } | 194 | | | 195 | 50.7k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 196 | 50.7k | } |
pei-arm.c:coff_swap_filehdr_in Line | Count | Source | 176 | 51.1k | { | 177 | 51.1k | FILHDR *filehdr_src = (FILHDR *) src; | 178 | 51.1k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 179 | | | 180 | 51.1k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 181 | 51.1k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 182 | 51.1k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 183 | 51.1k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 184 | 51.1k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 185 | 51.1k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 186 | | | 187 | | /* Other people's tools sometimes generate headers with an nsyms but | 188 | | a zero symptr. */ | 189 | 51.1k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 190 | 5.04k | { | 191 | 5.04k | filehdr_dst->f_nsyms = 0; | 192 | 5.04k | filehdr_dst->f_flags |= F_LSYMS; | 193 | 5.04k | } | 194 | | | 195 | 51.1k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 196 | 51.1k | } |
pei-mcore.c:coff_swap_filehdr_in Line | Count | Source | 176 | 51.9k | { | 177 | 51.9k | FILHDR *filehdr_src = (FILHDR *) src; | 178 | 51.9k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 179 | | | 180 | 51.9k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 181 | 51.9k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 182 | 51.9k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 183 | 51.9k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 184 | 51.9k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 185 | 51.9k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 186 | | | 187 | | /* Other people's tools sometimes generate headers with an nsyms but | 188 | | a zero symptr. */ | 189 | 51.9k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 190 | 5.11k | { | 191 | 5.11k | filehdr_dst->f_nsyms = 0; | 192 | 5.11k | filehdr_dst->f_flags |= F_LSYMS; | 193 | 5.11k | } | 194 | | | 195 | 51.9k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 196 | 51.9k | } |
pei-sh.c:coff_swap_filehdr_in Line | Count | Source | 176 | 51.9k | { | 177 | 51.9k | FILHDR *filehdr_src = (FILHDR *) src; | 178 | 51.9k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 179 | | | 180 | 51.9k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 181 | 51.9k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 182 | 51.9k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 183 | 51.9k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 184 | 51.9k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 185 | 51.9k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 186 | | | 187 | | /* Other people's tools sometimes generate headers with an nsyms but | 188 | | a zero symptr. */ | 189 | 51.9k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 190 | 5.09k | { | 191 | 5.09k | filehdr_dst->f_nsyms = 0; | 192 | 5.09k | filehdr_dst->f_flags |= F_LSYMS; | 193 | 5.09k | } | 194 | | | 195 | 51.9k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 196 | 51.9k | } |
|
197 | | |
198 | | #ifdef COFF_IMAGE_WITH_PE |
199 | | # define coff_swap_filehdr_out _bfd_XXi_only_swap_filehdr_out |
200 | | #elif defined COFF_WITH_peAArch64 |
201 | | # define coff_swap_filehdr_out _bfd_XX_only_swap_filehdr_out |
202 | | #elif defined COFF_WITH_pex64 |
203 | | # define coff_swap_filehdr_out _bfd_pex64_only_swap_filehdr_out |
204 | | #elif defined COFF_WITH_pep |
205 | | # define coff_swap_filehdr_out _bfd_pep_only_swap_filehdr_out |
206 | | #else |
207 | | # define coff_swap_filehdr_out _bfd_pe_only_swap_filehdr_out |
208 | | #endif |
209 | | |
210 | | static void |
211 | | coff_swap_scnhdr_in (bfd *abfd, void *ext, void *in) |
212 | 814k | { |
213 | 814k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; |
214 | 814k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; |
215 | | |
216 | 814k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); |
217 | | |
218 | 814k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); |
219 | 814k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); |
220 | 814k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); |
221 | 814k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); |
222 | 814k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); |
223 | 814k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); |
224 | 814k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); |
225 | | |
226 | | /* MS handles overflow of line numbers by carrying into the reloc |
227 | | field (it appears). Since it's supposed to be zero for PE |
228 | | *IMAGE* format, that's safe. This is still a bit iffy. */ |
229 | | #ifdef COFF_IMAGE_WITH_PE |
230 | 576k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) |
231 | 576k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); |
232 | | scnhdr_int->s_nreloc = 0; |
233 | | #else |
234 | 238k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); |
235 | 238k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); |
236 | | #endif |
237 | | |
238 | 814k | if (scnhdr_int->s_vaddr != 0) |
239 | 536k | { |
240 | 536k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; |
241 | | /* Do not cut upper 32-bits for 64-bit vma. */ |
242 | | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ |
243 | | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) |
244 | | scnhdr_int->s_vaddr &= 0xffffffff; |
245 | | #endif |
246 | 536k | } |
247 | | |
248 | 814k | #ifndef COFF_NO_HACK_SCNHDR_SIZE |
249 | | /* If this section holds uninitialized data and is from an object file |
250 | | or from an executable image that has not initialized the field, |
251 | | or if the image is an executable file and the physical size is padded, |
252 | | use the virtual size (stored in s_paddr) instead. */ |
253 | 814k | if (scnhdr_int->s_paddr > 0 |
254 | 595k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 |
255 | 127k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) |
256 | 548k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) |
257 | | /* This code used to set scnhdr_int->s_paddr to 0. However, |
258 | | coff_set_alignment_hook stores s_paddr in virt_size, which |
259 | | only works if it correctly holds the virtual size of the |
260 | | section. */ |
261 | 171k | scnhdr_int->s_size = scnhdr_int->s_paddr; |
262 | 814k | #endif |
263 | 814k | } pei-i386.c:coff_swap_scnhdr_in Line | Count | Source | 212 | 58.2k | { | 213 | 58.2k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 214 | 58.2k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 215 | | | 216 | 58.2k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 217 | | | 218 | 58.2k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 219 | 58.2k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 220 | 58.2k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 221 | 58.2k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 222 | 58.2k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 223 | 58.2k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 224 | 58.2k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 225 | | | 226 | | /* MS handles overflow of line numbers by carrying into the reloc | 227 | | field (it appears). Since it's supposed to be zero for PE | 228 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 229 | 58.2k | #ifdef COFF_IMAGE_WITH_PE | 230 | 58.2k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 231 | 58.2k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 232 | 58.2k | scnhdr_int->s_nreloc = 0; | 233 | | #else | 234 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 235 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 236 | | #endif | 237 | | | 238 | 58.2k | if (scnhdr_int->s_vaddr != 0) | 239 | 37.7k | { | 240 | 37.7k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 241 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 242 | 37.7k | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 243 | 37.7k | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 244 | 37.7k | scnhdr_int->s_vaddr &= 0xffffffff; | 245 | 37.7k | #endif | 246 | 37.7k | } | 247 | | | 248 | 58.2k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 249 | | /* If this section holds uninitialized data and is from an object file | 250 | | or from an executable image that has not initialized the field, | 251 | | or if the image is an executable file and the physical size is padded, | 252 | | use the virtual size (stored in s_paddr) instead. */ | 253 | 58.2k | if (scnhdr_int->s_paddr > 0 | 254 | 43.5k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 255 | 8.55k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 256 | 42.4k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 257 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 258 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 259 | | only works if it correctly holds the virtual size of the | 260 | | section. */ | 261 | 15.9k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 262 | 58.2k | #endif | 263 | 58.2k | } |
pe-x86_64.c:coff_swap_scnhdr_in Line | Count | Source | 212 | 32.1k | { | 213 | 32.1k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 214 | 32.1k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 215 | | | 216 | 32.1k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 217 | | | 218 | 32.1k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 219 | 32.1k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 220 | 32.1k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 221 | 32.1k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 222 | 32.1k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 223 | 32.1k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 224 | 32.1k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 225 | | | 226 | | /* MS handles overflow of line numbers by carrying into the reloc | 227 | | field (it appears). Since it's supposed to be zero for PE | 228 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 229 | | #ifdef COFF_IMAGE_WITH_PE | 230 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 231 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 232 | | scnhdr_int->s_nreloc = 0; | 233 | | #else | 234 | 32.1k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 235 | 32.1k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 236 | 32.1k | #endif | 237 | | | 238 | 32.1k | if (scnhdr_int->s_vaddr != 0) | 239 | 17.5k | { | 240 | 17.5k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 241 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 242 | | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 243 | | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 244 | | scnhdr_int->s_vaddr &= 0xffffffff; | 245 | | #endif | 246 | 17.5k | } | 247 | | | 248 | 32.1k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 249 | | /* If this section holds uninitialized data and is from an object file | 250 | | or from an executable image that has not initialized the field, | 251 | | or if the image is an executable file and the physical size is padded, | 252 | | use the virtual size (stored in s_paddr) instead. */ | 253 | 32.1k | if (scnhdr_int->s_paddr > 0 | 254 | 19.3k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 255 | 3.71k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 256 | 15.6k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 257 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 258 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 259 | | only works if it correctly holds the virtual size of the | 260 | | section. */ | 261 | 3.71k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 262 | 32.1k | #endif | 263 | 32.1k | } |
pei-x86_64.c:coff_swap_scnhdr_in Line | Count | Source | 212 | 60.2k | { | 213 | 60.2k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 214 | 60.2k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 215 | | | 216 | 60.2k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 217 | | | 218 | 60.2k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 219 | 60.2k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 220 | 60.2k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 221 | 60.2k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 222 | 60.2k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 223 | 60.2k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 224 | 60.2k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 225 | | | 226 | | /* MS handles overflow of line numbers by carrying into the reloc | 227 | | field (it appears). Since it's supposed to be zero for PE | 228 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 229 | 60.2k | #ifdef COFF_IMAGE_WITH_PE | 230 | 60.2k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 231 | 60.2k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 232 | 60.2k | scnhdr_int->s_nreloc = 0; | 233 | | #else | 234 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 235 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 236 | | #endif | 237 | | | 238 | 60.2k | if (scnhdr_int->s_vaddr != 0) | 239 | 38.9k | { | 240 | 38.9k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 241 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 242 | | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 243 | | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 244 | | scnhdr_int->s_vaddr &= 0xffffffff; | 245 | | #endif | 246 | 38.9k | } | 247 | | | 248 | 60.2k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 249 | | /* If this section holds uninitialized data and is from an object file | 250 | | or from an executable image that has not initialized the field, | 251 | | or if the image is an executable file and the physical size is padded, | 252 | | use the virtual size (stored in s_paddr) instead. */ | 253 | 60.2k | if (scnhdr_int->s_paddr > 0 | 254 | 42.7k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 255 | 8.74k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 256 | 41.7k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 257 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 258 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 259 | | only works if it correctly holds the virtual size of the | 260 | | section. */ | 261 | 14.7k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 262 | 60.2k | #endif | 263 | 60.2k | } |
pe-aarch64.c:coff_swap_scnhdr_in Line | Count | Source | 212 | 48.6k | { | 213 | 48.6k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 214 | 48.6k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 215 | | | 216 | 48.6k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 217 | | | 218 | 48.6k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 219 | 48.6k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 220 | 48.6k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 221 | 48.6k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 222 | 48.6k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 223 | 48.6k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 224 | 48.6k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 225 | | | 226 | | /* MS handles overflow of line numbers by carrying into the reloc | 227 | | field (it appears). Since it's supposed to be zero for PE | 228 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 229 | | #ifdef COFF_IMAGE_WITH_PE | 230 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 231 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 232 | | scnhdr_int->s_nreloc = 0; | 233 | | #else | 234 | 48.6k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 235 | 48.6k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 236 | 48.6k | #endif | 237 | | | 238 | 48.6k | if (scnhdr_int->s_vaddr != 0) | 239 | 32.8k | { | 240 | 32.8k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 241 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 242 | | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 243 | | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 244 | | scnhdr_int->s_vaddr &= 0xffffffff; | 245 | | #endif | 246 | 32.8k | } | 247 | | | 248 | 48.6k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 249 | | /* If this section holds uninitialized data and is from an object file | 250 | | or from an executable image that has not initialized the field, | 251 | | or if the image is an executable file and the physical size is padded, | 252 | | use the virtual size (stored in s_paddr) instead. */ | 253 | 48.6k | if (scnhdr_int->s_paddr > 0 | 254 | 35.0k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 255 | 5.91k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 256 | 29.1k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 257 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 258 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 259 | | only works if it correctly holds the virtual size of the | 260 | | section. */ | 261 | 5.91k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 262 | 48.6k | #endif | 263 | 48.6k | } |
pei-aarch64.c:coff_swap_scnhdr_in Line | Count | Source | 212 | 67.2k | { | 213 | 67.2k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 214 | 67.2k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 215 | | | 216 | 67.2k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 217 | | | 218 | 67.2k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 219 | 67.2k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 220 | 67.2k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 221 | 67.2k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 222 | 67.2k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 223 | 67.2k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 224 | 67.2k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 225 | | | 226 | | /* MS handles overflow of line numbers by carrying into the reloc | 227 | | field (it appears). Since it's supposed to be zero for PE | 228 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 229 | 67.2k | #ifdef COFF_IMAGE_WITH_PE | 230 | 67.2k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 231 | 67.2k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 232 | 67.2k | scnhdr_int->s_nreloc = 0; | 233 | | #else | 234 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 235 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 236 | | #endif | 237 | | | 238 | 67.2k | if (scnhdr_int->s_vaddr != 0) | 239 | 47.8k | { | 240 | 47.8k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 241 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 242 | | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 243 | | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 244 | | scnhdr_int->s_vaddr &= 0xffffffff; | 245 | | #endif | 246 | 47.8k | } | 247 | | | 248 | 67.2k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 249 | | /* If this section holds uninitialized data and is from an object file | 250 | | or from an executable image that has not initialized the field, | 251 | | or if the image is an executable file and the physical size is padded, | 252 | | use the virtual size (stored in s_paddr) instead. */ | 253 | 67.2k | if (scnhdr_int->s_paddr > 0 | 254 | 50.0k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 255 | 10.0k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 256 | 48.6k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 257 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 258 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 259 | | only works if it correctly holds the virtual size of the | 260 | | section. */ | 261 | 18.6k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 262 | 67.2k | #endif | 263 | 67.2k | } |
pei-ia64.c:coff_swap_scnhdr_in Line | Count | Source | 212 | 58.2k | { | 213 | 58.2k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 214 | 58.2k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 215 | | | 216 | 58.2k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 217 | | | 218 | 58.2k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 219 | 58.2k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 220 | 58.2k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 221 | 58.2k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 222 | 58.2k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 223 | 58.2k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 224 | 58.2k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 225 | | | 226 | | /* MS handles overflow of line numbers by carrying into the reloc | 227 | | field (it appears). Since it's supposed to be zero for PE | 228 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 229 | 58.2k | #ifdef COFF_IMAGE_WITH_PE | 230 | 58.2k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 231 | 58.2k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 232 | 58.2k | scnhdr_int->s_nreloc = 0; | 233 | | #else | 234 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 235 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 236 | | #endif | 237 | | | 238 | 58.2k | if (scnhdr_int->s_vaddr != 0) | 239 | 39.1k | { | 240 | 39.1k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 241 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 242 | 39.1k | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 243 | 39.1k | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 244 | 39.1k | scnhdr_int->s_vaddr &= 0xffffffff; | 245 | 39.1k | #endif | 246 | 39.1k | } | 247 | | | 248 | 58.2k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 249 | | /* If this section holds uninitialized data and is from an object file | 250 | | or from an executable image that has not initialized the field, | 251 | | or if the image is an executable file and the physical size is padded, | 252 | | use the virtual size (stored in s_paddr) instead. */ | 253 | 58.2k | if (scnhdr_int->s_paddr > 0 | 254 | 43.8k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 255 | 9.16k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 256 | 42.0k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 257 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 258 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 259 | | only works if it correctly holds the virtual size of the | 260 | | section. */ | 261 | 14.1k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 262 | 58.2k | #endif | 263 | 58.2k | } |
pei-loongarch64.c:coff_swap_scnhdr_in Line | Count | Source | 212 | 59.2k | { | 213 | 59.2k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 214 | 59.2k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 215 | | | 216 | 59.2k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 217 | | | 218 | 59.2k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 219 | 59.2k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 220 | 59.2k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 221 | 59.2k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 222 | 59.2k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 223 | 59.2k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 224 | 59.2k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 225 | | | 226 | | /* MS handles overflow of line numbers by carrying into the reloc | 227 | | field (it appears). Since it's supposed to be zero for PE | 228 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 229 | 59.2k | #ifdef COFF_IMAGE_WITH_PE | 230 | 59.2k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 231 | 59.2k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 232 | 59.2k | scnhdr_int->s_nreloc = 0; | 233 | | #else | 234 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 235 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 236 | | #endif | 237 | | | 238 | 59.2k | if (scnhdr_int->s_vaddr != 0) | 239 | 39.1k | { | 240 | 39.1k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 241 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 242 | | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 243 | | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 244 | | scnhdr_int->s_vaddr &= 0xffffffff; | 245 | | #endif | 246 | 39.1k | } | 247 | | | 248 | 59.2k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 249 | | /* If this section holds uninitialized data and is from an object file | 250 | | or from an executable image that has not initialized the field, | 251 | | or if the image is an executable file and the physical size is padded, | 252 | | use the virtual size (stored in s_paddr) instead. */ | 253 | 59.2k | if (scnhdr_int->s_paddr > 0 | 254 | 43.8k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 255 | 8.45k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 256 | 41.7k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 257 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 258 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 259 | | only works if it correctly holds the virtual size of the | 260 | | section. */ | 261 | 14.3k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 262 | 59.2k | #endif | 263 | 59.2k | } |
pei-riscv64.c:coff_swap_scnhdr_in Line | Count | Source | 212 | 56.6k | { | 213 | 56.6k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 214 | 56.6k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 215 | | | 216 | 56.6k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 217 | | | 218 | 56.6k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 219 | 56.6k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 220 | 56.6k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 221 | 56.6k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 222 | 56.6k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 223 | 56.6k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 224 | 56.6k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 225 | | | 226 | | /* MS handles overflow of line numbers by carrying into the reloc | 227 | | field (it appears). Since it's supposed to be zero for PE | 228 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 229 | 56.6k | #ifdef COFF_IMAGE_WITH_PE | 230 | 56.6k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 231 | 56.6k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 232 | 56.6k | scnhdr_int->s_nreloc = 0; | 233 | | #else | 234 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 235 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 236 | | #endif | 237 | | | 238 | 56.6k | if (scnhdr_int->s_vaddr != 0) | 239 | 35.9k | { | 240 | 35.9k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 241 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 242 | | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 243 | | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 244 | | scnhdr_int->s_vaddr &= 0xffffffff; | 245 | | #endif | 246 | 35.9k | } | 247 | | | 248 | 56.6k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 249 | | /* If this section holds uninitialized data and is from an object file | 250 | | or from an executable image that has not initialized the field, | 251 | | or if the image is an executable file and the physical size is padded, | 252 | | use the virtual size (stored in s_paddr) instead. */ | 253 | 56.6k | if (scnhdr_int->s_paddr > 0 | 254 | 41.2k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 255 | 10.5k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 256 | 39.8k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 257 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 258 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 259 | | only works if it correctly holds the virtual size of the | 260 | | section. */ | 261 | 11.6k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 262 | 56.6k | #endif | 263 | 56.6k | } |
pe-arm-wince.c:coff_swap_scnhdr_in Line | Count | Source | 212 | 24.2k | { | 213 | 24.2k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 214 | 24.2k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 215 | | | 216 | 24.2k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 217 | | | 218 | 24.2k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 219 | 24.2k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 220 | 24.2k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 221 | 24.2k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 222 | 24.2k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 223 | 24.2k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 224 | 24.2k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 225 | | | 226 | | /* MS handles overflow of line numbers by carrying into the reloc | 227 | | field (it appears). Since it's supposed to be zero for PE | 228 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 229 | | #ifdef COFF_IMAGE_WITH_PE | 230 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 231 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 232 | | scnhdr_int->s_nreloc = 0; | 233 | | #else | 234 | 24.2k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 235 | 24.2k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 236 | 24.2k | #endif | 237 | | | 238 | 24.2k | if (scnhdr_int->s_vaddr != 0) | 239 | 15.2k | { | 240 | 15.2k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 241 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 242 | 15.2k | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 243 | 15.2k | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 244 | 15.2k | scnhdr_int->s_vaddr &= 0xffffffff; | 245 | 15.2k | #endif | 246 | 15.2k | } | 247 | | | 248 | 24.2k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 249 | | /* If this section holds uninitialized data and is from an object file | 250 | | or from an executable image that has not initialized the field, | 251 | | or if the image is an executable file and the physical size is padded, | 252 | | use the virtual size (stored in s_paddr) instead. */ | 253 | 24.2k | if (scnhdr_int->s_paddr > 0 | 254 | 17.2k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 255 | 3.47k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 256 | 13.8k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 257 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 258 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 259 | | only works if it correctly holds the virtual size of the | 260 | | section. */ | 261 | 3.47k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 262 | 24.2k | #endif | 263 | 24.2k | } |
pe-arm.c:coff_swap_scnhdr_in Line | Count | Source | 212 | 24.2k | { | 213 | 24.2k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 214 | 24.2k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 215 | | | 216 | 24.2k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 217 | | | 218 | 24.2k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 219 | 24.2k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 220 | 24.2k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 221 | 24.2k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 222 | 24.2k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 223 | 24.2k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 224 | 24.2k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 225 | | | 226 | | /* MS handles overflow of line numbers by carrying into the reloc | 227 | | field (it appears). Since it's supposed to be zero for PE | 228 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 229 | | #ifdef COFF_IMAGE_WITH_PE | 230 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 231 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 232 | | scnhdr_int->s_nreloc = 0; | 233 | | #else | 234 | 24.2k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 235 | 24.2k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 236 | 24.2k | #endif | 237 | | | 238 | 24.2k | if (scnhdr_int->s_vaddr != 0) | 239 | 15.2k | { | 240 | 15.2k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 241 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 242 | 15.2k | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 243 | 15.2k | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 244 | 15.2k | scnhdr_int->s_vaddr &= 0xffffffff; | 245 | 15.2k | #endif | 246 | 15.2k | } | 247 | | | 248 | 24.2k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 249 | | /* If this section holds uninitialized data and is from an object file | 250 | | or from an executable image that has not initialized the field, | 251 | | or if the image is an executable file and the physical size is padded, | 252 | | use the virtual size (stored in s_paddr) instead. */ | 253 | 24.2k | if (scnhdr_int->s_paddr > 0 | 254 | 17.2k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 255 | 3.47k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 256 | 13.8k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 257 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 258 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 259 | | only works if it correctly holds the virtual size of the | 260 | | section. */ | 261 | 3.47k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 262 | 24.2k | #endif | 263 | 24.2k | } |
pe-i386.c:coff_swap_scnhdr_in Line | Count | Source | 212 | 34.8k | { | 213 | 34.8k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 214 | 34.8k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 215 | | | 216 | 34.8k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 217 | | | 218 | 34.8k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 219 | 34.8k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 220 | 34.8k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 221 | 34.8k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 222 | 34.8k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 223 | 34.8k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 224 | 34.8k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 225 | | | 226 | | /* MS handles overflow of line numbers by carrying into the reloc | 227 | | field (it appears). Since it's supposed to be zero for PE | 228 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 229 | | #ifdef COFF_IMAGE_WITH_PE | 230 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 231 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 232 | | scnhdr_int->s_nreloc = 0; | 233 | | #else | 234 | 34.8k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 235 | 34.8k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 236 | 34.8k | #endif | 237 | | | 238 | 34.8k | if (scnhdr_int->s_vaddr != 0) | 239 | 23.1k | { | 240 | 23.1k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 241 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 242 | 23.1k | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 243 | 23.1k | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 244 | 23.1k | scnhdr_int->s_vaddr &= 0xffffffff; | 245 | 23.1k | #endif | 246 | 23.1k | } | 247 | | | 248 | 34.8k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 249 | | /* If this section holds uninitialized data and is from an object file | 250 | | or from an executable image that has not initialized the field, | 251 | | or if the image is an executable file and the physical size is padded, | 252 | | use the virtual size (stored in s_paddr) instead. */ | 253 | 34.8k | if (scnhdr_int->s_paddr > 0 | 254 | 25.4k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 255 | 5.21k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 256 | 20.2k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 257 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 258 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 259 | | only works if it correctly holds the virtual size of the | 260 | | section. */ | 261 | 5.21k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 262 | 34.8k | #endif | 263 | 34.8k | } |
pe-mcore.c:coff_swap_scnhdr_in Line | Count | Source | 212 | 28.9k | { | 213 | 28.9k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 214 | 28.9k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 215 | | | 216 | 28.9k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 217 | | | 218 | 28.9k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 219 | 28.9k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 220 | 28.9k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 221 | 28.9k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 222 | 28.9k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 223 | 28.9k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 224 | 28.9k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 225 | | | 226 | | /* MS handles overflow of line numbers by carrying into the reloc | 227 | | field (it appears). Since it's supposed to be zero for PE | 228 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 229 | | #ifdef COFF_IMAGE_WITH_PE | 230 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 231 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 232 | | scnhdr_int->s_nreloc = 0; | 233 | | #else | 234 | 28.9k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 235 | 28.9k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 236 | 28.9k | #endif | 237 | | | 238 | 28.9k | if (scnhdr_int->s_vaddr != 0) | 239 | 17.9k | { | 240 | 17.9k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 241 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 242 | 17.9k | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 243 | 17.9k | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 244 | 17.9k | scnhdr_int->s_vaddr &= 0xffffffff; | 245 | 17.9k | #endif | 246 | 17.9k | } | 247 | | | 248 | 28.9k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 249 | | /* If this section holds uninitialized data and is from an object file | 250 | | or from an executable image that has not initialized the field, | 251 | | or if the image is an executable file and the physical size is padded, | 252 | | use the virtual size (stored in s_paddr) instead. */ | 253 | 28.9k | if (scnhdr_int->s_paddr > 0 | 254 | 20.7k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 255 | 4.03k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 256 | 16.7k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 257 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 258 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 259 | | only works if it correctly holds the virtual size of the | 260 | | section. */ | 261 | 4.03k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 262 | 28.9k | #endif | 263 | 28.9k | } |
pe-sh.c:coff_swap_scnhdr_in Line | Count | Source | 212 | 45.2k | { | 213 | 45.2k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 214 | 45.2k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 215 | | | 216 | 45.2k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 217 | | | 218 | 45.2k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 219 | 45.2k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 220 | 45.2k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 221 | 45.2k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 222 | 45.2k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 223 | 45.2k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 224 | 45.2k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 225 | | | 226 | | /* MS handles overflow of line numbers by carrying into the reloc | 227 | | field (it appears). Since it's supposed to be zero for PE | 228 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 229 | | #ifdef COFF_IMAGE_WITH_PE | 230 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 231 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 232 | | scnhdr_int->s_nreloc = 0; | 233 | | #else | 234 | 45.2k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 235 | 45.2k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 236 | 45.2k | #endif | 237 | | | 238 | 45.2k | if (scnhdr_int->s_vaddr != 0) | 239 | 29.3k | { | 240 | 29.3k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 241 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 242 | 29.3k | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 243 | 29.3k | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 244 | 29.3k | scnhdr_int->s_vaddr &= 0xffffffff; | 245 | 29.3k | #endif | 246 | 29.3k | } | 247 | | | 248 | 45.2k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 249 | | /* If this section holds uninitialized data and is from an object file | 250 | | or from an executable image that has not initialized the field, | 251 | | or if the image is an executable file and the physical size is padded, | 252 | | use the virtual size (stored in s_paddr) instead. */ | 253 | 45.2k | if (scnhdr_int->s_paddr > 0 | 254 | 32.1k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 255 | 6.39k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 256 | 25.7k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 257 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 258 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 259 | | only works if it correctly holds the virtual size of the | 260 | | section. */ | 261 | 6.39k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 262 | 45.2k | #endif | 263 | 45.2k | } |
pei-arm-wince.c:coff_swap_scnhdr_in Line | Count | Source | 212 | 47.1k | { | 213 | 47.1k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 214 | 47.1k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 215 | | | 216 | 47.1k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 217 | | | 218 | 47.1k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 219 | 47.1k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 220 | 47.1k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 221 | 47.1k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 222 | 47.1k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 223 | 47.1k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 224 | 47.1k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 225 | | | 226 | | /* MS handles overflow of line numbers by carrying into the reloc | 227 | | field (it appears). Since it's supposed to be zero for PE | 228 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 229 | 47.1k | #ifdef COFF_IMAGE_WITH_PE | 230 | 47.1k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 231 | 47.1k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 232 | 47.1k | scnhdr_int->s_nreloc = 0; | 233 | | #else | 234 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 235 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 236 | | #endif | 237 | | | 238 | 47.1k | if (scnhdr_int->s_vaddr != 0) | 239 | 31.5k | { | 240 | 31.5k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 241 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 242 | 31.5k | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 243 | 31.5k | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 244 | 31.5k | scnhdr_int->s_vaddr &= 0xffffffff; | 245 | 31.5k | #endif | 246 | 31.5k | } | 247 | | | 248 | 47.1k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 249 | | /* If this section holds uninitialized data and is from an object file | 250 | | or from an executable image that has not initialized the field, | 251 | | or if the image is an executable file and the physical size is padded, | 252 | | use the virtual size (stored in s_paddr) instead. */ | 253 | 47.1k | if (scnhdr_int->s_paddr > 0 | 254 | 35.8k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 255 | 9.07k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 256 | 34.3k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 257 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 258 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 259 | | only works if it correctly holds the virtual size of the | 260 | | section. */ | 261 | 11.4k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 262 | 47.1k | #endif | 263 | 47.1k | } |
pei-arm.c:coff_swap_scnhdr_in Line | Count | Source | 212 | 60.4k | { | 213 | 60.4k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 214 | 60.4k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 215 | | | 216 | 60.4k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 217 | | | 218 | 60.4k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 219 | 60.4k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 220 | 60.4k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 221 | 60.4k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 222 | 60.4k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 223 | 60.4k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 224 | 60.4k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 225 | | | 226 | | /* MS handles overflow of line numbers by carrying into the reloc | 227 | | field (it appears). Since it's supposed to be zero for PE | 228 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 229 | 60.4k | #ifdef COFF_IMAGE_WITH_PE | 230 | 60.4k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 231 | 60.4k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 232 | 60.4k | scnhdr_int->s_nreloc = 0; | 233 | | #else | 234 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 235 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 236 | | #endif | 237 | | | 238 | 60.4k | if (scnhdr_int->s_vaddr != 0) | 239 | 40.2k | { | 240 | 40.2k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 241 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 242 | 40.2k | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 243 | 40.2k | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 244 | 40.2k | scnhdr_int->s_vaddr &= 0xffffffff; | 245 | 40.2k | #endif | 246 | 40.2k | } | 247 | | | 248 | 60.4k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 249 | | /* If this section holds uninitialized data and is from an object file | 250 | | or from an executable image that has not initialized the field, | 251 | | or if the image is an executable file and the physical size is padded, | 252 | | use the virtual size (stored in s_paddr) instead. */ | 253 | 60.4k | if (scnhdr_int->s_paddr > 0 | 254 | 45.3k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 255 | 11.2k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 256 | 43.5k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 257 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 258 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 259 | | only works if it correctly holds the virtual size of the | 260 | | section. */ | 261 | 14.1k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 262 | 60.4k | #endif | 263 | 60.4k | } |
pei-mcore.c:coff_swap_scnhdr_in Line | Count | Source | 212 | 57.0k | { | 213 | 57.0k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 214 | 57.0k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 215 | | | 216 | 57.0k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 217 | | | 218 | 57.0k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 219 | 57.0k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 220 | 57.0k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 221 | 57.0k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 222 | 57.0k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 223 | 57.0k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 224 | 57.0k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 225 | | | 226 | | /* MS handles overflow of line numbers by carrying into the reloc | 227 | | field (it appears). Since it's supposed to be zero for PE | 228 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 229 | 57.0k | #ifdef COFF_IMAGE_WITH_PE | 230 | 57.0k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 231 | 57.0k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 232 | 57.0k | scnhdr_int->s_nreloc = 0; | 233 | | #else | 234 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 235 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 236 | | #endif | 237 | | | 238 | 57.0k | if (scnhdr_int->s_vaddr != 0) | 239 | 38.5k | { | 240 | 38.5k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 241 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 242 | 38.5k | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 243 | 38.5k | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 244 | 38.5k | scnhdr_int->s_vaddr &= 0xffffffff; | 245 | 38.5k | #endif | 246 | 38.5k | } | 247 | | | 248 | 57.0k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 249 | | /* If this section holds uninitialized data and is from an object file | 250 | | or from an executable image that has not initialized the field, | 251 | | or if the image is an executable file and the physical size is padded, | 252 | | use the virtual size (stored in s_paddr) instead. */ | 253 | 57.0k | if (scnhdr_int->s_paddr > 0 | 254 | 42.7k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 255 | 10.1k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 256 | 41.1k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 257 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 258 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 259 | | only works if it correctly holds the virtual size of the | 260 | | section. */ | 261 | 12.1k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 262 | 57.0k | #endif | 263 | 57.0k | } |
pei-sh.c:coff_swap_scnhdr_in Line | Count | Source | 212 | 51.4k | { | 213 | 51.4k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 214 | 51.4k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 215 | | | 216 | 51.4k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 217 | | | 218 | 51.4k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 219 | 51.4k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 220 | 51.4k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 221 | 51.4k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 222 | 51.4k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 223 | 51.4k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 224 | 51.4k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 225 | | | 226 | | /* MS handles overflow of line numbers by carrying into the reloc | 227 | | field (it appears). Since it's supposed to be zero for PE | 228 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 229 | 51.4k | #ifdef COFF_IMAGE_WITH_PE | 230 | 51.4k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 231 | 51.4k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 232 | 51.4k | scnhdr_int->s_nreloc = 0; | 233 | | #else | 234 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 235 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 236 | | #endif | 237 | | | 238 | 51.4k | if (scnhdr_int->s_vaddr != 0) | 239 | 35.9k | { | 240 | 35.9k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 241 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 242 | 35.9k | #if (!defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) \ | 243 | 35.9k | && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64)) | 244 | 35.9k | scnhdr_int->s_vaddr &= 0xffffffff; | 245 | 35.9k | #endif | 246 | 35.9k | } | 247 | | | 248 | 51.4k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 249 | | /* If this section holds uninitialized data and is from an object file | 250 | | or from an executable image that has not initialized the field, | 251 | | or if the image is an executable file and the physical size is padded, | 252 | | use the virtual size (stored in s_paddr) instead. */ | 253 | 51.4k | if (scnhdr_int->s_paddr > 0 | 254 | 39.1k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 255 | 9.51k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 256 | 37.7k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 257 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 258 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 259 | | only works if it correctly holds the virtual size of the | 260 | | section. */ | 261 | 12.4k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 262 | 51.4k | #endif | 263 | 51.4k | } |
|
264 | | |
265 | | static bool |
266 | | pe_mkobject (bfd *abfd) |
267 | 114k | { |
268 | | /* Some x86 code followed by an ascii string. */ |
269 | 114k | static const char default_dos_message[64] = { |
270 | 114k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, |
271 | 114k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, |
272 | 114k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, |
273 | 114k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, |
274 | 114k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, |
275 | 114k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, |
276 | 114k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, |
277 | 114k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
278 | | |
279 | 114k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); |
280 | 114k | abfd->tdata.pe_obj_data = pe; |
281 | 114k | if (pe == NULL) |
282 | 0 | return false; |
283 | | |
284 | 114k | pe->coff.pe = 1; |
285 | | |
286 | | /* in_reloc_p is architecture dependent. */ |
287 | 114k | pe->in_reloc_p = in_reloc_p; |
288 | | |
289 | 114k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); |
290 | | |
291 | 114k | bfd_coff_long_section_names (abfd) |
292 | 114k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; |
293 | | |
294 | 114k | return true; |
295 | 114k | } Line | Count | Source | 267 | 10.4k | { | 268 | | /* Some x86 code followed by an ascii string. */ | 269 | 10.4k | static const char default_dos_message[64] = { | 270 | 10.4k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 271 | 10.4k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 272 | 10.4k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 273 | 10.4k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 274 | 10.4k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 275 | 10.4k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 276 | 10.4k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 277 | 10.4k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 278 | | | 279 | 10.4k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 280 | 10.4k | abfd->tdata.pe_obj_data = pe; | 281 | 10.4k | if (pe == NULL) | 282 | 0 | return false; | 283 | | | 284 | 10.4k | pe->coff.pe = 1; | 285 | | | 286 | | /* in_reloc_p is architecture dependent. */ | 287 | 10.4k | pe->in_reloc_p = in_reloc_p; | 288 | | | 289 | 10.4k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 290 | | | 291 | 10.4k | bfd_coff_long_section_names (abfd) | 292 | 10.4k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 293 | | | 294 | | return true; | 295 | 10.4k | } |
Line | Count | Source | 267 | 5.38k | { | 268 | | /* Some x86 code followed by an ascii string. */ | 269 | 5.38k | static const char default_dos_message[64] = { | 270 | 5.38k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 271 | 5.38k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 272 | 5.38k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 273 | 5.38k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 274 | 5.38k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 275 | 5.38k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 276 | 5.38k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 277 | 5.38k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 278 | | | 279 | 5.38k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 280 | 5.38k | abfd->tdata.pe_obj_data = pe; | 281 | 5.38k | if (pe == NULL) | 282 | 0 | return false; | 283 | | | 284 | 5.38k | pe->coff.pe = 1; | 285 | | | 286 | | /* in_reloc_p is architecture dependent. */ | 287 | 5.38k | pe->in_reloc_p = in_reloc_p; | 288 | | | 289 | 5.38k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 290 | | | 291 | 5.38k | bfd_coff_long_section_names (abfd) | 292 | 5.38k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 293 | | | 294 | | return true; | 295 | 5.38k | } |
Line | Count | Source | 267 | 8.30k | { | 268 | | /* Some x86 code followed by an ascii string. */ | 269 | 8.30k | static const char default_dos_message[64] = { | 270 | 8.30k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 271 | 8.30k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 272 | 8.30k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 273 | 8.30k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 274 | 8.30k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 275 | 8.30k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 276 | 8.30k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 277 | 8.30k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 278 | | | 279 | 8.30k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 280 | 8.30k | abfd->tdata.pe_obj_data = pe; | 281 | 8.30k | if (pe == NULL) | 282 | 0 | return false; | 283 | | | 284 | 8.30k | pe->coff.pe = 1; | 285 | | | 286 | | /* in_reloc_p is architecture dependent. */ | 287 | 8.30k | pe->in_reloc_p = in_reloc_p; | 288 | | | 289 | 8.30k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 290 | | | 291 | 8.30k | bfd_coff_long_section_names (abfd) | 292 | 8.30k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 293 | | | 294 | | return true; | 295 | 8.30k | } |
Line | Count | Source | 267 | 9.91k | { | 268 | | /* Some x86 code followed by an ascii string. */ | 269 | 9.91k | static const char default_dos_message[64] = { | 270 | 9.91k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 271 | 9.91k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 272 | 9.91k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 273 | 9.91k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 274 | 9.91k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 275 | 9.91k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 276 | 9.91k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 277 | 9.91k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 278 | | | 279 | 9.91k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 280 | 9.91k | abfd->tdata.pe_obj_data = pe; | 281 | 9.91k | if (pe == NULL) | 282 | 0 | return false; | 283 | | | 284 | 9.91k | pe->coff.pe = 1; | 285 | | | 286 | | /* in_reloc_p is architecture dependent. */ | 287 | 9.91k | pe->in_reloc_p = in_reloc_p; | 288 | | | 289 | 9.91k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 290 | | | 291 | 9.91k | bfd_coff_long_section_names (abfd) | 292 | 9.91k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 293 | | | 294 | | return true; | 295 | 9.91k | } |
pei-aarch64.c:pe_mkobject Line | Count | Source | 267 | 9.20k | { | 268 | | /* Some x86 code followed by an ascii string. */ | 269 | 9.20k | static const char default_dos_message[64] = { | 270 | 9.20k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 271 | 9.20k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 272 | 9.20k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 273 | 9.20k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 274 | 9.20k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 275 | 9.20k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 276 | 9.20k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 277 | 9.20k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 278 | | | 279 | 9.20k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 280 | 9.20k | abfd->tdata.pe_obj_data = pe; | 281 | 9.20k | if (pe == NULL) | 282 | 0 | return false; | 283 | | | 284 | 9.20k | pe->coff.pe = 1; | 285 | | | 286 | | /* in_reloc_p is architecture dependent. */ | 287 | 9.20k | pe->in_reloc_p = in_reloc_p; | 288 | | | 289 | 9.20k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 290 | | | 291 | 9.20k | bfd_coff_long_section_names (abfd) | 292 | 9.20k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 293 | | | 294 | | return true; | 295 | 9.20k | } |
Line | Count | Source | 267 | 7.89k | { | 268 | | /* Some x86 code followed by an ascii string. */ | 269 | 7.89k | static const char default_dos_message[64] = { | 270 | 7.89k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 271 | 7.89k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 272 | 7.89k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 273 | 7.89k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 274 | 7.89k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 275 | 7.89k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 276 | 7.89k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 277 | 7.89k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 278 | | | 279 | 7.89k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 280 | 7.89k | abfd->tdata.pe_obj_data = pe; | 281 | 7.89k | if (pe == NULL) | 282 | 0 | return false; | 283 | | | 284 | 7.89k | pe->coff.pe = 1; | 285 | | | 286 | | /* in_reloc_p is architecture dependent. */ | 287 | 7.89k | pe->in_reloc_p = in_reloc_p; | 288 | | | 289 | 7.89k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 290 | | | 291 | 7.89k | bfd_coff_long_section_names (abfd) | 292 | 7.89k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 293 | | | 294 | | return true; | 295 | 7.89k | } |
pei-loongarch64.c:pe_mkobject Line | Count | Source | 267 | 7.14k | { | 268 | | /* Some x86 code followed by an ascii string. */ | 269 | 7.14k | static const char default_dos_message[64] = { | 270 | 7.14k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 271 | 7.14k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 272 | 7.14k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 273 | 7.14k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 274 | 7.14k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 275 | 7.14k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 276 | 7.14k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 277 | 7.14k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 278 | | | 279 | 7.14k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 280 | 7.14k | abfd->tdata.pe_obj_data = pe; | 281 | 7.14k | if (pe == NULL) | 282 | 0 | return false; | 283 | | | 284 | 7.14k | pe->coff.pe = 1; | 285 | | | 286 | | /* in_reloc_p is architecture dependent. */ | 287 | 7.14k | pe->in_reloc_p = in_reloc_p; | 288 | | | 289 | 7.14k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 290 | | | 291 | 7.14k | bfd_coff_long_section_names (abfd) | 292 | 7.14k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 293 | | | 294 | | return true; | 295 | 7.14k | } |
pei-riscv64.c:pe_mkobject Line | Count | Source | 267 | 7.60k | { | 268 | | /* Some x86 code followed by an ascii string. */ | 269 | 7.60k | static const char default_dos_message[64] = { | 270 | 7.60k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 271 | 7.60k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 272 | 7.60k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 273 | 7.60k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 274 | 7.60k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 275 | 7.60k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 276 | 7.60k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 277 | 7.60k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 278 | | | 279 | 7.60k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 280 | 7.60k | abfd->tdata.pe_obj_data = pe; | 281 | 7.60k | if (pe == NULL) | 282 | 0 | return false; | 283 | | | 284 | 7.60k | pe->coff.pe = 1; | 285 | | | 286 | | /* in_reloc_p is architecture dependent. */ | 287 | 7.60k | pe->in_reloc_p = in_reloc_p; | 288 | | | 289 | 7.60k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 290 | | | 291 | 7.60k | bfd_coff_long_section_names (abfd) | 292 | 7.60k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 293 | | | 294 | | return true; | 295 | 7.60k | } |
pe-arm-wince.c:pe_mkobject Line | Count | Source | 267 | 2.88k | { | 268 | | /* Some x86 code followed by an ascii string. */ | 269 | 2.88k | static const char default_dos_message[64] = { | 270 | 2.88k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 271 | 2.88k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 272 | 2.88k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 273 | 2.88k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 274 | 2.88k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 275 | 2.88k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 276 | 2.88k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 277 | 2.88k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 278 | | | 279 | 2.88k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 280 | 2.88k | abfd->tdata.pe_obj_data = pe; | 281 | 2.88k | if (pe == NULL) | 282 | 0 | return false; | 283 | | | 284 | 2.88k | pe->coff.pe = 1; | 285 | | | 286 | | /* in_reloc_p is architecture dependent. */ | 287 | 2.88k | pe->in_reloc_p = in_reloc_p; | 288 | | | 289 | 2.88k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 290 | | | 291 | 2.88k | bfd_coff_long_section_names (abfd) | 292 | 2.88k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 293 | | | 294 | | return true; | 295 | 2.88k | } |
Line | Count | Source | 267 | 2.88k | { | 268 | | /* Some x86 code followed by an ascii string. */ | 269 | 2.88k | static const char default_dos_message[64] = { | 270 | 2.88k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 271 | 2.88k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 272 | 2.88k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 273 | 2.88k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 274 | 2.88k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 275 | 2.88k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 276 | 2.88k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 277 | 2.88k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 278 | | | 279 | 2.88k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 280 | 2.88k | abfd->tdata.pe_obj_data = pe; | 281 | 2.88k | if (pe == NULL) | 282 | 0 | return false; | 283 | | | 284 | 2.88k | pe->coff.pe = 1; | 285 | | | 286 | | /* in_reloc_p is architecture dependent. */ | 287 | 2.88k | pe->in_reloc_p = in_reloc_p; | 288 | | | 289 | 2.88k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 290 | | | 291 | 2.88k | bfd_coff_long_section_names (abfd) | 292 | 2.88k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 293 | | | 294 | | return true; | 295 | 2.88k | } |
Line | Count | Source | 267 | 7.16k | { | 268 | | /* Some x86 code followed by an ascii string. */ | 269 | 7.16k | static const char default_dos_message[64] = { | 270 | 7.16k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 271 | 7.16k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 272 | 7.16k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 273 | 7.16k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 274 | 7.16k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 275 | 7.16k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 276 | 7.16k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 277 | 7.16k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 278 | | | 279 | 7.16k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 280 | 7.16k | abfd->tdata.pe_obj_data = pe; | 281 | 7.16k | if (pe == NULL) | 282 | 0 | return false; | 283 | | | 284 | 7.16k | pe->coff.pe = 1; | 285 | | | 286 | | /* in_reloc_p is architecture dependent. */ | 287 | 7.16k | pe->in_reloc_p = in_reloc_p; | 288 | | | 289 | 7.16k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 290 | | | 291 | 7.16k | bfd_coff_long_section_names (abfd) | 292 | 7.16k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 293 | | | 294 | | return true; | 295 | 7.16k | } |
Line | Count | Source | 267 | 4.19k | { | 268 | | /* Some x86 code followed by an ascii string. */ | 269 | 4.19k | static const char default_dos_message[64] = { | 270 | 4.19k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 271 | 4.19k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 272 | 4.19k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 273 | 4.19k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 274 | 4.19k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 275 | 4.19k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 276 | 4.19k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 277 | 4.19k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 278 | | | 279 | 4.19k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 280 | 4.19k | abfd->tdata.pe_obj_data = pe; | 281 | 4.19k | if (pe == NULL) | 282 | 0 | return false; | 283 | | | 284 | 4.19k | pe->coff.pe = 1; | 285 | | | 286 | | /* in_reloc_p is architecture dependent. */ | 287 | 4.19k | pe->in_reloc_p = in_reloc_p; | 288 | | | 289 | 4.19k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 290 | | | 291 | 4.19k | bfd_coff_long_section_names (abfd) | 292 | 4.19k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 293 | | | 294 | | return true; | 295 | 4.19k | } |
Line | Count | Source | 267 | 5.61k | { | 268 | | /* Some x86 code followed by an ascii string. */ | 269 | 5.61k | static const char default_dos_message[64] = { | 270 | 5.61k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 271 | 5.61k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 272 | 5.61k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 273 | 5.61k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 274 | 5.61k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 275 | 5.61k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 276 | 5.61k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 277 | 5.61k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 278 | | | 279 | 5.61k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 280 | 5.61k | abfd->tdata.pe_obj_data = pe; | 281 | 5.61k | if (pe == NULL) | 282 | 0 | return false; | 283 | | | 284 | 5.61k | pe->coff.pe = 1; | 285 | | | 286 | | /* in_reloc_p is architecture dependent. */ | 287 | 5.61k | pe->in_reloc_p = in_reloc_p; | 288 | | | 289 | 5.61k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 290 | | | 291 | 5.61k | bfd_coff_long_section_names (abfd) | 292 | 5.61k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 293 | | | 294 | | return true; | 295 | 5.61k | } |
pei-arm-wince.c:pe_mkobject Line | Count | Source | 267 | 5.68k | { | 268 | | /* Some x86 code followed by an ascii string. */ | 269 | 5.68k | static const char default_dos_message[64] = { | 270 | 5.68k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 271 | 5.68k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 272 | 5.68k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 273 | 5.68k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 274 | 5.68k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 275 | 5.68k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 276 | 5.68k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 277 | 5.68k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 278 | | | 279 | 5.68k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 280 | 5.68k | abfd->tdata.pe_obj_data = pe; | 281 | 5.68k | if (pe == NULL) | 282 | 0 | return false; | 283 | | | 284 | 5.68k | pe->coff.pe = 1; | 285 | | | 286 | | /* in_reloc_p is architecture dependent. */ | 287 | 5.68k | pe->in_reloc_p = in_reloc_p; | 288 | | | 289 | 5.68k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 290 | | | 291 | 5.68k | bfd_coff_long_section_names (abfd) | 292 | 5.68k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 293 | | | 294 | | return true; | 295 | 5.68k | } |
Line | Count | Source | 267 | 7.58k | { | 268 | | /* Some x86 code followed by an ascii string. */ | 269 | 7.58k | static const char default_dos_message[64] = { | 270 | 7.58k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 271 | 7.58k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 272 | 7.58k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 273 | 7.58k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 274 | 7.58k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 275 | 7.58k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 276 | 7.58k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 277 | 7.58k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 278 | | | 279 | 7.58k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 280 | 7.58k | abfd->tdata.pe_obj_data = pe; | 281 | 7.58k | if (pe == NULL) | 282 | 0 | return false; | 283 | | | 284 | 7.58k | pe->coff.pe = 1; | 285 | | | 286 | | /* in_reloc_p is architecture dependent. */ | 287 | 7.58k | pe->in_reloc_p = in_reloc_p; | 288 | | | 289 | 7.58k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 290 | | | 291 | 7.58k | bfd_coff_long_section_names (abfd) | 292 | 7.58k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 293 | | | 294 | | return true; | 295 | 7.58k | } |
Line | Count | Source | 267 | 5.98k | { | 268 | | /* Some x86 code followed by an ascii string. */ | 269 | 5.98k | static const char default_dos_message[64] = { | 270 | 5.98k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 271 | 5.98k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 272 | 5.98k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 273 | 5.98k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 274 | 5.98k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 275 | 5.98k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 276 | 5.98k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 277 | 5.98k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 278 | | | 279 | 5.98k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 280 | 5.98k | abfd->tdata.pe_obj_data = pe; | 281 | 5.98k | if (pe == NULL) | 282 | 0 | return false; | 283 | | | 284 | 5.98k | pe->coff.pe = 1; | 285 | | | 286 | | /* in_reloc_p is architecture dependent. */ | 287 | 5.98k | pe->in_reloc_p = in_reloc_p; | 288 | | | 289 | 5.98k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 290 | | | 291 | 5.98k | bfd_coff_long_section_names (abfd) | 292 | 5.98k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 293 | | | 294 | | return true; | 295 | 5.98k | } |
Line | Count | Source | 267 | 6.63k | { | 268 | | /* Some x86 code followed by an ascii string. */ | 269 | 6.63k | static const char default_dos_message[64] = { | 270 | 6.63k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 271 | 6.63k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 272 | 6.63k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 273 | 6.63k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 274 | 6.63k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 275 | 6.63k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 276 | 6.63k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 277 | 6.63k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 278 | | | 279 | 6.63k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 280 | 6.63k | abfd->tdata.pe_obj_data = pe; | 281 | 6.63k | if (pe == NULL) | 282 | 0 | return false; | 283 | | | 284 | 6.63k | pe->coff.pe = 1; | 285 | | | 286 | | /* in_reloc_p is architecture dependent. */ | 287 | 6.63k | pe->in_reloc_p = in_reloc_p; | 288 | | | 289 | 6.63k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 290 | | | 291 | 6.63k | bfd_coff_long_section_names (abfd) | 292 | 6.63k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 293 | | | 294 | | return true; | 295 | 6.63k | } |
|
296 | | |
297 | | /* Create the COFF backend specific information. */ |
298 | | |
299 | | static void * |
300 | | pe_mkobject_hook (bfd *abfd, |
301 | | void *filehdr, |
302 | | void *aouthdr ATTRIBUTE_UNUSED) |
303 | 107k | { |
304 | 107k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; |
305 | 107k | pe_data_type *pe; |
306 | | |
307 | 107k | if (! pe_mkobject (abfd)) |
308 | 0 | return NULL; |
309 | | |
310 | 107k | pe = pe_data (abfd); |
311 | 107k | pe->coff.sym_filepos = internal_f->f_symptr; |
312 | | /* These members communicate important constants about the symbol |
313 | | table to GDB's symbol-reading code. These `constants' |
314 | | unfortunately vary among coff implementations... */ |
315 | 107k | pe->coff.local_n_btmask = N_BTMASK; |
316 | 107k | pe->coff.local_n_btshft = N_BTSHFT; |
317 | 107k | pe->coff.local_n_tmask = N_TMASK; |
318 | 107k | pe->coff.local_n_tshift = N_TSHIFT; |
319 | 107k | pe->coff.local_symesz = SYMESZ; |
320 | 107k | pe->coff.local_auxesz = AUXESZ; |
321 | 107k | pe->coff.local_linesz = LINESZ; |
322 | | |
323 | 107k | pe->coff.timestamp = internal_f->f_timdat; |
324 | | |
325 | 107k | obj_raw_syment_count (abfd) = |
326 | 107k | obj_conv_table_size (abfd) = |
327 | 107k | internal_f->f_nsyms; |
328 | | |
329 | 107k | pe->real_flags = internal_f->f_flags; |
330 | | |
331 | 107k | if ((internal_f->f_flags & F_DLL) != 0) |
332 | 33.0k | pe->dll = 1; |
333 | | |
334 | 107k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) |
335 | 73.7k | abfd->flags |= HAS_DEBUG; |
336 | | |
337 | | #ifdef COFF_IMAGE_WITH_PE |
338 | 72.1k | if (aouthdr) |
339 | 41.1k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; |
340 | | #endif |
341 | | |
342 | | #ifdef ARM |
343 | 18.3k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) |
344 | 0 | coff_data (abfd) ->flags = 0; |
345 | | #endif |
346 | | |
347 | 107k | memcpy (pe->dos_message, internal_f->pe.dos_message, |
348 | 107k | sizeof (pe->dos_message)); |
349 | | |
350 | 107k | return (void *) pe; |
351 | 107k | } pei-i386.c:pe_mkobject_hook Line | Count | Source | 303 | 10.0k | { | 304 | 10.0k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 305 | 10.0k | pe_data_type *pe; | 306 | | | 307 | 10.0k | if (! pe_mkobject (abfd)) | 308 | 0 | return NULL; | 309 | | | 310 | 10.0k | pe = pe_data (abfd); | 311 | 10.0k | pe->coff.sym_filepos = internal_f->f_symptr; | 312 | | /* These members communicate important constants about the symbol | 313 | | table to GDB's symbol-reading code. These `constants' | 314 | | unfortunately vary among coff implementations... */ | 315 | 10.0k | pe->coff.local_n_btmask = N_BTMASK; | 316 | 10.0k | pe->coff.local_n_btshft = N_BTSHFT; | 317 | 10.0k | pe->coff.local_n_tmask = N_TMASK; | 318 | 10.0k | pe->coff.local_n_tshift = N_TSHIFT; | 319 | 10.0k | pe->coff.local_symesz = SYMESZ; | 320 | 10.0k | pe->coff.local_auxesz = AUXESZ; | 321 | 10.0k | pe->coff.local_linesz = LINESZ; | 322 | | | 323 | 10.0k | pe->coff.timestamp = internal_f->f_timdat; | 324 | | | 325 | 10.0k | obj_raw_syment_count (abfd) = | 326 | 10.0k | obj_conv_table_size (abfd) = | 327 | 10.0k | internal_f->f_nsyms; | 328 | | | 329 | 10.0k | pe->real_flags = internal_f->f_flags; | 330 | | | 331 | 10.0k | if ((internal_f->f_flags & F_DLL) != 0) | 332 | 2.92k | pe->dll = 1; | 333 | | | 334 | 10.0k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 335 | 7.58k | abfd->flags |= HAS_DEBUG; | 336 | | | 337 | 10.0k | #ifdef COFF_IMAGE_WITH_PE | 338 | 10.0k | if (aouthdr) | 339 | 4.91k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 340 | 10.0k | #endif | 341 | | | 342 | | #ifdef ARM | 343 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 344 | | coff_data (abfd) ->flags = 0; | 345 | | #endif | 346 | | | 347 | 10.0k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 348 | 10.0k | sizeof (pe->dos_message)); | 349 | | | 350 | 10.0k | return (void *) pe; | 351 | 10.0k | } |
pe-x86_64.c:pe_mkobject_hook Line | Count | Source | 303 | 4.74k | { | 304 | 4.74k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 305 | 4.74k | pe_data_type *pe; | 306 | | | 307 | 4.74k | if (! pe_mkobject (abfd)) | 308 | 0 | return NULL; | 309 | | | 310 | 4.74k | pe = pe_data (abfd); | 311 | 4.74k | pe->coff.sym_filepos = internal_f->f_symptr; | 312 | | /* These members communicate important constants about the symbol | 313 | | table to GDB's symbol-reading code. These `constants' | 314 | | unfortunately vary among coff implementations... */ | 315 | 4.74k | pe->coff.local_n_btmask = N_BTMASK; | 316 | 4.74k | pe->coff.local_n_btshft = N_BTSHFT; | 317 | 4.74k | pe->coff.local_n_tmask = N_TMASK; | 318 | 4.74k | pe->coff.local_n_tshift = N_TSHIFT; | 319 | 4.74k | pe->coff.local_symesz = SYMESZ; | 320 | 4.74k | pe->coff.local_auxesz = AUXESZ; | 321 | 4.74k | pe->coff.local_linesz = LINESZ; | 322 | | | 323 | 4.74k | pe->coff.timestamp = internal_f->f_timdat; | 324 | | | 325 | 4.74k | obj_raw_syment_count (abfd) = | 326 | 4.74k | obj_conv_table_size (abfd) = | 327 | 4.74k | internal_f->f_nsyms; | 328 | | | 329 | 4.74k | pe->real_flags = internal_f->f_flags; | 330 | | | 331 | 4.74k | if ((internal_f->f_flags & F_DLL) != 0) | 332 | 1.26k | pe->dll = 1; | 333 | | | 334 | 4.74k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 335 | 3.49k | abfd->flags |= HAS_DEBUG; | 336 | | | 337 | | #ifdef COFF_IMAGE_WITH_PE | 338 | | if (aouthdr) | 339 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 340 | | #endif | 341 | | | 342 | | #ifdef ARM | 343 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 344 | | coff_data (abfd) ->flags = 0; | 345 | | #endif | 346 | | | 347 | 4.74k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 348 | 4.74k | sizeof (pe->dos_message)); | 349 | | | 350 | 4.74k | return (void *) pe; | 351 | 4.74k | } |
pei-x86_64.c:pe_mkobject_hook Line | Count | Source | 303 | 7.86k | { | 304 | 7.86k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 305 | 7.86k | pe_data_type *pe; | 306 | | | 307 | 7.86k | if (! pe_mkobject (abfd)) | 308 | 0 | return NULL; | 309 | | | 310 | 7.86k | pe = pe_data (abfd); | 311 | 7.86k | pe->coff.sym_filepos = internal_f->f_symptr; | 312 | | /* These members communicate important constants about the symbol | 313 | | table to GDB's symbol-reading code. These `constants' | 314 | | unfortunately vary among coff implementations... */ | 315 | 7.86k | pe->coff.local_n_btmask = N_BTMASK; | 316 | 7.86k | pe->coff.local_n_btshft = N_BTSHFT; | 317 | 7.86k | pe->coff.local_n_tmask = N_TMASK; | 318 | 7.86k | pe->coff.local_n_tshift = N_TSHIFT; | 319 | 7.86k | pe->coff.local_symesz = SYMESZ; | 320 | 7.86k | pe->coff.local_auxesz = AUXESZ; | 321 | 7.86k | pe->coff.local_linesz = LINESZ; | 322 | | | 323 | 7.86k | pe->coff.timestamp = internal_f->f_timdat; | 324 | | | 325 | 7.86k | obj_raw_syment_count (abfd) = | 326 | 7.86k | obj_conv_table_size (abfd) = | 327 | 7.86k | internal_f->f_nsyms; | 328 | | | 329 | 7.86k | pe->real_flags = internal_f->f_flags; | 330 | | | 331 | 7.86k | if ((internal_f->f_flags & F_DLL) != 0) | 332 | 2.89k | pe->dll = 1; | 333 | | | 334 | 7.86k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 335 | 5.12k | abfd->flags |= HAS_DEBUG; | 336 | | | 337 | 7.86k | #ifdef COFF_IMAGE_WITH_PE | 338 | 7.86k | if (aouthdr) | 339 | 4.64k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 340 | 7.86k | #endif | 341 | | | 342 | | #ifdef ARM | 343 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 344 | | coff_data (abfd) ->flags = 0; | 345 | | #endif | 346 | | | 347 | 7.86k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 348 | 7.86k | sizeof (pe->dos_message)); | 349 | | | 350 | 7.86k | return (void *) pe; | 351 | 7.86k | } |
pe-aarch64.c:pe_mkobject_hook Line | Count | Source | 303 | 9.41k | { | 304 | 9.41k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 305 | 9.41k | pe_data_type *pe; | 306 | | | 307 | 9.41k | if (! pe_mkobject (abfd)) | 308 | 0 | return NULL; | 309 | | | 310 | 9.41k | pe = pe_data (abfd); | 311 | 9.41k | pe->coff.sym_filepos = internal_f->f_symptr; | 312 | | /* These members communicate important constants about the symbol | 313 | | table to GDB's symbol-reading code. These `constants' | 314 | | unfortunately vary among coff implementations... */ | 315 | 9.41k | pe->coff.local_n_btmask = N_BTMASK; | 316 | 9.41k | pe->coff.local_n_btshft = N_BTSHFT; | 317 | 9.41k | pe->coff.local_n_tmask = N_TMASK; | 318 | 9.41k | pe->coff.local_n_tshift = N_TSHIFT; | 319 | 9.41k | pe->coff.local_symesz = SYMESZ; | 320 | 9.41k | pe->coff.local_auxesz = AUXESZ; | 321 | 9.41k | pe->coff.local_linesz = LINESZ; | 322 | | | 323 | 9.41k | pe->coff.timestamp = internal_f->f_timdat; | 324 | | | 325 | 9.41k | obj_raw_syment_count (abfd) = | 326 | 9.41k | obj_conv_table_size (abfd) = | 327 | 9.41k | internal_f->f_nsyms; | 328 | | | 329 | 9.41k | pe->real_flags = internal_f->f_flags; | 330 | | | 331 | 9.41k | if ((internal_f->f_flags & F_DLL) != 0) | 332 | 1.81k | pe->dll = 1; | 333 | | | 334 | 9.41k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 335 | 4.29k | abfd->flags |= HAS_DEBUG; | 336 | | | 337 | | #ifdef COFF_IMAGE_WITH_PE | 338 | | if (aouthdr) | 339 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 340 | | #endif | 341 | | | 342 | | #ifdef ARM | 343 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 344 | | coff_data (abfd) ->flags = 0; | 345 | | #endif | 346 | | | 347 | 9.41k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 348 | 9.41k | sizeof (pe->dos_message)); | 349 | | | 350 | 9.41k | return (void *) pe; | 351 | 9.41k | } |
pei-aarch64.c:pe_mkobject_hook Line | Count | Source | 303 | 8.77k | { | 304 | 8.77k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 305 | 8.77k | pe_data_type *pe; | 306 | | | 307 | 8.77k | if (! pe_mkobject (abfd)) | 308 | 0 | return NULL; | 309 | | | 310 | 8.77k | pe = pe_data (abfd); | 311 | 8.77k | pe->coff.sym_filepos = internal_f->f_symptr; | 312 | | /* These members communicate important constants about the symbol | 313 | | table to GDB's symbol-reading code. These `constants' | 314 | | unfortunately vary among coff implementations... */ | 315 | 8.77k | pe->coff.local_n_btmask = N_BTMASK; | 316 | 8.77k | pe->coff.local_n_btshft = N_BTSHFT; | 317 | 8.77k | pe->coff.local_n_tmask = N_TMASK; | 318 | 8.77k | pe->coff.local_n_tshift = N_TSHIFT; | 319 | 8.77k | pe->coff.local_symesz = SYMESZ; | 320 | 8.77k | pe->coff.local_auxesz = AUXESZ; | 321 | 8.77k | pe->coff.local_linesz = LINESZ; | 322 | | | 323 | 8.77k | pe->coff.timestamp = internal_f->f_timdat; | 324 | | | 325 | 8.77k | obj_raw_syment_count (abfd) = | 326 | 8.77k | obj_conv_table_size (abfd) = | 327 | 8.77k | internal_f->f_nsyms; | 328 | | | 329 | 8.77k | pe->real_flags = internal_f->f_flags; | 330 | | | 331 | 8.77k | if ((internal_f->f_flags & F_DLL) != 0) | 332 | 2.29k | pe->dll = 1; | 333 | | | 334 | 8.77k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 335 | 6.92k | abfd->flags |= HAS_DEBUG; | 336 | | | 337 | 8.77k | #ifdef COFF_IMAGE_WITH_PE | 338 | 8.77k | if (aouthdr) | 339 | 6.46k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 340 | 8.77k | #endif | 341 | | | 342 | | #ifdef ARM | 343 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 344 | | coff_data (abfd) ->flags = 0; | 345 | | #endif | 346 | | | 347 | 8.77k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 348 | 8.77k | sizeof (pe->dos_message)); | 349 | | | 350 | 8.77k | return (void *) pe; | 351 | 8.77k | } |
pei-ia64.c:pe_mkobject_hook Line | Count | Source | 303 | 7.31k | { | 304 | 7.31k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 305 | 7.31k | pe_data_type *pe; | 306 | | | 307 | 7.31k | if (! pe_mkobject (abfd)) | 308 | 0 | return NULL; | 309 | | | 310 | 7.31k | pe = pe_data (abfd); | 311 | 7.31k | pe->coff.sym_filepos = internal_f->f_symptr; | 312 | | /* These members communicate important constants about the symbol | 313 | | table to GDB's symbol-reading code. These `constants' | 314 | | unfortunately vary among coff implementations... */ | 315 | 7.31k | pe->coff.local_n_btmask = N_BTMASK; | 316 | 7.31k | pe->coff.local_n_btshft = N_BTSHFT; | 317 | 7.31k | pe->coff.local_n_tmask = N_TMASK; | 318 | 7.31k | pe->coff.local_n_tshift = N_TSHIFT; | 319 | 7.31k | pe->coff.local_symesz = SYMESZ; | 320 | 7.31k | pe->coff.local_auxesz = AUXESZ; | 321 | 7.31k | pe->coff.local_linesz = LINESZ; | 322 | | | 323 | 7.31k | pe->coff.timestamp = internal_f->f_timdat; | 324 | | | 325 | 7.31k | obj_raw_syment_count (abfd) = | 326 | 7.31k | obj_conv_table_size (abfd) = | 327 | 7.31k | internal_f->f_nsyms; | 328 | | | 329 | 7.31k | pe->real_flags = internal_f->f_flags; | 330 | | | 331 | 7.31k | if ((internal_f->f_flags & F_DLL) != 0) | 332 | 2.25k | pe->dll = 1; | 333 | | | 334 | 7.31k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 335 | 5.14k | abfd->flags |= HAS_DEBUG; | 336 | | | 337 | 7.31k | #ifdef COFF_IMAGE_WITH_PE | 338 | 7.31k | if (aouthdr) | 339 | 3.42k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 340 | 7.31k | #endif | 341 | | | 342 | | #ifdef ARM | 343 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 344 | | coff_data (abfd) ->flags = 0; | 345 | | #endif | 346 | | | 347 | 7.31k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 348 | 7.31k | sizeof (pe->dos_message)); | 349 | | | 350 | 7.31k | return (void *) pe; | 351 | 7.31k | } |
pei-loongarch64.c:pe_mkobject_hook Line | Count | Source | 303 | 6.61k | { | 304 | 6.61k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 305 | 6.61k | pe_data_type *pe; | 306 | | | 307 | 6.61k | if (! pe_mkobject (abfd)) | 308 | 0 | return NULL; | 309 | | | 310 | 6.61k | pe = pe_data (abfd); | 311 | 6.61k | pe->coff.sym_filepos = internal_f->f_symptr; | 312 | | /* These members communicate important constants about the symbol | 313 | | table to GDB's symbol-reading code. These `constants' | 314 | | unfortunately vary among coff implementations... */ | 315 | 6.61k | pe->coff.local_n_btmask = N_BTMASK; | 316 | 6.61k | pe->coff.local_n_btshft = N_BTSHFT; | 317 | 6.61k | pe->coff.local_n_tmask = N_TMASK; | 318 | 6.61k | pe->coff.local_n_tshift = N_TSHIFT; | 319 | 6.61k | pe->coff.local_symesz = SYMESZ; | 320 | 6.61k | pe->coff.local_auxesz = AUXESZ; | 321 | 6.61k | pe->coff.local_linesz = LINESZ; | 322 | | | 323 | 6.61k | pe->coff.timestamp = internal_f->f_timdat; | 324 | | | 325 | 6.61k | obj_raw_syment_count (abfd) = | 326 | 6.61k | obj_conv_table_size (abfd) = | 327 | 6.61k | internal_f->f_nsyms; | 328 | | | 329 | 6.61k | pe->real_flags = internal_f->f_flags; | 330 | | | 331 | 6.61k | if ((internal_f->f_flags & F_DLL) != 0) | 332 | 2.07k | pe->dll = 1; | 333 | | | 334 | 6.61k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 335 | 4.88k | abfd->flags |= HAS_DEBUG; | 336 | | | 337 | 6.61k | #ifdef COFF_IMAGE_WITH_PE | 338 | 6.61k | if (aouthdr) | 339 | 4.45k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 340 | 6.61k | #endif | 341 | | | 342 | | #ifdef ARM | 343 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 344 | | coff_data (abfd) ->flags = 0; | 345 | | #endif | 346 | | | 347 | 6.61k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 348 | 6.61k | sizeof (pe->dos_message)); | 349 | | | 350 | 6.61k | return (void *) pe; | 351 | 6.61k | } |
pei-riscv64.c:pe_mkobject_hook Line | Count | Source | 303 | 7.07k | { | 304 | 7.07k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 305 | 7.07k | pe_data_type *pe; | 306 | | | 307 | 7.07k | if (! pe_mkobject (abfd)) | 308 | 0 | return NULL; | 309 | | | 310 | 7.07k | pe = pe_data (abfd); | 311 | 7.07k | pe->coff.sym_filepos = internal_f->f_symptr; | 312 | | /* These members communicate important constants about the symbol | 313 | | table to GDB's symbol-reading code. These `constants' | 314 | | unfortunately vary among coff implementations... */ | 315 | 7.07k | pe->coff.local_n_btmask = N_BTMASK; | 316 | 7.07k | pe->coff.local_n_btshft = N_BTSHFT; | 317 | 7.07k | pe->coff.local_n_tmask = N_TMASK; | 318 | 7.07k | pe->coff.local_n_tshift = N_TSHIFT; | 319 | 7.07k | pe->coff.local_symesz = SYMESZ; | 320 | 7.07k | pe->coff.local_auxesz = AUXESZ; | 321 | 7.07k | pe->coff.local_linesz = LINESZ; | 322 | | | 323 | 7.07k | pe->coff.timestamp = internal_f->f_timdat; | 324 | | | 325 | 7.07k | obj_raw_syment_count (abfd) = | 326 | 7.07k | obj_conv_table_size (abfd) = | 327 | 7.07k | internal_f->f_nsyms; | 328 | | | 329 | 7.07k | pe->real_flags = internal_f->f_flags; | 330 | | | 331 | 7.07k | if ((internal_f->f_flags & F_DLL) != 0) | 332 | 2.25k | pe->dll = 1; | 333 | | | 334 | 7.07k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 335 | 4.64k | abfd->flags |= HAS_DEBUG; | 336 | | | 337 | 7.07k | #ifdef COFF_IMAGE_WITH_PE | 338 | 7.07k | if (aouthdr) | 339 | 4.77k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 340 | 7.07k | #endif | 341 | | | 342 | | #ifdef ARM | 343 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 344 | | coff_data (abfd) ->flags = 0; | 345 | | #endif | 346 | | | 347 | 7.07k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 348 | 7.07k | sizeof (pe->dos_message)); | 349 | | | 350 | 7.07k | return (void *) pe; | 351 | 7.07k | } |
pe-arm-wince.c:pe_mkobject_hook Line | Count | Source | 303 | 2.88k | { | 304 | 2.88k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 305 | 2.88k | pe_data_type *pe; | 306 | | | 307 | 2.88k | if (! pe_mkobject (abfd)) | 308 | 0 | return NULL; | 309 | | | 310 | 2.88k | pe = pe_data (abfd); | 311 | 2.88k | pe->coff.sym_filepos = internal_f->f_symptr; | 312 | | /* These members communicate important constants about the symbol | 313 | | table to GDB's symbol-reading code. These `constants' | 314 | | unfortunately vary among coff implementations... */ | 315 | 2.88k | pe->coff.local_n_btmask = N_BTMASK; | 316 | 2.88k | pe->coff.local_n_btshft = N_BTSHFT; | 317 | 2.88k | pe->coff.local_n_tmask = N_TMASK; | 318 | 2.88k | pe->coff.local_n_tshift = N_TSHIFT; | 319 | 2.88k | pe->coff.local_symesz = SYMESZ; | 320 | 2.88k | pe->coff.local_auxesz = AUXESZ; | 321 | 2.88k | pe->coff.local_linesz = LINESZ; | 322 | | | 323 | 2.88k | pe->coff.timestamp = internal_f->f_timdat; | 324 | | | 325 | 2.88k | obj_raw_syment_count (abfd) = | 326 | 2.88k | obj_conv_table_size (abfd) = | 327 | 2.88k | internal_f->f_nsyms; | 328 | | | 329 | 2.88k | pe->real_flags = internal_f->f_flags; | 330 | | | 331 | 2.88k | if ((internal_f->f_flags & F_DLL) != 0) | 332 | 927 | pe->dll = 1; | 333 | | | 334 | 2.88k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 335 | 2.18k | abfd->flags |= HAS_DEBUG; | 336 | | | 337 | | #ifdef COFF_IMAGE_WITH_PE | 338 | | if (aouthdr) | 339 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 340 | | #endif | 341 | | | 342 | 2.88k | #ifdef ARM | 343 | 2.88k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 344 | 0 | coff_data (abfd) ->flags = 0; | 345 | 2.88k | #endif | 346 | | | 347 | 2.88k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 348 | 2.88k | sizeof (pe->dos_message)); | 349 | | | 350 | 2.88k | return (void *) pe; | 351 | 2.88k | } |
pe-arm.c:pe_mkobject_hook Line | Count | Source | 303 | 2.88k | { | 304 | 2.88k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 305 | 2.88k | pe_data_type *pe; | 306 | | | 307 | 2.88k | if (! pe_mkobject (abfd)) | 308 | 0 | return NULL; | 309 | | | 310 | 2.88k | pe = pe_data (abfd); | 311 | 2.88k | pe->coff.sym_filepos = internal_f->f_symptr; | 312 | | /* These members communicate important constants about the symbol | 313 | | table to GDB's symbol-reading code. These `constants' | 314 | | unfortunately vary among coff implementations... */ | 315 | 2.88k | pe->coff.local_n_btmask = N_BTMASK; | 316 | 2.88k | pe->coff.local_n_btshft = N_BTSHFT; | 317 | 2.88k | pe->coff.local_n_tmask = N_TMASK; | 318 | 2.88k | pe->coff.local_n_tshift = N_TSHIFT; | 319 | 2.88k | pe->coff.local_symesz = SYMESZ; | 320 | 2.88k | pe->coff.local_auxesz = AUXESZ; | 321 | 2.88k | pe->coff.local_linesz = LINESZ; | 322 | | | 323 | 2.88k | pe->coff.timestamp = internal_f->f_timdat; | 324 | | | 325 | 2.88k | obj_raw_syment_count (abfd) = | 326 | 2.88k | obj_conv_table_size (abfd) = | 327 | 2.88k | internal_f->f_nsyms; | 328 | | | 329 | 2.88k | pe->real_flags = internal_f->f_flags; | 330 | | | 331 | 2.88k | if ((internal_f->f_flags & F_DLL) != 0) | 332 | 927 | pe->dll = 1; | 333 | | | 334 | 2.88k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 335 | 2.18k | abfd->flags |= HAS_DEBUG; | 336 | | | 337 | | #ifdef COFF_IMAGE_WITH_PE | 338 | | if (aouthdr) | 339 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 340 | | #endif | 341 | | | 342 | 2.88k | #ifdef ARM | 343 | 2.88k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 344 | 0 | coff_data (abfd) ->flags = 0; | 345 | 2.88k | #endif | 346 | | | 347 | 2.88k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 348 | 2.88k | sizeof (pe->dos_message)); | 349 | | | 350 | 2.88k | return (void *) pe; | 351 | 2.88k | } |
pe-i386.c:pe_mkobject_hook Line | Count | Source | 303 | 6.74k | { | 304 | 6.74k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 305 | 6.74k | pe_data_type *pe; | 306 | | | 307 | 6.74k | if (! pe_mkobject (abfd)) | 308 | 0 | return NULL; | 309 | | | 310 | 6.74k | pe = pe_data (abfd); | 311 | 6.74k | pe->coff.sym_filepos = internal_f->f_symptr; | 312 | | /* These members communicate important constants about the symbol | 313 | | table to GDB's symbol-reading code. These `constants' | 314 | | unfortunately vary among coff implementations... */ | 315 | 6.74k | pe->coff.local_n_btmask = N_BTMASK; | 316 | 6.74k | pe->coff.local_n_btshft = N_BTSHFT; | 317 | 6.74k | pe->coff.local_n_tmask = N_TMASK; | 318 | 6.74k | pe->coff.local_n_tshift = N_TSHIFT; | 319 | 6.74k | pe->coff.local_symesz = SYMESZ; | 320 | 6.74k | pe->coff.local_auxesz = AUXESZ; | 321 | 6.74k | pe->coff.local_linesz = LINESZ; | 322 | | | 323 | 6.74k | pe->coff.timestamp = internal_f->f_timdat; | 324 | | | 325 | 6.74k | obj_raw_syment_count (abfd) = | 326 | 6.74k | obj_conv_table_size (abfd) = | 327 | 6.74k | internal_f->f_nsyms; | 328 | | | 329 | 6.74k | pe->real_flags = internal_f->f_flags; | 330 | | | 331 | 6.74k | if ((internal_f->f_flags & F_DLL) != 0) | 332 | 1.83k | pe->dll = 1; | 333 | | | 334 | 6.74k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 335 | 4.57k | abfd->flags |= HAS_DEBUG; | 336 | | | 337 | | #ifdef COFF_IMAGE_WITH_PE | 338 | | if (aouthdr) | 339 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 340 | | #endif | 341 | | | 342 | | #ifdef ARM | 343 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 344 | | coff_data (abfd) ->flags = 0; | 345 | | #endif | 346 | | | 347 | 6.74k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 348 | 6.74k | sizeof (pe->dos_message)); | 349 | | | 350 | 6.74k | return (void *) pe; | 351 | 6.74k | } |
pe-mcore.c:pe_mkobject_hook Line | Count | Source | 303 | 3.81k | { | 304 | 3.81k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 305 | 3.81k | pe_data_type *pe; | 306 | | | 307 | 3.81k | if (! pe_mkobject (abfd)) | 308 | 0 | return NULL; | 309 | | | 310 | 3.81k | pe = pe_data (abfd); | 311 | 3.81k | pe->coff.sym_filepos = internal_f->f_symptr; | 312 | | /* These members communicate important constants about the symbol | 313 | | table to GDB's symbol-reading code. These `constants' | 314 | | unfortunately vary among coff implementations... */ | 315 | 3.81k | pe->coff.local_n_btmask = N_BTMASK; | 316 | 3.81k | pe->coff.local_n_btshft = N_BTSHFT; | 317 | 3.81k | pe->coff.local_n_tmask = N_TMASK; | 318 | 3.81k | pe->coff.local_n_tshift = N_TSHIFT; | 319 | 3.81k | pe->coff.local_symesz = SYMESZ; | 320 | 3.81k | pe->coff.local_auxesz = AUXESZ; | 321 | 3.81k | pe->coff.local_linesz = LINESZ; | 322 | | | 323 | 3.81k | pe->coff.timestamp = internal_f->f_timdat; | 324 | | | 325 | 3.81k | obj_raw_syment_count (abfd) = | 326 | 3.81k | obj_conv_table_size (abfd) = | 327 | 3.81k | internal_f->f_nsyms; | 328 | | | 329 | 3.81k | pe->real_flags = internal_f->f_flags; | 330 | | | 331 | 3.81k | if ((internal_f->f_flags & F_DLL) != 0) | 332 | 1.30k | pe->dll = 1; | 333 | | | 334 | 3.81k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 335 | 3.02k | abfd->flags |= HAS_DEBUG; | 336 | | | 337 | | #ifdef COFF_IMAGE_WITH_PE | 338 | | if (aouthdr) | 339 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 340 | | #endif | 341 | | | 342 | | #ifdef ARM | 343 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 344 | | coff_data (abfd) ->flags = 0; | 345 | | #endif | 346 | | | 347 | 3.81k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 348 | 3.81k | sizeof (pe->dos_message)); | 349 | | | 350 | 3.81k | return (void *) pe; | 351 | 3.81k | } |
Line | Count | Source | 303 | 5.32k | { | 304 | 5.32k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 305 | 5.32k | pe_data_type *pe; | 306 | | | 307 | 5.32k | if (! pe_mkobject (abfd)) | 308 | 0 | return NULL; | 309 | | | 310 | 5.32k | pe = pe_data (abfd); | 311 | 5.32k | pe->coff.sym_filepos = internal_f->f_symptr; | 312 | | /* These members communicate important constants about the symbol | 313 | | table to GDB's symbol-reading code. These `constants' | 314 | | unfortunately vary among coff implementations... */ | 315 | 5.32k | pe->coff.local_n_btmask = N_BTMASK; | 316 | 5.32k | pe->coff.local_n_btshft = N_BTSHFT; | 317 | 5.32k | pe->coff.local_n_tmask = N_TMASK; | 318 | 5.32k | pe->coff.local_n_tshift = N_TSHIFT; | 319 | 5.32k | pe->coff.local_symesz = SYMESZ; | 320 | 5.32k | pe->coff.local_auxesz = AUXESZ; | 321 | 5.32k | pe->coff.local_linesz = LINESZ; | 322 | | | 323 | 5.32k | pe->coff.timestamp = internal_f->f_timdat; | 324 | | | 325 | 5.32k | obj_raw_syment_count (abfd) = | 326 | 5.32k | obj_conv_table_size (abfd) = | 327 | 5.32k | internal_f->f_nsyms; | 328 | | | 329 | 5.32k | pe->real_flags = internal_f->f_flags; | 330 | | | 331 | 5.32k | if ((internal_f->f_flags & F_DLL) != 0) | 332 | 1.55k | pe->dll = 1; | 333 | | | 334 | 5.32k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 335 | 3.94k | abfd->flags |= HAS_DEBUG; | 336 | | | 337 | | #ifdef COFF_IMAGE_WITH_PE | 338 | | if (aouthdr) | 339 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 340 | | #endif | 341 | | | 342 | | #ifdef ARM | 343 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 344 | | coff_data (abfd) ->flags = 0; | 345 | | #endif | 346 | | | 347 | 5.32k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 348 | 5.32k | sizeof (pe->dos_message)); | 349 | | | 350 | 5.32k | return (void *) pe; | 351 | 5.32k | } |
pei-arm-wince.c:pe_mkobject_hook Line | Count | Source | 303 | 5.44k | { | 304 | 5.44k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 305 | 5.44k | pe_data_type *pe; | 306 | | | 307 | 5.44k | if (! pe_mkobject (abfd)) | 308 | 0 | return NULL; | 309 | | | 310 | 5.44k | pe = pe_data (abfd); | 311 | 5.44k | pe->coff.sym_filepos = internal_f->f_symptr; | 312 | | /* These members communicate important constants about the symbol | 313 | | table to GDB's symbol-reading code. These `constants' | 314 | | unfortunately vary among coff implementations... */ | 315 | 5.44k | pe->coff.local_n_btmask = N_BTMASK; | 316 | 5.44k | pe->coff.local_n_btshft = N_BTSHFT; | 317 | 5.44k | pe->coff.local_n_tmask = N_TMASK; | 318 | 5.44k | pe->coff.local_n_tshift = N_TSHIFT; | 319 | 5.44k | pe->coff.local_symesz = SYMESZ; | 320 | 5.44k | pe->coff.local_auxesz = AUXESZ; | 321 | 5.44k | pe->coff.local_linesz = LINESZ; | 322 | | | 323 | 5.44k | pe->coff.timestamp = internal_f->f_timdat; | 324 | | | 325 | 5.44k | obj_raw_syment_count (abfd) = | 326 | 5.44k | obj_conv_table_size (abfd) = | 327 | 5.44k | internal_f->f_nsyms; | 328 | | | 329 | 5.44k | pe->real_flags = internal_f->f_flags; | 330 | | | 331 | 5.44k | if ((internal_f->f_flags & F_DLL) != 0) | 332 | 1.87k | pe->dll = 1; | 333 | | | 334 | 5.44k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 335 | 3.43k | abfd->flags |= HAS_DEBUG; | 336 | | | 337 | 5.44k | #ifdef COFF_IMAGE_WITH_PE | 338 | 5.44k | if (aouthdr) | 339 | 1.92k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 340 | 5.44k | #endif | 341 | | | 342 | 5.44k | #ifdef ARM | 343 | 5.44k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 344 | 0 | coff_data (abfd) ->flags = 0; | 345 | 5.44k | #endif | 346 | | | 347 | 5.44k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 348 | 5.44k | sizeof (pe->dos_message)); | 349 | | | 350 | 5.44k | return (void *) pe; | 351 | 5.44k | } |
pei-arm.c:pe_mkobject_hook Line | Count | Source | 303 | 7.15k | { | 304 | 7.15k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 305 | 7.15k | pe_data_type *pe; | 306 | | | 307 | 7.15k | if (! pe_mkobject (abfd)) | 308 | 0 | return NULL; | 309 | | | 310 | 7.15k | pe = pe_data (abfd); | 311 | 7.15k | pe->coff.sym_filepos = internal_f->f_symptr; | 312 | | /* These members communicate important constants about the symbol | 313 | | table to GDB's symbol-reading code. These `constants' | 314 | | unfortunately vary among coff implementations... */ | 315 | 7.15k | pe->coff.local_n_btmask = N_BTMASK; | 316 | 7.15k | pe->coff.local_n_btshft = N_BTSHFT; | 317 | 7.15k | pe->coff.local_n_tmask = N_TMASK; | 318 | 7.15k | pe->coff.local_n_tshift = N_TSHIFT; | 319 | 7.15k | pe->coff.local_symesz = SYMESZ; | 320 | 7.15k | pe->coff.local_auxesz = AUXESZ; | 321 | 7.15k | pe->coff.local_linesz = LINESZ; | 322 | | | 323 | 7.15k | pe->coff.timestamp = internal_f->f_timdat; | 324 | | | 325 | 7.15k | obj_raw_syment_count (abfd) = | 326 | 7.15k | obj_conv_table_size (abfd) = | 327 | 7.15k | internal_f->f_nsyms; | 328 | | | 329 | 7.15k | pe->real_flags = internal_f->f_flags; | 330 | | | 331 | 7.15k | if ((internal_f->f_flags & F_DLL) != 0) | 332 | 2.67k | pe->dll = 1; | 333 | | | 334 | 7.15k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 335 | 4.50k | abfd->flags |= HAS_DEBUG; | 336 | | | 337 | 7.15k | #ifdef COFF_IMAGE_WITH_PE | 338 | 7.15k | if (aouthdr) | 339 | 3.63k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 340 | 7.15k | #endif | 341 | | | 342 | 7.15k | #ifdef ARM | 343 | 7.15k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 344 | 0 | coff_data (abfd) ->flags = 0; | 345 | 7.15k | #endif | 346 | | | 347 | 7.15k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 348 | 7.15k | sizeof (pe->dos_message)); | 349 | | | 350 | 7.15k | return (void *) pe; | 351 | 7.15k | } |
pei-mcore.c:pe_mkobject_hook Line | Count | Source | 303 | 5.62k | { | 304 | 5.62k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 305 | 5.62k | pe_data_type *pe; | 306 | | | 307 | 5.62k | if (! pe_mkobject (abfd)) | 308 | 0 | return NULL; | 309 | | | 310 | 5.62k | pe = pe_data (abfd); | 311 | 5.62k | pe->coff.sym_filepos = internal_f->f_symptr; | 312 | | /* These members communicate important constants about the symbol | 313 | | table to GDB's symbol-reading code. These `constants' | 314 | | unfortunately vary among coff implementations... */ | 315 | 5.62k | pe->coff.local_n_btmask = N_BTMASK; | 316 | 5.62k | pe->coff.local_n_btshft = N_BTSHFT; | 317 | 5.62k | pe->coff.local_n_tmask = N_TMASK; | 318 | 5.62k | pe->coff.local_n_tshift = N_TSHIFT; | 319 | 5.62k | pe->coff.local_symesz = SYMESZ; | 320 | 5.62k | pe->coff.local_auxesz = AUXESZ; | 321 | 5.62k | pe->coff.local_linesz = LINESZ; | 322 | | | 323 | 5.62k | pe->coff.timestamp = internal_f->f_timdat; | 324 | | | 325 | 5.62k | obj_raw_syment_count (abfd) = | 326 | 5.62k | obj_conv_table_size (abfd) = | 327 | 5.62k | internal_f->f_nsyms; | 328 | | | 329 | 5.62k | pe->real_flags = internal_f->f_flags; | 330 | | | 331 | 5.62k | if ((internal_f->f_flags & F_DLL) != 0) | 332 | 2.02k | pe->dll = 1; | 333 | | | 334 | 5.62k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 335 | 3.63k | abfd->flags |= HAS_DEBUG; | 336 | | | 337 | 5.62k | #ifdef COFF_IMAGE_WITH_PE | 338 | 5.62k | if (aouthdr) | 339 | 3.39k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 340 | 5.62k | #endif | 341 | | | 342 | | #ifdef ARM | 343 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 344 | | coff_data (abfd) ->flags = 0; | 345 | | #endif | 346 | | | 347 | 5.62k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 348 | 5.62k | sizeof (pe->dos_message)); | 349 | | | 350 | 5.62k | return (void *) pe; | 351 | 5.62k | } |
pei-sh.c:pe_mkobject_hook Line | Count | Source | 303 | 6.22k | { | 304 | 6.22k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 305 | 6.22k | pe_data_type *pe; | 306 | | | 307 | 6.22k | if (! pe_mkobject (abfd)) | 308 | 0 | return NULL; | 309 | | | 310 | 6.22k | pe = pe_data (abfd); | 311 | 6.22k | pe->coff.sym_filepos = internal_f->f_symptr; | 312 | | /* These members communicate important constants about the symbol | 313 | | table to GDB's symbol-reading code. These `constants' | 314 | | unfortunately vary among coff implementations... */ | 315 | 6.22k | pe->coff.local_n_btmask = N_BTMASK; | 316 | 6.22k | pe->coff.local_n_btshft = N_BTSHFT; | 317 | 6.22k | pe->coff.local_n_tmask = N_TMASK; | 318 | 6.22k | pe->coff.local_n_tshift = N_TSHIFT; | 319 | 6.22k | pe->coff.local_symesz = SYMESZ; | 320 | 6.22k | pe->coff.local_auxesz = AUXESZ; | 321 | 6.22k | pe->coff.local_linesz = LINESZ; | 322 | | | 323 | 6.22k | pe->coff.timestamp = internal_f->f_timdat; | 324 | | | 325 | 6.22k | obj_raw_syment_count (abfd) = | 326 | 6.22k | obj_conv_table_size (abfd) = | 327 | 6.22k | internal_f->f_nsyms; | 328 | | | 329 | 6.22k | pe->real_flags = internal_f->f_flags; | 330 | | | 331 | 6.22k | if ((internal_f->f_flags & F_DLL) != 0) | 332 | 2.13k | pe->dll = 1; | 333 | | | 334 | 6.22k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 335 | 4.15k | abfd->flags |= HAS_DEBUG; | 336 | | | 337 | 6.22k | #ifdef COFF_IMAGE_WITH_PE | 338 | 6.22k | if (aouthdr) | 339 | 3.49k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 340 | 6.22k | #endif | 341 | | | 342 | | #ifdef ARM | 343 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 344 | | coff_data (abfd) ->flags = 0; | 345 | | #endif | 346 | | | 347 | 6.22k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 348 | 6.22k | sizeof (pe->dos_message)); | 349 | | | 350 | 6.22k | return (void *) pe; | 351 | 6.22k | } |
|
352 | | |
353 | | static bool |
354 | | pe_print_private_bfd_data (bfd *abfd, void *vfile) |
355 | 9.95k | { |
356 | 9.95k | FILE *file = (FILE *) vfile; |
357 | | |
358 | 9.95k | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) |
359 | 0 | return false; |
360 | | |
361 | 9.95k | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) |
362 | 9.74k | return true; |
363 | | |
364 | 205 | fputc ('\n', file); |
365 | | |
366 | 205 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); |
367 | 9.95k | } pei-i386.c:pe_print_private_bfd_data Line | Count | Source | 355 | 203 | { | 356 | 203 | FILE *file = (FILE *) vfile; | 357 | | | 358 | 203 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 359 | 0 | return false; | 360 | | | 361 | 203 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 362 | 203 | return true; | 363 | | | 364 | 0 | fputc ('\n', file); | 365 | |
| 366 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 367 | 203 | } |
pe-x86_64.c:pe_print_private_bfd_data Line | Count | Source | 355 | 168 | { | 356 | 168 | FILE *file = (FILE *) vfile; | 357 | | | 358 | 168 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 359 | 0 | return false; | 360 | | | 361 | 168 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 362 | 168 | return true; | 363 | | | 364 | 0 | fputc ('\n', file); | 365 | |
| 366 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 367 | 168 | } |
pei-x86_64.c:pe_print_private_bfd_data Line | Count | Source | 355 | 210 | { | 356 | 210 | FILE *file = (FILE *) vfile; | 357 | | | 358 | 210 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 359 | 0 | return false; | 360 | | | 361 | 210 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 362 | 210 | return true; | 363 | | | 364 | 0 | fputc ('\n', file); | 365 | |
| 366 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 367 | 210 | } |
pe-aarch64.c:pe_print_private_bfd_data Line | Count | Source | 355 | 5.18k | { | 356 | 5.18k | FILE *file = (FILE *) vfile; | 357 | | | 358 | 5.18k | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 359 | 0 | return false; | 360 | | | 361 | 5.18k | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 362 | 5.18k | return true; | 363 | | | 364 | 0 | fputc ('\n', file); | 365 | |
| 366 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 367 | 5.18k | } |
pei-aarch64.c:pe_print_private_bfd_data Line | Count | Source | 355 | 2.81k | { | 356 | 2.81k | FILE *file = (FILE *) vfile; | 357 | | | 358 | 2.81k | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 359 | 0 | return false; | 360 | | | 361 | 2.81k | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 362 | 2.81k | return true; | 363 | | | 364 | 0 | fputc ('\n', file); | 365 | |
| 366 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 367 | 2.81k | } |
pei-ia64.c:pe_print_private_bfd_data Line | Count | Source | 355 | 313 | { | 356 | 313 | FILE *file = (FILE *) vfile; | 357 | | | 358 | 313 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 359 | 0 | return false; | 360 | | | 361 | 313 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 362 | 313 | return true; | 363 | | | 364 | 0 | fputc ('\n', file); | 365 | |
| 366 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 367 | 313 | } |
pei-loongarch64.c:pe_print_private_bfd_data Line | Count | Source | 355 | 198 | { | 356 | 198 | FILE *file = (FILE *) vfile; | 357 | | | 358 | 198 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 359 | 0 | return false; | 360 | | | 361 | 198 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 362 | 198 | return true; | 363 | | | 364 | 0 | fputc ('\n', file); | 365 | |
| 366 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 367 | 198 | } |
pei-riscv64.c:pe_print_private_bfd_data Line | Count | Source | 355 | 199 | { | 356 | 199 | FILE *file = (FILE *) vfile; | 357 | | | 358 | 199 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 359 | 0 | return false; | 360 | | | 361 | 199 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 362 | 199 | return true; | 363 | | | 364 | 0 | fputc ('\n', file); | 365 | |
| 366 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 367 | 199 | } |
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 | 355 | 69 | { | 356 | 69 | FILE *file = (FILE *) vfile; | 357 | | | 358 | 69 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 359 | 0 | return false; | 360 | | | 361 | 69 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 362 | 69 | return true; | 363 | | | 364 | 0 | fputc ('\n', file); | 365 | |
| 366 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 367 | 69 | } |
pe-mcore.c:pe_print_private_bfd_data Line | Count | Source | 355 | 94 | { | 356 | 94 | FILE *file = (FILE *) vfile; | 357 | | | 358 | 94 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 359 | 0 | return false; | 360 | | | 361 | 94 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 362 | 94 | return true; | 363 | | | 364 | 0 | fputc ('\n', file); | 365 | |
| 366 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 367 | 94 | } |
pe-sh.c:pe_print_private_bfd_data Line | Count | Source | 355 | 63 | { | 356 | 63 | FILE *file = (FILE *) vfile; | 357 | | | 358 | 63 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 359 | 0 | return false; | 360 | | | 361 | 63 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 362 | 63 | return true; | 363 | | | 364 | 0 | fputc ('\n', file); | 365 | |
| 366 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 367 | 63 | } |
pei-arm-wince.c:pe_print_private_bfd_data Line | Count | Source | 355 | 7 | { | 356 | 7 | FILE *file = (FILE *) vfile; | 357 | | | 358 | 7 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 359 | 0 | return false; | 360 | | | 361 | 7 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 362 | 0 | return true; | 363 | | | 364 | 7 | fputc ('\n', file); | 365 | | | 366 | 7 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 367 | 7 | } |
pei-arm.c:pe_print_private_bfd_data Line | Count | Source | 355 | 198 | { | 356 | 198 | FILE *file = (FILE *) vfile; | 357 | | | 358 | 198 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 359 | 0 | return false; | 360 | | | 361 | 198 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 362 | 0 | return true; | 363 | | | 364 | 198 | fputc ('\n', file); | 365 | | | 366 | 198 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 367 | 198 | } |
pei-mcore.c:pe_print_private_bfd_data Line | Count | Source | 355 | 128 | { | 356 | 128 | FILE *file = (FILE *) vfile; | 357 | | | 358 | 128 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 359 | 0 | return false; | 360 | | | 361 | 128 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 362 | 128 | return true; | 363 | | | 364 | 0 | fputc ('\n', file); | 365 | |
| 366 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 367 | 128 | } |
pei-sh.c:pe_print_private_bfd_data Line | Count | Source | 355 | 100 | { | 356 | 100 | FILE *file = (FILE *) vfile; | 357 | | | 358 | 100 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 359 | 0 | return false; | 360 | | | 361 | 100 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 362 | 100 | return true; | 363 | | | 364 | 0 | fputc ('\n', file); | 365 | |
| 366 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 367 | 100 | } |
|
368 | | |
369 | | /* Copy any private info we understand from the input bfd |
370 | | to the output bfd. */ |
371 | | |
372 | | static bool |
373 | | pe_bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd) |
374 | 1.63k | { |
375 | | /* PR binutils/716: Copy the large address aware flag. |
376 | | XXX: Should we be copying other flags or other fields in the pe_data() |
377 | | structure ? */ |
378 | 1.63k | if (pe_data (obfd) != NULL |
379 | 1.63k | && pe_data (ibfd) != NULL |
380 | 1.63k | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) |
381 | 567 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; |
382 | | |
383 | 1.63k | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) |
384 | 15 | return false; |
385 | | |
386 | 1.61k | if (pe_saved_coff_bfd_copy_private_bfd_data) |
387 | 169 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); |
388 | | |
389 | 1.44k | return true; |
390 | 1.61k | } pei-i386.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 374 | 91 | { | 375 | | /* PR binutils/716: Copy the large address aware flag. | 376 | | XXX: Should we be copying other flags or other fields in the pe_data() | 377 | | structure ? */ | 378 | 91 | if (pe_data (obfd) != NULL | 379 | 91 | && pe_data (ibfd) != NULL | 380 | 91 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 381 | 20 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 382 | | | 383 | 91 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 384 | 1 | return false; | 385 | | | 386 | 90 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 387 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 388 | | | 389 | 90 | return true; | 390 | 90 | } |
pe-x86_64.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 374 | 125 | { | 375 | | /* PR binutils/716: Copy the large address aware flag. | 376 | | XXX: Should we be copying other flags or other fields in the pe_data() | 377 | | structure ? */ | 378 | 125 | if (pe_data (obfd) != NULL | 379 | 125 | && pe_data (ibfd) != NULL | 380 | 125 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 381 | 37 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 382 | | | 383 | 125 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 384 | 0 | return false; | 385 | | | 386 | 125 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 387 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 388 | | | 389 | 125 | return true; | 390 | 125 | } |
pei-x86_64.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 374 | 117 | { | 375 | | /* PR binutils/716: Copy the large address aware flag. | 376 | | XXX: Should we be copying other flags or other fields in the pe_data() | 377 | | structure ? */ | 378 | 117 | if (pe_data (obfd) != NULL | 379 | 117 | && pe_data (ibfd) != NULL | 380 | 117 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 381 | 47 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 382 | | | 383 | 117 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 384 | 1 | return false; | 385 | | | 386 | 116 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 387 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 388 | | | 389 | 116 | return true; | 390 | 116 | } |
pe-aarch64.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 374 | 121 | { | 375 | | /* PR binutils/716: Copy the large address aware flag. | 376 | | XXX: Should we be copying other flags or other fields in the pe_data() | 377 | | structure ? */ | 378 | 121 | if (pe_data (obfd) != NULL | 379 | 121 | && pe_data (ibfd) != NULL | 380 | 121 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 381 | 23 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 382 | | | 383 | 121 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 384 | 0 | return false; | 385 | | | 386 | 121 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 387 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 388 | | | 389 | 121 | return true; | 390 | 121 | } |
pei-aarch64.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 374 | 115 | { | 375 | | /* PR binutils/716: Copy the large address aware flag. | 376 | | XXX: Should we be copying other flags or other fields in the pe_data() | 377 | | structure ? */ | 378 | 115 | if (pe_data (obfd) != NULL | 379 | 115 | && pe_data (ibfd) != NULL | 380 | 115 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 381 | 39 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 382 | | | 383 | 115 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 384 | 1 | return false; | 385 | | | 386 | 114 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 387 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 388 | | | 389 | 114 | return true; | 390 | 114 | } |
pei-ia64.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 374 | 176 | { | 375 | | /* PR binutils/716: Copy the large address aware flag. | 376 | | XXX: Should we be copying other flags or other fields in the pe_data() | 377 | | structure ? */ | 378 | 176 | if (pe_data (obfd) != NULL | 379 | 176 | && pe_data (ibfd) != NULL | 380 | 176 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 381 | 47 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 382 | | | 383 | 176 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 384 | 2 | return false; | 385 | | | 386 | 174 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 387 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 388 | | | 389 | 174 | return true; | 390 | 174 | } |
pei-loongarch64.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 374 | 147 | { | 375 | | /* PR binutils/716: Copy the large address aware flag. | 376 | | XXX: Should we be copying other flags or other fields in the pe_data() | 377 | | structure ? */ | 378 | 147 | if (pe_data (obfd) != NULL | 379 | 147 | && pe_data (ibfd) != NULL | 380 | 147 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 381 | 56 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 382 | | | 383 | 147 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 384 | 2 | return false; | 385 | | | 386 | 145 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 387 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 388 | | | 389 | 145 | return true; | 390 | 145 | } |
pei-riscv64.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 374 | 168 | { | 375 | | /* PR binutils/716: Copy the large address aware flag. | 376 | | XXX: Should we be copying other flags or other fields in the pe_data() | 377 | | structure ? */ | 378 | 168 | if (pe_data (obfd) != NULL | 379 | 168 | && pe_data (ibfd) != NULL | 380 | 168 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 381 | 84 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 382 | | | 383 | 168 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 384 | 4 | return false; | 385 | | | 386 | 164 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 387 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 388 | | | 389 | 164 | return true; | 390 | 164 | } |
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 | 374 | 85 | { | 375 | | /* PR binutils/716: Copy the large address aware flag. | 376 | | XXX: Should we be copying other flags or other fields in the pe_data() | 377 | | structure ? */ | 378 | 85 | if (pe_data (obfd) != NULL | 379 | 85 | && pe_data (ibfd) != NULL | 380 | 85 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 381 | 14 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 382 | | | 383 | 85 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 384 | 0 | return false; | 385 | | | 386 | 85 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 387 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 388 | | | 389 | 85 | return true; | 390 | 85 | } |
pe-mcore.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 374 | 95 | { | 375 | | /* PR binutils/716: Copy the large address aware flag. | 376 | | XXX: Should we be copying other flags or other fields in the pe_data() | 377 | | structure ? */ | 378 | 95 | if (pe_data (obfd) != NULL | 379 | 95 | && pe_data (ibfd) != NULL | 380 | 95 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 381 | 25 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 382 | | | 383 | 95 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 384 | 0 | return false; | 385 | | | 386 | 95 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 387 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 388 | | | 389 | 95 | return true; | 390 | 95 | } |
pe-sh.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 374 | 81 | { | 375 | | /* PR binutils/716: Copy the large address aware flag. | 376 | | XXX: Should we be copying other flags or other fields in the pe_data() | 377 | | structure ? */ | 378 | 81 | if (pe_data (obfd) != NULL | 379 | 81 | && pe_data (ibfd) != NULL | 380 | 81 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 381 | 27 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 382 | | | 383 | 81 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 384 | 0 | return false; | 385 | | | 386 | 81 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 387 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 388 | | | 389 | 81 | return true; | 390 | 81 | } |
pei-arm-wince.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 374 | 65 | { | 375 | | /* PR binutils/716: Copy the large address aware flag. | 376 | | XXX: Should we be copying other flags or other fields in the pe_data() | 377 | | structure ? */ | 378 | 65 | if (pe_data (obfd) != NULL | 379 | 65 | && pe_data (ibfd) != NULL | 380 | 65 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 381 | 33 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 382 | | | 383 | 65 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 384 | 0 | return false; | 385 | | | 386 | 65 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 387 | 65 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 388 | | | 389 | 0 | return true; | 390 | 65 | } |
pei-arm.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 374 | 107 | { | 375 | | /* PR binutils/716: Copy the large address aware flag. | 376 | | XXX: Should we be copying other flags or other fields in the pe_data() | 377 | | structure ? */ | 378 | 107 | if (pe_data (obfd) != NULL | 379 | 107 | && pe_data (ibfd) != NULL | 380 | 107 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 381 | 63 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 382 | | | 383 | 107 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 384 | 3 | return false; | 385 | | | 386 | 104 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 387 | 104 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 388 | | | 389 | 0 | return true; | 390 | 104 | } |
pei-mcore.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 374 | 61 | { | 375 | | /* PR binutils/716: Copy the large address aware flag. | 376 | | XXX: Should we be copying other flags or other fields in the pe_data() | 377 | | structure ? */ | 378 | 61 | if (pe_data (obfd) != NULL | 379 | 61 | && pe_data (ibfd) != NULL | 380 | 61 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 381 | 36 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 382 | | | 383 | 61 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 384 | 1 | return false; | 385 | | | 386 | 60 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 387 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 388 | | | 389 | 60 | return true; | 390 | 60 | } |
pei-sh.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 374 | 79 | { | 375 | | /* PR binutils/716: Copy the large address aware flag. | 376 | | XXX: Should we be copying other flags or other fields in the pe_data() | 377 | | structure ? */ | 378 | 79 | if (pe_data (obfd) != NULL | 379 | 79 | && pe_data (ibfd) != NULL | 380 | 79 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 381 | 16 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 382 | | | 383 | 79 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 384 | 0 | return false; | 385 | | | 386 | 79 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 387 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 388 | | | 389 | 79 | return true; | 390 | 79 | } |
|
391 | | |
392 | | #define coff_bfd_copy_private_section_data \ |
393 | | _bfd_XX_bfd_copy_private_section_data |
394 | | |
395 | | #define coff_get_symbol_info _bfd_XX_get_symbol_info |
396 | | |
397 | | #ifdef COFF_IMAGE_WITH_PE |
398 | | |
399 | | /* Code to handle Microsoft's Import Library Format. |
400 | | Also known as LINK6 format. |
401 | | Documentation about this format can be found at: |
402 | | |
403 | | https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#import-library-format */ |
404 | | |
405 | | /* The following constants specify the sizes of the various data |
406 | | structures that we have to create in order to build a bfd describing |
407 | | an ILF object file. The final "+ 1" in the definitions of SIZEOF_IDATA6 |
408 | | and SIZEOF_IDATA7 below is to allow for the possibility that we might |
409 | | need a padding byte in order to ensure 16 bit alignment for the section's |
410 | | contents. |
411 | | |
412 | | The value for SIZEOF_ILF_STRINGS is computed as follows: |
413 | | |
414 | | There will be NUM_ILF_SECTIONS section symbols. Allow 9 characters |
415 | | per symbol for their names (longest section name is .idata$x). |
416 | | |
417 | | There will be two symbols for the imported value, one the symbol name |
418 | | and one with _imp__ prefixed. Allowing for the terminating nul's this |
419 | | is strlen (symbol_name) * 2 + 8 + 21 + strlen (source_dll). |
420 | | |
421 | | The strings in the string table must start STRING__SIZE_SIZE bytes into |
422 | | the table in order to for the string lookup code in coffgen/coffcode to |
423 | | work. */ |
424 | 8.46k | #define NUM_ILF_RELOCS 8 |
425 | 28.5k | #define NUM_ILF_SECTIONS 6 |
426 | 21.1k | #define NUM_ILF_SYMS (2 + NUM_ILF_SECTIONS) |
427 | | |
428 | 4.23k | #define SIZEOF_ILF_SYMS (NUM_ILF_SYMS * sizeof (*vars.sym_cache)) |
429 | 4.23k | #define SIZEOF_ILF_SYM_TABLE (NUM_ILF_SYMS * sizeof (*vars.sym_table)) |
430 | 4.23k | #define SIZEOF_ILF_NATIVE_SYMS (NUM_ILF_SYMS * sizeof (*vars.native_syms)) |
431 | 4.23k | #define SIZEOF_ILF_SYM_PTR_TABLE (NUM_ILF_SYMS * sizeof (*vars.sym_ptr_table)) |
432 | 4.23k | #define SIZEOF_ILF_EXT_SYMS (NUM_ILF_SYMS * sizeof (*vars.esym_table)) |
433 | 4.23k | #define SIZEOF_ILF_RELOCS (NUM_ILF_RELOCS * sizeof (*vars.reltab)) |
434 | 4.23k | #define SIZEOF_ILF_INT_RELOCS (NUM_ILF_RELOCS * sizeof (*vars.int_reltab)) |
435 | 4.23k | #define SIZEOF_ILF_STRINGS (strlen (symbol_name) * 2 + 8 \ |
436 | 4.23k | + 21 + strlen (source_dll) \ |
437 | 4.23k | + NUM_ILF_SECTIONS * 9 \ |
438 | 4.23k | + STRING_SIZE_SIZE) |
439 | 3.17k | #define SIZEOF_IDATA2 (5 * 4) |
440 | | |
441 | | /* For PEx64 idata4 & 5 have thumb size of 8 bytes. */ |
442 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) |
443 | 1.03k | #define SIZEOF_IDATA4 (2 * 4) |
444 | 1.03k | #define SIZEOF_IDATA5 (2 * 4) |
445 | | #else |
446 | 3.20k | #define SIZEOF_IDATA4 (1 * 4) |
447 | 3.20k | #define SIZEOF_IDATA5 (1 * 4) |
448 | | #endif |
449 | | |
450 | 3.90k | #define SIZEOF_IDATA6 (2 + strlen (import_name) + 1 + 1) |
451 | 3.17k | #define SIZEOF_IDATA7 (strlen (source_dll) + 1 + 1) |
452 | 3.17k | #define SIZEOF_ILF_SECTIONS (NUM_ILF_SECTIONS \ |
453 | 3.17k | * sizeof (struct coff_section_tdata)) |
454 | | |
455 | | #define ILF_DATA_SIZE \ |
456 | 3.17k | + SIZEOF_ILF_SYMS \ |
457 | 3.17k | + SIZEOF_ILF_SYM_TABLE \ |
458 | 3.17k | + SIZEOF_ILF_NATIVE_SYMS \ |
459 | 3.17k | + SIZEOF_ILF_SYM_PTR_TABLE \ |
460 | 3.17k | + SIZEOF_ILF_EXT_SYMS \ |
461 | 3.17k | + SIZEOF_ILF_RELOCS \ |
462 | 3.17k | + SIZEOF_ILF_INT_RELOCS \ |
463 | 3.17k | + SIZEOF_ILF_STRINGS \ |
464 | 3.17k | + SIZEOF_IDATA2 \ |
465 | 3.17k | + SIZEOF_IDATA4 \ |
466 | 3.17k | + SIZEOF_IDATA5 \ |
467 | 3.17k | + SIZEOF_IDATA6 \ |
468 | 3.17k | + SIZEOF_IDATA7 \ |
469 | 3.17k | + SIZEOF_ILF_SECTIONS \ |
470 | 3.17k | + MAX_TEXT_SECTION_SIZE |
471 | | |
472 | | /* Create an empty relocation against the given symbol. */ |
473 | | |
474 | | static void |
475 | | pe_ILF_make_a_symbol_reloc (pe_ILF_vars * vars, |
476 | | bfd_vma address, |
477 | | bfd_reloc_code_real_type reloc, |
478 | | struct bfd_symbol ** sym, |
479 | | unsigned int sym_index) |
480 | 1.89k | { |
481 | 1.89k | arelent *entry; |
482 | 1.89k | struct internal_reloc *internal; |
483 | | |
484 | 1.89k | entry = vars->reltab + vars->relcount; |
485 | 1.89k | internal = vars->int_reltab + vars->relcount; |
486 | | |
487 | 1.89k | entry->address = address; |
488 | 1.89k | entry->addend = 0; |
489 | 1.89k | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); |
490 | 1.89k | entry->sym_ptr_ptr = sym; |
491 | | |
492 | 1.89k | internal->r_vaddr = address; |
493 | 1.89k | internal->r_symndx = sym_index; |
494 | 1.89k | internal->r_type = entry->howto ? entry->howto->type : 0; |
495 | | |
496 | 1.89k | vars->relcount ++; |
497 | | |
498 | 1.89k | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); |
499 | 1.89k | } pei-i386.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 480 | 295 | { | 481 | 295 | arelent *entry; | 482 | 295 | struct internal_reloc *internal; | 483 | | | 484 | 295 | entry = vars->reltab + vars->relcount; | 485 | 295 | internal = vars->int_reltab + vars->relcount; | 486 | | | 487 | 295 | entry->address = address; | 488 | 295 | entry->addend = 0; | 489 | 295 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 490 | 295 | entry->sym_ptr_ptr = sym; | 491 | | | 492 | 295 | internal->r_vaddr = address; | 493 | 295 | internal->r_symndx = sym_index; | 494 | 295 | internal->r_type = entry->howto ? entry->howto->type : 0; | 495 | | | 496 | 295 | vars->relcount ++; | 497 | | | 498 | 295 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 499 | 295 | } |
pei-x86_64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 480 | 214 | { | 481 | 214 | arelent *entry; | 482 | 214 | struct internal_reloc *internal; | 483 | | | 484 | 214 | entry = vars->reltab + vars->relcount; | 485 | 214 | internal = vars->int_reltab + vars->relcount; | 486 | | | 487 | 214 | entry->address = address; | 488 | 214 | entry->addend = 0; | 489 | 214 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 490 | 214 | entry->sym_ptr_ptr = sym; | 491 | | | 492 | 214 | internal->r_vaddr = address; | 493 | 214 | internal->r_symndx = sym_index; | 494 | 214 | internal->r_type = entry->howto ? entry->howto->type : 0; | 495 | | | 496 | 214 | vars->relcount ++; | 497 | | | 498 | 214 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 499 | 214 | } |
pei-aarch64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 480 | 236 | { | 481 | 236 | arelent *entry; | 482 | 236 | struct internal_reloc *internal; | 483 | | | 484 | 236 | entry = vars->reltab + vars->relcount; | 485 | 236 | internal = vars->int_reltab + vars->relcount; | 486 | | | 487 | 236 | entry->address = address; | 488 | 236 | entry->addend = 0; | 489 | 236 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 490 | 236 | entry->sym_ptr_ptr = sym; | 491 | | | 492 | 236 | internal->r_vaddr = address; | 493 | 236 | internal->r_symndx = sym_index; | 494 | 236 | internal->r_type = entry->howto ? entry->howto->type : 0; | 495 | | | 496 | 236 | vars->relcount ++; | 497 | | | 498 | 236 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 499 | 236 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_symbol_reloc pei-loongarch64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 480 | 230 | { | 481 | 230 | arelent *entry; | 482 | 230 | struct internal_reloc *internal; | 483 | | | 484 | 230 | entry = vars->reltab + vars->relcount; | 485 | 230 | internal = vars->int_reltab + vars->relcount; | 486 | | | 487 | 230 | entry->address = address; | 488 | 230 | entry->addend = 0; | 489 | 230 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 490 | 230 | entry->sym_ptr_ptr = sym; | 491 | | | 492 | 230 | internal->r_vaddr = address; | 493 | 230 | internal->r_symndx = sym_index; | 494 | 230 | internal->r_type = entry->howto ? entry->howto->type : 0; | 495 | | | 496 | 230 | vars->relcount ++; | 497 | | | 498 | 230 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 499 | 230 | } |
pei-riscv64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 480 | 237 | { | 481 | 237 | arelent *entry; | 482 | 237 | struct internal_reloc *internal; | 483 | | | 484 | 237 | entry = vars->reltab + vars->relcount; | 485 | 237 | internal = vars->int_reltab + vars->relcount; | 486 | | | 487 | 237 | entry->address = address; | 488 | 237 | entry->addend = 0; | 489 | 237 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 490 | 237 | entry->sym_ptr_ptr = sym; | 491 | | | 492 | 237 | internal->r_vaddr = address; | 493 | 237 | internal->r_symndx = sym_index; | 494 | 237 | internal->r_type = entry->howto ? entry->howto->type : 0; | 495 | | | 496 | 237 | vars->relcount ++; | 497 | | | 498 | 237 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 499 | 237 | } |
pei-arm-wince.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 480 | 158 | { | 481 | 158 | arelent *entry; | 482 | 158 | struct internal_reloc *internal; | 483 | | | 484 | 158 | entry = vars->reltab + vars->relcount; | 485 | 158 | internal = vars->int_reltab + vars->relcount; | 486 | | | 487 | 158 | entry->address = address; | 488 | 158 | entry->addend = 0; | 489 | 158 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 490 | 158 | entry->sym_ptr_ptr = sym; | 491 | | | 492 | 158 | internal->r_vaddr = address; | 493 | 158 | internal->r_symndx = sym_index; | 494 | 158 | internal->r_type = entry->howto ? entry->howto->type : 0; | 495 | | | 496 | 158 | vars->relcount ++; | 497 | | | 498 | 158 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 499 | 158 | } |
pei-arm.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 480 | 166 | { | 481 | 166 | arelent *entry; | 482 | 166 | struct internal_reloc *internal; | 483 | | | 484 | 166 | entry = vars->reltab + vars->relcount; | 485 | 166 | internal = vars->int_reltab + vars->relcount; | 486 | | | 487 | 166 | entry->address = address; | 488 | 166 | entry->addend = 0; | 489 | 166 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 490 | 166 | entry->sym_ptr_ptr = sym; | 491 | | | 492 | 166 | internal->r_vaddr = address; | 493 | 166 | internal->r_symndx = sym_index; | 494 | 166 | internal->r_type = entry->howto ? entry->howto->type : 0; | 495 | | | 496 | 166 | vars->relcount ++; | 497 | | | 498 | 166 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 499 | 166 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_symbol_reloc pei-sh.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 480 | 363 | { | 481 | 363 | arelent *entry; | 482 | 363 | struct internal_reloc *internal; | 483 | | | 484 | 363 | entry = vars->reltab + vars->relcount; | 485 | 363 | internal = vars->int_reltab + vars->relcount; | 486 | | | 487 | 363 | entry->address = address; | 488 | 363 | entry->addend = 0; | 489 | 363 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 490 | 363 | entry->sym_ptr_ptr = sym; | 491 | | | 492 | 363 | internal->r_vaddr = address; | 493 | 363 | internal->r_symndx = sym_index; | 494 | 363 | internal->r_type = entry->howto ? entry->howto->type : 0; | 495 | | | 496 | 363 | vars->relcount ++; | 497 | | | 498 | 363 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 499 | 363 | } |
|
500 | | |
501 | | /* Create an empty relocation against the given section. */ |
502 | | |
503 | | static void |
504 | | pe_ILF_make_a_reloc (pe_ILF_vars * vars, |
505 | | bfd_vma address, |
506 | | bfd_reloc_code_real_type reloc, |
507 | | asection_ptr sec) |
508 | 1.45k | { |
509 | 1.45k | pe_ILF_make_a_symbol_reloc (vars, address, reloc, &sec->symbol, |
510 | 1.45k | coff_section_data (vars->abfd, sec)->i); |
511 | 1.45k | } pei-i386.c:pe_ILF_make_a_reloc Line | Count | Source | 508 | 214 | { | 509 | 214 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, &sec->symbol, | 510 | 214 | coff_section_data (vars->abfd, sec)->i); | 511 | 214 | } |
pei-x86_64.c:pe_ILF_make_a_reloc Line | Count | Source | 508 | 174 | { | 509 | 174 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, &sec->symbol, | 510 | 174 | coff_section_data (vars->abfd, sec)->i); | 511 | 174 | } |
pei-aarch64.c:pe_ILF_make_a_reloc Line | Count | Source | 508 | 180 | { | 509 | 180 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, &sec->symbol, | 510 | 180 | coff_section_data (vars->abfd, sec)->i); | 511 | 180 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_reloc pei-loongarch64.c:pe_ILF_make_a_reloc Line | Count | Source | 508 | 176 | { | 509 | 176 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, &sec->symbol, | 510 | 176 | coff_section_data (vars->abfd, sec)->i); | 511 | 176 | } |
pei-riscv64.c:pe_ILF_make_a_reloc Line | Count | Source | 508 | 186 | { | 509 | 186 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, &sec->symbol, | 510 | 186 | coff_section_data (vars->abfd, sec)->i); | 511 | 186 | } |
pei-arm-wince.c:pe_ILF_make_a_reloc Line | Count | Source | 508 | 118 | { | 509 | 118 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, &sec->symbol, | 510 | 118 | coff_section_data (vars->abfd, sec)->i); | 511 | 118 | } |
pei-arm.c:pe_ILF_make_a_reloc Line | Count | Source | 508 | 122 | { | 509 | 122 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, &sec->symbol, | 510 | 122 | coff_section_data (vars->abfd, sec)->i); | 511 | 122 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_reloc pei-sh.c:pe_ILF_make_a_reloc Line | Count | Source | 508 | 282 | { | 509 | 282 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, &sec->symbol, | 510 | 282 | coff_section_data (vars->abfd, sec)->i); | 511 | 282 | } |
|
512 | | |
513 | | /* Move the queued relocs into the given section. */ |
514 | | |
515 | | static void |
516 | | pe_ILF_save_relocs (pe_ILF_vars *vars, |
517 | | asection_ptr sec) |
518 | 1.89k | { |
519 | | /* Make sure that there is somewhere to store the internal relocs. */ |
520 | 1.89k | if (coff_section_data (vars->abfd, sec) == NULL) |
521 | | /* We should probably return an error indication here. */ |
522 | 0 | abort (); |
523 | | |
524 | 1.89k | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; |
525 | | |
526 | 1.89k | sec->relocation = vars->reltab; |
527 | 1.89k | sec->reloc_count = vars->relcount; |
528 | 1.89k | sec->flags |= SEC_RELOC; |
529 | | |
530 | 1.89k | vars->reltab += vars->relcount; |
531 | 1.89k | vars->int_reltab += vars->relcount; |
532 | 1.89k | vars->relcount = 0; |
533 | | |
534 | 1.89k | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); |
535 | 1.89k | } pei-i386.c:pe_ILF_save_relocs Line | Count | Source | 518 | 295 | { | 519 | | /* Make sure that there is somewhere to store the internal relocs. */ | 520 | 295 | if (coff_section_data (vars->abfd, sec) == NULL) | 521 | | /* We should probably return an error indication here. */ | 522 | 0 | abort (); | 523 | | | 524 | 295 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 525 | | | 526 | 295 | sec->relocation = vars->reltab; | 527 | 295 | sec->reloc_count = vars->relcount; | 528 | 295 | sec->flags |= SEC_RELOC; | 529 | | | 530 | 295 | vars->reltab += vars->relcount; | 531 | 295 | vars->int_reltab += vars->relcount; | 532 | 295 | vars->relcount = 0; | 533 | | | 534 | 295 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 535 | 295 | } |
pei-x86_64.c:pe_ILF_save_relocs Line | Count | Source | 518 | 214 | { | 519 | | /* Make sure that there is somewhere to store the internal relocs. */ | 520 | 214 | if (coff_section_data (vars->abfd, sec) == NULL) | 521 | | /* We should probably return an error indication here. */ | 522 | 0 | abort (); | 523 | | | 524 | 214 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 525 | | | 526 | 214 | sec->relocation = vars->reltab; | 527 | 214 | sec->reloc_count = vars->relcount; | 528 | 214 | sec->flags |= SEC_RELOC; | 529 | | | 530 | 214 | vars->reltab += vars->relcount; | 531 | 214 | vars->int_reltab += vars->relcount; | 532 | 214 | vars->relcount = 0; | 533 | | | 534 | 214 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 535 | 214 | } |
pei-aarch64.c:pe_ILF_save_relocs Line | Count | Source | 518 | 236 | { | 519 | | /* Make sure that there is somewhere to store the internal relocs. */ | 520 | 236 | if (coff_section_data (vars->abfd, sec) == NULL) | 521 | | /* We should probably return an error indication here. */ | 522 | 0 | abort (); | 523 | | | 524 | 236 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 525 | | | 526 | 236 | sec->relocation = vars->reltab; | 527 | 236 | sec->reloc_count = vars->relcount; | 528 | 236 | sec->flags |= SEC_RELOC; | 529 | | | 530 | 236 | vars->reltab += vars->relcount; | 531 | 236 | vars->int_reltab += vars->relcount; | 532 | 236 | vars->relcount = 0; | 533 | | | 534 | 236 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 535 | 236 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_save_relocs pei-loongarch64.c:pe_ILF_save_relocs Line | Count | Source | 518 | 230 | { | 519 | | /* Make sure that there is somewhere to store the internal relocs. */ | 520 | 230 | if (coff_section_data (vars->abfd, sec) == NULL) | 521 | | /* We should probably return an error indication here. */ | 522 | 0 | abort (); | 523 | | | 524 | 230 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 525 | | | 526 | 230 | sec->relocation = vars->reltab; | 527 | 230 | sec->reloc_count = vars->relcount; | 528 | 230 | sec->flags |= SEC_RELOC; | 529 | | | 530 | 230 | vars->reltab += vars->relcount; | 531 | 230 | vars->int_reltab += vars->relcount; | 532 | 230 | vars->relcount = 0; | 533 | | | 534 | 230 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 535 | 230 | } |
pei-riscv64.c:pe_ILF_save_relocs Line | Count | Source | 518 | 237 | { | 519 | | /* Make sure that there is somewhere to store the internal relocs. */ | 520 | 237 | if (coff_section_data (vars->abfd, sec) == NULL) | 521 | | /* We should probably return an error indication here. */ | 522 | 0 | abort (); | 523 | | | 524 | 237 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 525 | | | 526 | 237 | sec->relocation = vars->reltab; | 527 | 237 | sec->reloc_count = vars->relcount; | 528 | 237 | sec->flags |= SEC_RELOC; | 529 | | | 530 | 237 | vars->reltab += vars->relcount; | 531 | 237 | vars->int_reltab += vars->relcount; | 532 | 237 | vars->relcount = 0; | 533 | | | 534 | 237 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 535 | 237 | } |
pei-arm-wince.c:pe_ILF_save_relocs Line | Count | Source | 518 | 158 | { | 519 | | /* Make sure that there is somewhere to store the internal relocs. */ | 520 | 158 | if (coff_section_data (vars->abfd, sec) == NULL) | 521 | | /* We should probably return an error indication here. */ | 522 | 0 | abort (); | 523 | | | 524 | 158 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 525 | | | 526 | 158 | sec->relocation = vars->reltab; | 527 | 158 | sec->reloc_count = vars->relcount; | 528 | 158 | sec->flags |= SEC_RELOC; | 529 | | | 530 | 158 | vars->reltab += vars->relcount; | 531 | 158 | vars->int_reltab += vars->relcount; | 532 | 158 | vars->relcount = 0; | 533 | | | 534 | 158 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 535 | 158 | } |
pei-arm.c:pe_ILF_save_relocs Line | Count | Source | 518 | 166 | { | 519 | | /* Make sure that there is somewhere to store the internal relocs. */ | 520 | 166 | if (coff_section_data (vars->abfd, sec) == NULL) | 521 | | /* We should probably return an error indication here. */ | 522 | 0 | abort (); | 523 | | | 524 | 166 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 525 | | | 526 | 166 | sec->relocation = vars->reltab; | 527 | 166 | sec->reloc_count = vars->relcount; | 528 | 166 | sec->flags |= SEC_RELOC; | 529 | | | 530 | 166 | vars->reltab += vars->relcount; | 531 | 166 | vars->int_reltab += vars->relcount; | 532 | 166 | vars->relcount = 0; | 533 | | | 534 | 166 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 535 | 166 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_save_relocs pei-sh.c:pe_ILF_save_relocs Line | Count | Source | 518 | 363 | { | 519 | | /* Make sure that there is somewhere to store the internal relocs. */ | 520 | 363 | if (coff_section_data (vars->abfd, sec) == NULL) | 521 | | /* We should probably return an error indication here. */ | 522 | 0 | abort (); | 523 | | | 524 | 363 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 525 | | | 526 | 363 | sec->relocation = vars->reltab; | 527 | 363 | sec->reloc_count = vars->relcount; | 528 | 363 | sec->flags |= SEC_RELOC; | 529 | | | 530 | 363 | vars->reltab += vars->relcount; | 531 | 363 | vars->int_reltab += vars->relcount; | 532 | 363 | vars->relcount = 0; | 533 | | | 534 | 363 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 535 | 363 | } |
|
536 | | |
537 | | /* Create a global symbol and add it to the relevant tables. */ |
538 | | |
539 | | static void |
540 | | pe_ILF_make_a_symbol (pe_ILF_vars * vars, |
541 | | const char * prefix, |
542 | | const char * symbol_name, |
543 | | asection_ptr section, |
544 | | flagword extra_flags) |
545 | 5.94k | { |
546 | 5.94k | coff_symbol_type *sym; |
547 | 5.94k | combined_entry_type *ent; |
548 | 5.94k | SYMENT *esym; |
549 | 5.94k | unsigned short sclass; |
550 | | |
551 | 5.94k | if (extra_flags & BSF_LOCAL) |
552 | 3.28k | sclass = C_STAT; |
553 | 2.65k | else |
554 | 2.65k | sclass = C_EXT; |
555 | | |
556 | | #ifdef THUMBPEMAGIC |
557 | 1.01k | if (vars->magic == THUMBPEMAGIC) |
558 | 476 | { |
559 | 476 | if (extra_flags & BSF_FUNCTION) |
560 | 38 | sclass = C_THUMBEXTFUNC; |
561 | 438 | else if (extra_flags & BSF_LOCAL) |
562 | 266 | sclass = C_THUMBSTAT; |
563 | 172 | else |
564 | 172 | sclass = C_THUMBEXT; |
565 | 476 | } |
566 | | #endif |
567 | | |
568 | 5.94k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); |
569 | | |
570 | 5.94k | sym = vars->sym_ptr; |
571 | 5.94k | ent = vars->native_ptr; |
572 | 5.94k | esym = vars->esym_ptr; |
573 | | |
574 | | /* Copy the symbol's name into the string table. */ |
575 | 5.94k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); |
576 | | |
577 | 5.94k | if (section == NULL) |
578 | 985 | section = bfd_und_section_ptr; |
579 | | |
580 | | /* Initialise the external symbol. */ |
581 | 5.94k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, |
582 | 5.94k | esym->e.e.e_offset); |
583 | 5.94k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); |
584 | 5.94k | esym->e_sclass[0] = sclass; |
585 | | |
586 | | /* The following initialisations are unnecessary - the memory is |
587 | | zero initialised. They are just kept here as reminders. */ |
588 | | |
589 | | /* Initialise the internal symbol structure. */ |
590 | 5.94k | ent->u.syment.n_sclass = sclass; |
591 | 5.94k | ent->u.syment.n_scnum = section->target_index; |
592 | 5.94k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; |
593 | 5.94k | ent->is_sym = true; |
594 | | |
595 | 5.94k | sym->symbol.the_bfd = vars->abfd; |
596 | 5.94k | sym->symbol.name = vars->string_ptr; |
597 | 5.94k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; |
598 | 5.94k | sym->symbol.section = section; |
599 | 5.94k | sym->native = ent; |
600 | | |
601 | 5.94k | *vars->table_ptr = vars->sym_index; |
602 | 5.94k | *vars->sym_ptr_ptr = sym; |
603 | | |
604 | | /* Adjust pointers for the next symbol. */ |
605 | 5.94k | vars->sym_index ++; |
606 | 5.94k | vars->sym_ptr ++; |
607 | 5.94k | vars->sym_ptr_ptr ++; |
608 | 5.94k | vars->table_ptr ++; |
609 | 5.94k | vars->native_ptr ++; |
610 | 5.94k | vars->esym_ptr ++; |
611 | 5.94k | vars->string_ptr += len + 1; |
612 | | |
613 | 5.94k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); |
614 | 5.94k | } pei-i386.c:pe_ILF_make_a_symbol Line | Count | Source | 545 | 929 | { | 546 | 929 | coff_symbol_type *sym; | 547 | 929 | combined_entry_type *ent; | 548 | 929 | SYMENT *esym; | 549 | 929 | unsigned short sclass; | 550 | | | 551 | 929 | if (extra_flags & BSF_LOCAL) | 552 | 512 | sclass = C_STAT; | 553 | 417 | else | 554 | 417 | sclass = C_EXT; | 555 | | | 556 | | #ifdef THUMBPEMAGIC | 557 | | if (vars->magic == THUMBPEMAGIC) | 558 | | { | 559 | | if (extra_flags & BSF_FUNCTION) | 560 | | sclass = C_THUMBEXTFUNC; | 561 | | else if (extra_flags & BSF_LOCAL) | 562 | | sclass = C_THUMBSTAT; | 563 | | else | 564 | | sclass = C_THUMBEXT; | 565 | | } | 566 | | #endif | 567 | | | 568 | 929 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 569 | | | 570 | 929 | sym = vars->sym_ptr; | 571 | 929 | ent = vars->native_ptr; | 572 | 929 | esym = vars->esym_ptr; | 573 | | | 574 | | /* Copy the symbol's name into the string table. */ | 575 | 929 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 576 | | | 577 | 929 | if (section == NULL) | 578 | 153 | section = bfd_und_section_ptr; | 579 | | | 580 | | /* Initialise the external symbol. */ | 581 | 929 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 582 | 929 | esym->e.e.e_offset); | 583 | 929 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 584 | 929 | esym->e_sclass[0] = sclass; | 585 | | | 586 | | /* The following initialisations are unnecessary - the memory is | 587 | | zero initialised. They are just kept here as reminders. */ | 588 | | | 589 | | /* Initialise the internal symbol structure. */ | 590 | 929 | ent->u.syment.n_sclass = sclass; | 591 | 929 | ent->u.syment.n_scnum = section->target_index; | 592 | 929 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 593 | 929 | ent->is_sym = true; | 594 | | | 595 | 929 | sym->symbol.the_bfd = vars->abfd; | 596 | 929 | sym->symbol.name = vars->string_ptr; | 597 | 929 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 598 | 929 | sym->symbol.section = section; | 599 | 929 | sym->native = ent; | 600 | | | 601 | 929 | *vars->table_ptr = vars->sym_index; | 602 | 929 | *vars->sym_ptr_ptr = sym; | 603 | | | 604 | | /* Adjust pointers for the next symbol. */ | 605 | 929 | vars->sym_index ++; | 606 | 929 | vars->sym_ptr ++; | 607 | 929 | vars->sym_ptr_ptr ++; | 608 | 929 | vars->table_ptr ++; | 609 | 929 | vars->native_ptr ++; | 610 | 929 | vars->esym_ptr ++; | 611 | 929 | vars->string_ptr += len + 1; | 612 | | | 613 | 929 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 614 | 929 | } |
pei-x86_64.c:pe_ILF_make_a_symbol Line | Count | Source | 545 | 694 | { | 546 | 694 | coff_symbol_type *sym; | 547 | 694 | combined_entry_type *ent; | 548 | 694 | SYMENT *esym; | 549 | 694 | unsigned short sclass; | 550 | | | 551 | 694 | if (extra_flags & BSF_LOCAL) | 552 | 377 | sclass = C_STAT; | 553 | 317 | else | 554 | 317 | sclass = C_EXT; | 555 | | | 556 | | #ifdef THUMBPEMAGIC | 557 | | if (vars->magic == THUMBPEMAGIC) | 558 | | { | 559 | | if (extra_flags & BSF_FUNCTION) | 560 | | sclass = C_THUMBEXTFUNC; | 561 | | else if (extra_flags & BSF_LOCAL) | 562 | | sclass = C_THUMBSTAT; | 563 | | else | 564 | | sclass = C_THUMBEXT; | 565 | | } | 566 | | #endif | 567 | | | 568 | 694 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 569 | | | 570 | 694 | sym = vars->sym_ptr; | 571 | 694 | ent = vars->native_ptr; | 572 | 694 | esym = vars->esym_ptr; | 573 | | | 574 | | /* Copy the symbol's name into the string table. */ | 575 | 694 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 576 | | | 577 | 694 | if (section == NULL) | 578 | 116 | section = bfd_und_section_ptr; | 579 | | | 580 | | /* Initialise the external symbol. */ | 581 | 694 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 582 | 694 | esym->e.e.e_offset); | 583 | 694 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 584 | 694 | esym->e_sclass[0] = sclass; | 585 | | | 586 | | /* The following initialisations are unnecessary - the memory is | 587 | | zero initialised. They are just kept here as reminders. */ | 588 | | | 589 | | /* Initialise the internal symbol structure. */ | 590 | 694 | ent->u.syment.n_sclass = sclass; | 591 | 694 | ent->u.syment.n_scnum = section->target_index; | 592 | 694 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 593 | 694 | ent->is_sym = true; | 594 | | | 595 | 694 | sym->symbol.the_bfd = vars->abfd; | 596 | 694 | sym->symbol.name = vars->string_ptr; | 597 | 694 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 598 | 694 | sym->symbol.section = section; | 599 | 694 | sym->native = ent; | 600 | | | 601 | 694 | *vars->table_ptr = vars->sym_index; | 602 | 694 | *vars->sym_ptr_ptr = sym; | 603 | | | 604 | | /* Adjust pointers for the next symbol. */ | 605 | 694 | vars->sym_index ++; | 606 | 694 | vars->sym_ptr ++; | 607 | 694 | vars->sym_ptr_ptr ++; | 608 | 694 | vars->table_ptr ++; | 609 | 694 | vars->native_ptr ++; | 610 | 694 | vars->esym_ptr ++; | 611 | 694 | vars->string_ptr += len + 1; | 612 | | | 613 | 694 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 614 | 694 | } |
pei-aarch64.c:pe_ILF_make_a_symbol Line | Count | Source | 545 | 740 | { | 546 | 740 | coff_symbol_type *sym; | 547 | 740 | combined_entry_type *ent; | 548 | 740 | SYMENT *esym; | 549 | 740 | unsigned short sclass; | 550 | | | 551 | 740 | if (extra_flags & BSF_LOCAL) | 552 | 412 | sclass = C_STAT; | 553 | 328 | else | 554 | 328 | sclass = C_EXT; | 555 | | | 556 | | #ifdef THUMBPEMAGIC | 557 | | if (vars->magic == THUMBPEMAGIC) | 558 | | { | 559 | | if (extra_flags & BSF_FUNCTION) | 560 | | sclass = C_THUMBEXTFUNC; | 561 | | else if (extra_flags & BSF_LOCAL) | 562 | | sclass = C_THUMBSTAT; | 563 | | else | 564 | | sclass = C_THUMBEXT; | 565 | | } | 566 | | #endif | 567 | | | 568 | 740 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 569 | | | 570 | 740 | sym = vars->sym_ptr; | 571 | 740 | ent = vars->native_ptr; | 572 | 740 | esym = vars->esym_ptr; | 573 | | | 574 | | /* Copy the symbol's name into the string table. */ | 575 | 740 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 576 | | | 577 | 740 | if (section == NULL) | 578 | 123 | section = bfd_und_section_ptr; | 579 | | | 580 | | /* Initialise the external symbol. */ | 581 | 740 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 582 | 740 | esym->e.e.e_offset); | 583 | 740 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 584 | 740 | esym->e_sclass[0] = sclass; | 585 | | | 586 | | /* The following initialisations are unnecessary - the memory is | 587 | | zero initialised. They are just kept here as reminders. */ | 588 | | | 589 | | /* Initialise the internal symbol structure. */ | 590 | 740 | ent->u.syment.n_sclass = sclass; | 591 | 740 | ent->u.syment.n_scnum = section->target_index; | 592 | 740 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 593 | 740 | ent->is_sym = true; | 594 | | | 595 | 740 | sym->symbol.the_bfd = vars->abfd; | 596 | 740 | sym->symbol.name = vars->string_ptr; | 597 | 740 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 598 | 740 | sym->symbol.section = section; | 599 | 740 | sym->native = ent; | 600 | | | 601 | 740 | *vars->table_ptr = vars->sym_index; | 602 | 740 | *vars->sym_ptr_ptr = sym; | 603 | | | 604 | | /* Adjust pointers for the next symbol. */ | 605 | 740 | vars->sym_index ++; | 606 | 740 | vars->sym_ptr ++; | 607 | 740 | vars->sym_ptr_ptr ++; | 608 | 740 | vars->table_ptr ++; | 609 | 740 | vars->native_ptr ++; | 610 | 740 | vars->esym_ptr ++; | 611 | 740 | vars->string_ptr += len + 1; | 612 | | | 613 | 740 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 614 | 740 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_symbol pei-loongarch64.c:pe_ILF_make_a_symbol Line | Count | Source | 545 | 725 | { | 546 | 725 | coff_symbol_type *sym; | 547 | 725 | combined_entry_type *ent; | 548 | 725 | SYMENT *esym; | 549 | 725 | unsigned short sclass; | 550 | | | 551 | 725 | if (extra_flags & BSF_LOCAL) | 552 | 406 | sclass = C_STAT; | 553 | 319 | else | 554 | 319 | sclass = C_EXT; | 555 | | | 556 | | #ifdef THUMBPEMAGIC | 557 | | if (vars->magic == THUMBPEMAGIC) | 558 | | { | 559 | | if (extra_flags & BSF_FUNCTION) | 560 | | sclass = C_THUMBEXTFUNC; | 561 | | else if (extra_flags & BSF_LOCAL) | 562 | | sclass = C_THUMBSTAT; | 563 | | else | 564 | | sclass = C_THUMBEXT; | 565 | | } | 566 | | #endif | 567 | | | 568 | 725 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 569 | | | 570 | 725 | sym = vars->sym_ptr; | 571 | 725 | ent = vars->native_ptr; | 572 | 725 | esym = vars->esym_ptr; | 573 | | | 574 | | /* Copy the symbol's name into the string table. */ | 575 | 725 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 576 | | | 577 | 725 | if (section == NULL) | 578 | 123 | section = bfd_und_section_ptr; | 579 | | | 580 | | /* Initialise the external symbol. */ | 581 | 725 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 582 | 725 | esym->e.e.e_offset); | 583 | 725 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 584 | 725 | esym->e_sclass[0] = sclass; | 585 | | | 586 | | /* The following initialisations are unnecessary - the memory is | 587 | | zero initialised. They are just kept here as reminders. */ | 588 | | | 589 | | /* Initialise the internal symbol structure. */ | 590 | 725 | ent->u.syment.n_sclass = sclass; | 591 | 725 | ent->u.syment.n_scnum = section->target_index; | 592 | 725 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 593 | 725 | ent->is_sym = true; | 594 | | | 595 | 725 | sym->symbol.the_bfd = vars->abfd; | 596 | 725 | sym->symbol.name = vars->string_ptr; | 597 | 725 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 598 | 725 | sym->symbol.section = section; | 599 | 725 | sym->native = ent; | 600 | | | 601 | 725 | *vars->table_ptr = vars->sym_index; | 602 | 725 | *vars->sym_ptr_ptr = sym; | 603 | | | 604 | | /* Adjust pointers for the next symbol. */ | 605 | 725 | vars->sym_index ++; | 606 | 725 | vars->sym_ptr ++; | 607 | 725 | vars->sym_ptr_ptr ++; | 608 | 725 | vars->table_ptr ++; | 609 | 725 | vars->native_ptr ++; | 610 | 725 | vars->esym_ptr ++; | 611 | 725 | vars->string_ptr += len + 1; | 612 | | | 613 | 725 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 614 | 725 | } |
pei-riscv64.c:pe_ILF_make_a_symbol Line | Count | Source | 545 | 745 | { | 546 | 745 | coff_symbol_type *sym; | 547 | 745 | combined_entry_type *ent; | 548 | 745 | SYMENT *esym; | 549 | 745 | unsigned short sclass; | 550 | | | 551 | 745 | if (extra_flags & BSF_LOCAL) | 552 | 402 | sclass = C_STAT; | 553 | 343 | else | 554 | 343 | sclass = C_EXT; | 555 | | | 556 | | #ifdef THUMBPEMAGIC | 557 | | if (vars->magic == THUMBPEMAGIC) | 558 | | { | 559 | | if (extra_flags & BSF_FUNCTION) | 560 | | sclass = C_THUMBEXTFUNC; | 561 | | else if (extra_flags & BSF_LOCAL) | 562 | | sclass = C_THUMBSTAT; | 563 | | else | 564 | | sclass = C_THUMBEXT; | 565 | | } | 566 | | #endif | 567 | | | 568 | 745 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 569 | | | 570 | 745 | sym = vars->sym_ptr; | 571 | 745 | ent = vars->native_ptr; | 572 | 745 | esym = vars->esym_ptr; | 573 | | | 574 | | /* Copy the symbol's name into the string table. */ | 575 | 745 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 576 | | | 577 | 745 | if (section == NULL) | 578 | 122 | section = bfd_und_section_ptr; | 579 | | | 580 | | /* Initialise the external symbol. */ | 581 | 745 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 582 | 745 | esym->e.e.e_offset); | 583 | 745 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 584 | 745 | esym->e_sclass[0] = sclass; | 585 | | | 586 | | /* The following initialisations are unnecessary - the memory is | 587 | | zero initialised. They are just kept here as reminders. */ | 588 | | | 589 | | /* Initialise the internal symbol structure. */ | 590 | 745 | ent->u.syment.n_sclass = sclass; | 591 | 745 | ent->u.syment.n_scnum = section->target_index; | 592 | 745 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 593 | 745 | ent->is_sym = true; | 594 | | | 595 | 745 | sym->symbol.the_bfd = vars->abfd; | 596 | 745 | sym->symbol.name = vars->string_ptr; | 597 | 745 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 598 | 745 | sym->symbol.section = section; | 599 | 745 | sym->native = ent; | 600 | | | 601 | 745 | *vars->table_ptr = vars->sym_index; | 602 | 745 | *vars->sym_ptr_ptr = sym; | 603 | | | 604 | | /* Adjust pointers for the next symbol. */ | 605 | 745 | vars->sym_index ++; | 606 | 745 | vars->sym_ptr ++; | 607 | 745 | vars->sym_ptr_ptr ++; | 608 | 745 | vars->table_ptr ++; | 609 | 745 | vars->native_ptr ++; | 610 | 745 | vars->esym_ptr ++; | 611 | 745 | vars->string_ptr += len + 1; | 612 | | | 613 | 745 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 614 | 745 | } |
pei-arm-wince.c:pe_ILF_make_a_symbol Line | Count | Source | 545 | 491 | { | 546 | 491 | coff_symbol_type *sym; | 547 | 491 | combined_entry_type *ent; | 548 | 491 | SYMENT *esym; | 549 | 491 | unsigned short sclass; | 550 | | | 551 | 491 | if (extra_flags & BSF_LOCAL) | 552 | 277 | sclass = C_STAT; | 553 | 214 | else | 554 | 214 | sclass = C_EXT; | 555 | | | 556 | 491 | #ifdef THUMBPEMAGIC | 557 | 491 | if (vars->magic == THUMBPEMAGIC) | 558 | 238 | { | 559 | 238 | if (extra_flags & BSF_FUNCTION) | 560 | 19 | sclass = C_THUMBEXTFUNC; | 561 | 219 | else if (extra_flags & BSF_LOCAL) | 562 | 133 | sclass = C_THUMBSTAT; | 563 | 86 | else | 564 | 86 | sclass = C_THUMBEXT; | 565 | 238 | } | 566 | 491 | #endif | 567 | | | 568 | 491 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 569 | | | 570 | 491 | sym = vars->sym_ptr; | 571 | 491 | ent = vars->native_ptr; | 572 | 491 | esym = vars->esym_ptr; | 573 | | | 574 | | /* Copy the symbol's name into the string table. */ | 575 | 491 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 576 | | | 577 | 491 | if (section == NULL) | 578 | 79 | section = bfd_und_section_ptr; | 579 | | | 580 | | /* Initialise the external symbol. */ | 581 | 491 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 582 | 491 | esym->e.e.e_offset); | 583 | 491 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 584 | 491 | esym->e_sclass[0] = sclass; | 585 | | | 586 | | /* The following initialisations are unnecessary - the memory is | 587 | | zero initialised. They are just kept here as reminders. */ | 588 | | | 589 | | /* Initialise the internal symbol structure. */ | 590 | 491 | ent->u.syment.n_sclass = sclass; | 591 | 491 | ent->u.syment.n_scnum = section->target_index; | 592 | 491 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 593 | 491 | ent->is_sym = true; | 594 | | | 595 | 491 | sym->symbol.the_bfd = vars->abfd; | 596 | 491 | sym->symbol.name = vars->string_ptr; | 597 | 491 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 598 | 491 | sym->symbol.section = section; | 599 | 491 | sym->native = ent; | 600 | | | 601 | 491 | *vars->table_ptr = vars->sym_index; | 602 | 491 | *vars->sym_ptr_ptr = sym; | 603 | | | 604 | | /* Adjust pointers for the next symbol. */ | 605 | 491 | vars->sym_index ++; | 606 | 491 | vars->sym_ptr ++; | 607 | 491 | vars->sym_ptr_ptr ++; | 608 | 491 | vars->table_ptr ++; | 609 | 491 | vars->native_ptr ++; | 610 | 491 | vars->esym_ptr ++; | 611 | 491 | vars->string_ptr += len + 1; | 612 | | | 613 | 491 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 614 | 491 | } |
pei-arm.c:pe_ILF_make_a_symbol Line | Count | Source | 545 | 522 | { | 546 | 522 | coff_symbol_type *sym; | 547 | 522 | combined_entry_type *ent; | 548 | 522 | SYMENT *esym; | 549 | 522 | unsigned short sclass; | 550 | | | 551 | 522 | if (extra_flags & BSF_LOCAL) | 552 | 293 | sclass = C_STAT; | 553 | 229 | else | 554 | 229 | sclass = C_EXT; | 555 | | | 556 | 522 | #ifdef THUMBPEMAGIC | 557 | 522 | if (vars->magic == THUMBPEMAGIC) | 558 | 238 | { | 559 | 238 | if (extra_flags & BSF_FUNCTION) | 560 | 19 | sclass = C_THUMBEXTFUNC; | 561 | 219 | else if (extra_flags & BSF_LOCAL) | 562 | 133 | sclass = C_THUMBSTAT; | 563 | 86 | else | 564 | 86 | sclass = C_THUMBEXT; | 565 | 238 | } | 566 | 522 | #endif | 567 | | | 568 | 522 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 569 | | | 570 | 522 | sym = vars->sym_ptr; | 571 | 522 | ent = vars->native_ptr; | 572 | 522 | esym = vars->esym_ptr; | 573 | | | 574 | | /* Copy the symbol's name into the string table. */ | 575 | 522 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 576 | | | 577 | 522 | if (section == NULL) | 578 | 84 | section = bfd_und_section_ptr; | 579 | | | 580 | | /* Initialise the external symbol. */ | 581 | 522 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 582 | 522 | esym->e.e.e_offset); | 583 | 522 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 584 | 522 | esym->e_sclass[0] = sclass; | 585 | | | 586 | | /* The following initialisations are unnecessary - the memory is | 587 | | zero initialised. They are just kept here as reminders. */ | 588 | | | 589 | | /* Initialise the internal symbol structure. */ | 590 | 522 | ent->u.syment.n_sclass = sclass; | 591 | 522 | ent->u.syment.n_scnum = section->target_index; | 592 | 522 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 593 | 522 | ent->is_sym = true; | 594 | | | 595 | 522 | sym->symbol.the_bfd = vars->abfd; | 596 | 522 | sym->symbol.name = vars->string_ptr; | 597 | 522 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 598 | 522 | sym->symbol.section = section; | 599 | 522 | sym->native = ent; | 600 | | | 601 | 522 | *vars->table_ptr = vars->sym_index; | 602 | 522 | *vars->sym_ptr_ptr = sym; | 603 | | | 604 | | /* Adjust pointers for the next symbol. */ | 605 | 522 | vars->sym_index ++; | 606 | 522 | vars->sym_ptr ++; | 607 | 522 | vars->sym_ptr_ptr ++; | 608 | 522 | vars->table_ptr ++; | 609 | 522 | vars->native_ptr ++; | 610 | 522 | vars->esym_ptr ++; | 611 | 522 | vars->string_ptr += len + 1; | 612 | | | 613 | 522 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 614 | 522 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_symbol pei-sh.c:pe_ILF_make_a_symbol Line | Count | Source | 545 | 1.10k | { | 546 | 1.10k | coff_symbol_type *sym; | 547 | 1.10k | combined_entry_type *ent; | 548 | 1.10k | SYMENT *esym; | 549 | 1.10k | unsigned short sclass; | 550 | | | 551 | 1.10k | if (extra_flags & BSF_LOCAL) | 552 | 610 | sclass = C_STAT; | 553 | 490 | else | 554 | 490 | sclass = C_EXT; | 555 | | | 556 | | #ifdef THUMBPEMAGIC | 557 | | if (vars->magic == THUMBPEMAGIC) | 558 | | { | 559 | | if (extra_flags & BSF_FUNCTION) | 560 | | sclass = C_THUMBEXTFUNC; | 561 | | else if (extra_flags & BSF_LOCAL) | 562 | | sclass = C_THUMBSTAT; | 563 | | else | 564 | | sclass = C_THUMBEXT; | 565 | | } | 566 | | #endif | 567 | | | 568 | 1.10k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 569 | | | 570 | 1.10k | sym = vars->sym_ptr; | 571 | 1.10k | ent = vars->native_ptr; | 572 | 1.10k | esym = vars->esym_ptr; | 573 | | | 574 | | /* Copy the symbol's name into the string table. */ | 575 | 1.10k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 576 | | | 577 | 1.10k | if (section == NULL) | 578 | 185 | section = bfd_und_section_ptr; | 579 | | | 580 | | /* Initialise the external symbol. */ | 581 | 1.10k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 582 | 1.10k | esym->e.e.e_offset); | 583 | 1.10k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 584 | 1.10k | esym->e_sclass[0] = sclass; | 585 | | | 586 | | /* The following initialisations are unnecessary - the memory is | 587 | | zero initialised. They are just kept here as reminders. */ | 588 | | | 589 | | /* Initialise the internal symbol structure. */ | 590 | 1.10k | ent->u.syment.n_sclass = sclass; | 591 | 1.10k | ent->u.syment.n_scnum = section->target_index; | 592 | 1.10k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 593 | 1.10k | ent->is_sym = true; | 594 | | | 595 | 1.10k | sym->symbol.the_bfd = vars->abfd; | 596 | 1.10k | sym->symbol.name = vars->string_ptr; | 597 | 1.10k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 598 | 1.10k | sym->symbol.section = section; | 599 | 1.10k | sym->native = ent; | 600 | | | 601 | 1.10k | *vars->table_ptr = vars->sym_index; | 602 | 1.10k | *vars->sym_ptr_ptr = sym; | 603 | | | 604 | | /* Adjust pointers for the next symbol. */ | 605 | 1.10k | vars->sym_index ++; | 606 | 1.10k | vars->sym_ptr ++; | 607 | 1.10k | vars->sym_ptr_ptr ++; | 608 | 1.10k | vars->table_ptr ++; | 609 | 1.10k | vars->native_ptr ++; | 610 | 1.10k | vars->esym_ptr ++; | 611 | 1.10k | vars->string_ptr += len + 1; | 612 | | | 613 | 1.10k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 614 | 1.10k | } |
|
615 | | |
616 | | /* Create a section. */ |
617 | | |
618 | | static asection_ptr |
619 | | pe_ILF_make_a_section (pe_ILF_vars * vars, |
620 | | const char * name, |
621 | | unsigned int size, |
622 | | flagword extra_flags) |
623 | 3.28k | { |
624 | 3.28k | asection_ptr sec; |
625 | 3.28k | flagword flags; |
626 | 3.28k | intptr_t alignment; |
627 | | |
628 | 3.28k | sec = bfd_make_section_old_way (vars->abfd, name); |
629 | 3.28k | if (sec == NULL) |
630 | 0 | return NULL; |
631 | | |
632 | 3.28k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; |
633 | | |
634 | 3.28k | bfd_set_section_flags (sec, flags | extra_flags); |
635 | | |
636 | 3.28k | bfd_set_section_alignment (sec, 2); |
637 | | |
638 | | /* Check that we will not run out of space. */ |
639 | 3.28k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); |
640 | | |
641 | | /* Set the section size and contents. The actual |
642 | | contents are filled in by our parent. */ |
643 | 3.28k | bfd_set_section_size (sec, (bfd_size_type) size); |
644 | 3.28k | sec->contents = vars->data; |
645 | 3.28k | sec->target_index = vars->sec_index ++; |
646 | | |
647 | | /* Advance data pointer in the vars structure. */ |
648 | 3.28k | vars->data += size; |
649 | | |
650 | | /* Skip the padding byte if it was not needed. |
651 | | The logic here is that if the string length is odd, |
652 | | then the entire string length, including the null byte, |
653 | | is even and so the extra, padding byte, is not needed. */ |
654 | 3.28k | if (size & 1) |
655 | 389 | vars->data --; |
656 | | |
657 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we |
658 | | preserve host alignment requirements. The BFD_ASSERTs in this |
659 | | functions will warn us if we run out of room, but we should |
660 | | already have enough padding built in to ILF_DATA_SIZE. */ |
661 | 3.28k | #if GCC_VERSION >= 3000 |
662 | 3.28k | alignment = __alignof__ (struct coff_section_tdata); |
663 | | #else |
664 | | alignment = 8; |
665 | | #endif |
666 | 3.28k | vars->data |
667 | 3.28k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); |
668 | | |
669 | | /* Create a coff_section_tdata structure for our use. */ |
670 | 3.28k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; |
671 | 3.28k | vars->data += sizeof (struct coff_section_tdata); |
672 | | |
673 | 3.28k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); |
674 | | |
675 | | /* Create a symbol to refer to this section. */ |
676 | 3.28k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); |
677 | | |
678 | | /* Cache the index to the symbol in the coff_section_data structure. */ |
679 | 3.28k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; |
680 | | |
681 | 3.28k | return sec; |
682 | 3.28k | } pei-i386.c:pe_ILF_make_a_section Line | Count | Source | 623 | 512 | { | 624 | 512 | asection_ptr sec; | 625 | 512 | flagword flags; | 626 | 512 | intptr_t alignment; | 627 | | | 628 | 512 | sec = bfd_make_section_old_way (vars->abfd, name); | 629 | 512 | if (sec == NULL) | 630 | 0 | return NULL; | 631 | | | 632 | 512 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 633 | | | 634 | 512 | bfd_set_section_flags (sec, flags | extra_flags); | 635 | | | 636 | 512 | bfd_set_section_alignment (sec, 2); | 637 | | | 638 | | /* Check that we will not run out of space. */ | 639 | 512 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 640 | | | 641 | | /* Set the section size and contents. The actual | 642 | | contents are filled in by our parent. */ | 643 | 512 | bfd_set_section_size (sec, (bfd_size_type) size); | 644 | 512 | sec->contents = vars->data; | 645 | 512 | sec->target_index = vars->sec_index ++; | 646 | | | 647 | | /* Advance data pointer in the vars structure. */ | 648 | 512 | vars->data += size; | 649 | | | 650 | | /* Skip the padding byte if it was not needed. | 651 | | The logic here is that if the string length is odd, | 652 | | then the entire string length, including the null byte, | 653 | | is even and so the extra, padding byte, is not needed. */ | 654 | 512 | if (size & 1) | 655 | 49 | vars->data --; | 656 | | | 657 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 658 | | preserve host alignment requirements. The BFD_ASSERTs in this | 659 | | functions will warn us if we run out of room, but we should | 660 | | already have enough padding built in to ILF_DATA_SIZE. */ | 661 | 512 | #if GCC_VERSION >= 3000 | 662 | 512 | alignment = __alignof__ (struct coff_section_tdata); | 663 | | #else | 664 | | alignment = 8; | 665 | | #endif | 666 | 512 | vars->data | 667 | 512 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 668 | | | 669 | | /* Create a coff_section_tdata structure for our use. */ | 670 | 512 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 671 | 512 | vars->data += sizeof (struct coff_section_tdata); | 672 | | | 673 | 512 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 674 | | | 675 | | /* Create a symbol to refer to this section. */ | 676 | 512 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 677 | | | 678 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 679 | 512 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 680 | | | 681 | 512 | return sec; | 682 | 512 | } |
pei-x86_64.c:pe_ILF_make_a_section Line | Count | Source | 623 | 377 | { | 624 | 377 | asection_ptr sec; | 625 | 377 | flagword flags; | 626 | 377 | intptr_t alignment; | 627 | | | 628 | 377 | sec = bfd_make_section_old_way (vars->abfd, name); | 629 | 377 | if (sec == NULL) | 630 | 0 | return NULL; | 631 | | | 632 | 377 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 633 | | | 634 | 377 | bfd_set_section_flags (sec, flags | extra_flags); | 635 | | | 636 | 377 | bfd_set_section_alignment (sec, 2); | 637 | | | 638 | | /* Check that we will not run out of space. */ | 639 | 377 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 640 | | | 641 | | /* Set the section size and contents. The actual | 642 | | contents are filled in by our parent. */ | 643 | 377 | bfd_set_section_size (sec, (bfd_size_type) size); | 644 | 377 | sec->contents = vars->data; | 645 | 377 | sec->target_index = vars->sec_index ++; | 646 | | | 647 | | /* Advance data pointer in the vars structure. */ | 648 | 377 | vars->data += size; | 649 | | | 650 | | /* Skip the padding byte if it was not needed. | 651 | | The logic here is that if the string length is odd, | 652 | | then the entire string length, including the null byte, | 653 | | is even and so the extra, padding byte, is not needed. */ | 654 | 377 | if (size & 1) | 655 | 46 | vars->data --; | 656 | | | 657 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 658 | | preserve host alignment requirements. The BFD_ASSERTs in this | 659 | | functions will warn us if we run out of room, but we should | 660 | | already have enough padding built in to ILF_DATA_SIZE. */ | 661 | 377 | #if GCC_VERSION >= 3000 | 662 | 377 | alignment = __alignof__ (struct coff_section_tdata); | 663 | | #else | 664 | | alignment = 8; | 665 | | #endif | 666 | 377 | vars->data | 667 | 377 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 668 | | | 669 | | /* Create a coff_section_tdata structure for our use. */ | 670 | 377 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 671 | 377 | vars->data += sizeof (struct coff_section_tdata); | 672 | | | 673 | 377 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 674 | | | 675 | | /* Create a symbol to refer to this section. */ | 676 | 377 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 677 | | | 678 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 679 | 377 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 680 | | | 681 | 377 | return sec; | 682 | 377 | } |
pei-aarch64.c:pe_ILF_make_a_section Line | Count | Source | 623 | 412 | { | 624 | 412 | asection_ptr sec; | 625 | 412 | flagword flags; | 626 | 412 | intptr_t alignment; | 627 | | | 628 | 412 | sec = bfd_make_section_old_way (vars->abfd, name); | 629 | 412 | if (sec == NULL) | 630 | 0 | return NULL; | 631 | | | 632 | 412 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 633 | | | 634 | 412 | bfd_set_section_flags (sec, flags | extra_flags); | 635 | | | 636 | 412 | bfd_set_section_alignment (sec, 2); | 637 | | | 638 | | /* Check that we will not run out of space. */ | 639 | 412 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 640 | | | 641 | | /* Set the section size and contents. The actual | 642 | | contents are filled in by our parent. */ | 643 | 412 | bfd_set_section_size (sec, (bfd_size_type) size); | 644 | 412 | sec->contents = vars->data; | 645 | 412 | sec->target_index = vars->sec_index ++; | 646 | | | 647 | | /* Advance data pointer in the vars structure. */ | 648 | 412 | vars->data += size; | 649 | | | 650 | | /* Skip the padding byte if it was not needed. | 651 | | The logic here is that if the string length is odd, | 652 | | then the entire string length, including the null byte, | 653 | | is even and so the extra, padding byte, is not needed. */ | 654 | 412 | if (size & 1) | 655 | 43 | vars->data --; | 656 | | | 657 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 658 | | preserve host alignment requirements. The BFD_ASSERTs in this | 659 | | functions will warn us if we run out of room, but we should | 660 | | already have enough padding built in to ILF_DATA_SIZE. */ | 661 | 412 | #if GCC_VERSION >= 3000 | 662 | 412 | alignment = __alignof__ (struct coff_section_tdata); | 663 | | #else | 664 | | alignment = 8; | 665 | | #endif | 666 | 412 | vars->data | 667 | 412 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 668 | | | 669 | | /* Create a coff_section_tdata structure for our use. */ | 670 | 412 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 671 | 412 | vars->data += sizeof (struct coff_section_tdata); | 672 | | | 673 | 412 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 674 | | | 675 | | /* Create a symbol to refer to this section. */ | 676 | 412 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 677 | | | 678 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 679 | 412 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 680 | | | 681 | 412 | return sec; | 682 | 412 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_section pei-loongarch64.c:pe_ILF_make_a_section Line | Count | Source | 623 | 406 | { | 624 | 406 | asection_ptr sec; | 625 | 406 | flagword flags; | 626 | 406 | intptr_t alignment; | 627 | | | 628 | 406 | sec = bfd_make_section_old_way (vars->abfd, name); | 629 | 406 | if (sec == NULL) | 630 | 0 | return NULL; | 631 | | | 632 | 406 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 633 | | | 634 | 406 | bfd_set_section_flags (sec, flags | extra_flags); | 635 | | | 636 | 406 | bfd_set_section_alignment (sec, 2); | 637 | | | 638 | | /* Check that we will not run out of space. */ | 639 | 406 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 640 | | | 641 | | /* Set the section size and contents. The actual | 642 | | contents are filled in by our parent. */ | 643 | 406 | bfd_set_section_size (sec, (bfd_size_type) size); | 644 | 406 | sec->contents = vars->data; | 645 | 406 | sec->target_index = vars->sec_index ++; | 646 | | | 647 | | /* Advance data pointer in the vars structure. */ | 648 | 406 | vars->data += size; | 649 | | | 650 | | /* Skip the padding byte if it was not needed. | 651 | | The logic here is that if the string length is odd, | 652 | | then the entire string length, including the null byte, | 653 | | is even and so the extra, padding byte, is not needed. */ | 654 | 406 | if (size & 1) | 655 | 49 | vars->data --; | 656 | | | 657 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 658 | | preserve host alignment requirements. The BFD_ASSERTs in this | 659 | | functions will warn us if we run out of room, but we should | 660 | | already have enough padding built in to ILF_DATA_SIZE. */ | 661 | 406 | #if GCC_VERSION >= 3000 | 662 | 406 | alignment = __alignof__ (struct coff_section_tdata); | 663 | | #else | 664 | | alignment = 8; | 665 | | #endif | 666 | 406 | vars->data | 667 | 406 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 668 | | | 669 | | /* Create a coff_section_tdata structure for our use. */ | 670 | 406 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 671 | 406 | vars->data += sizeof (struct coff_section_tdata); | 672 | | | 673 | 406 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 674 | | | 675 | | /* Create a symbol to refer to this section. */ | 676 | 406 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 677 | | | 678 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 679 | 406 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 680 | | | 681 | 406 | return sec; | 682 | 406 | } |
pei-riscv64.c:pe_ILF_make_a_section Line | Count | Source | 623 | 402 | { | 624 | 402 | asection_ptr sec; | 625 | 402 | flagword flags; | 626 | 402 | intptr_t alignment; | 627 | | | 628 | 402 | sec = bfd_make_section_old_way (vars->abfd, name); | 629 | 402 | if (sec == NULL) | 630 | 0 | return NULL; | 631 | | | 632 | 402 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 633 | | | 634 | 402 | bfd_set_section_flags (sec, flags | extra_flags); | 635 | | | 636 | 402 | bfd_set_section_alignment (sec, 2); | 637 | | | 638 | | /* Check that we will not run out of space. */ | 639 | 402 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 640 | | | 641 | | /* Set the section size and contents. The actual | 642 | | contents are filled in by our parent. */ | 643 | 402 | bfd_set_section_size (sec, (bfd_size_type) size); | 644 | 402 | sec->contents = vars->data; | 645 | 402 | sec->target_index = vars->sec_index ++; | 646 | | | 647 | | /* Advance data pointer in the vars structure. */ | 648 | 402 | vars->data += size; | 649 | | | 650 | | /* Skip the padding byte if it was not needed. | 651 | | The logic here is that if the string length is odd, | 652 | | then the entire string length, including the null byte, | 653 | | is even and so the extra, padding byte, is not needed. */ | 654 | 402 | if (size & 1) | 655 | 51 | vars->data --; | 656 | | | 657 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 658 | | preserve host alignment requirements. The BFD_ASSERTs in this | 659 | | functions will warn us if we run out of room, but we should | 660 | | already have enough padding built in to ILF_DATA_SIZE. */ | 661 | 402 | #if GCC_VERSION >= 3000 | 662 | 402 | alignment = __alignof__ (struct coff_section_tdata); | 663 | | #else | 664 | | alignment = 8; | 665 | | #endif | 666 | 402 | vars->data | 667 | 402 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 668 | | | 669 | | /* Create a coff_section_tdata structure for our use. */ | 670 | 402 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 671 | 402 | vars->data += sizeof (struct coff_section_tdata); | 672 | | | 673 | 402 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 674 | | | 675 | | /* Create a symbol to refer to this section. */ | 676 | 402 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 677 | | | 678 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 679 | 402 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 680 | | | 681 | 402 | return sec; | 682 | 402 | } |
pei-arm-wince.c:pe_ILF_make_a_section Line | Count | Source | 623 | 277 | { | 624 | 277 | asection_ptr sec; | 625 | 277 | flagword flags; | 626 | 277 | intptr_t alignment; | 627 | | | 628 | 277 | sec = bfd_make_section_old_way (vars->abfd, name); | 629 | 277 | if (sec == NULL) | 630 | 0 | return NULL; | 631 | | | 632 | 277 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 633 | | | 634 | 277 | bfd_set_section_flags (sec, flags | extra_flags); | 635 | | | 636 | 277 | bfd_set_section_alignment (sec, 2); | 637 | | | 638 | | /* Check that we will not run out of space. */ | 639 | 277 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 640 | | | 641 | | /* Set the section size and contents. The actual | 642 | | contents are filled in by our parent. */ | 643 | 277 | bfd_set_section_size (sec, (bfd_size_type) size); | 644 | 277 | sec->contents = vars->data; | 645 | 277 | sec->target_index = vars->sec_index ++; | 646 | | | 647 | | /* Advance data pointer in the vars structure. */ | 648 | 277 | vars->data += size; | 649 | | | 650 | | /* Skip the padding byte if it was not needed. | 651 | | The logic here is that if the string length is odd, | 652 | | then the entire string length, including the null byte, | 653 | | is even and so the extra, padding byte, is not needed. */ | 654 | 277 | if (size & 1) | 655 | 32 | vars->data --; | 656 | | | 657 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 658 | | preserve host alignment requirements. The BFD_ASSERTs in this | 659 | | functions will warn us if we run out of room, but we should | 660 | | already have enough padding built in to ILF_DATA_SIZE. */ | 661 | 277 | #if GCC_VERSION >= 3000 | 662 | 277 | alignment = __alignof__ (struct coff_section_tdata); | 663 | | #else | 664 | | alignment = 8; | 665 | | #endif | 666 | 277 | vars->data | 667 | 277 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 668 | | | 669 | | /* Create a coff_section_tdata structure for our use. */ | 670 | 277 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 671 | 277 | vars->data += sizeof (struct coff_section_tdata); | 672 | | | 673 | 277 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 674 | | | 675 | | /* Create a symbol to refer to this section. */ | 676 | 277 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 677 | | | 678 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 679 | 277 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 680 | | | 681 | 277 | return sec; | 682 | 277 | } |
pei-arm.c:pe_ILF_make_a_section Line | Count | Source | 623 | 293 | { | 624 | 293 | asection_ptr sec; | 625 | 293 | flagword flags; | 626 | 293 | intptr_t alignment; | 627 | | | 628 | 293 | sec = bfd_make_section_old_way (vars->abfd, name); | 629 | 293 | if (sec == NULL) | 630 | 0 | return NULL; | 631 | | | 632 | 293 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 633 | | | 634 | 293 | bfd_set_section_flags (sec, flags | extra_flags); | 635 | | | 636 | 293 | bfd_set_section_alignment (sec, 2); | 637 | | | 638 | | /* Check that we will not run out of space. */ | 639 | 293 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 640 | | | 641 | | /* Set the section size and contents. The actual | 642 | | contents are filled in by our parent. */ | 643 | 293 | bfd_set_section_size (sec, (bfd_size_type) size); | 644 | 293 | sec->contents = vars->data; | 645 | 293 | sec->target_index = vars->sec_index ++; | 646 | | | 647 | | /* Advance data pointer in the vars structure. */ | 648 | 293 | vars->data += size; | 649 | | | 650 | | /* Skip the padding byte if it was not needed. | 651 | | The logic here is that if the string length is odd, | 652 | | then the entire string length, including the null byte, | 653 | | is even and so the extra, padding byte, is not needed. */ | 654 | 293 | if (size & 1) | 655 | 32 | vars->data --; | 656 | | | 657 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 658 | | preserve host alignment requirements. The BFD_ASSERTs in this | 659 | | functions will warn us if we run out of room, but we should | 660 | | already have enough padding built in to ILF_DATA_SIZE. */ | 661 | 293 | #if GCC_VERSION >= 3000 | 662 | 293 | alignment = __alignof__ (struct coff_section_tdata); | 663 | | #else | 664 | | alignment = 8; | 665 | | #endif | 666 | 293 | vars->data | 667 | 293 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 668 | | | 669 | | /* Create a coff_section_tdata structure for our use. */ | 670 | 293 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 671 | 293 | vars->data += sizeof (struct coff_section_tdata); | 672 | | | 673 | 293 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 674 | | | 675 | | /* Create a symbol to refer to this section. */ | 676 | 293 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 677 | | | 678 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 679 | 293 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 680 | | | 681 | 293 | return sec; | 682 | 293 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_section pei-sh.c:pe_ILF_make_a_section Line | Count | Source | 623 | 610 | { | 624 | 610 | asection_ptr sec; | 625 | 610 | flagword flags; | 626 | 610 | intptr_t alignment; | 627 | | | 628 | 610 | sec = bfd_make_section_old_way (vars->abfd, name); | 629 | 610 | if (sec == NULL) | 630 | 0 | return NULL; | 631 | | | 632 | 610 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 633 | | | 634 | 610 | bfd_set_section_flags (sec, flags | extra_flags); | 635 | | | 636 | 610 | bfd_set_section_alignment (sec, 2); | 637 | | | 638 | | /* Check that we will not run out of space. */ | 639 | 610 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 640 | | | 641 | | /* Set the section size and contents. The actual | 642 | | contents are filled in by our parent. */ | 643 | 610 | bfd_set_section_size (sec, (bfd_size_type) size); | 644 | 610 | sec->contents = vars->data; | 645 | 610 | sec->target_index = vars->sec_index ++; | 646 | | | 647 | | /* Advance data pointer in the vars structure. */ | 648 | 610 | vars->data += size; | 649 | | | 650 | | /* Skip the padding byte if it was not needed. | 651 | | The logic here is that if the string length is odd, | 652 | | then the entire string length, including the null byte, | 653 | | is even and so the extra, padding byte, is not needed. */ | 654 | 610 | if (size & 1) | 655 | 87 | vars->data --; | 656 | | | 657 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 658 | | preserve host alignment requirements. The BFD_ASSERTs in this | 659 | | functions will warn us if we run out of room, but we should | 660 | | already have enough padding built in to ILF_DATA_SIZE. */ | 661 | 610 | #if GCC_VERSION >= 3000 | 662 | 610 | alignment = __alignof__ (struct coff_section_tdata); | 663 | | #else | 664 | | alignment = 8; | 665 | | #endif | 666 | 610 | vars->data | 667 | 610 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 668 | | | 669 | | /* Create a coff_section_tdata structure for our use. */ | 670 | 610 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 671 | 610 | vars->data += sizeof (struct coff_section_tdata); | 672 | | | 673 | 610 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 674 | | | 675 | | /* Create a symbol to refer to this section. */ | 676 | 610 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 677 | | | 678 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 679 | 610 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 680 | | | 681 | 610 | return sec; | 682 | 610 | } |
|
683 | | |
684 | | /* This structure contains the code that goes into the .text section |
685 | | in order to perform a jump into the DLL lookup table. The entries |
686 | | in the table are index by the magic number used to represent the |
687 | | machine type in the PE file. The contents of the data[] arrays in |
688 | | these entries are stolen from the jtab[] arrays in ld/pe-dll.c. |
689 | | The SIZE field says how many bytes in the DATA array are actually |
690 | | used. The OFFSET field says where in the data array the address |
691 | | of the .idata$5 section should be placed. */ |
692 | 3.17k | #define MAX_TEXT_SECTION_SIZE 32 |
693 | | |
694 | | typedef struct |
695 | | { |
696 | | unsigned short magic; |
697 | | unsigned char data[MAX_TEXT_SECTION_SIZE]; |
698 | | unsigned int size; |
699 | | unsigned int offset; |
700 | | } |
701 | | jump_table; |
702 | | |
703 | | static const jump_table jtab[] = |
704 | | { |
705 | | #ifdef I386MAGIC |
706 | | { I386MAGIC, |
707 | | { 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90 }, |
708 | | 8, 2 |
709 | | }, |
710 | | #endif |
711 | | |
712 | | #ifdef AMD64MAGIC |
713 | | { AMD64MAGIC, |
714 | | { 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90 }, |
715 | | 8, 2 |
716 | | }, |
717 | | #endif |
718 | | |
719 | | #ifdef MC68MAGIC |
720 | | { MC68MAGIC, |
721 | | { /* XXX fill me in */ }, |
722 | | 0, 0 |
723 | | }, |
724 | | #endif |
725 | | |
726 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
727 | | { MIPS_ARCH_MAGIC_WINCE, |
728 | | { 0x00, 0x00, 0x08, 0x3c, 0x00, 0x00, 0x08, 0x8d, |
729 | | 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }, |
730 | | 16, 0 |
731 | | }, |
732 | | #endif |
733 | | |
734 | | #ifdef SH_ARCH_MAGIC_WINCE |
735 | | { SH_ARCH_MAGIC_WINCE, |
736 | | { 0x01, 0xd0, 0x02, 0x60, 0x2b, 0x40, |
737 | | 0x09, 0x00, 0x00, 0x00, 0x00, 0x00 }, |
738 | | 12, 8 |
739 | | }, |
740 | | #endif |
741 | | |
742 | | #ifdef AARCH64MAGIC |
743 | | /* We don't currently support jumping to DLLs, so if |
744 | | someone does try emit a runtime trap. Through UDF #0. */ |
745 | | { AARCH64MAGIC, |
746 | | { 0x00, 0x00, 0x00, 0x00 }, |
747 | | 4, 0 |
748 | | }, |
749 | | |
750 | | #endif |
751 | | |
752 | | #ifdef ARMPEMAGIC |
753 | | { ARMPEMAGIC, |
754 | | { 0x00, 0xc0, 0x9f, 0xe5, 0x00, 0xf0, |
755 | | 0x9c, 0xe5, 0x00, 0x00, 0x00, 0x00}, |
756 | | 12, 8 |
757 | | }, |
758 | | #endif |
759 | | |
760 | | #ifdef THUMBPEMAGIC |
761 | | { THUMBPEMAGIC, |
762 | | { 0x40, 0xb4, 0x02, 0x4e, 0x36, 0x68, 0xb4, 0x46, |
763 | | 0x40, 0xbc, 0x60, 0x47, 0x00, 0x00, 0x00, 0x00 }, |
764 | | 16, 12 |
765 | | }, |
766 | | #endif |
767 | | |
768 | | #ifdef LOONGARCH64MAGIC |
769 | | /* We don't currently support jumping to DLLs, so if |
770 | | someone does try emit a runtime trap. Through BREAK 0. */ |
771 | | { LOONGARCH64MAGIC, |
772 | | { 0x00, 0x00, 0x2a, 0x00 }, |
773 | | 4, 0 |
774 | | }, |
775 | | |
776 | | #endif |
777 | | |
778 | | #ifdef RISCV64MAGIC |
779 | | /* We don't currently support jumping to DLLs, so if |
780 | | someone does try emit a runtime trap. Through EBREAK. */ |
781 | | { RISCV64MAGIC, |
782 | | { 0x73, 0x00, 0x10, 0x00 }, |
783 | | 4, 0 |
784 | | }, |
785 | | |
786 | | #endif |
787 | | |
788 | | { 0, { 0 }, 0, 0 } |
789 | | }; |
790 | | |
791 | | #ifndef NUM_ENTRIES |
792 | 447 | #define NUM_ENTRIES(a) (sizeof (a) / sizeof (a)[0]) |
793 | | #endif |
794 | | |
795 | | /* Build a full BFD from the information supplied in a ILF object. */ |
796 | | |
797 | | static bool |
798 | | pe_ILF_build_a_bfd (bfd * abfd, |
799 | | unsigned int magic, |
800 | | char * symbol_name, |
801 | | char * source_dll, |
802 | | unsigned int ordinal, |
803 | | unsigned int types, |
804 | | char * import_name) |
805 | 1.41k | { |
806 | 1.41k | bfd_byte * ptr; |
807 | 1.41k | pe_ILF_vars vars; |
808 | 1.41k | struct internal_filehdr internal_f; |
809 | 1.41k | unsigned int import_type; |
810 | 1.41k | unsigned int import_name_type; |
811 | 1.41k | asection_ptr id4, id5, id6 = NULL, text = NULL; |
812 | 1.41k | coff_symbol_type ** imp_sym; |
813 | 1.41k | unsigned int imp_index; |
814 | 1.41k | intptr_t alignment; |
815 | | |
816 | | /* Decode and verify the types field of the ILF structure. */ |
817 | 1.41k | import_type = types & 0x3; |
818 | 1.41k | import_name_type = (types & 0x1c) >> 2; |
819 | | |
820 | 1.41k | switch (import_type) |
821 | 1.41k | { |
822 | 600 | case IMPORT_CODE: |
823 | 975 | case IMPORT_DATA: |
824 | 1.28k | case IMPORT_CONST: |
825 | 1.28k | break; |
826 | | |
827 | 135 | default: |
828 | | /* xgettext:c-format */ |
829 | 135 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), |
830 | 135 | abfd, import_type); |
831 | 135 | return false; |
832 | 1.41k | } |
833 | | |
834 | 1.28k | switch (import_name_type) |
835 | 1.28k | { |
836 | 332 | case IMPORT_ORDINAL: |
837 | 452 | case IMPORT_NAME: |
838 | 634 | case IMPORT_NAME_NOPREFIX: |
839 | 969 | case IMPORT_NAME_UNDECORATE: |
840 | 969 | import_name = symbol_name; |
841 | 969 | break; |
842 | | |
843 | 239 | case IMPORT_NAME_EXPORTAS: |
844 | 239 | if (!import_name || !import_name[0]) |
845 | 150 | { |
846 | 150 | _bfd_error_handler (_("%pB: missing import name for " |
847 | 150 | "IMPORT_NAME_EXPORTAS for %s"), |
848 | 150 | abfd, symbol_name); |
849 | 150 | return false; |
850 | 150 | } |
851 | 89 | break; |
852 | | |
853 | 89 | default: |
854 | | /* xgettext:c-format */ |
855 | 73 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), |
856 | 73 | abfd, import_name_type); |
857 | 73 | return false; |
858 | 1.28k | } |
859 | | |
860 | | /* Initialise local variables. |
861 | | |
862 | | Note these are kept in a structure rather than being |
863 | | declared as statics since bfd frowns on global variables. |
864 | | |
865 | | We are going to construct the contents of the BFD in memory, |
866 | | so allocate all the space that we will need right now. */ |
867 | 1.05k | vars.bim |
868 | 1.05k | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); |
869 | 1.05k | if (vars.bim == NULL) |
870 | 0 | return false; |
871 | | |
872 | 1.05k | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); |
873 | 1.05k | vars.bim->buffer = ptr; |
874 | 1.05k | vars.bim->size = ILF_DATA_SIZE; |
875 | 1.05k | vars.bim->capacity = ILF_DATA_SIZE; |
876 | 1.05k | if (ptr == NULL) |
877 | 0 | goto error_return; |
878 | | |
879 | | /* Initialise the pointers to regions of the memory and the |
880 | | other contents of the pe_ILF_vars structure as well. */ |
881 | 1.05k | vars.sym_cache = (coff_symbol_type *) ptr; |
882 | 1.05k | vars.sym_ptr = (coff_symbol_type *) ptr; |
883 | 1.05k | vars.sym_index = 0; |
884 | 1.05k | ptr += SIZEOF_ILF_SYMS; |
885 | | |
886 | 1.05k | vars.sym_table = (unsigned int *) ptr; |
887 | 1.05k | vars.table_ptr = (unsigned int *) ptr; |
888 | 1.05k | ptr += SIZEOF_ILF_SYM_TABLE; |
889 | | |
890 | 1.05k | vars.native_syms = (combined_entry_type *) ptr; |
891 | 1.05k | vars.native_ptr = (combined_entry_type *) ptr; |
892 | 1.05k | ptr += SIZEOF_ILF_NATIVE_SYMS; |
893 | | |
894 | 1.05k | vars.sym_ptr_table = (coff_symbol_type **) ptr; |
895 | 1.05k | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; |
896 | 1.05k | ptr += SIZEOF_ILF_SYM_PTR_TABLE; |
897 | | |
898 | 1.05k | vars.esym_table = (SYMENT *) ptr; |
899 | 1.05k | vars.esym_ptr = (SYMENT *) ptr; |
900 | 1.05k | ptr += SIZEOF_ILF_EXT_SYMS; |
901 | | |
902 | 1.05k | vars.reltab = (arelent *) ptr; |
903 | 1.05k | vars.relcount = 0; |
904 | 1.05k | ptr += SIZEOF_ILF_RELOCS; |
905 | | |
906 | 1.05k | vars.int_reltab = (struct internal_reloc *) ptr; |
907 | 1.05k | ptr += SIZEOF_ILF_INT_RELOCS; |
908 | | |
909 | 1.05k | vars.string_table = (char *) ptr; |
910 | 1.05k | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; |
911 | 1.05k | ptr += SIZEOF_ILF_STRINGS; |
912 | 1.05k | vars.end_string_ptr = (char *) ptr; |
913 | | |
914 | | /* The remaining space in bim->buffer is used |
915 | | by the pe_ILF_make_a_section() function. */ |
916 | | |
917 | | /* PR 18758: Make sure that the data area is sufficiently aligned for |
918 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence |
919 | | the test of GCC_VERSION. For other compilers we assume 8 byte |
920 | | alignment. */ |
921 | 1.05k | #if GCC_VERSION >= 3000 |
922 | 1.05k | alignment = __alignof__ (struct coff_section_tdata); |
923 | | #else |
924 | | alignment = 8; |
925 | | #endif |
926 | 1.05k | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); |
927 | | |
928 | 1.05k | vars.data = ptr; |
929 | 1.05k | vars.abfd = abfd; |
930 | 1.05k | vars.sec_index = 0; |
931 | 1.05k | vars.magic = magic; |
932 | | |
933 | | /* Create the initial .idata$<n> sections: |
934 | | [.idata$2: Import Directory Table -- not needed] |
935 | | .idata$4: Import Lookup Table |
936 | | .idata$5: Import Address Table |
937 | | |
938 | | Note we do not create a .idata$3 section as this is |
939 | | created for us by the linker script. */ |
940 | 1.05k | id4 = pe_ILF_make_a_section (&vars, ".idata$4", SIZEOF_IDATA4, 0); |
941 | 1.05k | id5 = pe_ILF_make_a_section (&vars, ".idata$5", SIZEOF_IDATA5, 0); |
942 | 1.05k | if (id4 == NULL || id5 == NULL) |
943 | 0 | goto error_return; |
944 | | |
945 | | /* Fill in the contents of these sections. */ |
946 | 1.05k | if (import_name_type == IMPORT_ORDINAL) |
947 | 332 | { |
948 | 332 | if (ordinal == 0) |
949 | | /* See PR 20907 for a reproducer. */ |
950 | 73 | goto error_return; |
951 | | |
952 | | #if (defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) \ |
953 | | || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64)) |
954 | 126 | ((unsigned int *) id4->contents)[0] = ordinal; |
955 | 126 | ((unsigned int *) id4->contents)[1] = 0x80000000; |
956 | 126 | ((unsigned int *) id5->contents)[0] = ordinal; |
957 | 126 | ((unsigned int *) id5->contents)[1] = 0x80000000; |
958 | | #else |
959 | 133 | ((unsigned int *) id4->contents)[0] = ordinal | 0x80000000; |
960 | 133 | ((unsigned int *) id5->contents)[0] = ordinal | 0x80000000; |
961 | 133 | #endif |
962 | 133 | } |
963 | 726 | else |
964 | 726 | { |
965 | 726 | char *symbol; |
966 | 726 | unsigned int len; |
967 | | |
968 | | /* Create .idata$6 - the Hint Name Table. */ |
969 | 726 | id6 = pe_ILF_make_a_section (&vars, ".idata$6", SIZEOF_IDATA6, 0); |
970 | 726 | if (id6 == NULL) |
971 | 0 | goto error_return; |
972 | | |
973 | | /* If necessary, trim the import symbol name. */ |
974 | 726 | symbol = import_name; |
975 | | |
976 | | /* As used by MS compiler, '_', '@', and '?' are alternative |
977 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, |
978 | | '@' used for fastcall (in C), '_' everywhere else. Only one |
979 | | of these is used for a symbol. We strip this leading char for |
980 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the |
981 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ |
982 | | |
983 | 726 | if (import_name_type != IMPORT_NAME |
984 | 606 | && import_name_type != IMPORT_NAME_EXPORTAS) |
985 | 517 | { |
986 | 517 | char c = symbol[0]; |
987 | | |
988 | | /* Check that we don't remove for targets with empty |
989 | | USER_LABEL_PREFIX the leading underscore. */ |
990 | 517 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) |
991 | 491 | || c == '@' || c == '?') |
992 | 151 | symbol++; |
993 | 517 | } |
994 | | |
995 | 726 | len = strlen (symbol); |
996 | 726 | if (import_name_type == IMPORT_NAME_UNDECORATE) |
997 | 335 | { |
998 | | /* Truncate at the first '@'. */ |
999 | 335 | char *at = strchr (symbol, '@'); |
1000 | | |
1001 | 335 | if (at != NULL) |
1002 | 65 | len = at - symbol; |
1003 | 335 | } |
1004 | | |
1005 | 726 | id6->contents[0] = ordinal & 0xff; |
1006 | 726 | id6->contents[1] = ordinal >> 8; |
1007 | | |
1008 | 726 | memcpy ((char *) id6->contents + 2, symbol, len); |
1009 | 726 | id6->contents[len + 2] = '\0'; |
1010 | 726 | } |
1011 | | |
1012 | 985 | if (import_name_type != IMPORT_ORDINAL) |
1013 | 726 | { |
1014 | 726 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); |
1015 | 726 | pe_ILF_save_relocs (&vars, id4); |
1016 | | |
1017 | 726 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); |
1018 | 726 | pe_ILF_save_relocs (&vars, id5); |
1019 | 726 | } |
1020 | | |
1021 | | /* Create an import symbol. */ |
1022 | 985 | pe_ILF_make_a_symbol (&vars, "__imp_", symbol_name, id5, 0); |
1023 | 985 | imp_sym = vars.sym_ptr_ptr - 1; |
1024 | 985 | imp_index = vars.sym_index - 1; |
1025 | | |
1026 | | /* Create extra sections depending upon the type of import we are |
1027 | | dealing with. */ |
1028 | 985 | switch (import_type) |
1029 | 985 | { |
1030 | 0 | int i; |
1031 | | |
1032 | 447 | case IMPORT_CODE: |
1033 | | /* CODE functions are special, in that they get a trampoline that |
1034 | | jumps to the main import symbol. Create a .text section to hold it. |
1035 | | First we need to look up its contents in the jump table. */ |
1036 | 940 | for (i = NUM_ENTRIES (jtab); i--;) |
1037 | 940 | { |
1038 | 940 | if (jtab[i].size == 0) |
1039 | 447 | continue; |
1040 | 493 | if (jtab[i].magic == magic) |
1041 | 447 | break; |
1042 | 493 | } |
1043 | | /* If we did not find a matching entry something is wrong. */ |
1044 | 447 | if (i < 0) |
1045 | 0 | abort (); |
1046 | | |
1047 | | /* Create the .text section. */ |
1048 | 447 | text = pe_ILF_make_a_section (&vars, ".text", jtab[i].size, SEC_CODE); |
1049 | 447 | if (text == NULL) |
1050 | 0 | goto error_return; |
1051 | | |
1052 | | /* Copy in the jump code. */ |
1053 | 447 | memcpy (text->contents, jtab[i].data, jtab[i].size); |
1054 | | |
1055 | | /* Create a reloc for the data in the text section. */ |
1056 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
1057 | | if (magic == MIPS_ARCH_MAGIC_WINCE) |
1058 | | { |
1059 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, |
1060 | | (struct bfd_symbol **) imp_sym, |
1061 | | imp_index); |
1062 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); |
1063 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, |
1064 | | (struct bfd_symbol **) imp_sym, |
1065 | | imp_index); |
1066 | | } |
1067 | | else |
1068 | | #endif |
1069 | | #ifdef AMD64MAGIC |
1070 | 40 | if (magic == AMD64MAGIC) |
1071 | 40 | { |
1072 | 40 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, |
1073 | 40 | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, |
1074 | 40 | imp_index); |
1075 | 40 | } |
1076 | 0 | else |
1077 | 0 | #endif |
1078 | 0 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, |
1079 | 0 | BFD_RELOC_32, (asymbol **) imp_sym, |
1080 | 0 | imp_index); |
1081 | | |
1082 | 447 | pe_ILF_save_relocs (&vars, text); |
1083 | 447 | break; |
1084 | | |
1085 | 298 | case IMPORT_DATA: |
1086 | 538 | case IMPORT_CONST: |
1087 | 538 | break; |
1088 | | |
1089 | 0 | default: |
1090 | | /* XXX code not yet written. */ |
1091 | 0 | abort (); |
1092 | 985 | } |
1093 | | |
1094 | | /* Now create a symbol describing the imported value. */ |
1095 | 985 | switch (import_type) |
1096 | 985 | { |
1097 | 447 | case IMPORT_CODE: |
1098 | 447 | pe_ILF_make_a_symbol (&vars, "", symbol_name, text, |
1099 | 447 | BSF_NOT_AT_END | BSF_FUNCTION); |
1100 | | |
1101 | 447 | break; |
1102 | | |
1103 | 298 | case IMPORT_DATA: |
1104 | | /* Nothing to do here. */ |
1105 | 298 | break; |
1106 | | |
1107 | 240 | case IMPORT_CONST: |
1108 | 240 | pe_ILF_make_a_symbol (&vars, "", symbol_name, id5, 0); |
1109 | 240 | break; |
1110 | | |
1111 | 0 | default: |
1112 | | /* XXX code not yet written. */ |
1113 | 0 | abort (); |
1114 | 985 | } |
1115 | | |
1116 | | /* Create an import symbol for the DLL, without the .dll suffix. */ |
1117 | 985 | ptr = (bfd_byte *) strrchr (source_dll, '.'); |
1118 | 985 | if (ptr) |
1119 | 124 | *ptr = 0; |
1120 | 985 | pe_ILF_make_a_symbol (&vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); |
1121 | 985 | if (ptr) |
1122 | 124 | *ptr = '.'; |
1123 | | |
1124 | | /* Initialise the bfd. */ |
1125 | 985 | memset (&internal_f, 0, sizeof (internal_f)); |
1126 | | |
1127 | 985 | internal_f.f_magic = magic; |
1128 | 985 | internal_f.f_symptr = 0; |
1129 | 985 | internal_f.f_nsyms = 0; |
1130 | 985 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ |
1131 | | |
1132 | 985 | if (!bfd_set_start_address (abfd, (bfd_vma) 0) |
1133 | 985 | || !bfd_coff_set_arch_mach_hook (abfd, &internal_f)) |
1134 | 0 | goto error_return; |
1135 | | |
1136 | 985 | if (bfd_coff_mkobject_hook (abfd, (void *) &internal_f, NULL) == NULL) |
1137 | 0 | goto error_return; |
1138 | | |
1139 | 985 | obj_pe (abfd) = true; |
1140 | | #ifdef THUMBPEMAGIC |
1141 | 163 | if (vars.magic == THUMBPEMAGIC) |
1142 | | /* Stop some linker warnings about thumb code not supporting |
1143 | | interworking. */ |
1144 | 78 | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; |
1145 | | #endif |
1146 | | |
1147 | | /* Switch from file contents to memory contents. */ |
1148 | 985 | bfd_cache_close (abfd); |
1149 | | |
1150 | 985 | abfd->iostream = (void *) vars.bim; |
1151 | 985 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; |
1152 | 985 | abfd->iovec = &_bfd_memory_iovec; |
1153 | 985 | abfd->where = 0; |
1154 | 985 | abfd->origin = 0; |
1155 | 985 | abfd->size = 0; |
1156 | 985 | obj_sym_filepos (abfd) = 0; |
1157 | | |
1158 | | /* Point the bfd at the symbol table. */ |
1159 | 985 | obj_symbols (abfd) = vars.sym_cache; |
1160 | 985 | abfd->symcount = vars.sym_index; |
1161 | | |
1162 | 985 | obj_raw_syments (abfd) = vars.native_syms; |
1163 | 985 | obj_raw_syment_count (abfd) = vars.sym_index; |
1164 | 985 | obj_coff_keep_raw_syms (abfd) = true; |
1165 | | |
1166 | 985 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; |
1167 | 985 | obj_coff_keep_syms (abfd) = true; |
1168 | | |
1169 | 985 | obj_convert (abfd) = vars.sym_table; |
1170 | 985 | obj_conv_table_size (abfd) = vars.sym_index; |
1171 | | |
1172 | 985 | obj_coff_strings (abfd) = vars.string_table; |
1173 | 985 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; |
1174 | 985 | obj_coff_keep_strings (abfd) = true; |
1175 | | |
1176 | 985 | return true; |
1177 | | |
1178 | 73 | error_return: |
1179 | 73 | free (vars.bim->buffer); |
1180 | 73 | free (vars.bim); |
1181 | 73 | return false; |
1182 | 985 | } pei-i386.c:pe_ILF_build_a_bfd Line | Count | Source | 805 | 195 | { | 806 | 195 | bfd_byte * ptr; | 807 | 195 | pe_ILF_vars vars; | 808 | 195 | struct internal_filehdr internal_f; | 809 | 195 | unsigned int import_type; | 810 | 195 | unsigned int import_name_type; | 811 | 195 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 812 | 195 | coff_symbol_type ** imp_sym; | 813 | 195 | unsigned int imp_index; | 814 | 195 | intptr_t alignment; | 815 | | | 816 | | /* Decode and verify the types field of the ILF structure. */ | 817 | 195 | import_type = types & 0x3; | 818 | 195 | import_name_type = (types & 0x1c) >> 2; | 819 | | | 820 | 195 | switch (import_type) | 821 | 195 | { | 822 | 98 | case IMPORT_CODE: | 823 | 144 | case IMPORT_DATA: | 824 | 186 | case IMPORT_CONST: | 825 | 186 | break; | 826 | | | 827 | 9 | default: | 828 | | /* xgettext:c-format */ | 829 | 9 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 830 | 9 | abfd, import_type); | 831 | 9 | return false; | 832 | 195 | } | 833 | | | 834 | 186 | switch (import_name_type) | 835 | 186 | { | 836 | 55 | case IMPORT_ORDINAL: | 837 | 84 | case IMPORT_NAME: | 838 | 113 | case IMPORT_NAME_NOPREFIX: | 839 | 152 | case IMPORT_NAME_UNDECORATE: | 840 | 152 | import_name = symbol_name; | 841 | 152 | break; | 842 | | | 843 | 26 | case IMPORT_NAME_EXPORTAS: | 844 | 26 | if (!import_name || !import_name[0]) | 845 | 16 | { | 846 | 16 | _bfd_error_handler (_("%pB: missing import name for " | 847 | 16 | "IMPORT_NAME_EXPORTAS for %s"), | 848 | 16 | abfd, symbol_name); | 849 | 16 | return false; | 850 | 16 | } | 851 | 10 | break; | 852 | | | 853 | 10 | default: | 854 | | /* xgettext:c-format */ | 855 | 8 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 856 | 8 | abfd, import_name_type); | 857 | 8 | return false; | 858 | 186 | } | 859 | | | 860 | | /* Initialise local variables. | 861 | | | 862 | | Note these are kept in a structure rather than being | 863 | | declared as statics since bfd frowns on global variables. | 864 | | | 865 | | We are going to construct the contents of the BFD in memory, | 866 | | so allocate all the space that we will need right now. */ | 867 | 162 | vars.bim | 868 | 162 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 869 | 162 | if (vars.bim == NULL) | 870 | 0 | return false; | 871 | | | 872 | 162 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 873 | 162 | vars.bim->buffer = ptr; | 874 | 162 | vars.bim->size = ILF_DATA_SIZE; | 875 | 162 | vars.bim->capacity = ILF_DATA_SIZE; | 876 | 162 | if (ptr == NULL) | 877 | 0 | goto error_return; | 878 | | | 879 | | /* Initialise the pointers to regions of the memory and the | 880 | | other contents of the pe_ILF_vars structure as well. */ | 881 | 162 | vars.sym_cache = (coff_symbol_type *) ptr; | 882 | 162 | vars.sym_ptr = (coff_symbol_type *) ptr; | 883 | 162 | vars.sym_index = 0; | 884 | 162 | ptr += SIZEOF_ILF_SYMS; | 885 | | | 886 | 162 | vars.sym_table = (unsigned int *) ptr; | 887 | 162 | vars.table_ptr = (unsigned int *) ptr; | 888 | 162 | ptr += SIZEOF_ILF_SYM_TABLE; | 889 | | | 890 | 162 | vars.native_syms = (combined_entry_type *) ptr; | 891 | 162 | vars.native_ptr = (combined_entry_type *) ptr; | 892 | 162 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 893 | | | 894 | 162 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 895 | 162 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 896 | 162 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 897 | | | 898 | 162 | vars.esym_table = (SYMENT *) ptr; | 899 | 162 | vars.esym_ptr = (SYMENT *) ptr; | 900 | 162 | ptr += SIZEOF_ILF_EXT_SYMS; | 901 | | | 902 | 162 | vars.reltab = (arelent *) ptr; | 903 | 162 | vars.relcount = 0; | 904 | 162 | ptr += SIZEOF_ILF_RELOCS; | 905 | | | 906 | 162 | vars.int_reltab = (struct internal_reloc *) ptr; | 907 | 162 | ptr += SIZEOF_ILF_INT_RELOCS; | 908 | | | 909 | 162 | vars.string_table = (char *) ptr; | 910 | 162 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 911 | 162 | ptr += SIZEOF_ILF_STRINGS; | 912 | 162 | vars.end_string_ptr = (char *) ptr; | 913 | | | 914 | | /* The remaining space in bim->buffer is used | 915 | | by the pe_ILF_make_a_section() function. */ | 916 | | | 917 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 918 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 919 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 920 | | alignment. */ | 921 | 162 | #if GCC_VERSION >= 3000 | 922 | 162 | alignment = __alignof__ (struct coff_section_tdata); | 923 | | #else | 924 | | alignment = 8; | 925 | | #endif | 926 | 162 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 927 | | | 928 | 162 | vars.data = ptr; | 929 | 162 | vars.abfd = abfd; | 930 | 162 | vars.sec_index = 0; | 931 | 162 | vars.magic = magic; | 932 | | | 933 | | /* Create the initial .idata$<n> sections: | 934 | | [.idata$2: Import Directory Table -- not needed] | 935 | | .idata$4: Import Lookup Table | 936 | | .idata$5: Import Address Table | 937 | | | 938 | | Note we do not create a .idata$3 section as this is | 939 | | created for us by the linker script. */ | 940 | 162 | id4 = pe_ILF_make_a_section (&vars, ".idata$4", SIZEOF_IDATA4, 0); | 941 | 162 | id5 = pe_ILF_make_a_section (&vars, ".idata$5", SIZEOF_IDATA5, 0); | 942 | 162 | if (id4 == NULL || id5 == NULL) | 943 | 0 | goto error_return; | 944 | | | 945 | | /* Fill in the contents of these sections. */ | 946 | 162 | if (import_name_type == IMPORT_ORDINAL) | 947 | 55 | { | 948 | 55 | if (ordinal == 0) | 949 | | /* See PR 20907 for a reproducer. */ | 950 | 9 | goto error_return; | 951 | | | 952 | | #if (defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) \ | 953 | | || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64)) | 954 | | ((unsigned int *) id4->contents)[0] = ordinal; | 955 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 956 | | ((unsigned int *) id5->contents)[0] = ordinal; | 957 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 958 | | #else | 959 | 46 | ((unsigned int *) id4->contents)[0] = ordinal | 0x80000000; | 960 | 46 | ((unsigned int *) id5->contents)[0] = ordinal | 0x80000000; | 961 | 46 | #endif | 962 | 46 | } | 963 | 107 | else | 964 | 107 | { | 965 | 107 | char *symbol; | 966 | 107 | unsigned int len; | 967 | | | 968 | | /* Create .idata$6 - the Hint Name Table. */ | 969 | 107 | id6 = pe_ILF_make_a_section (&vars, ".idata$6", SIZEOF_IDATA6, 0); | 970 | 107 | if (id6 == NULL) | 971 | 0 | goto error_return; | 972 | | | 973 | | /* If necessary, trim the import symbol name. */ | 974 | 107 | symbol = import_name; | 975 | | | 976 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 977 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 978 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 979 | | of these is used for a symbol. We strip this leading char for | 980 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 981 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 982 | | | 983 | 107 | if (import_name_type != IMPORT_NAME | 984 | 78 | && import_name_type != IMPORT_NAME_EXPORTAS) | 985 | 68 | { | 986 | 68 | char c = symbol[0]; | 987 | | | 988 | | /* Check that we don't remove for targets with empty | 989 | | USER_LABEL_PREFIX the leading underscore. */ | 990 | 68 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 991 | 59 | || c == '@' || c == '?') | 992 | 28 | symbol++; | 993 | 68 | } | 994 | | | 995 | 107 | len = strlen (symbol); | 996 | 107 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 997 | 39 | { | 998 | | /* Truncate at the first '@'. */ | 999 | 39 | char *at = strchr (symbol, '@'); | 1000 | | | 1001 | 39 | if (at != NULL) | 1002 | 7 | len = at - symbol; | 1003 | 39 | } | 1004 | | | 1005 | 107 | id6->contents[0] = ordinal & 0xff; | 1006 | 107 | id6->contents[1] = ordinal >> 8; | 1007 | | | 1008 | 107 | memcpy ((char *) id6->contents + 2, symbol, len); | 1009 | 107 | id6->contents[len + 2] = '\0'; | 1010 | 107 | } | 1011 | | | 1012 | 153 | if (import_name_type != IMPORT_ORDINAL) | 1013 | 107 | { | 1014 | 107 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1015 | 107 | pe_ILF_save_relocs (&vars, id4); | 1016 | | | 1017 | 107 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1018 | 107 | pe_ILF_save_relocs (&vars, id5); | 1019 | 107 | } | 1020 | | | 1021 | | /* Create an import symbol. */ | 1022 | 153 | pe_ILF_make_a_symbol (&vars, "__imp_", symbol_name, id5, 0); | 1023 | 153 | imp_sym = vars.sym_ptr_ptr - 1; | 1024 | 153 | imp_index = vars.sym_index - 1; | 1025 | | | 1026 | | /* Create extra sections depending upon the type of import we are | 1027 | | dealing with. */ | 1028 | 153 | switch (import_type) | 1029 | 153 | { | 1030 | 0 | int i; | 1031 | | | 1032 | 81 | case IMPORT_CODE: | 1033 | | /* CODE functions are special, in that they get a trampoline that | 1034 | | jumps to the main import symbol. Create a .text section to hold it. | 1035 | | First we need to look up its contents in the jump table. */ | 1036 | 162 | for (i = NUM_ENTRIES (jtab); i--;) | 1037 | 162 | { | 1038 | 162 | if (jtab[i].size == 0) | 1039 | 81 | continue; | 1040 | 81 | if (jtab[i].magic == magic) | 1041 | 81 | break; | 1042 | 81 | } | 1043 | | /* If we did not find a matching entry something is wrong. */ | 1044 | 81 | if (i < 0) | 1045 | 0 | abort (); | 1046 | | | 1047 | | /* Create the .text section. */ | 1048 | 81 | text = pe_ILF_make_a_section (&vars, ".text", jtab[i].size, SEC_CODE); | 1049 | 81 | if (text == NULL) | 1050 | 0 | goto error_return; | 1051 | | | 1052 | | /* Copy in the jump code. */ | 1053 | 81 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1054 | | | 1055 | | /* Create a reloc for the data in the text section. */ | 1056 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1057 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1058 | | { | 1059 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1060 | | (struct bfd_symbol **) imp_sym, | 1061 | | imp_index); | 1062 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1063 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1064 | | (struct bfd_symbol **) imp_sym, | 1065 | | imp_index); | 1066 | | } | 1067 | | else | 1068 | | #endif | 1069 | | #ifdef AMD64MAGIC | 1070 | | if (magic == AMD64MAGIC) | 1071 | | { | 1072 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1073 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1074 | | imp_index); | 1075 | | } | 1076 | | else | 1077 | | #endif | 1078 | 81 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1079 | 81 | BFD_RELOC_32, (asymbol **) imp_sym, | 1080 | 81 | imp_index); | 1081 | | | 1082 | 81 | pe_ILF_save_relocs (&vars, text); | 1083 | 81 | break; | 1084 | | | 1085 | 42 | case IMPORT_DATA: | 1086 | 72 | case IMPORT_CONST: | 1087 | 72 | break; | 1088 | | | 1089 | 0 | default: | 1090 | | /* XXX code not yet written. */ | 1091 | 0 | abort (); | 1092 | 153 | } | 1093 | | | 1094 | | /* Now create a symbol describing the imported value. */ | 1095 | 153 | switch (import_type) | 1096 | 153 | { | 1097 | 81 | case IMPORT_CODE: | 1098 | 81 | pe_ILF_make_a_symbol (&vars, "", symbol_name, text, | 1099 | 81 | BSF_NOT_AT_END | BSF_FUNCTION); | 1100 | | | 1101 | 81 | break; | 1102 | | | 1103 | 42 | case IMPORT_DATA: | 1104 | | /* Nothing to do here. */ | 1105 | 42 | break; | 1106 | | | 1107 | 30 | case IMPORT_CONST: | 1108 | 30 | pe_ILF_make_a_symbol (&vars, "", symbol_name, id5, 0); | 1109 | 30 | break; | 1110 | | | 1111 | 0 | default: | 1112 | | /* XXX code not yet written. */ | 1113 | 0 | abort (); | 1114 | 153 | } | 1115 | | | 1116 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1117 | 153 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1118 | 153 | if (ptr) | 1119 | 15 | *ptr = 0; | 1120 | 153 | pe_ILF_make_a_symbol (&vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1121 | 153 | if (ptr) | 1122 | 15 | *ptr = '.'; | 1123 | | | 1124 | | /* Initialise the bfd. */ | 1125 | 153 | memset (&internal_f, 0, sizeof (internal_f)); | 1126 | | | 1127 | 153 | internal_f.f_magic = magic; | 1128 | 153 | internal_f.f_symptr = 0; | 1129 | 153 | internal_f.f_nsyms = 0; | 1130 | 153 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1131 | | | 1132 | 153 | if (!bfd_set_start_address (abfd, (bfd_vma) 0) | 1133 | 153 | || !bfd_coff_set_arch_mach_hook (abfd, &internal_f)) | 1134 | 0 | goto error_return; | 1135 | | | 1136 | 153 | if (bfd_coff_mkobject_hook (abfd, (void *) &internal_f, NULL) == NULL) | 1137 | 0 | goto error_return; | 1138 | | | 1139 | 153 | obj_pe (abfd) = true; | 1140 | | #ifdef THUMBPEMAGIC | 1141 | | if (vars.magic == THUMBPEMAGIC) | 1142 | | /* Stop some linker warnings about thumb code not supporting | 1143 | | interworking. */ | 1144 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1145 | | #endif | 1146 | | | 1147 | | /* Switch from file contents to memory contents. */ | 1148 | 153 | bfd_cache_close (abfd); | 1149 | | | 1150 | 153 | abfd->iostream = (void *) vars.bim; | 1151 | 153 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1152 | 153 | abfd->iovec = &_bfd_memory_iovec; | 1153 | 153 | abfd->where = 0; | 1154 | 153 | abfd->origin = 0; | 1155 | 153 | abfd->size = 0; | 1156 | 153 | obj_sym_filepos (abfd) = 0; | 1157 | | | 1158 | | /* Point the bfd at the symbol table. */ | 1159 | 153 | obj_symbols (abfd) = vars.sym_cache; | 1160 | 153 | abfd->symcount = vars.sym_index; | 1161 | | | 1162 | 153 | obj_raw_syments (abfd) = vars.native_syms; | 1163 | 153 | obj_raw_syment_count (abfd) = vars.sym_index; | 1164 | 153 | obj_coff_keep_raw_syms (abfd) = true; | 1165 | | | 1166 | 153 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1167 | 153 | obj_coff_keep_syms (abfd) = true; | 1168 | | | 1169 | 153 | obj_convert (abfd) = vars.sym_table; | 1170 | 153 | obj_conv_table_size (abfd) = vars.sym_index; | 1171 | | | 1172 | 153 | obj_coff_strings (abfd) = vars.string_table; | 1173 | 153 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1174 | 153 | obj_coff_keep_strings (abfd) = true; | 1175 | | | 1176 | 153 | return true; | 1177 | | | 1178 | 9 | error_return: | 1179 | 9 | free (vars.bim->buffer); | 1180 | 9 | free (vars.bim); | 1181 | | return false; | 1182 | 153 | } |
pei-x86_64.c:pe_ILF_build_a_bfd Line | Count | Source | 805 | 161 | { | 806 | 161 | bfd_byte * ptr; | 807 | 161 | pe_ILF_vars vars; | 808 | 161 | struct internal_filehdr internal_f; | 809 | 161 | unsigned int import_type; | 810 | 161 | unsigned int import_name_type; | 811 | 161 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 812 | 161 | coff_symbol_type ** imp_sym; | 813 | 161 | unsigned int imp_index; | 814 | 161 | intptr_t alignment; | 815 | | | 816 | | /* Decode and verify the types field of the ILF structure. */ | 817 | 161 | import_type = types & 0x3; | 818 | 161 | import_name_type = (types & 0x1c) >> 2; | 819 | | | 820 | 161 | switch (import_type) | 821 | 161 | { | 822 | 53 | case IMPORT_CODE: | 823 | 92 | case IMPORT_DATA: | 824 | 152 | case IMPORT_CONST: | 825 | 152 | break; | 826 | | | 827 | 9 | default: | 828 | | /* xgettext:c-format */ | 829 | 9 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 830 | 9 | abfd, import_type); | 831 | 9 | return false; | 832 | 161 | } | 833 | | | 834 | 152 | switch (import_name_type) | 835 | 152 | { | 836 | 38 | case IMPORT_ORDINAL: | 837 | 48 | case IMPORT_NAME: | 838 | 72 | case IMPORT_NAME_NOPREFIX: | 839 | 115 | case IMPORT_NAME_UNDECORATE: | 840 | 115 | import_name = symbol_name; | 841 | 115 | break; | 842 | | | 843 | 28 | case IMPORT_NAME_EXPORTAS: | 844 | 28 | if (!import_name || !import_name[0]) | 845 | 18 | { | 846 | 18 | _bfd_error_handler (_("%pB: missing import name for " | 847 | 18 | "IMPORT_NAME_EXPORTAS for %s"), | 848 | 18 | abfd, symbol_name); | 849 | 18 | return false; | 850 | 18 | } | 851 | 10 | break; | 852 | | | 853 | 10 | default: | 854 | | /* xgettext:c-format */ | 855 | 9 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 856 | 9 | abfd, import_name_type); | 857 | 9 | return false; | 858 | 152 | } | 859 | | | 860 | | /* Initialise local variables. | 861 | | | 862 | | Note these are kept in a structure rather than being | 863 | | declared as statics since bfd frowns on global variables. | 864 | | | 865 | | We are going to construct the contents of the BFD in memory, | 866 | | so allocate all the space that we will need right now. */ | 867 | 125 | vars.bim | 868 | 125 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 869 | 125 | if (vars.bim == NULL) | 870 | 0 | return false; | 871 | | | 872 | 125 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 873 | 125 | vars.bim->buffer = ptr; | 874 | 125 | vars.bim->size = ILF_DATA_SIZE; | 875 | 125 | vars.bim->capacity = ILF_DATA_SIZE; | 876 | 125 | if (ptr == NULL) | 877 | 0 | goto error_return; | 878 | | | 879 | | /* Initialise the pointers to regions of the memory and the | 880 | | other contents of the pe_ILF_vars structure as well. */ | 881 | 125 | vars.sym_cache = (coff_symbol_type *) ptr; | 882 | 125 | vars.sym_ptr = (coff_symbol_type *) ptr; | 883 | 125 | vars.sym_index = 0; | 884 | 125 | ptr += SIZEOF_ILF_SYMS; | 885 | | | 886 | 125 | vars.sym_table = (unsigned int *) ptr; | 887 | 125 | vars.table_ptr = (unsigned int *) ptr; | 888 | 125 | ptr += SIZEOF_ILF_SYM_TABLE; | 889 | | | 890 | 125 | vars.native_syms = (combined_entry_type *) ptr; | 891 | 125 | vars.native_ptr = (combined_entry_type *) ptr; | 892 | 125 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 893 | | | 894 | 125 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 895 | 125 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 896 | 125 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 897 | | | 898 | 125 | vars.esym_table = (SYMENT *) ptr; | 899 | 125 | vars.esym_ptr = (SYMENT *) ptr; | 900 | 125 | ptr += SIZEOF_ILF_EXT_SYMS; | 901 | | | 902 | 125 | vars.reltab = (arelent *) ptr; | 903 | 125 | vars.relcount = 0; | 904 | 125 | ptr += SIZEOF_ILF_RELOCS; | 905 | | | 906 | 125 | vars.int_reltab = (struct internal_reloc *) ptr; | 907 | 125 | ptr += SIZEOF_ILF_INT_RELOCS; | 908 | | | 909 | 125 | vars.string_table = (char *) ptr; | 910 | 125 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 911 | 125 | ptr += SIZEOF_ILF_STRINGS; | 912 | 125 | vars.end_string_ptr = (char *) ptr; | 913 | | | 914 | | /* The remaining space in bim->buffer is used | 915 | | by the pe_ILF_make_a_section() function. */ | 916 | | | 917 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 918 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 919 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 920 | | alignment. */ | 921 | 125 | #if GCC_VERSION >= 3000 | 922 | 125 | alignment = __alignof__ (struct coff_section_tdata); | 923 | | #else | 924 | | alignment = 8; | 925 | | #endif | 926 | 125 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 927 | | | 928 | 125 | vars.data = ptr; | 929 | 125 | vars.abfd = abfd; | 930 | 125 | vars.sec_index = 0; | 931 | 125 | vars.magic = magic; | 932 | | | 933 | | /* Create the initial .idata$<n> sections: | 934 | | [.idata$2: Import Directory Table -- not needed] | 935 | | .idata$4: Import Lookup Table | 936 | | .idata$5: Import Address Table | 937 | | | 938 | | Note we do not create a .idata$3 section as this is | 939 | | created for us by the linker script. */ | 940 | 125 | id4 = pe_ILF_make_a_section (&vars, ".idata$4", SIZEOF_IDATA4, 0); | 941 | 125 | id5 = pe_ILF_make_a_section (&vars, ".idata$5", SIZEOF_IDATA5, 0); | 942 | 125 | if (id4 == NULL || id5 == NULL) | 943 | 0 | goto error_return; | 944 | | | 945 | | /* Fill in the contents of these sections. */ | 946 | 125 | if (import_name_type == IMPORT_ORDINAL) | 947 | 38 | { | 948 | 38 | if (ordinal == 0) | 949 | | /* See PR 20907 for a reproducer. */ | 950 | 9 | goto error_return; | 951 | | | 952 | 29 | #if (defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) \ | 953 | 29 | || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64)) | 954 | 29 | ((unsigned int *) id4->contents)[0] = ordinal; | 955 | 29 | ((unsigned int *) id4->contents)[1] = 0x80000000; | 956 | 29 | ((unsigned int *) id5->contents)[0] = ordinal; | 957 | 29 | ((unsigned int *) id5->contents)[1] = 0x80000000; | 958 | | #else | 959 | | ((unsigned int *) id4->contents)[0] = ordinal | 0x80000000; | 960 | | ((unsigned int *) id5->contents)[0] = ordinal | 0x80000000; | 961 | | #endif | 962 | 29 | } | 963 | 87 | else | 964 | 87 | { | 965 | 87 | char *symbol; | 966 | 87 | unsigned int len; | 967 | | | 968 | | /* Create .idata$6 - the Hint Name Table. */ | 969 | 87 | id6 = pe_ILF_make_a_section (&vars, ".idata$6", SIZEOF_IDATA6, 0); | 970 | 87 | if (id6 == NULL) | 971 | 0 | goto error_return; | 972 | | | 973 | | /* If necessary, trim the import symbol name. */ | 974 | 87 | symbol = import_name; | 975 | | | 976 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 977 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 978 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 979 | | of these is used for a symbol. We strip this leading char for | 980 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 981 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 982 | | | 983 | 87 | if (import_name_type != IMPORT_NAME | 984 | 77 | && import_name_type != IMPORT_NAME_EXPORTAS) | 985 | 67 | { | 986 | 67 | char c = symbol[0]; | 987 | | | 988 | | /* Check that we don't remove for targets with empty | 989 | | USER_LABEL_PREFIX the leading underscore. */ | 990 | 67 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 991 | 67 | || c == '@' || c == '?') | 992 | 20 | symbol++; | 993 | 67 | } | 994 | | | 995 | 87 | len = strlen (symbol); | 996 | 87 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 997 | 43 | { | 998 | | /* Truncate at the first '@'. */ | 999 | 43 | char *at = strchr (symbol, '@'); | 1000 | | | 1001 | 43 | if (at != NULL) | 1002 | 15 | len = at - symbol; | 1003 | 43 | } | 1004 | | | 1005 | 87 | id6->contents[0] = ordinal & 0xff; | 1006 | 87 | id6->contents[1] = ordinal >> 8; | 1007 | | | 1008 | 87 | memcpy ((char *) id6->contents + 2, symbol, len); | 1009 | 87 | id6->contents[len + 2] = '\0'; | 1010 | 87 | } | 1011 | | | 1012 | 116 | if (import_name_type != IMPORT_ORDINAL) | 1013 | 87 | { | 1014 | 87 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1015 | 87 | pe_ILF_save_relocs (&vars, id4); | 1016 | | | 1017 | 87 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1018 | 87 | pe_ILF_save_relocs (&vars, id5); | 1019 | 87 | } | 1020 | | | 1021 | | /* Create an import symbol. */ | 1022 | 116 | pe_ILF_make_a_symbol (&vars, "__imp_", symbol_name, id5, 0); | 1023 | 116 | imp_sym = vars.sym_ptr_ptr - 1; | 1024 | 116 | imp_index = vars.sym_index - 1; | 1025 | | | 1026 | | /* Create extra sections depending upon the type of import we are | 1027 | | dealing with. */ | 1028 | 116 | switch (import_type) | 1029 | 116 | { | 1030 | 0 | int i; | 1031 | | | 1032 | 40 | case IMPORT_CODE: | 1033 | | /* CODE functions are special, in that they get a trampoline that | 1034 | | jumps to the main import symbol. Create a .text section to hold it. | 1035 | | First we need to look up its contents in the jump table. */ | 1036 | 80 | for (i = NUM_ENTRIES (jtab); i--;) | 1037 | 80 | { | 1038 | 80 | if (jtab[i].size == 0) | 1039 | 40 | continue; | 1040 | 40 | if (jtab[i].magic == magic) | 1041 | 40 | break; | 1042 | 40 | } | 1043 | | /* If we did not find a matching entry something is wrong. */ | 1044 | 40 | if (i < 0) | 1045 | 0 | abort (); | 1046 | | | 1047 | | /* Create the .text section. */ | 1048 | 40 | text = pe_ILF_make_a_section (&vars, ".text", jtab[i].size, SEC_CODE); | 1049 | 40 | if (text == NULL) | 1050 | 0 | goto error_return; | 1051 | | | 1052 | | /* Copy in the jump code. */ | 1053 | 40 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1054 | | | 1055 | | /* Create a reloc for the data in the text section. */ | 1056 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1057 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1058 | | { | 1059 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1060 | | (struct bfd_symbol **) imp_sym, | 1061 | | imp_index); | 1062 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1063 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1064 | | (struct bfd_symbol **) imp_sym, | 1065 | | imp_index); | 1066 | | } | 1067 | | else | 1068 | | #endif | 1069 | 40 | #ifdef AMD64MAGIC | 1070 | 40 | if (magic == AMD64MAGIC) | 1071 | 40 | { | 1072 | 40 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1073 | 40 | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1074 | 40 | imp_index); | 1075 | 40 | } | 1076 | 0 | else | 1077 | 0 | #endif | 1078 | 0 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1079 | 0 | BFD_RELOC_32, (asymbol **) imp_sym, | 1080 | 0 | imp_index); | 1081 | | | 1082 | 40 | pe_ILF_save_relocs (&vars, text); | 1083 | 40 | break; | 1084 | | | 1085 | 31 | case IMPORT_DATA: | 1086 | 76 | case IMPORT_CONST: | 1087 | 76 | break; | 1088 | | | 1089 | 0 | default: | 1090 | | /* XXX code not yet written. */ | 1091 | 0 | abort (); | 1092 | 116 | } | 1093 | | | 1094 | | /* Now create a symbol describing the imported value. */ | 1095 | 116 | switch (import_type) | 1096 | 116 | { | 1097 | 40 | case IMPORT_CODE: | 1098 | 40 | pe_ILF_make_a_symbol (&vars, "", symbol_name, text, | 1099 | 40 | BSF_NOT_AT_END | BSF_FUNCTION); | 1100 | | | 1101 | 40 | break; | 1102 | | | 1103 | 31 | case IMPORT_DATA: | 1104 | | /* Nothing to do here. */ | 1105 | 31 | break; | 1106 | | | 1107 | 45 | case IMPORT_CONST: | 1108 | 45 | pe_ILF_make_a_symbol (&vars, "", symbol_name, id5, 0); | 1109 | 45 | break; | 1110 | | | 1111 | 0 | default: | 1112 | | /* XXX code not yet written. */ | 1113 | 0 | abort (); | 1114 | 116 | } | 1115 | | | 1116 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1117 | 116 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1118 | 116 | if (ptr) | 1119 | 14 | *ptr = 0; | 1120 | 116 | pe_ILF_make_a_symbol (&vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1121 | 116 | if (ptr) | 1122 | 14 | *ptr = '.'; | 1123 | | | 1124 | | /* Initialise the bfd. */ | 1125 | 116 | memset (&internal_f, 0, sizeof (internal_f)); | 1126 | | | 1127 | 116 | internal_f.f_magic = magic; | 1128 | 116 | internal_f.f_symptr = 0; | 1129 | 116 | internal_f.f_nsyms = 0; | 1130 | 116 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1131 | | | 1132 | 116 | if (!bfd_set_start_address (abfd, (bfd_vma) 0) | 1133 | 116 | || !bfd_coff_set_arch_mach_hook (abfd, &internal_f)) | 1134 | 0 | goto error_return; | 1135 | | | 1136 | 116 | if (bfd_coff_mkobject_hook (abfd, (void *) &internal_f, NULL) == NULL) | 1137 | 0 | goto error_return; | 1138 | | | 1139 | 116 | obj_pe (abfd) = true; | 1140 | | #ifdef THUMBPEMAGIC | 1141 | | if (vars.magic == THUMBPEMAGIC) | 1142 | | /* Stop some linker warnings about thumb code not supporting | 1143 | | interworking. */ | 1144 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1145 | | #endif | 1146 | | | 1147 | | /* Switch from file contents to memory contents. */ | 1148 | 116 | bfd_cache_close (abfd); | 1149 | | | 1150 | 116 | abfd->iostream = (void *) vars.bim; | 1151 | 116 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1152 | 116 | abfd->iovec = &_bfd_memory_iovec; | 1153 | 116 | abfd->where = 0; | 1154 | 116 | abfd->origin = 0; | 1155 | 116 | abfd->size = 0; | 1156 | 116 | obj_sym_filepos (abfd) = 0; | 1157 | | | 1158 | | /* Point the bfd at the symbol table. */ | 1159 | 116 | obj_symbols (abfd) = vars.sym_cache; | 1160 | 116 | abfd->symcount = vars.sym_index; | 1161 | | | 1162 | 116 | obj_raw_syments (abfd) = vars.native_syms; | 1163 | 116 | obj_raw_syment_count (abfd) = vars.sym_index; | 1164 | 116 | obj_coff_keep_raw_syms (abfd) = true; | 1165 | | | 1166 | 116 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1167 | 116 | obj_coff_keep_syms (abfd) = true; | 1168 | | | 1169 | 116 | obj_convert (abfd) = vars.sym_table; | 1170 | 116 | obj_conv_table_size (abfd) = vars.sym_index; | 1171 | | | 1172 | 116 | obj_coff_strings (abfd) = vars.string_table; | 1173 | 116 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1174 | 116 | obj_coff_keep_strings (abfd) = true; | 1175 | | | 1176 | 116 | return true; | 1177 | | | 1178 | 9 | error_return: | 1179 | 9 | free (vars.bim->buffer); | 1180 | 9 | free (vars.bim); | 1181 | | return false; | 1182 | 116 | } |
pei-aarch64.c:pe_ILF_build_a_bfd Line | Count | Source | 805 | 168 | { | 806 | 168 | bfd_byte * ptr; | 807 | 168 | pe_ILF_vars vars; | 808 | 168 | struct internal_filehdr internal_f; | 809 | 168 | unsigned int import_type; | 810 | 168 | unsigned int import_name_type; | 811 | 168 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 812 | 168 | coff_symbol_type ** imp_sym; | 813 | 168 | unsigned int imp_index; | 814 | 168 | intptr_t alignment; | 815 | | | 816 | | /* Decode and verify the types field of the ILF structure. */ | 817 | 168 | import_type = types & 0x3; | 818 | 168 | import_name_type = (types & 0x1c) >> 2; | 819 | | | 820 | 168 | switch (import_type) | 821 | 168 | { | 822 | 70 | case IMPORT_CODE: | 823 | 126 | case IMPORT_DATA: | 824 | 159 | case IMPORT_CONST: | 825 | 159 | break; | 826 | | | 827 | 9 | default: | 828 | | /* xgettext:c-format */ | 829 | 9 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 830 | 9 | abfd, import_type); | 831 | 9 | return false; | 832 | 168 | } | 833 | | | 834 | 159 | switch (import_name_type) | 835 | 159 | { | 836 | 43 | case IMPORT_ORDINAL: | 837 | 60 | case IMPORT_NAME: | 838 | 85 | case IMPORT_NAME_NOPREFIX: | 839 | 120 | case IMPORT_NAME_UNDECORATE: | 840 | 120 | import_name = symbol_name; | 841 | 120 | break; | 842 | | | 843 | 30 | case IMPORT_NAME_EXPORTAS: | 844 | 30 | if (!import_name || !import_name[0]) | 845 | 17 | { | 846 | 17 | _bfd_error_handler (_("%pB: missing import name for " | 847 | 17 | "IMPORT_NAME_EXPORTAS for %s"), | 848 | 17 | abfd, symbol_name); | 849 | 17 | return false; | 850 | 17 | } | 851 | 13 | break; | 852 | | | 853 | 13 | default: | 854 | | /* xgettext:c-format */ | 855 | 9 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 856 | 9 | abfd, import_name_type); | 857 | 9 | return false; | 858 | 159 | } | 859 | | | 860 | | /* Initialise local variables. | 861 | | | 862 | | Note these are kept in a structure rather than being | 863 | | declared as statics since bfd frowns on global variables. | 864 | | | 865 | | We are going to construct the contents of the BFD in memory, | 866 | | so allocate all the space that we will need right now. */ | 867 | 133 | vars.bim | 868 | 133 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 869 | 133 | if (vars.bim == NULL) | 870 | 0 | return false; | 871 | | | 872 | 133 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 873 | 133 | vars.bim->buffer = ptr; | 874 | 133 | vars.bim->size = ILF_DATA_SIZE; | 875 | 133 | vars.bim->capacity = ILF_DATA_SIZE; | 876 | 133 | if (ptr == NULL) | 877 | 0 | goto error_return; | 878 | | | 879 | | /* Initialise the pointers to regions of the memory and the | 880 | | other contents of the pe_ILF_vars structure as well. */ | 881 | 133 | vars.sym_cache = (coff_symbol_type *) ptr; | 882 | 133 | vars.sym_ptr = (coff_symbol_type *) ptr; | 883 | 133 | vars.sym_index = 0; | 884 | 133 | ptr += SIZEOF_ILF_SYMS; | 885 | | | 886 | 133 | vars.sym_table = (unsigned int *) ptr; | 887 | 133 | vars.table_ptr = (unsigned int *) ptr; | 888 | 133 | ptr += SIZEOF_ILF_SYM_TABLE; | 889 | | | 890 | 133 | vars.native_syms = (combined_entry_type *) ptr; | 891 | 133 | vars.native_ptr = (combined_entry_type *) ptr; | 892 | 133 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 893 | | | 894 | 133 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 895 | 133 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 896 | 133 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 897 | | | 898 | 133 | vars.esym_table = (SYMENT *) ptr; | 899 | 133 | vars.esym_ptr = (SYMENT *) ptr; | 900 | 133 | ptr += SIZEOF_ILF_EXT_SYMS; | 901 | | | 902 | 133 | vars.reltab = (arelent *) ptr; | 903 | 133 | vars.relcount = 0; | 904 | 133 | ptr += SIZEOF_ILF_RELOCS; | 905 | | | 906 | 133 | vars.int_reltab = (struct internal_reloc *) ptr; | 907 | 133 | ptr += SIZEOF_ILF_INT_RELOCS; | 908 | | | 909 | 133 | vars.string_table = (char *) ptr; | 910 | 133 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 911 | 133 | ptr += SIZEOF_ILF_STRINGS; | 912 | 133 | vars.end_string_ptr = (char *) ptr; | 913 | | | 914 | | /* The remaining space in bim->buffer is used | 915 | | by the pe_ILF_make_a_section() function. */ | 916 | | | 917 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 918 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 919 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 920 | | alignment. */ | 921 | 133 | #if GCC_VERSION >= 3000 | 922 | 133 | alignment = __alignof__ (struct coff_section_tdata); | 923 | | #else | 924 | | alignment = 8; | 925 | | #endif | 926 | 133 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 927 | | | 928 | 133 | vars.data = ptr; | 929 | 133 | vars.abfd = abfd; | 930 | 133 | vars.sec_index = 0; | 931 | 133 | vars.magic = magic; | 932 | | | 933 | | /* Create the initial .idata$<n> sections: | 934 | | [.idata$2: Import Directory Table -- not needed] | 935 | | .idata$4: Import Lookup Table | 936 | | .idata$5: Import Address Table | 937 | | | 938 | | Note we do not create a .idata$3 section as this is | 939 | | created for us by the linker script. */ | 940 | 133 | id4 = pe_ILF_make_a_section (&vars, ".idata$4", SIZEOF_IDATA4, 0); | 941 | 133 | id5 = pe_ILF_make_a_section (&vars, ".idata$5", SIZEOF_IDATA5, 0); | 942 | 133 | if (id4 == NULL || id5 == NULL) | 943 | 0 | goto error_return; | 944 | | | 945 | | /* Fill in the contents of these sections. */ | 946 | 133 | if (import_name_type == IMPORT_ORDINAL) | 947 | 43 | { | 948 | 43 | if (ordinal == 0) | 949 | | /* See PR 20907 for a reproducer. */ | 950 | 10 | goto error_return; | 951 | | | 952 | 33 | #if (defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) \ | 953 | 33 | || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64)) | 954 | 33 | ((unsigned int *) id4->contents)[0] = ordinal; | 955 | 33 | ((unsigned int *) id4->contents)[1] = 0x80000000; | 956 | 33 | ((unsigned int *) id5->contents)[0] = ordinal; | 957 | 33 | ((unsigned int *) id5->contents)[1] = 0x80000000; | 958 | | #else | 959 | | ((unsigned int *) id4->contents)[0] = ordinal | 0x80000000; | 960 | | ((unsigned int *) id5->contents)[0] = ordinal | 0x80000000; | 961 | | #endif | 962 | 33 | } | 963 | 90 | else | 964 | 90 | { | 965 | 90 | char *symbol; | 966 | 90 | unsigned int len; | 967 | | | 968 | | /* Create .idata$6 - the Hint Name Table. */ | 969 | 90 | id6 = pe_ILF_make_a_section (&vars, ".idata$6", SIZEOF_IDATA6, 0); | 970 | 90 | if (id6 == NULL) | 971 | 0 | goto error_return; | 972 | | | 973 | | /* If necessary, trim the import symbol name. */ | 974 | 90 | symbol = import_name; | 975 | | | 976 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 977 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 978 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 979 | | of these is used for a symbol. We strip this leading char for | 980 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 981 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 982 | | | 983 | 90 | if (import_name_type != IMPORT_NAME | 984 | 73 | && import_name_type != IMPORT_NAME_EXPORTAS) | 985 | 60 | { | 986 | 60 | char c = symbol[0]; | 987 | | | 988 | | /* Check that we don't remove for targets with empty | 989 | | USER_LABEL_PREFIX the leading underscore. */ | 990 | 60 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 991 | 60 | || c == '@' || c == '?') | 992 | 18 | symbol++; | 993 | 60 | } | 994 | | | 995 | 90 | len = strlen (symbol); | 996 | 90 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 997 | 35 | { | 998 | | /* Truncate at the first '@'. */ | 999 | 35 | char *at = strchr (symbol, '@'); | 1000 | | | 1001 | 35 | if (at != NULL) | 1002 | 6 | len = at - symbol; | 1003 | 35 | } | 1004 | | | 1005 | 90 | id6->contents[0] = ordinal & 0xff; | 1006 | 90 | id6->contents[1] = ordinal >> 8; | 1007 | | | 1008 | 90 | memcpy ((char *) id6->contents + 2, symbol, len); | 1009 | 90 | id6->contents[len + 2] = '\0'; | 1010 | 90 | } | 1011 | | | 1012 | 123 | if (import_name_type != IMPORT_ORDINAL) | 1013 | 90 | { | 1014 | 90 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1015 | 90 | pe_ILF_save_relocs (&vars, id4); | 1016 | | | 1017 | 90 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1018 | 90 | pe_ILF_save_relocs (&vars, id5); | 1019 | 90 | } | 1020 | | | 1021 | | /* Create an import symbol. */ | 1022 | 123 | pe_ILF_make_a_symbol (&vars, "__imp_", symbol_name, id5, 0); | 1023 | 123 | imp_sym = vars.sym_ptr_ptr - 1; | 1024 | 123 | imp_index = vars.sym_index - 1; | 1025 | | | 1026 | | /* Create extra sections depending upon the type of import we are | 1027 | | dealing with. */ | 1028 | 123 | switch (import_type) | 1029 | 123 | { | 1030 | 0 | int i; | 1031 | | | 1032 | 56 | case IMPORT_CODE: | 1033 | | /* CODE functions are special, in that they get a trampoline that | 1034 | | jumps to the main import symbol. Create a .text section to hold it. | 1035 | | First we need to look up its contents in the jump table. */ | 1036 | 112 | for (i = NUM_ENTRIES (jtab); i--;) | 1037 | 112 | { | 1038 | 112 | if (jtab[i].size == 0) | 1039 | 56 | continue; | 1040 | 56 | if (jtab[i].magic == magic) | 1041 | 56 | break; | 1042 | 56 | } | 1043 | | /* If we did not find a matching entry something is wrong. */ | 1044 | 56 | if (i < 0) | 1045 | 0 | abort (); | 1046 | | | 1047 | | /* Create the .text section. */ | 1048 | 56 | text = pe_ILF_make_a_section (&vars, ".text", jtab[i].size, SEC_CODE); | 1049 | 56 | if (text == NULL) | 1050 | 0 | goto error_return; | 1051 | | | 1052 | | /* Copy in the jump code. */ | 1053 | 56 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1054 | | | 1055 | | /* Create a reloc for the data in the text section. */ | 1056 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1057 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1058 | | { | 1059 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1060 | | (struct bfd_symbol **) imp_sym, | 1061 | | imp_index); | 1062 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1063 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1064 | | (struct bfd_symbol **) imp_sym, | 1065 | | imp_index); | 1066 | | } | 1067 | | else | 1068 | | #endif | 1069 | | #ifdef AMD64MAGIC | 1070 | | if (magic == AMD64MAGIC) | 1071 | | { | 1072 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1073 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1074 | | imp_index); | 1075 | | } | 1076 | | else | 1077 | | #endif | 1078 | 56 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1079 | 56 | BFD_RELOC_32, (asymbol **) imp_sym, | 1080 | 56 | imp_index); | 1081 | | | 1082 | 56 | pe_ILF_save_relocs (&vars, text); | 1083 | 56 | break; | 1084 | | | 1085 | 41 | case IMPORT_DATA: | 1086 | 67 | case IMPORT_CONST: | 1087 | 67 | break; | 1088 | | | 1089 | 0 | default: | 1090 | | /* XXX code not yet written. */ | 1091 | 0 | abort (); | 1092 | 123 | } | 1093 | | | 1094 | | /* Now create a symbol describing the imported value. */ | 1095 | 123 | switch (import_type) | 1096 | 123 | { | 1097 | 56 | case IMPORT_CODE: | 1098 | 56 | pe_ILF_make_a_symbol (&vars, "", symbol_name, text, | 1099 | 56 | BSF_NOT_AT_END | BSF_FUNCTION); | 1100 | | | 1101 | 56 | break; | 1102 | | | 1103 | 41 | case IMPORT_DATA: | 1104 | | /* Nothing to do here. */ | 1105 | 41 | break; | 1106 | | | 1107 | 26 | case IMPORT_CONST: | 1108 | 26 | pe_ILF_make_a_symbol (&vars, "", symbol_name, id5, 0); | 1109 | 26 | break; | 1110 | | | 1111 | 0 | default: | 1112 | | /* XXX code not yet written. */ | 1113 | 0 | abort (); | 1114 | 123 | } | 1115 | | | 1116 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1117 | 123 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1118 | 123 | if (ptr) | 1119 | 31 | *ptr = 0; | 1120 | 123 | pe_ILF_make_a_symbol (&vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1121 | 123 | if (ptr) | 1122 | 31 | *ptr = '.'; | 1123 | | | 1124 | | /* Initialise the bfd. */ | 1125 | 123 | memset (&internal_f, 0, sizeof (internal_f)); | 1126 | | | 1127 | 123 | internal_f.f_magic = magic; | 1128 | 123 | internal_f.f_symptr = 0; | 1129 | 123 | internal_f.f_nsyms = 0; | 1130 | 123 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1131 | | | 1132 | 123 | if (!bfd_set_start_address (abfd, (bfd_vma) 0) | 1133 | 123 | || !bfd_coff_set_arch_mach_hook (abfd, &internal_f)) | 1134 | 0 | goto error_return; | 1135 | | | 1136 | 123 | if (bfd_coff_mkobject_hook (abfd, (void *) &internal_f, NULL) == NULL) | 1137 | 0 | goto error_return; | 1138 | | | 1139 | 123 | obj_pe (abfd) = true; | 1140 | | #ifdef THUMBPEMAGIC | 1141 | | if (vars.magic == THUMBPEMAGIC) | 1142 | | /* Stop some linker warnings about thumb code not supporting | 1143 | | interworking. */ | 1144 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1145 | | #endif | 1146 | | | 1147 | | /* Switch from file contents to memory contents. */ | 1148 | 123 | bfd_cache_close (abfd); | 1149 | | | 1150 | 123 | abfd->iostream = (void *) vars.bim; | 1151 | 123 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1152 | 123 | abfd->iovec = &_bfd_memory_iovec; | 1153 | 123 | abfd->where = 0; | 1154 | 123 | abfd->origin = 0; | 1155 | 123 | abfd->size = 0; | 1156 | 123 | obj_sym_filepos (abfd) = 0; | 1157 | | | 1158 | | /* Point the bfd at the symbol table. */ | 1159 | 123 | obj_symbols (abfd) = vars.sym_cache; | 1160 | 123 | abfd->symcount = vars.sym_index; | 1161 | | | 1162 | 123 | obj_raw_syments (abfd) = vars.native_syms; | 1163 | 123 | obj_raw_syment_count (abfd) = vars.sym_index; | 1164 | 123 | obj_coff_keep_raw_syms (abfd) = true; | 1165 | | | 1166 | 123 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1167 | 123 | obj_coff_keep_syms (abfd) = true; | 1168 | | | 1169 | 123 | obj_convert (abfd) = vars.sym_table; | 1170 | 123 | obj_conv_table_size (abfd) = vars.sym_index; | 1171 | | | 1172 | 123 | obj_coff_strings (abfd) = vars.string_table; | 1173 | 123 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1174 | 123 | obj_coff_keep_strings (abfd) = true; | 1175 | | | 1176 | 123 | return true; | 1177 | | | 1178 | 10 | error_return: | 1179 | 10 | free (vars.bim->buffer); | 1180 | 10 | free (vars.bim); | 1181 | | return false; | 1182 | 123 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_build_a_bfd pei-loongarch64.c:pe_ILF_build_a_bfd Line | Count | Source | 805 | 168 | { | 806 | 168 | bfd_byte * ptr; | 807 | 168 | pe_ILF_vars vars; | 808 | 168 | struct internal_filehdr internal_f; | 809 | 168 | unsigned int import_type; | 810 | 168 | unsigned int import_name_type; | 811 | 168 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 812 | 168 | coff_symbol_type ** imp_sym; | 813 | 168 | unsigned int imp_index; | 814 | 168 | intptr_t alignment; | 815 | | | 816 | | /* Decode and verify the types field of the ILF structure. */ | 817 | 168 | import_type = types & 0x3; | 818 | 168 | import_name_type = (types & 0x1c) >> 2; | 819 | | | 820 | 168 | switch (import_type) | 821 | 168 | { | 822 | 73 | case IMPORT_CODE: | 823 | 133 | case IMPORT_DATA: | 824 | 159 | case IMPORT_CONST: | 825 | 159 | break; | 826 | | | 827 | 9 | default: | 828 | | /* xgettext:c-format */ | 829 | 9 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 830 | 9 | abfd, import_type); | 831 | 9 | return false; | 832 | 168 | } | 833 | | | 834 | 159 | switch (import_name_type) | 835 | 159 | { | 836 | 44 | case IMPORT_ORDINAL: | 837 | 61 | case IMPORT_NAME: | 838 | 75 | case IMPORT_NAME_NOPREFIX: | 839 | 119 | case IMPORT_NAME_UNDECORATE: | 840 | 119 | import_name = symbol_name; | 841 | 119 | break; | 842 | | | 843 | 31 | case IMPORT_NAME_EXPORTAS: | 844 | 31 | if (!import_name || !import_name[0]) | 845 | 18 | { | 846 | 18 | _bfd_error_handler (_("%pB: missing import name for " | 847 | 18 | "IMPORT_NAME_EXPORTAS for %s"), | 848 | 18 | abfd, symbol_name); | 849 | 18 | return false; | 850 | 18 | } | 851 | 13 | break; | 852 | | | 853 | 13 | default: | 854 | | /* xgettext:c-format */ | 855 | 9 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 856 | 9 | abfd, import_name_type); | 857 | 9 | return false; | 858 | 159 | } | 859 | | | 860 | | /* Initialise local variables. | 861 | | | 862 | | Note these are kept in a structure rather than being | 863 | | declared as statics since bfd frowns on global variables. | 864 | | | 865 | | We are going to construct the contents of the BFD in memory, | 866 | | so allocate all the space that we will need right now. */ | 867 | 132 | vars.bim | 868 | 132 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 869 | 132 | if (vars.bim == NULL) | 870 | 0 | return false; | 871 | | | 872 | 132 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 873 | 132 | vars.bim->buffer = ptr; | 874 | 132 | vars.bim->size = ILF_DATA_SIZE; | 875 | 132 | vars.bim->capacity = ILF_DATA_SIZE; | 876 | 132 | if (ptr == NULL) | 877 | 0 | goto error_return; | 878 | | | 879 | | /* Initialise the pointers to regions of the memory and the | 880 | | other contents of the pe_ILF_vars structure as well. */ | 881 | 132 | vars.sym_cache = (coff_symbol_type *) ptr; | 882 | 132 | vars.sym_ptr = (coff_symbol_type *) ptr; | 883 | 132 | vars.sym_index = 0; | 884 | 132 | ptr += SIZEOF_ILF_SYMS; | 885 | | | 886 | 132 | vars.sym_table = (unsigned int *) ptr; | 887 | 132 | vars.table_ptr = (unsigned int *) ptr; | 888 | 132 | ptr += SIZEOF_ILF_SYM_TABLE; | 889 | | | 890 | 132 | vars.native_syms = (combined_entry_type *) ptr; | 891 | 132 | vars.native_ptr = (combined_entry_type *) ptr; | 892 | 132 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 893 | | | 894 | 132 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 895 | 132 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 896 | 132 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 897 | | | 898 | 132 | vars.esym_table = (SYMENT *) ptr; | 899 | 132 | vars.esym_ptr = (SYMENT *) ptr; | 900 | 132 | ptr += SIZEOF_ILF_EXT_SYMS; | 901 | | | 902 | 132 | vars.reltab = (arelent *) ptr; | 903 | 132 | vars.relcount = 0; | 904 | 132 | ptr += SIZEOF_ILF_RELOCS; | 905 | | | 906 | 132 | vars.int_reltab = (struct internal_reloc *) ptr; | 907 | 132 | ptr += SIZEOF_ILF_INT_RELOCS; | 908 | | | 909 | 132 | vars.string_table = (char *) ptr; | 910 | 132 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 911 | 132 | ptr += SIZEOF_ILF_STRINGS; | 912 | 132 | vars.end_string_ptr = (char *) ptr; | 913 | | | 914 | | /* The remaining space in bim->buffer is used | 915 | | by the pe_ILF_make_a_section() function. */ | 916 | | | 917 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 918 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 919 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 920 | | alignment. */ | 921 | 132 | #if GCC_VERSION >= 3000 | 922 | 132 | alignment = __alignof__ (struct coff_section_tdata); | 923 | | #else | 924 | | alignment = 8; | 925 | | #endif | 926 | 132 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 927 | | | 928 | 132 | vars.data = ptr; | 929 | 132 | vars.abfd = abfd; | 930 | 132 | vars.sec_index = 0; | 931 | 132 | vars.magic = magic; | 932 | | | 933 | | /* Create the initial .idata$<n> sections: | 934 | | [.idata$2: Import Directory Table -- not needed] | 935 | | .idata$4: Import Lookup Table | 936 | | .idata$5: Import Address Table | 937 | | | 938 | | Note we do not create a .idata$3 section as this is | 939 | | created for us by the linker script. */ | 940 | 132 | id4 = pe_ILF_make_a_section (&vars, ".idata$4", SIZEOF_IDATA4, 0); | 941 | 132 | id5 = pe_ILF_make_a_section (&vars, ".idata$5", SIZEOF_IDATA5, 0); | 942 | 132 | if (id4 == NULL || id5 == NULL) | 943 | 0 | goto error_return; | 944 | | | 945 | | /* Fill in the contents of these sections. */ | 946 | 132 | if (import_name_type == IMPORT_ORDINAL) | 947 | 44 | { | 948 | 44 | if (ordinal == 0) | 949 | | /* See PR 20907 for a reproducer. */ | 950 | 9 | goto error_return; | 951 | | | 952 | 35 | #if (defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) \ | 953 | 35 | || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64)) | 954 | 35 | ((unsigned int *) id4->contents)[0] = ordinal; | 955 | 35 | ((unsigned int *) id4->contents)[1] = 0x80000000; | 956 | 35 | ((unsigned int *) id5->contents)[0] = ordinal; | 957 | 35 | ((unsigned int *) id5->contents)[1] = 0x80000000; | 958 | | #else | 959 | | ((unsigned int *) id4->contents)[0] = ordinal | 0x80000000; | 960 | | ((unsigned int *) id5->contents)[0] = ordinal | 0x80000000; | 961 | | #endif | 962 | 35 | } | 963 | 88 | else | 964 | 88 | { | 965 | 88 | char *symbol; | 966 | 88 | unsigned int len; | 967 | | | 968 | | /* Create .idata$6 - the Hint Name Table. */ | 969 | 88 | id6 = pe_ILF_make_a_section (&vars, ".idata$6", SIZEOF_IDATA6, 0); | 970 | 88 | if (id6 == NULL) | 971 | 0 | goto error_return; | 972 | | | 973 | | /* If necessary, trim the import symbol name. */ | 974 | 88 | symbol = import_name; | 975 | | | 976 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 977 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 978 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 979 | | of these is used for a symbol. We strip this leading char for | 980 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 981 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 982 | | | 983 | 88 | if (import_name_type != IMPORT_NAME | 984 | 71 | && import_name_type != IMPORT_NAME_EXPORTAS) | 985 | 58 | { | 986 | 58 | char c = symbol[0]; | 987 | | | 988 | | /* Check that we don't remove for targets with empty | 989 | | USER_LABEL_PREFIX the leading underscore. */ | 990 | 58 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 991 | 58 | || c == '@' || c == '?') | 992 | 13 | symbol++; | 993 | 58 | } | 994 | | | 995 | 88 | len = strlen (symbol); | 996 | 88 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 997 | 44 | { | 998 | | /* Truncate at the first '@'. */ | 999 | 44 | char *at = strchr (symbol, '@'); | 1000 | | | 1001 | 44 | if (at != NULL) | 1002 | 6 | len = at - symbol; | 1003 | 44 | } | 1004 | | | 1005 | 88 | id6->contents[0] = ordinal & 0xff; | 1006 | 88 | id6->contents[1] = ordinal >> 8; | 1007 | | | 1008 | 88 | memcpy ((char *) id6->contents + 2, symbol, len); | 1009 | 88 | id6->contents[len + 2] = '\0'; | 1010 | 88 | } | 1011 | | | 1012 | 123 | if (import_name_type != IMPORT_ORDINAL) | 1013 | 88 | { | 1014 | 88 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1015 | 88 | pe_ILF_save_relocs (&vars, id4); | 1016 | | | 1017 | 88 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1018 | 88 | pe_ILF_save_relocs (&vars, id5); | 1019 | 88 | } | 1020 | | | 1021 | | /* Create an import symbol. */ | 1022 | 123 | pe_ILF_make_a_symbol (&vars, "__imp_", symbol_name, id5, 0); | 1023 | 123 | imp_sym = vars.sym_ptr_ptr - 1; | 1024 | 123 | imp_index = vars.sym_index - 1; | 1025 | | | 1026 | | /* Create extra sections depending upon the type of import we are | 1027 | | dealing with. */ | 1028 | 123 | switch (import_type) | 1029 | 123 | { | 1030 | 0 | int i; | 1031 | | | 1032 | 54 | case IMPORT_CODE: | 1033 | | /* CODE functions are special, in that they get a trampoline that | 1034 | | jumps to the main import symbol. Create a .text section to hold it. | 1035 | | First we need to look up its contents in the jump table. */ | 1036 | 108 | for (i = NUM_ENTRIES (jtab); i--;) | 1037 | 108 | { | 1038 | 108 | if (jtab[i].size == 0) | 1039 | 54 | continue; | 1040 | 54 | if (jtab[i].magic == magic) | 1041 | 54 | break; | 1042 | 54 | } | 1043 | | /* If we did not find a matching entry something is wrong. */ | 1044 | 54 | if (i < 0) | 1045 | 0 | abort (); | 1046 | | | 1047 | | /* Create the .text section. */ | 1048 | 54 | text = pe_ILF_make_a_section (&vars, ".text", jtab[i].size, SEC_CODE); | 1049 | 54 | if (text == NULL) | 1050 | 0 | goto error_return; | 1051 | | | 1052 | | /* Copy in the jump code. */ | 1053 | 54 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1054 | | | 1055 | | /* Create a reloc for the data in the text section. */ | 1056 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1057 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1058 | | { | 1059 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1060 | | (struct bfd_symbol **) imp_sym, | 1061 | | imp_index); | 1062 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1063 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1064 | | (struct bfd_symbol **) imp_sym, | 1065 | | imp_index); | 1066 | | } | 1067 | | else | 1068 | | #endif | 1069 | | #ifdef AMD64MAGIC | 1070 | | if (magic == AMD64MAGIC) | 1071 | | { | 1072 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1073 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1074 | | imp_index); | 1075 | | } | 1076 | | else | 1077 | | #endif | 1078 | 54 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1079 | 54 | BFD_RELOC_32, (asymbol **) imp_sym, | 1080 | 54 | imp_index); | 1081 | | | 1082 | 54 | pe_ILF_save_relocs (&vars, text); | 1083 | 54 | break; | 1084 | | | 1085 | 50 | case IMPORT_DATA: | 1086 | 69 | case IMPORT_CONST: | 1087 | 69 | break; | 1088 | | | 1089 | 0 | default: | 1090 | | /* XXX code not yet written. */ | 1091 | 0 | abort (); | 1092 | 123 | } | 1093 | | | 1094 | | /* Now create a symbol describing the imported value. */ | 1095 | 123 | switch (import_type) | 1096 | 123 | { | 1097 | 54 | case IMPORT_CODE: | 1098 | 54 | pe_ILF_make_a_symbol (&vars, "", symbol_name, text, | 1099 | 54 | BSF_NOT_AT_END | BSF_FUNCTION); | 1100 | | | 1101 | 54 | break; | 1102 | | | 1103 | 50 | case IMPORT_DATA: | 1104 | | /* Nothing to do here. */ | 1105 | 50 | break; | 1106 | | | 1107 | 19 | case IMPORT_CONST: | 1108 | 19 | pe_ILF_make_a_symbol (&vars, "", symbol_name, id5, 0); | 1109 | 19 | break; | 1110 | | | 1111 | 0 | default: | 1112 | | /* XXX code not yet written. */ | 1113 | 0 | abort (); | 1114 | 123 | } | 1115 | | | 1116 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1117 | 123 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1118 | 123 | if (ptr) | 1119 | 17 | *ptr = 0; | 1120 | 123 | pe_ILF_make_a_symbol (&vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1121 | 123 | if (ptr) | 1122 | 17 | *ptr = '.'; | 1123 | | | 1124 | | /* Initialise the bfd. */ | 1125 | 123 | memset (&internal_f, 0, sizeof (internal_f)); | 1126 | | | 1127 | 123 | internal_f.f_magic = magic; | 1128 | 123 | internal_f.f_symptr = 0; | 1129 | 123 | internal_f.f_nsyms = 0; | 1130 | 123 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1131 | | | 1132 | 123 | if (!bfd_set_start_address (abfd, (bfd_vma) 0) | 1133 | 123 | || !bfd_coff_set_arch_mach_hook (abfd, &internal_f)) | 1134 | 0 | goto error_return; | 1135 | | | 1136 | 123 | if (bfd_coff_mkobject_hook (abfd, (void *) &internal_f, NULL) == NULL) | 1137 | 0 | goto error_return; | 1138 | | | 1139 | 123 | obj_pe (abfd) = true; | 1140 | | #ifdef THUMBPEMAGIC | 1141 | | if (vars.magic == THUMBPEMAGIC) | 1142 | | /* Stop some linker warnings about thumb code not supporting | 1143 | | interworking. */ | 1144 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1145 | | #endif | 1146 | | | 1147 | | /* Switch from file contents to memory contents. */ | 1148 | 123 | bfd_cache_close (abfd); | 1149 | | | 1150 | 123 | abfd->iostream = (void *) vars.bim; | 1151 | 123 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1152 | 123 | abfd->iovec = &_bfd_memory_iovec; | 1153 | 123 | abfd->where = 0; | 1154 | 123 | abfd->origin = 0; | 1155 | 123 | abfd->size = 0; | 1156 | 123 | obj_sym_filepos (abfd) = 0; | 1157 | | | 1158 | | /* Point the bfd at the symbol table. */ | 1159 | 123 | obj_symbols (abfd) = vars.sym_cache; | 1160 | 123 | abfd->symcount = vars.sym_index; | 1161 | | | 1162 | 123 | obj_raw_syments (abfd) = vars.native_syms; | 1163 | 123 | obj_raw_syment_count (abfd) = vars.sym_index; | 1164 | 123 | obj_coff_keep_raw_syms (abfd) = true; | 1165 | | | 1166 | 123 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1167 | 123 | obj_coff_keep_syms (abfd) = true; | 1168 | | | 1169 | 123 | obj_convert (abfd) = vars.sym_table; | 1170 | 123 | obj_conv_table_size (abfd) = vars.sym_index; | 1171 | | | 1172 | 123 | obj_coff_strings (abfd) = vars.string_table; | 1173 | 123 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1174 | 123 | obj_coff_keep_strings (abfd) = true; | 1175 | | | 1176 | 123 | return true; | 1177 | | | 1178 | 9 | error_return: | 1179 | 9 | free (vars.bim->buffer); | 1180 | 9 | free (vars.bim); | 1181 | | return false; | 1182 | 123 | } |
pei-riscv64.c:pe_ILF_build_a_bfd Line | Count | Source | 805 | 165 | { | 806 | 165 | bfd_byte * ptr; | 807 | 165 | pe_ILF_vars vars; | 808 | 165 | struct internal_filehdr internal_f; | 809 | 165 | unsigned int import_type; | 810 | 165 | unsigned int import_name_type; | 811 | 165 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 812 | 165 | coff_symbol_type ** imp_sym; | 813 | 165 | unsigned int imp_index; | 814 | 165 | intptr_t alignment; | 815 | | | 816 | | /* Decode and verify the types field of the ILF structure. */ | 817 | 165 | import_type = types & 0x3; | 818 | 165 | import_name_type = (types & 0x1c) >> 2; | 819 | | | 820 | 165 | switch (import_type) | 821 | 165 | { | 822 | 72 | case IMPORT_CODE: | 823 | 101 | case IMPORT_DATA: | 824 | 155 | case IMPORT_CONST: | 825 | 155 | break; | 826 | | | 827 | 10 | default: | 828 | | /* xgettext:c-format */ | 829 | 10 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 830 | 10 | abfd, import_type); | 831 | 10 | return false; | 832 | 165 | } | 833 | | | 834 | 155 | switch (import_name_type) | 835 | 155 | { | 836 | 36 | case IMPORT_ORDINAL: | 837 | 50 | case IMPORT_NAME: | 838 | 79 | case IMPORT_NAME_NOPREFIX: | 839 | 117 | case IMPORT_NAME_UNDECORATE: | 840 | 117 | import_name = symbol_name; | 841 | 117 | break; | 842 | | | 843 | 28 | case IMPORT_NAME_EXPORTAS: | 844 | 28 | if (!import_name || !import_name[0]) | 845 | 16 | { | 846 | 16 | _bfd_error_handler (_("%pB: missing import name for " | 847 | 16 | "IMPORT_NAME_EXPORTAS for %s"), | 848 | 16 | abfd, symbol_name); | 849 | 16 | return false; | 850 | 16 | } | 851 | 12 | break; | 852 | | | 853 | 12 | default: | 854 | | /* xgettext:c-format */ | 855 | 10 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 856 | 10 | abfd, import_name_type); | 857 | 10 | return false; | 858 | 155 | } | 859 | | | 860 | | /* Initialise local variables. | 861 | | | 862 | | Note these are kept in a structure rather than being | 863 | | declared as statics since bfd frowns on global variables. | 864 | | | 865 | | We are going to construct the contents of the BFD in memory, | 866 | | so allocate all the space that we will need right now. */ | 867 | 129 | vars.bim | 868 | 129 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 869 | 129 | if (vars.bim == NULL) | 870 | 0 | return false; | 871 | | | 872 | 129 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 873 | 129 | vars.bim->buffer = ptr; | 874 | 129 | vars.bim->size = ILF_DATA_SIZE; | 875 | 129 | vars.bim->capacity = ILF_DATA_SIZE; | 876 | 129 | if (ptr == NULL) | 877 | 0 | goto error_return; | 878 | | | 879 | | /* Initialise the pointers to regions of the memory and the | 880 | | other contents of the pe_ILF_vars structure as well. */ | 881 | 129 | vars.sym_cache = (coff_symbol_type *) ptr; | 882 | 129 | vars.sym_ptr = (coff_symbol_type *) ptr; | 883 | 129 | vars.sym_index = 0; | 884 | 129 | ptr += SIZEOF_ILF_SYMS; | 885 | | | 886 | 129 | vars.sym_table = (unsigned int *) ptr; | 887 | 129 | vars.table_ptr = (unsigned int *) ptr; | 888 | 129 | ptr += SIZEOF_ILF_SYM_TABLE; | 889 | | | 890 | 129 | vars.native_syms = (combined_entry_type *) ptr; | 891 | 129 | vars.native_ptr = (combined_entry_type *) ptr; | 892 | 129 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 893 | | | 894 | 129 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 895 | 129 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 896 | 129 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 897 | | | 898 | 129 | vars.esym_table = (SYMENT *) ptr; | 899 | 129 | vars.esym_ptr = (SYMENT *) ptr; | 900 | 129 | ptr += SIZEOF_ILF_EXT_SYMS; | 901 | | | 902 | 129 | vars.reltab = (arelent *) ptr; | 903 | 129 | vars.relcount = 0; | 904 | 129 | ptr += SIZEOF_ILF_RELOCS; | 905 | | | 906 | 129 | vars.int_reltab = (struct internal_reloc *) ptr; | 907 | 129 | ptr += SIZEOF_ILF_INT_RELOCS; | 908 | | | 909 | 129 | vars.string_table = (char *) ptr; | 910 | 129 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 911 | 129 | ptr += SIZEOF_ILF_STRINGS; | 912 | 129 | vars.end_string_ptr = (char *) ptr; | 913 | | | 914 | | /* The remaining space in bim->buffer is used | 915 | | by the pe_ILF_make_a_section() function. */ | 916 | | | 917 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 918 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 919 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 920 | | alignment. */ | 921 | 129 | #if GCC_VERSION >= 3000 | 922 | 129 | alignment = __alignof__ (struct coff_section_tdata); | 923 | | #else | 924 | | alignment = 8; | 925 | | #endif | 926 | 129 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 927 | | | 928 | 129 | vars.data = ptr; | 929 | 129 | vars.abfd = abfd; | 930 | 129 | vars.sec_index = 0; | 931 | 129 | vars.magic = magic; | 932 | | | 933 | | /* Create the initial .idata$<n> sections: | 934 | | [.idata$2: Import Directory Table -- not needed] | 935 | | .idata$4: Import Lookup Table | 936 | | .idata$5: Import Address Table | 937 | | | 938 | | Note we do not create a .idata$3 section as this is | 939 | | created for us by the linker script. */ | 940 | 129 | id4 = pe_ILF_make_a_section (&vars, ".idata$4", SIZEOF_IDATA4, 0); | 941 | 129 | id5 = pe_ILF_make_a_section (&vars, ".idata$5", SIZEOF_IDATA5, 0); | 942 | 129 | if (id4 == NULL || id5 == NULL) | 943 | 0 | goto error_return; | 944 | | | 945 | | /* Fill in the contents of these sections. */ | 946 | 129 | if (import_name_type == IMPORT_ORDINAL) | 947 | 36 | { | 948 | 36 | if (ordinal == 0) | 949 | | /* See PR 20907 for a reproducer. */ | 950 | 7 | goto error_return; | 951 | | | 952 | 29 | #if (defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) \ | 953 | 29 | || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64)) | 954 | 29 | ((unsigned int *) id4->contents)[0] = ordinal; | 955 | 29 | ((unsigned int *) id4->contents)[1] = 0x80000000; | 956 | 29 | ((unsigned int *) id5->contents)[0] = ordinal; | 957 | 29 | ((unsigned int *) id5->contents)[1] = 0x80000000; | 958 | | #else | 959 | | ((unsigned int *) id4->contents)[0] = ordinal | 0x80000000; | 960 | | ((unsigned int *) id5->contents)[0] = ordinal | 0x80000000; | 961 | | #endif | 962 | 29 | } | 963 | 93 | else | 964 | 93 | { | 965 | 93 | char *symbol; | 966 | 93 | unsigned int len; | 967 | | | 968 | | /* Create .idata$6 - the Hint Name Table. */ | 969 | 93 | id6 = pe_ILF_make_a_section (&vars, ".idata$6", SIZEOF_IDATA6, 0); | 970 | 93 | if (id6 == NULL) | 971 | 0 | goto error_return; | 972 | | | 973 | | /* If necessary, trim the import symbol name. */ | 974 | 93 | symbol = import_name; | 975 | | | 976 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 977 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 978 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 979 | | of these is used for a symbol. We strip this leading char for | 980 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 981 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 982 | | | 983 | 93 | if (import_name_type != IMPORT_NAME | 984 | 79 | && import_name_type != IMPORT_NAME_EXPORTAS) | 985 | 67 | { | 986 | 67 | char c = symbol[0]; | 987 | | | 988 | | /* Check that we don't remove for targets with empty | 989 | | USER_LABEL_PREFIX the leading underscore. */ | 990 | 67 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 991 | 67 | || c == '@' || c == '?') | 992 | 19 | symbol++; | 993 | 67 | } | 994 | | | 995 | 93 | len = strlen (symbol); | 996 | 93 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 997 | 38 | { | 998 | | /* Truncate at the first '@'. */ | 999 | 38 | char *at = strchr (symbol, '@'); | 1000 | | | 1001 | 38 | if (at != NULL) | 1002 | 12 | len = at - symbol; | 1003 | 38 | } | 1004 | | | 1005 | 93 | id6->contents[0] = ordinal & 0xff; | 1006 | 93 | id6->contents[1] = ordinal >> 8; | 1007 | | | 1008 | 93 | memcpy ((char *) id6->contents + 2, symbol, len); | 1009 | 93 | id6->contents[len + 2] = '\0'; | 1010 | 93 | } | 1011 | | | 1012 | 122 | if (import_name_type != IMPORT_ORDINAL) | 1013 | 93 | { | 1014 | 93 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1015 | 93 | pe_ILF_save_relocs (&vars, id4); | 1016 | | | 1017 | 93 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1018 | 93 | pe_ILF_save_relocs (&vars, id5); | 1019 | 93 | } | 1020 | | | 1021 | | /* Create an import symbol. */ | 1022 | 122 | pe_ILF_make_a_symbol (&vars, "__imp_", symbol_name, id5, 0); | 1023 | 122 | imp_sym = vars.sym_ptr_ptr - 1; | 1024 | 122 | imp_index = vars.sym_index - 1; | 1025 | | | 1026 | | /* Create extra sections depending upon the type of import we are | 1027 | | dealing with. */ | 1028 | 122 | switch (import_type) | 1029 | 122 | { | 1030 | 0 | int i; | 1031 | | | 1032 | 51 | case IMPORT_CODE: | 1033 | | /* CODE functions are special, in that they get a trampoline that | 1034 | | jumps to the main import symbol. Create a .text section to hold it. | 1035 | | First we need to look up its contents in the jump table. */ | 1036 | 102 | for (i = NUM_ENTRIES (jtab); i--;) | 1037 | 102 | { | 1038 | 102 | if (jtab[i].size == 0) | 1039 | 51 | continue; | 1040 | 51 | if (jtab[i].magic == magic) | 1041 | 51 | break; | 1042 | 51 | } | 1043 | | /* If we did not find a matching entry something is wrong. */ | 1044 | 51 | if (i < 0) | 1045 | 0 | abort (); | 1046 | | | 1047 | | /* Create the .text section. */ | 1048 | 51 | text = pe_ILF_make_a_section (&vars, ".text", jtab[i].size, SEC_CODE); | 1049 | 51 | if (text == NULL) | 1050 | 0 | goto error_return; | 1051 | | | 1052 | | /* Copy in the jump code. */ | 1053 | 51 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1054 | | | 1055 | | /* Create a reloc for the data in the text section. */ | 1056 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1057 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1058 | | { | 1059 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1060 | | (struct bfd_symbol **) imp_sym, | 1061 | | imp_index); | 1062 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1063 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1064 | | (struct bfd_symbol **) imp_sym, | 1065 | | imp_index); | 1066 | | } | 1067 | | else | 1068 | | #endif | 1069 | | #ifdef AMD64MAGIC | 1070 | | if (magic == AMD64MAGIC) | 1071 | | { | 1072 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1073 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1074 | | imp_index); | 1075 | | } | 1076 | | else | 1077 | | #endif | 1078 | 51 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1079 | 51 | BFD_RELOC_32, (asymbol **) imp_sym, | 1080 | 51 | imp_index); | 1081 | | | 1082 | 51 | pe_ILF_save_relocs (&vars, text); | 1083 | 51 | break; | 1084 | | | 1085 | 23 | case IMPORT_DATA: | 1086 | 71 | case IMPORT_CONST: | 1087 | 71 | break; | 1088 | | | 1089 | 0 | default: | 1090 | | /* XXX code not yet written. */ | 1091 | 0 | abort (); | 1092 | 122 | } | 1093 | | | 1094 | | /* Now create a symbol describing the imported value. */ | 1095 | 122 | switch (import_type) | 1096 | 122 | { | 1097 | 51 | case IMPORT_CODE: | 1098 | 51 | pe_ILF_make_a_symbol (&vars, "", symbol_name, text, | 1099 | 51 | BSF_NOT_AT_END | BSF_FUNCTION); | 1100 | | | 1101 | 51 | break; | 1102 | | | 1103 | 23 | case IMPORT_DATA: | 1104 | | /* Nothing to do here. */ | 1105 | 23 | break; | 1106 | | | 1107 | 48 | case IMPORT_CONST: | 1108 | 48 | pe_ILF_make_a_symbol (&vars, "", symbol_name, id5, 0); | 1109 | 48 | break; | 1110 | | | 1111 | 0 | default: | 1112 | | /* XXX code not yet written. */ | 1113 | 0 | abort (); | 1114 | 122 | } | 1115 | | | 1116 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1117 | 122 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1118 | 122 | if (ptr) | 1119 | 14 | *ptr = 0; | 1120 | 122 | pe_ILF_make_a_symbol (&vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1121 | 122 | if (ptr) | 1122 | 14 | *ptr = '.'; | 1123 | | | 1124 | | /* Initialise the bfd. */ | 1125 | 122 | memset (&internal_f, 0, sizeof (internal_f)); | 1126 | | | 1127 | 122 | internal_f.f_magic = magic; | 1128 | 122 | internal_f.f_symptr = 0; | 1129 | 122 | internal_f.f_nsyms = 0; | 1130 | 122 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1131 | | | 1132 | 122 | if (!bfd_set_start_address (abfd, (bfd_vma) 0) | 1133 | 122 | || !bfd_coff_set_arch_mach_hook (abfd, &internal_f)) | 1134 | 0 | goto error_return; | 1135 | | | 1136 | 122 | if (bfd_coff_mkobject_hook (abfd, (void *) &internal_f, NULL) == NULL) | 1137 | 0 | goto error_return; | 1138 | | | 1139 | 122 | obj_pe (abfd) = true; | 1140 | | #ifdef THUMBPEMAGIC | 1141 | | if (vars.magic == THUMBPEMAGIC) | 1142 | | /* Stop some linker warnings about thumb code not supporting | 1143 | | interworking. */ | 1144 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1145 | | #endif | 1146 | | | 1147 | | /* Switch from file contents to memory contents. */ | 1148 | 122 | bfd_cache_close (abfd); | 1149 | | | 1150 | 122 | abfd->iostream = (void *) vars.bim; | 1151 | 122 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1152 | 122 | abfd->iovec = &_bfd_memory_iovec; | 1153 | 122 | abfd->where = 0; | 1154 | 122 | abfd->origin = 0; | 1155 | 122 | abfd->size = 0; | 1156 | 122 | obj_sym_filepos (abfd) = 0; | 1157 | | | 1158 | | /* Point the bfd at the symbol table. */ | 1159 | 122 | obj_symbols (abfd) = vars.sym_cache; | 1160 | 122 | abfd->symcount = vars.sym_index; | 1161 | | | 1162 | 122 | obj_raw_syments (abfd) = vars.native_syms; | 1163 | 122 | obj_raw_syment_count (abfd) = vars.sym_index; | 1164 | 122 | obj_coff_keep_raw_syms (abfd) = true; | 1165 | | | 1166 | 122 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1167 | 122 | obj_coff_keep_syms (abfd) = true; | 1168 | | | 1169 | 122 | obj_convert (abfd) = vars.sym_table; | 1170 | 122 | obj_conv_table_size (abfd) = vars.sym_index; | 1171 | | | 1172 | 122 | obj_coff_strings (abfd) = vars.string_table; | 1173 | 122 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1174 | 122 | obj_coff_keep_strings (abfd) = true; | 1175 | | | 1176 | 122 | return true; | 1177 | | | 1178 | 7 | error_return: | 1179 | 7 | free (vars.bim->buffer); | 1180 | 7 | free (vars.bim); | 1181 | | return false; | 1182 | 122 | } |
pei-arm-wince.c:pe_ILF_build_a_bfd Line | Count | Source | 805 | 124 | { | 806 | 124 | bfd_byte * ptr; | 807 | 124 | pe_ILF_vars vars; | 808 | 124 | struct internal_filehdr internal_f; | 809 | 124 | unsigned int import_type; | 810 | 124 | unsigned int import_name_type; | 811 | 124 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 812 | 124 | coff_symbol_type ** imp_sym; | 813 | 124 | unsigned int imp_index; | 814 | 124 | intptr_t alignment; | 815 | | | 816 | | /* Decode and verify the types field of the ILF structure. */ | 817 | 124 | import_type = types & 0x3; | 818 | 124 | import_name_type = (types & 0x1c) >> 2; | 819 | | | 820 | 124 | switch (import_type) | 821 | 124 | { | 822 | 58 | case IMPORT_CODE: | 823 | 95 | case IMPORT_DATA: | 824 | 116 | case IMPORT_CONST: | 825 | 116 | break; | 826 | | | 827 | 8 | default: | 828 | | /* xgettext:c-format */ | 829 | 8 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 830 | 8 | abfd, import_type); | 831 | 8 | return false; | 832 | 124 | } | 833 | | | 834 | 116 | switch (import_name_type) | 835 | 116 | { | 836 | 30 | case IMPORT_ORDINAL: | 837 | 37 | case IMPORT_NAME: | 838 | 57 | case IMPORT_NAME_NOPREFIX: | 839 | 83 | case IMPORT_NAME_UNDECORATE: | 840 | 83 | import_name = symbol_name; | 841 | 83 | break; | 842 | | | 843 | 24 | case IMPORT_NAME_EXPORTAS: | 844 | 24 | if (!import_name || !import_name[0]) | 845 | 18 | { | 846 | 18 | _bfd_error_handler (_("%pB: missing import name for " | 847 | 18 | "IMPORT_NAME_EXPORTAS for %s"), | 848 | 18 | abfd, symbol_name); | 849 | 18 | return false; | 850 | 18 | } | 851 | 6 | break; | 852 | | | 853 | 9 | default: | 854 | | /* xgettext:c-format */ | 855 | 9 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 856 | 9 | abfd, import_name_type); | 857 | 9 | return false; | 858 | 116 | } | 859 | | | 860 | | /* Initialise local variables. | 861 | | | 862 | | Note these are kept in a structure rather than being | 863 | | declared as statics since bfd frowns on global variables. | 864 | | | 865 | | We are going to construct the contents of the BFD in memory, | 866 | | so allocate all the space that we will need right now. */ | 867 | 89 | vars.bim | 868 | 89 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 869 | 89 | if (vars.bim == NULL) | 870 | 0 | return false; | 871 | | | 872 | 89 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 873 | 89 | vars.bim->buffer = ptr; | 874 | 89 | vars.bim->size = ILF_DATA_SIZE; | 875 | 89 | vars.bim->capacity = ILF_DATA_SIZE; | 876 | 89 | if (ptr == NULL) | 877 | 0 | goto error_return; | 878 | | | 879 | | /* Initialise the pointers to regions of the memory and the | 880 | | other contents of the pe_ILF_vars structure as well. */ | 881 | 89 | vars.sym_cache = (coff_symbol_type *) ptr; | 882 | 89 | vars.sym_ptr = (coff_symbol_type *) ptr; | 883 | 89 | vars.sym_index = 0; | 884 | 89 | ptr += SIZEOF_ILF_SYMS; | 885 | | | 886 | 89 | vars.sym_table = (unsigned int *) ptr; | 887 | 89 | vars.table_ptr = (unsigned int *) ptr; | 888 | 89 | ptr += SIZEOF_ILF_SYM_TABLE; | 889 | | | 890 | 89 | vars.native_syms = (combined_entry_type *) ptr; | 891 | 89 | vars.native_ptr = (combined_entry_type *) ptr; | 892 | 89 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 893 | | | 894 | 89 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 895 | 89 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 896 | 89 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 897 | | | 898 | 89 | vars.esym_table = (SYMENT *) ptr; | 899 | 89 | vars.esym_ptr = (SYMENT *) ptr; | 900 | 89 | ptr += SIZEOF_ILF_EXT_SYMS; | 901 | | | 902 | 89 | vars.reltab = (arelent *) ptr; | 903 | 89 | vars.relcount = 0; | 904 | 89 | ptr += SIZEOF_ILF_RELOCS; | 905 | | | 906 | 89 | vars.int_reltab = (struct internal_reloc *) ptr; | 907 | 89 | ptr += SIZEOF_ILF_INT_RELOCS; | 908 | | | 909 | 89 | vars.string_table = (char *) ptr; | 910 | 89 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 911 | 89 | ptr += SIZEOF_ILF_STRINGS; | 912 | 89 | vars.end_string_ptr = (char *) ptr; | 913 | | | 914 | | /* The remaining space in bim->buffer is used | 915 | | by the pe_ILF_make_a_section() function. */ | 916 | | | 917 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 918 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 919 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 920 | | alignment. */ | 921 | 89 | #if GCC_VERSION >= 3000 | 922 | 89 | alignment = __alignof__ (struct coff_section_tdata); | 923 | | #else | 924 | | alignment = 8; | 925 | | #endif | 926 | 89 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 927 | | | 928 | 89 | vars.data = ptr; | 929 | 89 | vars.abfd = abfd; | 930 | 89 | vars.sec_index = 0; | 931 | 89 | vars.magic = magic; | 932 | | | 933 | | /* Create the initial .idata$<n> sections: | 934 | | [.idata$2: Import Directory Table -- not needed] | 935 | | .idata$4: Import Lookup Table | 936 | | .idata$5: Import Address Table | 937 | | | 938 | | Note we do not create a .idata$3 section as this is | 939 | | created for us by the linker script. */ | 940 | 89 | id4 = pe_ILF_make_a_section (&vars, ".idata$4", SIZEOF_IDATA4, 0); | 941 | 89 | id5 = pe_ILF_make_a_section (&vars, ".idata$5", SIZEOF_IDATA5, 0); | 942 | 89 | if (id4 == NULL || id5 == NULL) | 943 | 0 | goto error_return; | 944 | | | 945 | | /* Fill in the contents of these sections. */ | 946 | 89 | if (import_name_type == IMPORT_ORDINAL) | 947 | 30 | { | 948 | 30 | if (ordinal == 0) | 949 | | /* See PR 20907 for a reproducer. */ | 950 | 10 | goto error_return; | 951 | | | 952 | | #if (defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) \ | 953 | | || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64)) | 954 | | ((unsigned int *) id4->contents)[0] = ordinal; | 955 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 956 | | ((unsigned int *) id5->contents)[0] = ordinal; | 957 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 958 | | #else | 959 | 20 | ((unsigned int *) id4->contents)[0] = ordinal | 0x80000000; | 960 | 20 | ((unsigned int *) id5->contents)[0] = ordinal | 0x80000000; | 961 | 20 | #endif | 962 | 20 | } | 963 | 59 | else | 964 | 59 | { | 965 | 59 | char *symbol; | 966 | 59 | unsigned int len; | 967 | | | 968 | | /* Create .idata$6 - the Hint Name Table. */ | 969 | 59 | id6 = pe_ILF_make_a_section (&vars, ".idata$6", SIZEOF_IDATA6, 0); | 970 | 59 | if (id6 == NULL) | 971 | 0 | goto error_return; | 972 | | | 973 | | /* If necessary, trim the import symbol name. */ | 974 | 59 | symbol = import_name; | 975 | | | 976 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 977 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 978 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 979 | | of these is used for a symbol. We strip this leading char for | 980 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 981 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 982 | | | 983 | 59 | if (import_name_type != IMPORT_NAME | 984 | 52 | && import_name_type != IMPORT_NAME_EXPORTAS) | 985 | 46 | { | 986 | 46 | char c = symbol[0]; | 987 | | | 988 | | /* Check that we don't remove for targets with empty | 989 | | USER_LABEL_PREFIX the leading underscore. */ | 990 | 46 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 991 | 46 | || c == '@' || c == '?') | 992 | 9 | symbol++; | 993 | 46 | } | 994 | | | 995 | 59 | len = strlen (symbol); | 996 | 59 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 997 | 26 | { | 998 | | /* Truncate at the first '@'. */ | 999 | 26 | char *at = strchr (symbol, '@'); | 1000 | | | 1001 | 26 | if (at != NULL) | 1002 | 3 | len = at - symbol; | 1003 | 26 | } | 1004 | | | 1005 | 59 | id6->contents[0] = ordinal & 0xff; | 1006 | 59 | id6->contents[1] = ordinal >> 8; | 1007 | | | 1008 | 59 | memcpy ((char *) id6->contents + 2, symbol, len); | 1009 | 59 | id6->contents[len + 2] = '\0'; | 1010 | 59 | } | 1011 | | | 1012 | 79 | if (import_name_type != IMPORT_ORDINAL) | 1013 | 59 | { | 1014 | 59 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1015 | 59 | pe_ILF_save_relocs (&vars, id4); | 1016 | | | 1017 | 59 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1018 | 59 | pe_ILF_save_relocs (&vars, id5); | 1019 | 59 | } | 1020 | | | 1021 | | /* Create an import symbol. */ | 1022 | 79 | pe_ILF_make_a_symbol (&vars, "__imp_", symbol_name, id5, 0); | 1023 | 79 | imp_sym = vars.sym_ptr_ptr - 1; | 1024 | 79 | imp_index = vars.sym_index - 1; | 1025 | | | 1026 | | /* Create extra sections depending upon the type of import we are | 1027 | | dealing with. */ | 1028 | 79 | switch (import_type) | 1029 | 79 | { | 1030 | 0 | int i; | 1031 | | | 1032 | 40 | case IMPORT_CODE: | 1033 | | /* CODE functions are special, in that they get a trampoline that | 1034 | | jumps to the main import symbol. Create a .text section to hold it. | 1035 | | First we need to look up its contents in the jump table. */ | 1036 | 101 | for (i = NUM_ENTRIES (jtab); i--;) | 1037 | 101 | { | 1038 | 101 | if (jtab[i].size == 0) | 1039 | 40 | continue; | 1040 | 61 | if (jtab[i].magic == magic) | 1041 | 40 | break; | 1042 | 61 | } | 1043 | | /* If we did not find a matching entry something is wrong. */ | 1044 | 40 | if (i < 0) | 1045 | 0 | abort (); | 1046 | | | 1047 | | /* Create the .text section. */ | 1048 | 40 | text = pe_ILF_make_a_section (&vars, ".text", jtab[i].size, SEC_CODE); | 1049 | 40 | if (text == NULL) | 1050 | 0 | goto error_return; | 1051 | | | 1052 | | /* Copy in the jump code. */ | 1053 | 40 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1054 | | | 1055 | | /* Create a reloc for the data in the text section. */ | 1056 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1057 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1058 | | { | 1059 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1060 | | (struct bfd_symbol **) imp_sym, | 1061 | | imp_index); | 1062 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1063 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1064 | | (struct bfd_symbol **) imp_sym, | 1065 | | imp_index); | 1066 | | } | 1067 | | else | 1068 | | #endif | 1069 | | #ifdef AMD64MAGIC | 1070 | | if (magic == AMD64MAGIC) | 1071 | | { | 1072 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1073 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1074 | | imp_index); | 1075 | | } | 1076 | | else | 1077 | | #endif | 1078 | 40 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1079 | 40 | BFD_RELOC_32, (asymbol **) imp_sym, | 1080 | 40 | imp_index); | 1081 | | | 1082 | 40 | pe_ILF_save_relocs (&vars, text); | 1083 | 40 | break; | 1084 | | | 1085 | 23 | case IMPORT_DATA: | 1086 | 39 | case IMPORT_CONST: | 1087 | 39 | break; | 1088 | | | 1089 | 0 | default: | 1090 | | /* XXX code not yet written. */ | 1091 | 0 | abort (); | 1092 | 79 | } | 1093 | | | 1094 | | /* Now create a symbol describing the imported value. */ | 1095 | 79 | switch (import_type) | 1096 | 79 | { | 1097 | 40 | case IMPORT_CODE: | 1098 | 40 | pe_ILF_make_a_symbol (&vars, "", symbol_name, text, | 1099 | 40 | BSF_NOT_AT_END | BSF_FUNCTION); | 1100 | | | 1101 | 40 | break; | 1102 | | | 1103 | 23 | case IMPORT_DATA: | 1104 | | /* Nothing to do here. */ | 1105 | 23 | break; | 1106 | | | 1107 | 16 | case IMPORT_CONST: | 1108 | 16 | pe_ILF_make_a_symbol (&vars, "", symbol_name, id5, 0); | 1109 | 16 | break; | 1110 | | | 1111 | 0 | default: | 1112 | | /* XXX code not yet written. */ | 1113 | 0 | abort (); | 1114 | 79 | } | 1115 | | | 1116 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1117 | 79 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1118 | 79 | if (ptr) | 1119 | 6 | *ptr = 0; | 1120 | 79 | pe_ILF_make_a_symbol (&vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1121 | 79 | if (ptr) | 1122 | 6 | *ptr = '.'; | 1123 | | | 1124 | | /* Initialise the bfd. */ | 1125 | 79 | memset (&internal_f, 0, sizeof (internal_f)); | 1126 | | | 1127 | 79 | internal_f.f_magic = magic; | 1128 | 79 | internal_f.f_symptr = 0; | 1129 | 79 | internal_f.f_nsyms = 0; | 1130 | 79 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1131 | | | 1132 | 79 | if (!bfd_set_start_address (abfd, (bfd_vma) 0) | 1133 | 79 | || !bfd_coff_set_arch_mach_hook (abfd, &internal_f)) | 1134 | 0 | goto error_return; | 1135 | | | 1136 | 79 | if (bfd_coff_mkobject_hook (abfd, (void *) &internal_f, NULL) == NULL) | 1137 | 0 | goto error_return; | 1138 | | | 1139 | 79 | obj_pe (abfd) = true; | 1140 | 79 | #ifdef THUMBPEMAGIC | 1141 | 79 | if (vars.magic == THUMBPEMAGIC) | 1142 | | /* Stop some linker warnings about thumb code not supporting | 1143 | | interworking. */ | 1144 | 39 | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1145 | 79 | #endif | 1146 | | | 1147 | | /* Switch from file contents to memory contents. */ | 1148 | 79 | bfd_cache_close (abfd); | 1149 | | | 1150 | 79 | abfd->iostream = (void *) vars.bim; | 1151 | 79 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1152 | 79 | abfd->iovec = &_bfd_memory_iovec; | 1153 | 79 | abfd->where = 0; | 1154 | 79 | abfd->origin = 0; | 1155 | 79 | abfd->size = 0; | 1156 | 79 | obj_sym_filepos (abfd) = 0; | 1157 | | | 1158 | | /* Point the bfd at the symbol table. */ | 1159 | 79 | obj_symbols (abfd) = vars.sym_cache; | 1160 | 79 | abfd->symcount = vars.sym_index; | 1161 | | | 1162 | 79 | obj_raw_syments (abfd) = vars.native_syms; | 1163 | 79 | obj_raw_syment_count (abfd) = vars.sym_index; | 1164 | 79 | obj_coff_keep_raw_syms (abfd) = true; | 1165 | | | 1166 | 79 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1167 | 79 | obj_coff_keep_syms (abfd) = true; | 1168 | | | 1169 | 79 | obj_convert (abfd) = vars.sym_table; | 1170 | 79 | obj_conv_table_size (abfd) = vars.sym_index; | 1171 | | | 1172 | 79 | obj_coff_strings (abfd) = vars.string_table; | 1173 | 79 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1174 | 79 | obj_coff_keep_strings (abfd) = true; | 1175 | | | 1176 | 79 | return true; | 1177 | | | 1178 | 10 | error_return: | 1179 | 10 | free (vars.bim->buffer); | 1180 | 10 | free (vars.bim); | 1181 | | return false; | 1182 | 79 | } |
pei-arm.c:pe_ILF_build_a_bfd Line | Count | Source | 805 | 129 | { | 806 | 129 | bfd_byte * ptr; | 807 | 129 | pe_ILF_vars vars; | 808 | 129 | struct internal_filehdr internal_f; | 809 | 129 | unsigned int import_type; | 810 | 129 | unsigned int import_name_type; | 811 | 129 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 812 | 129 | coff_symbol_type ** imp_sym; | 813 | 129 | unsigned int imp_index; | 814 | 129 | intptr_t alignment; | 815 | | | 816 | | /* Decode and verify the types field of the ILF structure. */ | 817 | 129 | import_type = types & 0x3; | 818 | 129 | import_name_type = (types & 0x1c) >> 2; | 819 | | | 820 | 129 | switch (import_type) | 821 | 129 | { | 822 | 62 | case IMPORT_CODE: | 823 | 99 | case IMPORT_DATA: | 824 | 121 | case IMPORT_CONST: | 825 | 121 | break; | 826 | | | 827 | 8 | default: | 828 | | /* xgettext:c-format */ | 829 | 8 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 830 | 8 | abfd, import_type); | 831 | 8 | return false; | 832 | 129 | } | 833 | | | 834 | 121 | switch (import_name_type) | 835 | 121 | { | 836 | 33 | case IMPORT_ORDINAL: | 837 | 41 | case IMPORT_NAME: | 838 | 62 | case IMPORT_NAME_NOPREFIX: | 839 | 88 | case IMPORT_NAME_UNDECORATE: | 840 | 88 | import_name = symbol_name; | 841 | 88 | break; | 842 | | | 843 | 24 | case IMPORT_NAME_EXPORTAS: | 844 | 24 | if (!import_name || !import_name[0]) | 845 | 18 | { | 846 | 18 | _bfd_error_handler (_("%pB: missing import name for " | 847 | 18 | "IMPORT_NAME_EXPORTAS for %s"), | 848 | 18 | abfd, symbol_name); | 849 | 18 | return false; | 850 | 18 | } | 851 | 6 | break; | 852 | | | 853 | 9 | default: | 854 | | /* xgettext:c-format */ | 855 | 9 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 856 | 9 | abfd, import_name_type); | 857 | 9 | return false; | 858 | 121 | } | 859 | | | 860 | | /* Initialise local variables. | 861 | | | 862 | | Note these are kept in a structure rather than being | 863 | | declared as statics since bfd frowns on global variables. | 864 | | | 865 | | We are going to construct the contents of the BFD in memory, | 866 | | so allocate all the space that we will need right now. */ | 867 | 94 | vars.bim | 868 | 94 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 869 | 94 | if (vars.bim == NULL) | 870 | 0 | return false; | 871 | | | 872 | 94 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 873 | 94 | vars.bim->buffer = ptr; | 874 | 94 | vars.bim->size = ILF_DATA_SIZE; | 875 | 94 | vars.bim->capacity = ILF_DATA_SIZE; | 876 | 94 | if (ptr == NULL) | 877 | 0 | goto error_return; | 878 | | | 879 | | /* Initialise the pointers to regions of the memory and the | 880 | | other contents of the pe_ILF_vars structure as well. */ | 881 | 94 | vars.sym_cache = (coff_symbol_type *) ptr; | 882 | 94 | vars.sym_ptr = (coff_symbol_type *) ptr; | 883 | 94 | vars.sym_index = 0; | 884 | 94 | ptr += SIZEOF_ILF_SYMS; | 885 | | | 886 | 94 | vars.sym_table = (unsigned int *) ptr; | 887 | 94 | vars.table_ptr = (unsigned int *) ptr; | 888 | 94 | ptr += SIZEOF_ILF_SYM_TABLE; | 889 | | | 890 | 94 | vars.native_syms = (combined_entry_type *) ptr; | 891 | 94 | vars.native_ptr = (combined_entry_type *) ptr; | 892 | 94 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 893 | | | 894 | 94 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 895 | 94 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 896 | 94 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 897 | | | 898 | 94 | vars.esym_table = (SYMENT *) ptr; | 899 | 94 | vars.esym_ptr = (SYMENT *) ptr; | 900 | 94 | ptr += SIZEOF_ILF_EXT_SYMS; | 901 | | | 902 | 94 | vars.reltab = (arelent *) ptr; | 903 | 94 | vars.relcount = 0; | 904 | 94 | ptr += SIZEOF_ILF_RELOCS; | 905 | | | 906 | 94 | vars.int_reltab = (struct internal_reloc *) ptr; | 907 | 94 | ptr += SIZEOF_ILF_INT_RELOCS; | 908 | | | 909 | 94 | vars.string_table = (char *) ptr; | 910 | 94 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 911 | 94 | ptr += SIZEOF_ILF_STRINGS; | 912 | 94 | vars.end_string_ptr = (char *) ptr; | 913 | | | 914 | | /* The remaining space in bim->buffer is used | 915 | | by the pe_ILF_make_a_section() function. */ | 916 | | | 917 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 918 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 919 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 920 | | alignment. */ | 921 | 94 | #if GCC_VERSION >= 3000 | 922 | 94 | alignment = __alignof__ (struct coff_section_tdata); | 923 | | #else | 924 | | alignment = 8; | 925 | | #endif | 926 | 94 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 927 | | | 928 | 94 | vars.data = ptr; | 929 | 94 | vars.abfd = abfd; | 930 | 94 | vars.sec_index = 0; | 931 | 94 | vars.magic = magic; | 932 | | | 933 | | /* Create the initial .idata$<n> sections: | 934 | | [.idata$2: Import Directory Table -- not needed] | 935 | | .idata$4: Import Lookup Table | 936 | | .idata$5: Import Address Table | 937 | | | 938 | | Note we do not create a .idata$3 section as this is | 939 | | created for us by the linker script. */ | 940 | 94 | id4 = pe_ILF_make_a_section (&vars, ".idata$4", SIZEOF_IDATA4, 0); | 941 | 94 | id5 = pe_ILF_make_a_section (&vars, ".idata$5", SIZEOF_IDATA5, 0); | 942 | 94 | if (id4 == NULL || id5 == NULL) | 943 | 0 | goto error_return; | 944 | | | 945 | | /* Fill in the contents of these sections. */ | 946 | 94 | if (import_name_type == IMPORT_ORDINAL) | 947 | 33 | { | 948 | 33 | if (ordinal == 0) | 949 | | /* See PR 20907 for a reproducer. */ | 950 | 10 | goto error_return; | 951 | | | 952 | | #if (defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) \ | 953 | | || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64)) | 954 | | ((unsigned int *) id4->contents)[0] = ordinal; | 955 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 956 | | ((unsigned int *) id5->contents)[0] = ordinal; | 957 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 958 | | #else | 959 | 23 | ((unsigned int *) id4->contents)[0] = ordinal | 0x80000000; | 960 | 23 | ((unsigned int *) id5->contents)[0] = ordinal | 0x80000000; | 961 | 23 | #endif | 962 | 23 | } | 963 | 61 | else | 964 | 61 | { | 965 | 61 | char *symbol; | 966 | 61 | unsigned int len; | 967 | | | 968 | | /* Create .idata$6 - the Hint Name Table. */ | 969 | 61 | id6 = pe_ILF_make_a_section (&vars, ".idata$6", SIZEOF_IDATA6, 0); | 970 | 61 | if (id6 == NULL) | 971 | 0 | goto error_return; | 972 | | | 973 | | /* If necessary, trim the import symbol name. */ | 974 | 61 | symbol = import_name; | 975 | | | 976 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 977 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 978 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 979 | | of these is used for a symbol. We strip this leading char for | 980 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 981 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 982 | | | 983 | 61 | if (import_name_type != IMPORT_NAME | 984 | 53 | && import_name_type != IMPORT_NAME_EXPORTAS) | 985 | 47 | { | 986 | 47 | char c = symbol[0]; | 987 | | | 988 | | /* Check that we don't remove for targets with empty | 989 | | USER_LABEL_PREFIX the leading underscore. */ | 990 | 47 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 991 | 42 | || c == '@' || c == '?') | 992 | 14 | symbol++; | 993 | 47 | } | 994 | | | 995 | 61 | len = strlen (symbol); | 996 | 61 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 997 | 26 | { | 998 | | /* Truncate at the first '@'. */ | 999 | 26 | char *at = strchr (symbol, '@'); | 1000 | | | 1001 | 26 | if (at != NULL) | 1002 | 3 | len = at - symbol; | 1003 | 26 | } | 1004 | | | 1005 | 61 | id6->contents[0] = ordinal & 0xff; | 1006 | 61 | id6->contents[1] = ordinal >> 8; | 1007 | | | 1008 | 61 | memcpy ((char *) id6->contents + 2, symbol, len); | 1009 | 61 | id6->contents[len + 2] = '\0'; | 1010 | 61 | } | 1011 | | | 1012 | 84 | if (import_name_type != IMPORT_ORDINAL) | 1013 | 61 | { | 1014 | 61 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1015 | 61 | pe_ILF_save_relocs (&vars, id4); | 1016 | | | 1017 | 61 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1018 | 61 | pe_ILF_save_relocs (&vars, id5); | 1019 | 61 | } | 1020 | | | 1021 | | /* Create an import symbol. */ | 1022 | 84 | pe_ILF_make_a_symbol (&vars, "__imp_", symbol_name, id5, 0); | 1023 | 84 | imp_sym = vars.sym_ptr_ptr - 1; | 1024 | 84 | imp_index = vars.sym_index - 1; | 1025 | | | 1026 | | /* Create extra sections depending upon the type of import we are | 1027 | | dealing with. */ | 1028 | 84 | switch (import_type) | 1029 | 84 | { | 1030 | 0 | int i; | 1031 | | | 1032 | 44 | case IMPORT_CODE: | 1033 | | /* CODE functions are special, in that they get a trampoline that | 1034 | | jumps to the main import symbol. Create a .text section to hold it. | 1035 | | First we need to look up its contents in the jump table. */ | 1036 | 113 | for (i = NUM_ENTRIES (jtab); i--;) | 1037 | 113 | { | 1038 | 113 | if (jtab[i].size == 0) | 1039 | 44 | continue; | 1040 | 69 | if (jtab[i].magic == magic) | 1041 | 44 | break; | 1042 | 69 | } | 1043 | | /* If we did not find a matching entry something is wrong. */ | 1044 | 44 | if (i < 0) | 1045 | 0 | abort (); | 1046 | | | 1047 | | /* Create the .text section. */ | 1048 | 44 | text = pe_ILF_make_a_section (&vars, ".text", jtab[i].size, SEC_CODE); | 1049 | 44 | if (text == NULL) | 1050 | 0 | goto error_return; | 1051 | | | 1052 | | /* Copy in the jump code. */ | 1053 | 44 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1054 | | | 1055 | | /* Create a reloc for the data in the text section. */ | 1056 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1057 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1058 | | { | 1059 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1060 | | (struct bfd_symbol **) imp_sym, | 1061 | | imp_index); | 1062 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1063 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1064 | | (struct bfd_symbol **) imp_sym, | 1065 | | imp_index); | 1066 | | } | 1067 | | else | 1068 | | #endif | 1069 | | #ifdef AMD64MAGIC | 1070 | | if (magic == AMD64MAGIC) | 1071 | | { | 1072 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1073 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1074 | | imp_index); | 1075 | | } | 1076 | | else | 1077 | | #endif | 1078 | 44 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1079 | 44 | BFD_RELOC_32, (asymbol **) imp_sym, | 1080 | 44 | imp_index); | 1081 | | | 1082 | 44 | pe_ILF_save_relocs (&vars, text); | 1083 | 44 | break; | 1084 | | | 1085 | 23 | case IMPORT_DATA: | 1086 | 40 | case IMPORT_CONST: | 1087 | 40 | break; | 1088 | | | 1089 | 0 | default: | 1090 | | /* XXX code not yet written. */ | 1091 | 0 | abort (); | 1092 | 84 | } | 1093 | | | 1094 | | /* Now create a symbol describing the imported value. */ | 1095 | 84 | switch (import_type) | 1096 | 84 | { | 1097 | 44 | case IMPORT_CODE: | 1098 | 44 | pe_ILF_make_a_symbol (&vars, "", symbol_name, text, | 1099 | 44 | BSF_NOT_AT_END | BSF_FUNCTION); | 1100 | | | 1101 | 44 | break; | 1102 | | | 1103 | 23 | case IMPORT_DATA: | 1104 | | /* Nothing to do here. */ | 1105 | 23 | break; | 1106 | | | 1107 | 17 | case IMPORT_CONST: | 1108 | 17 | pe_ILF_make_a_symbol (&vars, "", symbol_name, id5, 0); | 1109 | 17 | break; | 1110 | | | 1111 | 0 | default: | 1112 | | /* XXX code not yet written. */ | 1113 | 0 | abort (); | 1114 | 84 | } | 1115 | | | 1116 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1117 | 84 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1118 | 84 | if (ptr) | 1119 | 6 | *ptr = 0; | 1120 | 84 | pe_ILF_make_a_symbol (&vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1121 | 84 | if (ptr) | 1122 | 6 | *ptr = '.'; | 1123 | | | 1124 | | /* Initialise the bfd. */ | 1125 | 84 | memset (&internal_f, 0, sizeof (internal_f)); | 1126 | | | 1127 | 84 | internal_f.f_magic = magic; | 1128 | 84 | internal_f.f_symptr = 0; | 1129 | 84 | internal_f.f_nsyms = 0; | 1130 | 84 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1131 | | | 1132 | 84 | if (!bfd_set_start_address (abfd, (bfd_vma) 0) | 1133 | 84 | || !bfd_coff_set_arch_mach_hook (abfd, &internal_f)) | 1134 | 0 | goto error_return; | 1135 | | | 1136 | 84 | if (bfd_coff_mkobject_hook (abfd, (void *) &internal_f, NULL) == NULL) | 1137 | 0 | goto error_return; | 1138 | | | 1139 | 84 | obj_pe (abfd) = true; | 1140 | 84 | #ifdef THUMBPEMAGIC | 1141 | 84 | if (vars.magic == THUMBPEMAGIC) | 1142 | | /* Stop some linker warnings about thumb code not supporting | 1143 | | interworking. */ | 1144 | 39 | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1145 | 84 | #endif | 1146 | | | 1147 | | /* Switch from file contents to memory contents. */ | 1148 | 84 | bfd_cache_close (abfd); | 1149 | | | 1150 | 84 | abfd->iostream = (void *) vars.bim; | 1151 | 84 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1152 | 84 | abfd->iovec = &_bfd_memory_iovec; | 1153 | 84 | abfd->where = 0; | 1154 | 84 | abfd->origin = 0; | 1155 | 84 | abfd->size = 0; | 1156 | 84 | obj_sym_filepos (abfd) = 0; | 1157 | | | 1158 | | /* Point the bfd at the symbol table. */ | 1159 | 84 | obj_symbols (abfd) = vars.sym_cache; | 1160 | 84 | abfd->symcount = vars.sym_index; | 1161 | | | 1162 | 84 | obj_raw_syments (abfd) = vars.native_syms; | 1163 | 84 | obj_raw_syment_count (abfd) = vars.sym_index; | 1164 | 84 | obj_coff_keep_raw_syms (abfd) = true; | 1165 | | | 1166 | 84 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1167 | 84 | obj_coff_keep_syms (abfd) = true; | 1168 | | | 1169 | 84 | obj_convert (abfd) = vars.sym_table; | 1170 | 84 | obj_conv_table_size (abfd) = vars.sym_index; | 1171 | | | 1172 | 84 | obj_coff_strings (abfd) = vars.string_table; | 1173 | 84 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1174 | 84 | obj_coff_keep_strings (abfd) = true; | 1175 | | | 1176 | 84 | return true; | 1177 | | | 1178 | 10 | error_return: | 1179 | 10 | free (vars.bim->buffer); | 1180 | 10 | free (vars.bim); | 1181 | | return false; | 1182 | 84 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_build_a_bfd pei-sh.c:pe_ILF_build_a_bfd Line | Count | Source | 805 | 306 | { | 806 | 306 | bfd_byte * ptr; | 807 | 306 | pe_ILF_vars vars; | 808 | 306 | struct internal_filehdr internal_f; | 809 | 306 | unsigned int import_type; | 810 | 306 | unsigned int import_name_type; | 811 | 306 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 812 | 306 | coff_symbol_type ** imp_sym; | 813 | 306 | unsigned int imp_index; | 814 | 306 | intptr_t alignment; | 815 | | | 816 | | /* Decode and verify the types field of the ILF structure. */ | 817 | 306 | import_type = types & 0x3; | 818 | 306 | import_name_type = (types & 0x1c) >> 2; | 819 | | | 820 | 306 | switch (import_type) | 821 | 306 | { | 822 | 114 | case IMPORT_CODE: | 823 | 185 | case IMPORT_DATA: | 824 | 233 | case IMPORT_CONST: | 825 | 233 | break; | 826 | | | 827 | 73 | default: | 828 | | /* xgettext:c-format */ | 829 | 73 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 830 | 73 | abfd, import_type); | 831 | 73 | return false; | 832 | 306 | } | 833 | | | 834 | 233 | switch (import_name_type) | 835 | 233 | { | 836 | 53 | case IMPORT_ORDINAL: | 837 | 71 | case IMPORT_NAME: | 838 | 91 | case IMPORT_NAME_NOPREFIX: | 839 | 175 | case IMPORT_NAME_UNDECORATE: | 840 | 175 | import_name = symbol_name; | 841 | 175 | break; | 842 | | | 843 | 48 | case IMPORT_NAME_EXPORTAS: | 844 | 48 | if (!import_name || !import_name[0]) | 845 | 29 | { | 846 | 29 | _bfd_error_handler (_("%pB: missing import name for " | 847 | 29 | "IMPORT_NAME_EXPORTAS for %s"), | 848 | 29 | abfd, symbol_name); | 849 | 29 | return false; | 850 | 29 | } | 851 | 19 | break; | 852 | | | 853 | 19 | default: | 854 | | /* xgettext:c-format */ | 855 | 10 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 856 | 10 | abfd, import_name_type); | 857 | 10 | return false; | 858 | 233 | } | 859 | | | 860 | | /* Initialise local variables. | 861 | | | 862 | | Note these are kept in a structure rather than being | 863 | | declared as statics since bfd frowns on global variables. | 864 | | | 865 | | We are going to construct the contents of the BFD in memory, | 866 | | so allocate all the space that we will need right now. */ | 867 | 194 | vars.bim | 868 | 194 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 869 | 194 | if (vars.bim == NULL) | 870 | 0 | return false; | 871 | | | 872 | 194 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 873 | 194 | vars.bim->buffer = ptr; | 874 | 194 | vars.bim->size = ILF_DATA_SIZE; | 875 | 194 | vars.bim->capacity = ILF_DATA_SIZE; | 876 | 194 | if (ptr == NULL) | 877 | 0 | goto error_return; | 878 | | | 879 | | /* Initialise the pointers to regions of the memory and the | 880 | | other contents of the pe_ILF_vars structure as well. */ | 881 | 194 | vars.sym_cache = (coff_symbol_type *) ptr; | 882 | 194 | vars.sym_ptr = (coff_symbol_type *) ptr; | 883 | 194 | vars.sym_index = 0; | 884 | 194 | ptr += SIZEOF_ILF_SYMS; | 885 | | | 886 | 194 | vars.sym_table = (unsigned int *) ptr; | 887 | 194 | vars.table_ptr = (unsigned int *) ptr; | 888 | 194 | ptr += SIZEOF_ILF_SYM_TABLE; | 889 | | | 890 | 194 | vars.native_syms = (combined_entry_type *) ptr; | 891 | 194 | vars.native_ptr = (combined_entry_type *) ptr; | 892 | 194 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 893 | | | 894 | 194 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 895 | 194 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 896 | 194 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 897 | | | 898 | 194 | vars.esym_table = (SYMENT *) ptr; | 899 | 194 | vars.esym_ptr = (SYMENT *) ptr; | 900 | 194 | ptr += SIZEOF_ILF_EXT_SYMS; | 901 | | | 902 | 194 | vars.reltab = (arelent *) ptr; | 903 | 194 | vars.relcount = 0; | 904 | 194 | ptr += SIZEOF_ILF_RELOCS; | 905 | | | 906 | 194 | vars.int_reltab = (struct internal_reloc *) ptr; | 907 | 194 | ptr += SIZEOF_ILF_INT_RELOCS; | 908 | | | 909 | 194 | vars.string_table = (char *) ptr; | 910 | 194 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 911 | 194 | ptr += SIZEOF_ILF_STRINGS; | 912 | 194 | vars.end_string_ptr = (char *) ptr; | 913 | | | 914 | | /* The remaining space in bim->buffer is used | 915 | | by the pe_ILF_make_a_section() function. */ | 916 | | | 917 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 918 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 919 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 920 | | alignment. */ | 921 | 194 | #if GCC_VERSION >= 3000 | 922 | 194 | alignment = __alignof__ (struct coff_section_tdata); | 923 | | #else | 924 | | alignment = 8; | 925 | | #endif | 926 | 194 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 927 | | | 928 | 194 | vars.data = ptr; | 929 | 194 | vars.abfd = abfd; | 930 | 194 | vars.sec_index = 0; | 931 | 194 | vars.magic = magic; | 932 | | | 933 | | /* Create the initial .idata$<n> sections: | 934 | | [.idata$2: Import Directory Table -- not needed] | 935 | | .idata$4: Import Lookup Table | 936 | | .idata$5: Import Address Table | 937 | | | 938 | | Note we do not create a .idata$3 section as this is | 939 | | created for us by the linker script. */ | 940 | 194 | id4 = pe_ILF_make_a_section (&vars, ".idata$4", SIZEOF_IDATA4, 0); | 941 | 194 | id5 = pe_ILF_make_a_section (&vars, ".idata$5", SIZEOF_IDATA5, 0); | 942 | 194 | if (id4 == NULL || id5 == NULL) | 943 | 0 | goto error_return; | 944 | | | 945 | | /* Fill in the contents of these sections. */ | 946 | 194 | if (import_name_type == IMPORT_ORDINAL) | 947 | 53 | { | 948 | 53 | if (ordinal == 0) | 949 | | /* See PR 20907 for a reproducer. */ | 950 | 9 | goto error_return; | 951 | | | 952 | | #if (defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) \ | 953 | | || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64)) | 954 | | ((unsigned int *) id4->contents)[0] = ordinal; | 955 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 956 | | ((unsigned int *) id5->contents)[0] = ordinal; | 957 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 958 | | #else | 959 | 44 | ((unsigned int *) id4->contents)[0] = ordinal | 0x80000000; | 960 | 44 | ((unsigned int *) id5->contents)[0] = ordinal | 0x80000000; | 961 | 44 | #endif | 962 | 44 | } | 963 | 141 | else | 964 | 141 | { | 965 | 141 | char *symbol; | 966 | 141 | unsigned int len; | 967 | | | 968 | | /* Create .idata$6 - the Hint Name Table. */ | 969 | 141 | id6 = pe_ILF_make_a_section (&vars, ".idata$6", SIZEOF_IDATA6, 0); | 970 | 141 | if (id6 == NULL) | 971 | 0 | goto error_return; | 972 | | | 973 | | /* If necessary, trim the import symbol name. */ | 974 | 141 | symbol = import_name; | 975 | | | 976 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 977 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 978 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 979 | | of these is used for a symbol. We strip this leading char for | 980 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 981 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 982 | | | 983 | 141 | if (import_name_type != IMPORT_NAME | 984 | 123 | && import_name_type != IMPORT_NAME_EXPORTAS) | 985 | 104 | { | 986 | 104 | char c = symbol[0]; | 987 | | | 988 | | /* Check that we don't remove for targets with empty | 989 | | USER_LABEL_PREFIX the leading underscore. */ | 990 | 104 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 991 | 92 | || c == '@' || c == '?') | 992 | 30 | symbol++; | 993 | 104 | } | 994 | | | 995 | 141 | len = strlen (symbol); | 996 | 141 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 997 | 84 | { | 998 | | /* Truncate at the first '@'. */ | 999 | 84 | char *at = strchr (symbol, '@'); | 1000 | | | 1001 | 84 | if (at != NULL) | 1002 | 13 | len = at - symbol; | 1003 | 84 | } | 1004 | | | 1005 | 141 | id6->contents[0] = ordinal & 0xff; | 1006 | 141 | id6->contents[1] = ordinal >> 8; | 1007 | | | 1008 | 141 | memcpy ((char *) id6->contents + 2, symbol, len); | 1009 | 141 | id6->contents[len + 2] = '\0'; | 1010 | 141 | } | 1011 | | | 1012 | 185 | if (import_name_type != IMPORT_ORDINAL) | 1013 | 141 | { | 1014 | 141 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1015 | 141 | pe_ILF_save_relocs (&vars, id4); | 1016 | | | 1017 | 141 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1018 | 141 | pe_ILF_save_relocs (&vars, id5); | 1019 | 141 | } | 1020 | | | 1021 | | /* Create an import symbol. */ | 1022 | 185 | pe_ILF_make_a_symbol (&vars, "__imp_", symbol_name, id5, 0); | 1023 | 185 | imp_sym = vars.sym_ptr_ptr - 1; | 1024 | 185 | imp_index = vars.sym_index - 1; | 1025 | | | 1026 | | /* Create extra sections depending upon the type of import we are | 1027 | | dealing with. */ | 1028 | 185 | switch (import_type) | 1029 | 185 | { | 1030 | 0 | int i; | 1031 | | | 1032 | 81 | case IMPORT_CODE: | 1033 | | /* CODE functions are special, in that they get a trampoline that | 1034 | | jumps to the main import symbol. Create a .text section to hold it. | 1035 | | First we need to look up its contents in the jump table. */ | 1036 | 162 | for (i = NUM_ENTRIES (jtab); i--;) | 1037 | 162 | { | 1038 | 162 | if (jtab[i].size == 0) | 1039 | 81 | continue; | 1040 | 81 | if (jtab[i].magic == magic) | 1041 | 81 | break; | 1042 | 81 | } | 1043 | | /* If we did not find a matching entry something is wrong. */ | 1044 | 81 | if (i < 0) | 1045 | 0 | abort (); | 1046 | | | 1047 | | /* Create the .text section. */ | 1048 | 81 | text = pe_ILF_make_a_section (&vars, ".text", jtab[i].size, SEC_CODE); | 1049 | 81 | if (text == NULL) | 1050 | 0 | goto error_return; | 1051 | | | 1052 | | /* Copy in the jump code. */ | 1053 | 81 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1054 | | | 1055 | | /* Create a reloc for the data in the text section. */ | 1056 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1057 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1058 | | { | 1059 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1060 | | (struct bfd_symbol **) imp_sym, | 1061 | | imp_index); | 1062 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1063 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1064 | | (struct bfd_symbol **) imp_sym, | 1065 | | imp_index); | 1066 | | } | 1067 | | else | 1068 | | #endif | 1069 | | #ifdef AMD64MAGIC | 1070 | | if (magic == AMD64MAGIC) | 1071 | | { | 1072 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1073 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1074 | | imp_index); | 1075 | | } | 1076 | | else | 1077 | | #endif | 1078 | 81 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1079 | 81 | BFD_RELOC_32, (asymbol **) imp_sym, | 1080 | 81 | imp_index); | 1081 | | | 1082 | 81 | pe_ILF_save_relocs (&vars, text); | 1083 | 81 | break; | 1084 | | | 1085 | 65 | case IMPORT_DATA: | 1086 | 104 | case IMPORT_CONST: | 1087 | 104 | break; | 1088 | | | 1089 | 0 | default: | 1090 | | /* XXX code not yet written. */ | 1091 | 0 | abort (); | 1092 | 185 | } | 1093 | | | 1094 | | /* Now create a symbol describing the imported value. */ | 1095 | 185 | switch (import_type) | 1096 | 185 | { | 1097 | 81 | case IMPORT_CODE: | 1098 | 81 | pe_ILF_make_a_symbol (&vars, "", symbol_name, text, | 1099 | 81 | BSF_NOT_AT_END | BSF_FUNCTION); | 1100 | | | 1101 | 81 | break; | 1102 | | | 1103 | 65 | case IMPORT_DATA: | 1104 | | /* Nothing to do here. */ | 1105 | 65 | break; | 1106 | | | 1107 | 39 | case IMPORT_CONST: | 1108 | 39 | pe_ILF_make_a_symbol (&vars, "", symbol_name, id5, 0); | 1109 | 39 | break; | 1110 | | | 1111 | 0 | default: | 1112 | | /* XXX code not yet written. */ | 1113 | 0 | abort (); | 1114 | 185 | } | 1115 | | | 1116 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1117 | 185 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1118 | 185 | if (ptr) | 1119 | 21 | *ptr = 0; | 1120 | 185 | pe_ILF_make_a_symbol (&vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1121 | 185 | if (ptr) | 1122 | 21 | *ptr = '.'; | 1123 | | | 1124 | | /* Initialise the bfd. */ | 1125 | 185 | memset (&internal_f, 0, sizeof (internal_f)); | 1126 | | | 1127 | 185 | internal_f.f_magic = magic; | 1128 | 185 | internal_f.f_symptr = 0; | 1129 | 185 | internal_f.f_nsyms = 0; | 1130 | 185 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1131 | | | 1132 | 185 | if (!bfd_set_start_address (abfd, (bfd_vma) 0) | 1133 | 185 | || !bfd_coff_set_arch_mach_hook (abfd, &internal_f)) | 1134 | 0 | goto error_return; | 1135 | | | 1136 | 185 | if (bfd_coff_mkobject_hook (abfd, (void *) &internal_f, NULL) == NULL) | 1137 | 0 | goto error_return; | 1138 | | | 1139 | 185 | obj_pe (abfd) = true; | 1140 | | #ifdef THUMBPEMAGIC | 1141 | | if (vars.magic == THUMBPEMAGIC) | 1142 | | /* Stop some linker warnings about thumb code not supporting | 1143 | | interworking. */ | 1144 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1145 | | #endif | 1146 | | | 1147 | | /* Switch from file contents to memory contents. */ | 1148 | 185 | bfd_cache_close (abfd); | 1149 | | | 1150 | 185 | abfd->iostream = (void *) vars.bim; | 1151 | 185 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1152 | 185 | abfd->iovec = &_bfd_memory_iovec; | 1153 | 185 | abfd->where = 0; | 1154 | 185 | abfd->origin = 0; | 1155 | 185 | abfd->size = 0; | 1156 | 185 | obj_sym_filepos (abfd) = 0; | 1157 | | | 1158 | | /* Point the bfd at the symbol table. */ | 1159 | 185 | obj_symbols (abfd) = vars.sym_cache; | 1160 | 185 | abfd->symcount = vars.sym_index; | 1161 | | | 1162 | 185 | obj_raw_syments (abfd) = vars.native_syms; | 1163 | 185 | obj_raw_syment_count (abfd) = vars.sym_index; | 1164 | 185 | obj_coff_keep_raw_syms (abfd) = true; | 1165 | | | 1166 | 185 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1167 | 185 | obj_coff_keep_syms (abfd) = true; | 1168 | | | 1169 | 185 | obj_convert (abfd) = vars.sym_table; | 1170 | 185 | obj_conv_table_size (abfd) = vars.sym_index; | 1171 | | | 1172 | 185 | obj_coff_strings (abfd) = vars.string_table; | 1173 | 185 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1174 | 185 | obj_coff_keep_strings (abfd) = true; | 1175 | | | 1176 | 185 | return true; | 1177 | | | 1178 | 9 | error_return: | 1179 | 9 | free (vars.bim->buffer); | 1180 | 9 | free (vars.bim); | 1181 | | return false; | 1182 | 185 | } |
|
1183 | | |
1184 | | /* Cleanup function, returned from check_format hook. */ |
1185 | | |
1186 | | static void |
1187 | | pe_ILF_cleanup (bfd *abfd) |
1188 | 90 | { |
1189 | 90 | coff_object_cleanup (abfd); |
1190 | | |
1191 | 90 | struct bfd_in_memory *bim = abfd->iostream; |
1192 | 90 | free (bim->buffer); |
1193 | 90 | free (bim); |
1194 | 90 | abfd->iostream = NULL; |
1195 | 90 | } 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 | 1188 | 45 | { | 1189 | 45 | coff_object_cleanup (abfd); | 1190 | | | 1191 | 45 | struct bfd_in_memory *bim = abfd->iostream; | 1192 | 45 | free (bim->buffer); | 1193 | 45 | free (bim); | 1194 | | abfd->iostream = NULL; | 1195 | 45 | } |
Line | Count | Source | 1188 | 45 | { | 1189 | 45 | coff_object_cleanup (abfd); | 1190 | | | 1191 | 45 | struct bfd_in_memory *bim = abfd->iostream; | 1192 | 45 | free (bim->buffer); | 1193 | 45 | free (bim); | 1194 | | abfd->iostream = NULL; | 1195 | 45 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_cleanup Unexecuted instantiation: pei-sh.c:pe_ILF_cleanup |
1196 | | |
1197 | | /* We have detected an Import Library Format archive element. |
1198 | | Decode the element and return the appropriate target. */ |
1199 | | |
1200 | | static bfd_cleanup |
1201 | | pe_ILF_object_p (bfd *abfd) |
1202 | 39.8k | { |
1203 | 39.8k | bfd_byte buffer[14]; |
1204 | 39.8k | bfd_byte * ptr; |
1205 | 39.8k | char * symbol_name; |
1206 | 39.8k | char * source_dll; |
1207 | 39.8k | char * import_name; |
1208 | 39.8k | unsigned int machine; |
1209 | 39.8k | bfd_size_type size; |
1210 | 39.8k | unsigned int ordinal; |
1211 | 39.8k | unsigned int types; |
1212 | 39.8k | unsigned int magic; |
1213 | | |
1214 | | /* Upon entry the first six bytes of the ILF header have |
1215 | | already been read. Now read the rest of the header. */ |
1216 | 39.8k | if (bfd_read (buffer, 14, abfd) != 14) |
1217 | 580 | return NULL; |
1218 | | |
1219 | 39.3k | ptr = buffer; |
1220 | | |
1221 | 39.3k | machine = H_GET_16 (abfd, ptr); |
1222 | 39.3k | ptr += 2; |
1223 | | |
1224 | | /* Check that the machine type is recognised. */ |
1225 | 39.3k | magic = 0; |
1226 | | |
1227 | 39.3k | switch (machine) |
1228 | 39.3k | { |
1229 | 122 | case IMAGE_FILE_MACHINE_UNKNOWN: |
1230 | 208 | case IMAGE_FILE_MACHINE_ALPHA: |
1231 | 276 | case IMAGE_FILE_MACHINE_ALPHA64: |
1232 | 371 | case IMAGE_FILE_MACHINE_IA64: |
1233 | 371 | break; |
1234 | | |
1235 | 3.22k | case IMAGE_FILE_MACHINE_I386: |
1236 | | #ifdef I386MAGIC |
1237 | 434 | magic = I386MAGIC; |
1238 | | #endif |
1239 | 3.22k | break; |
1240 | | |
1241 | 2.55k | case IMAGE_FILE_MACHINE_AMD64: |
1242 | | #ifdef AMD64MAGIC |
1243 | 341 | magic = AMD64MAGIC; |
1244 | | #endif |
1245 | 2.55k | break; |
1246 | | |
1247 | 59 | case IMAGE_FILE_MACHINE_R3000: |
1248 | 118 | case IMAGE_FILE_MACHINE_R4000: |
1249 | 199 | case IMAGE_FILE_MACHINE_R10000: |
1250 | | |
1251 | 267 | case IMAGE_FILE_MACHINE_MIPS16: |
1252 | 321 | case IMAGE_FILE_MACHINE_MIPSFPU: |
1253 | 398 | case IMAGE_FILE_MACHINE_MIPSFPU16: |
1254 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
1255 | | magic = MIPS_ARCH_MAGIC_WINCE; |
1256 | | #endif |
1257 | 398 | break; |
1258 | | |
1259 | 10.6k | case IMAGE_FILE_MACHINE_SH3: |
1260 | 12.4k | case IMAGE_FILE_MACHINE_SH4: |
1261 | | #ifdef SH_ARCH_MAGIC_WINCE |
1262 | 1.43k | magic = SH_ARCH_MAGIC_WINCE; |
1263 | | #endif |
1264 | 12.4k | break; |
1265 | | |
1266 | 1.64k | case IMAGE_FILE_MACHINE_ARM: |
1267 | | #ifdef ARMPEMAGIC |
1268 | 421 | magic = ARMPEMAGIC; |
1269 | | #endif |
1270 | 1.64k | break; |
1271 | | |
1272 | 3.06k | case IMAGE_FILE_MACHINE_ARM64: |
1273 | | #ifdef AARCH64MAGIC |
1274 | 405 | magic = AARCH64MAGIC; |
1275 | | #endif |
1276 | 3.06k | break; |
1277 | | |
1278 | 3.04k | case IMAGE_FILE_MACHINE_LOONGARCH64: |
1279 | | #ifdef LOONGARCH64MAGIC |
1280 | 396 | magic = LOONGARCH64MAGIC; |
1281 | | #endif |
1282 | 3.04k | break; |
1283 | | |
1284 | 3.18k | case IMAGE_FILE_MACHINE_RISCV64: |
1285 | | #ifdef RISCV64MAGIC |
1286 | 415 | magic = RISCV64MAGIC; |
1287 | | #endif |
1288 | 3.18k | break; |
1289 | | |
1290 | 1.84k | case IMAGE_FILE_MACHINE_THUMB: |
1291 | | #ifdef THUMBPEMAGIC |
1292 | | { |
1293 | | extern const bfd_target TARGET_LITTLE_SYM; |
1294 | | |
1295 | 382 | if (abfd->xvec == &TARGET_LITTLE_SYM) |
1296 | 374 | magic = THUMBPEMAGIC; |
1297 | | } |
1298 | | #endif |
1299 | 1.84k | break; |
1300 | | |
1301 | 0 | case IMAGE_FILE_MACHINE_POWERPC: |
1302 | | /* We no longer support PowerPC. */ |
1303 | 7.52k | default: |
1304 | 7.52k | _bfd_error_handler |
1305 | | /* xgettext:c-format */ |
1306 | 7.52k | (_("%pB: unrecognised machine type (0x%x)" |
1307 | 7.52k | " in Import Library Format archive"), |
1308 | 7.52k | abfd, machine); |
1309 | 7.52k | bfd_set_error (bfd_error_malformed_archive); |
1310 | | |
1311 | 7.52k | return NULL; |
1312 | 0 | break; |
1313 | 39.3k | } |
1314 | | |
1315 | 31.7k | if (magic == 0) |
1316 | 27.5k | { |
1317 | 27.5k | _bfd_error_handler |
1318 | | /* xgettext:c-format */ |
1319 | 27.5k | (_("%pB: recognised but unhandled machine type (0x%x)" |
1320 | 27.5k | " in Import Library Format archive"), |
1321 | 27.5k | abfd, machine); |
1322 | 27.5k | bfd_set_error (bfd_error_wrong_format); |
1323 | | |
1324 | 27.5k | return NULL; |
1325 | 27.5k | } |
1326 | | |
1327 | | /* We do not bother to check the date. |
1328 | | date = H_GET_32 (abfd, ptr); */ |
1329 | 4.22k | ptr += 4; |
1330 | | |
1331 | 4.22k | size = H_GET_32 (abfd, ptr); |
1332 | 4.22k | ptr += 4; |
1333 | | |
1334 | 4.22k | if (size == 0) |
1335 | 86 | { |
1336 | 86 | _bfd_error_handler |
1337 | 86 | (_("%pB: size field is zero in Import Library Format header"), abfd); |
1338 | 86 | bfd_set_error (bfd_error_malformed_archive); |
1339 | | |
1340 | 86 | return NULL; |
1341 | 86 | } |
1342 | | |
1343 | 4.13k | ordinal = H_GET_16 (abfd, ptr); |
1344 | 4.13k | ptr += 2; |
1345 | | |
1346 | 4.13k | types = H_GET_16 (abfd, ptr); |
1347 | | /* ptr += 2; */ |
1348 | | |
1349 | | /* Now read in the two strings that follow. */ |
1350 | 4.13k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); |
1351 | 4.13k | if (ptr == NULL) |
1352 | 1.83k | return NULL; |
1353 | | |
1354 | 2.30k | symbol_name = (char *) ptr; |
1355 | | /* See PR 20905 for an example of where the strnlen is necessary. */ |
1356 | 2.30k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; |
1357 | | |
1358 | | /* Verify that the strings are null terminated. */ |
1359 | 2.30k | if (ptr[size - 1] != 0 |
1360 | 1.48k | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) |
1361 | 886 | { |
1362 | 886 | _bfd_error_handler |
1363 | 886 | (_("%pB: string not null terminated in ILF object file"), abfd); |
1364 | 886 | bfd_set_error (bfd_error_malformed_archive); |
1365 | 886 | bfd_release (abfd, ptr); |
1366 | 886 | return NULL; |
1367 | 886 | } |
1368 | | |
1369 | | /* An ILF file may contain a third string, after source_dll; this is |
1370 | | used for IMPORT_NAME_EXPORTAS. We know from above that the whole |
1371 | | block of data is null terminated, ptr[size-1]==0, but we don't |
1372 | | know how many individual null terminated strings we have in there. |
1373 | | |
1374 | | First find the end of source_dll. */ |
1375 | 1.41k | import_name = source_dll + strlen (source_dll) + 1; |
1376 | 1.41k | if ((bfd_byte *) import_name >= ptr + size) |
1377 | 512 | { |
1378 | | /* If this points at the end of the ptr+size block, we only had |
1379 | | two strings. */ |
1380 | 512 | import_name = NULL; |
1381 | 512 | } |
1382 | | |
1383 | | /* Now construct the bfd. */ |
1384 | 1.41k | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, |
1385 | 1.41k | source_dll, ordinal, types, |
1386 | 1.41k | import_name)) |
1387 | 431 | { |
1388 | 431 | bfd_release (abfd, ptr); |
1389 | 431 | return NULL; |
1390 | 431 | } |
1391 | | |
1392 | 985 | return pe_ILF_cleanup; |
1393 | 1.41k | } pei-i386.c:pe_ILF_object_p Line | Count | Source | 1202 | 4.61k | { | 1203 | 4.61k | bfd_byte buffer[14]; | 1204 | 4.61k | bfd_byte * ptr; | 1205 | 4.61k | char * symbol_name; | 1206 | 4.61k | char * source_dll; | 1207 | 4.61k | char * import_name; | 1208 | 4.61k | unsigned int machine; | 1209 | 4.61k | bfd_size_type size; | 1210 | 4.61k | unsigned int ordinal; | 1211 | 4.61k | unsigned int types; | 1212 | 4.61k | unsigned int magic; | 1213 | | | 1214 | | /* Upon entry the first six bytes of the ILF header have | 1215 | | already been read. Now read the rest of the header. */ | 1216 | 4.61k | if (bfd_read (buffer, 14, abfd) != 14) | 1217 | 65 | return NULL; | 1218 | | | 1219 | 4.54k | ptr = buffer; | 1220 | | | 1221 | 4.54k | machine = H_GET_16 (abfd, ptr); | 1222 | 4.54k | ptr += 2; | 1223 | | | 1224 | | /* Check that the machine type is recognised. */ | 1225 | 4.54k | magic = 0; | 1226 | | | 1227 | 4.54k | switch (machine) | 1228 | 4.54k | { | 1229 | 12 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1230 | 22 | case IMAGE_FILE_MACHINE_ALPHA: | 1231 | 30 | case IMAGE_FILE_MACHINE_ALPHA64: | 1232 | 41 | case IMAGE_FILE_MACHINE_IA64: | 1233 | 41 | break; | 1234 | | | 1235 | 434 | case IMAGE_FILE_MACHINE_I386: | 1236 | 434 | #ifdef I386MAGIC | 1237 | 434 | magic = I386MAGIC; | 1238 | 434 | #endif | 1239 | 434 | break; | 1240 | | | 1241 | 291 | case IMAGE_FILE_MACHINE_AMD64: | 1242 | | #ifdef AMD64MAGIC | 1243 | | magic = AMD64MAGIC; | 1244 | | #endif | 1245 | 291 | break; | 1246 | | | 1247 | 6 | case IMAGE_FILE_MACHINE_R3000: | 1248 | 13 | case IMAGE_FILE_MACHINE_R4000: | 1249 | 22 | case IMAGE_FILE_MACHINE_R10000: | 1250 | | | 1251 | 30 | case IMAGE_FILE_MACHINE_MIPS16: | 1252 | 36 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1253 | 45 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1254 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1255 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1256 | | #endif | 1257 | 45 | break; | 1258 | | | 1259 | 1.19k | case IMAGE_FILE_MACHINE_SH3: | 1260 | 1.40k | case IMAGE_FILE_MACHINE_SH4: | 1261 | | #ifdef SH_ARCH_MAGIC_WINCE | 1262 | | magic = SH_ARCH_MAGIC_WINCE; | 1263 | | #endif | 1264 | 1.40k | break; | 1265 | | | 1266 | 172 | case IMAGE_FILE_MACHINE_ARM: | 1267 | | #ifdef ARMPEMAGIC | 1268 | | magic = ARMPEMAGIC; | 1269 | | #endif | 1270 | 172 | break; | 1271 | | | 1272 | 351 | case IMAGE_FILE_MACHINE_ARM64: | 1273 | | #ifdef AARCH64MAGIC | 1274 | | magic = AARCH64MAGIC; | 1275 | | #endif | 1276 | 351 | break; | 1277 | | | 1278 | 348 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1279 | | #ifdef LOONGARCH64MAGIC | 1280 | | magic = LOONGARCH64MAGIC; | 1281 | | #endif | 1282 | 348 | break; | 1283 | | | 1284 | 362 | case IMAGE_FILE_MACHINE_RISCV64: | 1285 | | #ifdef RISCV64MAGIC | 1286 | | magic = RISCV64MAGIC; | 1287 | | #endif | 1288 | 362 | break; | 1289 | | | 1290 | 217 | case IMAGE_FILE_MACHINE_THUMB: | 1291 | | #ifdef THUMBPEMAGIC | 1292 | | { | 1293 | | extern const bfd_target TARGET_LITTLE_SYM; | 1294 | | | 1295 | | if (abfd->xvec == &TARGET_LITTLE_SYM) | 1296 | | magic = THUMBPEMAGIC; | 1297 | | } | 1298 | | #endif | 1299 | 217 | break; | 1300 | | | 1301 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1302 | | /* We no longer support PowerPC. */ | 1303 | 883 | default: | 1304 | 883 | _bfd_error_handler | 1305 | | /* xgettext:c-format */ | 1306 | 883 | (_("%pB: unrecognised machine type (0x%x)" | 1307 | 883 | " in Import Library Format archive"), | 1308 | 883 | abfd, machine); | 1309 | 883 | bfd_set_error (bfd_error_malformed_archive); | 1310 | | | 1311 | 883 | return NULL; | 1312 | 0 | break; | 1313 | 4.54k | } | 1314 | | | 1315 | 3.66k | if (magic == 0) | 1316 | 3.22k | { | 1317 | 3.22k | _bfd_error_handler | 1318 | | /* xgettext:c-format */ | 1319 | 3.22k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1320 | 3.22k | " in Import Library Format archive"), | 1321 | 3.22k | abfd, machine); | 1322 | 3.22k | bfd_set_error (bfd_error_wrong_format); | 1323 | | | 1324 | 3.22k | return NULL; | 1325 | 3.22k | } | 1326 | | | 1327 | | /* We do not bother to check the date. | 1328 | | date = H_GET_32 (abfd, ptr); */ | 1329 | 434 | ptr += 4; | 1330 | | | 1331 | 434 | size = H_GET_32 (abfd, ptr); | 1332 | 434 | ptr += 4; | 1333 | | | 1334 | 434 | if (size == 0) | 1335 | 11 | { | 1336 | 11 | _bfd_error_handler | 1337 | 11 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1338 | 11 | bfd_set_error (bfd_error_malformed_archive); | 1339 | | | 1340 | 11 | return NULL; | 1341 | 11 | } | 1342 | | | 1343 | 423 | ordinal = H_GET_16 (abfd, ptr); | 1344 | 423 | ptr += 2; | 1345 | | | 1346 | 423 | types = H_GET_16 (abfd, ptr); | 1347 | | /* ptr += 2; */ | 1348 | | | 1349 | | /* Now read in the two strings that follow. */ | 1350 | 423 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1351 | 423 | if (ptr == NULL) | 1352 | 209 | return NULL; | 1353 | | | 1354 | 214 | symbol_name = (char *) ptr; | 1355 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1356 | 214 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1357 | | | 1358 | | /* Verify that the strings are null terminated. */ | 1359 | 214 | if (ptr[size - 1] != 0 | 1360 | 204 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1361 | 19 | { | 1362 | 19 | _bfd_error_handler | 1363 | 19 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1364 | 19 | bfd_set_error (bfd_error_malformed_archive); | 1365 | 19 | bfd_release (abfd, ptr); | 1366 | 19 | return NULL; | 1367 | 19 | } | 1368 | | | 1369 | | /* An ILF file may contain a third string, after source_dll; this is | 1370 | | used for IMPORT_NAME_EXPORTAS. We know from above that the whole | 1371 | | block of data is null terminated, ptr[size-1]==0, but we don't | 1372 | | know how many individual null terminated strings we have in there. | 1373 | | | 1374 | | First find the end of source_dll. */ | 1375 | 195 | import_name = source_dll + strlen (source_dll) + 1; | 1376 | 195 | if ((bfd_byte *) import_name >= ptr + size) | 1377 | 68 | { | 1378 | | /* If this points at the end of the ptr+size block, we only had | 1379 | | two strings. */ | 1380 | 68 | import_name = NULL; | 1381 | 68 | } | 1382 | | | 1383 | | /* Now construct the bfd. */ | 1384 | 195 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1385 | 195 | source_dll, ordinal, types, | 1386 | 195 | import_name)) | 1387 | 42 | { | 1388 | 42 | bfd_release (abfd, ptr); | 1389 | 42 | return NULL; | 1390 | 42 | } | 1391 | | | 1392 | 153 | return pe_ILF_cleanup; | 1393 | 195 | } |
pei-x86_64.c:pe_ILF_object_p Line | Count | Source | 1202 | 4.56k | { | 1203 | 4.56k | bfd_byte buffer[14]; | 1204 | 4.56k | bfd_byte * ptr; | 1205 | 4.56k | char * symbol_name; | 1206 | 4.56k | char * source_dll; | 1207 | 4.56k | char * import_name; | 1208 | 4.56k | unsigned int machine; | 1209 | 4.56k | bfd_size_type size; | 1210 | 4.56k | unsigned int ordinal; | 1211 | 4.56k | unsigned int types; | 1212 | 4.56k | unsigned int magic; | 1213 | | | 1214 | | /* Upon entry the first six bytes of the ILF header have | 1215 | | already been read. Now read the rest of the header. */ | 1216 | 4.56k | if (bfd_read (buffer, 14, abfd) != 14) | 1217 | 65 | return NULL; | 1218 | | | 1219 | 4.49k | ptr = buffer; | 1220 | | | 1221 | 4.49k | machine = H_GET_16 (abfd, ptr); | 1222 | 4.49k | ptr += 2; | 1223 | | | 1224 | | /* Check that the machine type is recognised. */ | 1225 | 4.49k | magic = 0; | 1226 | | | 1227 | 4.49k | switch (machine) | 1228 | 4.49k | { | 1229 | 12 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1230 | 22 | case IMAGE_FILE_MACHINE_ALPHA: | 1231 | 30 | case IMAGE_FILE_MACHINE_ALPHA64: | 1232 | 41 | case IMAGE_FILE_MACHINE_IA64: | 1233 | 41 | break; | 1234 | | | 1235 | 366 | case IMAGE_FILE_MACHINE_I386: | 1236 | | #ifdef I386MAGIC | 1237 | | magic = I386MAGIC; | 1238 | | #endif | 1239 | 366 | break; | 1240 | | | 1241 | 341 | case IMAGE_FILE_MACHINE_AMD64: | 1242 | 341 | #ifdef AMD64MAGIC | 1243 | 341 | magic = AMD64MAGIC; | 1244 | 341 | #endif | 1245 | 341 | break; | 1246 | | | 1247 | 6 | case IMAGE_FILE_MACHINE_R3000: | 1248 | 13 | case IMAGE_FILE_MACHINE_R4000: | 1249 | 22 | case IMAGE_FILE_MACHINE_R10000: | 1250 | | | 1251 | 30 | case IMAGE_FILE_MACHINE_MIPS16: | 1252 | 36 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1253 | 45 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1254 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1255 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1256 | | #endif | 1257 | 45 | break; | 1258 | | | 1259 | 1.16k | case IMAGE_FILE_MACHINE_SH3: | 1260 | 1.37k | case IMAGE_FILE_MACHINE_SH4: | 1261 | | #ifdef SH_ARCH_MAGIC_WINCE | 1262 | | magic = SH_ARCH_MAGIC_WINCE; | 1263 | | #endif | 1264 | 1.37k | break; | 1265 | | | 1266 | 172 | case IMAGE_FILE_MACHINE_ARM: | 1267 | | #ifdef ARMPEMAGIC | 1268 | | magic = ARMPEMAGIC; | 1269 | | #endif | 1270 | 172 | break; | 1271 | | | 1272 | 351 | case IMAGE_FILE_MACHINE_ARM64: | 1273 | | #ifdef AARCH64MAGIC | 1274 | | magic = AARCH64MAGIC; | 1275 | | #endif | 1276 | 351 | break; | 1277 | | | 1278 | 348 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1279 | | #ifdef LOONGARCH64MAGIC | 1280 | | magic = LOONGARCH64MAGIC; | 1281 | | #endif | 1282 | 348 | break; | 1283 | | | 1284 | 361 | case IMAGE_FILE_MACHINE_RISCV64: | 1285 | | #ifdef RISCV64MAGIC | 1286 | | magic = RISCV64MAGIC; | 1287 | | #endif | 1288 | 361 | break; | 1289 | | | 1290 | 217 | case IMAGE_FILE_MACHINE_THUMB: | 1291 | | #ifdef THUMBPEMAGIC | 1292 | | { | 1293 | | extern const bfd_target TARGET_LITTLE_SYM; | 1294 | | | 1295 | | if (abfd->xvec == &TARGET_LITTLE_SYM) | 1296 | | magic = THUMBPEMAGIC; | 1297 | | } | 1298 | | #endif | 1299 | 217 | break; | 1300 | | | 1301 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1302 | | /* We no longer support PowerPC. */ | 1303 | 883 | default: | 1304 | 883 | _bfd_error_handler | 1305 | | /* xgettext:c-format */ | 1306 | 883 | (_("%pB: unrecognised machine type (0x%x)" | 1307 | 883 | " in Import Library Format archive"), | 1308 | 883 | abfd, machine); | 1309 | 883 | bfd_set_error (bfd_error_malformed_archive); | 1310 | | | 1311 | 883 | return NULL; | 1312 | 0 | break; | 1313 | 4.49k | } | 1314 | | | 1315 | 3.61k | if (magic == 0) | 1316 | 3.27k | { | 1317 | 3.27k | _bfd_error_handler | 1318 | | /* xgettext:c-format */ | 1319 | 3.27k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1320 | 3.27k | " in Import Library Format archive"), | 1321 | 3.27k | abfd, machine); | 1322 | 3.27k | bfd_set_error (bfd_error_wrong_format); | 1323 | | | 1324 | 3.27k | return NULL; | 1325 | 3.27k | } | 1326 | | | 1327 | | /* We do not bother to check the date. | 1328 | | date = H_GET_32 (abfd, ptr); */ | 1329 | 341 | ptr += 4; | 1330 | | | 1331 | 341 | size = H_GET_32 (abfd, ptr); | 1332 | 341 | ptr += 4; | 1333 | | | 1334 | 341 | if (size == 0) | 1335 | 8 | { | 1336 | 8 | _bfd_error_handler | 1337 | 8 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1338 | 8 | bfd_set_error (bfd_error_malformed_archive); | 1339 | | | 1340 | 8 | return NULL; | 1341 | 8 | } | 1342 | | | 1343 | 333 | ordinal = H_GET_16 (abfd, ptr); | 1344 | 333 | ptr += 2; | 1345 | | | 1346 | 333 | types = H_GET_16 (abfd, ptr); | 1347 | | /* ptr += 2; */ | 1348 | | | 1349 | | /* Now read in the two strings that follow. */ | 1350 | 333 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1351 | 333 | if (ptr == NULL) | 1352 | 153 | return NULL; | 1353 | | | 1354 | 180 | symbol_name = (char *) ptr; | 1355 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1356 | 180 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1357 | | | 1358 | | /* Verify that the strings are null terminated. */ | 1359 | 180 | if (ptr[size - 1] != 0 | 1360 | 168 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1361 | 19 | { | 1362 | 19 | _bfd_error_handler | 1363 | 19 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1364 | 19 | bfd_set_error (bfd_error_malformed_archive); | 1365 | 19 | bfd_release (abfd, ptr); | 1366 | 19 | return NULL; | 1367 | 19 | } | 1368 | | | 1369 | | /* An ILF file may contain a third string, after source_dll; this is | 1370 | | used for IMPORT_NAME_EXPORTAS. We know from above that the whole | 1371 | | block of data is null terminated, ptr[size-1]==0, but we don't | 1372 | | know how many individual null terminated strings we have in there. | 1373 | | | 1374 | | First find the end of source_dll. */ | 1375 | 161 | import_name = source_dll + strlen (source_dll) + 1; | 1376 | 161 | if ((bfd_byte *) import_name >= ptr + size) | 1377 | 71 | { | 1378 | | /* If this points at the end of the ptr+size block, we only had | 1379 | | two strings. */ | 1380 | 71 | import_name = NULL; | 1381 | 71 | } | 1382 | | | 1383 | | /* Now construct the bfd. */ | 1384 | 161 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1385 | 161 | source_dll, ordinal, types, | 1386 | 161 | import_name)) | 1387 | 45 | { | 1388 | 45 | bfd_release (abfd, ptr); | 1389 | 45 | return NULL; | 1390 | 45 | } | 1391 | | | 1392 | 116 | return pe_ILF_cleanup; | 1393 | 161 | } |
pei-aarch64.c:pe_ILF_object_p Line | Count | Source | 1202 | 4.60k | { | 1203 | 4.60k | bfd_byte buffer[14]; | 1204 | 4.60k | bfd_byte * ptr; | 1205 | 4.60k | char * symbol_name; | 1206 | 4.60k | char * source_dll; | 1207 | 4.60k | char * import_name; | 1208 | 4.60k | unsigned int machine; | 1209 | 4.60k | bfd_size_type size; | 1210 | 4.60k | unsigned int ordinal; | 1211 | 4.60k | unsigned int types; | 1212 | 4.60k | unsigned int magic; | 1213 | | | 1214 | | /* Upon entry the first six bytes of the ILF header have | 1215 | | already been read. Now read the rest of the header. */ | 1216 | 4.60k | if (bfd_read (buffer, 14, abfd) != 14) | 1217 | 65 | return NULL; | 1218 | | | 1219 | 4.53k | ptr = buffer; | 1220 | | | 1221 | 4.53k | machine = H_GET_16 (abfd, ptr); | 1222 | 4.53k | ptr += 2; | 1223 | | | 1224 | | /* Check that the machine type is recognised. */ | 1225 | 4.53k | magic = 0; | 1226 | | | 1227 | 4.53k | switch (machine) | 1228 | 4.53k | { | 1229 | 12 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1230 | 22 | case IMAGE_FILE_MACHINE_ALPHA: | 1231 | 30 | case IMAGE_FILE_MACHINE_ALPHA64: | 1232 | 41 | case IMAGE_FILE_MACHINE_IA64: | 1233 | 41 | break; | 1234 | | | 1235 | 368 | case IMAGE_FILE_MACHINE_I386: | 1236 | | #ifdef I386MAGIC | 1237 | | magic = I386MAGIC; | 1238 | | #endif | 1239 | 368 | break; | 1240 | | | 1241 | 291 | case IMAGE_FILE_MACHINE_AMD64: | 1242 | | #ifdef AMD64MAGIC | 1243 | | magic = AMD64MAGIC; | 1244 | | #endif | 1245 | 291 | break; | 1246 | | | 1247 | 6 | case IMAGE_FILE_MACHINE_R3000: | 1248 | 13 | case IMAGE_FILE_MACHINE_R4000: | 1249 | 22 | case IMAGE_FILE_MACHINE_R10000: | 1250 | | | 1251 | 30 | case IMAGE_FILE_MACHINE_MIPS16: | 1252 | 36 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1253 | 45 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1254 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1255 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1256 | | #endif | 1257 | 45 | break; | 1258 | | | 1259 | 1.19k | case IMAGE_FILE_MACHINE_SH3: | 1260 | 1.40k | case IMAGE_FILE_MACHINE_SH4: | 1261 | | #ifdef SH_ARCH_MAGIC_WINCE | 1262 | | magic = SH_ARCH_MAGIC_WINCE; | 1263 | | #endif | 1264 | 1.40k | break; | 1265 | | | 1266 | 177 | case IMAGE_FILE_MACHINE_ARM: | 1267 | | #ifdef ARMPEMAGIC | 1268 | | magic = ARMPEMAGIC; | 1269 | | #endif | 1270 | 177 | break; | 1271 | | | 1272 | 405 | case IMAGE_FILE_MACHINE_ARM64: | 1273 | 405 | #ifdef AARCH64MAGIC | 1274 | 405 | magic = AARCH64MAGIC; | 1275 | 405 | #endif | 1276 | 405 | break; | 1277 | | | 1278 | 348 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1279 | | #ifdef LOONGARCH64MAGIC | 1280 | | magic = LOONGARCH64MAGIC; | 1281 | | #endif | 1282 | 348 | break; | 1283 | | | 1284 | 362 | case IMAGE_FILE_MACHINE_RISCV64: | 1285 | | #ifdef RISCV64MAGIC | 1286 | | magic = RISCV64MAGIC; | 1287 | | #endif | 1288 | 362 | break; | 1289 | | | 1290 | 217 | case IMAGE_FILE_MACHINE_THUMB: | 1291 | | #ifdef THUMBPEMAGIC | 1292 | | { | 1293 | | extern const bfd_target TARGET_LITTLE_SYM; | 1294 | | | 1295 | | if (abfd->xvec == &TARGET_LITTLE_SYM) | 1296 | | magic = THUMBPEMAGIC; | 1297 | | } | 1298 | | #endif | 1299 | 217 | break; | 1300 | | | 1301 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1302 | | /* We no longer support PowerPC. */ | 1303 | 883 | default: | 1304 | 883 | _bfd_error_handler | 1305 | | /* xgettext:c-format */ | 1306 | 883 | (_("%pB: unrecognised machine type (0x%x)" | 1307 | 883 | " in Import Library Format archive"), | 1308 | 883 | abfd, machine); | 1309 | 883 | bfd_set_error (bfd_error_malformed_archive); | 1310 | | | 1311 | 883 | return NULL; | 1312 | 0 | break; | 1313 | 4.53k | } | 1314 | | | 1315 | 3.65k | if (magic == 0) | 1316 | 3.25k | { | 1317 | 3.25k | _bfd_error_handler | 1318 | | /* xgettext:c-format */ | 1319 | 3.25k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1320 | 3.25k | " in Import Library Format archive"), | 1321 | 3.25k | abfd, machine); | 1322 | 3.25k | bfd_set_error (bfd_error_wrong_format); | 1323 | | | 1324 | 3.25k | return NULL; | 1325 | 3.25k | } | 1326 | | | 1327 | | /* We do not bother to check the date. | 1328 | | date = H_GET_32 (abfd, ptr); */ | 1329 | 405 | ptr += 4; | 1330 | | | 1331 | 405 | size = H_GET_32 (abfd, ptr); | 1332 | 405 | ptr += 4; | 1333 | | | 1334 | 405 | if (size == 0) | 1335 | 11 | { | 1336 | 11 | _bfd_error_handler | 1337 | 11 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1338 | 11 | bfd_set_error (bfd_error_malformed_archive); | 1339 | | | 1340 | 11 | return NULL; | 1341 | 11 | } | 1342 | | | 1343 | 394 | ordinal = H_GET_16 (abfd, ptr); | 1344 | 394 | ptr += 2; | 1345 | | | 1346 | 394 | types = H_GET_16 (abfd, ptr); | 1347 | | /* ptr += 2; */ | 1348 | | | 1349 | | /* Now read in the two strings that follow. */ | 1350 | 394 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1351 | 394 | if (ptr == NULL) | 1352 | 207 | return NULL; | 1353 | | | 1354 | 187 | symbol_name = (char *) ptr; | 1355 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1356 | 187 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1357 | | | 1358 | | /* Verify that the strings are null terminated. */ | 1359 | 187 | if (ptr[size - 1] != 0 | 1360 | 177 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1361 | 19 | { | 1362 | 19 | _bfd_error_handler | 1363 | 19 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1364 | 19 | bfd_set_error (bfd_error_malformed_archive); | 1365 | 19 | bfd_release (abfd, ptr); | 1366 | 19 | return NULL; | 1367 | 19 | } | 1368 | | | 1369 | | /* An ILF file may contain a third string, after source_dll; this is | 1370 | | used for IMPORT_NAME_EXPORTAS. We know from above that the whole | 1371 | | block of data is null terminated, ptr[size-1]==0, but we don't | 1372 | | know how many individual null terminated strings we have in there. | 1373 | | | 1374 | | First find the end of source_dll. */ | 1375 | 168 | import_name = source_dll + strlen (source_dll) + 1; | 1376 | 168 | if ((bfd_byte *) import_name >= ptr + size) | 1377 | 60 | { | 1378 | | /* If this points at the end of the ptr+size block, we only had | 1379 | | two strings. */ | 1380 | 60 | import_name = NULL; | 1381 | 60 | } | 1382 | | | 1383 | | /* Now construct the bfd. */ | 1384 | 168 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1385 | 168 | source_dll, ordinal, types, | 1386 | 168 | import_name)) | 1387 | 45 | { | 1388 | 45 | bfd_release (abfd, ptr); | 1389 | 45 | return NULL; | 1390 | 45 | } | 1391 | | | 1392 | 123 | return pe_ILF_cleanup; | 1393 | 168 | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_object_p pei-loongarch64.c:pe_ILF_object_p Line | Count | Source | 1202 | 4.55k | { | 1203 | 4.55k | bfd_byte buffer[14]; | 1204 | 4.55k | bfd_byte * ptr; | 1205 | 4.55k | char * symbol_name; | 1206 | 4.55k | char * source_dll; | 1207 | 4.55k | char * import_name; | 1208 | 4.55k | unsigned int machine; | 1209 | 4.55k | bfd_size_type size; | 1210 | 4.55k | unsigned int ordinal; | 1211 | 4.55k | unsigned int types; | 1212 | 4.55k | unsigned int magic; | 1213 | | | 1214 | | /* Upon entry the first six bytes of the ILF header have | 1215 | | already been read. Now read the rest of the header. */ | 1216 | 4.55k | if (bfd_read (buffer, 14, abfd) != 14) | 1217 | 65 | return NULL; | 1218 | | | 1219 | 4.49k | ptr = buffer; | 1220 | | | 1221 | 4.49k | machine = H_GET_16 (abfd, ptr); | 1222 | 4.49k | ptr += 2; | 1223 | | | 1224 | | /* Check that the machine type is recognised. */ | 1225 | 4.49k | magic = 0; | 1226 | | | 1227 | 4.49k | switch (machine) | 1228 | 4.49k | { | 1229 | 12 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1230 | 22 | case IMAGE_FILE_MACHINE_ALPHA: | 1231 | 30 | case IMAGE_FILE_MACHINE_ALPHA64: | 1232 | 41 | case IMAGE_FILE_MACHINE_IA64: | 1233 | 41 | break; | 1234 | | | 1235 | 366 | case IMAGE_FILE_MACHINE_I386: | 1236 | | #ifdef I386MAGIC | 1237 | | magic = I386MAGIC; | 1238 | | #endif | 1239 | 366 | break; | 1240 | | | 1241 | 287 | case IMAGE_FILE_MACHINE_AMD64: | 1242 | | #ifdef AMD64MAGIC | 1243 | | magic = AMD64MAGIC; | 1244 | | #endif | 1245 | 287 | break; | 1246 | | | 1247 | 6 | case IMAGE_FILE_MACHINE_R3000: | 1248 | 13 | case IMAGE_FILE_MACHINE_R4000: | 1249 | 22 | case IMAGE_FILE_MACHINE_R10000: | 1250 | | | 1251 | 30 | case IMAGE_FILE_MACHINE_MIPS16: | 1252 | 36 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1253 | 45 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1254 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1255 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1256 | | #endif | 1257 | 45 | break; | 1258 | | | 1259 | 1.16k | case IMAGE_FILE_MACHINE_SH3: | 1260 | 1.37k | case IMAGE_FILE_MACHINE_SH4: | 1261 | | #ifdef SH_ARCH_MAGIC_WINCE | 1262 | | magic = SH_ARCH_MAGIC_WINCE; | 1263 | | #endif | 1264 | 1.37k | break; | 1265 | | | 1266 | 172 | case IMAGE_FILE_MACHINE_ARM: | 1267 | | #ifdef ARMPEMAGIC | 1268 | | magic = ARMPEMAGIC; | 1269 | | #endif | 1270 | 172 | break; | 1271 | | | 1272 | 351 | case IMAGE_FILE_MACHINE_ARM64: | 1273 | | #ifdef AARCH64MAGIC | 1274 | | magic = AARCH64MAGIC; | 1275 | | #endif | 1276 | 351 | break; | 1277 | | | 1278 | 396 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1279 | 396 | #ifdef LOONGARCH64MAGIC | 1280 | 396 | magic = LOONGARCH64MAGIC; | 1281 | 396 | #endif | 1282 | 396 | break; | 1283 | | | 1284 | 361 | case IMAGE_FILE_MACHINE_RISCV64: | 1285 | | #ifdef RISCV64MAGIC | 1286 | | magic = RISCV64MAGIC; | 1287 | | #endif | 1288 | 361 | break; | 1289 | | | 1290 | 217 | case IMAGE_FILE_MACHINE_THUMB: | 1291 | | #ifdef THUMBPEMAGIC | 1292 | | { | 1293 | | extern const bfd_target TARGET_LITTLE_SYM; | 1294 | | | 1295 | | if (abfd->xvec == &TARGET_LITTLE_SYM) | 1296 | | magic = THUMBPEMAGIC; | 1297 | | } | 1298 | | #endif | 1299 | 217 | break; | 1300 | | | 1301 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1302 | | /* We no longer support PowerPC. */ | 1303 | 883 | default: | 1304 | 883 | _bfd_error_handler | 1305 | | /* xgettext:c-format */ | 1306 | 883 | (_("%pB: unrecognised machine type (0x%x)" | 1307 | 883 | " in Import Library Format archive"), | 1308 | 883 | abfd, machine); | 1309 | 883 | bfd_set_error (bfd_error_malformed_archive); | 1310 | | | 1311 | 883 | return NULL; | 1312 | 0 | break; | 1313 | 4.49k | } | 1314 | | | 1315 | 3.60k | if (magic == 0) | 1316 | 3.21k | { | 1317 | 3.21k | _bfd_error_handler | 1318 | | /* xgettext:c-format */ | 1319 | 3.21k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1320 | 3.21k | " in Import Library Format archive"), | 1321 | 3.21k | abfd, machine); | 1322 | 3.21k | bfd_set_error (bfd_error_wrong_format); | 1323 | | | 1324 | 3.21k | return NULL; | 1325 | 3.21k | } | 1326 | | | 1327 | | /* We do not bother to check the date. | 1328 | | date = H_GET_32 (abfd, ptr); */ | 1329 | 396 | ptr += 4; | 1330 | | | 1331 | 396 | size = H_GET_32 (abfd, ptr); | 1332 | 396 | ptr += 4; | 1333 | | | 1334 | 396 | if (size == 0) | 1335 | 9 | { | 1336 | 9 | _bfd_error_handler | 1337 | 9 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1338 | 9 | bfd_set_error (bfd_error_malformed_archive); | 1339 | | | 1340 | 9 | return NULL; | 1341 | 9 | } | 1342 | | | 1343 | 387 | ordinal = H_GET_16 (abfd, ptr); | 1344 | 387 | ptr += 2; | 1345 | | | 1346 | 387 | types = H_GET_16 (abfd, ptr); | 1347 | | /* ptr += 2; */ | 1348 | | | 1349 | | /* Now read in the two strings that follow. */ | 1350 | 387 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1351 | 387 | if (ptr == NULL) | 1352 | 200 | return NULL; | 1353 | | | 1354 | 187 | symbol_name = (char *) ptr; | 1355 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1356 | 187 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1357 | | | 1358 | | /* Verify that the strings are null terminated. */ | 1359 | 187 | if (ptr[size - 1] != 0 | 1360 | 177 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1361 | 19 | { | 1362 | 19 | _bfd_error_handler | 1363 | 19 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1364 | 19 | bfd_set_error (bfd_error_malformed_archive); | 1365 | 19 | bfd_release (abfd, ptr); | 1366 | 19 | return NULL; | 1367 | 19 | } | 1368 | | | 1369 | | /* An ILF file may contain a third string, after source_dll; this is | 1370 | | used for IMPORT_NAME_EXPORTAS. We know from above that the whole | 1371 | | block of data is null terminated, ptr[size-1]==0, but we don't | 1372 | | know how many individual null terminated strings we have in there. | 1373 | | | 1374 | | First find the end of source_dll. */ | 1375 | 168 | import_name = source_dll + strlen (source_dll) + 1; | 1376 | 168 | if ((bfd_byte *) import_name >= ptr + size) | 1377 | 63 | { | 1378 | | /* If this points at the end of the ptr+size block, we only had | 1379 | | two strings. */ | 1380 | 63 | import_name = NULL; | 1381 | 63 | } | 1382 | | | 1383 | | /* Now construct the bfd. */ | 1384 | 168 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1385 | 168 | source_dll, ordinal, types, | 1386 | 168 | import_name)) | 1387 | 45 | { | 1388 | 45 | bfd_release (abfd, ptr); | 1389 | 45 | return NULL; | 1390 | 45 | } | 1391 | | | 1392 | 123 | return pe_ILF_cleanup; | 1393 | 168 | } |
pei-riscv64.c:pe_ILF_object_p Line | Count | Source | 1202 | 4.59k | { | 1203 | 4.59k | bfd_byte buffer[14]; | 1204 | 4.59k | bfd_byte * ptr; | 1205 | 4.59k | char * symbol_name; | 1206 | 4.59k | char * source_dll; | 1207 | 4.59k | char * import_name; | 1208 | 4.59k | unsigned int machine; | 1209 | 4.59k | bfd_size_type size; | 1210 | 4.59k | unsigned int ordinal; | 1211 | 4.59k | unsigned int types; | 1212 | 4.59k | unsigned int magic; | 1213 | | | 1214 | | /* Upon entry the first six bytes of the ILF header have | 1215 | | already been read. Now read the rest of the header. */ | 1216 | 4.59k | if (bfd_read (buffer, 14, abfd) != 14) | 1217 | 65 | return NULL; | 1218 | | | 1219 | 4.53k | ptr = buffer; | 1220 | | | 1221 | 4.53k | machine = H_GET_16 (abfd, ptr); | 1222 | 4.53k | ptr += 2; | 1223 | | | 1224 | | /* Check that the machine type is recognised. */ | 1225 | 4.53k | magic = 0; | 1226 | | | 1227 | 4.53k | switch (machine) | 1228 | 4.53k | { | 1229 | 12 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1230 | 22 | case IMAGE_FILE_MACHINE_ALPHA: | 1231 | 30 | case IMAGE_FILE_MACHINE_ALPHA64: | 1232 | 41 | case IMAGE_FILE_MACHINE_IA64: | 1233 | 41 | break; | 1234 | | | 1235 | 366 | case IMAGE_FILE_MACHINE_I386: | 1236 | | #ifdef I386MAGIC | 1237 | | magic = I386MAGIC; | 1238 | | #endif | 1239 | 366 | break; | 1240 | | | 1241 | 291 | case IMAGE_FILE_MACHINE_AMD64: | 1242 | | #ifdef AMD64MAGIC | 1243 | | magic = AMD64MAGIC; | 1244 | | #endif | 1245 | 291 | break; | 1246 | | | 1247 | 6 | case IMAGE_FILE_MACHINE_R3000: | 1248 | 13 | case IMAGE_FILE_MACHINE_R4000: | 1249 | 22 | case IMAGE_FILE_MACHINE_R10000: | 1250 | | | 1251 | 30 | case IMAGE_FILE_MACHINE_MIPS16: | 1252 | 36 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1253 | 45 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1254 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1255 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1256 | | #endif | 1257 | 45 | break; | 1258 | | | 1259 | 1.19k | case IMAGE_FILE_MACHINE_SH3: | 1260 | 1.40k | case IMAGE_FILE_MACHINE_SH4: | 1261 | | #ifdef SH_ARCH_MAGIC_WINCE | 1262 | | magic = SH_ARCH_MAGIC_WINCE; | 1263 | | #endif | 1264 | 1.40k | break; | 1265 | | | 1266 | 172 | case IMAGE_FILE_MACHINE_ARM: | 1267 | | #ifdef ARMPEMAGIC | 1268 | | magic = ARMPEMAGIC; | 1269 | | #endif | 1270 | 172 | break; | 1271 | | | 1272 | 351 | case IMAGE_FILE_MACHINE_ARM64: | 1273 | | #ifdef AARCH64MAGIC | 1274 | | magic = AARCH64MAGIC; | 1275 | | #endif | 1276 | 351 | break; | 1277 | | | 1278 | 348 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1279 | | #ifdef LOONGARCH64MAGIC | 1280 | | magic = LOONGARCH64MAGIC; | 1281 | | #endif | 1282 | 348 | break; | 1283 | | | 1284 | 415 | case IMAGE_FILE_MACHINE_RISCV64: | 1285 | 415 | #ifdef RISCV64MAGIC | 1286 | 415 | magic = RISCV64MAGIC; | 1287 | 415 | #endif | 1288 | 415 | break; | 1289 | | | 1290 | 217 | case IMAGE_FILE_MACHINE_THUMB: | 1291 | | #ifdef THUMBPEMAGIC | 1292 | | { | 1293 | | extern const bfd_target TARGET_LITTLE_SYM; | 1294 | | | 1295 | | if (abfd->xvec == &TARGET_LITTLE_SYM) | 1296 | | magic = THUMBPEMAGIC; | 1297 | | } | 1298 | | #endif | 1299 | 217 | break; | 1300 | | | 1301 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1302 | | /* We no longer support PowerPC. */ | 1303 | 883 | default: | 1304 | 883 | _bfd_error_handler | 1305 | | /* xgettext:c-format */ | 1306 | 883 | (_("%pB: unrecognised machine type (0x%x)" | 1307 | 883 | " in Import Library Format archive"), | 1308 | 883 | abfd, machine); | 1309 | 883 | bfd_set_error (bfd_error_malformed_archive); | 1310 | | | 1311 | 883 | return NULL; | 1312 | 0 | break; | 1313 | 4.53k | } | 1314 | | | 1315 | 3.64k | if (magic == 0) | 1316 | 3.23k | { | 1317 | 3.23k | _bfd_error_handler | 1318 | | /* xgettext:c-format */ | 1319 | 3.23k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1320 | 3.23k | " in Import Library Format archive"), | 1321 | 3.23k | abfd, machine); | 1322 | 3.23k | bfd_set_error (bfd_error_wrong_format); | 1323 | | | 1324 | 3.23k | return NULL; | 1325 | 3.23k | } | 1326 | | | 1327 | | /* We do not bother to check the date. | 1328 | | date = H_GET_32 (abfd, ptr); */ | 1329 | 415 | ptr += 4; | 1330 | | | 1331 | 415 | size = H_GET_32 (abfd, ptr); | 1332 | 415 | ptr += 4; | 1333 | | | 1334 | 415 | if (size == 0) | 1335 | 9 | { | 1336 | 9 | _bfd_error_handler | 1337 | 9 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1338 | 9 | bfd_set_error (bfd_error_malformed_archive); | 1339 | | | 1340 | 9 | return NULL; | 1341 | 9 | } | 1342 | | | 1343 | 406 | ordinal = H_GET_16 (abfd, ptr); | 1344 | 406 | ptr += 2; | 1345 | | | 1346 | 406 | types = H_GET_16 (abfd, ptr); | 1347 | | /* ptr += 2; */ | 1348 | | | 1349 | | /* Now read in the two strings that follow. */ | 1350 | 406 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1351 | 406 | if (ptr == NULL) | 1352 | 224 | return NULL; | 1353 | | | 1354 | 182 | symbol_name = (char *) ptr; | 1355 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1356 | 182 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1357 | | | 1358 | | /* Verify that the strings are null terminated. */ | 1359 | 182 | if (ptr[size - 1] != 0 | 1360 | 173 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1361 | 17 | { | 1362 | 17 | _bfd_error_handler | 1363 | 17 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1364 | 17 | bfd_set_error (bfd_error_malformed_archive); | 1365 | 17 | bfd_release (abfd, ptr); | 1366 | 17 | return NULL; | 1367 | 17 | } | 1368 | | | 1369 | | /* An ILF file may contain a third string, after source_dll; this is | 1370 | | used for IMPORT_NAME_EXPORTAS. We know from above that the whole | 1371 | | block of data is null terminated, ptr[size-1]==0, but we don't | 1372 | | know how many individual null terminated strings we have in there. | 1373 | | | 1374 | | First find the end of source_dll. */ | 1375 | 165 | import_name = source_dll + strlen (source_dll) + 1; | 1376 | 165 | if ((bfd_byte *) import_name >= ptr + size) | 1377 | 41 | { | 1378 | | /* If this points at the end of the ptr+size block, we only had | 1379 | | two strings. */ | 1380 | 41 | import_name = NULL; | 1381 | 41 | } | 1382 | | | 1383 | | /* Now construct the bfd. */ | 1384 | 165 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1385 | 165 | source_dll, ordinal, types, | 1386 | 165 | import_name)) | 1387 | 43 | { | 1388 | 43 | bfd_release (abfd, ptr); | 1389 | 43 | return NULL; | 1390 | 43 | } | 1391 | | | 1392 | 122 | return pe_ILF_cleanup; | 1393 | 165 | } |
pei-arm-wince.c:pe_ILF_object_p Line | Count | Source | 1202 | 4.24k | { | 1203 | 4.24k | bfd_byte buffer[14]; | 1204 | 4.24k | bfd_byte * ptr; | 1205 | 4.24k | char * symbol_name; | 1206 | 4.24k | char * source_dll; | 1207 | 4.24k | char * import_name; | 1208 | 4.24k | unsigned int machine; | 1209 | 4.24k | bfd_size_type size; | 1210 | 4.24k | unsigned int ordinal; | 1211 | 4.24k | unsigned int types; | 1212 | 4.24k | unsigned int magic; | 1213 | | | 1214 | | /* Upon entry the first six bytes of the ILF header have | 1215 | | already been read. Now read the rest of the header. */ | 1216 | 4.24k | if (bfd_read (buffer, 14, abfd) != 14) | 1217 | 65 | return NULL; | 1218 | | | 1219 | 4.18k | ptr = buffer; | 1220 | | | 1221 | 4.18k | machine = H_GET_16 (abfd, ptr); | 1222 | 4.18k | ptr += 2; | 1223 | | | 1224 | | /* Check that the machine type is recognised. */ | 1225 | 4.18k | magic = 0; | 1226 | | | 1227 | 4.18k | switch (machine) | 1228 | 4.18k | { | 1229 | 17 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1230 | 26 | case IMAGE_FILE_MACHINE_ALPHA: | 1231 | 33 | case IMAGE_FILE_MACHINE_ALPHA64: | 1232 | 43 | case IMAGE_FILE_MACHINE_IA64: | 1233 | 43 | break; | 1234 | | | 1235 | 331 | case IMAGE_FILE_MACHINE_I386: | 1236 | | #ifdef I386MAGIC | 1237 | | magic = I386MAGIC; | 1238 | | #endif | 1239 | 331 | break; | 1240 | | | 1241 | 264 | case IMAGE_FILE_MACHINE_AMD64: | 1242 | | #ifdef AMD64MAGIC | 1243 | | magic = AMD64MAGIC; | 1244 | | #endif | 1245 | 264 | break; | 1246 | | | 1247 | 8 | case IMAGE_FILE_MACHINE_R3000: | 1248 | 14 | case IMAGE_FILE_MACHINE_R4000: | 1249 | 23 | case IMAGE_FILE_MACHINE_R10000: | 1250 | | | 1251 | 30 | case IMAGE_FILE_MACHINE_MIPS16: | 1252 | 36 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1253 | 44 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1254 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1255 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1256 | | #endif | 1257 | 44 | break; | 1258 | | | 1259 | 1.17k | case IMAGE_FILE_MACHINE_SH3: | 1260 | 1.35k | case IMAGE_FILE_MACHINE_SH4: | 1261 | | #ifdef SH_ARCH_MAGIC_WINCE | 1262 | | magic = SH_ARCH_MAGIC_WINCE; | 1263 | | #endif | 1264 | 1.35k | break; | 1265 | | | 1266 | 208 | case IMAGE_FILE_MACHINE_ARM: | 1267 | 208 | #ifdef ARMPEMAGIC | 1268 | 208 | magic = ARMPEMAGIC; | 1269 | 208 | #endif | 1270 | 208 | break; | 1271 | | | 1272 | 315 | case IMAGE_FILE_MACHINE_ARM64: | 1273 | | #ifdef AARCH64MAGIC | 1274 | | magic = AARCH64MAGIC; | 1275 | | #endif | 1276 | 315 | break; | 1277 | | | 1278 | 313 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1279 | | #ifdef LOONGARCH64MAGIC | 1280 | | magic = LOONGARCH64MAGIC; | 1281 | | #endif | 1282 | 313 | break; | 1283 | | | 1284 | 331 | case IMAGE_FILE_MACHINE_RISCV64: | 1285 | | #ifdef RISCV64MAGIC | 1286 | | magic = RISCV64MAGIC; | 1287 | | #endif | 1288 | 331 | break; | 1289 | | | 1290 | 191 | case IMAGE_FILE_MACHINE_THUMB: | 1291 | 191 | #ifdef THUMBPEMAGIC | 1292 | 191 | { | 1293 | 191 | extern const bfd_target TARGET_LITTLE_SYM; | 1294 | | | 1295 | 191 | if (abfd->xvec == &TARGET_LITTLE_SYM) | 1296 | 187 | magic = THUMBPEMAGIC; | 1297 | 191 | } | 1298 | 191 | #endif | 1299 | 191 | break; | 1300 | | | 1301 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1302 | | /* We no longer support PowerPC. */ | 1303 | 784 | default: | 1304 | 784 | _bfd_error_handler | 1305 | | /* xgettext:c-format */ | 1306 | 784 | (_("%pB: unrecognised machine type (0x%x)" | 1307 | 784 | " in Import Library Format archive"), | 1308 | 784 | abfd, machine); | 1309 | 784 | bfd_set_error (bfd_error_malformed_archive); | 1310 | | | 1311 | 784 | return NULL; | 1312 | 0 | break; | 1313 | 4.18k | } | 1314 | | | 1315 | 3.39k | if (magic == 0) | 1316 | 3.00k | { | 1317 | 3.00k | _bfd_error_handler | 1318 | | /* xgettext:c-format */ | 1319 | 3.00k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1320 | 3.00k | " in Import Library Format archive"), | 1321 | 3.00k | abfd, machine); | 1322 | 3.00k | bfd_set_error (bfd_error_wrong_format); | 1323 | | | 1324 | 3.00k | return NULL; | 1325 | 3.00k | } | 1326 | | | 1327 | | /* We do not bother to check the date. | 1328 | | date = H_GET_32 (abfd, ptr); */ | 1329 | 395 | ptr += 4; | 1330 | | | 1331 | 395 | size = H_GET_32 (abfd, ptr); | 1332 | 395 | ptr += 4; | 1333 | | | 1334 | 395 | if (size == 0) | 1335 | 11 | { | 1336 | 11 | _bfd_error_handler | 1337 | 11 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1338 | 11 | bfd_set_error (bfd_error_malformed_archive); | 1339 | | | 1340 | 11 | return NULL; | 1341 | 11 | } | 1342 | | | 1343 | 384 | ordinal = H_GET_16 (abfd, ptr); | 1344 | 384 | ptr += 2; | 1345 | | | 1346 | 384 | types = H_GET_16 (abfd, ptr); | 1347 | | /* ptr += 2; */ | 1348 | | | 1349 | | /* Now read in the two strings that follow. */ | 1350 | 384 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1351 | 384 | if (ptr == NULL) | 1352 | 240 | return NULL; | 1353 | | | 1354 | 144 | symbol_name = (char *) ptr; | 1355 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1356 | 144 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1357 | | | 1358 | | /* Verify that the strings are null terminated. */ | 1359 | 144 | if (ptr[size - 1] != 0 | 1360 | 133 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1361 | 20 | { | 1362 | 20 | _bfd_error_handler | 1363 | 20 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1364 | 20 | bfd_set_error (bfd_error_malformed_archive); | 1365 | 20 | bfd_release (abfd, ptr); | 1366 | 20 | return NULL; | 1367 | 20 | } | 1368 | | | 1369 | | /* An ILF file may contain a third string, after source_dll; this is | 1370 | | used for IMPORT_NAME_EXPORTAS. We know from above that the whole | 1371 | | block of data is null terminated, ptr[size-1]==0, but we don't | 1372 | | know how many individual null terminated strings we have in there. | 1373 | | | 1374 | | First find the end of source_dll. */ | 1375 | 124 | import_name = source_dll + strlen (source_dll) + 1; | 1376 | 124 | if ((bfd_byte *) import_name >= ptr + size) | 1377 | 65 | { | 1378 | | /* If this points at the end of the ptr+size block, we only had | 1379 | | two strings. */ | 1380 | 65 | import_name = NULL; | 1381 | 65 | } | 1382 | | | 1383 | | /* Now construct the bfd. */ | 1384 | 124 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1385 | 124 | source_dll, ordinal, types, | 1386 | 124 | import_name)) | 1387 | 45 | { | 1388 | 45 | bfd_release (abfd, ptr); | 1389 | 45 | return NULL; | 1390 | 45 | } | 1391 | | | 1392 | 79 | return pe_ILF_cleanup; | 1393 | 124 | } |
pei-arm.c:pe_ILF_object_p Line | Count | Source | 1202 | 4.25k | { | 1203 | 4.25k | bfd_byte buffer[14]; | 1204 | 4.25k | bfd_byte * ptr; | 1205 | 4.25k | char * symbol_name; | 1206 | 4.25k | char * source_dll; | 1207 | 4.25k | char * import_name; | 1208 | 4.25k | unsigned int machine; | 1209 | 4.25k | bfd_size_type size; | 1210 | 4.25k | unsigned int ordinal; | 1211 | 4.25k | unsigned int types; | 1212 | 4.25k | unsigned int magic; | 1213 | | | 1214 | | /* Upon entry the first six bytes of the ILF header have | 1215 | | already been read. Now read the rest of the header. */ | 1216 | 4.25k | if (bfd_read (buffer, 14, abfd) != 14) | 1217 | 65 | return NULL; | 1218 | | | 1219 | 4.18k | ptr = buffer; | 1220 | | | 1221 | 4.18k | machine = H_GET_16 (abfd, ptr); | 1222 | 4.18k | ptr += 2; | 1223 | | | 1224 | | /* Check that the machine type is recognised. */ | 1225 | 4.18k | magic = 0; | 1226 | | | 1227 | 4.18k | switch (machine) | 1228 | 4.18k | { | 1229 | 17 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1230 | 26 | case IMAGE_FILE_MACHINE_ALPHA: | 1231 | 33 | case IMAGE_FILE_MACHINE_ALPHA64: | 1232 | 43 | case IMAGE_FILE_MACHINE_IA64: | 1233 | 43 | break; | 1234 | | | 1235 | 331 | case IMAGE_FILE_MACHINE_I386: | 1236 | | #ifdef I386MAGIC | 1237 | | magic = I386MAGIC; | 1238 | | #endif | 1239 | 331 | break; | 1240 | | | 1241 | 264 | case IMAGE_FILE_MACHINE_AMD64: | 1242 | | #ifdef AMD64MAGIC | 1243 | | magic = AMD64MAGIC; | 1244 | | #endif | 1245 | 264 | break; | 1246 | | | 1247 | 8 | case IMAGE_FILE_MACHINE_R3000: | 1248 | 14 | case IMAGE_FILE_MACHINE_R4000: | 1249 | 23 | case IMAGE_FILE_MACHINE_R10000: | 1250 | | | 1251 | 30 | case IMAGE_FILE_MACHINE_MIPS16: | 1252 | 36 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1253 | 44 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1254 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1255 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1256 | | #endif | 1257 | 44 | break; | 1258 | | | 1259 | 1.17k | case IMAGE_FILE_MACHINE_SH3: | 1260 | 1.35k | case IMAGE_FILE_MACHINE_SH4: | 1261 | | #ifdef SH_ARCH_MAGIC_WINCE | 1262 | | magic = SH_ARCH_MAGIC_WINCE; | 1263 | | #endif | 1264 | 1.35k | break; | 1265 | | | 1266 | 213 | case IMAGE_FILE_MACHINE_ARM: | 1267 | 213 | #ifdef ARMPEMAGIC | 1268 | 213 | magic = ARMPEMAGIC; | 1269 | 213 | #endif | 1270 | 213 | break; | 1271 | | | 1272 | 315 | case IMAGE_FILE_MACHINE_ARM64: | 1273 | | #ifdef AARCH64MAGIC | 1274 | | magic = AARCH64MAGIC; | 1275 | | #endif | 1276 | 315 | break; | 1277 | | | 1278 | 313 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1279 | | #ifdef LOONGARCH64MAGIC | 1280 | | magic = LOONGARCH64MAGIC; | 1281 | | #endif | 1282 | 313 | break; | 1283 | | | 1284 | 331 | case IMAGE_FILE_MACHINE_RISCV64: | 1285 | | #ifdef RISCV64MAGIC | 1286 | | magic = RISCV64MAGIC; | 1287 | | #endif | 1288 | 331 | break; | 1289 | | | 1290 | 191 | case IMAGE_FILE_MACHINE_THUMB: | 1291 | 191 | #ifdef THUMBPEMAGIC | 1292 | 191 | { | 1293 | 191 | extern const bfd_target TARGET_LITTLE_SYM; | 1294 | | | 1295 | 191 | if (abfd->xvec == &TARGET_LITTLE_SYM) | 1296 | 187 | magic = THUMBPEMAGIC; | 1297 | 191 | } | 1298 | 191 | #endif | 1299 | 191 | break; | 1300 | | | 1301 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1302 | | /* We no longer support PowerPC. */ | 1303 | 784 | default: | 1304 | 784 | _bfd_error_handler | 1305 | | /* xgettext:c-format */ | 1306 | 784 | (_("%pB: unrecognised machine type (0x%x)" | 1307 | 784 | " in Import Library Format archive"), | 1308 | 784 | abfd, machine); | 1309 | 784 | bfd_set_error (bfd_error_malformed_archive); | 1310 | | | 1311 | 784 | return NULL; | 1312 | 0 | break; | 1313 | 4.18k | } | 1314 | | | 1315 | 3.40k | if (magic == 0) | 1316 | 3.00k | { | 1317 | 3.00k | _bfd_error_handler | 1318 | | /* xgettext:c-format */ | 1319 | 3.00k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1320 | 3.00k | " in Import Library Format archive"), | 1321 | 3.00k | abfd, machine); | 1322 | 3.00k | bfd_set_error (bfd_error_wrong_format); | 1323 | | | 1324 | 3.00k | return NULL; | 1325 | 3.00k | } | 1326 | | | 1327 | | /* We do not bother to check the date. | 1328 | | date = H_GET_32 (abfd, ptr); */ | 1329 | 400 | ptr += 4; | 1330 | | | 1331 | 400 | size = H_GET_32 (abfd, ptr); | 1332 | 400 | ptr += 4; | 1333 | | | 1334 | 400 | if (size == 0) | 1335 | 11 | { | 1336 | 11 | _bfd_error_handler | 1337 | 11 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1338 | 11 | bfd_set_error (bfd_error_malformed_archive); | 1339 | | | 1340 | 11 | return NULL; | 1341 | 11 | } | 1342 | | | 1343 | 389 | ordinal = H_GET_16 (abfd, ptr); | 1344 | 389 | ptr += 2; | 1345 | | | 1346 | 389 | types = H_GET_16 (abfd, ptr); | 1347 | | /* ptr += 2; */ | 1348 | | | 1349 | | /* Now read in the two strings that follow. */ | 1350 | 389 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1351 | 389 | if (ptr == NULL) | 1352 | 240 | return NULL; | 1353 | | | 1354 | 149 | symbol_name = (char *) ptr; | 1355 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1356 | 149 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1357 | | | 1358 | | /* Verify that the strings are null terminated. */ | 1359 | 149 | if (ptr[size - 1] != 0 | 1360 | 138 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1361 | 20 | { | 1362 | 20 | _bfd_error_handler | 1363 | 20 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1364 | 20 | bfd_set_error (bfd_error_malformed_archive); | 1365 | 20 | bfd_release (abfd, ptr); | 1366 | 20 | return NULL; | 1367 | 20 | } | 1368 | | | 1369 | | /* An ILF file may contain a third string, after source_dll; this is | 1370 | | used for IMPORT_NAME_EXPORTAS. We know from above that the whole | 1371 | | block of data is null terminated, ptr[size-1]==0, but we don't | 1372 | | know how many individual null terminated strings we have in there. | 1373 | | | 1374 | | First find the end of source_dll. */ | 1375 | 129 | import_name = source_dll + strlen (source_dll) + 1; | 1376 | 129 | if ((bfd_byte *) import_name >= ptr + size) | 1377 | 67 | { | 1378 | | /* If this points at the end of the ptr+size block, we only had | 1379 | | two strings. */ | 1380 | 67 | import_name = NULL; | 1381 | 67 | } | 1382 | | | 1383 | | /* Now construct the bfd. */ | 1384 | 129 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1385 | 129 | source_dll, ordinal, types, | 1386 | 129 | import_name)) | 1387 | 45 | { | 1388 | 45 | bfd_release (abfd, ptr); | 1389 | 45 | return NULL; | 1390 | 45 | } | 1391 | | | 1392 | 84 | return pe_ILF_cleanup; | 1393 | 129 | } |
pei-mcore.c:pe_ILF_object_p Line | Count | Source | 1202 | 4.24k | { | 1203 | 4.24k | bfd_byte buffer[14]; | 1204 | 4.24k | bfd_byte * ptr; | 1205 | 4.24k | char * symbol_name; | 1206 | 4.24k | char * source_dll; | 1207 | 4.24k | char * import_name; | 1208 | 4.24k | unsigned int machine; | 1209 | 4.24k | bfd_size_type size; | 1210 | 4.24k | unsigned int ordinal; | 1211 | 4.24k | unsigned int types; | 1212 | 4.24k | unsigned int magic; | 1213 | | | 1214 | | /* Upon entry the first six bytes of the ILF header have | 1215 | | already been read. Now read the rest of the header. */ | 1216 | 4.24k | if (bfd_read (buffer, 14, abfd) != 14) | 1217 | 65 | return NULL; | 1218 | | | 1219 | 4.17k | ptr = buffer; | 1220 | | | 1221 | 4.17k | machine = H_GET_16 (abfd, ptr); | 1222 | 4.17k | ptr += 2; | 1223 | | | 1224 | | /* Check that the machine type is recognised. */ | 1225 | 4.17k | magic = 0; | 1226 | | | 1227 | 4.17k | switch (machine) | 1228 | 4.17k | { | 1229 | 17 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1230 | 26 | case IMAGE_FILE_MACHINE_ALPHA: | 1231 | 33 | case IMAGE_FILE_MACHINE_ALPHA64: | 1232 | 43 | case IMAGE_FILE_MACHINE_IA64: | 1233 | 43 | break; | 1234 | | | 1235 | 329 | case IMAGE_FILE_MACHINE_I386: | 1236 | | #ifdef I386MAGIC | 1237 | | magic = I386MAGIC; | 1238 | | #endif | 1239 | 329 | break; | 1240 | | | 1241 | 264 | case IMAGE_FILE_MACHINE_AMD64: | 1242 | | #ifdef AMD64MAGIC | 1243 | | magic = AMD64MAGIC; | 1244 | | #endif | 1245 | 264 | break; | 1246 | | | 1247 | 8 | case IMAGE_FILE_MACHINE_R3000: | 1248 | 14 | case IMAGE_FILE_MACHINE_R4000: | 1249 | 23 | case IMAGE_FILE_MACHINE_R10000: | 1250 | | | 1251 | 30 | case IMAGE_FILE_MACHINE_MIPS16: | 1252 | 36 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1253 | 44 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1254 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1255 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1256 | | #endif | 1257 | 44 | break; | 1258 | | | 1259 | 1.17k | case IMAGE_FILE_MACHINE_SH3: | 1260 | 1.35k | case IMAGE_FILE_MACHINE_SH4: | 1261 | | #ifdef SH_ARCH_MAGIC_WINCE | 1262 | | magic = SH_ARCH_MAGIC_WINCE; | 1263 | | #endif | 1264 | 1.35k | break; | 1265 | | | 1266 | 208 | case IMAGE_FILE_MACHINE_ARM: | 1267 | | #ifdef ARMPEMAGIC | 1268 | | magic = ARMPEMAGIC; | 1269 | | #endif | 1270 | 208 | break; | 1271 | | | 1272 | 315 | case IMAGE_FILE_MACHINE_ARM64: | 1273 | | #ifdef AARCH64MAGIC | 1274 | | magic = AARCH64MAGIC; | 1275 | | #endif | 1276 | 315 | break; | 1277 | | | 1278 | 313 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1279 | | #ifdef LOONGARCH64MAGIC | 1280 | | magic = LOONGARCH64MAGIC; | 1281 | | #endif | 1282 | 313 | break; | 1283 | | | 1284 | 331 | case IMAGE_FILE_MACHINE_RISCV64: | 1285 | | #ifdef RISCV64MAGIC | 1286 | | magic = RISCV64MAGIC; | 1287 | | #endif | 1288 | 331 | break; | 1289 | | | 1290 | 191 | case IMAGE_FILE_MACHINE_THUMB: | 1291 | | #ifdef THUMBPEMAGIC | 1292 | | { | 1293 | | extern const bfd_target TARGET_LITTLE_SYM; | 1294 | | | 1295 | | if (abfd->xvec == &TARGET_LITTLE_SYM) | 1296 | | magic = THUMBPEMAGIC; | 1297 | | } | 1298 | | #endif | 1299 | 191 | break; | 1300 | | | 1301 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1302 | | /* We no longer support PowerPC. */ | 1303 | 784 | default: | 1304 | 784 | _bfd_error_handler | 1305 | | /* xgettext:c-format */ | 1306 | 784 | (_("%pB: unrecognised machine type (0x%x)" | 1307 | 784 | " in Import Library Format archive"), | 1308 | 784 | abfd, machine); | 1309 | 784 | bfd_set_error (bfd_error_malformed_archive); | 1310 | | | 1311 | 784 | return NULL; | 1312 | 0 | break; | 1313 | 4.17k | } | 1314 | | | 1315 | 3.39k | if (magic == 0) | 1316 | 3.39k | { | 1317 | 3.39k | _bfd_error_handler | 1318 | | /* xgettext:c-format */ | 1319 | 3.39k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1320 | 3.39k | " in Import Library Format archive"), | 1321 | 3.39k | abfd, machine); | 1322 | 3.39k | bfd_set_error (bfd_error_wrong_format); | 1323 | | | 1324 | 3.39k | return NULL; | 1325 | 3.39k | } | 1326 | | | 1327 | | /* We do not bother to check the date. | 1328 | | date = H_GET_32 (abfd, ptr); */ | 1329 | 0 | ptr += 4; | 1330 | |
| 1331 | 0 | size = H_GET_32 (abfd, ptr); | 1332 | 0 | ptr += 4; | 1333 | |
| 1334 | 0 | if (size == 0) | 1335 | 0 | { | 1336 | 0 | _bfd_error_handler | 1337 | 0 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1338 | 0 | bfd_set_error (bfd_error_malformed_archive); | 1339 | |
| 1340 | 0 | return NULL; | 1341 | 0 | } | 1342 | | | 1343 | 0 | ordinal = H_GET_16 (abfd, ptr); | 1344 | 0 | ptr += 2; | 1345 | |
| 1346 | 0 | types = H_GET_16 (abfd, ptr); | 1347 | | /* ptr += 2; */ | 1348 | | | 1349 | | /* Now read in the two strings that follow. */ | 1350 | 0 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1351 | 0 | if (ptr == NULL) | 1352 | 0 | return NULL; | 1353 | | | 1354 | 0 | symbol_name = (char *) ptr; | 1355 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1356 | 0 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1357 | | | 1358 | | /* Verify that the strings are null terminated. */ | 1359 | 0 | if (ptr[size - 1] != 0 | 1360 | 0 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1361 | 0 | { | 1362 | 0 | _bfd_error_handler | 1363 | 0 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1364 | 0 | bfd_set_error (bfd_error_malformed_archive); | 1365 | 0 | bfd_release (abfd, ptr); | 1366 | 0 | return NULL; | 1367 | 0 | } | 1368 | | | 1369 | | /* An ILF file may contain a third string, after source_dll; this is | 1370 | | used for IMPORT_NAME_EXPORTAS. We know from above that the whole | 1371 | | block of data is null terminated, ptr[size-1]==0, but we don't | 1372 | | know how many individual null terminated strings we have in there. | 1373 | | | 1374 | | First find the end of source_dll. */ | 1375 | 0 | import_name = source_dll + strlen (source_dll) + 1; | 1376 | 0 | if ((bfd_byte *) import_name >= ptr + size) | 1377 | 0 | { | 1378 | | /* If this points at the end of the ptr+size block, we only had | 1379 | | two strings. */ | 1380 | 0 | import_name = NULL; | 1381 | 0 | } | 1382 | | | 1383 | | /* Now construct the bfd. */ | 1384 | 0 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1385 | 0 | source_dll, ordinal, types, | 1386 | 0 | import_name)) | 1387 | 0 | { | 1388 | 0 | bfd_release (abfd, ptr); | 1389 | 0 | return NULL; | 1390 | 0 | } | 1391 | | | 1392 | 0 | return pe_ILF_cleanup; | 1393 | 0 | } |
Line | Count | Source | 1202 | 4.21k | { | 1203 | 4.21k | bfd_byte buffer[14]; | 1204 | 4.21k | bfd_byte * ptr; | 1205 | 4.21k | char * symbol_name; | 1206 | 4.21k | char * source_dll; | 1207 | 4.21k | char * import_name; | 1208 | 4.21k | unsigned int machine; | 1209 | 4.21k | bfd_size_type size; | 1210 | 4.21k | unsigned int ordinal; | 1211 | 4.21k | unsigned int types; | 1212 | 4.21k | unsigned int magic; | 1213 | | | 1214 | | /* Upon entry the first six bytes of the ILF header have | 1215 | | already been read. Now read the rest of the header. */ | 1216 | 4.21k | if (bfd_read (buffer, 14, abfd) != 14) | 1217 | 60 | return NULL; | 1218 | | | 1219 | 4.15k | ptr = buffer; | 1220 | | | 1221 | 4.15k | machine = H_GET_16 (abfd, ptr); | 1222 | 4.15k | ptr += 2; | 1223 | | | 1224 | | /* Check that the machine type is recognised. */ | 1225 | 4.15k | magic = 0; | 1226 | | | 1227 | 4.15k | switch (machine) | 1228 | 4.15k | { | 1229 | 11 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1230 | 20 | case IMAGE_FILE_MACHINE_ALPHA: | 1231 | 27 | case IMAGE_FILE_MACHINE_ALPHA64: | 1232 | 37 | case IMAGE_FILE_MACHINE_IA64: | 1233 | 37 | break; | 1234 | | | 1235 | 329 | case IMAGE_FILE_MACHINE_I386: | 1236 | | #ifdef I386MAGIC | 1237 | | magic = I386MAGIC; | 1238 | | #endif | 1239 | 329 | break; | 1240 | | | 1241 | 264 | case IMAGE_FILE_MACHINE_AMD64: | 1242 | | #ifdef AMD64MAGIC | 1243 | | magic = AMD64MAGIC; | 1244 | | #endif | 1245 | 264 | break; | 1246 | | | 1247 | 5 | case IMAGE_FILE_MACHINE_R3000: | 1248 | 11 | case IMAGE_FILE_MACHINE_R4000: | 1249 | 20 | case IMAGE_FILE_MACHINE_R10000: | 1250 | | | 1251 | 27 | case IMAGE_FILE_MACHINE_MIPS16: | 1252 | 33 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1253 | 41 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1254 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1255 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1256 | | #endif | 1257 | 41 | break; | 1258 | | | 1259 | 1.22k | case IMAGE_FILE_MACHINE_SH3: | 1260 | 1.43k | case IMAGE_FILE_MACHINE_SH4: | 1261 | 1.43k | #ifdef SH_ARCH_MAGIC_WINCE | 1262 | 1.43k | magic = SH_ARCH_MAGIC_WINCE; | 1263 | 1.43k | #endif | 1264 | 1.43k | break; | 1265 | | | 1266 | 150 | case IMAGE_FILE_MACHINE_ARM: | 1267 | | #ifdef ARMPEMAGIC | 1268 | | magic = ARMPEMAGIC; | 1269 | | #endif | 1270 | 150 | break; | 1271 | | | 1272 | 315 | case IMAGE_FILE_MACHINE_ARM64: | 1273 | | #ifdef AARCH64MAGIC | 1274 | | magic = AARCH64MAGIC; | 1275 | | #endif | 1276 | 315 | break; | 1277 | | | 1278 | 313 | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1279 | | #ifdef LOONGARCH64MAGIC | 1280 | | magic = LOONGARCH64MAGIC; | 1281 | | #endif | 1282 | 313 | break; | 1283 | | | 1284 | 330 | case IMAGE_FILE_MACHINE_RISCV64: | 1285 | | #ifdef RISCV64MAGIC | 1286 | | magic = RISCV64MAGIC; | 1287 | | #endif | 1288 | 330 | break; | 1289 | | | 1290 | 187 | case IMAGE_FILE_MACHINE_THUMB: | 1291 | | #ifdef THUMBPEMAGIC | 1292 | | { | 1293 | | extern const bfd_target TARGET_LITTLE_SYM; | 1294 | | | 1295 | | if (abfd->xvec == &TARGET_LITTLE_SYM) | 1296 | | magic = THUMBPEMAGIC; | 1297 | | } | 1298 | | #endif | 1299 | 187 | break; | 1300 | | | 1301 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1302 | | /* We no longer support PowerPC. */ | 1303 | 756 | default: | 1304 | 756 | _bfd_error_handler | 1305 | | /* xgettext:c-format */ | 1306 | 756 | (_("%pB: unrecognised machine type (0x%x)" | 1307 | 756 | " in Import Library Format archive"), | 1308 | 756 | abfd, machine); | 1309 | 756 | bfd_set_error (bfd_error_malformed_archive); | 1310 | | | 1311 | 756 | return NULL; | 1312 | 0 | break; | 1313 | 4.15k | } | 1314 | | | 1315 | 3.40k | if (magic == 0) | 1316 | 1.96k | { | 1317 | 1.96k | _bfd_error_handler | 1318 | | /* xgettext:c-format */ | 1319 | 1.96k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1320 | 1.96k | " in Import Library Format archive"), | 1321 | 1.96k | abfd, machine); | 1322 | 1.96k | bfd_set_error (bfd_error_wrong_format); | 1323 | | | 1324 | 1.96k | return NULL; | 1325 | 1.96k | } | 1326 | | | 1327 | | /* We do not bother to check the date. | 1328 | | date = H_GET_32 (abfd, ptr); */ | 1329 | 1.43k | ptr += 4; | 1330 | | | 1331 | 1.43k | size = H_GET_32 (abfd, ptr); | 1332 | 1.43k | ptr += 4; | 1333 | | | 1334 | 1.43k | if (size == 0) | 1335 | 16 | { | 1336 | 16 | _bfd_error_handler | 1337 | 16 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1338 | 16 | bfd_set_error (bfd_error_malformed_archive); | 1339 | | | 1340 | 16 | return NULL; | 1341 | 16 | } | 1342 | | | 1343 | 1.42k | ordinal = H_GET_16 (abfd, ptr); | 1344 | 1.42k | ptr += 2; | 1345 | | | 1346 | 1.42k | types = H_GET_16 (abfd, ptr); | 1347 | | /* ptr += 2; */ | 1348 | | | 1349 | | /* Now read in the two strings that follow. */ | 1350 | 1.42k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1351 | 1.42k | if (ptr == NULL) | 1352 | 361 | return NULL; | 1353 | | | 1354 | 1.05k | symbol_name = (char *) ptr; | 1355 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1356 | 1.05k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1357 | | | 1358 | | /* Verify that the strings are null terminated. */ | 1359 | 1.05k | if (ptr[size - 1] != 0 | 1360 | 318 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1361 | 753 | { | 1362 | 753 | _bfd_error_handler | 1363 | 753 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1364 | 753 | bfd_set_error (bfd_error_malformed_archive); | 1365 | 753 | bfd_release (abfd, ptr); | 1366 | 753 | return NULL; | 1367 | 753 | } | 1368 | | | 1369 | | /* An ILF file may contain a third string, after source_dll; this is | 1370 | | used for IMPORT_NAME_EXPORTAS. We know from above that the whole | 1371 | | block of data is null terminated, ptr[size-1]==0, but we don't | 1372 | | know how many individual null terminated strings we have in there. | 1373 | | | 1374 | | First find the end of source_dll. */ | 1375 | 306 | import_name = source_dll + strlen (source_dll) + 1; | 1376 | 306 | if ((bfd_byte *) import_name >= ptr + size) | 1377 | 77 | { | 1378 | | /* If this points at the end of the ptr+size block, we only had | 1379 | | two strings. */ | 1380 | 77 | import_name = NULL; | 1381 | 77 | } | 1382 | | | 1383 | | /* Now construct the bfd. */ | 1384 | 306 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1385 | 306 | source_dll, ordinal, types, | 1386 | 306 | import_name)) | 1387 | 121 | { | 1388 | 121 | bfd_release (abfd, ptr); | 1389 | 121 | return NULL; | 1390 | 121 | } | 1391 | | | 1392 | 185 | return pe_ILF_cleanup; | 1393 | 306 | } |
|
1394 | | |
1395 | | static void |
1396 | | pe_bfd_read_buildid (bfd *abfd) |
1397 | 50.8k | { |
1398 | 50.8k | pe_data_type *pe = pe_data (abfd); |
1399 | 50.8k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; |
1400 | 50.8k | asection *section; |
1401 | 50.8k | bfd_byte *data = 0; |
1402 | 50.8k | bfd_size_type dataoff; |
1403 | 50.8k | unsigned int i; |
1404 | 50.8k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; |
1405 | 50.8k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; |
1406 | | |
1407 | 50.8k | if (size == 0) |
1408 | 31.2k | return; |
1409 | | |
1410 | 19.5k | addr += extra->ImageBase; |
1411 | | |
1412 | | /* Search for the section containing the DebugDirectory. */ |
1413 | 143k | for (section = abfd->sections; section != NULL; section = section->next) |
1414 | 133k | { |
1415 | 133k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) |
1416 | 9.78k | break; |
1417 | 133k | } |
1418 | | |
1419 | 19.5k | if (section == NULL) |
1420 | 9.76k | return; |
1421 | | |
1422 | 9.78k | if (!(section->flags & SEC_HAS_CONTENTS)) |
1423 | 528 | return; |
1424 | | |
1425 | 9.25k | dataoff = addr - section->vma; |
1426 | | |
1427 | | /* PR 20605 and 22373: Make sure that the data is really there. |
1428 | | Note - since we are dealing with unsigned quantities we have |
1429 | | to be careful to check for potential overflows. */ |
1430 | 9.25k | if (dataoff >= section->size |
1431 | 9.25k | || size > section->size - dataoff) |
1432 | 3.07k | { |
1433 | 3.07k | _bfd_error_handler |
1434 | 3.07k | (_("%pB: error: debug data ends beyond end of debug directory"), |
1435 | 3.07k | abfd); |
1436 | 3.07k | return; |
1437 | 3.07k | } |
1438 | | |
1439 | | /* Read the whole section. */ |
1440 | 6.17k | if (!bfd_malloc_and_get_section (abfd, section, &data)) |
1441 | 1.76k | { |
1442 | 1.76k | free (data); |
1443 | 1.76k | return; |
1444 | 1.76k | } |
1445 | | |
1446 | | /* Search for a CodeView entry in the DebugDirectory */ |
1447 | 300k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) |
1448 | 298k | { |
1449 | 298k | struct external_IMAGE_DEBUG_DIRECTORY *ext |
1450 | 298k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; |
1451 | 298k | struct internal_IMAGE_DEBUG_DIRECTORY idd; |
1452 | | |
1453 | 298k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); |
1454 | | |
1455 | 298k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) |
1456 | 1.78k | { |
1457 | 1.78k | char buffer[256 + 1]; |
1458 | 1.78k | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; |
1459 | | |
1460 | | /* |
1461 | | The debug entry doesn't have to have to be in a section, in which |
1462 | | case AddressOfRawData is 0, so always use PointerToRawData. |
1463 | | */ |
1464 | 1.78k | if (_bfd_XXi_slurp_codeview_record (abfd, |
1465 | 1.78k | (file_ptr) idd.PointerToRawData, |
1466 | 1.78k | idd.SizeOfData, cvinfo, NULL)) |
1467 | 138 | { |
1468 | 138 | struct bfd_build_id *build_id; |
1469 | 138 | size_t bidlen = sizeof (*build_id) + cvinfo->SignatureLength; |
1470 | | |
1471 | 138 | build_id = bfd_alloc (abfd, bidlen); |
1472 | 138 | if (build_id) |
1473 | 138 | { |
1474 | 138 | build_id->size = cvinfo->SignatureLength; |
1475 | 138 | memcpy(build_id->data, cvinfo->Signature, |
1476 | 138 | cvinfo->SignatureLength); |
1477 | 138 | abfd->build_id = build_id; |
1478 | 138 | } |
1479 | 138 | } |
1480 | 1.78k | break; |
1481 | 1.78k | } |
1482 | 298k | } |
1483 | | |
1484 | 4.40k | free (data); |
1485 | 4.40k | } pei-i386.c:pe_bfd_read_buildid Line | Count | Source | 1397 | 8.35k | { | 1398 | 8.35k | pe_data_type *pe = pe_data (abfd); | 1399 | 8.35k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1400 | 8.35k | asection *section; | 1401 | 8.35k | bfd_byte *data = 0; | 1402 | 8.35k | bfd_size_type dataoff; | 1403 | 8.35k | unsigned int i; | 1404 | 8.35k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1405 | 8.35k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1406 | | | 1407 | 8.35k | if (size == 0) | 1408 | 6.45k | return; | 1409 | | | 1410 | 1.89k | addr += extra->ImageBase; | 1411 | | | 1412 | | /* Search for the section containing the DebugDirectory. */ | 1413 | 14.6k | for (section = abfd->sections; section != NULL; section = section->next) | 1414 | 13.6k | { | 1415 | 13.6k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1416 | 936 | break; | 1417 | 13.6k | } | 1418 | | | 1419 | 1.89k | if (section == NULL) | 1420 | 963 | return; | 1421 | | | 1422 | 936 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1423 | 73 | return; | 1424 | | | 1425 | 863 | dataoff = addr - section->vma; | 1426 | | | 1427 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1428 | | Note - since we are dealing with unsigned quantities we have | 1429 | | to be careful to check for potential overflows. */ | 1430 | 863 | if (dataoff >= section->size | 1431 | 863 | || size > section->size - dataoff) | 1432 | 381 | { | 1433 | 381 | _bfd_error_handler | 1434 | 381 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1435 | 381 | abfd); | 1436 | 381 | return; | 1437 | 381 | } | 1438 | | | 1439 | | /* Read the whole section. */ | 1440 | 482 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1441 | 218 | { | 1442 | 218 | free (data); | 1443 | 218 | return; | 1444 | 218 | } | 1445 | | | 1446 | | /* Search for a CodeView entry in the DebugDirectory */ | 1447 | 8.23k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1448 | 8.10k | { | 1449 | 8.10k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1450 | 8.10k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1451 | 8.10k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1452 | | | 1453 | 8.10k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1454 | | | 1455 | 8.10k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1456 | 139 | { | 1457 | 139 | char buffer[256 + 1]; | 1458 | 139 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1459 | | | 1460 | | /* | 1461 | | The debug entry doesn't have to have to be in a section, in which | 1462 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1463 | | */ | 1464 | 139 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1465 | 139 | (file_ptr) idd.PointerToRawData, | 1466 | 139 | idd.SizeOfData, cvinfo, NULL)) | 1467 | 13 | { | 1468 | 13 | struct bfd_build_id *build_id; | 1469 | 13 | size_t bidlen = sizeof (*build_id) + cvinfo->SignatureLength; | 1470 | | | 1471 | 13 | build_id = bfd_alloc (abfd, bidlen); | 1472 | 13 | if (build_id) | 1473 | 13 | { | 1474 | 13 | build_id->size = cvinfo->SignatureLength; | 1475 | 13 | memcpy(build_id->data, cvinfo->Signature, | 1476 | 13 | cvinfo->SignatureLength); | 1477 | 13 | abfd->build_id = build_id; | 1478 | 13 | } | 1479 | 13 | } | 1480 | 139 | break; | 1481 | 139 | } | 1482 | 8.10k | } | 1483 | | | 1484 | 264 | free (data); | 1485 | 264 | } |
pei-x86_64.c:pe_bfd_read_buildid Line | Count | Source | 1397 | 5.96k | { | 1398 | 5.96k | pe_data_type *pe = pe_data (abfd); | 1399 | 5.96k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1400 | 5.96k | asection *section; | 1401 | 5.96k | bfd_byte *data = 0; | 1402 | 5.96k | bfd_size_type dataoff; | 1403 | 5.96k | unsigned int i; | 1404 | 5.96k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1405 | 5.96k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1406 | | | 1407 | 5.96k | if (size == 0) | 1408 | 3.91k | return; | 1409 | | | 1410 | 2.05k | addr += extra->ImageBase; | 1411 | | | 1412 | | /* Search for the section containing the DebugDirectory. */ | 1413 | 21.4k | for (section = abfd->sections; section != NULL; section = section->next) | 1414 | 20.3k | { | 1415 | 20.3k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1416 | 949 | break; | 1417 | 20.3k | } | 1418 | | | 1419 | 2.05k | if (section == NULL) | 1420 | 1.10k | return; | 1421 | | | 1422 | 949 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1423 | 60 | return; | 1424 | | | 1425 | 889 | dataoff = addr - section->vma; | 1426 | | | 1427 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1428 | | Note - since we are dealing with unsigned quantities we have | 1429 | | to be careful to check for potential overflows. */ | 1430 | 889 | if (dataoff >= section->size | 1431 | 889 | || size > section->size - dataoff) | 1432 | 261 | { | 1433 | 261 | _bfd_error_handler | 1434 | 261 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1435 | 261 | abfd); | 1436 | 261 | return; | 1437 | 261 | } | 1438 | | | 1439 | | /* Read the whole section. */ | 1440 | 628 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1441 | 207 | { | 1442 | 207 | free (data); | 1443 | 207 | return; | 1444 | 207 | } | 1445 | | | 1446 | | /* Search for a CodeView entry in the DebugDirectory */ | 1447 | 16.8k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1448 | 16.6k | { | 1449 | 16.6k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1450 | 16.6k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1451 | 16.6k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1452 | | | 1453 | 16.6k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1454 | | | 1455 | 16.6k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1456 | 300 | { | 1457 | 300 | char buffer[256 + 1]; | 1458 | 300 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1459 | | | 1460 | | /* | 1461 | | The debug entry doesn't have to have to be in a section, in which | 1462 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1463 | | */ | 1464 | 300 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1465 | 300 | (file_ptr) idd.PointerToRawData, | 1466 | 300 | idd.SizeOfData, cvinfo, NULL)) | 1467 | 42 | { | 1468 | 42 | struct bfd_build_id *build_id; | 1469 | 42 | size_t bidlen = sizeof (*build_id) + cvinfo->SignatureLength; | 1470 | | | 1471 | 42 | build_id = bfd_alloc (abfd, bidlen); | 1472 | 42 | if (build_id) | 1473 | 42 | { | 1474 | 42 | build_id->size = cvinfo->SignatureLength; | 1475 | 42 | memcpy(build_id->data, cvinfo->Signature, | 1476 | 42 | cvinfo->SignatureLength); | 1477 | 42 | abfd->build_id = build_id; | 1478 | 42 | } | 1479 | 42 | } | 1480 | 300 | break; | 1481 | 300 | } | 1482 | 16.6k | } | 1483 | | | 1484 | 421 | free (data); | 1485 | 421 | } |
pei-aarch64.c:pe_bfd_read_buildid Line | Count | Source | 1397 | 6.56k | { | 1398 | 6.56k | pe_data_type *pe = pe_data (abfd); | 1399 | 6.56k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1400 | 6.56k | asection *section; | 1401 | 6.56k | bfd_byte *data = 0; | 1402 | 6.56k | bfd_size_type dataoff; | 1403 | 6.56k | unsigned int i; | 1404 | 6.56k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1405 | 6.56k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1406 | | | 1407 | 6.56k | if (size == 0) | 1408 | 2.33k | return; | 1409 | | | 1410 | 4.22k | addr += extra->ImageBase; | 1411 | | | 1412 | | /* Search for the section containing the DebugDirectory. */ | 1413 | 24.8k | for (section = abfd->sections; section != NULL; section = section->next) | 1414 | 23.4k | { | 1415 | 23.4k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1416 | 2.83k | break; | 1417 | 23.4k | } | 1418 | | | 1419 | 4.22k | if (section == NULL) | 1420 | 1.39k | return; | 1421 | | | 1422 | 2.83k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1423 | 19 | return; | 1424 | | | 1425 | 2.81k | dataoff = addr - section->vma; | 1426 | | | 1427 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1428 | | Note - since we are dealing with unsigned quantities we have | 1429 | | to be careful to check for potential overflows. */ | 1430 | 2.81k | if (dataoff >= section->size | 1431 | 2.81k | || size > section->size - dataoff) | 1432 | 339 | { | 1433 | 339 | _bfd_error_handler | 1434 | 339 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1435 | 339 | abfd); | 1436 | 339 | return; | 1437 | 339 | } | 1438 | | | 1439 | | /* Read the whole section. */ | 1440 | 2.47k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1441 | 345 | { | 1442 | 345 | free (data); | 1443 | 345 | return; | 1444 | 345 | } | 1445 | | | 1446 | | /* Search for a CodeView entry in the DebugDirectory */ | 1447 | 243k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1448 | 242k | { | 1449 | 242k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1450 | 242k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1451 | 242k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1452 | | | 1453 | 242k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1454 | | | 1455 | 242k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1456 | 494 | { | 1457 | 494 | char buffer[256 + 1]; | 1458 | 494 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1459 | | | 1460 | | /* | 1461 | | The debug entry doesn't have to have to be in a section, in which | 1462 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1463 | | */ | 1464 | 494 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1465 | 494 | (file_ptr) idd.PointerToRawData, | 1466 | 494 | idd.SizeOfData, cvinfo, NULL)) | 1467 | 17 | { | 1468 | 17 | struct bfd_build_id *build_id; | 1469 | 17 | size_t bidlen = sizeof (*build_id) + cvinfo->SignatureLength; | 1470 | | | 1471 | 17 | build_id = bfd_alloc (abfd, bidlen); | 1472 | 17 | if (build_id) | 1473 | 17 | { | 1474 | 17 | build_id->size = cvinfo->SignatureLength; | 1475 | 17 | memcpy(build_id->data, cvinfo->Signature, | 1476 | 17 | cvinfo->SignatureLength); | 1477 | 17 | abfd->build_id = build_id; | 1478 | 17 | } | 1479 | 17 | } | 1480 | 494 | break; | 1481 | 494 | } | 1482 | 242k | } | 1483 | | | 1484 | 2.13k | free (data); | 1485 | 2.13k | } |
pei-ia64.c:pe_bfd_read_buildid Line | Count | Source | 1397 | 5.27k | { | 1398 | 5.27k | pe_data_type *pe = pe_data (abfd); | 1399 | 5.27k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1400 | 5.27k | asection *section; | 1401 | 5.27k | bfd_byte *data = 0; | 1402 | 5.27k | bfd_size_type dataoff; | 1403 | 5.27k | unsigned int i; | 1404 | 5.27k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1405 | 5.27k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1406 | | | 1407 | 5.27k | if (size == 0) | 1408 | 3.50k | return; | 1409 | | | 1410 | 1.77k | addr += extra->ImageBase; | 1411 | | | 1412 | | /* Search for the section containing the DebugDirectory. */ | 1413 | 10.2k | for (section = abfd->sections; section != NULL; section = section->next) | 1414 | 8.98k | { | 1415 | 8.98k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1416 | 512 | break; | 1417 | 8.98k | } | 1418 | | | 1419 | 1.77k | if (section == NULL) | 1420 | 1.26k | return; | 1421 | | | 1422 | 512 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1423 | 47 | return; | 1424 | | | 1425 | 465 | dataoff = addr - section->vma; | 1426 | | | 1427 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1428 | | Note - since we are dealing with unsigned quantities we have | 1429 | | to be careful to check for potential overflows. */ | 1430 | 465 | if (dataoff >= section->size | 1431 | 465 | || size > section->size - dataoff) | 1432 | 165 | { | 1433 | 165 | _bfd_error_handler | 1434 | 165 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1435 | 165 | abfd); | 1436 | 165 | return; | 1437 | 165 | } | 1438 | | | 1439 | | /* Read the whole section. */ | 1440 | 300 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1441 | 81 | { | 1442 | 81 | free (data); | 1443 | 81 | return; | 1444 | 81 | } | 1445 | | | 1446 | | /* Search for a CodeView entry in the DebugDirectory */ | 1447 | 2.39k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1448 | 2.30k | { | 1449 | 2.30k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1450 | 2.30k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1451 | 2.30k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1452 | | | 1453 | 2.30k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1454 | | | 1455 | 2.30k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1456 | 126 | { | 1457 | 126 | char buffer[256 + 1]; | 1458 | 126 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1459 | | | 1460 | | /* | 1461 | | The debug entry doesn't have to have to be in a section, in which | 1462 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1463 | | */ | 1464 | 126 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1465 | 126 | (file_ptr) idd.PointerToRawData, | 1466 | 126 | idd.SizeOfData, cvinfo, NULL)) | 1467 | 6 | { | 1468 | 6 | struct bfd_build_id *build_id; | 1469 | 6 | size_t bidlen = sizeof (*build_id) + cvinfo->SignatureLength; | 1470 | | | 1471 | 6 | build_id = bfd_alloc (abfd, bidlen); | 1472 | 6 | if (build_id) | 1473 | 6 | { | 1474 | 6 | build_id->size = cvinfo->SignatureLength; | 1475 | 6 | memcpy(build_id->data, cvinfo->Signature, | 1476 | 6 | cvinfo->SignatureLength); | 1477 | 6 | abfd->build_id = build_id; | 1478 | 6 | } | 1479 | 6 | } | 1480 | 126 | break; | 1481 | 126 | } | 1482 | 2.30k | } | 1483 | | | 1484 | 219 | free (data); | 1485 | 219 | } |
pei-loongarch64.c:pe_bfd_read_buildid Line | Count | Source | 1397 | 4.48k | { | 1398 | 4.48k | pe_data_type *pe = pe_data (abfd); | 1399 | 4.48k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1400 | 4.48k | asection *section; | 1401 | 4.48k | bfd_byte *data = 0; | 1402 | 4.48k | bfd_size_type dataoff; | 1403 | 4.48k | unsigned int i; | 1404 | 4.48k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1405 | 4.48k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1406 | | | 1407 | 4.48k | if (size == 0) | 1408 | 2.85k | return; | 1409 | | | 1410 | 1.63k | addr += extra->ImageBase; | 1411 | | | 1412 | | /* Search for the section containing the DebugDirectory. */ | 1413 | 15.8k | for (section = abfd->sections; section != NULL; section = section->next) | 1414 | 15.0k | { | 1415 | 15.0k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1416 | 798 | break; | 1417 | 15.0k | } | 1418 | | | 1419 | 1.63k | if (section == NULL) | 1420 | 835 | return; | 1421 | | | 1422 | 798 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1423 | 51 | return; | 1424 | | | 1425 | 747 | dataoff = addr - section->vma; | 1426 | | | 1427 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1428 | | Note - since we are dealing with unsigned quantities we have | 1429 | | to be careful to check for potential overflows. */ | 1430 | 747 | if (dataoff >= section->size | 1431 | 747 | || size > section->size - dataoff) | 1432 | 250 | { | 1433 | 250 | _bfd_error_handler | 1434 | 250 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1435 | 250 | abfd); | 1436 | 250 | return; | 1437 | 250 | } | 1438 | | | 1439 | | /* Read the whole section. */ | 1440 | 497 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1441 | 125 | { | 1442 | 125 | free (data); | 1443 | 125 | return; | 1444 | 125 | } | 1445 | | | 1446 | | /* Search for a CodeView entry in the DebugDirectory */ | 1447 | 9.52k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1448 | 9.38k | { | 1449 | 9.38k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1450 | 9.38k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1451 | 9.38k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1452 | | | 1453 | 9.38k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1454 | | | 1455 | 9.38k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1456 | 236 | { | 1457 | 236 | char buffer[256 + 1]; | 1458 | 236 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1459 | | | 1460 | | /* | 1461 | | The debug entry doesn't have to have to be in a section, in which | 1462 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1463 | | */ | 1464 | 236 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1465 | 236 | (file_ptr) idd.PointerToRawData, | 1466 | 236 | idd.SizeOfData, cvinfo, NULL)) | 1467 | 17 | { | 1468 | 17 | struct bfd_build_id *build_id; | 1469 | 17 | size_t bidlen = sizeof (*build_id) + cvinfo->SignatureLength; | 1470 | | | 1471 | 17 | build_id = bfd_alloc (abfd, bidlen); | 1472 | 17 | if (build_id) | 1473 | 17 | { | 1474 | 17 | build_id->size = cvinfo->SignatureLength; | 1475 | 17 | memcpy(build_id->data, cvinfo->Signature, | 1476 | 17 | cvinfo->SignatureLength); | 1477 | 17 | abfd->build_id = build_id; | 1478 | 17 | } | 1479 | 17 | } | 1480 | 236 | break; | 1481 | 236 | } | 1482 | 9.38k | } | 1483 | | | 1484 | 372 | free (data); | 1485 | 372 | } |
pei-riscv64.c:pe_bfd_read_buildid Line | Count | Source | 1397 | 4.83k | { | 1398 | 4.83k | pe_data_type *pe = pe_data (abfd); | 1399 | 4.83k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1400 | 4.83k | asection *section; | 1401 | 4.83k | bfd_byte *data = 0; | 1402 | 4.83k | bfd_size_type dataoff; | 1403 | 4.83k | unsigned int i; | 1404 | 4.83k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1405 | 4.83k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1406 | | | 1407 | 4.83k | if (size == 0) | 1408 | 2.93k | return; | 1409 | | | 1410 | 1.89k | addr += extra->ImageBase; | 1411 | | | 1412 | | /* Search for the section containing the DebugDirectory. */ | 1413 | 16.2k | for (section = abfd->sections; section != NULL; section = section->next) | 1414 | 15.2k | { | 1415 | 15.2k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1416 | 815 | break; | 1417 | 15.2k | } | 1418 | | | 1419 | 1.89k | if (section == NULL) | 1420 | 1.07k | return; | 1421 | | | 1422 | 815 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1423 | 50 | return; | 1424 | | | 1425 | 765 | dataoff = addr - section->vma; | 1426 | | | 1427 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1428 | | Note - since we are dealing with unsigned quantities we have | 1429 | | to be careful to check for potential overflows. */ | 1430 | 765 | if (dataoff >= section->size | 1431 | 765 | || size > section->size - dataoff) | 1432 | 402 | { | 1433 | 402 | _bfd_error_handler | 1434 | 402 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1435 | 402 | abfd); | 1436 | 402 | return; | 1437 | 402 | } | 1438 | | | 1439 | | /* Read the whole section. */ | 1440 | 363 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1441 | 102 | { | 1442 | 102 | free (data); | 1443 | 102 | return; | 1444 | 102 | } | 1445 | | | 1446 | | /* Search for a CodeView entry in the DebugDirectory */ | 1447 | 4.66k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1448 | 4.59k | { | 1449 | 4.59k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1450 | 4.59k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1451 | 4.59k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1452 | | | 1453 | 4.59k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1454 | | | 1455 | 4.59k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1456 | 192 | { | 1457 | 192 | char buffer[256 + 1]; | 1458 | 192 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1459 | | | 1460 | | /* | 1461 | | The debug entry doesn't have to have to be in a section, in which | 1462 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1463 | | */ | 1464 | 192 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1465 | 192 | (file_ptr) idd.PointerToRawData, | 1466 | 192 | idd.SizeOfData, cvinfo, NULL)) | 1467 | 14 | { | 1468 | 14 | struct bfd_build_id *build_id; | 1469 | 14 | size_t bidlen = sizeof (*build_id) + cvinfo->SignatureLength; | 1470 | | | 1471 | 14 | build_id = bfd_alloc (abfd, bidlen); | 1472 | 14 | if (build_id) | 1473 | 14 | { | 1474 | 14 | build_id->size = cvinfo->SignatureLength; | 1475 | 14 | memcpy(build_id->data, cvinfo->Signature, | 1476 | 14 | cvinfo->SignatureLength); | 1477 | 14 | abfd->build_id = build_id; | 1478 | 14 | } | 1479 | 14 | } | 1480 | 192 | break; | 1481 | 192 | } | 1482 | 4.59k | } | 1483 | | | 1484 | 261 | free (data); | 1485 | 261 | } |
pei-arm-wince.c:pe_bfd_read_buildid Line | Count | Source | 1397 | 2.65k | { | 1398 | 2.65k | pe_data_type *pe = pe_data (abfd); | 1399 | 2.65k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1400 | 2.65k | asection *section; | 1401 | 2.65k | bfd_byte *data = 0; | 1402 | 2.65k | bfd_size_type dataoff; | 1403 | 2.65k | unsigned int i; | 1404 | 2.65k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1405 | 2.65k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1406 | | | 1407 | 2.65k | if (size == 0) | 1408 | 1.41k | return; | 1409 | | | 1410 | 1.24k | addr += extra->ImageBase; | 1411 | | | 1412 | | /* Search for the section containing the DebugDirectory. */ | 1413 | 6.37k | for (section = abfd->sections; section != NULL; section = section->next) | 1414 | 5.62k | { | 1415 | 5.62k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1416 | 491 | break; | 1417 | 5.62k | } | 1418 | | | 1419 | 1.24k | if (section == NULL) | 1420 | 750 | return; | 1421 | | | 1422 | 491 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1423 | 41 | return; | 1424 | | | 1425 | 450 | dataoff = addr - section->vma; | 1426 | | | 1427 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1428 | | Note - since we are dealing with unsigned quantities we have | 1429 | | to be careful to check for potential overflows. */ | 1430 | 450 | if (dataoff >= section->size | 1431 | 450 | || size > section->size - dataoff) | 1432 | 207 | { | 1433 | 207 | _bfd_error_handler | 1434 | 207 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1435 | 207 | abfd); | 1436 | 207 | return; | 1437 | 207 | } | 1438 | | | 1439 | | /* Read the whole section. */ | 1440 | 243 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1441 | 128 | { | 1442 | 128 | free (data); | 1443 | 128 | return; | 1444 | 128 | } | 1445 | | | 1446 | | /* Search for a CodeView entry in the DebugDirectory */ | 1447 | 1.95k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1448 | 1.89k | { | 1449 | 1.89k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1450 | 1.89k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1451 | 1.89k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1452 | | | 1453 | 1.89k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1454 | | | 1455 | 1.89k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1456 | 60 | { | 1457 | 60 | char buffer[256 + 1]; | 1458 | 60 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1459 | | | 1460 | | /* | 1461 | | The debug entry doesn't have to have to be in a section, in which | 1462 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1463 | | */ | 1464 | 60 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1465 | 60 | (file_ptr) idd.PointerToRawData, | 1466 | 60 | idd.SizeOfData, cvinfo, NULL)) | 1467 | 6 | { | 1468 | 6 | struct bfd_build_id *build_id; | 1469 | 6 | size_t bidlen = sizeof (*build_id) + cvinfo->SignatureLength; | 1470 | | | 1471 | 6 | build_id = bfd_alloc (abfd, bidlen); | 1472 | 6 | if (build_id) | 1473 | 6 | { | 1474 | 6 | build_id->size = cvinfo->SignatureLength; | 1475 | 6 | memcpy(build_id->data, cvinfo->Signature, | 1476 | 6 | cvinfo->SignatureLength); | 1477 | 6 | abfd->build_id = build_id; | 1478 | 6 | } | 1479 | 6 | } | 1480 | 60 | break; | 1481 | 60 | } | 1482 | 1.89k | } | 1483 | | | 1484 | 115 | free (data); | 1485 | 115 | } |
pei-arm.c:pe_bfd_read_buildid Line | Count | Source | 1397 | 4.00k | { | 1398 | 4.00k | pe_data_type *pe = pe_data (abfd); | 1399 | 4.00k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1400 | 4.00k | asection *section; | 1401 | 4.00k | bfd_byte *data = 0; | 1402 | 4.00k | bfd_size_type dataoff; | 1403 | 4.00k | unsigned int i; | 1404 | 4.00k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1405 | 4.00k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1406 | | | 1407 | 4.00k | if (size == 0) | 1408 | 2.26k | return; | 1409 | | | 1410 | 1.74k | addr += extra->ImageBase; | 1411 | | | 1412 | | /* Search for the section containing the DebugDirectory. */ | 1413 | 9.79k | for (section = abfd->sections; section != NULL; section = section->next) | 1414 | 8.88k | { | 1415 | 8.88k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1416 | 834 | break; | 1417 | 8.88k | } | 1418 | | | 1419 | 1.74k | if (section == NULL) | 1420 | 912 | return; | 1421 | | | 1422 | 834 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1423 | 40 | return; | 1424 | | | 1425 | 794 | dataoff = addr - section->vma; | 1426 | | | 1427 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1428 | | Note - since we are dealing with unsigned quantities we have | 1429 | | to be careful to check for potential overflows. */ | 1430 | 794 | if (dataoff >= section->size | 1431 | 794 | || size > section->size - dataoff) | 1432 | 343 | { | 1433 | 343 | _bfd_error_handler | 1434 | 343 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1435 | 343 | abfd); | 1436 | 343 | return; | 1437 | 343 | } | 1438 | | | 1439 | | /* Read the whole section. */ | 1440 | 451 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1441 | 198 | { | 1442 | 198 | free (data); | 1443 | 198 | return; | 1444 | 198 | } | 1445 | | | 1446 | | /* Search for a CodeView entry in the DebugDirectory */ | 1447 | 3.62k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1448 | 3.46k | { | 1449 | 3.46k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1450 | 3.46k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1451 | 3.46k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1452 | | | 1453 | 3.46k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1454 | | | 1455 | 3.46k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1456 | 91 | { | 1457 | 91 | char buffer[256 + 1]; | 1458 | 91 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1459 | | | 1460 | | /* | 1461 | | The debug entry doesn't have to have to be in a section, in which | 1462 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1463 | | */ | 1464 | 91 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1465 | 91 | (file_ptr) idd.PointerToRawData, | 1466 | 91 | idd.SizeOfData, cvinfo, NULL)) | 1467 | 17 | { | 1468 | 17 | struct bfd_build_id *build_id; | 1469 | 17 | size_t bidlen = sizeof (*build_id) + cvinfo->SignatureLength; | 1470 | | | 1471 | 17 | build_id = bfd_alloc (abfd, bidlen); | 1472 | 17 | if (build_id) | 1473 | 17 | { | 1474 | 17 | build_id->size = cvinfo->SignatureLength; | 1475 | 17 | memcpy(build_id->data, cvinfo->Signature, | 1476 | 17 | cvinfo->SignatureLength); | 1477 | 17 | abfd->build_id = build_id; | 1478 | 17 | } | 1479 | 17 | } | 1480 | 91 | break; | 1481 | 91 | } | 1482 | 3.46k | } | 1483 | | | 1484 | 253 | free (data); | 1485 | 253 | } |
pei-mcore.c:pe_bfd_read_buildid Line | Count | Source | 1397 | 4.19k | { | 1398 | 4.19k | pe_data_type *pe = pe_data (abfd); | 1399 | 4.19k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1400 | 4.19k | asection *section; | 1401 | 4.19k | bfd_byte *data = 0; | 1402 | 4.19k | bfd_size_type dataoff; | 1403 | 4.19k | unsigned int i; | 1404 | 4.19k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1405 | 4.19k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1406 | | | 1407 | 4.19k | if (size == 0) | 1408 | 2.71k | return; | 1409 | | | 1410 | 1.47k | addr += extra->ImageBase; | 1411 | | | 1412 | | /* Search for the section containing the DebugDirectory. */ | 1413 | 13.3k | for (section = abfd->sections; section != NULL; section = section->next) | 1414 | 12.6k | { | 1415 | 12.6k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1416 | 756 | break; | 1417 | 12.6k | } | 1418 | | | 1419 | 1.47k | if (section == NULL) | 1420 | 719 | return; | 1421 | | | 1422 | 756 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1423 | 72 | return; | 1424 | | | 1425 | 684 | dataoff = addr - section->vma; | 1426 | | | 1427 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1428 | | Note - since we are dealing with unsigned quantities we have | 1429 | | to be careful to check for potential overflows. */ | 1430 | 684 | if (dataoff >= section->size | 1431 | 684 | || size > section->size - dataoff) | 1432 | 348 | { | 1433 | 348 | _bfd_error_handler | 1434 | 348 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1435 | 348 | abfd); | 1436 | 348 | return; | 1437 | 348 | } | 1438 | | | 1439 | | /* Read the whole section. */ | 1440 | 336 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1441 | 171 | { | 1442 | 171 | free (data); | 1443 | 171 | return; | 1444 | 171 | } | 1445 | | | 1446 | | /* Search for a CodeView entry in the DebugDirectory */ | 1447 | 3.85k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1448 | 3.75k | { | 1449 | 3.75k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1450 | 3.75k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1451 | 3.75k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1452 | | | 1453 | 3.75k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1454 | | | 1455 | 3.75k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1456 | 62 | { | 1457 | 62 | char buffer[256 + 1]; | 1458 | 62 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1459 | | | 1460 | | /* | 1461 | | The debug entry doesn't have to have to be in a section, in which | 1462 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1463 | | */ | 1464 | 62 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1465 | 62 | (file_ptr) idd.PointerToRawData, | 1466 | 62 | idd.SizeOfData, cvinfo, NULL)) | 1467 | 3 | { | 1468 | 3 | struct bfd_build_id *build_id; | 1469 | 3 | size_t bidlen = sizeof (*build_id) + cvinfo->SignatureLength; | 1470 | | | 1471 | 3 | build_id = bfd_alloc (abfd, bidlen); | 1472 | 3 | if (build_id) | 1473 | 3 | { | 1474 | 3 | build_id->size = cvinfo->SignatureLength; | 1475 | 3 | memcpy(build_id->data, cvinfo->Signature, | 1476 | 3 | cvinfo->SignatureLength); | 1477 | 3 | abfd->build_id = build_id; | 1478 | 3 | } | 1479 | 3 | } | 1480 | 62 | break; | 1481 | 62 | } | 1482 | 3.75k | } | 1483 | | | 1484 | 165 | free (data); | 1485 | 165 | } |
pei-sh.c:pe_bfd_read_buildid Line | Count | Source | 1397 | 4.49k | { | 1398 | 4.49k | pe_data_type *pe = pe_data (abfd); | 1399 | 4.49k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1400 | 4.49k | asection *section; | 1401 | 4.49k | bfd_byte *data = 0; | 1402 | 4.49k | bfd_size_type dataoff; | 1403 | 4.49k | unsigned int i; | 1404 | 4.49k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1405 | 4.49k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1406 | | | 1407 | 4.49k | if (size == 0) | 1408 | 2.89k | return; | 1409 | | | 1410 | 1.60k | addr += extra->ImageBase; | 1411 | | | 1412 | | /* Search for the section containing the DebugDirectory. */ | 1413 | 10.6k | for (section = abfd->sections; section != NULL; section = section->next) | 1414 | 9.88k | { | 1415 | 9.88k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1416 | 858 | break; | 1417 | 9.88k | } | 1418 | | | 1419 | 1.60k | if (section == NULL) | 1420 | 745 | return; | 1421 | | | 1422 | 858 | if (!(section->flags & SEC_HAS_CONTENTS)) | 1423 | 75 | return; | 1424 | | | 1425 | 783 | dataoff = addr - section->vma; | 1426 | | | 1427 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1428 | | Note - since we are dealing with unsigned quantities we have | 1429 | | to be careful to check for potential overflows. */ | 1430 | 783 | if (dataoff >= section->size | 1431 | 783 | || size > section->size - dataoff) | 1432 | 381 | { | 1433 | 381 | _bfd_error_handler | 1434 | 381 | (_("%pB: error: debug data ends beyond end of debug directory"), | 1435 | 381 | abfd); | 1436 | 381 | return; | 1437 | 381 | } | 1438 | | | 1439 | | /* Read the whole section. */ | 1440 | 402 | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1441 | 194 | { | 1442 | 194 | free (data); | 1443 | 194 | return; | 1444 | 194 | } | 1445 | | | 1446 | | /* Search for a CodeView entry in the DebugDirectory */ | 1447 | 5.91k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1448 | 5.79k | { | 1449 | 5.79k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1450 | 5.79k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1451 | 5.79k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1452 | | | 1453 | 5.79k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1454 | | | 1455 | 5.79k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1456 | 88 | { | 1457 | 88 | char buffer[256 + 1]; | 1458 | 88 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1459 | | | 1460 | | /* | 1461 | | The debug entry doesn't have to have to be in a section, in which | 1462 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1463 | | */ | 1464 | 88 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1465 | 88 | (file_ptr) idd.PointerToRawData, | 1466 | 88 | idd.SizeOfData, cvinfo, NULL)) | 1467 | 3 | { | 1468 | 3 | struct bfd_build_id *build_id; | 1469 | 3 | size_t bidlen = sizeof (*build_id) + cvinfo->SignatureLength; | 1470 | | | 1471 | 3 | build_id = bfd_alloc (abfd, bidlen); | 1472 | 3 | if (build_id) | 1473 | 3 | { | 1474 | 3 | build_id->size = cvinfo->SignatureLength; | 1475 | 3 | memcpy(build_id->data, cvinfo->Signature, | 1476 | 3 | cvinfo->SignatureLength); | 1477 | 3 | abfd->build_id = build_id; | 1478 | 3 | } | 1479 | 3 | } | 1480 | 88 | break; | 1481 | 88 | } | 1482 | 5.79k | } | 1483 | | | 1484 | 208 | free (data); | 1485 | 208 | } |
|
1486 | | |
1487 | | static bfd_cleanup |
1488 | | pe_bfd_object_p (bfd *abfd) |
1489 | 2.52M | { |
1490 | 2.52M | bfd_byte buffer[6]; |
1491 | 2.52M | struct external_DOS_hdr dos_hdr; |
1492 | 2.52M | struct external_PEI_IMAGE_hdr image_hdr; |
1493 | 2.52M | struct internal_filehdr internal_f; |
1494 | 2.52M | struct internal_aouthdr internal_a; |
1495 | 2.52M | bfd_size_type opt_hdr_size; |
1496 | 2.52M | file_ptr offset; |
1497 | 2.52M | bfd_cleanup result; |
1498 | | |
1499 | | /* Detect if this a Microsoft Import Library Format element. */ |
1500 | | /* First read the beginning of the header. */ |
1501 | 2.52M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 |
1502 | 2.52M | || bfd_read (buffer, 6, abfd) != 6) |
1503 | 30.8k | { |
1504 | 30.8k | if (bfd_get_error () != bfd_error_system_call) |
1505 | 25.4k | bfd_set_error (bfd_error_wrong_format); |
1506 | 30.8k | return NULL; |
1507 | 30.8k | } |
1508 | | |
1509 | | /* Then check the magic and the version (only 0 is supported). */ |
1510 | 2.49M | if (H_GET_32 (abfd, buffer) == 0xffff0000 |
1511 | 48.4k | && H_GET_16 (abfd, buffer + 4) == 0) |
1512 | 39.8k | return pe_ILF_object_p (abfd); |
1513 | | |
1514 | 2.45M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 |
1515 | 2.45M | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) |
1516 | 607k | { |
1517 | 607k | if (bfd_get_error () != bfd_error_system_call) |
1518 | 607k | bfd_set_error (bfd_error_wrong_format); |
1519 | 607k | return NULL; |
1520 | 607k | } |
1521 | | |
1522 | | /* There are really two magic numbers involved; the magic number |
1523 | | that says this is a NT executable (PEI) and the magic number that |
1524 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in |
1525 | | the e_magic field. The latter is stored in the f_magic field. |
1526 | | If the NT magic number isn't valid, the architecture magic number |
1527 | | could be mimicked by some other field (specifically, the number |
1528 | | of relocs in section 3). Since this routine can only be called |
1529 | | correctly for a PEI file, check the e_magic number here, and, if |
1530 | | it doesn't match, clobber the f_magic number so that we don't get |
1531 | | a false match. */ |
1532 | 1.85M | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) |
1533 | 1.33M | { |
1534 | 1.33M | bfd_set_error (bfd_error_wrong_format); |
1535 | 1.33M | return NULL; |
1536 | 1.33M | } |
1537 | | |
1538 | 511k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); |
1539 | 511k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 |
1540 | 511k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) |
1541 | 8.28k | { |
1542 | 8.28k | if (bfd_get_error () != bfd_error_system_call) |
1543 | 8.28k | bfd_set_error (bfd_error_wrong_format); |
1544 | 8.28k | return NULL; |
1545 | 8.28k | } |
1546 | | |
1547 | 502k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) |
1548 | 10.5k | { |
1549 | 10.5k | bfd_set_error (bfd_error_wrong_format); |
1550 | 10.5k | return NULL; |
1551 | 10.5k | } |
1552 | | |
1553 | | /* Swap file header, so that we get the location for calling |
1554 | | real_object_p. */ |
1555 | 492k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); |
1556 | | |
1557 | 492k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) |
1558 | 76.2k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) |
1559 | 416k | { |
1560 | 416k | bfd_set_error (bfd_error_wrong_format); |
1561 | 416k | return NULL; |
1562 | 416k | } |
1563 | | |
1564 | 75.9k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, |
1565 | 75.9k | sizeof (internal_f.pe.dos_message)); |
1566 | | |
1567 | | /* Read the optional header, which has variable size. */ |
1568 | 75.9k | opt_hdr_size = internal_f.f_opthdr; |
1569 | | |
1570 | 75.9k | if (opt_hdr_size != 0) |
1571 | 45.9k | { |
1572 | 45.9k | bfd_size_type amt = opt_hdr_size; |
1573 | 45.9k | bfd_byte *opthdr; |
1574 | | |
1575 | | /* PR 17521 file: 230-131433-0.004. */ |
1576 | 45.9k | if (amt < sizeof (PEAOUTHDR)) |
1577 | 42.6k | amt = sizeof (PEAOUTHDR); |
1578 | | |
1579 | 45.9k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); |
1580 | 45.9k | if (opthdr == NULL) |
1581 | 441 | return NULL; |
1582 | 45.4k | if (amt > opt_hdr_size) |
1583 | 42.3k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); |
1584 | | |
1585 | 45.4k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); |
1586 | | |
1587 | 45.4k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; |
1588 | | |
1589 | | #ifdef ARM |
1590 | | /* Use Subsystem to distinguish between pei-arm-little and |
1591 | | pei-arm-wince-little. */ |
1592 | | #ifdef WINCE |
1593 | 4.77k | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) |
1594 | | #else |
1595 | 5.14k | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) |
1596 | 1.50k | #endif |
1597 | 4.35k | { |
1598 | 4.35k | bfd_set_error (bfd_error_wrong_format); |
1599 | 4.35k | return NULL; |
1600 | 4.35k | } |
1601 | 5.56k | #endif |
1602 | | |
1603 | 41.1k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment |
1604 | 19.3k | || a->SectionAlignment >= 0x80000000) |
1605 | 22.1k | { |
1606 | 22.1k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), |
1607 | 22.1k | abfd); |
1608 | 22.1k | a->SectionAlignment &= -a->SectionAlignment; |
1609 | 22.1k | if (a->SectionAlignment >= 0x80000000) |
1610 | 420 | a->SectionAlignment = 0x40000000; |
1611 | 22.1k | } |
1612 | | |
1613 | 41.1k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment |
1614 | 20.8k | || a->FileAlignment > a->SectionAlignment) |
1615 | 26.6k | { |
1616 | 26.6k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), |
1617 | 26.6k | abfd); |
1618 | 26.6k | a->FileAlignment &= -a->FileAlignment; |
1619 | 26.6k | if (a->FileAlignment > a->SectionAlignment) |
1620 | 18.7k | a->FileAlignment = a->SectionAlignment; |
1621 | 26.6k | } |
1622 | | |
1623 | 41.1k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) |
1624 | 21.8k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); |
1625 | 5.56k | } |
1626 | | |
1627 | 71.1k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, |
1628 | 71.1k | (opt_hdr_size != 0 |
1629 | 71.1k | ? &internal_a |
1630 | 71.1k | : (struct internal_aouthdr *) NULL)); |
1631 | | |
1632 | 71.1k | if (result) |
1633 | 50.8k | { |
1634 | | /* Now the whole header has been processed, see if there is a build-id */ |
1635 | 50.8k | pe_bfd_read_buildid(abfd); |
1636 | 50.8k | } |
1637 | | |
1638 | 71.1k | return result; |
1639 | 75.9k | } pei-i386.c:pe_bfd_object_p Line | Count | Source | 1489 | 228k | { | 1490 | 228k | bfd_byte buffer[6]; | 1491 | 228k | struct external_DOS_hdr dos_hdr; | 1492 | 228k | struct external_PEI_IMAGE_hdr image_hdr; | 1493 | 228k | struct internal_filehdr internal_f; | 1494 | 228k | struct internal_aouthdr internal_a; | 1495 | 228k | bfd_size_type opt_hdr_size; | 1496 | 228k | file_ptr offset; | 1497 | 228k | bfd_cleanup result; | 1498 | | | 1499 | | /* Detect if this a Microsoft Import Library Format element. */ | 1500 | | /* First read the beginning of the header. */ | 1501 | 228k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1502 | 228k | || bfd_read (buffer, 6, abfd) != 6) | 1503 | 2.75k | { | 1504 | 2.75k | if (bfd_get_error () != bfd_error_system_call) | 1505 | 2.30k | bfd_set_error (bfd_error_wrong_format); | 1506 | 2.75k | return NULL; | 1507 | 2.75k | } | 1508 | | | 1509 | | /* Then check the magic and the version (only 0 is supported). */ | 1510 | 226k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1511 | 5.61k | && H_GET_16 (abfd, buffer + 4) == 0) | 1512 | 4.61k | return pe_ILF_object_p (abfd); | 1513 | | | 1514 | 221k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1515 | 221k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1516 | 54.9k | { | 1517 | 54.9k | if (bfd_get_error () != bfd_error_system_call) | 1518 | 54.9k | bfd_set_error (bfd_error_wrong_format); | 1519 | 54.9k | return NULL; | 1520 | 54.9k | } | 1521 | | | 1522 | | /* There are really two magic numbers involved; the magic number | 1523 | | that says this is a NT executable (PEI) and the magic number that | 1524 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1525 | | the e_magic field. The latter is stored in the f_magic field. | 1526 | | If the NT magic number isn't valid, the architecture magic number | 1527 | | could be mimicked by some other field (specifically, the number | 1528 | | of relocs in section 3). Since this routine can only be called | 1529 | | correctly for a PEI file, check the e_magic number here, and, if | 1530 | | it doesn't match, clobber the f_magic number so that we don't get | 1531 | | a false match. */ | 1532 | 166k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1533 | 108k | { | 1534 | 108k | bfd_set_error (bfd_error_wrong_format); | 1535 | 108k | return NULL; | 1536 | 108k | } | 1537 | | | 1538 | 57.7k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1539 | 57.7k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1540 | 57.7k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1541 | 921 | { | 1542 | 921 | if (bfd_get_error () != bfd_error_system_call) | 1543 | 921 | bfd_set_error (bfd_error_wrong_format); | 1544 | 921 | return NULL; | 1545 | 921 | } | 1546 | | | 1547 | 56.8k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1548 | 1.17k | { | 1549 | 1.17k | bfd_set_error (bfd_error_wrong_format); | 1550 | 1.17k | return NULL; | 1551 | 1.17k | } | 1552 | | | 1553 | | /* Swap file header, so that we get the location for calling | 1554 | | real_object_p. */ | 1555 | 55.6k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1556 | | | 1557 | 55.6k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1558 | 9.93k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1559 | 45.7k | { | 1560 | 45.7k | bfd_set_error (bfd_error_wrong_format); | 1561 | 45.7k | return NULL; | 1562 | 45.7k | } | 1563 | | | 1564 | 9.90k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1565 | 9.90k | sizeof (internal_f.pe.dos_message)); | 1566 | | | 1567 | | /* Read the optional header, which has variable size. */ | 1568 | 9.90k | opt_hdr_size = internal_f.f_opthdr; | 1569 | | | 1570 | 9.90k | if (opt_hdr_size != 0) | 1571 | 4.95k | { | 1572 | 4.95k | bfd_size_type amt = opt_hdr_size; | 1573 | 4.95k | bfd_byte *opthdr; | 1574 | | | 1575 | | /* PR 17521 file: 230-131433-0.004. */ | 1576 | 4.95k | if (amt < sizeof (PEAOUTHDR)) | 1577 | 4.15k | amt = sizeof (PEAOUTHDR); | 1578 | | | 1579 | 4.95k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1580 | 4.95k | if (opthdr == NULL) | 1581 | 42 | return NULL; | 1582 | 4.91k | if (amt > opt_hdr_size) | 1583 | 4.12k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1584 | | | 1585 | 4.91k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1586 | | | 1587 | 4.91k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1588 | | | 1589 | | #ifdef ARM | 1590 | | /* Use Subsystem to distinguish between pei-arm-little and | 1591 | | pei-arm-wince-little. */ | 1592 | | #ifdef WINCE | 1593 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1594 | | #else | 1595 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1596 | | #endif | 1597 | | { | 1598 | | bfd_set_error (bfd_error_wrong_format); | 1599 | | return NULL; | 1600 | | } | 1601 | | #endif | 1602 | | | 1603 | 4.91k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1604 | 2.70k | || a->SectionAlignment >= 0x80000000) | 1605 | 2.29k | { | 1606 | 2.29k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1607 | 2.29k | abfd); | 1608 | 2.29k | a->SectionAlignment &= -a->SectionAlignment; | 1609 | 2.29k | if (a->SectionAlignment >= 0x80000000) | 1610 | 83 | a->SectionAlignment = 0x40000000; | 1611 | 2.29k | } | 1612 | | | 1613 | 4.91k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1614 | 2.75k | || a->FileAlignment > a->SectionAlignment) | 1615 | 2.65k | { | 1616 | 2.65k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1617 | 2.65k | abfd); | 1618 | 2.65k | a->FileAlignment &= -a->FileAlignment; | 1619 | 2.65k | if (a->FileAlignment > a->SectionAlignment) | 1620 | 1.73k | a->FileAlignment = a->SectionAlignment; | 1621 | 2.65k | } | 1622 | | | 1623 | 4.91k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1624 | 2.37k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1625 | 4.91k | } | 1626 | | | 1627 | 9.86k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1628 | 9.86k | (opt_hdr_size != 0 | 1629 | 9.86k | ? &internal_a | 1630 | 9.86k | : (struct internal_aouthdr *) NULL)); | 1631 | | | 1632 | 9.86k | if (result) | 1633 | 8.35k | { | 1634 | | /* Now the whole header has been processed, see if there is a build-id */ | 1635 | 8.35k | pe_bfd_read_buildid(abfd); | 1636 | 8.35k | } | 1637 | | | 1638 | 9.86k | return result; | 1639 | 9.90k | } |
pei-x86_64.c:pe_bfd_object_p Line | Count | Source | 1489 | 227k | { | 1490 | 227k | bfd_byte buffer[6]; | 1491 | 227k | struct external_DOS_hdr dos_hdr; | 1492 | 227k | struct external_PEI_IMAGE_hdr image_hdr; | 1493 | 227k | struct internal_filehdr internal_f; | 1494 | 227k | struct internal_aouthdr internal_a; | 1495 | 227k | bfd_size_type opt_hdr_size; | 1496 | 227k | file_ptr offset; | 1497 | 227k | bfd_cleanup result; | 1498 | | | 1499 | | /* Detect if this a Microsoft Import Library Format element. */ | 1500 | | /* First read the beginning of the header. */ | 1501 | 227k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1502 | 227k | || bfd_read (buffer, 6, abfd) != 6) | 1503 | 2.75k | { | 1504 | 2.75k | if (bfd_get_error () != bfd_error_system_call) | 1505 | 2.30k | bfd_set_error (bfd_error_wrong_format); | 1506 | 2.75k | return NULL; | 1507 | 2.75k | } | 1508 | | | 1509 | | /* Then check the magic and the version (only 0 is supported). */ | 1510 | 224k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1511 | 5.56k | && H_GET_16 (abfd, buffer + 4) == 0) | 1512 | 4.56k | return pe_ILF_object_p (abfd); | 1513 | | | 1514 | 220k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1515 | 220k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1516 | 54.9k | { | 1517 | 54.9k | if (bfd_get_error () != bfd_error_system_call) | 1518 | 54.9k | bfd_set_error (bfd_error_wrong_format); | 1519 | 54.9k | return NULL; | 1520 | 54.9k | } | 1521 | | | 1522 | | /* There are really two magic numbers involved; the magic number | 1523 | | that says this is a NT executable (PEI) and the magic number that | 1524 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1525 | | the e_magic field. The latter is stored in the f_magic field. | 1526 | | If the NT magic number isn't valid, the architecture magic number | 1527 | | could be mimicked by some other field (specifically, the number | 1528 | | of relocs in section 3). Since this routine can only be called | 1529 | | correctly for a PEI file, check the e_magic number here, and, if | 1530 | | it doesn't match, clobber the f_magic number so that we don't get | 1531 | | a false match. */ | 1532 | 165k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1533 | 108k | { | 1534 | 108k | bfd_set_error (bfd_error_wrong_format); | 1535 | 108k | return NULL; | 1536 | 108k | } | 1537 | | | 1538 | 56.6k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1539 | 56.6k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1540 | 56.6k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1541 | 921 | { | 1542 | 921 | if (bfd_get_error () != bfd_error_system_call) | 1543 | 921 | bfd_set_error (bfd_error_wrong_format); | 1544 | 921 | return NULL; | 1545 | 921 | } | 1546 | | | 1547 | 55.7k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1548 | 1.17k | { | 1549 | 1.17k | bfd_set_error (bfd_error_wrong_format); | 1550 | 1.17k | return NULL; | 1551 | 1.17k | } | 1552 | | | 1553 | | /* Swap file header, so that we get the location for calling | 1554 | | real_object_p. */ | 1555 | 54.5k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1556 | | | 1557 | 54.5k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1558 | 7.83k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1559 | 46.7k | { | 1560 | 46.7k | bfd_set_error (bfd_error_wrong_format); | 1561 | 46.7k | return NULL; | 1562 | 46.7k | } | 1563 | | | 1564 | 7.78k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1565 | 7.78k | sizeof (internal_f.pe.dos_message)); | 1566 | | | 1567 | | /* Read the optional header, which has variable size. */ | 1568 | 7.78k | opt_hdr_size = internal_f.f_opthdr; | 1569 | | | 1570 | 7.78k | if (opt_hdr_size != 0) | 1571 | 4.67k | { | 1572 | 4.67k | bfd_size_type amt = opt_hdr_size; | 1573 | 4.67k | bfd_byte *opthdr; | 1574 | | | 1575 | | /* PR 17521 file: 230-131433-0.004. */ | 1576 | 4.67k | if (amt < sizeof (PEAOUTHDR)) | 1577 | 4.36k | amt = sizeof (PEAOUTHDR); | 1578 | | | 1579 | 4.67k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1580 | 4.67k | if (opthdr == NULL) | 1581 | 37 | return NULL; | 1582 | 4.64k | if (amt > opt_hdr_size) | 1583 | 4.33k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1584 | | | 1585 | 4.64k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1586 | | | 1587 | 4.64k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1588 | | | 1589 | | #ifdef ARM | 1590 | | /* Use Subsystem to distinguish between pei-arm-little and | 1591 | | pei-arm-wince-little. */ | 1592 | | #ifdef WINCE | 1593 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1594 | | #else | 1595 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1596 | | #endif | 1597 | | { | 1598 | | bfd_set_error (bfd_error_wrong_format); | 1599 | | return NULL; | 1600 | | } | 1601 | | #endif | 1602 | | | 1603 | 4.64k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1604 | 2.41k | || a->SectionAlignment >= 0x80000000) | 1605 | 2.26k | { | 1606 | 2.26k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1607 | 2.26k | abfd); | 1608 | 2.26k | a->SectionAlignment &= -a->SectionAlignment; | 1609 | 2.26k | if (a->SectionAlignment >= 0x80000000) | 1610 | 37 | a->SectionAlignment = 0x40000000; | 1611 | 2.26k | } | 1612 | | | 1613 | 4.64k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1614 | 2.37k | || a->FileAlignment > a->SectionAlignment) | 1615 | 2.73k | { | 1616 | 2.73k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1617 | 2.73k | abfd); | 1618 | 2.73k | a->FileAlignment &= -a->FileAlignment; | 1619 | 2.73k | if (a->FileAlignment > a->SectionAlignment) | 1620 | 1.46k | a->FileAlignment = a->SectionAlignment; | 1621 | 2.73k | } | 1622 | | | 1623 | 4.64k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1624 | 2.35k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1625 | 4.64k | } | 1626 | | | 1627 | 7.74k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1628 | 7.74k | (opt_hdr_size != 0 | 1629 | 7.74k | ? &internal_a | 1630 | 7.74k | : (struct internal_aouthdr *) NULL)); | 1631 | | | 1632 | 7.74k | if (result) | 1633 | 5.96k | { | 1634 | | /* Now the whole header has been processed, see if there is a build-id */ | 1635 | 5.96k | pe_bfd_read_buildid(abfd); | 1636 | 5.96k | } | 1637 | | | 1638 | 7.74k | return result; | 1639 | 7.78k | } |
pei-aarch64.c:pe_bfd_object_p Line | Count | Source | 1489 | 225k | { | 1490 | 225k | bfd_byte buffer[6]; | 1491 | 225k | struct external_DOS_hdr dos_hdr; | 1492 | 225k | struct external_PEI_IMAGE_hdr image_hdr; | 1493 | 225k | struct internal_filehdr internal_f; | 1494 | 225k | struct internal_aouthdr internal_a; | 1495 | 225k | bfd_size_type opt_hdr_size; | 1496 | 225k | file_ptr offset; | 1497 | 225k | bfd_cleanup result; | 1498 | | | 1499 | | /* Detect if this a Microsoft Import Library Format element. */ | 1500 | | /* First read the beginning of the header. */ | 1501 | 225k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1502 | 225k | || bfd_read (buffer, 6, abfd) != 6) | 1503 | 2.75k | { | 1504 | 2.75k | if (bfd_get_error () != bfd_error_system_call) | 1505 | 2.30k | bfd_set_error (bfd_error_wrong_format); | 1506 | 2.75k | return NULL; | 1507 | 2.75k | } | 1508 | | | 1509 | | /* Then check the magic and the version (only 0 is supported). */ | 1510 | 223k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1511 | 5.60k | && H_GET_16 (abfd, buffer + 4) == 0) | 1512 | 4.60k | return pe_ILF_object_p (abfd); | 1513 | | | 1514 | 218k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1515 | 218k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1516 | 54.8k | { | 1517 | 54.8k | if (bfd_get_error () != bfd_error_system_call) | 1518 | 54.8k | bfd_set_error (bfd_error_wrong_format); | 1519 | 54.8k | return NULL; | 1520 | 54.8k | } | 1521 | | | 1522 | | /* There are really two magic numbers involved; the magic number | 1523 | | that says this is a NT executable (PEI) and the magic number that | 1524 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1525 | | the e_magic field. The latter is stored in the f_magic field. | 1526 | | If the NT magic number isn't valid, the architecture magic number | 1527 | | could be mimicked by some other field (specifically, the number | 1528 | | of relocs in section 3). Since this routine can only be called | 1529 | | correctly for a PEI file, check the e_magic number here, and, if | 1530 | | it doesn't match, clobber the f_magic number so that we don't get | 1531 | | a false match. */ | 1532 | 163k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1533 | 108k | { | 1534 | 108k | bfd_set_error (bfd_error_wrong_format); | 1535 | 108k | return NULL; | 1536 | 108k | } | 1537 | | | 1538 | 54.8k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1539 | 54.8k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1540 | 54.8k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1541 | 921 | { | 1542 | 921 | if (bfd_get_error () != bfd_error_system_call) | 1543 | 921 | bfd_set_error (bfd_error_wrong_format); | 1544 | 921 | return NULL; | 1545 | 921 | } | 1546 | | | 1547 | 53.9k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1548 | 1.17k | { | 1549 | 1.17k | bfd_set_error (bfd_error_wrong_format); | 1550 | 1.17k | return NULL; | 1551 | 1.17k | } | 1552 | | | 1553 | | /* Swap file header, so that we get the location for calling | 1554 | | real_object_p. */ | 1555 | 52.7k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1556 | | | 1557 | 52.7k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1558 | 8.71k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1559 | 44.0k | { | 1560 | 44.0k | bfd_set_error (bfd_error_wrong_format); | 1561 | 44.0k | return NULL; | 1562 | 44.0k | } | 1563 | | | 1564 | 8.68k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1565 | 8.68k | sizeof (internal_f.pe.dos_message)); | 1566 | | | 1567 | | /* Read the optional header, which has variable size. */ | 1568 | 8.68k | opt_hdr_size = internal_f.f_opthdr; | 1569 | | | 1570 | 8.68k | if (opt_hdr_size != 0) | 1571 | 6.50k | { | 1572 | 6.50k | bfd_size_type amt = opt_hdr_size; | 1573 | 6.50k | bfd_byte *opthdr; | 1574 | | | 1575 | | /* PR 17521 file: 230-131433-0.004. */ | 1576 | 6.50k | if (amt < sizeof (PEAOUTHDR)) | 1577 | 6.25k | amt = sizeof (PEAOUTHDR); | 1578 | | | 1579 | 6.50k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1580 | 6.50k | if (opthdr == NULL) | 1581 | 39 | return NULL; | 1582 | 6.46k | if (amt > opt_hdr_size) | 1583 | 6.22k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1584 | | | 1585 | 6.46k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1586 | | | 1587 | 6.46k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1588 | | | 1589 | | #ifdef ARM | 1590 | | /* Use Subsystem to distinguish between pei-arm-little and | 1591 | | pei-arm-wince-little. */ | 1592 | | #ifdef WINCE | 1593 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1594 | | #else | 1595 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1596 | | #endif | 1597 | | { | 1598 | | bfd_set_error (bfd_error_wrong_format); | 1599 | | return NULL; | 1600 | | } | 1601 | | #endif | 1602 | | | 1603 | 6.46k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1604 | 2.11k | || a->SectionAlignment >= 0x80000000) | 1605 | 4.37k | { | 1606 | 4.37k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1607 | 4.37k | abfd); | 1608 | 4.37k | a->SectionAlignment &= -a->SectionAlignment; | 1609 | 4.37k | if (a->SectionAlignment >= 0x80000000) | 1610 | 30 | a->SectionAlignment = 0x40000000; | 1611 | 4.37k | } | 1612 | | | 1613 | 6.46k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1614 | 4.22k | || a->FileAlignment > a->SectionAlignment) | 1615 | 4.95k | { | 1616 | 4.95k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1617 | 4.95k | abfd); | 1618 | 4.95k | a->FileAlignment &= -a->FileAlignment; | 1619 | 4.95k | if (a->FileAlignment > a->SectionAlignment) | 1620 | 3.95k | a->FileAlignment = a->SectionAlignment; | 1621 | 4.95k | } | 1622 | | | 1623 | 6.46k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1624 | 2.96k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1625 | 6.46k | } | 1626 | | | 1627 | 8.65k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1628 | 8.65k | (opt_hdr_size != 0 | 1629 | 8.65k | ? &internal_a | 1630 | 8.65k | : (struct internal_aouthdr *) NULL)); | 1631 | | | 1632 | 8.65k | if (result) | 1633 | 6.56k | { | 1634 | | /* Now the whole header has been processed, see if there is a build-id */ | 1635 | 6.56k | pe_bfd_read_buildid(abfd); | 1636 | 6.56k | } | 1637 | | | 1638 | 8.65k | return result; | 1639 | 8.68k | } |
pei-ia64.c:pe_bfd_object_p Line | Count | Source | 1489 | 16.9k | { | 1490 | 16.9k | bfd_byte buffer[6]; | 1491 | 16.9k | struct external_DOS_hdr dos_hdr; | 1492 | 16.9k | struct external_PEI_IMAGE_hdr image_hdr; | 1493 | 16.9k | struct internal_filehdr internal_f; | 1494 | 16.9k | struct internal_aouthdr internal_a; | 1495 | 16.9k | bfd_size_type opt_hdr_size; | 1496 | 16.9k | file_ptr offset; | 1497 | 16.9k | bfd_cleanup result; | 1498 | | | 1499 | | /* Detect if this a Microsoft Import Library Format element. */ | 1500 | | /* First read the beginning of the header. */ | 1501 | 16.9k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1502 | 16.9k | || bfd_read (buffer, 6, abfd) != 6) | 1503 | 0 | { | 1504 | 0 | if (bfd_get_error () != bfd_error_system_call) | 1505 | 0 | bfd_set_error (bfd_error_wrong_format); | 1506 | 0 | return NULL; | 1507 | 0 | } | 1508 | | | 1509 | | /* Then check the magic and the version (only 0 is supported). */ | 1510 | 16.9k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1511 | 0 | && H_GET_16 (abfd, buffer + 4) == 0) | 1512 | 0 | return pe_ILF_object_p (abfd); | 1513 | | | 1514 | 16.9k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1515 | 16.9k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1516 | 0 | { | 1517 | 0 | if (bfd_get_error () != bfd_error_system_call) | 1518 | 0 | bfd_set_error (bfd_error_wrong_format); | 1519 | 0 | return NULL; | 1520 | 0 | } | 1521 | | | 1522 | | /* There are really two magic numbers involved; the magic number | 1523 | | that says this is a NT executable (PEI) and the magic number that | 1524 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1525 | | the e_magic field. The latter is stored in the f_magic field. | 1526 | | If the NT magic number isn't valid, the architecture magic number | 1527 | | could be mimicked by some other field (specifically, the number | 1528 | | of relocs in section 3). Since this routine can only be called | 1529 | | correctly for a PEI file, check the e_magic number here, and, if | 1530 | | it doesn't match, clobber the f_magic number so that we don't get | 1531 | | a false match. */ | 1532 | 16.9k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1533 | 0 | { | 1534 | 0 | bfd_set_error (bfd_error_wrong_format); | 1535 | 0 | return NULL; | 1536 | 0 | } | 1537 | | | 1538 | 16.9k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1539 | 16.9k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1540 | 16.9k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1541 | 0 | { | 1542 | 0 | if (bfd_get_error () != bfd_error_system_call) | 1543 | 0 | bfd_set_error (bfd_error_wrong_format); | 1544 | 0 | return NULL; | 1545 | 0 | } | 1546 | | | 1547 | 16.9k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1548 | 0 | { | 1549 | 0 | bfd_set_error (bfd_error_wrong_format); | 1550 | 0 | return NULL; | 1551 | 0 | } | 1552 | | | 1553 | | /* Swap file header, so that we get the location for calling | 1554 | | real_object_p. */ | 1555 | 16.9k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1556 | | | 1557 | 16.9k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1558 | 7.39k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1559 | 9.63k | { | 1560 | 9.63k | bfd_set_error (bfd_error_wrong_format); | 1561 | 9.63k | return NULL; | 1562 | 9.63k | } | 1563 | | | 1564 | 7.35k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1565 | 7.35k | sizeof (internal_f.pe.dos_message)); | 1566 | | | 1567 | | /* Read the optional header, which has variable size. */ | 1568 | 7.35k | opt_hdr_size = internal_f.f_opthdr; | 1569 | | | 1570 | 7.35k | if (opt_hdr_size != 0) | 1571 | 3.46k | { | 1572 | 3.46k | bfd_size_type amt = opt_hdr_size; | 1573 | 3.46k | bfd_byte *opthdr; | 1574 | | | 1575 | | /* PR 17521 file: 230-131433-0.004. */ | 1576 | 3.46k | if (amt < sizeof (PEAOUTHDR)) | 1577 | 3.35k | amt = sizeof (PEAOUTHDR); | 1578 | | | 1579 | 3.46k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1580 | 3.46k | if (opthdr == NULL) | 1581 | 39 | return NULL; | 1582 | 3.42k | if (amt > opt_hdr_size) | 1583 | 3.32k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1584 | | | 1585 | 3.42k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1586 | | | 1587 | 3.42k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1588 | | | 1589 | | #ifdef ARM | 1590 | | /* Use Subsystem to distinguish between pei-arm-little and | 1591 | | pei-arm-wince-little. */ | 1592 | | #ifdef WINCE | 1593 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1594 | | #else | 1595 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1596 | | #endif | 1597 | | { | 1598 | | bfd_set_error (bfd_error_wrong_format); | 1599 | | return NULL; | 1600 | | } | 1601 | | #endif | 1602 | | | 1603 | 3.42k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1604 | 1.51k | || a->SectionAlignment >= 0x80000000) | 1605 | 1.95k | { | 1606 | 1.95k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1607 | 1.95k | abfd); | 1608 | 1.95k | a->SectionAlignment &= -a->SectionAlignment; | 1609 | 1.95k | if (a->SectionAlignment >= 0x80000000) | 1610 | 49 | a->SectionAlignment = 0x40000000; | 1611 | 1.95k | } | 1612 | | | 1613 | 3.42k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1614 | 1.41k | || a->FileAlignment > a->SectionAlignment) | 1615 | 2.52k | { | 1616 | 2.52k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1617 | 2.52k | abfd); | 1618 | 2.52k | a->FileAlignment &= -a->FileAlignment; | 1619 | 2.52k | if (a->FileAlignment > a->SectionAlignment) | 1620 | 1.38k | a->FileAlignment = a->SectionAlignment; | 1621 | 2.52k | } | 1622 | | | 1623 | 3.42k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1624 | 2.42k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1625 | 3.42k | } | 1626 | | | 1627 | 7.31k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1628 | 7.31k | (opt_hdr_size != 0 | 1629 | 7.31k | ? &internal_a | 1630 | 7.31k | : (struct internal_aouthdr *) NULL)); | 1631 | | | 1632 | 7.31k | if (result) | 1633 | 5.27k | { | 1634 | | /* Now the whole header has been processed, see if there is a build-id */ | 1635 | 5.27k | pe_bfd_read_buildid(abfd); | 1636 | 5.27k | } | 1637 | | | 1638 | 7.31k | return result; | 1639 | 7.35k | } |
pei-loongarch64.c:pe_bfd_object_p Line | Count | Source | 1489 | 226k | { | 1490 | 226k | bfd_byte buffer[6]; | 1491 | 226k | struct external_DOS_hdr dos_hdr; | 1492 | 226k | struct external_PEI_IMAGE_hdr image_hdr; | 1493 | 226k | struct internal_filehdr internal_f; | 1494 | 226k | struct internal_aouthdr internal_a; | 1495 | 226k | bfd_size_type opt_hdr_size; | 1496 | 226k | file_ptr offset; | 1497 | 226k | bfd_cleanup result; | 1498 | | | 1499 | | /* Detect if this a Microsoft Import Library Format element. */ | 1500 | | /* First read the beginning of the header. */ | 1501 | 226k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1502 | 226k | || bfd_read (buffer, 6, abfd) != 6) | 1503 | 2.75k | { | 1504 | 2.75k | if (bfd_get_error () != bfd_error_system_call) | 1505 | 2.30k | bfd_set_error (bfd_error_wrong_format); | 1506 | 2.75k | return NULL; | 1507 | 2.75k | } | 1508 | | | 1509 | | /* Then check the magic and the version (only 0 is supported). */ | 1510 | 223k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1511 | 5.55k | && H_GET_16 (abfd, buffer + 4) == 0) | 1512 | 4.55k | return pe_ILF_object_p (abfd); | 1513 | | | 1514 | 219k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1515 | 219k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1516 | 54.9k | { | 1517 | 54.9k | if (bfd_get_error () != bfd_error_system_call) | 1518 | 54.9k | bfd_set_error (bfd_error_wrong_format); | 1519 | 54.9k | return NULL; | 1520 | 54.9k | } | 1521 | | | 1522 | | /* There are really two magic numbers involved; the magic number | 1523 | | that says this is a NT executable (PEI) and the magic number that | 1524 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1525 | | the e_magic field. The latter is stored in the f_magic field. | 1526 | | If the NT magic number isn't valid, the architecture magic number | 1527 | | could be mimicked by some other field (specifically, the number | 1528 | | of relocs in section 3). Since this routine can only be called | 1529 | | correctly for a PEI file, check the e_magic number here, and, if | 1530 | | it doesn't match, clobber the f_magic number so that we don't get | 1531 | | a false match. */ | 1532 | 164k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1533 | 108k | { | 1534 | 108k | bfd_set_error (bfd_error_wrong_format); | 1535 | 108k | return NULL; | 1536 | 108k | } | 1537 | | | 1538 | 55.4k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1539 | 55.4k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1540 | 55.4k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1541 | 921 | { | 1542 | 921 | if (bfd_get_error () != bfd_error_system_call) | 1543 | 921 | bfd_set_error (bfd_error_wrong_format); | 1544 | 921 | return NULL; | 1545 | 921 | } | 1546 | | | 1547 | 54.5k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1548 | 1.17k | { | 1549 | 1.17k | bfd_set_error (bfd_error_wrong_format); | 1550 | 1.17k | return NULL; | 1551 | 1.17k | } | 1552 | | | 1553 | | /* Swap file header, so that we get the location for calling | 1554 | | real_object_p. */ | 1555 | 53.3k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1556 | | | 1557 | 53.3k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1558 | 6.54k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1559 | 46.8k | { | 1560 | 46.8k | bfd_set_error (bfd_error_wrong_format); | 1561 | 46.8k | return NULL; | 1562 | 46.8k | } | 1563 | | | 1564 | 6.53k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1565 | 6.53k | sizeof (internal_f.pe.dos_message)); | 1566 | | | 1567 | | /* Read the optional header, which has variable size. */ | 1568 | 6.53k | opt_hdr_size = internal_f.f_opthdr; | 1569 | | | 1570 | 6.53k | if (opt_hdr_size != 0) | 1571 | 4.49k | { | 1572 | 4.49k | bfd_size_type amt = opt_hdr_size; | 1573 | 4.49k | bfd_byte *opthdr; | 1574 | | | 1575 | | /* PR 17521 file: 230-131433-0.004. */ | 1576 | 4.49k | if (amt < sizeof (PEAOUTHDR)) | 1577 | 4.24k | amt = sizeof (PEAOUTHDR); | 1578 | | | 1579 | 4.49k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1580 | 4.49k | if (opthdr == NULL) | 1581 | 40 | return NULL; | 1582 | 4.45k | if (amt > opt_hdr_size) | 1583 | 4.21k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1584 | | | 1585 | 4.45k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1586 | | | 1587 | 4.45k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1588 | | | 1589 | | #ifdef ARM | 1590 | | /* Use Subsystem to distinguish between pei-arm-little and | 1591 | | pei-arm-wince-little. */ | 1592 | | #ifdef WINCE | 1593 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1594 | | #else | 1595 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1596 | | #endif | 1597 | | { | 1598 | | bfd_set_error (bfd_error_wrong_format); | 1599 | | return NULL; | 1600 | | } | 1601 | | #endif | 1602 | | | 1603 | 4.45k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1604 | 2.53k | || a->SectionAlignment >= 0x80000000) | 1605 | 1.97k | { | 1606 | 1.97k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1607 | 1.97k | abfd); | 1608 | 1.97k | a->SectionAlignment &= -a->SectionAlignment; | 1609 | 1.97k | if (a->SectionAlignment >= 0x80000000) | 1610 | 62 | a->SectionAlignment = 0x40000000; | 1611 | 1.97k | } | 1612 | | | 1613 | 4.45k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1614 | 2.20k | || a->FileAlignment > a->SectionAlignment) | 1615 | 2.56k | { | 1616 | 2.56k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1617 | 2.56k | abfd); | 1618 | 2.56k | a->FileAlignment &= -a->FileAlignment; | 1619 | 2.56k | if (a->FileAlignment > a->SectionAlignment) | 1620 | 1.54k | a->FileAlignment = a->SectionAlignment; | 1621 | 2.56k | } | 1622 | | | 1623 | 4.45k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1624 | 2.19k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1625 | 4.45k | } | 1626 | | | 1627 | 6.49k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1628 | 6.49k | (opt_hdr_size != 0 | 1629 | 6.49k | ? &internal_a | 1630 | 6.49k | : (struct internal_aouthdr *) NULL)); | 1631 | | | 1632 | 6.49k | if (result) | 1633 | 4.48k | { | 1634 | | /* Now the whole header has been processed, see if there is a build-id */ | 1635 | 4.48k | pe_bfd_read_buildid(abfd); | 1636 | 4.48k | } | 1637 | | | 1638 | 6.49k | return result; | 1639 | 6.53k | } |
pei-riscv64.c:pe_bfd_object_p Line | Count | Source | 1489 | 226k | { | 1490 | 226k | bfd_byte buffer[6]; | 1491 | 226k | struct external_DOS_hdr dos_hdr; | 1492 | 226k | struct external_PEI_IMAGE_hdr image_hdr; | 1493 | 226k | struct internal_filehdr internal_f; | 1494 | 226k | struct internal_aouthdr internal_a; | 1495 | 226k | bfd_size_type opt_hdr_size; | 1496 | 226k | file_ptr offset; | 1497 | 226k | bfd_cleanup result; | 1498 | | | 1499 | | /* Detect if this a Microsoft Import Library Format element. */ | 1500 | | /* First read the beginning of the header. */ | 1501 | 226k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1502 | 226k | || bfd_read (buffer, 6, abfd) != 6) | 1503 | 2.75k | { | 1504 | 2.75k | if (bfd_get_error () != bfd_error_system_call) | 1505 | 2.30k | bfd_set_error (bfd_error_wrong_format); | 1506 | 2.75k | return NULL; | 1507 | 2.75k | } | 1508 | | | 1509 | | /* Then check the magic and the version (only 0 is supported). */ | 1510 | 223k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1511 | 5.59k | && H_GET_16 (abfd, buffer + 4) == 0) | 1512 | 4.59k | return pe_ILF_object_p (abfd); | 1513 | | | 1514 | 219k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1515 | 219k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1516 | 54.9k | { | 1517 | 54.9k | if (bfd_get_error () != bfd_error_system_call) | 1518 | 54.9k | bfd_set_error (bfd_error_wrong_format); | 1519 | 54.9k | return NULL; | 1520 | 54.9k | } | 1521 | | | 1522 | | /* There are really two magic numbers involved; the magic number | 1523 | | that says this is a NT executable (PEI) and the magic number that | 1524 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1525 | | the e_magic field. The latter is stored in the f_magic field. | 1526 | | If the NT magic number isn't valid, the architecture magic number | 1527 | | could be mimicked by some other field (specifically, the number | 1528 | | of relocs in section 3). Since this routine can only be called | 1529 | | correctly for a PEI file, check the e_magic number here, and, if | 1530 | | it doesn't match, clobber the f_magic number so that we don't get | 1531 | | a false match. */ | 1532 | 164k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1533 | 108k | { | 1534 | 108k | bfd_set_error (bfd_error_wrong_format); | 1535 | 108k | return NULL; | 1536 | 108k | } | 1537 | | | 1538 | 55.5k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1539 | 55.5k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1540 | 55.5k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1541 | 921 | { | 1542 | 921 | if (bfd_get_error () != bfd_error_system_call) | 1543 | 921 | bfd_set_error (bfd_error_wrong_format); | 1544 | 921 | return NULL; | 1545 | 921 | } | 1546 | | | 1547 | 54.6k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1548 | 1.17k | { | 1549 | 1.17k | bfd_set_error (bfd_error_wrong_format); | 1550 | 1.17k | return NULL; | 1551 | 1.17k | } | 1552 | | | 1553 | | /* Swap file header, so that we get the location for calling | 1554 | | real_object_p. */ | 1555 | 53.4k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1556 | | | 1557 | 53.4k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1558 | 7.01k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1559 | 46.4k | { | 1560 | 46.4k | bfd_set_error (bfd_error_wrong_format); | 1561 | 46.4k | return NULL; | 1562 | 46.4k | } | 1563 | | | 1564 | 7.00k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1565 | 7.00k | sizeof (internal_f.pe.dos_message)); | 1566 | | | 1567 | | /* Read the optional header, which has variable size. */ | 1568 | 7.00k | opt_hdr_size = internal_f.f_opthdr; | 1569 | | | 1570 | 7.00k | if (opt_hdr_size != 0) | 1571 | 4.81k | { | 1572 | 4.81k | bfd_size_type amt = opt_hdr_size; | 1573 | 4.81k | bfd_byte *opthdr; | 1574 | | | 1575 | | /* PR 17521 file: 230-131433-0.004. */ | 1576 | 4.81k | if (amt < sizeof (PEAOUTHDR)) | 1577 | 4.41k | amt = sizeof (PEAOUTHDR); | 1578 | | | 1579 | 4.81k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1580 | 4.81k | if (opthdr == NULL) | 1581 | 46 | return NULL; | 1582 | 4.77k | if (amt > opt_hdr_size) | 1583 | 4.37k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1584 | | | 1585 | 4.77k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1586 | | | 1587 | 4.77k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1588 | | | 1589 | | #ifdef ARM | 1590 | | /* Use Subsystem to distinguish between pei-arm-little and | 1591 | | pei-arm-wince-little. */ | 1592 | | #ifdef WINCE | 1593 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1594 | | #else | 1595 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1596 | | #endif | 1597 | | { | 1598 | | bfd_set_error (bfd_error_wrong_format); | 1599 | | return NULL; | 1600 | | } | 1601 | | #endif | 1602 | | | 1603 | 4.77k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1604 | 2.78k | || a->SectionAlignment >= 0x80000000) | 1605 | 2.02k | { | 1606 | 2.02k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1607 | 2.02k | abfd); | 1608 | 2.02k | a->SectionAlignment &= -a->SectionAlignment; | 1609 | 2.02k | if (a->SectionAlignment >= 0x80000000) | 1610 | 41 | a->SectionAlignment = 0x40000000; | 1611 | 2.02k | } | 1612 | | | 1613 | 4.77k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1614 | 2.23k | || a->FileAlignment > a->SectionAlignment) | 1615 | 3.00k | { | 1616 | 3.00k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1617 | 3.00k | abfd); | 1618 | 3.00k | a->FileAlignment &= -a->FileAlignment; | 1619 | 3.00k | if (a->FileAlignment > a->SectionAlignment) | 1620 | 2.19k | a->FileAlignment = a->SectionAlignment; | 1621 | 3.00k | } | 1622 | | | 1623 | 4.77k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1624 | 2.55k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1625 | 4.77k | } | 1626 | | | 1627 | 6.95k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1628 | 6.95k | (opt_hdr_size != 0 | 1629 | 6.95k | ? &internal_a | 1630 | 6.95k | : (struct internal_aouthdr *) NULL)); | 1631 | | | 1632 | 6.95k | if (result) | 1633 | 4.83k | { | 1634 | | /* Now the whole header has been processed, see if there is a build-id */ | 1635 | 4.83k | pe_bfd_read_buildid(abfd); | 1636 | 4.83k | } | 1637 | | | 1638 | 6.95k | return result; | 1639 | 7.00k | } |
pei-arm-wince.c:pe_bfd_object_p Line | Count | Source | 1489 | 391k | { | 1490 | 391k | bfd_byte buffer[6]; | 1491 | 391k | struct external_DOS_hdr dos_hdr; | 1492 | 391k | struct external_PEI_IMAGE_hdr image_hdr; | 1493 | 391k | struct internal_filehdr internal_f; | 1494 | 391k | struct internal_aouthdr internal_a; | 1495 | 391k | bfd_size_type opt_hdr_size; | 1496 | 391k | file_ptr offset; | 1497 | 391k | bfd_cleanup result; | 1498 | | | 1499 | | /* Detect if this a Microsoft Import Library Format element. */ | 1500 | | /* First read the beginning of the header. */ | 1501 | 391k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1502 | 391k | || bfd_read (buffer, 6, abfd) != 6) | 1503 | 4.88k | { | 1504 | 4.88k | if (bfd_get_error () != bfd_error_system_call) | 1505 | 3.99k | bfd_set_error (bfd_error_wrong_format); | 1506 | 4.88k | return NULL; | 1507 | 4.88k | } | 1508 | | | 1509 | | /* Then check the magic and the version (only 0 is supported). */ | 1510 | 386k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1511 | 5.14k | && H_GET_16 (abfd, buffer + 4) == 0) | 1512 | 4.24k | return pe_ILF_object_p (abfd); | 1513 | | | 1514 | 382k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1515 | 382k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1516 | 95.5k | { | 1517 | 95.5k | if (bfd_get_error () != bfd_error_system_call) | 1518 | 95.5k | bfd_set_error (bfd_error_wrong_format); | 1519 | 95.5k | return NULL; | 1520 | 95.5k | } | 1521 | | | 1522 | | /* There are really two magic numbers involved; the magic number | 1523 | | that says this is a NT executable (PEI) and the magic number that | 1524 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1525 | | the e_magic field. The latter is stored in the f_magic field. | 1526 | | If the NT magic number isn't valid, the architecture magic number | 1527 | | could be mimicked by some other field (specifically, the number | 1528 | | of relocs in section 3). Since this routine can only be called | 1529 | | correctly for a PEI file, check the e_magic number here, and, if | 1530 | | it doesn't match, clobber the f_magic number so that we don't get | 1531 | | a false match. */ | 1532 | 287k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1533 | 234k | { | 1534 | 234k | bfd_set_error (bfd_error_wrong_format); | 1535 | 234k | return NULL; | 1536 | 234k | } | 1537 | | | 1538 | 52.8k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1539 | 52.8k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1540 | 52.8k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1541 | 920 | { | 1542 | 920 | if (bfd_get_error () != bfd_error_system_call) | 1543 | 920 | bfd_set_error (bfd_error_wrong_format); | 1544 | 920 | return NULL; | 1545 | 920 | } | 1546 | | | 1547 | 51.9k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1548 | 1.16k | { | 1549 | 1.16k | bfd_set_error (bfd_error_wrong_format); | 1550 | 1.16k | return NULL; | 1551 | 1.16k | } | 1552 | | | 1553 | | /* Swap file header, so that we get the location for calling | 1554 | | real_object_p. */ | 1555 | 50.7k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1556 | | | 1557 | 50.7k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1558 | 8.31k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1559 | 42.4k | { | 1560 | 42.4k | bfd_set_error (bfd_error_wrong_format); | 1561 | 42.4k | return NULL; | 1562 | 42.4k | } | 1563 | | | 1564 | 8.26k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1565 | 8.26k | sizeof (internal_f.pe.dos_message)); | 1566 | | | 1567 | | /* Read the optional header, which has variable size. */ | 1568 | 8.26k | opt_hdr_size = internal_f.f_opthdr; | 1569 | | | 1570 | 8.26k | if (opt_hdr_size != 0) | 1571 | 4.83k | { | 1572 | 4.83k | bfd_size_type amt = opt_hdr_size; | 1573 | 4.83k | bfd_byte *opthdr; | 1574 | | | 1575 | | /* PR 17521 file: 230-131433-0.004. */ | 1576 | 4.83k | if (amt < sizeof (PEAOUTHDR)) | 1577 | 4.48k | amt = sizeof (PEAOUTHDR); | 1578 | | | 1579 | 4.83k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1580 | 4.83k | if (opthdr == NULL) | 1581 | 60 | return NULL; | 1582 | 4.77k | if (amt > opt_hdr_size) | 1583 | 4.43k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1584 | | | 1585 | 4.77k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1586 | | | 1587 | 4.77k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1588 | | | 1589 | 4.77k | #ifdef ARM | 1590 | | /* Use Subsystem to distinguish between pei-arm-little and | 1591 | | pei-arm-wince-little. */ | 1592 | 4.77k | #ifdef WINCE | 1593 | 4.77k | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1594 | | #else | 1595 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1596 | | #endif | 1597 | 2.84k | { | 1598 | 2.84k | bfd_set_error (bfd_error_wrong_format); | 1599 | 2.84k | return NULL; | 1600 | 2.84k | } | 1601 | 1.92k | #endif | 1602 | | | 1603 | 1.92k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1604 | 420 | || a->SectionAlignment >= 0x80000000) | 1605 | 1.52k | { | 1606 | 1.52k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1607 | 1.52k | abfd); | 1608 | 1.52k | a->SectionAlignment &= -a->SectionAlignment; | 1609 | 1.52k | if (a->SectionAlignment >= 0x80000000) | 1610 | 18 | a->SectionAlignment = 0x40000000; | 1611 | 1.52k | } | 1612 | | | 1613 | 1.92k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1614 | 505 | || a->FileAlignment > a->SectionAlignment) | 1615 | 1.70k | { | 1616 | 1.70k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1617 | 1.70k | abfd); | 1618 | 1.70k | a->FileAlignment &= -a->FileAlignment; | 1619 | 1.70k | if (a->FileAlignment > a->SectionAlignment) | 1620 | 1.36k | a->FileAlignment = a->SectionAlignment; | 1621 | 1.70k | } | 1622 | | | 1623 | 1.92k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1624 | 1.42k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1625 | 1.92k | } | 1626 | | | 1627 | 5.36k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1628 | 5.36k | (opt_hdr_size != 0 | 1629 | 5.36k | ? &internal_a | 1630 | 5.36k | : (struct internal_aouthdr *) NULL)); | 1631 | | | 1632 | 5.36k | if (result) | 1633 | 2.65k | { | 1634 | | /* Now the whole header has been processed, see if there is a build-id */ | 1635 | 2.65k | pe_bfd_read_buildid(abfd); | 1636 | 2.65k | } | 1637 | | | 1638 | 5.36k | return result; | 1639 | 8.26k | } |
pei-arm.c:pe_bfd_object_p Line | Count | Source | 1489 | 392k | { | 1490 | 392k | bfd_byte buffer[6]; | 1491 | 392k | struct external_DOS_hdr dos_hdr; | 1492 | 392k | struct external_PEI_IMAGE_hdr image_hdr; | 1493 | 392k | struct internal_filehdr internal_f; | 1494 | 392k | struct internal_aouthdr internal_a; | 1495 | 392k | bfd_size_type opt_hdr_size; | 1496 | 392k | file_ptr offset; | 1497 | 392k | bfd_cleanup result; | 1498 | | | 1499 | | /* Detect if this a Microsoft Import Library Format element. */ | 1500 | | /* First read the beginning of the header. */ | 1501 | 392k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1502 | 392k | || bfd_read (buffer, 6, abfd) != 6) | 1503 | 4.88k | { | 1504 | 4.88k | if (bfd_get_error () != bfd_error_system_call) | 1505 | 3.99k | bfd_set_error (bfd_error_wrong_format); | 1506 | 4.88k | return NULL; | 1507 | 4.88k | } | 1508 | | | 1509 | | /* Then check the magic and the version (only 0 is supported). */ | 1510 | 387k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1511 | 5.15k | && H_GET_16 (abfd, buffer + 4) == 0) | 1512 | 4.25k | return pe_ILF_object_p (abfd); | 1513 | | | 1514 | 383k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1515 | 383k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1516 | 95.5k | { | 1517 | 95.5k | if (bfd_get_error () != bfd_error_system_call) | 1518 | 95.5k | bfd_set_error (bfd_error_wrong_format); | 1519 | 95.5k | return NULL; | 1520 | 95.5k | } | 1521 | | | 1522 | | /* There are really two magic numbers involved; the magic number | 1523 | | that says this is a NT executable (PEI) and the magic number that | 1524 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1525 | | the e_magic field. The latter is stored in the f_magic field. | 1526 | | If the NT magic number isn't valid, the architecture magic number | 1527 | | could be mimicked by some other field (specifically, the number | 1528 | | of relocs in section 3). Since this routine can only be called | 1529 | | correctly for a PEI file, check the e_magic number here, and, if | 1530 | | it doesn't match, clobber the f_magic number so that we don't get | 1531 | | a false match. */ | 1532 | 287k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1533 | 234k | { | 1534 | 234k | bfd_set_error (bfd_error_wrong_format); | 1535 | 234k | return NULL; | 1536 | 234k | } | 1537 | | | 1538 | 53.1k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1539 | 53.1k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1540 | 53.1k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1541 | 920 | { | 1542 | 920 | if (bfd_get_error () != bfd_error_system_call) | 1543 | 920 | bfd_set_error (bfd_error_wrong_format); | 1544 | 920 | return NULL; | 1545 | 920 | } | 1546 | | | 1547 | 52.2k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1548 | 1.16k | { | 1549 | 1.16k | bfd_set_error (bfd_error_wrong_format); | 1550 | 1.16k | return NULL; | 1551 | 1.16k | } | 1552 | | | 1553 | | /* Swap file header, so that we get the location for calling | 1554 | | real_object_p. */ | 1555 | 51.1k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1556 | | | 1557 | 51.1k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1558 | 8.67k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1559 | 42.4k | { | 1560 | 42.4k | bfd_set_error (bfd_error_wrong_format); | 1561 | 42.4k | return NULL; | 1562 | 42.4k | } | 1563 | | | 1564 | 8.63k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1565 | 8.63k | sizeof (internal_f.pe.dos_message)); | 1566 | | | 1567 | | /* Read the optional header, which has variable size. */ | 1568 | 8.63k | opt_hdr_size = internal_f.f_opthdr; | 1569 | | | 1570 | 8.63k | if (opt_hdr_size != 0) | 1571 | 5.20k | { | 1572 | 5.20k | bfd_size_type amt = opt_hdr_size; | 1573 | 5.20k | bfd_byte *opthdr; | 1574 | | | 1575 | | /* PR 17521 file: 230-131433-0.004. */ | 1576 | 5.20k | if (amt < sizeof (PEAOUTHDR)) | 1577 | 4.85k | amt = sizeof (PEAOUTHDR); | 1578 | | | 1579 | 5.20k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1580 | 5.20k | if (opthdr == NULL) | 1581 | 60 | return NULL; | 1582 | 5.14k | if (amt > opt_hdr_size) | 1583 | 4.79k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1584 | | | 1585 | 5.14k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1586 | | | 1587 | 5.14k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1588 | | | 1589 | 5.14k | #ifdef ARM | 1590 | | /* Use Subsystem to distinguish between pei-arm-little and | 1591 | | pei-arm-wince-little. */ | 1592 | | #ifdef WINCE | 1593 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1594 | | #else | 1595 | 5.14k | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1596 | 1.50k | #endif | 1597 | 1.50k | { | 1598 | 1.50k | bfd_set_error (bfd_error_wrong_format); | 1599 | 1.50k | return NULL; | 1600 | 1.50k | } | 1601 | 3.63k | #endif | 1602 | | | 1603 | 3.63k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1604 | 1.53k | || a->SectionAlignment >= 0x80000000) | 1605 | 2.13k | { | 1606 | 2.13k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1607 | 2.13k | abfd); | 1608 | 2.13k | a->SectionAlignment &= -a->SectionAlignment; | 1609 | 2.13k | if (a->SectionAlignment >= 0x80000000) | 1610 | 33 | a->SectionAlignment = 0x40000000; | 1611 | 2.13k | } | 1612 | | | 1613 | 3.63k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1614 | 1.66k | || a->FileAlignment > a->SectionAlignment) | 1615 | 2.37k | { | 1616 | 2.37k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1617 | 2.37k | abfd); | 1618 | 2.37k | a->FileAlignment &= -a->FileAlignment; | 1619 | 2.37k | if (a->FileAlignment > a->SectionAlignment) | 1620 | 1.82k | a->FileAlignment = a->SectionAlignment; | 1621 | 2.37k | } | 1622 | | | 1623 | 3.63k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1624 | 1.95k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1625 | 3.63k | } | 1626 | | | 1627 | 7.06k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1628 | 7.06k | (opt_hdr_size != 0 | 1629 | 7.06k | ? &internal_a | 1630 | 7.06k | : (struct internal_aouthdr *) NULL)); | 1631 | | | 1632 | 7.06k | if (result) | 1633 | 4.00k | { | 1634 | | /* Now the whole header has been processed, see if there is a build-id */ | 1635 | 4.00k | pe_bfd_read_buildid(abfd); | 1636 | 4.00k | } | 1637 | | | 1638 | 7.06k | return result; | 1639 | 8.63k | } |
pei-mcore.c:pe_bfd_object_p Line | Count | Source | 1489 | 393k | { | 1490 | 393k | bfd_byte buffer[6]; | 1491 | 393k | struct external_DOS_hdr dos_hdr; | 1492 | 393k | struct external_PEI_IMAGE_hdr image_hdr; | 1493 | 393k | struct internal_filehdr internal_f; | 1494 | 393k | struct internal_aouthdr internal_a; | 1495 | 393k | bfd_size_type opt_hdr_size; | 1496 | 393k | file_ptr offset; | 1497 | 393k | bfd_cleanup result; | 1498 | | | 1499 | | /* Detect if this a Microsoft Import Library Format element. */ | 1500 | | /* First read the beginning of the header. */ | 1501 | 393k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1502 | 393k | || bfd_read (buffer, 6, abfd) != 6) | 1503 | 4.88k | { | 1504 | 4.88k | if (bfd_get_error () != bfd_error_system_call) | 1505 | 3.99k | bfd_set_error (bfd_error_wrong_format); | 1506 | 4.88k | return NULL; | 1507 | 4.88k | } | 1508 | | | 1509 | | /* Then check the magic and the version (only 0 is supported). */ | 1510 | 388k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1511 | 5.14k | && H_GET_16 (abfd, buffer + 4) == 0) | 1512 | 4.24k | return pe_ILF_object_p (abfd); | 1513 | | | 1514 | 383k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1515 | 383k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1516 | 95.5k | { | 1517 | 95.5k | if (bfd_get_error () != bfd_error_system_call) | 1518 | 95.5k | bfd_set_error (bfd_error_wrong_format); | 1519 | 95.5k | return NULL; | 1520 | 95.5k | } | 1521 | | | 1522 | | /* There are really two magic numbers involved; the magic number | 1523 | | that says this is a NT executable (PEI) and the magic number that | 1524 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1525 | | the e_magic field. The latter is stored in the f_magic field. | 1526 | | If the NT magic number isn't valid, the architecture magic number | 1527 | | could be mimicked by some other field (specifically, the number | 1528 | | of relocs in section 3). Since this routine can only be called | 1529 | | correctly for a PEI file, check the e_magic number here, and, if | 1530 | | it doesn't match, clobber the f_magic number so that we don't get | 1531 | | a false match. */ | 1532 | 288k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1533 | 234k | { | 1534 | 234k | bfd_set_error (bfd_error_wrong_format); | 1535 | 234k | return NULL; | 1536 | 234k | } | 1537 | | | 1538 | 53.9k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1539 | 53.9k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1540 | 53.9k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1541 | 920 | { | 1542 | 920 | if (bfd_get_error () != bfd_error_system_call) | 1543 | 920 | bfd_set_error (bfd_error_wrong_format); | 1544 | 920 | return NULL; | 1545 | 920 | } | 1546 | | | 1547 | 53.0k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1548 | 1.16k | { | 1549 | 1.16k | bfd_set_error (bfd_error_wrong_format); | 1550 | 1.16k | return NULL; | 1551 | 1.16k | } | 1552 | | | 1553 | | /* Swap file header, so that we get the location for calling | 1554 | | real_object_p. */ | 1555 | 51.9k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1556 | | | 1557 | 51.9k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1558 | 5.67k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1559 | 46.2k | { | 1560 | 46.2k | bfd_set_error (bfd_error_wrong_format); | 1561 | 46.2k | return NULL; | 1562 | 46.2k | } | 1563 | | | 1564 | 5.65k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1565 | 5.65k | sizeof (internal_f.pe.dos_message)); | 1566 | | | 1567 | | /* Read the optional header, which has variable size. */ | 1568 | 5.65k | opt_hdr_size = internal_f.f_opthdr; | 1569 | | | 1570 | 5.65k | if (opt_hdr_size != 0) | 1571 | 3.42k | { | 1572 | 3.42k | bfd_size_type amt = opt_hdr_size; | 1573 | 3.42k | bfd_byte *opthdr; | 1574 | | | 1575 | | /* PR 17521 file: 230-131433-0.004. */ | 1576 | 3.42k | if (amt < sizeof (PEAOUTHDR)) | 1577 | 3.24k | amt = sizeof (PEAOUTHDR); | 1578 | | | 1579 | 3.42k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1580 | 3.42k | if (opthdr == NULL) | 1581 | 30 | return NULL; | 1582 | 3.39k | if (amt > opt_hdr_size) | 1583 | 3.21k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1584 | | | 1585 | 3.39k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1586 | | | 1587 | 3.39k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1588 | | | 1589 | | #ifdef ARM | 1590 | | /* Use Subsystem to distinguish between pei-arm-little and | 1591 | | pei-arm-wince-little. */ | 1592 | | #ifdef WINCE | 1593 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1594 | | #else | 1595 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1596 | | #endif | 1597 | | { | 1598 | | bfd_set_error (bfd_error_wrong_format); | 1599 | | return NULL; | 1600 | | } | 1601 | | #endif | 1602 | | | 1603 | 3.39k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1604 | 1.71k | || a->SectionAlignment >= 0x80000000) | 1605 | 1.72k | { | 1606 | 1.72k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1607 | 1.72k | abfd); | 1608 | 1.72k | a->SectionAlignment &= -a->SectionAlignment; | 1609 | 1.72k | if (a->SectionAlignment >= 0x80000000) | 1610 | 44 | a->SectionAlignment = 0x40000000; | 1611 | 1.72k | } | 1612 | | | 1613 | 3.39k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1614 | 1.63k | || a->FileAlignment > a->SectionAlignment) | 1615 | 2.03k | { | 1616 | 2.03k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1617 | 2.03k | abfd); | 1618 | 2.03k | a->FileAlignment &= -a->FileAlignment; | 1619 | 2.03k | if (a->FileAlignment > a->SectionAlignment) | 1620 | 1.69k | a->FileAlignment = a->SectionAlignment; | 1621 | 2.03k | } | 1622 | | | 1623 | 3.39k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1624 | 1.77k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1625 | 3.39k | } | 1626 | | | 1627 | 5.62k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1628 | 5.62k | (opt_hdr_size != 0 | 1629 | 5.62k | ? &internal_a | 1630 | 5.62k | : (struct internal_aouthdr *) NULL)); | 1631 | | | 1632 | 5.62k | if (result) | 1633 | 4.19k | { | 1634 | | /* Now the whole header has been processed, see if there is a build-id */ | 1635 | 4.19k | pe_bfd_read_buildid(abfd); | 1636 | 4.19k | } | 1637 | | | 1638 | 5.62k | return result; | 1639 | 5.65k | } |
Line | Count | Source | 1489 | 198k | { | 1490 | 198k | bfd_byte buffer[6]; | 1491 | 198k | struct external_DOS_hdr dos_hdr; | 1492 | 198k | struct external_PEI_IMAGE_hdr image_hdr; | 1493 | 198k | struct internal_filehdr internal_f; | 1494 | 198k | struct internal_aouthdr internal_a; | 1495 | 198k | bfd_size_type opt_hdr_size; | 1496 | 198k | file_ptr offset; | 1497 | 198k | bfd_cleanup result; | 1498 | | | 1499 | | /* Detect if this a Microsoft Import Library Format element. */ | 1500 | | /* First read the beginning of the header. */ | 1501 | 198k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1502 | 198k | || bfd_read (buffer, 6, abfd) != 6) | 1503 | 2.43k | { | 1504 | 2.43k | if (bfd_get_error () != bfd_error_system_call) | 1505 | 1.99k | bfd_set_error (bfd_error_wrong_format); | 1506 | 2.43k | return NULL; | 1507 | 2.43k | } | 1508 | | | 1509 | | /* Then check the magic and the version (only 0 is supported). */ | 1510 | 196k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1511 | 5.10k | && H_GET_16 (abfd, buffer + 4) == 0) | 1512 | 4.21k | return pe_ILF_object_p (abfd); | 1513 | | | 1514 | 192k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1515 | 192k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1516 | 46.2k | { | 1517 | 46.2k | if (bfd_get_error () != bfd_error_system_call) | 1518 | 46.2k | bfd_set_error (bfd_error_wrong_format); | 1519 | 46.2k | return NULL; | 1520 | 46.2k | } | 1521 | | | 1522 | | /* There are really two magic numbers involved; the magic number | 1523 | | that says this is a NT executable (PEI) and the magic number that | 1524 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1525 | | the e_magic field. The latter is stored in the f_magic field. | 1526 | | If the NT magic number isn't valid, the architecture magic number | 1527 | | could be mimicked by some other field (specifically, the number | 1528 | | of relocs in section 3). Since this routine can only be called | 1529 | | correctly for a PEI file, check the e_magic number here, and, if | 1530 | | it doesn't match, clobber the f_magic number so that we don't get | 1531 | | a false match. */ | 1532 | 145k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1533 | 91.7k | { | 1534 | 91.7k | bfd_set_error (bfd_error_wrong_format); | 1535 | 91.7k | return NULL; | 1536 | 91.7k | } | 1537 | | | 1538 | 54.0k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1539 | 54.0k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1540 | 54.0k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1541 | 920 | { | 1542 | 920 | if (bfd_get_error () != bfd_error_system_call) | 1543 | 920 | bfd_set_error (bfd_error_wrong_format); | 1544 | 920 | return NULL; | 1545 | 920 | } | 1546 | | | 1547 | 53.1k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1548 | 1.16k | { | 1549 | 1.16k | bfd_set_error (bfd_error_wrong_format); | 1550 | 1.16k | return NULL; | 1551 | 1.16k | } | 1552 | | | 1553 | | /* Swap file header, so that we get the location for calling | 1554 | | real_object_p. */ | 1555 | 51.9k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1556 | | | 1557 | 51.9k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1558 | 6.10k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1559 | 45.8k | { | 1560 | 45.8k | bfd_set_error (bfd_error_wrong_format); | 1561 | 45.8k | return NULL; | 1562 | 45.8k | } | 1563 | | | 1564 | 6.08k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1565 | 6.08k | sizeof (internal_f.pe.dos_message)); | 1566 | | | 1567 | | /* Read the optional header, which has variable size. */ | 1568 | 6.08k | opt_hdr_size = internal_f.f_opthdr; | 1569 | | | 1570 | 6.08k | if (opt_hdr_size != 0) | 1571 | 3.54k | { | 1572 | 3.54k | bfd_size_type amt = opt_hdr_size; | 1573 | 3.54k | bfd_byte *opthdr; | 1574 | | | 1575 | | /* PR 17521 file: 230-131433-0.004. */ | 1576 | 3.54k | if (amt < sizeof (PEAOUTHDR)) | 1577 | 3.29k | amt = sizeof (PEAOUTHDR); | 1578 | | | 1579 | 3.54k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1580 | 3.54k | if (opthdr == NULL) | 1581 | 48 | return NULL; | 1582 | 3.49k | if (amt > opt_hdr_size) | 1583 | 3.25k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1584 | | | 1585 | 3.49k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1586 | | | 1587 | 3.49k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1588 | | | 1589 | | #ifdef ARM | 1590 | | /* Use Subsystem to distinguish between pei-arm-little and | 1591 | | pei-arm-wince-little. */ | 1592 | | #ifdef WINCE | 1593 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1594 | | #else | 1595 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1596 | | #endif | 1597 | | { | 1598 | | bfd_set_error (bfd_error_wrong_format); | 1599 | | return NULL; | 1600 | | } | 1601 | | #endif | 1602 | | | 1603 | 3.49k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1604 | 1.64k | || a->SectionAlignment >= 0x80000000) | 1605 | 1.87k | { | 1606 | 1.87k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1607 | 1.87k | abfd); | 1608 | 1.87k | a->SectionAlignment &= -a->SectionAlignment; | 1609 | 1.87k | if (a->SectionAlignment >= 0x80000000) | 1610 | 23 | a->SectionAlignment = 0x40000000; | 1611 | 1.87k | } | 1612 | | | 1613 | 3.49k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1614 | 1.85k | || a->FileAlignment > a->SectionAlignment) | 1615 | 2.11k | { | 1616 | 2.11k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1617 | 2.11k | abfd); | 1618 | 2.11k | a->FileAlignment &= -a->FileAlignment; | 1619 | 2.11k | if (a->FileAlignment > a->SectionAlignment) | 1620 | 1.57k | a->FileAlignment = a->SectionAlignment; | 1621 | 2.11k | } | 1622 | | | 1623 | 3.49k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1624 | 1.87k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1625 | 3.49k | } | 1626 | | | 1627 | 6.03k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1628 | 6.03k | (opt_hdr_size != 0 | 1629 | 6.03k | ? &internal_a | 1630 | 6.03k | : (struct internal_aouthdr *) NULL)); | 1631 | | | 1632 | 6.03k | if (result) | 1633 | 4.49k | { | 1634 | | /* Now the whole header has been processed, see if there is a build-id */ | 1635 | 4.49k | pe_bfd_read_buildid(abfd); | 1636 | 4.49k | } | 1637 | | | 1638 | 6.03k | return result; | 1639 | 6.08k | } |
|
1640 | | |
1641 | 16.9k | #define coff_object_p pe_bfd_object_p |
1642 | | #endif /* COFF_IMAGE_WITH_PE */ |