/src/binutils-gdb/bfd/peicode.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* Support for the generic parts of PE/PEI, for BFD. |
2 | | Copyright (C) 1995-2024 Free Software Foundation, Inc. |
3 | | Written by Cygnus Solutions. |
4 | | |
5 | | This file is part of BFD, the Binary File Descriptor library. |
6 | | |
7 | | This program is free software; you can redistribute it and/or modify |
8 | | it under the terms of the GNU General Public License as published by |
9 | | the Free Software Foundation; either version 3 of the License, or |
10 | | (at your option) any later version. |
11 | | |
12 | | This program is distributed in the hope that it will be useful, |
13 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | | GNU General Public License for more details. |
16 | | |
17 | | You should have received a copy of the GNU General Public License |
18 | | along with this program; if not, write to the Free Software |
19 | | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
20 | | MA 02110-1301, USA. */ |
21 | | |
22 | | |
23 | | /* Most of this hacked by Steve Chamberlain, |
24 | | sac@cygnus.com |
25 | | |
26 | | PE/PEI rearrangement (and code added): Donn Terry |
27 | | Softway Systems, Inc. */ |
28 | | |
29 | | /* Hey look, some documentation [and in a place you expect to find it]! |
30 | | |
31 | | The main reference for the pei format is "Microsoft Portable Executable |
32 | | and Common Object File Format Specification 4.1". Get it if you need to |
33 | | do some serious hacking on this code. |
34 | | |
35 | | Another reference: |
36 | | "Peering Inside the PE: A Tour of the Win32 Portable Executable |
37 | | File Format", MSJ 1994, Volume 9. |
38 | | |
39 | | The *sole* difference between the pe format and the pei format is that the |
40 | | latter has an MSDOS 2.0 .exe header on the front that prints the message |
41 | | "This app must be run under Windows." (or some such). |
42 | | (FIXME: Whether that statement is *really* true or not is unknown. |
43 | | Are there more subtle differences between pe and pei formats? |
44 | | For now assume there aren't. If you find one, then for God sakes |
45 | | document it here!) |
46 | | |
47 | | The Microsoft docs use the word "image" instead of "executable" because |
48 | | the former can also refer to a DLL (shared library). Confusion can arise |
49 | | because the `i' in `pei' also refers to "image". The `pe' format can |
50 | | also create images (i.e. executables), it's just that to run on a win32 |
51 | | system you need to use the pei format. |
52 | | |
53 | | FIXME: Please add more docs here so the next poor fool that has to hack |
54 | | on this code has a chance of getting something accomplished without |
55 | | wasting too much time. */ |
56 | | |
57 | | #include "libpei.h" |
58 | | |
59 | | static bool (*pe_saved_coff_bfd_print_private_bfd_data) (bfd *, void *) = |
60 | | #ifndef coff_bfd_print_private_bfd_data |
61 | | NULL; |
62 | | #else |
63 | | coff_bfd_print_private_bfd_data; |
64 | | #undef coff_bfd_print_private_bfd_data |
65 | | #endif |
66 | | |
67 | | static bool pe_print_private_bfd_data (bfd *, void *); |
68 | | #define coff_bfd_print_private_bfd_data pe_print_private_bfd_data |
69 | | |
70 | | static bool (*pe_saved_coff_bfd_copy_private_bfd_data) (bfd *, bfd *) = |
71 | | #ifndef coff_bfd_copy_private_bfd_data |
72 | | NULL; |
73 | | #else |
74 | | coff_bfd_copy_private_bfd_data; |
75 | | #undef coff_bfd_copy_private_bfd_data |
76 | | #endif |
77 | | |
78 | | static bool pe_bfd_copy_private_bfd_data (bfd *, bfd *); |
79 | | #define coff_bfd_copy_private_bfd_data pe_bfd_copy_private_bfd_data |
80 | | |
81 | | #define coff_mkobject pe_mkobject |
82 | | #define coff_mkobject_hook pe_mkobject_hook |
83 | | |
84 | | #ifdef COFF_IMAGE_WITH_PE |
85 | | /* This structure contains static variables used by the ILF code. */ |
86 | | typedef asection * asection_ptr; |
87 | | |
88 | | typedef struct |
89 | | { |
90 | | bfd * abfd; |
91 | | bfd_byte * data; |
92 | | struct bfd_in_memory * bim; |
93 | | unsigned short magic; |
94 | | |
95 | | arelent * reltab; |
96 | | unsigned int relcount; |
97 | | |
98 | | coff_symbol_type * sym_cache; |
99 | | coff_symbol_type * sym_ptr; |
100 | | unsigned int sym_index; |
101 | | |
102 | | unsigned int * sym_table; |
103 | | unsigned int * table_ptr; |
104 | | |
105 | | combined_entry_type * native_syms; |
106 | | combined_entry_type * native_ptr; |
107 | | |
108 | | coff_symbol_type ** sym_ptr_table; |
109 | | coff_symbol_type ** sym_ptr_ptr; |
110 | | |
111 | | unsigned int sec_index; |
112 | | |
113 | | char * string_table; |
114 | | char * string_ptr; |
115 | | char * end_string_ptr; |
116 | | |
117 | | SYMENT * esym_table; |
118 | | SYMENT * esym_ptr; |
119 | | |
120 | | struct internal_reloc * int_reltab; |
121 | | } |
122 | | pe_ILF_vars; |
123 | | #endif /* COFF_IMAGE_WITH_PE */ |
124 | | |
125 | | bfd_cleanup coff_real_object_p |
126 | | (bfd *, unsigned, struct internal_filehdr *, struct internal_aouthdr *); |
127 | | |
128 | | #ifndef NO_COFF_RELOCS |
129 | | static void |
130 | | coff_swap_reloc_in (bfd * abfd, void * src, void * dst) |
131 | 222k | { |
132 | 222k | RELOC *reloc_src = (RELOC *) src; |
133 | 222k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; |
134 | | |
135 | 222k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); |
136 | 222k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); |
137 | 222k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); |
138 | | #ifdef SWAP_IN_RELOC_OFFSET |
139 | 91.1k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); |
140 | | #endif |
141 | 222k | } pei-i386.c:coff_swap_reloc_in Line | Count | Source | 131 | 11.6k | { | 132 | 11.6k | RELOC *reloc_src = (RELOC *) src; | 133 | 11.6k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 11.6k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 11.6k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 11.6k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | | #ifdef SWAP_IN_RELOC_OFFSET | 139 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | | #endif | 141 | 11.6k | } |
pe-x86_64.c:coff_swap_reloc_in Line | Count | Source | 131 | 11.8k | { | 132 | 11.8k | RELOC *reloc_src = (RELOC *) src; | 133 | 11.8k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 11.8k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 11.8k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 11.8k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | | #ifdef SWAP_IN_RELOC_OFFSET | 139 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | | #endif | 141 | 11.8k | } |
pei-x86_64.c:coff_swap_reloc_in Line | Count | Source | 131 | 10.3k | { | 132 | 10.3k | RELOC *reloc_src = (RELOC *) src; | 133 | 10.3k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 10.3k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 10.3k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 10.3k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | | #ifdef SWAP_IN_RELOC_OFFSET | 139 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | | #endif | 141 | 10.3k | } |
pe-aarch64.c:coff_swap_reloc_in Line | Count | Source | 131 | 9.70k | { | 132 | 9.70k | RELOC *reloc_src = (RELOC *) src; | 133 | 9.70k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 9.70k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 9.70k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 9.70k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | | #ifdef SWAP_IN_RELOC_OFFSET | 139 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | | #endif | 141 | 9.70k | } |
pei-aarch64.c:coff_swap_reloc_in Line | Count | Source | 131 | 9.65k | { | 132 | 9.65k | RELOC *reloc_src = (RELOC *) src; | 133 | 9.65k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 9.65k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 9.65k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 9.65k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | | #ifdef SWAP_IN_RELOC_OFFSET | 139 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | | #endif | 141 | 9.65k | } |
pei-ia64.c:coff_swap_reloc_in Line | Count | Source | 131 | 17.1k | { | 132 | 17.1k | RELOC *reloc_src = (RELOC *) src; | 133 | 17.1k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 17.1k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 17.1k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 17.1k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | | #ifdef SWAP_IN_RELOC_OFFSET | 139 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | | #endif | 141 | 17.1k | } |
pei-loongarch64.c:coff_swap_reloc_in Line | Count | Source | 131 | 7.28k | { | 132 | 7.28k | RELOC *reloc_src = (RELOC *) src; | 133 | 7.28k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 7.28k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 7.28k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 7.28k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 7.28k | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 7.28k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 7.28k | #endif | 141 | 7.28k | } |
pei-riscv64.c:coff_swap_reloc_in Line | Count | Source | 131 | 4.85k | { | 132 | 4.85k | RELOC *reloc_src = (RELOC *) src; | 133 | 4.85k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 4.85k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 4.85k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 4.85k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 4.85k | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 4.85k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 4.85k | #endif | 141 | 4.85k | } |
pe-arm-wince.c:coff_swap_reloc_in Line | Count | Source | 131 | 2.03k | { | 132 | 2.03k | RELOC *reloc_src = (RELOC *) src; | 133 | 2.03k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 2.03k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 2.03k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 2.03k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 2.03k | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 2.03k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 2.03k | #endif | 141 | 2.03k | } |
pe-arm.c:coff_swap_reloc_in Line | Count | Source | 131 | 2.03k | { | 132 | 2.03k | RELOC *reloc_src = (RELOC *) src; | 133 | 2.03k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 2.03k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 2.03k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 2.03k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 2.03k | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 2.03k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 2.03k | #endif | 141 | 2.03k | } |
pe-i386.c:coff_swap_reloc_in Line | Count | Source | 131 | 31.4k | { | 132 | 31.4k | RELOC *reloc_src = (RELOC *) src; | 133 | 31.4k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 31.4k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 31.4k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 31.4k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | | #ifdef SWAP_IN_RELOC_OFFSET | 139 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | | #endif | 141 | 31.4k | } |
pe-mcore.c:coff_swap_reloc_in Line | Count | Source | 131 | 8.52k | { | 132 | 8.52k | RELOC *reloc_src = (RELOC *) src; | 133 | 8.52k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 8.52k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 8.52k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 8.52k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 8.52k | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 8.52k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 8.52k | #endif | 141 | 8.52k | } |
pe-sh.c:coff_swap_reloc_in Line | Count | Source | 131 | 12.5k | { | 132 | 12.5k | RELOC *reloc_src = (RELOC *) src; | 133 | 12.5k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 12.5k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 12.5k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 12.5k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | | #ifdef SWAP_IN_RELOC_OFFSET | 139 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | | #endif | 141 | 12.5k | } |
pei-arm-wince.c:coff_swap_reloc_in Line | Count | Source | 131 | 27.8k | { | 132 | 27.8k | RELOC *reloc_src = (RELOC *) src; | 133 | 27.8k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 27.8k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 27.8k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 27.8k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 27.8k | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 27.8k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 27.8k | #endif | 141 | 27.8k | } |
pei-arm.c:coff_swap_reloc_in Line | Count | Source | 131 | 20.9k | { | 132 | 20.9k | RELOC *reloc_src = (RELOC *) src; | 133 | 20.9k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 20.9k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 20.9k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 20.9k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 20.9k | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 20.9k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 20.9k | #endif | 141 | 20.9k | } |
pei-mcore.c:coff_swap_reloc_in Line | Count | Source | 131 | 17.6k | { | 132 | 17.6k | RELOC *reloc_src = (RELOC *) src; | 133 | 17.6k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 17.6k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 17.6k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 17.6k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | 17.6k | #ifdef SWAP_IN_RELOC_OFFSET | 139 | 17.6k | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | 17.6k | #endif | 141 | 17.6k | } |
pei-sh.c:coff_swap_reloc_in Line | Count | Source | 131 | 16.4k | { | 132 | 16.4k | RELOC *reloc_src = (RELOC *) src; | 133 | 16.4k | struct internal_reloc *reloc_dst = (struct internal_reloc *) dst; | 134 | | | 135 | 16.4k | reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr); | 136 | 16.4k | reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx); | 137 | 16.4k | reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type); | 138 | | #ifdef SWAP_IN_RELOC_OFFSET | 139 | | reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset); | 140 | | #endif | 141 | 16.4k | } |
|
142 | | |
143 | | static unsigned int |
144 | | coff_swap_reloc_out (bfd * abfd, void * src, void * dst) |
145 | 0 | { |
146 | 0 | struct internal_reloc *reloc_src = (struct internal_reloc *) src; |
147 | 0 | struct external_reloc *reloc_dst = (struct external_reloc *) dst; |
148 | |
|
149 | 0 | H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr); |
150 | 0 | H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx); |
151 | 0 | H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type); |
152 | |
|
153 | | #ifdef SWAP_OUT_RELOC_OFFSET |
154 | 0 | SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset); |
155 | | #endif |
156 | | #ifdef SWAP_OUT_RELOC_EXTRA |
157 | | SWAP_OUT_RELOC_EXTRA (abfd, reloc_src, reloc_dst); |
158 | | #endif |
159 | 0 | return RELSZ; |
160 | 0 | } Unexecuted instantiation: pei-i386.c:coff_swap_reloc_out Unexecuted instantiation: pe-x86_64.c:coff_swap_reloc_out Unexecuted instantiation: pei-x86_64.c:coff_swap_reloc_out Unexecuted instantiation: pe-aarch64.c:coff_swap_reloc_out Unexecuted instantiation: pei-aarch64.c:coff_swap_reloc_out Unexecuted instantiation: pei-ia64.c:coff_swap_reloc_out Unexecuted instantiation: pei-loongarch64.c:coff_swap_reloc_out Unexecuted instantiation: pei-riscv64.c:coff_swap_reloc_out Unexecuted instantiation: pe-arm-wince.c:coff_swap_reloc_out Unexecuted instantiation: pe-arm.c:coff_swap_reloc_out Unexecuted instantiation: pe-i386.c:coff_swap_reloc_out Unexecuted instantiation: pe-mcore.c:coff_swap_reloc_out Unexecuted instantiation: pe-sh.c:coff_swap_reloc_out Unexecuted instantiation: pei-arm-wince.c:coff_swap_reloc_out Unexecuted instantiation: pei-arm.c:coff_swap_reloc_out Unexecuted instantiation: pei-mcore.c:coff_swap_reloc_out Unexecuted instantiation: pei-sh.c:coff_swap_reloc_out |
161 | | #endif /* not NO_COFF_RELOCS */ |
162 | | |
163 | | #ifdef COFF_IMAGE_WITH_PE |
164 | | #undef FILHDR |
165 | 5.89M | #define FILHDR struct external_PEI_IMAGE_hdr |
166 | | #endif |
167 | | |
168 | | static void |
169 | | coff_swap_filehdr_in (bfd * abfd, void * src, void * dst) |
170 | 22.6M | { |
171 | 22.6M | FILHDR *filehdr_src = (FILHDR *) src; |
172 | 22.6M | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; |
173 | | |
174 | 22.6M | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); |
175 | 22.6M | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); |
176 | 22.6M | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); |
177 | 22.6M | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); |
178 | 22.6M | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); |
179 | 22.6M | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); |
180 | | |
181 | | /* Other people's tools sometimes generate headers with an nsyms but |
182 | | a zero symptr. */ |
183 | 22.6M | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) |
184 | 2.72M | { |
185 | 2.72M | filehdr_dst->f_nsyms = 0; |
186 | 2.72M | filehdr_dst->f_flags |= F_LSYMS; |
187 | 2.72M | } |
188 | | |
189 | 22.6M | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); |
190 | 22.6M | } pei-i386.c:coff_swap_filehdr_in Line | Count | Source | 170 | 599k | { | 171 | 599k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 599k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 599k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 599k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 599k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 599k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 599k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 599k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 599k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 69.9k | { | 185 | 69.9k | filehdr_dst->f_nsyms = 0; | 186 | 69.9k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 69.9k | } | 188 | | | 189 | 599k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 599k | } |
pe-x86_64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 1.69M | { | 171 | 1.69M | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 1.69M | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 1.69M | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 1.69M | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 1.69M | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 1.69M | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 1.69M | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 1.69M | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 1.69M | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 205k | { | 185 | 205k | filehdr_dst->f_nsyms = 0; | 186 | 205k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 205k | } | 188 | | | 189 | 1.69M | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 1.69M | } |
pei-x86_64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 607k | { | 171 | 607k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 607k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 607k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 607k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 607k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 607k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 607k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 607k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 607k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 68.5k | { | 185 | 68.5k | filehdr_dst->f_nsyms = 0; | 186 | 68.5k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 68.5k | } | 188 | | | 189 | 607k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 607k | } |
pe-aarch64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 1.68M | { | 171 | 1.68M | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 1.68M | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 1.68M | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 1.68M | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 1.68M | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 1.68M | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 1.68M | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 1.68M | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 1.68M | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 205k | { | 185 | 205k | filehdr_dst->f_nsyms = 0; | 186 | 205k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 205k | } | 188 | | | 189 | 1.68M | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 1.68M | } |
pei-aarch64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 588k | { | 171 | 588k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 588k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 588k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 588k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 588k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 588k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 588k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 588k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 588k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 68.1k | { | 185 | 68.1k | filehdr_dst->f_nsyms = 0; | 186 | 68.1k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 68.1k | } | 188 | | | 189 | 588k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 588k | } |
pei-ia64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 571k | { | 171 | 571k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 571k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 571k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 571k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 571k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 571k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 571k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 571k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 571k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 65.9k | { | 185 | 65.9k | filehdr_dst->f_nsyms = 0; | 186 | 65.9k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 65.9k | } | 188 | | | 189 | 571k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 571k | } |
pei-loongarch64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 587k | { | 171 | 587k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 587k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 587k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 587k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 587k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 587k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 587k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 587k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 587k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 68.0k | { | 185 | 68.0k | filehdr_dst->f_nsyms = 0; | 186 | 68.0k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 68.0k | } | 188 | | | 189 | 587k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 587k | } |
pei-riscv64.c:coff_swap_filehdr_in Line | Count | Source | 170 | 587k | { | 171 | 587k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 587k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 587k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 587k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 587k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 587k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 587k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 587k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 587k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 68.0k | { | 185 | 68.0k | filehdr_dst->f_nsyms = 0; | 186 | 68.0k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 68.0k | } | 188 | | | 189 | 587k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 587k | } |
pe-arm-wince.c:coff_swap_filehdr_in Line | Count | Source | 170 | 3.35M | { | 171 | 3.35M | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 3.35M | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 3.35M | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 3.35M | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 3.35M | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 3.35M | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 3.35M | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 3.35M | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 3.35M | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 407k | { | 185 | 407k | filehdr_dst->f_nsyms = 0; | 186 | 407k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 407k | } | 188 | | | 189 | 3.35M | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 3.35M | } |
pe-arm.c:coff_swap_filehdr_in Line | Count | Source | 170 | 3.35M | { | 171 | 3.35M | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 3.35M | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 3.35M | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 3.35M | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 3.35M | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 3.35M | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 3.35M | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 3.35M | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 3.35M | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 407k | { | 185 | 407k | filehdr_dst->f_nsyms = 0; | 186 | 407k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 407k | } | 188 | | | 189 | 3.35M | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 3.35M | } |
pe-i386.c:coff_swap_filehdr_in Line | Count | Source | 170 | 1.68M | { | 171 | 1.68M | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 1.68M | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 1.68M | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 1.68M | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 1.68M | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 1.68M | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 1.68M | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 1.68M | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 1.68M | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 205k | { | 185 | 205k | filehdr_dst->f_nsyms = 0; | 186 | 205k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 205k | } | 188 | | | 189 | 1.68M | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 1.68M | } |
pe-mcore.c:coff_swap_filehdr_in Line | Count | Source | 170 | 3.35M | { | 171 | 3.35M | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 3.35M | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 3.35M | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 3.35M | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 3.35M | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 3.35M | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 3.35M | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 3.35M | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 3.35M | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 407k | { | 185 | 407k | filehdr_dst->f_nsyms = 0; | 186 | 407k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 407k | } | 188 | | | 189 | 3.35M | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 3.35M | } |
pe-sh.c:coff_swap_filehdr_in Line | Count | Source | 170 | 1.67M | { | 171 | 1.67M | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 1.67M | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 1.67M | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 1.67M | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 1.67M | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 1.67M | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 1.67M | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 1.67M | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 1.67M | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 203k | { | 185 | 203k | filehdr_dst->f_nsyms = 0; | 186 | 203k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 203k | } | 188 | | | 189 | 1.67M | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 1.67M | } |
pei-arm-wince.c:coff_swap_filehdr_in Line | Count | Source | 170 | 587k | { | 171 | 587k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 587k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 587k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 587k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 587k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 587k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 587k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 587k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 587k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 68.1k | { | 185 | 68.1k | filehdr_dst->f_nsyms = 0; | 186 | 68.1k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 68.1k | } | 188 | | | 189 | 587k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 587k | } |
pei-arm.c:coff_swap_filehdr_in Line | Count | Source | 170 | 587k | { | 171 | 587k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 587k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 587k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 587k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 587k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 587k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 587k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 587k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 587k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 68.1k | { | 185 | 68.1k | filehdr_dst->f_nsyms = 0; | 186 | 68.1k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 68.1k | } | 188 | | | 189 | 587k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 587k | } |
pei-mcore.c:coff_swap_filehdr_in Line | Count | Source | 170 | 587k | { | 171 | 587k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 587k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 587k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 587k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 587k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 587k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 587k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 587k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 587k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 68.0k | { | 185 | 68.0k | filehdr_dst->f_nsyms = 0; | 186 | 68.0k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 68.0k | } | 188 | | | 189 | 587k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 587k | } |
pei-sh.c:coff_swap_filehdr_in Line | Count | Source | 170 | 587k | { | 171 | 587k | FILHDR *filehdr_src = (FILHDR *) src; | 172 | 587k | struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 173 | | | 174 | 587k | filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic); | 175 | 587k | filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns); | 176 | 587k | filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat); | 177 | 587k | filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms); | 178 | 587k | filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags); | 179 | 587k | filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr); | 180 | | | 181 | | /* Other people's tools sometimes generate headers with an nsyms but | 182 | | a zero symptr. */ | 183 | 587k | if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0) | 184 | 68.0k | { | 185 | 68.0k | filehdr_dst->f_nsyms = 0; | 186 | 68.0k | filehdr_dst->f_flags |= F_LSYMS; | 187 | 68.0k | } | 188 | | | 189 | 587k | filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr); | 190 | 587k | } |
|
191 | | |
192 | | #ifdef COFF_IMAGE_WITH_PE |
193 | | # define coff_swap_filehdr_out _bfd_XXi_only_swap_filehdr_out |
194 | | #elif defined COFF_WITH_peAArch64 |
195 | | # define coff_swap_filehdr_out _bfd_XX_only_swap_filehdr_out |
196 | | #elif defined COFF_WITH_pex64 |
197 | | # define coff_swap_filehdr_out _bfd_pex64_only_swap_filehdr_out |
198 | | #elif defined COFF_WITH_pep |
199 | | # define coff_swap_filehdr_out _bfd_pep_only_swap_filehdr_out |
200 | | #else |
201 | | # define coff_swap_filehdr_out _bfd_pe_only_swap_filehdr_out |
202 | | #endif |
203 | | |
204 | | static void |
205 | | coff_swap_scnhdr_in (bfd * abfd, void * ext, void * in) |
206 | 3.91M | { |
207 | 3.91M | SCNHDR *scnhdr_ext = (SCNHDR *) ext; |
208 | 3.91M | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; |
209 | | |
210 | 3.91M | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); |
211 | | |
212 | 3.91M | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); |
213 | 3.91M | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); |
214 | 3.91M | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); |
215 | 3.91M | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); |
216 | 3.91M | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); |
217 | 3.91M | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); |
218 | 3.91M | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); |
219 | | |
220 | | /* MS handles overflow of line numbers by carrying into the reloc |
221 | | field (it appears). Since it's supposed to be zero for PE |
222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ |
223 | | #ifdef COFF_IMAGE_WITH_PE |
224 | 3.03M | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) |
225 | 3.03M | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); |
226 | | scnhdr_int->s_nreloc = 0; |
227 | | #else |
228 | 876k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); |
229 | 876k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); |
230 | | #endif |
231 | | |
232 | 3.91M | if (scnhdr_int->s_vaddr != 0) |
233 | 1.77M | { |
234 | 1.77M | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; |
235 | | /* Do not cut upper 32-bits for 64-bit vma. */ |
236 | | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64) |
237 | | scnhdr_int->s_vaddr &= 0xffffffff; |
238 | | #endif |
239 | 1.77M | } |
240 | | |
241 | 3.91M | #ifndef COFF_NO_HACK_SCNHDR_SIZE |
242 | | /* If this section holds uninitialized data and is from an object file |
243 | | or from an executable image that has not initialized the field, |
244 | | or if the image is an executable file and the physical size is padded, |
245 | | use the virtual size (stored in s_paddr) instead. */ |
246 | 3.91M | if (scnhdr_int->s_paddr > 0 |
247 | 3.91M | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 |
248 | 1.87M | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) |
249 | 1.87M | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) |
250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, |
251 | | coff_set_alignment_hook stores s_paddr in virt_size, which |
252 | | only works if it correctly holds the virtual size of the |
253 | | section. */ |
254 | 606k | scnhdr_int->s_size = scnhdr_int->s_paddr; |
255 | 3.91M | #endif |
256 | 3.91M | } pei-i386.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 255k | { | 207 | 255k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 255k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 255k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 255k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 255k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 255k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 255k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 255k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 255k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 255k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 255k | #ifdef COFF_IMAGE_WITH_PE | 224 | 255k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 255k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 255k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 255k | if (scnhdr_int->s_vaddr != 0) | 233 | 137k | { | 234 | 137k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 137k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64) | 237 | 137k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 137k | #endif | 239 | 137k | } | 240 | | | 241 | 255k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 255k | if (scnhdr_int->s_paddr > 0 | 247 | 255k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 211k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 211k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 89.8k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 255k | #endif | 256 | 255k | } |
pe-x86_64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 345k | { | 207 | 345k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 345k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 345k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 345k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 345k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 345k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 345k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 345k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 345k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 345k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | | #ifdef COFF_IMAGE_WITH_PE | 224 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | 345k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 345k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 345k | #endif | 231 | | | 232 | 345k | if (scnhdr_int->s_vaddr != 0) | 233 | 154k | { | 234 | 154k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64) | 237 | | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | | #endif | 239 | 154k | } | 240 | | | 241 | 345k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 345k | if (scnhdr_int->s_paddr > 0 | 247 | 345k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 143k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 143k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 21.9k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 345k | #endif | 256 | 345k | } |
pei-x86_64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 247k | { | 207 | 247k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 247k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 247k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 247k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 247k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 247k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 247k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 247k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 247k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 247k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 247k | #ifdef COFF_IMAGE_WITH_PE | 224 | 247k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 247k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 247k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 247k | if (scnhdr_int->s_vaddr != 0) | 233 | 170k | { | 234 | 170k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64) | 237 | | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | | #endif | 239 | 170k | } | 240 | | | 241 | 247k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 247k | if (scnhdr_int->s_paddr > 0 | 247 | 247k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 157k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 157k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 70.1k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 247k | #endif | 256 | 247k | } |
pe-aarch64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 113k | { | 207 | 113k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 113k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 113k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 113k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 113k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 113k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 113k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 113k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 113k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 113k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | | #ifdef COFF_IMAGE_WITH_PE | 224 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | 113k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 113k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 113k | #endif | 231 | | | 232 | 113k | if (scnhdr_int->s_vaddr != 0) | 233 | 54.0k | { | 234 | 54.0k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64) | 237 | | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | | #endif | 239 | 54.0k | } | 240 | | | 241 | 113k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 113k | if (scnhdr_int->s_paddr > 0 | 247 | 113k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 54.9k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 54.9k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 9.01k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 113k | #endif | 256 | 113k | } |
pei-aarch64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 146k | { | 207 | 146k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 146k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 146k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 146k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 146k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 146k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 146k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 146k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 146k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 146k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 146k | #ifdef COFF_IMAGE_WITH_PE | 224 | 146k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 146k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 146k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 146k | if (scnhdr_int->s_vaddr != 0) | 233 | 106k | { | 234 | 106k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64) | 237 | | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | | #endif | 239 | 106k | } | 240 | | | 241 | 146k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 146k | if (scnhdr_int->s_paddr > 0 | 247 | 146k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 110k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 110k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 43.5k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 146k | #endif | 256 | 146k | } |
pei-ia64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 257k | { | 207 | 257k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 257k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 257k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 257k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 257k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 257k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 257k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 257k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 257k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 257k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 257k | #ifdef COFF_IMAGE_WITH_PE | 224 | 257k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 257k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 257k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 257k | if (scnhdr_int->s_vaddr != 0) | 233 | 146k | { | 234 | 146k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 146k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64) | 237 | 146k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 146k | #endif | 239 | 146k | } | 240 | | | 241 | 257k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 257k | if (scnhdr_int->s_paddr > 0 | 247 | 257k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 144k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 144k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 56.5k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 257k | #endif | 256 | 257k | } |
pei-loongarch64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 116k | { | 207 | 116k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 116k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 116k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 116k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 116k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 116k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 116k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 116k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 116k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 116k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 116k | #ifdef COFF_IMAGE_WITH_PE | 224 | 116k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 116k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 116k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 116k | if (scnhdr_int->s_vaddr != 0) | 233 | 80.1k | { | 234 | 80.1k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64) | 237 | | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | | #endif | 239 | 80.1k | } | 240 | | | 241 | 116k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 116k | if (scnhdr_int->s_paddr > 0 | 247 | 116k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 82.9k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 82.9k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 29.9k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 116k | #endif | 256 | 116k | } |
pei-riscv64.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 333k | { | 207 | 333k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 333k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 333k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 333k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 333k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 333k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 333k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 333k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 333k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 333k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 333k | #ifdef COFF_IMAGE_WITH_PE | 224 | 333k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 333k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 333k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 333k | if (scnhdr_int->s_vaddr != 0) | 233 | 86.4k | { | 234 | 86.4k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64) | 237 | | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | | #endif | 239 | 86.4k | } | 240 | | | 241 | 333k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 333k | if (scnhdr_int->s_paddr > 0 | 247 | 333k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 89.2k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 89.2k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 21.1k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 333k | #endif | 256 | 333k | } |
pe-arm-wince.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 40.4k | { | 207 | 40.4k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 40.4k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 40.4k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 40.4k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 40.4k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 40.4k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 40.4k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 40.4k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 40.4k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 40.4k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | | #ifdef COFF_IMAGE_WITH_PE | 224 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | 40.4k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 40.4k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 40.4k | #endif | 231 | | | 232 | 40.4k | if (scnhdr_int->s_vaddr != 0) | 233 | 31.2k | { | 234 | 31.2k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 31.2k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64) | 237 | 31.2k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 31.2k | #endif | 239 | 31.2k | } | 240 | | | 241 | 40.4k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 40.4k | if (scnhdr_int->s_paddr > 0 | 247 | 40.4k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 31.4k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 31.4k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 6.05k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 40.4k | #endif | 256 | 40.4k | } |
pe-arm.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 40.4k | { | 207 | 40.4k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 40.4k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 40.4k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 40.4k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 40.4k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 40.4k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 40.4k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 40.4k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 40.4k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 40.4k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | | #ifdef COFF_IMAGE_WITH_PE | 224 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | 40.4k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 40.4k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 40.4k | #endif | 231 | | | 232 | 40.4k | if (scnhdr_int->s_vaddr != 0) | 233 | 31.2k | { | 234 | 31.2k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 31.2k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64) | 237 | 31.2k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 31.2k | #endif | 239 | 31.2k | } | 240 | | | 241 | 40.4k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 40.4k | if (scnhdr_int->s_paddr > 0 | 247 | 40.4k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 31.4k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 31.4k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 6.05k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 40.4k | #endif | 256 | 40.4k | } |
pe-i386.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 139k | { | 207 | 139k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 139k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 139k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 139k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 139k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 139k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 139k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 139k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 139k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 139k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | | #ifdef COFF_IMAGE_WITH_PE | 224 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | 139k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 139k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 139k | #endif | 231 | | | 232 | 139k | if (scnhdr_int->s_vaddr != 0) | 233 | 94.9k | { | 234 | 94.9k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 94.9k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64) | 237 | 94.9k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 94.9k | #endif | 239 | 94.9k | } | 240 | | | 241 | 139k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 139k | if (scnhdr_int->s_paddr > 0 | 247 | 139k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 99.7k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 99.7k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 19.2k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 139k | #endif | 256 | 139k | } |
pe-mcore.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 114k | { | 207 | 114k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 114k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 114k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 114k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 114k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 114k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 114k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 114k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 114k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 114k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | | #ifdef COFF_IMAGE_WITH_PE | 224 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | 114k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 114k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 114k | #endif | 231 | | | 232 | 114k | if (scnhdr_int->s_vaddr != 0) | 233 | 74.0k | { | 234 | 74.0k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 74.0k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64) | 237 | 74.0k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 74.0k | #endif | 239 | 74.0k | } | 240 | | | 241 | 114k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 114k | if (scnhdr_int->s_paddr > 0 | 247 | 114k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 73.5k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 73.5k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 17.0k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 114k | #endif | 256 | 114k | } |
pe-sh.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 82.8k | { | 207 | 82.8k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 82.8k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 82.8k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 82.8k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 82.8k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 82.8k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 82.8k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 82.8k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 82.8k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 82.8k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | | #ifdef COFF_IMAGE_WITH_PE | 224 | | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | 82.8k | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | 82.8k | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | 82.8k | #endif | 231 | | | 232 | 82.8k | if (scnhdr_int->s_vaddr != 0) | 233 | 49.8k | { | 234 | 49.8k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 49.8k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64) | 237 | 49.8k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 49.8k | #endif | 239 | 49.8k | } | 240 | | | 241 | 82.8k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 82.8k | if (scnhdr_int->s_paddr > 0 | 247 | 82.8k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 53.7k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 53.7k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 6.38k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 82.8k | #endif | 256 | 82.8k | } |
pei-arm-wince.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 227k | { | 207 | 227k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 227k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 227k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 227k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 227k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 227k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 227k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 227k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 227k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 227k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 227k | #ifdef COFF_IMAGE_WITH_PE | 224 | 227k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 227k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 227k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 227k | if (scnhdr_int->s_vaddr != 0) | 233 | 130k | { | 234 | 130k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 130k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64) | 237 | 130k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 130k | #endif | 239 | 130k | } | 240 | | | 241 | 227k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 227k | if (scnhdr_int->s_paddr > 0 | 247 | 227k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 147k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 147k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 56.6k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 227k | #endif | 256 | 227k | } |
pei-arm.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 1.02M | { | 207 | 1.02M | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 1.02M | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 1.02M | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 1.02M | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 1.02M | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 1.02M | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 1.02M | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 1.02M | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 1.02M | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 1.02M | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 1.02M | #ifdef COFF_IMAGE_WITH_PE | 224 | 1.02M | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 1.02M | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 1.02M | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 1.02M | if (scnhdr_int->s_vaddr != 0) | 233 | 183k | { | 234 | 183k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 183k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64) | 237 | 183k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 183k | #endif | 239 | 183k | } | 240 | | | 241 | 1.02M | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 1.02M | if (scnhdr_int->s_paddr > 0 | 247 | 1.02M | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 190k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 190k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 61.5k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 1.02M | #endif | 256 | 1.02M | } |
pei-mcore.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 203k | { | 207 | 203k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 203k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 203k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 203k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 203k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 203k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 203k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 203k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 203k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 203k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 203k | #ifdef COFF_IMAGE_WITH_PE | 224 | 203k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 203k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 203k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 203k | if (scnhdr_int->s_vaddr != 0) | 233 | 117k | { | 234 | 117k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 117k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64) | 237 | 117k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 117k | #endif | 239 | 117k | } | 240 | | | 241 | 203k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 203k | if (scnhdr_int->s_paddr > 0 | 247 | 203k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 122k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 122k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 40.7k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 203k | #endif | 256 | 203k | } |
pei-sh.c:coff_swap_scnhdr_in Line | Count | Source | 206 | 220k | { | 207 | 220k | SCNHDR *scnhdr_ext = (SCNHDR *) ext; | 208 | 220k | struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 209 | | | 210 | 220k | memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name)); | 211 | | | 212 | 220k | scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr); | 213 | 220k | scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr); | 214 | 220k | scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size); | 215 | 220k | scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr); | 216 | 220k | scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr); | 217 | 220k | scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr); | 218 | 220k | scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags); | 219 | | | 220 | | /* MS handles overflow of line numbers by carrying into the reloc | 221 | | field (it appears). Since it's supposed to be zero for PE | 222 | | *IMAGE* format, that's safe. This is still a bit iffy. */ | 223 | 220k | #ifdef COFF_IMAGE_WITH_PE | 224 | 220k | scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno) | 225 | 220k | + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16)); | 226 | 220k | scnhdr_int->s_nreloc = 0; | 227 | | #else | 228 | | scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc); | 229 | | scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno); | 230 | | #endif | 231 | | | 232 | 220k | if (scnhdr_int->s_vaddr != 0) | 233 | 123k | { | 234 | 123k | scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; | 235 | | /* Do not cut upper 32-bits for 64-bit vma. */ | 236 | 123k | #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peLoongArch64) && !defined(COFF_WITH_peRiscV64) | 237 | 123k | scnhdr_int->s_vaddr &= 0xffffffff; | 238 | 123k | #endif | 239 | 123k | } | 240 | | | 241 | 220k | #ifndef COFF_NO_HACK_SCNHDR_SIZE | 242 | | /* If this section holds uninitialized data and is from an object file | 243 | | or from an executable image that has not initialized the field, | 244 | | or if the image is an executable file and the physical size is padded, | 245 | | use the virtual size (stored in s_paddr) instead. */ | 246 | 220k | if (scnhdr_int->s_paddr > 0 | 247 | 220k | && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0 | 248 | 130k | && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0)) | 249 | 130k | || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr)))) | 250 | | /* This code used to set scnhdr_int->s_paddr to 0. However, | 251 | | coff_set_alignment_hook stores s_paddr in virt_size, which | 252 | | only works if it correctly holds the virtual size of the | 253 | | section. */ | 254 | 50.6k | scnhdr_int->s_size = scnhdr_int->s_paddr; | 255 | 220k | #endif | 256 | 220k | } |
|
257 | | |
258 | | static bool |
259 | | pe_mkobject (bfd * abfd) |
260 | 902k | { |
261 | | /* Some x86 code followed by an ascii string. */ |
262 | 902k | static const char default_dos_message[64] = { |
263 | 902k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, |
264 | 902k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, |
265 | 902k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, |
266 | 902k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, |
267 | 902k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, |
268 | 902k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, |
269 | 902k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, |
270 | 902k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
271 | | |
272 | 902k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); |
273 | 902k | abfd->tdata.pe_obj_data = pe; |
274 | 902k | if (pe == NULL) |
275 | 0 | return false; |
276 | | |
277 | 902k | pe->coff.pe = 1; |
278 | | |
279 | | /* in_reloc_p is architecture dependent. */ |
280 | 902k | pe->in_reloc_p = in_reloc_p; |
281 | | |
282 | 902k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); |
283 | | |
284 | 902k | bfd_coff_long_section_names (abfd) |
285 | 902k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; |
286 | | |
287 | 902k | return true; |
288 | 902k | } Line | Count | Source | 260 | 75.1k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 75.1k | static const char default_dos_message[64] = { | 263 | 75.1k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 75.1k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 75.1k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 75.1k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 75.1k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 75.1k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 75.1k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 75.1k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 75.1k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 75.1k | abfd->tdata.pe_obj_data = pe; | 274 | 75.1k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 75.1k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 75.1k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 75.1k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 75.1k | bfd_coff_long_section_names (abfd) | 285 | 75.1k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 75.1k | return true; | 288 | 75.1k | } |
Line | Count | Source | 260 | 89.8k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 89.8k | static const char default_dos_message[64] = { | 263 | 89.8k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 89.8k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 89.8k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 89.8k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 89.8k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 89.8k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 89.8k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 89.8k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 89.8k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 89.8k | abfd->tdata.pe_obj_data = pe; | 274 | 89.8k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 89.8k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 89.8k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 89.8k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 89.8k | bfd_coff_long_section_names (abfd) | 285 | 89.8k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 89.8k | return true; | 288 | 89.8k | } |
Line | Count | Source | 260 | 86.1k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 86.1k | static const char default_dos_message[64] = { | 263 | 86.1k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 86.1k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 86.1k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 86.1k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 86.1k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 86.1k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 86.1k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 86.1k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 86.1k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 86.1k | abfd->tdata.pe_obj_data = pe; | 274 | 86.1k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 86.1k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 86.1k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 86.1k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 86.1k | bfd_coff_long_section_names (abfd) | 285 | 86.1k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 86.1k | return true; | 288 | 86.1k | } |
Line | Count | Source | 260 | 26.8k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 26.8k | static const char default_dos_message[64] = { | 263 | 26.8k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 26.8k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 26.8k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 26.8k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 26.8k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 26.8k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 26.8k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 26.8k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 26.8k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 26.8k | abfd->tdata.pe_obj_data = pe; | 274 | 26.8k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 26.8k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 26.8k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 26.8k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 26.8k | bfd_coff_long_section_names (abfd) | 285 | 26.8k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 26.8k | return true; | 288 | 26.8k | } |
pei-aarch64.c:pe_mkobject Line | Count | Source | 260 | 59.9k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 59.9k | static const char default_dos_message[64] = { | 263 | 59.9k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 59.9k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 59.9k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 59.9k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 59.9k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 59.9k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 59.9k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 59.9k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 59.9k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 59.9k | abfd->tdata.pe_obj_data = pe; | 274 | 59.9k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 59.9k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 59.9k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 59.9k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 59.9k | bfd_coff_long_section_names (abfd) | 285 | 59.9k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 59.9k | return true; | 288 | 59.9k | } |
Line | Count | Source | 260 | 75.0k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 75.0k | static const char default_dos_message[64] = { | 263 | 75.0k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 75.0k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 75.0k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 75.0k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 75.0k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 75.0k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 75.0k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 75.0k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 75.0k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 75.0k | abfd->tdata.pe_obj_data = pe; | 274 | 75.0k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 75.0k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 75.0k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 75.0k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 75.0k | bfd_coff_long_section_names (abfd) | 285 | 75.0k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 75.0k | return true; | 288 | 75.0k | } |
pei-loongarch64.c:pe_mkobject Line | Count | Source | 260 | 44.0k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 44.0k | static const char default_dos_message[64] = { | 263 | 44.0k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 44.0k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 44.0k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 44.0k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 44.0k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 44.0k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 44.0k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 44.0k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 44.0k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 44.0k | abfd->tdata.pe_obj_data = pe; | 274 | 44.0k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 44.0k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 44.0k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 44.0k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 44.0k | bfd_coff_long_section_names (abfd) | 285 | 44.0k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 44.0k | return true; | 288 | 44.0k | } |
pei-riscv64.c:pe_mkobject Line | Count | Source | 260 | 28.2k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 28.2k | static const char default_dos_message[64] = { | 263 | 28.2k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 28.2k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 28.2k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 28.2k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 28.2k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 28.2k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 28.2k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 28.2k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 28.2k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 28.2k | abfd->tdata.pe_obj_data = pe; | 274 | 28.2k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 28.2k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 28.2k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 28.2k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 28.2k | bfd_coff_long_section_names (abfd) | 285 | 28.2k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 28.2k | return true; | 288 | 28.2k | } |
pe-arm-wince.c:pe_mkobject Line | Count | Source | 260 | 13.3k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 13.3k | static const char default_dos_message[64] = { | 263 | 13.3k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 13.3k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 13.3k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 13.3k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 13.3k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 13.3k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 13.3k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 13.3k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 13.3k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 13.3k | abfd->tdata.pe_obj_data = pe; | 274 | 13.3k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 13.3k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 13.3k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 13.3k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 13.3k | bfd_coff_long_section_names (abfd) | 285 | 13.3k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 13.3k | return true; | 288 | 13.3k | } |
Line | Count | Source | 260 | 13.3k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 13.3k | static const char default_dos_message[64] = { | 263 | 13.3k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 13.3k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 13.3k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 13.3k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 13.3k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 13.3k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 13.3k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 13.3k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 13.3k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 13.3k | abfd->tdata.pe_obj_data = pe; | 274 | 13.3k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 13.3k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 13.3k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 13.3k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 13.3k | bfd_coff_long_section_names (abfd) | 285 | 13.3k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 13.3k | return true; | 288 | 13.3k | } |
Line | Count | Source | 260 | 46.4k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 46.4k | static const char default_dos_message[64] = { | 263 | 46.4k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 46.4k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 46.4k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 46.4k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 46.4k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 46.4k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 46.4k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 46.4k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 46.4k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 46.4k | abfd->tdata.pe_obj_data = pe; | 274 | 46.4k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 46.4k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 46.4k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 46.4k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 46.4k | bfd_coff_long_section_names (abfd) | 285 | 46.4k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 46.4k | return true; | 288 | 46.4k | } |
Line | Count | Source | 260 | 32.2k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 32.2k | static const char default_dos_message[64] = { | 263 | 32.2k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 32.2k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 32.2k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 32.2k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 32.2k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 32.2k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 32.2k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 32.2k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 32.2k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 32.2k | abfd->tdata.pe_obj_data = pe; | 274 | 32.2k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 32.2k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 32.2k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 32.2k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 32.2k | bfd_coff_long_section_names (abfd) | 285 | 32.2k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 32.2k | return true; | 288 | 32.2k | } |
Line | Count | Source | 260 | 28.2k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 28.2k | static const char default_dos_message[64] = { | 263 | 28.2k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 28.2k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 28.2k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 28.2k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 28.2k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 28.2k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 28.2k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 28.2k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 28.2k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 28.2k | abfd->tdata.pe_obj_data = pe; | 274 | 28.2k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 28.2k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 28.2k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 28.2k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 28.2k | bfd_coff_long_section_names (abfd) | 285 | 28.2k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 28.2k | return true; | 288 | 28.2k | } |
pei-arm-wince.c:pe_mkobject Line | Count | Source | 260 | 69.3k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 69.3k | static const char default_dos_message[64] = { | 263 | 69.3k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 69.3k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 69.3k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 69.3k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 69.3k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 69.3k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 69.3k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 69.3k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 69.3k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 69.3k | abfd->tdata.pe_obj_data = pe; | 274 | 69.3k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 69.3k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 69.3k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 69.3k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 69.3k | bfd_coff_long_section_names (abfd) | 285 | 69.3k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 69.3k | return true; | 288 | 69.3k | } |
Line | Count | Source | 260 | 88.0k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 88.0k | static const char default_dos_message[64] = { | 263 | 88.0k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 88.0k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 88.0k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 88.0k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 88.0k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 88.0k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 88.0k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 88.0k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 88.0k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 88.0k | abfd->tdata.pe_obj_data = pe; | 274 | 88.0k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 88.0k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 88.0k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 88.0k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 88.0k | bfd_coff_long_section_names (abfd) | 285 | 88.0k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 88.0k | return true; | 288 | 88.0k | } |
Line | Count | Source | 260 | 62.9k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 62.9k | static const char default_dos_message[64] = { | 263 | 62.9k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 62.9k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 62.9k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 62.9k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 62.9k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 62.9k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 62.9k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 62.9k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 62.9k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 62.9k | abfd->tdata.pe_obj_data = pe; | 274 | 62.9k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 62.9k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 62.9k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 62.9k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 62.9k | bfd_coff_long_section_names (abfd) | 285 | 62.9k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 62.9k | return true; | 288 | 62.9k | } |
Line | Count | Source | 260 | 63.6k | { | 261 | | /* Some x86 code followed by an ascii string. */ | 262 | 63.6k | static const char default_dos_message[64] = { | 263 | 63.6k | 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, | 264 | 63.6k | 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, | 265 | 63.6k | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, | 266 | 63.6k | 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, | 267 | 63.6k | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, | 268 | 63.6k | 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, | 269 | 63.6k | 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, | 270 | 63.6k | 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 271 | | | 272 | 63.6k | pe_data_type *pe = bfd_zalloc (abfd, sizeof (*pe)); | 273 | 63.6k | abfd->tdata.pe_obj_data = pe; | 274 | 63.6k | if (pe == NULL) | 275 | 0 | return false; | 276 | | | 277 | 63.6k | pe->coff.pe = 1; | 278 | | | 279 | | /* in_reloc_p is architecture dependent. */ | 280 | 63.6k | pe->in_reloc_p = in_reloc_p; | 281 | | | 282 | 63.6k | memcpy (pe->dos_message, default_dos_message, sizeof (pe->dos_message)); | 283 | | | 284 | 63.6k | bfd_coff_long_section_names (abfd) | 285 | 63.6k | = coff_backend_info (abfd)->_bfd_coff_long_section_names; | 286 | | | 287 | 63.6k | return true; | 288 | 63.6k | } |
|
289 | | |
290 | | /* Create the COFF backend specific information. */ |
291 | | |
292 | | static void * |
293 | | pe_mkobject_hook (bfd * abfd, |
294 | | void * filehdr, |
295 | | void * aouthdr ATTRIBUTE_UNUSED) |
296 | 902k | { |
297 | 902k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; |
298 | 902k | pe_data_type *pe; |
299 | | |
300 | 902k | if (! pe_mkobject (abfd)) |
301 | 0 | return NULL; |
302 | | |
303 | 902k | pe = pe_data (abfd); |
304 | 902k | pe->coff.sym_filepos = internal_f->f_symptr; |
305 | | /* These members communicate important constants about the symbol |
306 | | table to GDB's symbol-reading code. These `constants' |
307 | | unfortunately vary among coff implementations... */ |
308 | 902k | pe->coff.local_n_btmask = N_BTMASK; |
309 | 902k | pe->coff.local_n_btshft = N_BTSHFT; |
310 | 902k | pe->coff.local_n_tmask = N_TMASK; |
311 | 902k | pe->coff.local_n_tshift = N_TSHIFT; |
312 | 902k | pe->coff.local_symesz = SYMESZ; |
313 | 902k | pe->coff.local_auxesz = AUXESZ; |
314 | 902k | pe->coff.local_linesz = LINESZ; |
315 | | |
316 | 902k | pe->coff.timestamp = internal_f->f_timdat; |
317 | | |
318 | 902k | obj_raw_syment_count (abfd) = |
319 | 902k | obj_conv_table_size (abfd) = |
320 | 902k | internal_f->f_nsyms; |
321 | | |
322 | 902k | pe->real_flags = internal_f->f_flags; |
323 | | |
324 | 902k | if ((internal_f->f_flags & F_DLL) != 0) |
325 | 278k | pe->dll = 1; |
326 | | |
327 | 902k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) |
328 | 655k | abfd->flags |= HAS_DEBUG; |
329 | | |
330 | | #ifdef COFF_IMAGE_WITH_PE |
331 | 652k | if (aouthdr) |
332 | 411k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; |
333 | | #endif |
334 | | |
335 | | #ifdef ARM |
336 | 184k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) |
337 | 0 | coff_data (abfd) ->flags = 0; |
338 | | #endif |
339 | | |
340 | 902k | memcpy (pe->dos_message, internal_f->pe.dos_message, |
341 | 902k | sizeof (pe->dos_message)); |
342 | | |
343 | 902k | return (void *) pe; |
344 | 902k | } pei-i386.c:pe_mkobject_hook Line | Count | Source | 296 | 75.1k | { | 297 | 75.1k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 75.1k | pe_data_type *pe; | 299 | | | 300 | 75.1k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 75.1k | pe = pe_data (abfd); | 304 | 75.1k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 75.1k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 75.1k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 75.1k | pe->coff.local_n_tmask = N_TMASK; | 311 | 75.1k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 75.1k | pe->coff.local_symesz = SYMESZ; | 313 | 75.1k | pe->coff.local_auxesz = AUXESZ; | 314 | 75.1k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 75.1k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 75.1k | obj_raw_syment_count (abfd) = | 319 | 75.1k | obj_conv_table_size (abfd) = | 320 | 75.1k | internal_f->f_nsyms; | 321 | | | 322 | 75.1k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 75.1k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 16.2k | pe->dll = 1; | 326 | | | 327 | 75.1k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 63.7k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 75.1k | #ifdef COFF_IMAGE_WITH_PE | 331 | 75.1k | if (aouthdr) | 332 | 51.5k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 75.1k | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 75.1k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 75.1k | sizeof (pe->dos_message)); | 342 | | | 343 | 75.1k | return (void *) pe; | 344 | 75.1k | } |
pe-x86_64.c:pe_mkobject_hook Line | Count | Source | 296 | 89.8k | { | 297 | 89.8k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 89.8k | pe_data_type *pe; | 299 | | | 300 | 89.8k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 89.8k | pe = pe_data (abfd); | 304 | 89.8k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 89.8k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 89.8k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 89.8k | pe->coff.local_n_tmask = N_TMASK; | 311 | 89.8k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 89.8k | pe->coff.local_symesz = SYMESZ; | 313 | 89.8k | pe->coff.local_auxesz = AUXESZ; | 314 | 89.8k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 89.8k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 89.8k | obj_raw_syment_count (abfd) = | 319 | 89.8k | obj_conv_table_size (abfd) = | 320 | 89.8k | internal_f->f_nsyms; | 321 | | | 322 | 89.8k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 89.8k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 20.4k | pe->dll = 1; | 326 | | | 327 | 89.8k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 65.6k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | | #ifdef COFF_IMAGE_WITH_PE | 331 | | if (aouthdr) | 332 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 89.8k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 89.8k | sizeof (pe->dos_message)); | 342 | | | 343 | 89.8k | return (void *) pe; | 344 | 89.8k | } |
pei-x86_64.c:pe_mkobject_hook Line | Count | Source | 296 | 86.1k | { | 297 | 86.1k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 86.1k | pe_data_type *pe; | 299 | | | 300 | 86.1k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 86.1k | pe = pe_data (abfd); | 304 | 86.1k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 86.1k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 86.1k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 86.1k | pe->coff.local_n_tmask = N_TMASK; | 311 | 86.1k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 86.1k | pe->coff.local_symesz = SYMESZ; | 313 | 86.1k | pe->coff.local_auxesz = AUXESZ; | 314 | 86.1k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 86.1k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 86.1k | obj_raw_syment_count (abfd) = | 319 | 86.1k | obj_conv_table_size (abfd) = | 320 | 86.1k | internal_f->f_nsyms; | 321 | | | 322 | 86.1k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 86.1k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 31.9k | pe->dll = 1; | 326 | | | 327 | 86.1k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 62.5k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 86.1k | #ifdef COFF_IMAGE_WITH_PE | 331 | 86.1k | if (aouthdr) | 332 | 55.1k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 86.1k | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 86.1k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 86.1k | sizeof (pe->dos_message)); | 342 | | | 343 | 86.1k | return (void *) pe; | 344 | 86.1k | } |
pe-aarch64.c:pe_mkobject_hook Line | Count | Source | 296 | 26.8k | { | 297 | 26.8k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 26.8k | pe_data_type *pe; | 299 | | | 300 | 26.8k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 26.8k | pe = pe_data (abfd); | 304 | 26.8k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 26.8k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 26.8k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 26.8k | pe->coff.local_n_tmask = N_TMASK; | 311 | 26.8k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 26.8k | pe->coff.local_symesz = SYMESZ; | 313 | 26.8k | pe->coff.local_auxesz = AUXESZ; | 314 | 26.8k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 26.8k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 26.8k | obj_raw_syment_count (abfd) = | 319 | 26.8k | obj_conv_table_size (abfd) = | 320 | 26.8k | internal_f->f_nsyms; | 321 | | | 322 | 26.8k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 26.8k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 6.42k | pe->dll = 1; | 326 | | | 327 | 26.8k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 20.2k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | | #ifdef COFF_IMAGE_WITH_PE | 331 | | if (aouthdr) | 332 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 26.8k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 26.8k | sizeof (pe->dos_message)); | 342 | | | 343 | 26.8k | return (void *) pe; | 344 | 26.8k | } |
pei-aarch64.c:pe_mkobject_hook Line | Count | Source | 296 | 59.9k | { | 297 | 59.9k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 59.9k | pe_data_type *pe; | 299 | | | 300 | 59.9k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 59.9k | pe = pe_data (abfd); | 304 | 59.9k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 59.9k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 59.9k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 59.9k | pe->coff.local_n_tmask = N_TMASK; | 311 | 59.9k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 59.9k | pe->coff.local_symesz = SYMESZ; | 313 | 59.9k | pe->coff.local_auxesz = AUXESZ; | 314 | 59.9k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 59.9k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 59.9k | obj_raw_syment_count (abfd) = | 319 | 59.9k | obj_conv_table_size (abfd) = | 320 | 59.9k | internal_f->f_nsyms; | 321 | | | 322 | 59.9k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 59.9k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 21.9k | pe->dll = 1; | 326 | | | 327 | 59.9k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 39.0k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 59.9k | #ifdef COFF_IMAGE_WITH_PE | 331 | 59.9k | if (aouthdr) | 332 | 43.9k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 59.9k | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 59.9k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 59.9k | sizeof (pe->dos_message)); | 342 | | | 343 | 59.9k | return (void *) pe; | 344 | 59.9k | } |
pei-ia64.c:pe_mkobject_hook Line | Count | Source | 296 | 75.0k | { | 297 | 75.0k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 75.0k | pe_data_type *pe; | 299 | | | 300 | 75.0k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 75.0k | pe = pe_data (abfd); | 304 | 75.0k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 75.0k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 75.0k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 75.0k | pe->coff.local_n_tmask = N_TMASK; | 311 | 75.0k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 75.0k | pe->coff.local_symesz = SYMESZ; | 313 | 75.0k | pe->coff.local_auxesz = AUXESZ; | 314 | 75.0k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 75.0k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 75.0k | obj_raw_syment_count (abfd) = | 319 | 75.0k | obj_conv_table_size (abfd) = | 320 | 75.0k | internal_f->f_nsyms; | 321 | | | 322 | 75.0k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 75.0k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 29.6k | pe->dll = 1; | 326 | | | 327 | 75.0k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 49.3k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 75.0k | #ifdef COFF_IMAGE_WITH_PE | 331 | 75.0k | if (aouthdr) | 332 | 49.2k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 75.0k | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 75.0k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 75.0k | sizeof (pe->dos_message)); | 342 | | | 343 | 75.0k | return (void *) pe; | 344 | 75.0k | } |
pei-loongarch64.c:pe_mkobject_hook Line | Count | Source | 296 | 44.0k | { | 297 | 44.0k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 44.0k | pe_data_type *pe; | 299 | | | 300 | 44.0k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 44.0k | pe = pe_data (abfd); | 304 | 44.0k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 44.0k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 44.0k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 44.0k | pe->coff.local_n_tmask = N_TMASK; | 311 | 44.0k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 44.0k | pe->coff.local_symesz = SYMESZ; | 313 | 44.0k | pe->coff.local_auxesz = AUXESZ; | 314 | 44.0k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 44.0k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 44.0k | obj_raw_syment_count (abfd) = | 319 | 44.0k | obj_conv_table_size (abfd) = | 320 | 44.0k | internal_f->f_nsyms; | 321 | | | 322 | 44.0k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 44.0k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 17.2k | pe->dll = 1; | 326 | | | 327 | 44.0k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 31.0k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 44.0k | #ifdef COFF_IMAGE_WITH_PE | 331 | 44.0k | if (aouthdr) | 332 | 31.7k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 44.0k | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 44.0k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 44.0k | sizeof (pe->dos_message)); | 342 | | | 343 | 44.0k | return (void *) pe; | 344 | 44.0k | } |
pei-riscv64.c:pe_mkobject_hook Line | Count | Source | 296 | 28.2k | { | 297 | 28.2k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 28.2k | pe_data_type *pe; | 299 | | | 300 | 28.2k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 28.2k | pe = pe_data (abfd); | 304 | 28.2k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 28.2k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 28.2k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 28.2k | pe->coff.local_n_tmask = N_TMASK; | 311 | 28.2k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 28.2k | pe->coff.local_symesz = SYMESZ; | 313 | 28.2k | pe->coff.local_auxesz = AUXESZ; | 314 | 28.2k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 28.2k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 28.2k | obj_raw_syment_count (abfd) = | 319 | 28.2k | obj_conv_table_size (abfd) = | 320 | 28.2k | internal_f->f_nsyms; | 321 | | | 322 | 28.2k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 28.2k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 17.6k | pe->dll = 1; | 326 | | | 327 | 28.2k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 10.3k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 28.2k | #ifdef COFF_IMAGE_WITH_PE | 331 | 28.2k | if (aouthdr) | 332 | 24.2k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 28.2k | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 28.2k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 28.2k | sizeof (pe->dos_message)); | 342 | | | 343 | 28.2k | return (void *) pe; | 344 | 28.2k | } |
pe-arm-wince.c:pe_mkobject_hook Line | Count | Source | 296 | 13.3k | { | 297 | 13.3k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 13.3k | pe_data_type *pe; | 299 | | | 300 | 13.3k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 13.3k | pe = pe_data (abfd); | 304 | 13.3k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 13.3k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 13.3k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 13.3k | pe->coff.local_n_tmask = N_TMASK; | 311 | 13.3k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 13.3k | pe->coff.local_symesz = SYMESZ; | 313 | 13.3k | pe->coff.local_auxesz = AUXESZ; | 314 | 13.3k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 13.3k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 13.3k | obj_raw_syment_count (abfd) = | 319 | 13.3k | obj_conv_table_size (abfd) = | 320 | 13.3k | internal_f->f_nsyms; | 321 | | | 322 | 13.3k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 13.3k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 4.28k | pe->dll = 1; | 326 | | | 327 | 13.3k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 9.71k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | | #ifdef COFF_IMAGE_WITH_PE | 331 | | if (aouthdr) | 332 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | | #endif | 334 | | | 335 | 13.3k | #ifdef ARM | 336 | 13.3k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | 0 | coff_data (abfd) ->flags = 0; | 338 | 13.3k | #endif | 339 | | | 340 | 13.3k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 13.3k | sizeof (pe->dos_message)); | 342 | | | 343 | 13.3k | return (void *) pe; | 344 | 13.3k | } |
pe-arm.c:pe_mkobject_hook Line | Count | Source | 296 | 13.3k | { | 297 | 13.3k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 13.3k | pe_data_type *pe; | 299 | | | 300 | 13.3k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 13.3k | pe = pe_data (abfd); | 304 | 13.3k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 13.3k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 13.3k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 13.3k | pe->coff.local_n_tmask = N_TMASK; | 311 | 13.3k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 13.3k | pe->coff.local_symesz = SYMESZ; | 313 | 13.3k | pe->coff.local_auxesz = AUXESZ; | 314 | 13.3k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 13.3k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 13.3k | obj_raw_syment_count (abfd) = | 319 | 13.3k | obj_conv_table_size (abfd) = | 320 | 13.3k | internal_f->f_nsyms; | 321 | | | 322 | 13.3k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 13.3k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 4.28k | pe->dll = 1; | 326 | | | 327 | 13.3k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 9.71k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | | #ifdef COFF_IMAGE_WITH_PE | 331 | | if (aouthdr) | 332 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | | #endif | 334 | | | 335 | 13.3k | #ifdef ARM | 336 | 13.3k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | 0 | coff_data (abfd) ->flags = 0; | 338 | 13.3k | #endif | 339 | | | 340 | 13.3k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 13.3k | sizeof (pe->dos_message)); | 342 | | | 343 | 13.3k | return (void *) pe; | 344 | 13.3k | } |
pe-i386.c:pe_mkobject_hook Line | Count | Source | 296 | 46.4k | { | 297 | 46.4k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 46.4k | pe_data_type *pe; | 299 | | | 300 | 46.4k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 46.4k | pe = pe_data (abfd); | 304 | 46.4k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 46.4k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 46.4k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 46.4k | pe->coff.local_n_tmask = N_TMASK; | 311 | 46.4k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 46.4k | pe->coff.local_symesz = SYMESZ; | 313 | 46.4k | pe->coff.local_auxesz = AUXESZ; | 314 | 46.4k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 46.4k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 46.4k | obj_raw_syment_count (abfd) = | 319 | 46.4k | obj_conv_table_size (abfd) = | 320 | 46.4k | internal_f->f_nsyms; | 321 | | | 322 | 46.4k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 46.4k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 14.4k | pe->dll = 1; | 326 | | | 327 | 46.4k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 35.3k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | | #ifdef COFF_IMAGE_WITH_PE | 331 | | if (aouthdr) | 332 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 46.4k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 46.4k | sizeof (pe->dos_message)); | 342 | | | 343 | 46.4k | return (void *) pe; | 344 | 46.4k | } |
pe-mcore.c:pe_mkobject_hook Line | Count | Source | 296 | 32.2k | { | 297 | 32.2k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 32.2k | pe_data_type *pe; | 299 | | | 300 | 32.2k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 32.2k | pe = pe_data (abfd); | 304 | 32.2k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 32.2k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 32.2k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 32.2k | pe->coff.local_n_tmask = N_TMASK; | 311 | 32.2k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 32.2k | pe->coff.local_symesz = SYMESZ; | 313 | 32.2k | pe->coff.local_auxesz = AUXESZ; | 314 | 32.2k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 32.2k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 32.2k | obj_raw_syment_count (abfd) = | 319 | 32.2k | obj_conv_table_size (abfd) = | 320 | 32.2k | internal_f->f_nsyms; | 321 | | | 322 | 32.2k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 32.2k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 9.85k | pe->dll = 1; | 326 | | | 327 | 32.2k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 23.2k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | | #ifdef COFF_IMAGE_WITH_PE | 331 | | if (aouthdr) | 332 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 32.2k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 32.2k | sizeof (pe->dos_message)); | 342 | | | 343 | 32.2k | return (void *) pe; | 344 | 32.2k | } |
Line | Count | Source | 296 | 28.2k | { | 297 | 28.2k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 28.2k | pe_data_type *pe; | 299 | | | 300 | 28.2k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 28.2k | pe = pe_data (abfd); | 304 | 28.2k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 28.2k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 28.2k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 28.2k | pe->coff.local_n_tmask = N_TMASK; | 311 | 28.2k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 28.2k | pe->coff.local_symesz = SYMESZ; | 313 | 28.2k | pe->coff.local_auxesz = AUXESZ; | 314 | 28.2k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 28.2k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 28.2k | obj_raw_syment_count (abfd) = | 319 | 28.2k | obj_conv_table_size (abfd) = | 320 | 28.2k | internal_f->f_nsyms; | 321 | | | 322 | 28.2k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 28.2k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 8.46k | pe->dll = 1; | 326 | | | 327 | 28.2k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 22.6k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | | #ifdef COFF_IMAGE_WITH_PE | 331 | | if (aouthdr) | 332 | | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 28.2k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 28.2k | sizeof (pe->dos_message)); | 342 | | | 343 | 28.2k | return (void *) pe; | 344 | 28.2k | } |
pei-arm-wince.c:pe_mkobject_hook Line | Count | Source | 296 | 69.3k | { | 297 | 69.3k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 69.3k | pe_data_type *pe; | 299 | | | 300 | 69.3k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 69.3k | pe = pe_data (abfd); | 304 | 69.3k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 69.3k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 69.3k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 69.3k | pe->coff.local_n_tmask = N_TMASK; | 311 | 69.3k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 69.3k | pe->coff.local_symesz = SYMESZ; | 313 | 69.3k | pe->coff.local_auxesz = AUXESZ; | 314 | 69.3k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 69.3k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 69.3k | obj_raw_syment_count (abfd) = | 319 | 69.3k | obj_conv_table_size (abfd) = | 320 | 69.3k | internal_f->f_nsyms; | 321 | | | 322 | 69.3k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 69.3k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 18.1k | pe->dll = 1; | 326 | | | 327 | 69.3k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 51.8k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 69.3k | #ifdef COFF_IMAGE_WITH_PE | 331 | 69.3k | if (aouthdr) | 332 | 26.3k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 69.3k | #endif | 334 | | | 335 | 69.3k | #ifdef ARM | 336 | 69.3k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | 0 | coff_data (abfd) ->flags = 0; | 338 | 69.3k | #endif | 339 | | | 340 | 69.3k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 69.3k | sizeof (pe->dos_message)); | 342 | | | 343 | 69.3k | return (void *) pe; | 344 | 69.3k | } |
pei-arm.c:pe_mkobject_hook Line | Count | Source | 296 | 88.0k | { | 297 | 88.0k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 88.0k | pe_data_type *pe; | 299 | | | 300 | 88.0k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 88.0k | pe = pe_data (abfd); | 304 | 88.0k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 88.0k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 88.0k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 88.0k | pe->coff.local_n_tmask = N_TMASK; | 311 | 88.0k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 88.0k | pe->coff.local_symesz = SYMESZ; | 313 | 88.0k | pe->coff.local_auxesz = AUXESZ; | 314 | 88.0k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 88.0k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 88.0k | obj_raw_syment_count (abfd) = | 319 | 88.0k | obj_conv_table_size (abfd) = | 320 | 88.0k | internal_f->f_nsyms; | 321 | | | 322 | 88.0k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 88.0k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 25.3k | pe->dll = 1; | 326 | | | 327 | 88.0k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 65.4k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 88.0k | #ifdef COFF_IMAGE_WITH_PE | 331 | 88.0k | if (aouthdr) | 332 | 40.6k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 88.0k | #endif | 334 | | | 335 | 88.0k | #ifdef ARM | 336 | 88.0k | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | 0 | coff_data (abfd) ->flags = 0; | 338 | 88.0k | #endif | 339 | | | 340 | 88.0k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 88.0k | sizeof (pe->dos_message)); | 342 | | | 343 | 88.0k | return (void *) pe; | 344 | 88.0k | } |
pei-mcore.c:pe_mkobject_hook Line | Count | Source | 296 | 62.9k | { | 297 | 62.9k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 62.9k | pe_data_type *pe; | 299 | | | 300 | 62.9k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 62.9k | pe = pe_data (abfd); | 304 | 62.9k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 62.9k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 62.9k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 62.9k | pe->coff.local_n_tmask = N_TMASK; | 311 | 62.9k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 62.9k | pe->coff.local_symesz = SYMESZ; | 313 | 62.9k | pe->coff.local_auxesz = AUXESZ; | 314 | 62.9k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 62.9k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 62.9k | obj_raw_syment_count (abfd) = | 319 | 62.9k | obj_conv_table_size (abfd) = | 320 | 62.9k | internal_f->f_nsyms; | 321 | | | 322 | 62.9k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 62.9k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 15.3k | pe->dll = 1; | 326 | | | 327 | 62.9k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 46.7k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 62.9k | #ifdef COFF_IMAGE_WITH_PE | 331 | 62.9k | if (aouthdr) | 332 | 45.3k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 62.9k | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 62.9k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 62.9k | sizeof (pe->dos_message)); | 342 | | | 343 | 62.9k | return (void *) pe; | 344 | 62.9k | } |
pei-sh.c:pe_mkobject_hook Line | Count | Source | 296 | 63.6k | { | 297 | 63.6k | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | 298 | 63.6k | pe_data_type *pe; | 299 | | | 300 | 63.6k | if (! pe_mkobject (abfd)) | 301 | 0 | return NULL; | 302 | | | 303 | 63.6k | pe = pe_data (abfd); | 304 | 63.6k | pe->coff.sym_filepos = internal_f->f_symptr; | 305 | | /* These members communicate important constants about the symbol | 306 | | table to GDB's symbol-reading code. These `constants' | 307 | | unfortunately vary among coff implementations... */ | 308 | 63.6k | pe->coff.local_n_btmask = N_BTMASK; | 309 | 63.6k | pe->coff.local_n_btshft = N_BTSHFT; | 310 | 63.6k | pe->coff.local_n_tmask = N_TMASK; | 311 | 63.6k | pe->coff.local_n_tshift = N_TSHIFT; | 312 | 63.6k | pe->coff.local_symesz = SYMESZ; | 313 | 63.6k | pe->coff.local_auxesz = AUXESZ; | 314 | 63.6k | pe->coff.local_linesz = LINESZ; | 315 | | | 316 | 63.6k | pe->coff.timestamp = internal_f->f_timdat; | 317 | | | 318 | 63.6k | obj_raw_syment_count (abfd) = | 319 | 63.6k | obj_conv_table_size (abfd) = | 320 | 63.6k | internal_f->f_nsyms; | 321 | | | 322 | 63.6k | pe->real_flags = internal_f->f_flags; | 323 | | | 324 | 63.6k | if ((internal_f->f_flags & F_DLL) != 0) | 325 | 16.9k | pe->dll = 1; | 326 | | | 327 | 63.6k | if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) | 328 | 48.7k | abfd->flags |= HAS_DEBUG; | 329 | | | 330 | 63.6k | #ifdef COFF_IMAGE_WITH_PE | 331 | 63.6k | if (aouthdr) | 332 | 42.9k | pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe; | 333 | 63.6k | #endif | 334 | | | 335 | | #ifdef ARM | 336 | | if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) | 337 | | coff_data (abfd) ->flags = 0; | 338 | | #endif | 339 | | | 340 | 63.6k | memcpy (pe->dos_message, internal_f->pe.dos_message, | 341 | 63.6k | sizeof (pe->dos_message)); | 342 | | | 343 | 63.6k | return (void *) pe; | 344 | 63.6k | } |
|
345 | | |
346 | | static bool |
347 | | pe_print_private_bfd_data (bfd *abfd, void * vfile) |
348 | 4.17k | { |
349 | 4.17k | FILE *file = (FILE *) vfile; |
350 | | |
351 | 4.17k | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) |
352 | 0 | return false; |
353 | | |
354 | 4.17k | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) |
355 | 3.92k | return true; |
356 | | |
357 | 253 | fputc ('\n', file); |
358 | | |
359 | 253 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); |
360 | 4.17k | } pei-i386.c:pe_print_private_bfd_data Line | Count | Source | 348 | 240 | { | 349 | 240 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 240 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 240 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 240 | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 240 | } |
pe-x86_64.c:pe_print_private_bfd_data Line | Count | Source | 348 | 224 | { | 349 | 224 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 224 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 224 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 224 | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 224 | } |
pei-x86_64.c:pe_print_private_bfd_data Line | Count | Source | 348 | 286 | { | 349 | 286 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 286 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 286 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 286 | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 286 | } |
pe-aarch64.c:pe_print_private_bfd_data Line | Count | Source | 348 | 1.09k | { | 349 | 1.09k | FILE *file = (FILE *) vfile; | 350 | | | 351 | 1.09k | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 1.09k | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 1.09k | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 1.09k | } |
pei-aarch64.c:pe_print_private_bfd_data Line | Count | Source | 348 | 923 | { | 349 | 923 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 923 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 923 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 923 | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 923 | } |
pei-ia64.c:pe_print_private_bfd_data Line | Count | Source | 348 | 206 | { | 349 | 206 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 206 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 206 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 206 | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 206 | } |
pei-loongarch64.c:pe_print_private_bfd_data Line | Count | Source | 348 | 214 | { | 349 | 214 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 214 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 214 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 214 | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 214 | } |
pei-riscv64.c:pe_print_private_bfd_data Line | Count | Source | 348 | 144 | { | 349 | 144 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 144 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 144 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 144 | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 144 | } |
Unexecuted instantiation: pe-arm-wince.c:pe_print_private_bfd_data Unexecuted instantiation: pe-arm.c:pe_print_private_bfd_data pe-i386.c:pe_print_private_bfd_data Line | Count | Source | 348 | 112 | { | 349 | 112 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 112 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 112 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 112 | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 112 | } |
pe-mcore.c:pe_print_private_bfd_data Line | Count | Source | 348 | 155 | { | 349 | 155 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 155 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 155 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 155 | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 155 | } |
pe-sh.c:pe_print_private_bfd_data Line | Count | Source | 348 | 91 | { | 349 | 91 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 91 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 91 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 91 | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 91 | } |
pei-arm-wince.c:pe_print_private_bfd_data Line | Count | Source | 348 | 108 | { | 349 | 108 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 108 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 108 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 0 | return true; | 356 | | | 357 | 108 | fputc ('\n', file); | 358 | | | 359 | 108 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 108 | } |
pei-arm.c:pe_print_private_bfd_data Line | Count | Source | 348 | 145 | { | 349 | 145 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 145 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 145 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 0 | return true; | 356 | | | 357 | 145 | fputc ('\n', file); | 358 | | | 359 | 145 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 145 | } |
pei-mcore.c:pe_print_private_bfd_data Line | Count | Source | 348 | 126 | { | 349 | 126 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 126 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 126 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 126 | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 126 | } |
pei-sh.c:pe_print_private_bfd_data Line | Count | Source | 348 | 113 | { | 349 | 113 | FILE *file = (FILE *) vfile; | 350 | | | 351 | 113 | if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile)) | 352 | 0 | return false; | 353 | | | 354 | 113 | if (pe_saved_coff_bfd_print_private_bfd_data == NULL) | 355 | 113 | return true; | 356 | | | 357 | 0 | fputc ('\n', file); | 358 | |
| 359 | 0 | return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile); | 360 | 113 | } |
|
361 | | |
362 | | /* Copy any private info we understand from the input bfd |
363 | | to the output bfd. */ |
364 | | |
365 | | static bool |
366 | | pe_bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd) |
367 | 2 | { |
368 | | /* PR binutils/716: Copy the large address aware flag. |
369 | | XXX: Should we be copying other flags or other fields in the pe_data() |
370 | | structure ? */ |
371 | 2 | if (pe_data (obfd) != NULL |
372 | 2 | && pe_data (ibfd) != NULL |
373 | 2 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) |
374 | 0 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; |
375 | | |
376 | 2 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) |
377 | 0 | return false; |
378 | | |
379 | 2 | if (pe_saved_coff_bfd_copy_private_bfd_data) |
380 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); |
381 | | |
382 | 2 | return true; |
383 | 2 | } Unexecuted instantiation: pei-i386.c:pe_bfd_copy_private_bfd_data pe-x86_64.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 367 | 1 | { | 368 | | /* PR binutils/716: Copy the large address aware flag. | 369 | | XXX: Should we be copying other flags or other fields in the pe_data() | 370 | | structure ? */ | 371 | 1 | if (pe_data (obfd) != NULL | 372 | 1 | && pe_data (ibfd) != NULL | 373 | 1 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 374 | 0 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 375 | | | 376 | 1 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 377 | 0 | return false; | 378 | | | 379 | 1 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 380 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 381 | | | 382 | 1 | return true; | 383 | 1 | } |
pei-x86_64.c:pe_bfd_copy_private_bfd_data Line | Count | Source | 367 | 1 | { | 368 | | /* PR binutils/716: Copy the large address aware flag. | 369 | | XXX: Should we be copying other flags or other fields in the pe_data() | 370 | | structure ? */ | 371 | 1 | if (pe_data (obfd) != NULL | 372 | 1 | && pe_data (ibfd) != NULL | 373 | 1 | && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE) | 374 | 0 | pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE; | 375 | | | 376 | 1 | if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)) | 377 | 0 | return false; | 378 | | | 379 | 1 | if (pe_saved_coff_bfd_copy_private_bfd_data) | 380 | 0 | return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd); | 381 | | | 382 | 1 | return true; | 383 | 1 | } |
Unexecuted instantiation: pe-aarch64.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-aarch64.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-ia64.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-loongarch64.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-riscv64.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pe-arm-wince.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pe-arm.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pe-i386.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pe-mcore.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pe-sh.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-arm-wince.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-arm.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-mcore.c:pe_bfd_copy_private_bfd_data Unexecuted instantiation: pei-sh.c:pe_bfd_copy_private_bfd_data |
384 | | |
385 | | #define coff_bfd_copy_private_section_data \ |
386 | | _bfd_XX_bfd_copy_private_section_data |
387 | | |
388 | | #define coff_get_symbol_info _bfd_XX_get_symbol_info |
389 | | |
390 | | #ifdef COFF_IMAGE_WITH_PE |
391 | | |
392 | | /* Code to handle Microsoft's Import Library Format. |
393 | | Also known as LINK6 format. |
394 | | Documentation about this format can be found at: |
395 | | |
396 | | https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#import-library-format */ |
397 | | |
398 | | /* The following constants specify the sizes of the various data |
399 | | structures that we have to create in order to build a bfd describing |
400 | | an ILF object file. The final "+ 1" in the definitions of SIZEOF_IDATA6 |
401 | | and SIZEOF_IDATA7 below is to allow for the possibility that we might |
402 | | need a padding byte in order to ensure 16 bit alignment for the section's |
403 | | contents. |
404 | | |
405 | | The value for SIZEOF_ILF_STRINGS is computed as follows: |
406 | | |
407 | | There will be NUM_ILF_SECTIONS section symbols. Allow 9 characters |
408 | | per symbol for their names (longest section name is .idata$x). |
409 | | |
410 | | There will be two symbols for the imported value, one the symbol name |
411 | | and one with _imp__ prefixed. Allowing for the terminating nul's this |
412 | | is strlen (symbol_name) * 2 + 8 + 21 + strlen (source_dll). |
413 | | |
414 | | The strings in the string table must start STRING__SIZE_SIZE bytes into |
415 | | the table in order to for the string lookup code in coffgen/coffcode to |
416 | | work. */ |
417 | 130k | #define NUM_ILF_RELOCS 8 |
418 | 433k | #define NUM_ILF_SECTIONS 6 |
419 | 325k | #define NUM_ILF_SYMS (2 + NUM_ILF_SECTIONS) |
420 | | |
421 | 65.0k | #define SIZEOF_ILF_SYMS (NUM_ILF_SYMS * sizeof (* vars.sym_cache)) |
422 | 65.0k | #define SIZEOF_ILF_SYM_TABLE (NUM_ILF_SYMS * sizeof (* vars.sym_table)) |
423 | 65.0k | #define SIZEOF_ILF_NATIVE_SYMS (NUM_ILF_SYMS * sizeof (* vars.native_syms)) |
424 | 65.0k | #define SIZEOF_ILF_SYM_PTR_TABLE (NUM_ILF_SYMS * sizeof (* vars.sym_ptr_table)) |
425 | 65.0k | #define SIZEOF_ILF_EXT_SYMS (NUM_ILF_SYMS * sizeof (* vars.esym_table)) |
426 | 65.0k | #define SIZEOF_ILF_RELOCS (NUM_ILF_RELOCS * sizeof (* vars.reltab)) |
427 | 65.0k | #define SIZEOF_ILF_INT_RELOCS (NUM_ILF_RELOCS * sizeof (* vars.int_reltab)) |
428 | 65.0k | #define SIZEOF_ILF_STRINGS (strlen (symbol_name) * 2 + 8 \ |
429 | 65.0k | + 21 + strlen (source_dll) \ |
430 | 65.0k | + NUM_ILF_SECTIONS * 9 \ |
431 | 65.0k | + STRING_SIZE_SIZE) |
432 | 43.3k | #define SIZEOF_IDATA2 (5 * 4) |
433 | | |
434 | | /* For PEx64 idata4 & 5 have thumb size of 8 bytes. */ |
435 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) |
436 | 23.1k | #define SIZEOF_IDATA4 (2 * 4) |
437 | 23.1k | #define SIZEOF_IDATA5 (2 * 4) |
438 | | #else |
439 | 41.9k | #define SIZEOF_IDATA4 (1 * 4) |
440 | 41.9k | #define SIZEOF_IDATA5 (1 * 4) |
441 | | #endif |
442 | | |
443 | 56.8k | #define SIZEOF_IDATA6 (2 + strlen (symbol_name) + 1 + 1) |
444 | 43.3k | #define SIZEOF_IDATA7 (strlen (source_dll) + 1 + 1) |
445 | 43.3k | #define SIZEOF_ILF_SECTIONS (NUM_ILF_SECTIONS * sizeof (struct coff_section_tdata)) |
446 | | |
447 | | #define ILF_DATA_SIZE \ |
448 | 43.3k | + SIZEOF_ILF_SYMS \ |
449 | 43.3k | + SIZEOF_ILF_SYM_TABLE \ |
450 | 43.3k | + SIZEOF_ILF_NATIVE_SYMS \ |
451 | 43.3k | + SIZEOF_ILF_SYM_PTR_TABLE \ |
452 | 43.3k | + SIZEOF_ILF_EXT_SYMS \ |
453 | 43.3k | + SIZEOF_ILF_RELOCS \ |
454 | 43.3k | + SIZEOF_ILF_INT_RELOCS \ |
455 | 43.3k | + SIZEOF_ILF_STRINGS \ |
456 | 43.3k | + SIZEOF_IDATA2 \ |
457 | 43.3k | + SIZEOF_IDATA4 \ |
458 | 43.3k | + SIZEOF_IDATA5 \ |
459 | 43.3k | + SIZEOF_IDATA6 \ |
460 | 43.3k | + SIZEOF_IDATA7 \ |
461 | 43.3k | + SIZEOF_ILF_SECTIONS \ |
462 | 43.3k | + MAX_TEXT_SECTION_SIZE |
463 | | |
464 | | /* Create an empty relocation against the given symbol. */ |
465 | | |
466 | | static void |
467 | | pe_ILF_make_a_symbol_reloc (pe_ILF_vars * vars, |
468 | | bfd_vma address, |
469 | | bfd_reloc_code_real_type reloc, |
470 | | struct bfd_symbol ** sym, |
471 | | unsigned int sym_index) |
472 | 38.8k | { |
473 | 38.8k | arelent * entry; |
474 | 38.8k | struct internal_reloc * internal; |
475 | | |
476 | 38.8k | entry = vars->reltab + vars->relcount; |
477 | 38.8k | internal = vars->int_reltab + vars->relcount; |
478 | | |
479 | 38.8k | entry->address = address; |
480 | 38.8k | entry->addend = 0; |
481 | 38.8k | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); |
482 | 38.8k | entry->sym_ptr_ptr = sym; |
483 | | |
484 | 38.8k | internal->r_vaddr = address; |
485 | 38.8k | internal->r_symndx = sym_index; |
486 | 38.8k | internal->r_type = entry->howto ? entry->howto->type : 0; |
487 | | |
488 | 38.8k | vars->relcount ++; |
489 | | |
490 | 38.8k | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); |
491 | 38.8k | } pei-i386.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 472 | 7.77k | { | 473 | 7.77k | arelent * entry; | 474 | 7.77k | struct internal_reloc * internal; | 475 | | | 476 | 7.77k | entry = vars->reltab + vars->relcount; | 477 | 7.77k | internal = vars->int_reltab + vars->relcount; | 478 | | | 479 | 7.77k | entry->address = address; | 480 | 7.77k | entry->addend = 0; | 481 | 7.77k | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 482 | 7.77k | entry->sym_ptr_ptr = sym; | 483 | | | 484 | 7.77k | internal->r_vaddr = address; | 485 | 7.77k | internal->r_symndx = sym_index; | 486 | 7.77k | internal->r_type = entry->howto ? entry->howto->type : 0; | 487 | | | 488 | 7.77k | vars->relcount ++; | 489 | | | 490 | 7.77k | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 491 | 7.77k | } |
pei-x86_64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 472 | 6.30k | { | 473 | 6.30k | arelent * entry; | 474 | 6.30k | struct internal_reloc * internal; | 475 | | | 476 | 6.30k | entry = vars->reltab + vars->relcount; | 477 | 6.30k | internal = vars->int_reltab + vars->relcount; | 478 | | | 479 | 6.30k | entry->address = address; | 480 | 6.30k | entry->addend = 0; | 481 | 6.30k | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 482 | 6.30k | entry->sym_ptr_ptr = sym; | 483 | | | 484 | 6.30k | internal->r_vaddr = address; | 485 | 6.30k | internal->r_symndx = sym_index; | 486 | 6.30k | internal->r_type = entry->howto ? entry->howto->type : 0; | 487 | | | 488 | 6.30k | vars->relcount ++; | 489 | | | 490 | 6.30k | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 491 | 6.30k | } |
pei-aarch64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 472 | 6.42k | { | 473 | 6.42k | arelent * entry; | 474 | 6.42k | struct internal_reloc * internal; | 475 | | | 476 | 6.42k | entry = vars->reltab + vars->relcount; | 477 | 6.42k | internal = vars->int_reltab + vars->relcount; | 478 | | | 479 | 6.42k | entry->address = address; | 480 | 6.42k | entry->addend = 0; | 481 | 6.42k | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 482 | 6.42k | entry->sym_ptr_ptr = sym; | 483 | | | 484 | 6.42k | internal->r_vaddr = address; | 485 | 6.42k | internal->r_symndx = sym_index; | 486 | 6.42k | internal->r_type = entry->howto ? entry->howto->type : 0; | 487 | | | 488 | 6.42k | vars->relcount ++; | 489 | | | 490 | 6.42k | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 491 | 6.42k | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_symbol_reloc pei-loongarch64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 472 | 2.67k | { | 473 | 2.67k | arelent * entry; | 474 | 2.67k | struct internal_reloc * internal; | 475 | | | 476 | 2.67k | entry = vars->reltab + vars->relcount; | 477 | 2.67k | internal = vars->int_reltab + vars->relcount; | 478 | | | 479 | 2.67k | entry->address = address; | 480 | 2.67k | entry->addend = 0; | 481 | 2.67k | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 482 | 2.67k | entry->sym_ptr_ptr = sym; | 483 | | | 484 | 2.67k | internal->r_vaddr = address; | 485 | 2.67k | internal->r_symndx = sym_index; | 486 | 2.67k | internal->r_type = entry->howto ? entry->howto->type : 0; | 487 | | | 488 | 2.67k | vars->relcount ++; | 489 | | | 490 | 2.67k | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 491 | 2.67k | } |
pei-riscv64.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 472 | 990 | { | 473 | 990 | arelent * entry; | 474 | 990 | struct internal_reloc * internal; | 475 | | | 476 | 990 | entry = vars->reltab + vars->relcount; | 477 | 990 | internal = vars->int_reltab + vars->relcount; | 478 | | | 479 | 990 | entry->address = address; | 480 | 990 | entry->addend = 0; | 481 | 990 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 482 | 990 | entry->sym_ptr_ptr = sym; | 483 | | | 484 | 990 | internal->r_vaddr = address; | 485 | 990 | internal->r_symndx = sym_index; | 486 | 990 | internal->r_type = entry->howto ? entry->howto->type : 0; | 487 | | | 488 | 990 | vars->relcount ++; | 489 | | | 490 | 990 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 491 | 990 | } |
pei-arm-wince.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 472 | 134 | { | 473 | 134 | arelent * entry; | 474 | 134 | struct internal_reloc * internal; | 475 | | | 476 | 134 | entry = vars->reltab + vars->relcount; | 477 | 134 | internal = vars->int_reltab + vars->relcount; | 478 | | | 479 | 134 | entry->address = address; | 480 | 134 | entry->addend = 0; | 481 | 134 | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 482 | 134 | entry->sym_ptr_ptr = sym; | 483 | | | 484 | 134 | internal->r_vaddr = address; | 485 | 134 | internal->r_symndx = sym_index; | 486 | 134 | internal->r_type = entry->howto ? entry->howto->type : 0; | 487 | | | 488 | 134 | vars->relcount ++; | 489 | | | 490 | 134 | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 491 | 134 | } |
pei-arm.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 472 | 8.68k | { | 473 | 8.68k | arelent * entry; | 474 | 8.68k | struct internal_reloc * internal; | 475 | | | 476 | 8.68k | entry = vars->reltab + vars->relcount; | 477 | 8.68k | internal = vars->int_reltab + vars->relcount; | 478 | | | 479 | 8.68k | entry->address = address; | 480 | 8.68k | entry->addend = 0; | 481 | 8.68k | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 482 | 8.68k | entry->sym_ptr_ptr = sym; | 483 | | | 484 | 8.68k | internal->r_vaddr = address; | 485 | 8.68k | internal->r_symndx = sym_index; | 486 | 8.68k | internal->r_type = entry->howto ? entry->howto->type : 0; | 487 | | | 488 | 8.68k | vars->relcount ++; | 489 | | | 490 | 8.68k | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 491 | 8.68k | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_symbol_reloc pei-sh.c:pe_ILF_make_a_symbol_reloc Line | Count | Source | 472 | 5.90k | { | 473 | 5.90k | arelent * entry; | 474 | 5.90k | struct internal_reloc * internal; | 475 | | | 476 | 5.90k | entry = vars->reltab + vars->relcount; | 477 | 5.90k | internal = vars->int_reltab + vars->relcount; | 478 | | | 479 | 5.90k | entry->address = address; | 480 | 5.90k | entry->addend = 0; | 481 | 5.90k | entry->howto = bfd_reloc_type_lookup (vars->abfd, reloc); | 482 | 5.90k | entry->sym_ptr_ptr = sym; | 483 | | | 484 | 5.90k | internal->r_vaddr = address; | 485 | 5.90k | internal->r_symndx = sym_index; | 486 | 5.90k | internal->r_type = entry->howto ? entry->howto->type : 0; | 487 | | | 488 | 5.90k | vars->relcount ++; | 489 | | | 490 | 5.90k | BFD_ASSERT (vars->relcount <= NUM_ILF_RELOCS); | 491 | 5.90k | } |
|
492 | | |
493 | | /* Create an empty relocation against the given section. */ |
494 | | |
495 | | static void |
496 | | pe_ILF_make_a_reloc (pe_ILF_vars * vars, |
497 | | bfd_vma address, |
498 | | bfd_reloc_code_real_type reloc, |
499 | | asection_ptr sec) |
500 | 26.9k | { |
501 | 26.9k | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, |
502 | 26.9k | coff_section_data (vars->abfd, sec)->i); |
503 | 26.9k | } pei-i386.c:pe_ILF_make_a_reloc Line | Count | Source | 500 | 4.91k | { | 501 | 4.91k | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 502 | 4.91k | coff_section_data (vars->abfd, sec)->i); | 503 | 4.91k | } |
pei-x86_64.c:pe_ILF_make_a_reloc Line | Count | Source | 500 | 4.18k | { | 501 | 4.18k | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 502 | 4.18k | coff_section_data (vars->abfd, sec)->i); | 503 | 4.18k | } |
pei-aarch64.c:pe_ILF_make_a_reloc Line | Count | Source | 500 | 4.84k | { | 501 | 4.84k | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 502 | 4.84k | coff_section_data (vars->abfd, sec)->i); | 503 | 4.84k | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_reloc pei-loongarch64.c:pe_ILF_make_a_reloc Line | Count | Source | 500 | 2.07k | { | 501 | 2.07k | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 502 | 2.07k | coff_section_data (vars->abfd, sec)->i); | 503 | 2.07k | } |
pei-riscv64.c:pe_ILF_make_a_reloc Line | Count | Source | 500 | 736 | { | 501 | 736 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 502 | 736 | coff_section_data (vars->abfd, sec)->i); | 503 | 736 | } |
pei-arm-wince.c:pe_ILF_make_a_reloc Line | Count | Source | 500 | 92 | { | 501 | 92 | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 502 | 92 | coff_section_data (vars->abfd, sec)->i); | 503 | 92 | } |
pei-arm.c:pe_ILF_make_a_reloc Line | Count | Source | 500 | 5.25k | { | 501 | 5.25k | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 502 | 5.25k | coff_section_data (vars->abfd, sec)->i); | 503 | 5.25k | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_reloc pei-sh.c:pe_ILF_make_a_reloc Line | Count | Source | 500 | 4.80k | { | 501 | 4.80k | pe_ILF_make_a_symbol_reloc (vars, address, reloc, sec->symbol_ptr_ptr, | 502 | 4.80k | coff_section_data (vars->abfd, sec)->i); | 503 | 4.80k | } |
|
504 | | |
505 | | /* Move the queued relocs into the given section. */ |
506 | | |
507 | | static void |
508 | | pe_ILF_save_relocs (pe_ILF_vars * vars, |
509 | | asection_ptr sec) |
510 | 38.8k | { |
511 | | /* Make sure that there is somewhere to store the internal relocs. */ |
512 | 38.8k | if (coff_section_data (vars->abfd, sec) == NULL) |
513 | | /* We should probably return an error indication here. */ |
514 | 0 | abort (); |
515 | | |
516 | 38.8k | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; |
517 | | |
518 | 38.8k | sec->relocation = vars->reltab; |
519 | 38.8k | sec->reloc_count = vars->relcount; |
520 | 38.8k | sec->flags |= SEC_RELOC; |
521 | | |
522 | 38.8k | vars->reltab += vars->relcount; |
523 | 38.8k | vars->int_reltab += vars->relcount; |
524 | 38.8k | vars->relcount = 0; |
525 | | |
526 | 38.8k | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); |
527 | 38.8k | } pei-i386.c:pe_ILF_save_relocs Line | Count | Source | 510 | 7.77k | { | 511 | | /* Make sure that there is somewhere to store the internal relocs. */ | 512 | 7.77k | if (coff_section_data (vars->abfd, sec) == NULL) | 513 | | /* We should probably return an error indication here. */ | 514 | 0 | abort (); | 515 | | | 516 | 7.77k | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 517 | | | 518 | 7.77k | sec->relocation = vars->reltab; | 519 | 7.77k | sec->reloc_count = vars->relcount; | 520 | 7.77k | sec->flags |= SEC_RELOC; | 521 | | | 522 | 7.77k | vars->reltab += vars->relcount; | 523 | 7.77k | vars->int_reltab += vars->relcount; | 524 | 7.77k | vars->relcount = 0; | 525 | | | 526 | 7.77k | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 527 | 7.77k | } |
pei-x86_64.c:pe_ILF_save_relocs Line | Count | Source | 510 | 6.30k | { | 511 | | /* Make sure that there is somewhere to store the internal relocs. */ | 512 | 6.30k | if (coff_section_data (vars->abfd, sec) == NULL) | 513 | | /* We should probably return an error indication here. */ | 514 | 0 | abort (); | 515 | | | 516 | 6.30k | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 517 | | | 518 | 6.30k | sec->relocation = vars->reltab; | 519 | 6.30k | sec->reloc_count = vars->relcount; | 520 | 6.30k | sec->flags |= SEC_RELOC; | 521 | | | 522 | 6.30k | vars->reltab += vars->relcount; | 523 | 6.30k | vars->int_reltab += vars->relcount; | 524 | 6.30k | vars->relcount = 0; | 525 | | | 526 | 6.30k | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 527 | 6.30k | } |
pei-aarch64.c:pe_ILF_save_relocs Line | Count | Source | 510 | 6.42k | { | 511 | | /* Make sure that there is somewhere to store the internal relocs. */ | 512 | 6.42k | if (coff_section_data (vars->abfd, sec) == NULL) | 513 | | /* We should probably return an error indication here. */ | 514 | 0 | abort (); | 515 | | | 516 | 6.42k | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 517 | | | 518 | 6.42k | sec->relocation = vars->reltab; | 519 | 6.42k | sec->reloc_count = vars->relcount; | 520 | 6.42k | sec->flags |= SEC_RELOC; | 521 | | | 522 | 6.42k | vars->reltab += vars->relcount; | 523 | 6.42k | vars->int_reltab += vars->relcount; | 524 | 6.42k | vars->relcount = 0; | 525 | | | 526 | 6.42k | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 527 | 6.42k | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_save_relocs pei-loongarch64.c:pe_ILF_save_relocs Line | Count | Source | 510 | 2.67k | { | 511 | | /* Make sure that there is somewhere to store the internal relocs. */ | 512 | 2.67k | if (coff_section_data (vars->abfd, sec) == NULL) | 513 | | /* We should probably return an error indication here. */ | 514 | 0 | abort (); | 515 | | | 516 | 2.67k | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 517 | | | 518 | 2.67k | sec->relocation = vars->reltab; | 519 | 2.67k | sec->reloc_count = vars->relcount; | 520 | 2.67k | sec->flags |= SEC_RELOC; | 521 | | | 522 | 2.67k | vars->reltab += vars->relcount; | 523 | 2.67k | vars->int_reltab += vars->relcount; | 524 | 2.67k | vars->relcount = 0; | 525 | | | 526 | 2.67k | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 527 | 2.67k | } |
pei-riscv64.c:pe_ILF_save_relocs Line | Count | Source | 510 | 990 | { | 511 | | /* Make sure that there is somewhere to store the internal relocs. */ | 512 | 990 | if (coff_section_data (vars->abfd, sec) == NULL) | 513 | | /* We should probably return an error indication here. */ | 514 | 0 | abort (); | 515 | | | 516 | 990 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 517 | | | 518 | 990 | sec->relocation = vars->reltab; | 519 | 990 | sec->reloc_count = vars->relcount; | 520 | 990 | sec->flags |= SEC_RELOC; | 521 | | | 522 | 990 | vars->reltab += vars->relcount; | 523 | 990 | vars->int_reltab += vars->relcount; | 524 | 990 | vars->relcount = 0; | 525 | | | 526 | 990 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 527 | 990 | } |
pei-arm-wince.c:pe_ILF_save_relocs Line | Count | Source | 510 | 134 | { | 511 | | /* Make sure that there is somewhere to store the internal relocs. */ | 512 | 134 | if (coff_section_data (vars->abfd, sec) == NULL) | 513 | | /* We should probably return an error indication here. */ | 514 | 0 | abort (); | 515 | | | 516 | 134 | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 517 | | | 518 | 134 | sec->relocation = vars->reltab; | 519 | 134 | sec->reloc_count = vars->relcount; | 520 | 134 | sec->flags |= SEC_RELOC; | 521 | | | 522 | 134 | vars->reltab += vars->relcount; | 523 | 134 | vars->int_reltab += vars->relcount; | 524 | 134 | vars->relcount = 0; | 525 | | | 526 | 134 | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 527 | 134 | } |
pei-arm.c:pe_ILF_save_relocs Line | Count | Source | 510 | 8.68k | { | 511 | | /* Make sure that there is somewhere to store the internal relocs. */ | 512 | 8.68k | if (coff_section_data (vars->abfd, sec) == NULL) | 513 | | /* We should probably return an error indication here. */ | 514 | 0 | abort (); | 515 | | | 516 | 8.68k | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 517 | | | 518 | 8.68k | sec->relocation = vars->reltab; | 519 | 8.68k | sec->reloc_count = vars->relcount; | 520 | 8.68k | sec->flags |= SEC_RELOC; | 521 | | | 522 | 8.68k | vars->reltab += vars->relcount; | 523 | 8.68k | vars->int_reltab += vars->relcount; | 524 | 8.68k | vars->relcount = 0; | 525 | | | 526 | 8.68k | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 527 | 8.68k | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_save_relocs pei-sh.c:pe_ILF_save_relocs Line | Count | Source | 510 | 5.90k | { | 511 | | /* Make sure that there is somewhere to store the internal relocs. */ | 512 | 5.90k | if (coff_section_data (vars->abfd, sec) == NULL) | 513 | | /* We should probably return an error indication here. */ | 514 | 0 | abort (); | 515 | | | 516 | 5.90k | coff_section_data (vars->abfd, sec)->relocs = vars->int_reltab; | 517 | | | 518 | 5.90k | sec->relocation = vars->reltab; | 519 | 5.90k | sec->reloc_count = vars->relcount; | 520 | 5.90k | sec->flags |= SEC_RELOC; | 521 | | | 522 | 5.90k | vars->reltab += vars->relcount; | 523 | 5.90k | vars->int_reltab += vars->relcount; | 524 | 5.90k | vars->relcount = 0; | 525 | | | 526 | 5.90k | BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table); | 527 | 5.90k | } |
|
528 | | |
529 | | /* Create a global symbol and add it to the relevant tables. */ |
530 | | |
531 | | static void |
532 | | pe_ILF_make_a_symbol (pe_ILF_vars * vars, |
533 | | const char * prefix, |
534 | | const char * symbol_name, |
535 | | asection_ptr section, |
536 | | flagword extra_flags) |
537 | 121k | { |
538 | 121k | coff_symbol_type * sym; |
539 | 121k | combined_entry_type * ent; |
540 | 121k | SYMENT * esym; |
541 | 121k | unsigned short sclass; |
542 | | |
543 | 121k | if (extra_flags & BSF_LOCAL) |
544 | 68.8k | sclass = C_STAT; |
545 | 53.1k | else |
546 | 53.1k | sclass = C_EXT; |
547 | | |
548 | | #ifdef THUMBPEMAGIC |
549 | 28.3k | if (vars->magic == THUMBPEMAGIC) |
550 | 5.82k | { |
551 | 5.82k | if (extra_flags & BSF_FUNCTION) |
552 | 506 | sclass = C_THUMBEXTFUNC; |
553 | 5.31k | else if (extra_flags & BSF_LOCAL) |
554 | 3.30k | sclass = C_THUMBSTAT; |
555 | 2.01k | else |
556 | 2.01k | sclass = C_THUMBEXT; |
557 | 5.82k | } |
558 | | #endif |
559 | | |
560 | 121k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); |
561 | | |
562 | 121k | sym = vars->sym_ptr; |
563 | 121k | ent = vars->native_ptr; |
564 | 121k | esym = vars->esym_ptr; |
565 | | |
566 | | /* Copy the symbol's name into the string table. */ |
567 | 121k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); |
568 | | |
569 | 121k | if (section == NULL) |
570 | 20.5k | section = bfd_und_section_ptr; |
571 | | |
572 | | /* Initialise the external symbol. */ |
573 | 121k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, |
574 | 121k | esym->e.e.e_offset); |
575 | 121k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); |
576 | 121k | esym->e_sclass[0] = sclass; |
577 | | |
578 | | /* The following initialisations are unnecessary - the memory is |
579 | | zero initialised. They are just kept here as reminders. */ |
580 | | |
581 | | /* Initialise the internal symbol structure. */ |
582 | 121k | ent->u.syment.n_sclass = sclass; |
583 | 121k | ent->u.syment.n_scnum = section->target_index; |
584 | 121k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; |
585 | 121k | ent->is_sym = true; |
586 | | |
587 | 121k | sym->symbol.the_bfd = vars->abfd; |
588 | 121k | sym->symbol.name = vars->string_ptr; |
589 | 121k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; |
590 | 121k | sym->symbol.section = section; |
591 | 121k | sym->native = ent; |
592 | | |
593 | 121k | * vars->table_ptr = vars->sym_index; |
594 | 121k | * vars->sym_ptr_ptr = sym; |
595 | | |
596 | | /* Adjust pointers for the next symbol. */ |
597 | 121k | vars->sym_index ++; |
598 | 121k | vars->sym_ptr ++; |
599 | 121k | vars->sym_ptr_ptr ++; |
600 | 121k | vars->table_ptr ++; |
601 | 121k | vars->native_ptr ++; |
602 | 121k | vars->esym_ptr ++; |
603 | 121k | vars->string_ptr += len + 1; |
604 | | |
605 | 121k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); |
606 | 121k | } pei-i386.c:pe_ILF_make_a_symbol Line | Count | Source | 537 | 22.6k | { | 538 | 22.6k | coff_symbol_type * sym; | 539 | 22.6k | combined_entry_type * ent; | 540 | 22.6k | SYMENT * esym; | 541 | 22.6k | unsigned short sclass; | 542 | | | 543 | 22.6k | if (extra_flags & BSF_LOCAL) | 544 | 12.7k | sclass = C_STAT; | 545 | 9.90k | else | 546 | 9.90k | sclass = C_EXT; | 547 | | | 548 | | #ifdef THUMBPEMAGIC | 549 | | if (vars->magic == THUMBPEMAGIC) | 550 | | { | 551 | | if (extra_flags & BSF_FUNCTION) | 552 | | sclass = C_THUMBEXTFUNC; | 553 | | else if (extra_flags & BSF_LOCAL) | 554 | | sclass = C_THUMBSTAT; | 555 | | else | 556 | | sclass = C_THUMBEXT; | 557 | | } | 558 | | #endif | 559 | | | 560 | 22.6k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 561 | | | 562 | 22.6k | sym = vars->sym_ptr; | 563 | 22.6k | ent = vars->native_ptr; | 564 | 22.6k | esym = vars->esym_ptr; | 565 | | | 566 | | /* Copy the symbol's name into the string table. */ | 567 | 22.6k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 568 | | | 569 | 22.6k | if (section == NULL) | 570 | 3.52k | section = bfd_und_section_ptr; | 571 | | | 572 | | /* Initialise the external symbol. */ | 573 | 22.6k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 574 | 22.6k | esym->e.e.e_offset); | 575 | 22.6k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 576 | 22.6k | esym->e_sclass[0] = sclass; | 577 | | | 578 | | /* The following initialisations are unnecessary - the memory is | 579 | | zero initialised. They are just kept here as reminders. */ | 580 | | | 581 | | /* Initialise the internal symbol structure. */ | 582 | 22.6k | ent->u.syment.n_sclass = sclass; | 583 | 22.6k | ent->u.syment.n_scnum = section->target_index; | 584 | 22.6k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 585 | 22.6k | ent->is_sym = true; | 586 | | | 587 | 22.6k | sym->symbol.the_bfd = vars->abfd; | 588 | 22.6k | sym->symbol.name = vars->string_ptr; | 589 | 22.6k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 590 | 22.6k | sym->symbol.section = section; | 591 | 22.6k | sym->native = ent; | 592 | | | 593 | 22.6k | * vars->table_ptr = vars->sym_index; | 594 | 22.6k | * vars->sym_ptr_ptr = sym; | 595 | | | 596 | | /* Adjust pointers for the next symbol. */ | 597 | 22.6k | vars->sym_index ++; | 598 | 22.6k | vars->sym_ptr ++; | 599 | 22.6k | vars->sym_ptr_ptr ++; | 600 | 22.6k | vars->table_ptr ++; | 601 | 22.6k | vars->native_ptr ++; | 602 | 22.6k | vars->esym_ptr ++; | 603 | 22.6k | vars->string_ptr += len + 1; | 604 | | | 605 | 22.6k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 606 | 22.6k | } |
pei-x86_64.c:pe_ILF_make_a_symbol Line | Count | Source | 537 | 22.0k | { | 538 | 22.0k | coff_symbol_type * sym; | 539 | 22.0k | combined_entry_type * ent; | 540 | 22.0k | SYMENT * esym; | 541 | 22.0k | unsigned short sclass; | 542 | | | 543 | 22.0k | if (extra_flags & BSF_LOCAL) | 544 | 12.3k | sclass = C_STAT; | 545 | 9.64k | else | 546 | 9.64k | sclass = C_EXT; | 547 | | | 548 | | #ifdef THUMBPEMAGIC | 549 | | if (vars->magic == THUMBPEMAGIC) | 550 | | { | 551 | | if (extra_flags & BSF_FUNCTION) | 552 | | sclass = C_THUMBEXTFUNC; | 553 | | else if (extra_flags & BSF_LOCAL) | 554 | | sclass = C_THUMBSTAT; | 555 | | else | 556 | | sclass = C_THUMBEXT; | 557 | | } | 558 | | #endif | 559 | | | 560 | 22.0k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 561 | | | 562 | 22.0k | sym = vars->sym_ptr; | 563 | 22.0k | ent = vars->native_ptr; | 564 | 22.0k | esym = vars->esym_ptr; | 565 | | | 566 | | /* Copy the symbol's name into the string table. */ | 567 | 22.0k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 568 | | | 569 | 22.0k | if (section == NULL) | 570 | 3.76k | section = bfd_und_section_ptr; | 571 | | | 572 | | /* Initialise the external symbol. */ | 573 | 22.0k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 574 | 22.0k | esym->e.e.e_offset); | 575 | 22.0k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 576 | 22.0k | esym->e_sclass[0] = sclass; | 577 | | | 578 | | /* The following initialisations are unnecessary - the memory is | 579 | | zero initialised. They are just kept here as reminders. */ | 580 | | | 581 | | /* Initialise the internal symbol structure. */ | 582 | 22.0k | ent->u.syment.n_sclass = sclass; | 583 | 22.0k | ent->u.syment.n_scnum = section->target_index; | 584 | 22.0k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 585 | 22.0k | ent->is_sym = true; | 586 | | | 587 | 22.0k | sym->symbol.the_bfd = vars->abfd; | 588 | 22.0k | sym->symbol.name = vars->string_ptr; | 589 | 22.0k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 590 | 22.0k | sym->symbol.section = section; | 591 | 22.0k | sym->native = ent; | 592 | | | 593 | 22.0k | * vars->table_ptr = vars->sym_index; | 594 | 22.0k | * vars->sym_ptr_ptr = sym; | 595 | | | 596 | | /* Adjust pointers for the next symbol. */ | 597 | 22.0k | vars->sym_index ++; | 598 | 22.0k | vars->sym_ptr ++; | 599 | 22.0k | vars->sym_ptr_ptr ++; | 600 | 22.0k | vars->table_ptr ++; | 601 | 22.0k | vars->native_ptr ++; | 602 | 22.0k | vars->esym_ptr ++; | 603 | 22.0k | vars->string_ptr += len + 1; | 604 | | | 605 | 22.0k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 606 | 22.0k | } |
pei-aarch64.c:pe_ILF_make_a_symbol Line | Count | Source | 537 | 19.8k | { | 538 | 19.8k | coff_symbol_type * sym; | 539 | 19.8k | combined_entry_type * ent; | 540 | 19.8k | SYMENT * esym; | 541 | 19.8k | unsigned short sclass; | 542 | | | 543 | 19.8k | if (extra_flags & BSF_LOCAL) | 544 | 11.2k | sclass = C_STAT; | 545 | 8.61k | else | 546 | 8.61k | sclass = C_EXT; | 547 | | | 548 | | #ifdef THUMBPEMAGIC | 549 | | if (vars->magic == THUMBPEMAGIC) | 550 | | { | 551 | | if (extra_flags & BSF_FUNCTION) | 552 | | sclass = C_THUMBEXTFUNC; | 553 | | else if (extra_flags & BSF_LOCAL) | 554 | | sclass = C_THUMBSTAT; | 555 | | else | 556 | | sclass = C_THUMBEXT; | 557 | | } | 558 | | #endif | 559 | | | 560 | 19.8k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 561 | | | 562 | 19.8k | sym = vars->sym_ptr; | 563 | 19.8k | ent = vars->native_ptr; | 564 | 19.8k | esym = vars->esym_ptr; | 565 | | | 566 | | /* Copy the symbol's name into the string table. */ | 567 | 19.8k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 568 | | | 569 | 19.8k | if (section == NULL) | 570 | 3.51k | section = bfd_und_section_ptr; | 571 | | | 572 | | /* Initialise the external symbol. */ | 573 | 19.8k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 574 | 19.8k | esym->e.e.e_offset); | 575 | 19.8k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 576 | 19.8k | esym->e_sclass[0] = sclass; | 577 | | | 578 | | /* The following initialisations are unnecessary - the memory is | 579 | | zero initialised. They are just kept here as reminders. */ | 580 | | | 581 | | /* Initialise the internal symbol structure. */ | 582 | 19.8k | ent->u.syment.n_sclass = sclass; | 583 | 19.8k | ent->u.syment.n_scnum = section->target_index; | 584 | 19.8k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 585 | 19.8k | ent->is_sym = true; | 586 | | | 587 | 19.8k | sym->symbol.the_bfd = vars->abfd; | 588 | 19.8k | sym->symbol.name = vars->string_ptr; | 589 | 19.8k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 590 | 19.8k | sym->symbol.section = section; | 591 | 19.8k | sym->native = ent; | 592 | | | 593 | 19.8k | * vars->table_ptr = vars->sym_index; | 594 | 19.8k | * vars->sym_ptr_ptr = sym; | 595 | | | 596 | | /* Adjust pointers for the next symbol. */ | 597 | 19.8k | vars->sym_index ++; | 598 | 19.8k | vars->sym_ptr ++; | 599 | 19.8k | vars->sym_ptr_ptr ++; | 600 | 19.8k | vars->table_ptr ++; | 601 | 19.8k | vars->native_ptr ++; | 602 | 19.8k | vars->esym_ptr ++; | 603 | 19.8k | vars->string_ptr += len + 1; | 604 | | | 605 | 19.8k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 606 | 19.8k | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_symbol pei-loongarch64.c:pe_ILF_make_a_symbol Line | Count | Source | 537 | 9.67k | { | 538 | 9.67k | coff_symbol_type * sym; | 539 | 9.67k | combined_entry_type * ent; | 540 | 9.67k | SYMENT * esym; | 541 | 9.67k | unsigned short sclass; | 542 | | | 543 | 9.67k | if (extra_flags & BSF_LOCAL) | 544 | 5.47k | sclass = C_STAT; | 545 | 4.20k | else | 546 | 4.20k | sclass = C_EXT; | 547 | | | 548 | | #ifdef THUMBPEMAGIC | 549 | | if (vars->magic == THUMBPEMAGIC) | 550 | | { | 551 | | if (extra_flags & BSF_FUNCTION) | 552 | | sclass = C_THUMBEXTFUNC; | 553 | | else if (extra_flags & BSF_LOCAL) | 554 | | sclass = C_THUMBSTAT; | 555 | | else | 556 | | sclass = C_THUMBEXT; | 557 | | } | 558 | | #endif | 559 | | | 560 | 9.67k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 561 | | | 562 | 9.67k | sym = vars->sym_ptr; | 563 | 9.67k | ent = vars->native_ptr; | 564 | 9.67k | esym = vars->esym_ptr; | 565 | | | 566 | | /* Copy the symbol's name into the string table. */ | 567 | 9.67k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 568 | | | 569 | 9.67k | if (section == NULL) | 570 | 1.80k | section = bfd_und_section_ptr; | 571 | | | 572 | | /* Initialise the external symbol. */ | 573 | 9.67k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 574 | 9.67k | esym->e.e.e_offset); | 575 | 9.67k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 576 | 9.67k | esym->e_sclass[0] = sclass; | 577 | | | 578 | | /* The following initialisations are unnecessary - the memory is | 579 | | zero initialised. They are just kept here as reminders. */ | 580 | | | 581 | | /* Initialise the internal symbol structure. */ | 582 | 9.67k | ent->u.syment.n_sclass = sclass; | 583 | 9.67k | ent->u.syment.n_scnum = section->target_index; | 584 | 9.67k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 585 | 9.67k | ent->is_sym = true; | 586 | | | 587 | 9.67k | sym->symbol.the_bfd = vars->abfd; | 588 | 9.67k | sym->symbol.name = vars->string_ptr; | 589 | 9.67k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 590 | 9.67k | sym->symbol.section = section; | 591 | 9.67k | sym->native = ent; | 592 | | | 593 | 9.67k | * vars->table_ptr = vars->sym_index; | 594 | 9.67k | * vars->sym_ptr_ptr = sym; | 595 | | | 596 | | /* Adjust pointers for the next symbol. */ | 597 | 9.67k | vars->sym_index ++; | 598 | 9.67k | vars->sym_ptr ++; | 599 | 9.67k | vars->sym_ptr_ptr ++; | 600 | 9.67k | vars->table_ptr ++; | 601 | 9.67k | vars->native_ptr ++; | 602 | 9.67k | vars->esym_ptr ++; | 603 | 9.67k | vars->string_ptr += len + 1; | 604 | | | 605 | 9.67k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 606 | 9.67k | } |
pei-riscv64.c:pe_ILF_make_a_symbol Line | Count | Source | 537 | 3.37k | { | 538 | 3.37k | coff_symbol_type * sym; | 539 | 3.37k | combined_entry_type * ent; | 540 | 3.37k | SYMENT * esym; | 541 | 3.37k | unsigned short sclass; | 542 | | | 543 | 3.37k | if (extra_flags & BSF_LOCAL) | 544 | 1.88k | sclass = C_STAT; | 545 | 1.49k | else | 546 | 1.49k | sclass = C_EXT; | 547 | | | 548 | | #ifdef THUMBPEMAGIC | 549 | | if (vars->magic == THUMBPEMAGIC) | 550 | | { | 551 | | if (extra_flags & BSF_FUNCTION) | 552 | | sclass = C_THUMBEXTFUNC; | 553 | | else if (extra_flags & BSF_LOCAL) | 554 | | sclass = C_THUMBSTAT; | 555 | | else | 556 | | sclass = C_THUMBEXT; | 557 | | } | 558 | | #endif | 559 | | | 560 | 3.37k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 561 | | | 562 | 3.37k | sym = vars->sym_ptr; | 563 | 3.37k | ent = vars->native_ptr; | 564 | 3.37k | esym = vars->esym_ptr; | 565 | | | 566 | | /* Copy the symbol's name into the string table. */ | 567 | 3.37k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 568 | | | 569 | 3.37k | if (section == NULL) | 570 | 619 | section = bfd_und_section_ptr; | 571 | | | 572 | | /* Initialise the external symbol. */ | 573 | 3.37k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 574 | 3.37k | esym->e.e.e_offset); | 575 | 3.37k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 576 | 3.37k | esym->e_sclass[0] = sclass; | 577 | | | 578 | | /* The following initialisations are unnecessary - the memory is | 579 | | zero initialised. They are just kept here as reminders. */ | 580 | | | 581 | | /* Initialise the internal symbol structure. */ | 582 | 3.37k | ent->u.syment.n_sclass = sclass; | 583 | 3.37k | ent->u.syment.n_scnum = section->target_index; | 584 | 3.37k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 585 | 3.37k | ent->is_sym = true; | 586 | | | 587 | 3.37k | sym->symbol.the_bfd = vars->abfd; | 588 | 3.37k | sym->symbol.name = vars->string_ptr; | 589 | 3.37k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 590 | 3.37k | sym->symbol.section = section; | 591 | 3.37k | sym->native = ent; | 592 | | | 593 | 3.37k | * vars->table_ptr = vars->sym_index; | 594 | 3.37k | * vars->sym_ptr_ptr = sym; | 595 | | | 596 | | /* Adjust pointers for the next symbol. */ | 597 | 3.37k | vars->sym_index ++; | 598 | 3.37k | vars->sym_ptr ++; | 599 | 3.37k | vars->sym_ptr_ptr ++; | 600 | 3.37k | vars->table_ptr ++; | 601 | 3.37k | vars->native_ptr ++; | 602 | 3.37k | vars->esym_ptr ++; | 603 | 3.37k | vars->string_ptr += len + 1; | 604 | | | 605 | 3.37k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 606 | 3.37k | } |
pei-arm-wince.c:pe_ILF_make_a_symbol Line | Count | Source | 537 | 636 | { | 538 | 636 | coff_symbol_type * sym; | 539 | 636 | combined_entry_type * ent; | 540 | 636 | SYMENT * esym; | 541 | 636 | unsigned short sclass; | 542 | | | 543 | 636 | if (extra_flags & BSF_LOCAL) | 544 | 458 | sclass = C_STAT; | 545 | 178 | else | 546 | 178 | sclass = C_EXT; | 547 | | | 548 | 636 | #ifdef THUMBPEMAGIC | 549 | 636 | if (vars->magic == THUMBPEMAGIC) | 550 | 154 | { | 551 | 154 | if (extra_flags & BSF_FUNCTION) | 552 | 12 | sclass = C_THUMBEXTFUNC; | 553 | 142 | else if (extra_flags & BSF_LOCAL) | 554 | 92 | sclass = C_THUMBSTAT; | 555 | 50 | else | 556 | 50 | sclass = C_THUMBEXT; | 557 | 154 | } | 558 | 636 | #endif | 559 | | | 560 | 636 | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 561 | | | 562 | 636 | sym = vars->sym_ptr; | 563 | 636 | ent = vars->native_ptr; | 564 | 636 | esym = vars->esym_ptr; | 565 | | | 566 | | /* Copy the symbol's name into the string table. */ | 567 | 636 | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 568 | | | 569 | 636 | if (section == NULL) | 570 | 68 | section = bfd_und_section_ptr; | 571 | | | 572 | | /* Initialise the external symbol. */ | 573 | 636 | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 574 | 636 | esym->e.e.e_offset); | 575 | 636 | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 576 | 636 | esym->e_sclass[0] = sclass; | 577 | | | 578 | | /* The following initialisations are unnecessary - the memory is | 579 | | zero initialised. They are just kept here as reminders. */ | 580 | | | 581 | | /* Initialise the internal symbol structure. */ | 582 | 636 | ent->u.syment.n_sclass = sclass; | 583 | 636 | ent->u.syment.n_scnum = section->target_index; | 584 | 636 | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 585 | 636 | ent->is_sym = true; | 586 | | | 587 | 636 | sym->symbol.the_bfd = vars->abfd; | 588 | 636 | sym->symbol.name = vars->string_ptr; | 589 | 636 | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 590 | 636 | sym->symbol.section = section; | 591 | 636 | sym->native = ent; | 592 | | | 593 | 636 | * vars->table_ptr = vars->sym_index; | 594 | 636 | * vars->sym_ptr_ptr = sym; | 595 | | | 596 | | /* Adjust pointers for the next symbol. */ | 597 | 636 | vars->sym_index ++; | 598 | 636 | vars->sym_ptr ++; | 599 | 636 | vars->sym_ptr_ptr ++; | 600 | 636 | vars->table_ptr ++; | 601 | 636 | vars->native_ptr ++; | 602 | 636 | vars->esym_ptr ++; | 603 | 636 | vars->string_ptr += len + 1; | 604 | | | 605 | 636 | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 606 | 636 | } |
pei-arm.c:pe_ILF_make_a_symbol Line | Count | Source | 537 | 27.7k | { | 538 | 27.7k | coff_symbol_type * sym; | 539 | 27.7k | combined_entry_type * ent; | 540 | 27.7k | SYMENT * esym; | 541 | 27.7k | unsigned short sclass; | 542 | | | 543 | 27.7k | if (extra_flags & BSF_LOCAL) | 544 | 15.3k | sclass = C_STAT; | 545 | 12.4k | else | 546 | 12.4k | sclass = C_EXT; | 547 | | | 548 | 27.7k | #ifdef THUMBPEMAGIC | 549 | 27.7k | if (vars->magic == THUMBPEMAGIC) | 550 | 5.67k | { | 551 | 5.67k | if (extra_flags & BSF_FUNCTION) | 552 | 494 | sclass = C_THUMBEXTFUNC; | 553 | 5.17k | else if (extra_flags & BSF_LOCAL) | 554 | 3.20k | sclass = C_THUMBSTAT; | 555 | 1.96k | else | 556 | 1.96k | sclass = C_THUMBEXT; | 557 | 5.67k | } | 558 | 27.7k | #endif | 559 | | | 560 | 27.7k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 561 | | | 562 | 27.7k | sym = vars->sym_ptr; | 563 | 27.7k | ent = vars->native_ptr; | 564 | 27.7k | esym = vars->esym_ptr; | 565 | | | 566 | | /* Copy the symbol's name into the string table. */ | 567 | 27.7k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 568 | | | 569 | 27.7k | if (section == NULL) | 570 | 4.50k | section = bfd_und_section_ptr; | 571 | | | 572 | | /* Initialise the external symbol. */ | 573 | 27.7k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 574 | 27.7k | esym->e.e.e_offset); | 575 | 27.7k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 576 | 27.7k | esym->e_sclass[0] = sclass; | 577 | | | 578 | | /* The following initialisations are unnecessary - the memory is | 579 | | zero initialised. They are just kept here as reminders. */ | 580 | | | 581 | | /* Initialise the internal symbol structure. */ | 582 | 27.7k | ent->u.syment.n_sclass = sclass; | 583 | 27.7k | ent->u.syment.n_scnum = section->target_index; | 584 | 27.7k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 585 | 27.7k | ent->is_sym = true; | 586 | | | 587 | 27.7k | sym->symbol.the_bfd = vars->abfd; | 588 | 27.7k | sym->symbol.name = vars->string_ptr; | 589 | 27.7k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 590 | 27.7k | sym->symbol.section = section; | 591 | 27.7k | sym->native = ent; | 592 | | | 593 | 27.7k | * vars->table_ptr = vars->sym_index; | 594 | 27.7k | * vars->sym_ptr_ptr = sym; | 595 | | | 596 | | /* Adjust pointers for the next symbol. */ | 597 | 27.7k | vars->sym_index ++; | 598 | 27.7k | vars->sym_ptr ++; | 599 | 27.7k | vars->sym_ptr_ptr ++; | 600 | 27.7k | vars->table_ptr ++; | 601 | 27.7k | vars->native_ptr ++; | 602 | 27.7k | vars->esym_ptr ++; | 603 | 27.7k | vars->string_ptr += len + 1; | 604 | | | 605 | 27.7k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 606 | 27.7k | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_symbol pei-sh.c:pe_ILF_make_a_symbol Line | Count | Source | 537 | 15.9k | { | 538 | 15.9k | coff_symbol_type * sym; | 539 | 15.9k | combined_entry_type * ent; | 540 | 15.9k | SYMENT * esym; | 541 | 15.9k | unsigned short sclass; | 542 | | | 543 | 15.9k | if (extra_flags & BSF_LOCAL) | 544 | 9.29k | sclass = C_STAT; | 545 | 6.64k | else | 546 | 6.64k | sclass = C_EXT; | 547 | | | 548 | | #ifdef THUMBPEMAGIC | 549 | | if (vars->magic == THUMBPEMAGIC) | 550 | | { | 551 | | if (extra_flags & BSF_FUNCTION) | 552 | | sclass = C_THUMBEXTFUNC; | 553 | | else if (extra_flags & BSF_LOCAL) | 554 | | sclass = C_THUMBSTAT; | 555 | | else | 556 | | sclass = C_THUMBEXT; | 557 | | } | 558 | | #endif | 559 | | | 560 | 15.9k | BFD_ASSERT (vars->sym_index < NUM_ILF_SYMS); | 561 | | | 562 | 15.9k | sym = vars->sym_ptr; | 563 | 15.9k | ent = vars->native_ptr; | 564 | 15.9k | esym = vars->esym_ptr; | 565 | | | 566 | | /* Copy the symbol's name into the string table. */ | 567 | 15.9k | int len = sprintf (vars->string_ptr, "%s%s", prefix, symbol_name); | 568 | | | 569 | 15.9k | if (section == NULL) | 570 | 2.77k | section = bfd_und_section_ptr; | 571 | | | 572 | | /* Initialise the external symbol. */ | 573 | 15.9k | H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table, | 574 | 15.9k | esym->e.e.e_offset); | 575 | 15.9k | H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum); | 576 | 15.9k | esym->e_sclass[0] = sclass; | 577 | | | 578 | | /* The following initialisations are unnecessary - the memory is | 579 | | zero initialised. They are just kept here as reminders. */ | 580 | | | 581 | | /* Initialise the internal symbol structure. */ | 582 | 15.9k | ent->u.syment.n_sclass = sclass; | 583 | 15.9k | ent->u.syment.n_scnum = section->target_index; | 584 | 15.9k | ent->u.syment._n._n_n._n_offset = (uintptr_t) sym; | 585 | 15.9k | ent->is_sym = true; | 586 | | | 587 | 15.9k | sym->symbol.the_bfd = vars->abfd; | 588 | 15.9k | sym->symbol.name = vars->string_ptr; | 589 | 15.9k | sym->symbol.flags = BSF_EXPORT | BSF_GLOBAL | extra_flags; | 590 | 15.9k | sym->symbol.section = section; | 591 | 15.9k | sym->native = ent; | 592 | | | 593 | 15.9k | * vars->table_ptr = vars->sym_index; | 594 | 15.9k | * vars->sym_ptr_ptr = sym; | 595 | | | 596 | | /* Adjust pointers for the next symbol. */ | 597 | 15.9k | vars->sym_index ++; | 598 | 15.9k | vars->sym_ptr ++; | 599 | 15.9k | vars->sym_ptr_ptr ++; | 600 | 15.9k | vars->table_ptr ++; | 601 | 15.9k | vars->native_ptr ++; | 602 | 15.9k | vars->esym_ptr ++; | 603 | 15.9k | vars->string_ptr += len + 1; | 604 | | | 605 | 15.9k | BFD_ASSERT (vars->string_ptr < vars->end_string_ptr); | 606 | 15.9k | } |
|
607 | | |
608 | | /* Create a section. */ |
609 | | |
610 | | static asection_ptr |
611 | | pe_ILF_make_a_section (pe_ILF_vars * vars, |
612 | | const char * name, |
613 | | unsigned int size, |
614 | | flagword extra_flags) |
615 | 68.8k | { |
616 | 68.8k | asection_ptr sec; |
617 | 68.8k | flagword flags; |
618 | 68.8k | intptr_t alignment; |
619 | | |
620 | 68.8k | sec = bfd_make_section_old_way (vars->abfd, name); |
621 | 68.8k | if (sec == NULL) |
622 | 0 | return NULL; |
623 | | |
624 | 68.8k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; |
625 | | |
626 | 68.8k | bfd_set_section_flags (sec, flags | extra_flags); |
627 | | |
628 | 68.8k | bfd_set_section_alignment (sec, 2); |
629 | | |
630 | | /* Check that we will not run out of space. */ |
631 | 68.8k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); |
632 | | |
633 | | /* Set the section size and contents. The actual |
634 | | contents are filled in by our parent. */ |
635 | 68.8k | bfd_set_section_size (sec, (bfd_size_type) size); |
636 | 68.8k | sec->contents = vars->data; |
637 | 68.8k | sec->target_index = vars->sec_index ++; |
638 | | |
639 | | /* Advance data pointer in the vars structure. */ |
640 | 68.8k | vars->data += size; |
641 | | |
642 | | /* Skip the padding byte if it was not needed. |
643 | | The logic here is that if the string length is odd, |
644 | | then the entire string length, including the null byte, |
645 | | is even and so the extra, padding byte, is not needed. */ |
646 | 68.8k | if (size & 1) |
647 | 8.80k | vars->data --; |
648 | | |
649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we |
650 | | preserve host alignment requirements. The BFD_ASSERTs in this |
651 | | functions will warn us if we run out of room, but we should |
652 | | already have enough padding built in to ILF_DATA_SIZE. */ |
653 | 68.8k | #if GCC_VERSION >= 3000 |
654 | 68.8k | alignment = __alignof__ (struct coff_section_tdata); |
655 | | #else |
656 | | alignment = 8; |
657 | | #endif |
658 | 68.8k | vars->data |
659 | 68.8k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); |
660 | | |
661 | | /* Create a coff_section_tdata structure for our use. */ |
662 | 68.8k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; |
663 | 68.8k | vars->data += sizeof (struct coff_section_tdata); |
664 | | |
665 | 68.8k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); |
666 | | |
667 | | /* Create a symbol to refer to this section. */ |
668 | 68.8k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); |
669 | | |
670 | | /* Cache the index to the symbol in the coff_section_data structure. */ |
671 | 68.8k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; |
672 | | |
673 | 68.8k | return sec; |
674 | 68.8k | } pei-i386.c:pe_ILF_make_a_section Line | Count | Source | 615 | 12.7k | { | 616 | 12.7k | asection_ptr sec; | 617 | 12.7k | flagword flags; | 618 | 12.7k | intptr_t alignment; | 619 | | | 620 | 12.7k | sec = bfd_make_section_old_way (vars->abfd, name); | 621 | 12.7k | if (sec == NULL) | 622 | 0 | return NULL; | 623 | | | 624 | 12.7k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 625 | | | 626 | 12.7k | bfd_set_section_flags (sec, flags | extra_flags); | 627 | | | 628 | 12.7k | bfd_set_section_alignment (sec, 2); | 629 | | | 630 | | /* Check that we will not run out of space. */ | 631 | 12.7k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 632 | | | 633 | | /* Set the section size and contents. The actual | 634 | | contents are filled in by our parent. */ | 635 | 12.7k | bfd_set_section_size (sec, (bfd_size_type) size); | 636 | 12.7k | sec->contents = vars->data; | 637 | 12.7k | sec->target_index = vars->sec_index ++; | 638 | | | 639 | | /* Advance data pointer in the vars structure. */ | 640 | 12.7k | vars->data += size; | 641 | | | 642 | | /* Skip the padding byte if it was not needed. | 643 | | The logic here is that if the string length is odd, | 644 | | then the entire string length, including the null byte, | 645 | | is even and so the extra, padding byte, is not needed. */ | 646 | 12.7k | if (size & 1) | 647 | 1.86k | vars->data --; | 648 | | | 649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 650 | | preserve host alignment requirements. The BFD_ASSERTs in this | 651 | | functions will warn us if we run out of room, but we should | 652 | | already have enough padding built in to ILF_DATA_SIZE. */ | 653 | 12.7k | #if GCC_VERSION >= 3000 | 654 | 12.7k | alignment = __alignof__ (struct coff_section_tdata); | 655 | | #else | 656 | | alignment = 8; | 657 | | #endif | 658 | 12.7k | vars->data | 659 | 12.7k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 660 | | | 661 | | /* Create a coff_section_tdata structure for our use. */ | 662 | 12.7k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 663 | 12.7k | vars->data += sizeof (struct coff_section_tdata); | 664 | | | 665 | 12.7k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 666 | | | 667 | | /* Create a symbol to refer to this section. */ | 668 | 12.7k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 669 | | | 670 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 671 | 12.7k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 672 | | | 673 | 12.7k | return sec; | 674 | 12.7k | } |
pei-x86_64.c:pe_ILF_make_a_section Line | Count | Source | 615 | 12.3k | { | 616 | 12.3k | asection_ptr sec; | 617 | 12.3k | flagword flags; | 618 | 12.3k | intptr_t alignment; | 619 | | | 620 | 12.3k | sec = bfd_make_section_old_way (vars->abfd, name); | 621 | 12.3k | if (sec == NULL) | 622 | 0 | return NULL; | 623 | | | 624 | 12.3k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 625 | | | 626 | 12.3k | bfd_set_section_flags (sec, flags | extra_flags); | 627 | | | 628 | 12.3k | bfd_set_section_alignment (sec, 2); | 629 | | | 630 | | /* Check that we will not run out of space. */ | 631 | 12.3k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 632 | | | 633 | | /* Set the section size and contents. The actual | 634 | | contents are filled in by our parent. */ | 635 | 12.3k | bfd_set_section_size (sec, (bfd_size_type) size); | 636 | 12.3k | sec->contents = vars->data; | 637 | 12.3k | sec->target_index = vars->sec_index ++; | 638 | | | 639 | | /* Advance data pointer in the vars structure. */ | 640 | 12.3k | vars->data += size; | 641 | | | 642 | | /* Skip the padding byte if it was not needed. | 643 | | The logic here is that if the string length is odd, | 644 | | then the entire string length, including the null byte, | 645 | | is even and so the extra, padding byte, is not needed. */ | 646 | 12.3k | if (size & 1) | 647 | 891 | vars->data --; | 648 | | | 649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 650 | | preserve host alignment requirements. The BFD_ASSERTs in this | 651 | | functions will warn us if we run out of room, but we should | 652 | | already have enough padding built in to ILF_DATA_SIZE. */ | 653 | 12.3k | #if GCC_VERSION >= 3000 | 654 | 12.3k | alignment = __alignof__ (struct coff_section_tdata); | 655 | | #else | 656 | | alignment = 8; | 657 | | #endif | 658 | 12.3k | vars->data | 659 | 12.3k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 660 | | | 661 | | /* Create a coff_section_tdata structure for our use. */ | 662 | 12.3k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 663 | 12.3k | vars->data += sizeof (struct coff_section_tdata); | 664 | | | 665 | 12.3k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 666 | | | 667 | | /* Create a symbol to refer to this section. */ | 668 | 12.3k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 669 | | | 670 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 671 | 12.3k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 672 | | | 673 | 12.3k | return sec; | 674 | 12.3k | } |
pei-aarch64.c:pe_ILF_make_a_section Line | Count | Source | 615 | 11.2k | { | 616 | 11.2k | asection_ptr sec; | 617 | 11.2k | flagword flags; | 618 | 11.2k | intptr_t alignment; | 619 | | | 620 | 11.2k | sec = bfd_make_section_old_way (vars->abfd, name); | 621 | 11.2k | if (sec == NULL) | 622 | 0 | return NULL; | 623 | | | 624 | 11.2k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 625 | | | 626 | 11.2k | bfd_set_section_flags (sec, flags | extra_flags); | 627 | | | 628 | 11.2k | bfd_set_section_alignment (sec, 2); | 629 | | | 630 | | /* Check that we will not run out of space. */ | 631 | 11.2k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 632 | | | 633 | | /* Set the section size and contents. The actual | 634 | | contents are filled in by our parent. */ | 635 | 11.2k | bfd_set_section_size (sec, (bfd_size_type) size); | 636 | 11.2k | sec->contents = vars->data; | 637 | 11.2k | sec->target_index = vars->sec_index ++; | 638 | | | 639 | | /* Advance data pointer in the vars structure. */ | 640 | 11.2k | vars->data += size; | 641 | | | 642 | | /* Skip the padding byte if it was not needed. | 643 | | The logic here is that if the string length is odd, | 644 | | then the entire string length, including the null byte, | 645 | | is even and so the extra, padding byte, is not needed. */ | 646 | 11.2k | if (size & 1) | 647 | 2.17k | vars->data --; | 648 | | | 649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 650 | | preserve host alignment requirements. The BFD_ASSERTs in this | 651 | | functions will warn us if we run out of room, but we should | 652 | | already have enough padding built in to ILF_DATA_SIZE. */ | 653 | 11.2k | #if GCC_VERSION >= 3000 | 654 | 11.2k | alignment = __alignof__ (struct coff_section_tdata); | 655 | | #else | 656 | | alignment = 8; | 657 | | #endif | 658 | 11.2k | vars->data | 659 | 11.2k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 660 | | | 661 | | /* Create a coff_section_tdata structure for our use. */ | 662 | 11.2k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 663 | 11.2k | vars->data += sizeof (struct coff_section_tdata); | 664 | | | 665 | 11.2k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 666 | | | 667 | | /* Create a symbol to refer to this section. */ | 668 | 11.2k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 669 | | | 670 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 671 | 11.2k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 672 | | | 673 | 11.2k | return sec; | 674 | 11.2k | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_make_a_section pei-loongarch64.c:pe_ILF_make_a_section Line | Count | Source | 615 | 5.47k | { | 616 | 5.47k | asection_ptr sec; | 617 | 5.47k | flagword flags; | 618 | 5.47k | intptr_t alignment; | 619 | | | 620 | 5.47k | sec = bfd_make_section_old_way (vars->abfd, name); | 621 | 5.47k | if (sec == NULL) | 622 | 0 | return NULL; | 623 | | | 624 | 5.47k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 625 | | | 626 | 5.47k | bfd_set_section_flags (sec, flags | extra_flags); | 627 | | | 628 | 5.47k | bfd_set_section_alignment (sec, 2); | 629 | | | 630 | | /* Check that we will not run out of space. */ | 631 | 5.47k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 632 | | | 633 | | /* Set the section size and contents. The actual | 634 | | contents are filled in by our parent. */ | 635 | 5.47k | bfd_set_section_size (sec, (bfd_size_type) size); | 636 | 5.47k | sec->contents = vars->data; | 637 | 5.47k | sec->target_index = vars->sec_index ++; | 638 | | | 639 | | /* Advance data pointer in the vars structure. */ | 640 | 5.47k | vars->data += size; | 641 | | | 642 | | /* Skip the padding byte if it was not needed. | 643 | | The logic here is that if the string length is odd, | 644 | | then the entire string length, including the null byte, | 645 | | is even and so the extra, padding byte, is not needed. */ | 646 | 5.47k | if (size & 1) | 647 | 382 | vars->data --; | 648 | | | 649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 650 | | preserve host alignment requirements. The BFD_ASSERTs in this | 651 | | functions will warn us if we run out of room, but we should | 652 | | already have enough padding built in to ILF_DATA_SIZE. */ | 653 | 5.47k | #if GCC_VERSION >= 3000 | 654 | 5.47k | alignment = __alignof__ (struct coff_section_tdata); | 655 | | #else | 656 | | alignment = 8; | 657 | | #endif | 658 | 5.47k | vars->data | 659 | 5.47k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 660 | | | 661 | | /* Create a coff_section_tdata structure for our use. */ | 662 | 5.47k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 663 | 5.47k | vars->data += sizeof (struct coff_section_tdata); | 664 | | | 665 | 5.47k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 666 | | | 667 | | /* Create a symbol to refer to this section. */ | 668 | 5.47k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 669 | | | 670 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 671 | 5.47k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 672 | | | 673 | 5.47k | return sec; | 674 | 5.47k | } |
pei-riscv64.c:pe_ILF_make_a_section Line | Count | Source | 615 | 1.88k | { | 616 | 1.88k | asection_ptr sec; | 617 | 1.88k | flagword flags; | 618 | 1.88k | intptr_t alignment; | 619 | | | 620 | 1.88k | sec = bfd_make_section_old_way (vars->abfd, name); | 621 | 1.88k | if (sec == NULL) | 622 | 0 | return NULL; | 623 | | | 624 | 1.88k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 625 | | | 626 | 1.88k | bfd_set_section_flags (sec, flags | extra_flags); | 627 | | | 628 | 1.88k | bfd_set_section_alignment (sec, 2); | 629 | | | 630 | | /* Check that we will not run out of space. */ | 631 | 1.88k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 632 | | | 633 | | /* Set the section size and contents. The actual | 634 | | contents are filled in by our parent. */ | 635 | 1.88k | bfd_set_section_size (sec, (bfd_size_type) size); | 636 | 1.88k | sec->contents = vars->data; | 637 | 1.88k | sec->target_index = vars->sec_index ++; | 638 | | | 639 | | /* Advance data pointer in the vars structure. */ | 640 | 1.88k | vars->data += size; | 641 | | | 642 | | /* Skip the padding byte if it was not needed. | 643 | | The logic here is that if the string length is odd, | 644 | | then the entire string length, including the null byte, | 645 | | is even and so the extra, padding byte, is not needed. */ | 646 | 1.88k | if (size & 1) | 647 | 12 | vars->data --; | 648 | | | 649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 650 | | preserve host alignment requirements. The BFD_ASSERTs in this | 651 | | functions will warn us if we run out of room, but we should | 652 | | already have enough padding built in to ILF_DATA_SIZE. */ | 653 | 1.88k | #if GCC_VERSION >= 3000 | 654 | 1.88k | alignment = __alignof__ (struct coff_section_tdata); | 655 | | #else | 656 | | alignment = 8; | 657 | | #endif | 658 | 1.88k | vars->data | 659 | 1.88k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 660 | | | 661 | | /* Create a coff_section_tdata structure for our use. */ | 662 | 1.88k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 663 | 1.88k | vars->data += sizeof (struct coff_section_tdata); | 664 | | | 665 | 1.88k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 666 | | | 667 | | /* Create a symbol to refer to this section. */ | 668 | 1.88k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 669 | | | 670 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 671 | 1.88k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 672 | | | 673 | 1.88k | return sec; | 674 | 1.88k | } |
pei-arm-wince.c:pe_ILF_make_a_section Line | Count | Source | 615 | 458 | { | 616 | 458 | asection_ptr sec; | 617 | 458 | flagword flags; | 618 | 458 | intptr_t alignment; | 619 | | | 620 | 458 | sec = bfd_make_section_old_way (vars->abfd, name); | 621 | 458 | if (sec == NULL) | 622 | 0 | return NULL; | 623 | | | 624 | 458 | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 625 | | | 626 | 458 | bfd_set_section_flags (sec, flags | extra_flags); | 627 | | | 628 | 458 | bfd_set_section_alignment (sec, 2); | 629 | | | 630 | | /* Check that we will not run out of space. */ | 631 | 458 | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 632 | | | 633 | | /* Set the section size and contents. The actual | 634 | | contents are filled in by our parent. */ | 635 | 458 | bfd_set_section_size (sec, (bfd_size_type) size); | 636 | 458 | sec->contents = vars->data; | 637 | 458 | sec->target_index = vars->sec_index ++; | 638 | | | 639 | | /* Advance data pointer in the vars structure. */ | 640 | 458 | vars->data += size; | 641 | | | 642 | | /* Skip the padding byte if it was not needed. | 643 | | The logic here is that if the string length is odd, | 644 | | then the entire string length, including the null byte, | 645 | | is even and so the extra, padding byte, is not needed. */ | 646 | 458 | if (size & 1) | 647 | 25 | vars->data --; | 648 | | | 649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 650 | | preserve host alignment requirements. The BFD_ASSERTs in this | 651 | | functions will warn us if we run out of room, but we should | 652 | | already have enough padding built in to ILF_DATA_SIZE. */ | 653 | 458 | #if GCC_VERSION >= 3000 | 654 | 458 | alignment = __alignof__ (struct coff_section_tdata); | 655 | | #else | 656 | | alignment = 8; | 657 | | #endif | 658 | 458 | vars->data | 659 | 458 | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 660 | | | 661 | | /* Create a coff_section_tdata structure for our use. */ | 662 | 458 | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 663 | 458 | vars->data += sizeof (struct coff_section_tdata); | 664 | | | 665 | 458 | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 666 | | | 667 | | /* Create a symbol to refer to this section. */ | 668 | 458 | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 669 | | | 670 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 671 | 458 | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 672 | | | 673 | 458 | return sec; | 674 | 458 | } |
pei-arm.c:pe_ILF_make_a_section Line | Count | Source | 615 | 15.3k | { | 616 | 15.3k | asection_ptr sec; | 617 | 15.3k | flagword flags; | 618 | 15.3k | intptr_t alignment; | 619 | | | 620 | 15.3k | sec = bfd_make_section_old_way (vars->abfd, name); | 621 | 15.3k | if (sec == NULL) | 622 | 0 | return NULL; | 623 | | | 624 | 15.3k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 625 | | | 626 | 15.3k | bfd_set_section_flags (sec, flags | extra_flags); | 627 | | | 628 | 15.3k | bfd_set_section_alignment (sec, 2); | 629 | | | 630 | | /* Check that we will not run out of space. */ | 631 | 15.3k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 632 | | | 633 | | /* Set the section size and contents. The actual | 634 | | contents are filled in by our parent. */ | 635 | 15.3k | bfd_set_section_size (sec, (bfd_size_type) size); | 636 | 15.3k | sec->contents = vars->data; | 637 | 15.3k | sec->target_index = vars->sec_index ++; | 638 | | | 639 | | /* Advance data pointer in the vars structure. */ | 640 | 15.3k | vars->data += size; | 641 | | | 642 | | /* Skip the padding byte if it was not needed. | 643 | | The logic here is that if the string length is odd, | 644 | | then the entire string length, including the null byte, | 645 | | is even and so the extra, padding byte, is not needed. */ | 646 | 15.3k | if (size & 1) | 647 | 2.13k | vars->data --; | 648 | | | 649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 650 | | preserve host alignment requirements. The BFD_ASSERTs in this | 651 | | functions will warn us if we run out of room, but we should | 652 | | already have enough padding built in to ILF_DATA_SIZE. */ | 653 | 15.3k | #if GCC_VERSION >= 3000 | 654 | 15.3k | alignment = __alignof__ (struct coff_section_tdata); | 655 | | #else | 656 | | alignment = 8; | 657 | | #endif | 658 | 15.3k | vars->data | 659 | 15.3k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 660 | | | 661 | | /* Create a coff_section_tdata structure for our use. */ | 662 | 15.3k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 663 | 15.3k | vars->data += sizeof (struct coff_section_tdata); | 664 | | | 665 | 15.3k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 666 | | | 667 | | /* Create a symbol to refer to this section. */ | 668 | 15.3k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 669 | | | 670 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 671 | 15.3k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 672 | | | 673 | 15.3k | return sec; | 674 | 15.3k | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_make_a_section pei-sh.c:pe_ILF_make_a_section Line | Count | Source | 615 | 9.29k | { | 616 | 9.29k | asection_ptr sec; | 617 | 9.29k | flagword flags; | 618 | 9.29k | intptr_t alignment; | 619 | | | 620 | 9.29k | sec = bfd_make_section_old_way (vars->abfd, name); | 621 | 9.29k | if (sec == NULL) | 622 | 0 | return NULL; | 623 | | | 624 | 9.29k | flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_IN_MEMORY; | 625 | | | 626 | 9.29k | bfd_set_section_flags (sec, flags | extra_flags); | 627 | | | 628 | 9.29k | bfd_set_section_alignment (sec, 2); | 629 | | | 630 | | /* Check that we will not run out of space. */ | 631 | 9.29k | BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); | 632 | | | 633 | | /* Set the section size and contents. The actual | 634 | | contents are filled in by our parent. */ | 635 | 9.29k | bfd_set_section_size (sec, (bfd_size_type) size); | 636 | 9.29k | sec->contents = vars->data; | 637 | 9.29k | sec->target_index = vars->sec_index ++; | 638 | | | 639 | | /* Advance data pointer in the vars structure. */ | 640 | 9.29k | vars->data += size; | 641 | | | 642 | | /* Skip the padding byte if it was not needed. | 643 | | The logic here is that if the string length is odd, | 644 | | then the entire string length, including the null byte, | 645 | | is even and so the extra, padding byte, is not needed. */ | 646 | 9.29k | if (size & 1) | 647 | 1.31k | vars->data --; | 648 | | | 649 | | /* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we | 650 | | preserve host alignment requirements. The BFD_ASSERTs in this | 651 | | functions will warn us if we run out of room, but we should | 652 | | already have enough padding built in to ILF_DATA_SIZE. */ | 653 | 9.29k | #if GCC_VERSION >= 3000 | 654 | 9.29k | alignment = __alignof__ (struct coff_section_tdata); | 655 | | #else | 656 | | alignment = 8; | 657 | | #endif | 658 | 9.29k | vars->data | 659 | 9.29k | = (bfd_byte *) (((intptr_t) vars->data + alignment - 1) & -alignment); | 660 | | | 661 | | /* Create a coff_section_tdata structure for our use. */ | 662 | 9.29k | sec->used_by_bfd = (struct coff_section_tdata *) vars->data; | 663 | 9.29k | vars->data += sizeof (struct coff_section_tdata); | 664 | | | 665 | 9.29k | BFD_ASSERT (vars->data <= vars->bim->buffer + vars->bim->size); | 666 | | | 667 | | /* Create a symbol to refer to this section. */ | 668 | 9.29k | pe_ILF_make_a_symbol (vars, "", name, sec, BSF_LOCAL); | 669 | | | 670 | | /* Cache the index to the symbol in the coff_section_data structure. */ | 671 | 9.29k | coff_section_data (vars->abfd, sec)->i = vars->sym_index - 1; | 672 | | | 673 | 9.29k | return sec; | 674 | 9.29k | } |
|
675 | | |
676 | | /* This structure contains the code that goes into the .text section |
677 | | in order to perform a jump into the DLL lookup table. The entries |
678 | | in the table are index by the magic number used to represent the |
679 | | machine type in the PE file. The contents of the data[] arrays in |
680 | | these entries are stolen from the jtab[] arrays in ld/pe-dll.c. |
681 | | The SIZE field says how many bytes in the DATA array are actually |
682 | | used. The OFFSET field says where in the data array the address |
683 | | of the .idata$5 section should be placed. */ |
684 | 43.3k | #define MAX_TEXT_SECTION_SIZE 32 |
685 | | |
686 | | typedef struct |
687 | | { |
688 | | unsigned short magic; |
689 | | unsigned char data[MAX_TEXT_SECTION_SIZE]; |
690 | | unsigned int size; |
691 | | unsigned int offset; |
692 | | } |
693 | | jump_table; |
694 | | |
695 | | static const jump_table jtab[] = |
696 | | { |
697 | | #ifdef I386MAGIC |
698 | | { I386MAGIC, |
699 | | { 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90 }, |
700 | | 8, 2 |
701 | | }, |
702 | | #endif |
703 | | |
704 | | #ifdef AMD64MAGIC |
705 | | { AMD64MAGIC, |
706 | | { 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90 }, |
707 | | 8, 2 |
708 | | }, |
709 | | #endif |
710 | | |
711 | | #ifdef MC68MAGIC |
712 | | { MC68MAGIC, |
713 | | { /* XXX fill me in */ }, |
714 | | 0, 0 |
715 | | }, |
716 | | #endif |
717 | | |
718 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
719 | | { MIPS_ARCH_MAGIC_WINCE, |
720 | | { 0x00, 0x00, 0x08, 0x3c, 0x00, 0x00, 0x08, 0x8d, |
721 | | 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }, |
722 | | 16, 0 |
723 | | }, |
724 | | #endif |
725 | | |
726 | | #ifdef SH_ARCH_MAGIC_WINCE |
727 | | { SH_ARCH_MAGIC_WINCE, |
728 | | { 0x01, 0xd0, 0x02, 0x60, 0x2b, 0x40, |
729 | | 0x09, 0x00, 0x00, 0x00, 0x00, 0x00 }, |
730 | | 12, 8 |
731 | | }, |
732 | | #endif |
733 | | |
734 | | #ifdef AARCH64MAGIC |
735 | | /* We don't currently support jumping to DLLs, so if |
736 | | someone does try emit a runtime trap. Through UDF #0. */ |
737 | | { AARCH64MAGIC, |
738 | | { 0x00, 0x00, 0x00, 0x00 }, |
739 | | 4, 0 |
740 | | }, |
741 | | |
742 | | #endif |
743 | | |
744 | | #ifdef ARMPEMAGIC |
745 | | { ARMPEMAGIC, |
746 | | { 0x00, 0xc0, 0x9f, 0xe5, 0x00, 0xf0, |
747 | | 0x9c, 0xe5, 0x00, 0x00, 0x00, 0x00}, |
748 | | 12, 8 |
749 | | }, |
750 | | #endif |
751 | | |
752 | | #ifdef THUMBPEMAGIC |
753 | | { THUMBPEMAGIC, |
754 | | { 0x40, 0xb4, 0x02, 0x4e, 0x36, 0x68, 0xb4, 0x46, |
755 | | 0x40, 0xbc, 0x60, 0x47, 0x00, 0x00, 0x00, 0x00 }, |
756 | | 16, 12 |
757 | | }, |
758 | | #endif |
759 | | |
760 | | #ifdef LOONGARCH64MAGIC |
761 | | /* We don't currently support jumping to DLLs, so if |
762 | | someone does try emit a runtime trap. Through BREAK 0. */ |
763 | | { LOONGARCH64MAGIC, |
764 | | { 0x00, 0x00, 0x2a, 0x00 }, |
765 | | 4, 0 |
766 | | }, |
767 | | |
768 | | #endif |
769 | | |
770 | | #ifdef RISCV64MAGIC |
771 | | /* We don't currently support jumping to DLLs, so if |
772 | | someone does try emit a runtime trap. Through EBREAK. */ |
773 | | { RISCV64MAGIC, |
774 | | { 0x73, 0x00, 0x10, 0x00 }, |
775 | | 4, 0 |
776 | | }, |
777 | | |
778 | | #endif |
779 | | |
780 | | { 0, { 0 }, 0, 0 } |
781 | | }; |
782 | | |
783 | | #ifndef NUM_ENTRIES |
784 | 11.9k | #define NUM_ENTRIES(a) (sizeof (a) / sizeof (a)[0]) |
785 | | #endif |
786 | | |
787 | | /* Build a full BFD from the information supplied in a ILF object. */ |
788 | | |
789 | | static bool |
790 | | pe_ILF_build_a_bfd (bfd * abfd, |
791 | | unsigned int magic, |
792 | | char * symbol_name, |
793 | | char * source_dll, |
794 | | unsigned int ordinal, |
795 | | unsigned int types) |
796 | 26.8k | { |
797 | 26.8k | bfd_byte * ptr; |
798 | 26.8k | pe_ILF_vars vars; |
799 | 26.8k | struct internal_filehdr internal_f; |
800 | 26.8k | unsigned int import_type; |
801 | 26.8k | unsigned int import_name_type; |
802 | 26.8k | asection_ptr id4, id5, id6 = NULL, text = NULL; |
803 | 26.8k | coff_symbol_type ** imp_sym; |
804 | 26.8k | unsigned int imp_index; |
805 | 26.8k | intptr_t alignment; |
806 | | |
807 | | /* Decode and verify the types field of the ILF structure. */ |
808 | 26.8k | import_type = types & 0x3; |
809 | 26.8k | import_name_type = (types & 0x1c) >> 2; |
810 | | |
811 | 26.8k | switch (import_type) |
812 | 26.8k | { |
813 | 14.0k | case IMPORT_CODE: |
814 | 23.3k | case IMPORT_DATA: |
815 | 23.3k | break; |
816 | | |
817 | 1.41k | case IMPORT_CONST: |
818 | | /* XXX code yet to be written. */ |
819 | | /* xgettext:c-format */ |
820 | 1.41k | _bfd_error_handler (_("%pB: unhandled import type; %x"), |
821 | 1.41k | abfd, import_type); |
822 | 1.41k | return false; |
823 | | |
824 | 2.12k | default: |
825 | | /* xgettext:c-format */ |
826 | 2.12k | _bfd_error_handler (_("%pB: unrecognized import type; %x"), |
827 | 2.12k | abfd, import_type); |
828 | 2.12k | return false; |
829 | 26.8k | } |
830 | | |
831 | 23.3k | switch (import_name_type) |
832 | 23.3k | { |
833 | 8.24k | case IMPORT_ORDINAL: |
834 | 12.1k | case IMPORT_NAME: |
835 | 15.8k | case IMPORT_NAME_NOPREFIX: |
836 | 21.6k | case IMPORT_NAME_UNDECORATE: |
837 | 21.6k | break; |
838 | | |
839 | 1.64k | default: |
840 | | /* xgettext:c-format */ |
841 | 1.64k | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), |
842 | 1.64k | abfd, import_name_type); |
843 | 1.64k | return false; |
844 | 23.3k | } |
845 | | |
846 | | /* Initialise local variables. |
847 | | |
848 | | Note these are kept in a structure rather than being |
849 | | declared as statics since bfd frowns on global variables. |
850 | | |
851 | | We are going to construct the contents of the BFD in memory, |
852 | | so allocate all the space that we will need right now. */ |
853 | 21.6k | vars.bim |
854 | 21.6k | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); |
855 | 21.6k | if (vars.bim == NULL) |
856 | 0 | return false; |
857 | | |
858 | 21.6k | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); |
859 | 21.6k | vars.bim->buffer = ptr; |
860 | 21.6k | vars.bim->size = ILF_DATA_SIZE; |
861 | 21.6k | if (ptr == NULL) |
862 | 0 | goto error_return; |
863 | | |
864 | | /* Initialise the pointers to regions of the memory and the |
865 | | other contents of the pe_ILF_vars structure as well. */ |
866 | 21.6k | vars.sym_cache = (coff_symbol_type *) ptr; |
867 | 21.6k | vars.sym_ptr = (coff_symbol_type *) ptr; |
868 | 21.6k | vars.sym_index = 0; |
869 | 21.6k | ptr += SIZEOF_ILF_SYMS; |
870 | | |
871 | 21.6k | vars.sym_table = (unsigned int *) ptr; |
872 | 21.6k | vars.table_ptr = (unsigned int *) ptr; |
873 | 21.6k | ptr += SIZEOF_ILF_SYM_TABLE; |
874 | | |
875 | 21.6k | vars.native_syms = (combined_entry_type *) ptr; |
876 | 21.6k | vars.native_ptr = (combined_entry_type *) ptr; |
877 | 21.6k | ptr += SIZEOF_ILF_NATIVE_SYMS; |
878 | | |
879 | 21.6k | vars.sym_ptr_table = (coff_symbol_type **) ptr; |
880 | 21.6k | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; |
881 | 21.6k | ptr += SIZEOF_ILF_SYM_PTR_TABLE; |
882 | | |
883 | 21.6k | vars.esym_table = (SYMENT *) ptr; |
884 | 21.6k | vars.esym_ptr = (SYMENT *) ptr; |
885 | 21.6k | ptr += SIZEOF_ILF_EXT_SYMS; |
886 | | |
887 | 21.6k | vars.reltab = (arelent *) ptr; |
888 | 21.6k | vars.relcount = 0; |
889 | 21.6k | ptr += SIZEOF_ILF_RELOCS; |
890 | | |
891 | 21.6k | vars.int_reltab = (struct internal_reloc *) ptr; |
892 | 21.6k | ptr += SIZEOF_ILF_INT_RELOCS; |
893 | | |
894 | 21.6k | vars.string_table = (char *) ptr; |
895 | 21.6k | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; |
896 | 21.6k | ptr += SIZEOF_ILF_STRINGS; |
897 | 21.6k | vars.end_string_ptr = (char *) ptr; |
898 | | |
899 | | /* The remaining space in bim->buffer is used |
900 | | by the pe_ILF_make_a_section() function. */ |
901 | | |
902 | | /* PR 18758: Make sure that the data area is sufficiently aligned for |
903 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence |
904 | | the test of GCC_VERSION. For other compilers we assume 8 byte |
905 | | alignment. */ |
906 | 21.6k | #if GCC_VERSION >= 3000 |
907 | 21.6k | alignment = __alignof__ (struct coff_section_tdata); |
908 | | #else |
909 | | alignment = 8; |
910 | | #endif |
911 | 21.6k | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); |
912 | | |
913 | 21.6k | vars.data = ptr; |
914 | 21.6k | vars.abfd = abfd; |
915 | 21.6k | vars.sec_index = 0; |
916 | 21.6k | vars.magic = magic; |
917 | | |
918 | | /* Create the initial .idata$<n> sections: |
919 | | [.idata$2: Import Directory Table -- not needed] |
920 | | .idata$4: Import Lookup Table |
921 | | .idata$5: Import Address Table |
922 | | |
923 | | Note we do not create a .idata$3 section as this is |
924 | | created for us by the linker script. */ |
925 | 21.6k | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); |
926 | 21.6k | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); |
927 | 21.6k | if (id4 == NULL || id5 == NULL) |
928 | 0 | goto error_return; |
929 | | |
930 | | /* Fill in the contents of these sections. */ |
931 | 21.6k | if (import_name_type == IMPORT_ORDINAL) |
932 | 8.24k | { |
933 | 8.24k | if (ordinal == 0) |
934 | | /* See PR 20907 for a reproducer. */ |
935 | 1.12k | goto error_return; |
936 | | |
937 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64) |
938 | 3.77k | ((unsigned int *) id4->contents)[0] = ordinal; |
939 | 3.77k | ((unsigned int *) id4->contents)[1] = 0x80000000; |
940 | 3.77k | ((unsigned int *) id5->contents)[0] = ordinal; |
941 | 3.77k | ((unsigned int *) id5->contents)[1] = 0x80000000; |
942 | | #else |
943 | 3.33k | * (unsigned int *) id4->contents = ordinal | 0x80000000; |
944 | 3.33k | * (unsigned int *) id5->contents = ordinal | 0x80000000; |
945 | 3.33k | #endif |
946 | 3.33k | } |
947 | 13.4k | else |
948 | 13.4k | { |
949 | 13.4k | char * symbol; |
950 | 13.4k | unsigned int len; |
951 | | |
952 | | /* Create .idata$6 - the Hint Name Table. */ |
953 | 13.4k | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); |
954 | 13.4k | if (id6 == NULL) |
955 | 0 | goto error_return; |
956 | | |
957 | | /* If necessary, trim the import symbol name. */ |
958 | 13.4k | symbol = symbol_name; |
959 | | |
960 | | /* As used by MS compiler, '_', '@', and '?' are alternative |
961 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, |
962 | | '@' used for fastcall (in C), '_' everywhere else. Only one |
963 | | of these is used for a symbol. We strip this leading char for |
964 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the |
965 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ |
966 | | |
967 | 13.4k | if (import_name_type != IMPORT_NAME) |
968 | 9.59k | { |
969 | 9.59k | char c = symbol[0]; |
970 | | |
971 | | /* Check that we don't remove for targets with empty |
972 | | USER_LABEL_PREFIX the leading underscore. */ |
973 | 9.59k | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) |
974 | 9.59k | || c == '@' || c == '?') |
975 | 1.75k | symbol++; |
976 | 9.59k | } |
977 | | |
978 | 13.4k | len = strlen (symbol); |
979 | 13.4k | if (import_name_type == IMPORT_NAME_UNDECORATE) |
980 | 5.81k | { |
981 | | /* Truncate at the first '@'. */ |
982 | 5.81k | char *at = strchr (symbol, '@'); |
983 | | |
984 | 5.81k | if (at != NULL) |
985 | 701 | len = at - symbol; |
986 | 5.81k | } |
987 | | |
988 | 13.4k | id6->contents[0] = ordinal & 0xff; |
989 | 13.4k | id6->contents[1] = ordinal >> 8; |
990 | | |
991 | 13.4k | memcpy ((char *) id6->contents + 2, symbol, len); |
992 | 13.4k | id6->contents[len + 2] = '\0'; |
993 | 13.4k | } |
994 | | |
995 | 20.5k | if (import_name_type != IMPORT_ORDINAL) |
996 | 13.4k | { |
997 | 13.4k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); |
998 | 13.4k | pe_ILF_save_relocs (&vars, id4); |
999 | | |
1000 | 13.4k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); |
1001 | 13.4k | pe_ILF_save_relocs (&vars, id5); |
1002 | 13.4k | } |
1003 | | |
1004 | | /* Create an import symbol. */ |
1005 | 20.5k | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); |
1006 | 20.5k | imp_sym = vars.sym_ptr_ptr - 1; |
1007 | 20.5k | imp_index = vars.sym_index - 1; |
1008 | | |
1009 | | /* Create extra sections depending upon the type of import we are dealing with. */ |
1010 | 20.5k | switch (import_type) |
1011 | 20.5k | { |
1012 | 0 | int i; |
1013 | | |
1014 | 11.9k | case IMPORT_CODE: |
1015 | | /* CODE functions are special, in that they get a trampoline that |
1016 | | jumps to the main import symbol. Create a .text section to hold it. |
1017 | | First we need to look up its contents in the jump table. */ |
1018 | 26.9k | for (i = NUM_ENTRIES (jtab); i--;) |
1019 | 26.9k | { |
1020 | 26.9k | if (jtab[i].size == 0) |
1021 | 11.9k | continue; |
1022 | 14.9k | if (jtab[i].magic == magic) |
1023 | 11.9k | break; |
1024 | 14.9k | } |
1025 | | /* If we did not find a matching entry something is wrong. */ |
1026 | 11.9k | if (i < 0) |
1027 | 0 | abort (); |
1028 | | |
1029 | | /* Create the .text section. */ |
1030 | 11.9k | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); |
1031 | 11.9k | if (text == NULL) |
1032 | 0 | goto error_return; |
1033 | | |
1034 | | /* Copy in the jump code. */ |
1035 | 11.9k | memcpy (text->contents, jtab[i].data, jtab[i].size); |
1036 | | |
1037 | | /* Create a reloc for the data in the text section. */ |
1038 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
1039 | | if (magic == MIPS_ARCH_MAGIC_WINCE) |
1040 | | { |
1041 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, |
1042 | | (struct bfd_symbol **) imp_sym, |
1043 | | imp_index); |
1044 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); |
1045 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, |
1046 | | (struct bfd_symbol **) imp_sym, |
1047 | | imp_index); |
1048 | | } |
1049 | | else |
1050 | | #endif |
1051 | | #ifdef AMD64MAGIC |
1052 | 2.11k | if (magic == AMD64MAGIC) |
1053 | 2.11k | { |
1054 | 2.11k | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, |
1055 | 2.11k | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, |
1056 | 2.11k | imp_index); |
1057 | 2.11k | } |
1058 | 0 | else |
1059 | 0 | #endif |
1060 | 0 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, |
1061 | 0 | BFD_RELOC_32, (asymbol **) imp_sym, |
1062 | 0 | imp_index); |
1063 | | |
1064 | 11.9k | pe_ILF_save_relocs (& vars, text); |
1065 | 11.9k | break; |
1066 | | |
1067 | 8.58k | case IMPORT_DATA: |
1068 | 8.58k | break; |
1069 | | |
1070 | 0 | default: |
1071 | | /* XXX code not yet written. */ |
1072 | 0 | abort (); |
1073 | 20.5k | } |
1074 | | |
1075 | | /* Now create a symbol describing the imported value. */ |
1076 | 20.5k | switch (import_type) |
1077 | 20.5k | { |
1078 | 11.9k | case IMPORT_CODE: |
1079 | 11.9k | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, |
1080 | 11.9k | BSF_NOT_AT_END | BSF_FUNCTION); |
1081 | | |
1082 | 11.9k | break; |
1083 | | |
1084 | 8.58k | case IMPORT_DATA: |
1085 | | /* Nothing to do here. */ |
1086 | 8.58k | break; |
1087 | | |
1088 | 0 | default: |
1089 | | /* XXX code not yet written. */ |
1090 | 0 | abort (); |
1091 | 20.5k | } |
1092 | | |
1093 | | /* Create an import symbol for the DLL, without the .dll suffix. */ |
1094 | 20.5k | ptr = (bfd_byte *) strrchr (source_dll, '.'); |
1095 | 20.5k | if (ptr) |
1096 | 3.03k | * ptr = 0; |
1097 | 20.5k | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); |
1098 | 20.5k | if (ptr) |
1099 | 3.03k | * ptr = '.'; |
1100 | | |
1101 | | /* Initialise the bfd. */ |
1102 | 20.5k | memset (& internal_f, 0, sizeof (internal_f)); |
1103 | | |
1104 | 20.5k | internal_f.f_magic = magic; |
1105 | 20.5k | internal_f.f_symptr = 0; |
1106 | 20.5k | internal_f.f_nsyms = 0; |
1107 | 20.5k | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ |
1108 | | |
1109 | 20.5k | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) |
1110 | 20.5k | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) |
1111 | 0 | goto error_return; |
1112 | | |
1113 | 20.5k | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) |
1114 | 0 | goto error_return; |
1115 | | |
1116 | 20.5k | obj_pe (abfd) = true; |
1117 | | #ifdef THUMBPEMAGIC |
1118 | 4.57k | if (vars.magic == THUMBPEMAGIC) |
1119 | | /* Stop some linker warnings about thumb code not supporting interworking. */ |
1120 | 1.00k | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; |
1121 | | #endif |
1122 | | |
1123 | | /* Switch from file contents to memory contents. */ |
1124 | 20.5k | bfd_cache_close (abfd); |
1125 | | |
1126 | 20.5k | abfd->iostream = (void *) vars.bim; |
1127 | 20.5k | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; |
1128 | 20.5k | abfd->iovec = &_bfd_memory_iovec; |
1129 | 20.5k | abfd->where = 0; |
1130 | 20.5k | abfd->origin = 0; |
1131 | 20.5k | abfd->size = 0; |
1132 | 20.5k | obj_sym_filepos (abfd) = 0; |
1133 | | |
1134 | | /* Point the bfd at the symbol table. */ |
1135 | 20.5k | obj_symbols (abfd) = vars.sym_cache; |
1136 | 20.5k | abfd->symcount = vars.sym_index; |
1137 | | |
1138 | 20.5k | obj_raw_syments (abfd) = vars.native_syms; |
1139 | 20.5k | obj_raw_syment_count (abfd) = vars.sym_index; |
1140 | | |
1141 | 20.5k | obj_coff_external_syms (abfd) = (void *) vars.esym_table; |
1142 | 20.5k | obj_coff_keep_syms (abfd) = true; |
1143 | | |
1144 | 20.5k | obj_convert (abfd) = vars.sym_table; |
1145 | 20.5k | obj_conv_table_size (abfd) = vars.sym_index; |
1146 | | |
1147 | 20.5k | obj_coff_strings (abfd) = vars.string_table; |
1148 | 20.5k | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; |
1149 | 20.5k | obj_coff_keep_strings (abfd) = true; |
1150 | | |
1151 | 20.5k | return true; |
1152 | | |
1153 | 1.12k | error_return: |
1154 | 1.12k | free (vars.bim->buffer); |
1155 | 1.12k | free (vars.bim); |
1156 | 1.12k | return false; |
1157 | 20.5k | } pei-i386.c:pe_ILF_build_a_bfd Line | Count | Source | 796 | 4.59k | { | 797 | 4.59k | bfd_byte * ptr; | 798 | 4.59k | pe_ILF_vars vars; | 799 | 4.59k | struct internal_filehdr internal_f; | 800 | 4.59k | unsigned int import_type; | 801 | 4.59k | unsigned int import_name_type; | 802 | 4.59k | asection_ptr id4, id5, id6 = NULL, text = NULL; | 803 | 4.59k | coff_symbol_type ** imp_sym; | 804 | 4.59k | unsigned int imp_index; | 805 | 4.59k | intptr_t alignment; | 806 | | | 807 | | /* Decode and verify the types field of the ILF structure. */ | 808 | 4.59k | import_type = types & 0x3; | 809 | 4.59k | import_name_type = (types & 0x1c) >> 2; | 810 | | | 811 | 4.59k | switch (import_type) | 812 | 4.59k | { | 813 | 3.29k | case IMPORT_CODE: | 814 | 4.06k | case IMPORT_DATA: | 815 | 4.06k | break; | 816 | | | 817 | 215 | case IMPORT_CONST: | 818 | | /* XXX code yet to be written. */ | 819 | | /* xgettext:c-format */ | 820 | 215 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 821 | 215 | abfd, import_type); | 822 | 215 | return false; | 823 | | | 824 | 315 | default: | 825 | | /* xgettext:c-format */ | 826 | 315 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 827 | 315 | abfd, import_type); | 828 | 315 | return false; | 829 | 4.59k | } | 830 | | | 831 | 4.06k | switch (import_name_type) | 832 | 4.06k | { | 833 | 1.28k | case IMPORT_ORDINAL: | 834 | 1.72k | case IMPORT_NAME: | 835 | 2.30k | case IMPORT_NAME_NOPREFIX: | 836 | 3.73k | case IMPORT_NAME_UNDECORATE: | 837 | 3.73k | break; | 838 | | | 839 | 324 | default: | 840 | | /* xgettext:c-format */ | 841 | 324 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 842 | 324 | abfd, import_name_type); | 843 | 324 | return false; | 844 | 4.06k | } | 845 | | | 846 | | /* Initialise local variables. | 847 | | | 848 | | Note these are kept in a structure rather than being | 849 | | declared as statics since bfd frowns on global variables. | 850 | | | 851 | | We are going to construct the contents of the BFD in memory, | 852 | | so allocate all the space that we will need right now. */ | 853 | 3.73k | vars.bim | 854 | 3.73k | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 855 | 3.73k | if (vars.bim == NULL) | 856 | 0 | return false; | 857 | | | 858 | 3.73k | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 859 | 3.73k | vars.bim->buffer = ptr; | 860 | 3.73k | vars.bim->size = ILF_DATA_SIZE; | 861 | 3.73k | if (ptr == NULL) | 862 | 0 | goto error_return; | 863 | | | 864 | | /* Initialise the pointers to regions of the memory and the | 865 | | other contents of the pe_ILF_vars structure as well. */ | 866 | 3.73k | vars.sym_cache = (coff_symbol_type *) ptr; | 867 | 3.73k | vars.sym_ptr = (coff_symbol_type *) ptr; | 868 | 3.73k | vars.sym_index = 0; | 869 | 3.73k | ptr += SIZEOF_ILF_SYMS; | 870 | | | 871 | 3.73k | vars.sym_table = (unsigned int *) ptr; | 872 | 3.73k | vars.table_ptr = (unsigned int *) ptr; | 873 | 3.73k | ptr += SIZEOF_ILF_SYM_TABLE; | 874 | | | 875 | 3.73k | vars.native_syms = (combined_entry_type *) ptr; | 876 | 3.73k | vars.native_ptr = (combined_entry_type *) ptr; | 877 | 3.73k | ptr += SIZEOF_ILF_NATIVE_SYMS; | 878 | | | 879 | 3.73k | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 880 | 3.73k | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 881 | 3.73k | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 882 | | | 883 | 3.73k | vars.esym_table = (SYMENT *) ptr; | 884 | 3.73k | vars.esym_ptr = (SYMENT *) ptr; | 885 | 3.73k | ptr += SIZEOF_ILF_EXT_SYMS; | 886 | | | 887 | 3.73k | vars.reltab = (arelent *) ptr; | 888 | 3.73k | vars.relcount = 0; | 889 | 3.73k | ptr += SIZEOF_ILF_RELOCS; | 890 | | | 891 | 3.73k | vars.int_reltab = (struct internal_reloc *) ptr; | 892 | 3.73k | ptr += SIZEOF_ILF_INT_RELOCS; | 893 | | | 894 | 3.73k | vars.string_table = (char *) ptr; | 895 | 3.73k | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 896 | 3.73k | ptr += SIZEOF_ILF_STRINGS; | 897 | 3.73k | vars.end_string_ptr = (char *) ptr; | 898 | | | 899 | | /* The remaining space in bim->buffer is used | 900 | | by the pe_ILF_make_a_section() function. */ | 901 | | | 902 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 903 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 904 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 905 | | alignment. */ | 906 | 3.73k | #if GCC_VERSION >= 3000 | 907 | 3.73k | alignment = __alignof__ (struct coff_section_tdata); | 908 | | #else | 909 | | alignment = 8; | 910 | | #endif | 911 | 3.73k | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 912 | | | 913 | 3.73k | vars.data = ptr; | 914 | 3.73k | vars.abfd = abfd; | 915 | 3.73k | vars.sec_index = 0; | 916 | 3.73k | vars.magic = magic; | 917 | | | 918 | | /* Create the initial .idata$<n> sections: | 919 | | [.idata$2: Import Directory Table -- not needed] | 920 | | .idata$4: Import Lookup Table | 921 | | .idata$5: Import Address Table | 922 | | | 923 | | Note we do not create a .idata$3 section as this is | 924 | | created for us by the linker script. */ | 925 | 3.73k | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 926 | 3.73k | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 927 | 3.73k | if (id4 == NULL || id5 == NULL) | 928 | 0 | goto error_return; | 929 | | | 930 | | /* Fill in the contents of these sections. */ | 931 | 3.73k | if (import_name_type == IMPORT_ORDINAL) | 932 | 1.28k | { | 933 | 1.28k | if (ordinal == 0) | 934 | | /* See PR 20907 for a reproducer. */ | 935 | 216 | goto error_return; | 936 | | | 937 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64) | 938 | | ((unsigned int *) id4->contents)[0] = ordinal; | 939 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 940 | | ((unsigned int *) id5->contents)[0] = ordinal; | 941 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 942 | | #else | 943 | 1.06k | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 944 | 1.06k | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 945 | 1.06k | #endif | 946 | 1.06k | } | 947 | 2.45k | else | 948 | 2.45k | { | 949 | 2.45k | char * symbol; | 950 | 2.45k | unsigned int len; | 951 | | | 952 | | /* Create .idata$6 - the Hint Name Table. */ | 953 | 2.45k | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 954 | 2.45k | if (id6 == NULL) | 955 | 0 | goto error_return; | 956 | | | 957 | | /* If necessary, trim the import symbol name. */ | 958 | 2.45k | symbol = symbol_name; | 959 | | | 960 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 961 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 962 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 963 | | of these is used for a symbol. We strip this leading char for | 964 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 965 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 966 | | | 967 | 2.45k | if (import_name_type != IMPORT_NAME) | 968 | 2.01k | { | 969 | 2.01k | char c = symbol[0]; | 970 | | | 971 | | /* Check that we don't remove for targets with empty | 972 | | USER_LABEL_PREFIX the leading underscore. */ | 973 | 2.01k | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 974 | 2.01k | || c == '@' || c == '?') | 975 | 11 | symbol++; | 976 | 2.01k | } | 977 | | | 978 | 2.45k | len = strlen (symbol); | 979 | 2.45k | if (import_name_type == IMPORT_NAME_UNDECORATE) | 980 | 1.42k | { | 981 | | /* Truncate at the first '@'. */ | 982 | 1.42k | char *at = strchr (symbol, '@'); | 983 | | | 984 | 1.42k | if (at != NULL) | 985 | 206 | len = at - symbol; | 986 | 1.42k | } | 987 | | | 988 | 2.45k | id6->contents[0] = ordinal & 0xff; | 989 | 2.45k | id6->contents[1] = ordinal >> 8; | 990 | | | 991 | 2.45k | memcpy ((char *) id6->contents + 2, symbol, len); | 992 | 2.45k | id6->contents[len + 2] = '\0'; | 993 | 2.45k | } | 994 | | | 995 | 3.52k | if (import_name_type != IMPORT_ORDINAL) | 996 | 2.45k | { | 997 | 2.45k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 998 | 2.45k | pe_ILF_save_relocs (&vars, id4); | 999 | | | 1000 | 2.45k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1001 | 2.45k | pe_ILF_save_relocs (&vars, id5); | 1002 | 2.45k | } | 1003 | | | 1004 | | /* Create an import symbol. */ | 1005 | 3.52k | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 1006 | 3.52k | imp_sym = vars.sym_ptr_ptr - 1; | 1007 | 3.52k | imp_index = vars.sym_index - 1; | 1008 | | | 1009 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1010 | 3.52k | switch (import_type) | 1011 | 3.52k | { | 1012 | 0 | int i; | 1013 | | | 1014 | 2.86k | case IMPORT_CODE: | 1015 | | /* CODE functions are special, in that they get a trampoline that | 1016 | | jumps to the main import symbol. Create a .text section to hold it. | 1017 | | First we need to look up its contents in the jump table. */ | 1018 | 5.72k | for (i = NUM_ENTRIES (jtab); i--;) | 1019 | 5.72k | { | 1020 | 5.72k | if (jtab[i].size == 0) | 1021 | 2.86k | continue; | 1022 | 2.86k | if (jtab[i].magic == magic) | 1023 | 2.86k | break; | 1024 | 2.86k | } | 1025 | | /* If we did not find a matching entry something is wrong. */ | 1026 | 2.86k | if (i < 0) | 1027 | 0 | abort (); | 1028 | | | 1029 | | /* Create the .text section. */ | 1030 | 2.86k | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1031 | 2.86k | if (text == NULL) | 1032 | 0 | goto error_return; | 1033 | | | 1034 | | /* Copy in the jump code. */ | 1035 | 2.86k | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1036 | | | 1037 | | /* Create a reloc for the data in the text section. */ | 1038 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1039 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1040 | | { | 1041 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1042 | | (struct bfd_symbol **) imp_sym, | 1043 | | imp_index); | 1044 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1045 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1046 | | (struct bfd_symbol **) imp_sym, | 1047 | | imp_index); | 1048 | | } | 1049 | | else | 1050 | | #endif | 1051 | | #ifdef AMD64MAGIC | 1052 | | if (magic == AMD64MAGIC) | 1053 | | { | 1054 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1055 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1056 | | imp_index); | 1057 | | } | 1058 | | else | 1059 | | #endif | 1060 | 2.86k | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1061 | 2.86k | BFD_RELOC_32, (asymbol **) imp_sym, | 1062 | 2.86k | imp_index); | 1063 | | | 1064 | 2.86k | pe_ILF_save_relocs (& vars, text); | 1065 | 2.86k | break; | 1066 | | | 1067 | 659 | case IMPORT_DATA: | 1068 | 659 | break; | 1069 | | | 1070 | 0 | default: | 1071 | | /* XXX code not yet written. */ | 1072 | 0 | abort (); | 1073 | 3.52k | } | 1074 | | | 1075 | | /* Now create a symbol describing the imported value. */ | 1076 | 3.52k | switch (import_type) | 1077 | 3.52k | { | 1078 | 2.86k | case IMPORT_CODE: | 1079 | 2.86k | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1080 | 2.86k | BSF_NOT_AT_END | BSF_FUNCTION); | 1081 | | | 1082 | 2.86k | break; | 1083 | | | 1084 | 659 | case IMPORT_DATA: | 1085 | | /* Nothing to do here. */ | 1086 | 659 | break; | 1087 | | | 1088 | 0 | default: | 1089 | | /* XXX code not yet written. */ | 1090 | 0 | abort (); | 1091 | 3.52k | } | 1092 | | | 1093 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1094 | 3.52k | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1095 | 3.52k | if (ptr) | 1096 | 209 | * ptr = 0; | 1097 | 3.52k | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1098 | 3.52k | if (ptr) | 1099 | 209 | * ptr = '.'; | 1100 | | | 1101 | | /* Initialise the bfd. */ | 1102 | 3.52k | memset (& internal_f, 0, sizeof (internal_f)); | 1103 | | | 1104 | 3.52k | internal_f.f_magic = magic; | 1105 | 3.52k | internal_f.f_symptr = 0; | 1106 | 3.52k | internal_f.f_nsyms = 0; | 1107 | 3.52k | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1108 | | | 1109 | 3.52k | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1110 | 3.52k | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1111 | 0 | goto error_return; | 1112 | | | 1113 | 3.52k | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1114 | 0 | goto error_return; | 1115 | | | 1116 | 3.52k | obj_pe (abfd) = true; | 1117 | | #ifdef THUMBPEMAGIC | 1118 | | if (vars.magic == THUMBPEMAGIC) | 1119 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1120 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1121 | | #endif | 1122 | | | 1123 | | /* Switch from file contents to memory contents. */ | 1124 | 3.52k | bfd_cache_close (abfd); | 1125 | | | 1126 | 3.52k | abfd->iostream = (void *) vars.bim; | 1127 | 3.52k | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1128 | 3.52k | abfd->iovec = &_bfd_memory_iovec; | 1129 | 3.52k | abfd->where = 0; | 1130 | 3.52k | abfd->origin = 0; | 1131 | 3.52k | abfd->size = 0; | 1132 | 3.52k | obj_sym_filepos (abfd) = 0; | 1133 | | | 1134 | | /* Point the bfd at the symbol table. */ | 1135 | 3.52k | obj_symbols (abfd) = vars.sym_cache; | 1136 | 3.52k | abfd->symcount = vars.sym_index; | 1137 | | | 1138 | 3.52k | obj_raw_syments (abfd) = vars.native_syms; | 1139 | 3.52k | obj_raw_syment_count (abfd) = vars.sym_index; | 1140 | | | 1141 | 3.52k | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1142 | 3.52k | obj_coff_keep_syms (abfd) = true; | 1143 | | | 1144 | 3.52k | obj_convert (abfd) = vars.sym_table; | 1145 | 3.52k | obj_conv_table_size (abfd) = vars.sym_index; | 1146 | | | 1147 | 3.52k | obj_coff_strings (abfd) = vars.string_table; | 1148 | 3.52k | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1149 | 3.52k | obj_coff_keep_strings (abfd) = true; | 1150 | | | 1151 | 3.52k | return true; | 1152 | | | 1153 | 216 | error_return: | 1154 | 216 | free (vars.bim->buffer); | 1155 | 216 | free (vars.bim); | 1156 | 216 | return false; | 1157 | 3.52k | } |
pei-x86_64.c:pe_ILF_build_a_bfd Line | Count | Source | 796 | 5.02k | { | 797 | 5.02k | bfd_byte * ptr; | 798 | 5.02k | pe_ILF_vars vars; | 799 | 5.02k | struct internal_filehdr internal_f; | 800 | 5.02k | unsigned int import_type; | 801 | 5.02k | unsigned int import_name_type; | 802 | 5.02k | asection_ptr id4, id5, id6 = NULL, text = NULL; | 803 | 5.02k | coff_symbol_type ** imp_sym; | 804 | 5.02k | unsigned int imp_index; | 805 | 5.02k | intptr_t alignment; | 806 | | | 807 | | /* Decode and verify the types field of the ILF structure. */ | 808 | 5.02k | import_type = types & 0x3; | 809 | 5.02k | import_name_type = (types & 0x1c) >> 2; | 810 | | | 811 | 5.02k | switch (import_type) | 812 | 5.02k | { | 813 | 2.74k | case IMPORT_CODE: | 814 | 4.49k | case IMPORT_DATA: | 815 | 4.49k | break; | 816 | | | 817 | 215 | case IMPORT_CONST: | 818 | | /* XXX code yet to be written. */ | 819 | | /* xgettext:c-format */ | 820 | 215 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 821 | 215 | abfd, import_type); | 822 | 215 | return false; | 823 | | | 824 | 316 | default: | 825 | | /* xgettext:c-format */ | 826 | 316 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 827 | 316 | abfd, import_type); | 828 | 316 | return false; | 829 | 5.02k | } | 830 | | | 831 | 4.49k | switch (import_name_type) | 832 | 4.49k | { | 833 | 1.98k | case IMPORT_ORDINAL: | 834 | 2.39k | case IMPORT_NAME: | 835 | 3.08k | case IMPORT_NAME_NOPREFIX: | 836 | 4.07k | case IMPORT_NAME_UNDECORATE: | 837 | 4.07k | break; | 838 | | | 839 | 421 | default: | 840 | | /* xgettext:c-format */ | 841 | 421 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 842 | 421 | abfd, import_name_type); | 843 | 421 | return false; | 844 | 4.49k | } | 845 | | | 846 | | /* Initialise local variables. | 847 | | | 848 | | Note these are kept in a structure rather than being | 849 | | declared as statics since bfd frowns on global variables. | 850 | | | 851 | | We are going to construct the contents of the BFD in memory, | 852 | | so allocate all the space that we will need right now. */ | 853 | 4.07k | vars.bim | 854 | 4.07k | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 855 | 4.07k | if (vars.bim == NULL) | 856 | 0 | return false; | 857 | | | 858 | 4.07k | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 859 | 4.07k | vars.bim->buffer = ptr; | 860 | 4.07k | vars.bim->size = ILF_DATA_SIZE; | 861 | 4.07k | if (ptr == NULL) | 862 | 0 | goto error_return; | 863 | | | 864 | | /* Initialise the pointers to regions of the memory and the | 865 | | other contents of the pe_ILF_vars structure as well. */ | 866 | 4.07k | vars.sym_cache = (coff_symbol_type *) ptr; | 867 | 4.07k | vars.sym_ptr = (coff_symbol_type *) ptr; | 868 | 4.07k | vars.sym_index = 0; | 869 | 4.07k | ptr += SIZEOF_ILF_SYMS; | 870 | | | 871 | 4.07k | vars.sym_table = (unsigned int *) ptr; | 872 | 4.07k | vars.table_ptr = (unsigned int *) ptr; | 873 | 4.07k | ptr += SIZEOF_ILF_SYM_TABLE; | 874 | | | 875 | 4.07k | vars.native_syms = (combined_entry_type *) ptr; | 876 | 4.07k | vars.native_ptr = (combined_entry_type *) ptr; | 877 | 4.07k | ptr += SIZEOF_ILF_NATIVE_SYMS; | 878 | | | 879 | 4.07k | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 880 | 4.07k | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 881 | 4.07k | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 882 | | | 883 | 4.07k | vars.esym_table = (SYMENT *) ptr; | 884 | 4.07k | vars.esym_ptr = (SYMENT *) ptr; | 885 | 4.07k | ptr += SIZEOF_ILF_EXT_SYMS; | 886 | | | 887 | 4.07k | vars.reltab = (arelent *) ptr; | 888 | 4.07k | vars.relcount = 0; | 889 | 4.07k | ptr += SIZEOF_ILF_RELOCS; | 890 | | | 891 | 4.07k | vars.int_reltab = (struct internal_reloc *) ptr; | 892 | 4.07k | ptr += SIZEOF_ILF_INT_RELOCS; | 893 | | | 894 | 4.07k | vars.string_table = (char *) ptr; | 895 | 4.07k | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 896 | 4.07k | ptr += SIZEOF_ILF_STRINGS; | 897 | 4.07k | vars.end_string_ptr = (char *) ptr; | 898 | | | 899 | | /* The remaining space in bim->buffer is used | 900 | | by the pe_ILF_make_a_section() function. */ | 901 | | | 902 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 903 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 904 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 905 | | alignment. */ | 906 | 4.07k | #if GCC_VERSION >= 3000 | 907 | 4.07k | alignment = __alignof__ (struct coff_section_tdata); | 908 | | #else | 909 | | alignment = 8; | 910 | | #endif | 911 | 4.07k | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 912 | | | 913 | 4.07k | vars.data = ptr; | 914 | 4.07k | vars.abfd = abfd; | 915 | 4.07k | vars.sec_index = 0; | 916 | 4.07k | vars.magic = magic; | 917 | | | 918 | | /* Create the initial .idata$<n> sections: | 919 | | [.idata$2: Import Directory Table -- not needed] | 920 | | .idata$4: Import Lookup Table | 921 | | .idata$5: Import Address Table | 922 | | | 923 | | Note we do not create a .idata$3 section as this is | 924 | | created for us by the linker script. */ | 925 | 4.07k | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 926 | 4.07k | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 927 | 4.07k | if (id4 == NULL || id5 == NULL) | 928 | 0 | goto error_return; | 929 | | | 930 | | /* Fill in the contents of these sections. */ | 931 | 4.07k | if (import_name_type == IMPORT_ORDINAL) | 932 | 1.98k | { | 933 | 1.98k | if (ordinal == 0) | 934 | | /* See PR 20907 for a reproducer. */ | 935 | 315 | goto error_return; | 936 | | | 937 | 1.66k | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64) | 938 | 1.66k | ((unsigned int *) id4->contents)[0] = ordinal; | 939 | 1.66k | ((unsigned int *) id4->contents)[1] = 0x80000000; | 940 | 1.66k | ((unsigned int *) id5->contents)[0] = ordinal; | 941 | 1.66k | ((unsigned int *) id5->contents)[1] = 0x80000000; | 942 | | #else | 943 | | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 944 | | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 945 | | #endif | 946 | 1.66k | } | 947 | 2.09k | else | 948 | 2.09k | { | 949 | 2.09k | char * symbol; | 950 | 2.09k | unsigned int len; | 951 | | | 952 | | /* Create .idata$6 - the Hint Name Table. */ | 953 | 2.09k | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 954 | 2.09k | if (id6 == NULL) | 955 | 0 | goto error_return; | 956 | | | 957 | | /* If necessary, trim the import symbol name. */ | 958 | 2.09k | symbol = symbol_name; | 959 | | | 960 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 961 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 962 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 963 | | of these is used for a symbol. We strip this leading char for | 964 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 965 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 966 | | | 967 | 2.09k | if (import_name_type != IMPORT_NAME) | 968 | 1.68k | { | 969 | 1.68k | char c = symbol[0]; | 970 | | | 971 | | /* Check that we don't remove for targets with empty | 972 | | USER_LABEL_PREFIX the leading underscore. */ | 973 | 1.68k | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 974 | 1.68k | || c == '@' || c == '?') | 975 | 580 | symbol++; | 976 | 1.68k | } | 977 | | | 978 | 2.09k | len = strlen (symbol); | 979 | 2.09k | if (import_name_type == IMPORT_NAME_UNDECORATE) | 980 | 995 | { | 981 | | /* Truncate at the first '@'. */ | 982 | 995 | char *at = strchr (symbol, '@'); | 983 | | | 984 | 995 | if (at != NULL) | 985 | 103 | len = at - symbol; | 986 | 995 | } | 987 | | | 988 | 2.09k | id6->contents[0] = ordinal & 0xff; | 989 | 2.09k | id6->contents[1] = ordinal >> 8; | 990 | | | 991 | 2.09k | memcpy ((char *) id6->contents + 2, symbol, len); | 992 | 2.09k | id6->contents[len + 2] = '\0'; | 993 | 2.09k | } | 994 | | | 995 | 3.76k | if (import_name_type != IMPORT_ORDINAL) | 996 | 2.09k | { | 997 | 2.09k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 998 | 2.09k | pe_ILF_save_relocs (&vars, id4); | 999 | | | 1000 | 2.09k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1001 | 2.09k | pe_ILF_save_relocs (&vars, id5); | 1002 | 2.09k | } | 1003 | | | 1004 | | /* Create an import symbol. */ | 1005 | 3.76k | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 1006 | 3.76k | imp_sym = vars.sym_ptr_ptr - 1; | 1007 | 3.76k | imp_index = vars.sym_index - 1; | 1008 | | | 1009 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1010 | 3.76k | switch (import_type) | 1011 | 3.76k | { | 1012 | 0 | int i; | 1013 | | | 1014 | 2.11k | case IMPORT_CODE: | 1015 | | /* CODE functions are special, in that they get a trampoline that | 1016 | | jumps to the main import symbol. Create a .text section to hold it. | 1017 | | First we need to look up its contents in the jump table. */ | 1018 | 4.23k | for (i = NUM_ENTRIES (jtab); i--;) | 1019 | 4.23k | { | 1020 | 4.23k | if (jtab[i].size == 0) | 1021 | 2.11k | continue; | 1022 | 2.11k | if (jtab[i].magic == magic) | 1023 | 2.11k | break; | 1024 | 2.11k | } | 1025 | | /* If we did not find a matching entry something is wrong. */ | 1026 | 2.11k | if (i < 0) | 1027 | 0 | abort (); | 1028 | | | 1029 | | /* Create the .text section. */ | 1030 | 2.11k | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1031 | 2.11k | if (text == NULL) | 1032 | 0 | goto error_return; | 1033 | | | 1034 | | /* Copy in the jump code. */ | 1035 | 2.11k | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1036 | | | 1037 | | /* Create a reloc for the data in the text section. */ | 1038 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1039 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1040 | | { | 1041 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1042 | | (struct bfd_symbol **) imp_sym, | 1043 | | imp_index); | 1044 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1045 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1046 | | (struct bfd_symbol **) imp_sym, | 1047 | | imp_index); | 1048 | | } | 1049 | | else | 1050 | | #endif | 1051 | 2.11k | #ifdef AMD64MAGIC | 1052 | 2.11k | if (magic == AMD64MAGIC) | 1053 | 2.11k | { | 1054 | 2.11k | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1055 | 2.11k | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1056 | 2.11k | imp_index); | 1057 | 2.11k | } | 1058 | 0 | else | 1059 | 0 | #endif | 1060 | 0 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1061 | 0 | BFD_RELOC_32, (asymbol **) imp_sym, | 1062 | 0 | imp_index); | 1063 | | | 1064 | 2.11k | pe_ILF_save_relocs (& vars, text); | 1065 | 2.11k | break; | 1066 | | | 1067 | 1.64k | case IMPORT_DATA: | 1068 | 1.64k | break; | 1069 | | | 1070 | 0 | default: | 1071 | | /* XXX code not yet written. */ | 1072 | 0 | abort (); | 1073 | 3.76k | } | 1074 | | | 1075 | | /* Now create a symbol describing the imported value. */ | 1076 | 3.76k | switch (import_type) | 1077 | 3.76k | { | 1078 | 2.11k | case IMPORT_CODE: | 1079 | 2.11k | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1080 | 2.11k | BSF_NOT_AT_END | BSF_FUNCTION); | 1081 | | | 1082 | 2.11k | break; | 1083 | | | 1084 | 1.64k | case IMPORT_DATA: | 1085 | | /* Nothing to do here. */ | 1086 | 1.64k | break; | 1087 | | | 1088 | 0 | default: | 1089 | | /* XXX code not yet written. */ | 1090 | 0 | abort (); | 1091 | 3.76k | } | 1092 | | | 1093 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1094 | 3.76k | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1095 | 3.76k | if (ptr) | 1096 | 981 | * ptr = 0; | 1097 | 3.76k | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1098 | 3.76k | if (ptr) | 1099 | 981 | * ptr = '.'; | 1100 | | | 1101 | | /* Initialise the bfd. */ | 1102 | 3.76k | memset (& internal_f, 0, sizeof (internal_f)); | 1103 | | | 1104 | 3.76k | internal_f.f_magic = magic; | 1105 | 3.76k | internal_f.f_symptr = 0; | 1106 | 3.76k | internal_f.f_nsyms = 0; | 1107 | 3.76k | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1108 | | | 1109 | 3.76k | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1110 | 3.76k | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1111 | 0 | goto error_return; | 1112 | | | 1113 | 3.76k | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1114 | 0 | goto error_return; | 1115 | | | 1116 | 3.76k | obj_pe (abfd) = true; | 1117 | | #ifdef THUMBPEMAGIC | 1118 | | if (vars.magic == THUMBPEMAGIC) | 1119 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1120 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1121 | | #endif | 1122 | | | 1123 | | /* Switch from file contents to memory contents. */ | 1124 | 3.76k | bfd_cache_close (abfd); | 1125 | | | 1126 | 3.76k | abfd->iostream = (void *) vars.bim; | 1127 | 3.76k | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1128 | 3.76k | abfd->iovec = &_bfd_memory_iovec; | 1129 | 3.76k | abfd->where = 0; | 1130 | 3.76k | abfd->origin = 0; | 1131 | 3.76k | abfd->size = 0; | 1132 | 3.76k | obj_sym_filepos (abfd) = 0; | 1133 | | | 1134 | | /* Point the bfd at the symbol table. */ | 1135 | 3.76k | obj_symbols (abfd) = vars.sym_cache; | 1136 | 3.76k | abfd->symcount = vars.sym_index; | 1137 | | | 1138 | 3.76k | obj_raw_syments (abfd) = vars.native_syms; | 1139 | 3.76k | obj_raw_syment_count (abfd) = vars.sym_index; | 1140 | | | 1141 | 3.76k | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1142 | 3.76k | obj_coff_keep_syms (abfd) = true; | 1143 | | | 1144 | 3.76k | obj_convert (abfd) = vars.sym_table; | 1145 | 3.76k | obj_conv_table_size (abfd) = vars.sym_index; | 1146 | | | 1147 | 3.76k | obj_coff_strings (abfd) = vars.string_table; | 1148 | 3.76k | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1149 | 3.76k | obj_coff_keep_strings (abfd) = true; | 1150 | | | 1151 | 3.76k | return true; | 1152 | | | 1153 | 315 | error_return: | 1154 | 315 | free (vars.bim->buffer); | 1155 | 315 | free (vars.bim); | 1156 | 315 | return false; | 1157 | 3.76k | } |
pei-aarch64.c:pe_ILF_build_a_bfd Line | Count | Source | 796 | 4.17k | { | 797 | 4.17k | bfd_byte * ptr; | 798 | 4.17k | pe_ILF_vars vars; | 799 | 4.17k | struct internal_filehdr internal_f; | 800 | 4.17k | unsigned int import_type; | 801 | 4.17k | unsigned int import_name_type; | 802 | 4.17k | asection_ptr id4, id5, id6 = NULL, text = NULL; | 803 | 4.17k | coff_symbol_type ** imp_sym; | 804 | 4.17k | unsigned int imp_index; | 805 | 4.17k | intptr_t alignment; | 806 | | | 807 | | /* Decode and verify the types field of the ILF structure. */ | 808 | 4.17k | import_type = types & 0x3; | 809 | 4.17k | import_name_type = (types & 0x1c) >> 2; | 810 | | | 811 | 4.17k | switch (import_type) | 812 | 4.17k | { | 813 | 1.80k | case IMPORT_CODE: | 814 | 3.74k | case IMPORT_DATA: | 815 | 3.74k | break; | 816 | | | 817 | 214 | case IMPORT_CONST: | 818 | | /* XXX code yet to be written. */ | 819 | | /* xgettext:c-format */ | 820 | 214 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 821 | 214 | abfd, import_type); | 822 | 214 | return false; | 823 | | | 824 | 215 | default: | 825 | | /* xgettext:c-format */ | 826 | 215 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 827 | 215 | abfd, import_type); | 828 | 215 | return false; | 829 | 4.17k | } | 830 | | | 831 | 3.74k | switch (import_name_type) | 832 | 3.74k | { | 833 | 1.20k | case IMPORT_ORDINAL: | 834 | 2.16k | case IMPORT_NAME: | 835 | 2.26k | case IMPORT_NAME_NOPREFIX: | 836 | 3.63k | case IMPORT_NAME_UNDECORATE: | 837 | 3.63k | break; | 838 | | | 839 | 113 | default: | 840 | | /* xgettext:c-format */ | 841 | 113 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 842 | 113 | abfd, import_name_type); | 843 | 113 | return false; | 844 | 3.74k | } | 845 | | | 846 | | /* Initialise local variables. | 847 | | | 848 | | Note these are kept in a structure rather than being | 849 | | declared as statics since bfd frowns on global variables. | 850 | | | 851 | | We are going to construct the contents of the BFD in memory, | 852 | | so allocate all the space that we will need right now. */ | 853 | 3.63k | vars.bim | 854 | 3.63k | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 855 | 3.63k | if (vars.bim == NULL) | 856 | 0 | return false; | 857 | | | 858 | 3.63k | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 859 | 3.63k | vars.bim->buffer = ptr; | 860 | 3.63k | vars.bim->size = ILF_DATA_SIZE; | 861 | 3.63k | if (ptr == NULL) | 862 | 0 | goto error_return; | 863 | | | 864 | | /* Initialise the pointers to regions of the memory and the | 865 | | other contents of the pe_ILF_vars structure as well. */ | 866 | 3.63k | vars.sym_cache = (coff_symbol_type *) ptr; | 867 | 3.63k | vars.sym_ptr = (coff_symbol_type *) ptr; | 868 | 3.63k | vars.sym_index = 0; | 869 | 3.63k | ptr += SIZEOF_ILF_SYMS; | 870 | | | 871 | 3.63k | vars.sym_table = (unsigned int *) ptr; | 872 | 3.63k | vars.table_ptr = (unsigned int *) ptr; | 873 | 3.63k | ptr += SIZEOF_ILF_SYM_TABLE; | 874 | | | 875 | 3.63k | vars.native_syms = (combined_entry_type *) ptr; | 876 | 3.63k | vars.native_ptr = (combined_entry_type *) ptr; | 877 | 3.63k | ptr += SIZEOF_ILF_NATIVE_SYMS; | 878 | | | 879 | 3.63k | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 880 | 3.63k | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 881 | 3.63k | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 882 | | | 883 | 3.63k | vars.esym_table = (SYMENT *) ptr; | 884 | 3.63k | vars.esym_ptr = (SYMENT *) ptr; | 885 | 3.63k | ptr += SIZEOF_ILF_EXT_SYMS; | 886 | | | 887 | 3.63k | vars.reltab = (arelent *) ptr; | 888 | 3.63k | vars.relcount = 0; | 889 | 3.63k | ptr += SIZEOF_ILF_RELOCS; | 890 | | | 891 | 3.63k | vars.int_reltab = (struct internal_reloc *) ptr; | 892 | 3.63k | ptr += SIZEOF_ILF_INT_RELOCS; | 893 | | | 894 | 3.63k | vars.string_table = (char *) ptr; | 895 | 3.63k | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 896 | 3.63k | ptr += SIZEOF_ILF_STRINGS; | 897 | 3.63k | vars.end_string_ptr = (char *) ptr; | 898 | | | 899 | | /* The remaining space in bim->buffer is used | 900 | | by the pe_ILF_make_a_section() function. */ | 901 | | | 902 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 903 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 904 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 905 | | alignment. */ | 906 | 3.63k | #if GCC_VERSION >= 3000 | 907 | 3.63k | alignment = __alignof__ (struct coff_section_tdata); | 908 | | #else | 909 | | alignment = 8; | 910 | | #endif | 911 | 3.63k | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 912 | | | 913 | 3.63k | vars.data = ptr; | 914 | 3.63k | vars.abfd = abfd; | 915 | 3.63k | vars.sec_index = 0; | 916 | 3.63k | vars.magic = magic; | 917 | | | 918 | | /* Create the initial .idata$<n> sections: | 919 | | [.idata$2: Import Directory Table -- not needed] | 920 | | .idata$4: Import Lookup Table | 921 | | .idata$5: Import Address Table | 922 | | | 923 | | Note we do not create a .idata$3 section as this is | 924 | | created for us by the linker script. */ | 925 | 3.63k | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 926 | 3.63k | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 927 | 3.63k | if (id4 == NULL || id5 == NULL) | 928 | 0 | goto error_return; | 929 | | | 930 | | /* Fill in the contents of these sections. */ | 931 | 3.63k | if (import_name_type == IMPORT_ORDINAL) | 932 | 1.20k | { | 933 | 1.20k | if (ordinal == 0) | 934 | | /* See PR 20907 for a reproducer. */ | 935 | 114 | goto error_return; | 936 | | | 937 | 1.09k | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64) | 938 | 1.09k | ((unsigned int *) id4->contents)[0] = ordinal; | 939 | 1.09k | ((unsigned int *) id4->contents)[1] = 0x80000000; | 940 | 1.09k | ((unsigned int *) id5->contents)[0] = ordinal; | 941 | 1.09k | ((unsigned int *) id5->contents)[1] = 0x80000000; | 942 | | #else | 943 | | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 944 | | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 945 | | #endif | 946 | 1.09k | } | 947 | 2.42k | else | 948 | 2.42k | { | 949 | 2.42k | char * symbol; | 950 | 2.42k | unsigned int len; | 951 | | | 952 | | /* Create .idata$6 - the Hint Name Table. */ | 953 | 2.42k | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 954 | 2.42k | if (id6 == NULL) | 955 | 0 | goto error_return; | 956 | | | 957 | | /* If necessary, trim the import symbol name. */ | 958 | 2.42k | symbol = symbol_name; | 959 | | | 960 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 961 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 962 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 963 | | of these is used for a symbol. We strip this leading char for | 964 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 965 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 966 | | | 967 | 2.42k | if (import_name_type != IMPORT_NAME) | 968 | 1.47k | { | 969 | 1.47k | char c = symbol[0]; | 970 | | | 971 | | /* Check that we don't remove for targets with empty | 972 | | USER_LABEL_PREFIX the leading underscore. */ | 973 | 1.47k | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 974 | 1.47k | || c == '@' || c == '?') | 975 | 715 | symbol++; | 976 | 1.47k | } | 977 | | | 978 | 2.42k | len = strlen (symbol); | 979 | 2.42k | if (import_name_type == IMPORT_NAME_UNDECORATE) | 980 | 1.36k | { | 981 | | /* Truncate at the first '@'. */ | 982 | 1.36k | char *at = strchr (symbol, '@'); | 983 | | | 984 | 1.36k | if (at != NULL) | 985 | 3 | len = at - symbol; | 986 | 1.36k | } | 987 | | | 988 | 2.42k | id6->contents[0] = ordinal & 0xff; | 989 | 2.42k | id6->contents[1] = ordinal >> 8; | 990 | | | 991 | 2.42k | memcpy ((char *) id6->contents + 2, symbol, len); | 992 | 2.42k | id6->contents[len + 2] = '\0'; | 993 | 2.42k | } | 994 | | | 995 | 3.51k | if (import_name_type != IMPORT_ORDINAL) | 996 | 2.42k | { | 997 | 2.42k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 998 | 2.42k | pe_ILF_save_relocs (&vars, id4); | 999 | | | 1000 | 2.42k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1001 | 2.42k | pe_ILF_save_relocs (&vars, id5); | 1002 | 2.42k | } | 1003 | | | 1004 | | /* Create an import symbol. */ | 1005 | 3.51k | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 1006 | 3.51k | imp_sym = vars.sym_ptr_ptr - 1; | 1007 | 3.51k | imp_index = vars.sym_index - 1; | 1008 | | | 1009 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1010 | 3.51k | switch (import_type) | 1011 | 3.51k | { | 1012 | 0 | int i; | 1013 | | | 1014 | 1.58k | case IMPORT_CODE: | 1015 | | /* CODE functions are special, in that they get a trampoline that | 1016 | | jumps to the main import symbol. Create a .text section to hold it. | 1017 | | First we need to look up its contents in the jump table. */ | 1018 | 3.16k | for (i = NUM_ENTRIES (jtab); i--;) | 1019 | 3.16k | { | 1020 | 3.16k | if (jtab[i].size == 0) | 1021 | 1.58k | continue; | 1022 | 1.58k | if (jtab[i].magic == magic) | 1023 | 1.58k | break; | 1024 | 1.58k | } | 1025 | | /* If we did not find a matching entry something is wrong. */ | 1026 | 1.58k | if (i < 0) | 1027 | 0 | abort (); | 1028 | | | 1029 | | /* Create the .text section. */ | 1030 | 1.58k | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1031 | 1.58k | if (text == NULL) | 1032 | 0 | goto error_return; | 1033 | | | 1034 | | /* Copy in the jump code. */ | 1035 | 1.58k | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1036 | | | 1037 | | /* Create a reloc for the data in the text section. */ | 1038 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1039 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1040 | | { | 1041 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1042 | | (struct bfd_symbol **) imp_sym, | 1043 | | imp_index); | 1044 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1045 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1046 | | (struct bfd_symbol **) imp_sym, | 1047 | | imp_index); | 1048 | | } | 1049 | | else | 1050 | | #endif | 1051 | | #ifdef AMD64MAGIC | 1052 | | if (magic == AMD64MAGIC) | 1053 | | { | 1054 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1055 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1056 | | imp_index); | 1057 | | } | 1058 | | else | 1059 | | #endif | 1060 | 1.58k | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1061 | 1.58k | BFD_RELOC_32, (asymbol **) imp_sym, | 1062 | 1.58k | imp_index); | 1063 | | | 1064 | 1.58k | pe_ILF_save_relocs (& vars, text); | 1065 | 1.58k | break; | 1066 | | | 1067 | 1.93k | case IMPORT_DATA: | 1068 | 1.93k | break; | 1069 | | | 1070 | 0 | default: | 1071 | | /* XXX code not yet written. */ | 1072 | 0 | abort (); | 1073 | 3.51k | } | 1074 | | | 1075 | | /* Now create a symbol describing the imported value. */ | 1076 | 3.51k | switch (import_type) | 1077 | 3.51k | { | 1078 | 1.58k | case IMPORT_CODE: | 1079 | 1.58k | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1080 | 1.58k | BSF_NOT_AT_END | BSF_FUNCTION); | 1081 | | | 1082 | 1.58k | break; | 1083 | | | 1084 | 1.93k | case IMPORT_DATA: | 1085 | | /* Nothing to do here. */ | 1086 | 1.93k | break; | 1087 | | | 1088 | 0 | default: | 1089 | | /* XXX code not yet written. */ | 1090 | 0 | abort (); | 1091 | 3.51k | } | 1092 | | | 1093 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1094 | 3.51k | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1095 | 3.51k | if (ptr) | 1096 | 240 | * ptr = 0; | 1097 | 3.51k | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1098 | 3.51k | if (ptr) | 1099 | 240 | * ptr = '.'; | 1100 | | | 1101 | | /* Initialise the bfd. */ | 1102 | 3.51k | memset (& internal_f, 0, sizeof (internal_f)); | 1103 | | | 1104 | 3.51k | internal_f.f_magic = magic; | 1105 | 3.51k | internal_f.f_symptr = 0; | 1106 | 3.51k | internal_f.f_nsyms = 0; | 1107 | 3.51k | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1108 | | | 1109 | 3.51k | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1110 | 3.51k | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1111 | 0 | goto error_return; | 1112 | | | 1113 | 3.51k | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1114 | 0 | goto error_return; | 1115 | | | 1116 | 3.51k | obj_pe (abfd) = true; | 1117 | | #ifdef THUMBPEMAGIC | 1118 | | if (vars.magic == THUMBPEMAGIC) | 1119 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1120 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1121 | | #endif | 1122 | | | 1123 | | /* Switch from file contents to memory contents. */ | 1124 | 3.51k | bfd_cache_close (abfd); | 1125 | | | 1126 | 3.51k | abfd->iostream = (void *) vars.bim; | 1127 | 3.51k | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1128 | 3.51k | abfd->iovec = &_bfd_memory_iovec; | 1129 | 3.51k | abfd->where = 0; | 1130 | 3.51k | abfd->origin = 0; | 1131 | 3.51k | abfd->size = 0; | 1132 | 3.51k | obj_sym_filepos (abfd) = 0; | 1133 | | | 1134 | | /* Point the bfd at the symbol table. */ | 1135 | 3.51k | obj_symbols (abfd) = vars.sym_cache; | 1136 | 3.51k | abfd->symcount = vars.sym_index; | 1137 | | | 1138 | 3.51k | obj_raw_syments (abfd) = vars.native_syms; | 1139 | 3.51k | obj_raw_syment_count (abfd) = vars.sym_index; | 1140 | | | 1141 | 3.51k | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1142 | 3.51k | obj_coff_keep_syms (abfd) = true; | 1143 | | | 1144 | 3.51k | obj_convert (abfd) = vars.sym_table; | 1145 | 3.51k | obj_conv_table_size (abfd) = vars.sym_index; | 1146 | | | 1147 | 3.51k | obj_coff_strings (abfd) = vars.string_table; | 1148 | 3.51k | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1149 | 3.51k | obj_coff_keep_strings (abfd) = true; | 1150 | | | 1151 | 3.51k | return true; | 1152 | | | 1153 | 114 | error_return: | 1154 | 114 | free (vars.bim->buffer); | 1155 | 114 | free (vars.bim); | 1156 | 114 | return false; | 1157 | 3.51k | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_build_a_bfd pei-loongarch64.c:pe_ILF_build_a_bfd Line | Count | Source | 796 | 2.87k | { | 797 | 2.87k | bfd_byte * ptr; | 798 | 2.87k | pe_ILF_vars vars; | 799 | 2.87k | struct internal_filehdr internal_f; | 800 | 2.87k | unsigned int import_type; | 801 | 2.87k | unsigned int import_name_type; | 802 | 2.87k | asection_ptr id4, id5, id6 = NULL, text = NULL; | 803 | 2.87k | coff_symbol_type ** imp_sym; | 804 | 2.87k | unsigned int imp_index; | 805 | 2.87k | intptr_t alignment; | 806 | | | 807 | | /* Decode and verify the types field of the ILF structure. */ | 808 | 2.87k | import_type = types & 0x3; | 809 | 2.87k | import_name_type = (types & 0x1c) >> 2; | 810 | | | 811 | 2.87k | switch (import_type) | 812 | 2.87k | { | 813 | 822 | case IMPORT_CODE: | 814 | 2.24k | case IMPORT_DATA: | 815 | 2.24k | break; | 816 | | | 817 | 316 | case IMPORT_CONST: | 818 | | /* XXX code yet to be written. */ | 819 | | /* xgettext:c-format */ | 820 | 316 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 821 | 316 | abfd, import_type); | 822 | 316 | return false; | 823 | | | 824 | 313 | default: | 825 | | /* xgettext:c-format */ | 826 | 313 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 827 | 313 | abfd, import_type); | 828 | 313 | return false; | 829 | 2.87k | } | 830 | | | 831 | 2.24k | switch (import_name_type) | 832 | 2.24k | { | 833 | 877 | case IMPORT_ORDINAL: | 834 | 1.01k | case IMPORT_NAME: | 835 | 1.02k | case IMPORT_NAME_NOPREFIX: | 836 | 1.91k | case IMPORT_NAME_UNDECORATE: | 837 | 1.91k | break; | 838 | | | 839 | 325 | default: | 840 | | /* xgettext:c-format */ | 841 | 325 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 842 | 325 | abfd, import_name_type); | 843 | 325 | return false; | 844 | 2.24k | } | 845 | | | 846 | | /* Initialise local variables. | 847 | | | 848 | | Note these are kept in a structure rather than being | 849 | | declared as statics since bfd frowns on global variables. | 850 | | | 851 | | We are going to construct the contents of the BFD in memory, | 852 | | so allocate all the space that we will need right now. */ | 853 | 1.91k | vars.bim | 854 | 1.91k | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 855 | 1.91k | if (vars.bim == NULL) | 856 | 0 | return false; | 857 | | | 858 | 1.91k | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 859 | 1.91k | vars.bim->buffer = ptr; | 860 | 1.91k | vars.bim->size = ILF_DATA_SIZE; | 861 | 1.91k | if (ptr == NULL) | 862 | 0 | goto error_return; | 863 | | | 864 | | /* Initialise the pointers to regions of the memory and the | 865 | | other contents of the pe_ILF_vars structure as well. */ | 866 | 1.91k | vars.sym_cache = (coff_symbol_type *) ptr; | 867 | 1.91k | vars.sym_ptr = (coff_symbol_type *) ptr; | 868 | 1.91k | vars.sym_index = 0; | 869 | 1.91k | ptr += SIZEOF_ILF_SYMS; | 870 | | | 871 | 1.91k | vars.sym_table = (unsigned int *) ptr; | 872 | 1.91k | vars.table_ptr = (unsigned int *) ptr; | 873 | 1.91k | ptr += SIZEOF_ILF_SYM_TABLE; | 874 | | | 875 | 1.91k | vars.native_syms = (combined_entry_type *) ptr; | 876 | 1.91k | vars.native_ptr = (combined_entry_type *) ptr; | 877 | 1.91k | ptr += SIZEOF_ILF_NATIVE_SYMS; | 878 | | | 879 | 1.91k | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 880 | 1.91k | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 881 | 1.91k | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 882 | | | 883 | 1.91k | vars.esym_table = (SYMENT *) ptr; | 884 | 1.91k | vars.esym_ptr = (SYMENT *) ptr; | 885 | 1.91k | ptr += SIZEOF_ILF_EXT_SYMS; | 886 | | | 887 | 1.91k | vars.reltab = (arelent *) ptr; | 888 | 1.91k | vars.relcount = 0; | 889 | 1.91k | ptr += SIZEOF_ILF_RELOCS; | 890 | | | 891 | 1.91k | vars.int_reltab = (struct internal_reloc *) ptr; | 892 | 1.91k | ptr += SIZEOF_ILF_INT_RELOCS; | 893 | | | 894 | 1.91k | vars.string_table = (char *) ptr; | 895 | 1.91k | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 896 | 1.91k | ptr += SIZEOF_ILF_STRINGS; | 897 | 1.91k | vars.end_string_ptr = (char *) ptr; | 898 | | | 899 | | /* The remaining space in bim->buffer is used | 900 | | by the pe_ILF_make_a_section() function. */ | 901 | | | 902 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 903 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 904 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 905 | | alignment. */ | 906 | 1.91k | #if GCC_VERSION >= 3000 | 907 | 1.91k | alignment = __alignof__ (struct coff_section_tdata); | 908 | | #else | 909 | | alignment = 8; | 910 | | #endif | 911 | 1.91k | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 912 | | | 913 | 1.91k | vars.data = ptr; | 914 | 1.91k | vars.abfd = abfd; | 915 | 1.91k | vars.sec_index = 0; | 916 | 1.91k | vars.magic = magic; | 917 | | | 918 | | /* Create the initial .idata$<n> sections: | 919 | | [.idata$2: Import Directory Table -- not needed] | 920 | | .idata$4: Import Lookup Table | 921 | | .idata$5: Import Address Table | 922 | | | 923 | | Note we do not create a .idata$3 section as this is | 924 | | created for us by the linker script. */ | 925 | 1.91k | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 926 | 1.91k | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 927 | 1.91k | if (id4 == NULL || id5 == NULL) | 928 | 0 | goto error_return; | 929 | | | 930 | | /* Fill in the contents of these sections. */ | 931 | 1.91k | if (import_name_type == IMPORT_ORDINAL) | 932 | 877 | { | 933 | 877 | if (ordinal == 0) | 934 | | /* See PR 20907 for a reproducer. */ | 935 | 115 | goto error_return; | 936 | | | 937 | 762 | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64) | 938 | 762 | ((unsigned int *) id4->contents)[0] = ordinal; | 939 | 762 | ((unsigned int *) id4->contents)[1] = 0x80000000; | 940 | 762 | ((unsigned int *) id5->contents)[0] = ordinal; | 941 | 762 | ((unsigned int *) id5->contents)[1] = 0x80000000; | 942 | | #else | 943 | | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 944 | | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 945 | | #endif | 946 | 762 | } | 947 | 1.03k | else | 948 | 1.03k | { | 949 | 1.03k | char * symbol; | 950 | 1.03k | unsigned int len; | 951 | | | 952 | | /* Create .idata$6 - the Hint Name Table. */ | 953 | 1.03k | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 954 | 1.03k | if (id6 == NULL) | 955 | 0 | goto error_return; | 956 | | | 957 | | /* If necessary, trim the import symbol name. */ | 958 | 1.03k | symbol = symbol_name; | 959 | | | 960 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 961 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 962 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 963 | | of these is used for a symbol. We strip this leading char for | 964 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 965 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 966 | | | 967 | 1.03k | if (import_name_type != IMPORT_NAME) | 968 | 899 | { | 969 | 899 | char c = symbol[0]; | 970 | | | 971 | | /* Check that we don't remove for targets with empty | 972 | | USER_LABEL_PREFIX the leading underscore. */ | 973 | 899 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 974 | 899 | || c == '@' || c == '?') | 975 | 411 | symbol++; | 976 | 899 | } | 977 | | | 978 | 1.03k | len = strlen (symbol); | 979 | 1.03k | if (import_name_type == IMPORT_NAME_UNDECORATE) | 980 | 891 | { | 981 | | /* Truncate at the first '@'. */ | 982 | 891 | char *at = strchr (symbol, '@'); | 983 | | | 984 | 891 | if (at != NULL) | 985 | 136 | len = at - symbol; | 986 | 891 | } | 987 | | | 988 | 1.03k | id6->contents[0] = ordinal & 0xff; | 989 | 1.03k | id6->contents[1] = ordinal >> 8; | 990 | | | 991 | 1.03k | memcpy ((char *) id6->contents + 2, symbol, len); | 992 | 1.03k | id6->contents[len + 2] = '\0'; | 993 | 1.03k | } | 994 | | | 995 | 1.80k | if (import_name_type != IMPORT_ORDINAL) | 996 | 1.03k | { | 997 | 1.03k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 998 | 1.03k | pe_ILF_save_relocs (&vars, id4); | 999 | | | 1000 | 1.03k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1001 | 1.03k | pe_ILF_save_relocs (&vars, id5); | 1002 | 1.03k | } | 1003 | | | 1004 | | /* Create an import symbol. */ | 1005 | 1.80k | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 1006 | 1.80k | imp_sym = vars.sym_ptr_ptr - 1; | 1007 | 1.80k | imp_index = vars.sym_index - 1; | 1008 | | | 1009 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1010 | 1.80k | switch (import_type) | 1011 | 1.80k | { | 1012 | 0 | int i; | 1013 | | | 1014 | 600 | case IMPORT_CODE: | 1015 | | /* CODE functions are special, in that they get a trampoline that | 1016 | | jumps to the main import symbol. Create a .text section to hold it. | 1017 | | First we need to look up its contents in the jump table. */ | 1018 | 1.20k | for (i = NUM_ENTRIES (jtab); i--;) | 1019 | 1.20k | { | 1020 | 1.20k | if (jtab[i].size == 0) | 1021 | 600 | continue; | 1022 | 600 | if (jtab[i].magic == magic) | 1023 | 600 | break; | 1024 | 600 | } | 1025 | | /* If we did not find a matching entry something is wrong. */ | 1026 | 600 | if (i < 0) | 1027 | 0 | abort (); | 1028 | | | 1029 | | /* Create the .text section. */ | 1030 | 600 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1031 | 600 | if (text == NULL) | 1032 | 0 | goto error_return; | 1033 | | | 1034 | | /* Copy in the jump code. */ | 1035 | 600 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1036 | | | 1037 | | /* Create a reloc for the data in the text section. */ | 1038 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1039 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1040 | | { | 1041 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1042 | | (struct bfd_symbol **) imp_sym, | 1043 | | imp_index); | 1044 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1045 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1046 | | (struct bfd_symbol **) imp_sym, | 1047 | | imp_index); | 1048 | | } | 1049 | | else | 1050 | | #endif | 1051 | | #ifdef AMD64MAGIC | 1052 | | if (magic == AMD64MAGIC) | 1053 | | { | 1054 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1055 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1056 | | imp_index); | 1057 | | } | 1058 | | else | 1059 | | #endif | 1060 | 600 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1061 | 600 | BFD_RELOC_32, (asymbol **) imp_sym, | 1062 | 600 | imp_index); | 1063 | | | 1064 | 600 | pe_ILF_save_relocs (& vars, text); | 1065 | 600 | break; | 1066 | | | 1067 | 1.20k | case IMPORT_DATA: | 1068 | 1.20k | break; | 1069 | | | 1070 | 0 | default: | 1071 | | /* XXX code not yet written. */ | 1072 | 0 | abort (); | 1073 | 1.80k | } | 1074 | | | 1075 | | /* Now create a symbol describing the imported value. */ | 1076 | 1.80k | switch (import_type) | 1077 | 1.80k | { | 1078 | 600 | case IMPORT_CODE: | 1079 | 600 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1080 | 600 | BSF_NOT_AT_END | BSF_FUNCTION); | 1081 | | | 1082 | 600 | break; | 1083 | | | 1084 | 1.20k | case IMPORT_DATA: | 1085 | | /* Nothing to do here. */ | 1086 | 1.20k | break; | 1087 | | | 1088 | 0 | default: | 1089 | | /* XXX code not yet written. */ | 1090 | 0 | abort (); | 1091 | 1.80k | } | 1092 | | | 1093 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1094 | 1.80k | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1095 | 1.80k | if (ptr) | 1096 | 413 | * ptr = 0; | 1097 | 1.80k | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1098 | 1.80k | if (ptr) | 1099 | 413 | * ptr = '.'; | 1100 | | | 1101 | | /* Initialise the bfd. */ | 1102 | 1.80k | memset (& internal_f, 0, sizeof (internal_f)); | 1103 | | | 1104 | 1.80k | internal_f.f_magic = magic; | 1105 | 1.80k | internal_f.f_symptr = 0; | 1106 | 1.80k | internal_f.f_nsyms = 0; | 1107 | 1.80k | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1108 | | | 1109 | 1.80k | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1110 | 1.80k | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1111 | 0 | goto error_return; | 1112 | | | 1113 | 1.80k | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1114 | 0 | goto error_return; | 1115 | | | 1116 | 1.80k | obj_pe (abfd) = true; | 1117 | | #ifdef THUMBPEMAGIC | 1118 | | if (vars.magic == THUMBPEMAGIC) | 1119 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1120 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1121 | | #endif | 1122 | | | 1123 | | /* Switch from file contents to memory contents. */ | 1124 | 1.80k | bfd_cache_close (abfd); | 1125 | | | 1126 | 1.80k | abfd->iostream = (void *) vars.bim; | 1127 | 1.80k | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1128 | 1.80k | abfd->iovec = &_bfd_memory_iovec; | 1129 | 1.80k | abfd->where = 0; | 1130 | 1.80k | abfd->origin = 0; | 1131 | 1.80k | abfd->size = 0; | 1132 | 1.80k | obj_sym_filepos (abfd) = 0; | 1133 | | | 1134 | | /* Point the bfd at the symbol table. */ | 1135 | 1.80k | obj_symbols (abfd) = vars.sym_cache; | 1136 | 1.80k | abfd->symcount = vars.sym_index; | 1137 | | | 1138 | 1.80k | obj_raw_syments (abfd) = vars.native_syms; | 1139 | 1.80k | obj_raw_syment_count (abfd) = vars.sym_index; | 1140 | | | 1141 | 1.80k | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1142 | 1.80k | obj_coff_keep_syms (abfd) = true; | 1143 | | | 1144 | 1.80k | obj_convert (abfd) = vars.sym_table; | 1145 | 1.80k | obj_conv_table_size (abfd) = vars.sym_index; | 1146 | | | 1147 | 1.80k | obj_coff_strings (abfd) = vars.string_table; | 1148 | 1.80k | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1149 | 1.80k | obj_coff_keep_strings (abfd) = true; | 1150 | | | 1151 | 1.80k | return true; | 1152 | | | 1153 | 115 | error_return: | 1154 | 115 | free (vars.bim->buffer); | 1155 | 115 | free (vars.bim); | 1156 | 115 | return false; | 1157 | 1.80k | } |
pei-riscv64.c:pe_ILF_build_a_bfd Line | Count | Source | 796 | 866 | { | 797 | 866 | bfd_byte * ptr; | 798 | 866 | pe_ILF_vars vars; | 799 | 866 | struct internal_filehdr internal_f; | 800 | 866 | unsigned int import_type; | 801 | 866 | unsigned int import_name_type; | 802 | 866 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 803 | 866 | coff_symbol_type ** imp_sym; | 804 | 866 | unsigned int imp_index; | 805 | 866 | intptr_t alignment; | 806 | | | 807 | | /* Decode and verify the types field of the ILF structure. */ | 808 | 866 | import_type = types & 0x3; | 809 | 866 | import_name_type = (types & 0x1c) >> 2; | 810 | | | 811 | 866 | switch (import_type) | 812 | 866 | { | 813 | 372 | case IMPORT_CODE: | 814 | 745 | case IMPORT_DATA: | 815 | 745 | break; | 816 | | | 817 | 9 | case IMPORT_CONST: | 818 | | /* XXX code yet to be written. */ | 819 | | /* xgettext:c-format */ | 820 | 9 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 821 | 9 | abfd, import_type); | 822 | 9 | return false; | 823 | | | 824 | 112 | default: | 825 | | /* xgettext:c-format */ | 826 | 112 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 827 | 112 | abfd, import_type); | 828 | 112 | return false; | 829 | 866 | } | 830 | | | 831 | 745 | switch (import_name_type) | 832 | 745 | { | 833 | 262 | case IMPORT_ORDINAL: | 834 | 368 | case IMPORT_NAME: | 835 | 610 | case IMPORT_NAME_NOPREFIX: | 836 | 630 | case IMPORT_NAME_UNDECORATE: | 837 | 630 | break; | 838 | | | 839 | 115 | default: | 840 | | /* xgettext:c-format */ | 841 | 115 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 842 | 115 | abfd, import_name_type); | 843 | 115 | return false; | 844 | 745 | } | 845 | | | 846 | | /* Initialise local variables. | 847 | | | 848 | | Note these are kept in a structure rather than being | 849 | | declared as statics since bfd frowns on global variables. | 850 | | | 851 | | We are going to construct the contents of the BFD in memory, | 852 | | so allocate all the space that we will need right now. */ | 853 | 630 | vars.bim | 854 | 630 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 855 | 630 | if (vars.bim == NULL) | 856 | 0 | return false; | 857 | | | 858 | 630 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 859 | 630 | vars.bim->buffer = ptr; | 860 | 630 | vars.bim->size = ILF_DATA_SIZE; | 861 | 630 | if (ptr == NULL) | 862 | 0 | goto error_return; | 863 | | | 864 | | /* Initialise the pointers to regions of the memory and the | 865 | | other contents of the pe_ILF_vars structure as well. */ | 866 | 630 | vars.sym_cache = (coff_symbol_type *) ptr; | 867 | 630 | vars.sym_ptr = (coff_symbol_type *) ptr; | 868 | 630 | vars.sym_index = 0; | 869 | 630 | ptr += SIZEOF_ILF_SYMS; | 870 | | | 871 | 630 | vars.sym_table = (unsigned int *) ptr; | 872 | 630 | vars.table_ptr = (unsigned int *) ptr; | 873 | 630 | ptr += SIZEOF_ILF_SYM_TABLE; | 874 | | | 875 | 630 | vars.native_syms = (combined_entry_type *) ptr; | 876 | 630 | vars.native_ptr = (combined_entry_type *) ptr; | 877 | 630 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 878 | | | 879 | 630 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 880 | 630 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 881 | 630 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 882 | | | 883 | 630 | vars.esym_table = (SYMENT *) ptr; | 884 | 630 | vars.esym_ptr = (SYMENT *) ptr; | 885 | 630 | ptr += SIZEOF_ILF_EXT_SYMS; | 886 | | | 887 | 630 | vars.reltab = (arelent *) ptr; | 888 | 630 | vars.relcount = 0; | 889 | 630 | ptr += SIZEOF_ILF_RELOCS; | 890 | | | 891 | 630 | vars.int_reltab = (struct internal_reloc *) ptr; | 892 | 630 | ptr += SIZEOF_ILF_INT_RELOCS; | 893 | | | 894 | 630 | vars.string_table = (char *) ptr; | 895 | 630 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 896 | 630 | ptr += SIZEOF_ILF_STRINGS; | 897 | 630 | vars.end_string_ptr = (char *) ptr; | 898 | | | 899 | | /* The remaining space in bim->buffer is used | 900 | | by the pe_ILF_make_a_section() function. */ | 901 | | | 902 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 903 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 904 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 905 | | alignment. */ | 906 | 630 | #if GCC_VERSION >= 3000 | 907 | 630 | alignment = __alignof__ (struct coff_section_tdata); | 908 | | #else | 909 | | alignment = 8; | 910 | | #endif | 911 | 630 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 912 | | | 913 | 630 | vars.data = ptr; | 914 | 630 | vars.abfd = abfd; | 915 | 630 | vars.sec_index = 0; | 916 | 630 | vars.magic = magic; | 917 | | | 918 | | /* Create the initial .idata$<n> sections: | 919 | | [.idata$2: Import Directory Table -- not needed] | 920 | | .idata$4: Import Lookup Table | 921 | | .idata$5: Import Address Table | 922 | | | 923 | | Note we do not create a .idata$3 section as this is | 924 | | created for us by the linker script. */ | 925 | 630 | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 926 | 630 | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 927 | 630 | if (id4 == NULL || id5 == NULL) | 928 | 0 | goto error_return; | 929 | | | 930 | | /* Fill in the contents of these sections. */ | 931 | 630 | if (import_name_type == IMPORT_ORDINAL) | 932 | 262 | { | 933 | 262 | if (ordinal == 0) | 934 | | /* See PR 20907 for a reproducer. */ | 935 | 11 | goto error_return; | 936 | | | 937 | 251 | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64) | 938 | 251 | ((unsigned int *) id4->contents)[0] = ordinal; | 939 | 251 | ((unsigned int *) id4->contents)[1] = 0x80000000; | 940 | 251 | ((unsigned int *) id5->contents)[0] = ordinal; | 941 | 251 | ((unsigned int *) id5->contents)[1] = 0x80000000; | 942 | | #else | 943 | | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 944 | | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 945 | | #endif | 946 | 251 | } | 947 | 368 | else | 948 | 368 | { | 949 | 368 | char * symbol; | 950 | 368 | unsigned int len; | 951 | | | 952 | | /* Create .idata$6 - the Hint Name Table. */ | 953 | 368 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 954 | 368 | if (id6 == NULL) | 955 | 0 | goto error_return; | 956 | | | 957 | | /* If necessary, trim the import symbol name. */ | 958 | 368 | symbol = symbol_name; | 959 | | | 960 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 961 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 962 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 963 | | of these is used for a symbol. We strip this leading char for | 964 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 965 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 966 | | | 967 | 368 | if (import_name_type != IMPORT_NAME) | 968 | 262 | { | 969 | 262 | char c = symbol[0]; | 970 | | | 971 | | /* Check that we don't remove for targets with empty | 972 | | USER_LABEL_PREFIX the leading underscore. */ | 973 | 262 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 974 | 262 | || c == '@' || c == '?') | 975 | 6 | symbol++; | 976 | 262 | } | 977 | | | 978 | 368 | len = strlen (symbol); | 979 | 368 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 980 | 20 | { | 981 | | /* Truncate at the first '@'. */ | 982 | 20 | char *at = strchr (symbol, '@'); | 983 | | | 984 | 20 | if (at != NULL) | 985 | 3 | len = at - symbol; | 986 | 20 | } | 987 | | | 988 | 368 | id6->contents[0] = ordinal & 0xff; | 989 | 368 | id6->contents[1] = ordinal >> 8; | 990 | | | 991 | 368 | memcpy ((char *) id6->contents + 2, symbol, len); | 992 | 368 | id6->contents[len + 2] = '\0'; | 993 | 368 | } | 994 | | | 995 | 619 | if (import_name_type != IMPORT_ORDINAL) | 996 | 368 | { | 997 | 368 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 998 | 368 | pe_ILF_save_relocs (&vars, id4); | 999 | | | 1000 | 368 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1001 | 368 | pe_ILF_save_relocs (&vars, id5); | 1002 | 368 | } | 1003 | | | 1004 | | /* Create an import symbol. */ | 1005 | 619 | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 1006 | 619 | imp_sym = vars.sym_ptr_ptr - 1; | 1007 | 619 | imp_index = vars.sym_index - 1; | 1008 | | | 1009 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1010 | 619 | switch (import_type) | 1011 | 619 | { | 1012 | 0 | int i; | 1013 | | | 1014 | 254 | case IMPORT_CODE: | 1015 | | /* CODE functions are special, in that they get a trampoline that | 1016 | | jumps to the main import symbol. Create a .text section to hold it. | 1017 | | First we need to look up its contents in the jump table. */ | 1018 | 508 | for (i = NUM_ENTRIES (jtab); i--;) | 1019 | 508 | { | 1020 | 508 | if (jtab[i].size == 0) | 1021 | 254 | continue; | 1022 | 254 | if (jtab[i].magic == magic) | 1023 | 254 | break; | 1024 | 254 | } | 1025 | | /* If we did not find a matching entry something is wrong. */ | 1026 | 254 | if (i < 0) | 1027 | 0 | abort (); | 1028 | | | 1029 | | /* Create the .text section. */ | 1030 | 254 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1031 | 254 | if (text == NULL) | 1032 | 0 | goto error_return; | 1033 | | | 1034 | | /* Copy in the jump code. */ | 1035 | 254 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1036 | | | 1037 | | /* Create a reloc for the data in the text section. */ | 1038 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1039 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1040 | | { | 1041 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1042 | | (struct bfd_symbol **) imp_sym, | 1043 | | imp_index); | 1044 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1045 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1046 | | (struct bfd_symbol **) imp_sym, | 1047 | | imp_index); | 1048 | | } | 1049 | | else | 1050 | | #endif | 1051 | | #ifdef AMD64MAGIC | 1052 | | if (magic == AMD64MAGIC) | 1053 | | { | 1054 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1055 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1056 | | imp_index); | 1057 | | } | 1058 | | else | 1059 | | #endif | 1060 | 254 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1061 | 254 | BFD_RELOC_32, (asymbol **) imp_sym, | 1062 | 254 | imp_index); | 1063 | | | 1064 | 254 | pe_ILF_save_relocs (& vars, text); | 1065 | 254 | break; | 1066 | | | 1067 | 365 | case IMPORT_DATA: | 1068 | 365 | break; | 1069 | | | 1070 | 0 | default: | 1071 | | /* XXX code not yet written. */ | 1072 | 0 | abort (); | 1073 | 619 | } | 1074 | | | 1075 | | /* Now create a symbol describing the imported value. */ | 1076 | 619 | switch (import_type) | 1077 | 619 | { | 1078 | 254 | case IMPORT_CODE: | 1079 | 254 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1080 | 254 | BSF_NOT_AT_END | BSF_FUNCTION); | 1081 | | | 1082 | 254 | break; | 1083 | | | 1084 | 365 | case IMPORT_DATA: | 1085 | | /* Nothing to do here. */ | 1086 | 365 | break; | 1087 | | | 1088 | 0 | default: | 1089 | | /* XXX code not yet written. */ | 1090 | 0 | abort (); | 1091 | 619 | } | 1092 | | | 1093 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1094 | 619 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1095 | 619 | if (ptr) | 1096 | 5 | * ptr = 0; | 1097 | 619 | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1098 | 619 | if (ptr) | 1099 | 5 | * ptr = '.'; | 1100 | | | 1101 | | /* Initialise the bfd. */ | 1102 | 619 | memset (& internal_f, 0, sizeof (internal_f)); | 1103 | | | 1104 | 619 | internal_f.f_magic = magic; | 1105 | 619 | internal_f.f_symptr = 0; | 1106 | 619 | internal_f.f_nsyms = 0; | 1107 | 619 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1108 | | | 1109 | 619 | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1110 | 619 | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1111 | 0 | goto error_return; | 1112 | | | 1113 | 619 | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1114 | 0 | goto error_return; | 1115 | | | 1116 | 619 | obj_pe (abfd) = true; | 1117 | | #ifdef THUMBPEMAGIC | 1118 | | if (vars.magic == THUMBPEMAGIC) | 1119 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1120 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1121 | | #endif | 1122 | | | 1123 | | /* Switch from file contents to memory contents. */ | 1124 | 619 | bfd_cache_close (abfd); | 1125 | | | 1126 | 619 | abfd->iostream = (void *) vars.bim; | 1127 | 619 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1128 | 619 | abfd->iovec = &_bfd_memory_iovec; | 1129 | 619 | abfd->where = 0; | 1130 | 619 | abfd->origin = 0; | 1131 | 619 | abfd->size = 0; | 1132 | 619 | obj_sym_filepos (abfd) = 0; | 1133 | | | 1134 | | /* Point the bfd at the symbol table. */ | 1135 | 619 | obj_symbols (abfd) = vars.sym_cache; | 1136 | 619 | abfd->symcount = vars.sym_index; | 1137 | | | 1138 | 619 | obj_raw_syments (abfd) = vars.native_syms; | 1139 | 619 | obj_raw_syment_count (abfd) = vars.sym_index; | 1140 | | | 1141 | 619 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1142 | 619 | obj_coff_keep_syms (abfd) = true; | 1143 | | | 1144 | 619 | obj_convert (abfd) = vars.sym_table; | 1145 | 619 | obj_conv_table_size (abfd) = vars.sym_index; | 1146 | | | 1147 | 619 | obj_coff_strings (abfd) = vars.string_table; | 1148 | 619 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1149 | 619 | obj_coff_keep_strings (abfd) = true; | 1150 | | | 1151 | 619 | return true; | 1152 | | | 1153 | 11 | error_return: | 1154 | 11 | free (vars.bim->buffer); | 1155 | 11 | free (vars.bim); | 1156 | 11 | return false; | 1157 | 619 | } |
pei-arm-wince.c:pe_ILF_build_a_bfd Line | Count | Source | 796 | 727 | { | 797 | 727 | bfd_byte * ptr; | 798 | 727 | pe_ILF_vars vars; | 799 | 727 | struct internal_filehdr internal_f; | 800 | 727 | unsigned int import_type; | 801 | 727 | unsigned int import_name_type; | 802 | 727 | asection_ptr id4, id5, id6 = NULL, text = NULL; | 803 | 727 | coff_symbol_type ** imp_sym; | 804 | 727 | unsigned int imp_index; | 805 | 727 | intptr_t alignment; | 806 | | | 807 | | /* Decode and verify the types field of the ILF structure. */ | 808 | 727 | import_type = types & 0x3; | 809 | 727 | import_name_type = (types & 0x1c) >> 2; | 810 | | | 811 | 727 | switch (import_type) | 812 | 727 | { | 813 | 161 | case IMPORT_CODE: | 814 | 297 | case IMPORT_DATA: | 815 | 297 | break; | 816 | | | 817 | 116 | case IMPORT_CONST: | 818 | | /* XXX code yet to be written. */ | 819 | | /* xgettext:c-format */ | 820 | 116 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 821 | 116 | abfd, import_type); | 822 | 116 | return false; | 823 | | | 824 | 314 | default: | 825 | | /* xgettext:c-format */ | 826 | 314 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 827 | 314 | abfd, import_type); | 828 | 314 | return false; | 829 | 727 | } | 830 | | | 831 | 297 | switch (import_name_type) | 832 | 297 | { | 833 | 139 | case IMPORT_ORDINAL: | 834 | 151 | case IMPORT_NAME: | 835 | 169 | case IMPORT_NAME_NOPREFIX: | 836 | 185 | case IMPORT_NAME_UNDECORATE: | 837 | 185 | break; | 838 | | | 839 | 112 | default: | 840 | | /* xgettext:c-format */ | 841 | 112 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 842 | 112 | abfd, import_name_type); | 843 | 112 | return false; | 844 | 297 | } | 845 | | | 846 | | /* Initialise local variables. | 847 | | | 848 | | Note these are kept in a structure rather than being | 849 | | declared as statics since bfd frowns on global variables. | 850 | | | 851 | | We are going to construct the contents of the BFD in memory, | 852 | | so allocate all the space that we will need right now. */ | 853 | 185 | vars.bim | 854 | 185 | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 855 | 185 | if (vars.bim == NULL) | 856 | 0 | return false; | 857 | | | 858 | 185 | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 859 | 185 | vars.bim->buffer = ptr; | 860 | 185 | vars.bim->size = ILF_DATA_SIZE; | 861 | 185 | if (ptr == NULL) | 862 | 0 | goto error_return; | 863 | | | 864 | | /* Initialise the pointers to regions of the memory and the | 865 | | other contents of the pe_ILF_vars structure as well. */ | 866 | 185 | vars.sym_cache = (coff_symbol_type *) ptr; | 867 | 185 | vars.sym_ptr = (coff_symbol_type *) ptr; | 868 | 185 | vars.sym_index = 0; | 869 | 185 | ptr += SIZEOF_ILF_SYMS; | 870 | | | 871 | 185 | vars.sym_table = (unsigned int *) ptr; | 872 | 185 | vars.table_ptr = (unsigned int *) ptr; | 873 | 185 | ptr += SIZEOF_ILF_SYM_TABLE; | 874 | | | 875 | 185 | vars.native_syms = (combined_entry_type *) ptr; | 876 | 185 | vars.native_ptr = (combined_entry_type *) ptr; | 877 | 185 | ptr += SIZEOF_ILF_NATIVE_SYMS; | 878 | | | 879 | 185 | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 880 | 185 | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 881 | 185 | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 882 | | | 883 | 185 | vars.esym_table = (SYMENT *) ptr; | 884 | 185 | vars.esym_ptr = (SYMENT *) ptr; | 885 | 185 | ptr += SIZEOF_ILF_EXT_SYMS; | 886 | | | 887 | 185 | vars.reltab = (arelent *) ptr; | 888 | 185 | vars.relcount = 0; | 889 | 185 | ptr += SIZEOF_ILF_RELOCS; | 890 | | | 891 | 185 | vars.int_reltab = (struct internal_reloc *) ptr; | 892 | 185 | ptr += SIZEOF_ILF_INT_RELOCS; | 893 | | | 894 | 185 | vars.string_table = (char *) ptr; | 895 | 185 | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 896 | 185 | ptr += SIZEOF_ILF_STRINGS; | 897 | 185 | vars.end_string_ptr = (char *) ptr; | 898 | | | 899 | | /* The remaining space in bim->buffer is used | 900 | | by the pe_ILF_make_a_section() function. */ | 901 | | | 902 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 903 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 904 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 905 | | alignment. */ | 906 | 185 | #if GCC_VERSION >= 3000 | 907 | 185 | alignment = __alignof__ (struct coff_section_tdata); | 908 | | #else | 909 | | alignment = 8; | 910 | | #endif | 911 | 185 | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 912 | | | 913 | 185 | vars.data = ptr; | 914 | 185 | vars.abfd = abfd; | 915 | 185 | vars.sec_index = 0; | 916 | 185 | vars.magic = magic; | 917 | | | 918 | | /* Create the initial .idata$<n> sections: | 919 | | [.idata$2: Import Directory Table -- not needed] | 920 | | .idata$4: Import Lookup Table | 921 | | .idata$5: Import Address Table | 922 | | | 923 | | Note we do not create a .idata$3 section as this is | 924 | | created for us by the linker script. */ | 925 | 185 | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 926 | 185 | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 927 | 185 | if (id4 == NULL || id5 == NULL) | 928 | 0 | goto error_return; | 929 | | | 930 | | /* Fill in the contents of these sections. */ | 931 | 185 | if (import_name_type == IMPORT_ORDINAL) | 932 | 139 | { | 933 | 139 | if (ordinal == 0) | 934 | | /* See PR 20907 for a reproducer. */ | 935 | 117 | goto error_return; | 936 | | | 937 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64) | 938 | | ((unsigned int *) id4->contents)[0] = ordinal; | 939 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 940 | | ((unsigned int *) id5->contents)[0] = ordinal; | 941 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 942 | | #else | 943 | 22 | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 944 | 22 | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 945 | 22 | #endif | 946 | 22 | } | 947 | 46 | else | 948 | 46 | { | 949 | 46 | char * symbol; | 950 | 46 | unsigned int len; | 951 | | | 952 | | /* Create .idata$6 - the Hint Name Table. */ | 953 | 46 | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 954 | 46 | if (id6 == NULL) | 955 | 0 | goto error_return; | 956 | | | 957 | | /* If necessary, trim the import symbol name. */ | 958 | 46 | symbol = symbol_name; | 959 | | | 960 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 961 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 962 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 963 | | of these is used for a symbol. We strip this leading char for | 964 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 965 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 966 | | | 967 | 46 | if (import_name_type != IMPORT_NAME) | 968 | 34 | { | 969 | 34 | char c = symbol[0]; | 970 | | | 971 | | /* Check that we don't remove for targets with empty | 972 | | USER_LABEL_PREFIX the leading underscore. */ | 973 | 34 | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 974 | 34 | || c == '@' || c == '?') | 975 | 6 | symbol++; | 976 | 34 | } | 977 | | | 978 | 46 | len = strlen (symbol); | 979 | 46 | if (import_name_type == IMPORT_NAME_UNDECORATE) | 980 | 16 | { | 981 | | /* Truncate at the first '@'. */ | 982 | 16 | char *at = strchr (symbol, '@'); | 983 | | | 984 | 16 | if (at != NULL) | 985 | 3 | len = at - symbol; | 986 | 16 | } | 987 | | | 988 | 46 | id6->contents[0] = ordinal & 0xff; | 989 | 46 | id6->contents[1] = ordinal >> 8; | 990 | | | 991 | 46 | memcpy ((char *) id6->contents + 2, symbol, len); | 992 | 46 | id6->contents[len + 2] = '\0'; | 993 | 46 | } | 994 | | | 995 | 68 | if (import_name_type != IMPORT_ORDINAL) | 996 | 46 | { | 997 | 46 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 998 | 46 | pe_ILF_save_relocs (&vars, id4); | 999 | | | 1000 | 46 | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1001 | 46 | pe_ILF_save_relocs (&vars, id5); | 1002 | 46 | } | 1003 | | | 1004 | | /* Create an import symbol. */ | 1005 | 68 | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 1006 | 68 | imp_sym = vars.sym_ptr_ptr - 1; | 1007 | 68 | imp_index = vars.sym_index - 1; | 1008 | | | 1009 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1010 | 68 | switch (import_type) | 1011 | 68 | { | 1012 | 0 | int i; | 1013 | | | 1014 | 42 | case IMPORT_CODE: | 1015 | | /* CODE functions are special, in that they get a trampoline that | 1016 | | jumps to the main import symbol. Create a .text section to hold it. | 1017 | | First we need to look up its contents in the jump table. */ | 1018 | 114 | for (i = NUM_ENTRIES (jtab); i--;) | 1019 | 114 | { | 1020 | 114 | if (jtab[i].size == 0) | 1021 | 42 | continue; | 1022 | 72 | if (jtab[i].magic == magic) | 1023 | 42 | break; | 1024 | 72 | } | 1025 | | /* If we did not find a matching entry something is wrong. */ | 1026 | 42 | if (i < 0) | 1027 | 0 | abort (); | 1028 | | | 1029 | | /* Create the .text section. */ | 1030 | 42 | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1031 | 42 | if (text == NULL) | 1032 | 0 | goto error_return; | 1033 | | | 1034 | | /* Copy in the jump code. */ | 1035 | 42 | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1036 | | | 1037 | | /* Create a reloc for the data in the text section. */ | 1038 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1039 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1040 | | { | 1041 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1042 | | (struct bfd_symbol **) imp_sym, | 1043 | | imp_index); | 1044 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1045 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1046 | | (struct bfd_symbol **) imp_sym, | 1047 | | imp_index); | 1048 | | } | 1049 | | else | 1050 | | #endif | 1051 | | #ifdef AMD64MAGIC | 1052 | | if (magic == AMD64MAGIC) | 1053 | | { | 1054 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1055 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1056 | | imp_index); | 1057 | | } | 1058 | | else | 1059 | | #endif | 1060 | 42 | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1061 | 42 | BFD_RELOC_32, (asymbol **) imp_sym, | 1062 | 42 | imp_index); | 1063 | | | 1064 | 42 | pe_ILF_save_relocs (& vars, text); | 1065 | 42 | break; | 1066 | | | 1067 | 26 | case IMPORT_DATA: | 1068 | 26 | break; | 1069 | | | 1070 | 0 | default: | 1071 | | /* XXX code not yet written. */ | 1072 | 0 | abort (); | 1073 | 68 | } | 1074 | | | 1075 | | /* Now create a symbol describing the imported value. */ | 1076 | 68 | switch (import_type) | 1077 | 68 | { | 1078 | 42 | case IMPORT_CODE: | 1079 | 42 | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1080 | 42 | BSF_NOT_AT_END | BSF_FUNCTION); | 1081 | | | 1082 | 42 | break; | 1083 | | | 1084 | 26 | case IMPORT_DATA: | 1085 | | /* Nothing to do here. */ | 1086 | 26 | break; | 1087 | | | 1088 | 0 | default: | 1089 | | /* XXX code not yet written. */ | 1090 | 0 | abort (); | 1091 | 68 | } | 1092 | | | 1093 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1094 | 68 | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1095 | 68 | if (ptr) | 1096 | 12 | * ptr = 0; | 1097 | 68 | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1098 | 68 | if (ptr) | 1099 | 12 | * ptr = '.'; | 1100 | | | 1101 | | /* Initialise the bfd. */ | 1102 | 68 | memset (& internal_f, 0, sizeof (internal_f)); | 1103 | | | 1104 | 68 | internal_f.f_magic = magic; | 1105 | 68 | internal_f.f_symptr = 0; | 1106 | 68 | internal_f.f_nsyms = 0; | 1107 | 68 | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1108 | | | 1109 | 68 | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1110 | 68 | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1111 | 0 | goto error_return; | 1112 | | | 1113 | 68 | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1114 | 0 | goto error_return; | 1115 | | | 1116 | 68 | obj_pe (abfd) = true; | 1117 | 68 | #ifdef THUMBPEMAGIC | 1118 | 68 | if (vars.magic == THUMBPEMAGIC) | 1119 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1120 | 25 | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1121 | 68 | #endif | 1122 | | | 1123 | | /* Switch from file contents to memory contents. */ | 1124 | 68 | bfd_cache_close (abfd); | 1125 | | | 1126 | 68 | abfd->iostream = (void *) vars.bim; | 1127 | 68 | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1128 | 68 | abfd->iovec = &_bfd_memory_iovec; | 1129 | 68 | abfd->where = 0; | 1130 | 68 | abfd->origin = 0; | 1131 | 68 | abfd->size = 0; | 1132 | 68 | obj_sym_filepos (abfd) = 0; | 1133 | | | 1134 | | /* Point the bfd at the symbol table. */ | 1135 | 68 | obj_symbols (abfd) = vars.sym_cache; | 1136 | 68 | abfd->symcount = vars.sym_index; | 1137 | | | 1138 | 68 | obj_raw_syments (abfd) = vars.native_syms; | 1139 | 68 | obj_raw_syment_count (abfd) = vars.sym_index; | 1140 | | | 1141 | 68 | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1142 | 68 | obj_coff_keep_syms (abfd) = true; | 1143 | | | 1144 | 68 | obj_convert (abfd) = vars.sym_table; | 1145 | 68 | obj_conv_table_size (abfd) = vars.sym_index; | 1146 | | | 1147 | 68 | obj_coff_strings (abfd) = vars.string_table; | 1148 | 68 | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1149 | 68 | obj_coff_keep_strings (abfd) = true; | 1150 | | | 1151 | 68 | return true; | 1152 | | | 1153 | 117 | error_return: | 1154 | 117 | free (vars.bim->buffer); | 1155 | 117 | free (vars.bim); | 1156 | 117 | return false; | 1157 | 68 | } |
pei-arm.c:pe_ILF_build_a_bfd Line | Count | Source | 796 | 5.16k | { | 797 | 5.16k | bfd_byte * ptr; | 798 | 5.16k | pe_ILF_vars vars; | 799 | 5.16k | struct internal_filehdr internal_f; | 800 | 5.16k | unsigned int import_type; | 801 | 5.16k | unsigned int import_name_type; | 802 | 5.16k | asection_ptr id4, id5, id6 = NULL, text = NULL; | 803 | 5.16k | coff_symbol_type ** imp_sym; | 804 | 5.16k | unsigned int imp_index; | 805 | 5.16k | intptr_t alignment; | 806 | | | 807 | | /* Decode and verify the types field of the ILF structure. */ | 808 | 5.16k | import_type = types & 0x3; | 809 | 5.16k | import_name_type = (types & 0x1c) >> 2; | 810 | | | 811 | 5.16k | switch (import_type) | 812 | 5.16k | { | 813 | 3.54k | case IMPORT_CODE: | 814 | 4.73k | case IMPORT_DATA: | 815 | 4.73k | break; | 816 | | | 817 | 116 | case IMPORT_CONST: | 818 | | /* XXX code yet to be written. */ | 819 | | /* xgettext:c-format */ | 820 | 116 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 821 | 116 | abfd, import_type); | 822 | 116 | return false; | 823 | | | 824 | 314 | default: | 825 | | /* xgettext:c-format */ | 826 | 314 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 827 | 314 | abfd, import_type); | 828 | 314 | return false; | 829 | 5.16k | } | 830 | | | 831 | 4.73k | switch (import_name_type) | 832 | 4.73k | { | 833 | 1.99k | case IMPORT_ORDINAL: | 834 | 3.05k | case IMPORT_NAME: | 835 | 4.03k | case IMPORT_NAME_NOPREFIX: | 836 | 4.62k | case IMPORT_NAME_UNDECORATE: | 837 | 4.62k | break; | 838 | | | 839 | 112 | default: | 840 | | /* xgettext:c-format */ | 841 | 112 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 842 | 112 | abfd, import_name_type); | 843 | 112 | return false; | 844 | 4.73k | } | 845 | | | 846 | | /* Initialise local variables. | 847 | | | 848 | | Note these are kept in a structure rather than being | 849 | | declared as statics since bfd frowns on global variables. | 850 | | | 851 | | We are going to construct the contents of the BFD in memory, | 852 | | so allocate all the space that we will need right now. */ | 853 | 4.62k | vars.bim | 854 | 4.62k | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 855 | 4.62k | if (vars.bim == NULL) | 856 | 0 | return false; | 857 | | | 858 | 4.62k | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 859 | 4.62k | vars.bim->buffer = ptr; | 860 | 4.62k | vars.bim->size = ILF_DATA_SIZE; | 861 | 4.62k | if (ptr == NULL) | 862 | 0 | goto error_return; | 863 | | | 864 | | /* Initialise the pointers to regions of the memory and the | 865 | | other contents of the pe_ILF_vars structure as well. */ | 866 | 4.62k | vars.sym_cache = (coff_symbol_type *) ptr; | 867 | 4.62k | vars.sym_ptr = (coff_symbol_type *) ptr; | 868 | 4.62k | vars.sym_index = 0; | 869 | 4.62k | ptr += SIZEOF_ILF_SYMS; | 870 | | | 871 | 4.62k | vars.sym_table = (unsigned int *) ptr; | 872 | 4.62k | vars.table_ptr = (unsigned int *) ptr; | 873 | 4.62k | ptr += SIZEOF_ILF_SYM_TABLE; | 874 | | | 875 | 4.62k | vars.native_syms = (combined_entry_type *) ptr; | 876 | 4.62k | vars.native_ptr = (combined_entry_type *) ptr; | 877 | 4.62k | ptr += SIZEOF_ILF_NATIVE_SYMS; | 878 | | | 879 | 4.62k | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 880 | 4.62k | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 881 | 4.62k | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 882 | | | 883 | 4.62k | vars.esym_table = (SYMENT *) ptr; | 884 | 4.62k | vars.esym_ptr = (SYMENT *) ptr; | 885 | 4.62k | ptr += SIZEOF_ILF_EXT_SYMS; | 886 | | | 887 | 4.62k | vars.reltab = (arelent *) ptr; | 888 | 4.62k | vars.relcount = 0; | 889 | 4.62k | ptr += SIZEOF_ILF_RELOCS; | 890 | | | 891 | 4.62k | vars.int_reltab = (struct internal_reloc *) ptr; | 892 | 4.62k | ptr += SIZEOF_ILF_INT_RELOCS; | 893 | | | 894 | 4.62k | vars.string_table = (char *) ptr; | 895 | 4.62k | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 896 | 4.62k | ptr += SIZEOF_ILF_STRINGS; | 897 | 4.62k | vars.end_string_ptr = (char *) ptr; | 898 | | | 899 | | /* The remaining space in bim->buffer is used | 900 | | by the pe_ILF_make_a_section() function. */ | 901 | | | 902 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 903 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 904 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 905 | | alignment. */ | 906 | 4.62k | #if GCC_VERSION >= 3000 | 907 | 4.62k | alignment = __alignof__ (struct coff_section_tdata); | 908 | | #else | 909 | | alignment = 8; | 910 | | #endif | 911 | 4.62k | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 912 | | | 913 | 4.62k | vars.data = ptr; | 914 | 4.62k | vars.abfd = abfd; | 915 | 4.62k | vars.sec_index = 0; | 916 | 4.62k | vars.magic = magic; | 917 | | | 918 | | /* Create the initial .idata$<n> sections: | 919 | | [.idata$2: Import Directory Table -- not needed] | 920 | | .idata$4: Import Lookup Table | 921 | | .idata$5: Import Address Table | 922 | | | 923 | | Note we do not create a .idata$3 section as this is | 924 | | created for us by the linker script. */ | 925 | 4.62k | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 926 | 4.62k | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 927 | 4.62k | if (id4 == NULL || id5 == NULL) | 928 | 0 | goto error_return; | 929 | | | 930 | | /* Fill in the contents of these sections. */ | 931 | 4.62k | if (import_name_type == IMPORT_ORDINAL) | 932 | 1.99k | { | 933 | 1.99k | if (ordinal == 0) | 934 | | /* See PR 20907 for a reproducer. */ | 935 | 117 | goto error_return; | 936 | | | 937 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64) | 938 | | ((unsigned int *) id4->contents)[0] = ordinal; | 939 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 940 | | ((unsigned int *) id5->contents)[0] = ordinal; | 941 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 942 | | #else | 943 | 1.87k | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 944 | 1.87k | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 945 | 1.87k | #endif | 946 | 1.87k | } | 947 | 2.62k | else | 948 | 2.62k | { | 949 | 2.62k | char * symbol; | 950 | 2.62k | unsigned int len; | 951 | | | 952 | | /* Create .idata$6 - the Hint Name Table. */ | 953 | 2.62k | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 954 | 2.62k | if (id6 == NULL) | 955 | 0 | goto error_return; | 956 | | | 957 | | /* If necessary, trim the import symbol name. */ | 958 | 2.62k | symbol = symbol_name; | 959 | | | 960 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 961 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 962 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 963 | | of these is used for a symbol. We strip this leading char for | 964 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 965 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 966 | | | 967 | 2.62k | if (import_name_type != IMPORT_NAME) | 968 | 1.56k | { | 969 | 1.56k | char c = symbol[0]; | 970 | | | 971 | | /* Check that we don't remove for targets with empty | 972 | | USER_LABEL_PREFIX the leading underscore. */ | 973 | 1.56k | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 974 | 1.56k | || c == '@' || c == '?') | 975 | 12 | symbol++; | 976 | 1.56k | } | 977 | | | 978 | 2.62k | len = strlen (symbol); | 979 | 2.62k | if (import_name_type == IMPORT_NAME_UNDECORATE) | 980 | 592 | { | 981 | | /* Truncate at the first '@'. */ | 982 | 592 | char *at = strchr (symbol, '@'); | 983 | | | 984 | 592 | if (at != NULL) | 985 | 4 | len = at - symbol; | 986 | 592 | } | 987 | | | 988 | 2.62k | id6->contents[0] = ordinal & 0xff; | 989 | 2.62k | id6->contents[1] = ordinal >> 8; | 990 | | | 991 | 2.62k | memcpy ((char *) id6->contents + 2, symbol, len); | 992 | 2.62k | id6->contents[len + 2] = '\0'; | 993 | 2.62k | } | 994 | | | 995 | 4.50k | if (import_name_type != IMPORT_ORDINAL) | 996 | 2.62k | { | 997 | 2.62k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 998 | 2.62k | pe_ILF_save_relocs (&vars, id4); | 999 | | | 1000 | 2.62k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1001 | 2.62k | pe_ILF_save_relocs (&vars, id5); | 1002 | 2.62k | } | 1003 | | | 1004 | | /* Create an import symbol. */ | 1005 | 4.50k | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 1006 | 4.50k | imp_sym = vars.sym_ptr_ptr - 1; | 1007 | 4.50k | imp_index = vars.sym_index - 1; | 1008 | | | 1009 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1010 | 4.50k | switch (import_type) | 1011 | 4.50k | { | 1012 | 0 | int i; | 1013 | | | 1014 | 3.42k | case IMPORT_CODE: | 1015 | | /* CODE functions are special, in that they get a trampoline that | 1016 | | jumps to the main import symbol. Create a .text section to hold it. | 1017 | | First we need to look up its contents in the jump table. */ | 1018 | 9.79k | for (i = NUM_ENTRIES (jtab); i--;) | 1019 | 9.79k | { | 1020 | 9.79k | if (jtab[i].size == 0) | 1021 | 3.42k | continue; | 1022 | 6.36k | if (jtab[i].magic == magic) | 1023 | 3.42k | break; | 1024 | 6.36k | } | 1025 | | /* If we did not find a matching entry something is wrong. */ | 1026 | 3.42k | if (i < 0) | 1027 | 0 | abort (); | 1028 | | | 1029 | | /* Create the .text section. */ | 1030 | 3.42k | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1031 | 3.42k | if (text == NULL) | 1032 | 0 | goto error_return; | 1033 | | | 1034 | | /* Copy in the jump code. */ | 1035 | 3.42k | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1036 | | | 1037 | | /* Create a reloc for the data in the text section. */ | 1038 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1039 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1040 | | { | 1041 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1042 | | (struct bfd_symbol **) imp_sym, | 1043 | | imp_index); | 1044 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1045 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1046 | | (struct bfd_symbol **) imp_sym, | 1047 | | imp_index); | 1048 | | } | 1049 | | else | 1050 | | #endif | 1051 | | #ifdef AMD64MAGIC | 1052 | | if (magic == AMD64MAGIC) | 1053 | | { | 1054 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1055 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1056 | | imp_index); | 1057 | | } | 1058 | | else | 1059 | | #endif | 1060 | 3.42k | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1061 | 3.42k | BFD_RELOC_32, (asymbol **) imp_sym, | 1062 | 3.42k | imp_index); | 1063 | | | 1064 | 3.42k | pe_ILF_save_relocs (& vars, text); | 1065 | 3.42k | break; | 1066 | | | 1067 | 1.07k | case IMPORT_DATA: | 1068 | 1.07k | break; | 1069 | | | 1070 | 0 | default: | 1071 | | /* XXX code not yet written. */ | 1072 | 0 | abort (); | 1073 | 4.50k | } | 1074 | | | 1075 | | /* Now create a symbol describing the imported value. */ | 1076 | 4.50k | switch (import_type) | 1077 | 4.50k | { | 1078 | 3.42k | case IMPORT_CODE: | 1079 | 3.42k | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1080 | 3.42k | BSF_NOT_AT_END | BSF_FUNCTION); | 1081 | | | 1082 | 3.42k | break; | 1083 | | | 1084 | 1.07k | case IMPORT_DATA: | 1085 | | /* Nothing to do here. */ | 1086 | 1.07k | break; | 1087 | | | 1088 | 0 | default: | 1089 | | /* XXX code not yet written. */ | 1090 | 0 | abort (); | 1091 | 4.50k | } | 1092 | | | 1093 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1094 | 4.50k | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1095 | 4.50k | if (ptr) | 1096 | 927 | * ptr = 0; | 1097 | 4.50k | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1098 | 4.50k | if (ptr) | 1099 | 927 | * ptr = '.'; | 1100 | | | 1101 | | /* Initialise the bfd. */ | 1102 | 4.50k | memset (& internal_f, 0, sizeof (internal_f)); | 1103 | | | 1104 | 4.50k | internal_f.f_magic = magic; | 1105 | 4.50k | internal_f.f_symptr = 0; | 1106 | 4.50k | internal_f.f_nsyms = 0; | 1107 | 4.50k | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1108 | | | 1109 | 4.50k | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1110 | 4.50k | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1111 | 0 | goto error_return; | 1112 | | | 1113 | 4.50k | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1114 | 0 | goto error_return; | 1115 | | | 1116 | 4.50k | obj_pe (abfd) = true; | 1117 | 4.50k | #ifdef THUMBPEMAGIC | 1118 | 4.50k | if (vars.magic == THUMBPEMAGIC) | 1119 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1120 | 984 | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1121 | 4.50k | #endif | 1122 | | | 1123 | | /* Switch from file contents to memory contents. */ | 1124 | 4.50k | bfd_cache_close (abfd); | 1125 | | | 1126 | 4.50k | abfd->iostream = (void *) vars.bim; | 1127 | 4.50k | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1128 | 4.50k | abfd->iovec = &_bfd_memory_iovec; | 1129 | 4.50k | abfd->where = 0; | 1130 | 4.50k | abfd->origin = 0; | 1131 | 4.50k | abfd->size = 0; | 1132 | 4.50k | obj_sym_filepos (abfd) = 0; | 1133 | | | 1134 | | /* Point the bfd at the symbol table. */ | 1135 | 4.50k | obj_symbols (abfd) = vars.sym_cache; | 1136 | 4.50k | abfd->symcount = vars.sym_index; | 1137 | | | 1138 | 4.50k | obj_raw_syments (abfd) = vars.native_syms; | 1139 | 4.50k | obj_raw_syment_count (abfd) = vars.sym_index; | 1140 | | | 1141 | 4.50k | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1142 | 4.50k | obj_coff_keep_syms (abfd) = true; | 1143 | | | 1144 | 4.50k | obj_convert (abfd) = vars.sym_table; | 1145 | 4.50k | obj_conv_table_size (abfd) = vars.sym_index; | 1146 | | | 1147 | 4.50k | obj_coff_strings (abfd) = vars.string_table; | 1148 | 4.50k | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1149 | 4.50k | obj_coff_keep_strings (abfd) = true; | 1150 | | | 1151 | 4.50k | return true; | 1152 | | | 1153 | 117 | error_return: | 1154 | 117 | free (vars.bim->buffer); | 1155 | 117 | free (vars.bim); | 1156 | 117 | return false; | 1157 | 4.50k | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_build_a_bfd pei-sh.c:pe_ILF_build_a_bfd Line | Count | Source | 796 | 3.45k | { | 797 | 3.45k | bfd_byte * ptr; | 798 | 3.45k | pe_ILF_vars vars; | 799 | 3.45k | struct internal_filehdr internal_f; | 800 | 3.45k | unsigned int import_type; | 801 | 3.45k | unsigned int import_name_type; | 802 | 3.45k | asection_ptr id4, id5, id6 = NULL, text = NULL; | 803 | 3.45k | coff_symbol_type ** imp_sym; | 804 | 3.45k | unsigned int imp_index; | 805 | 3.45k | intptr_t alignment; | 806 | | | 807 | | /* Decode and verify the types field of the ILF structure. */ | 808 | 3.45k | import_type = types & 0x3; | 809 | 3.45k | import_name_type = (types & 0x1c) >> 2; | 810 | | | 811 | 3.45k | switch (import_type) | 812 | 3.45k | { | 813 | 1.33k | case IMPORT_CODE: | 814 | 3.01k | case IMPORT_DATA: | 815 | 3.01k | break; | 816 | | | 817 | 216 | case IMPORT_CONST: | 818 | | /* XXX code yet to be written. */ | 819 | | /* xgettext:c-format */ | 820 | 216 | _bfd_error_handler (_("%pB: unhandled import type; %x"), | 821 | 216 | abfd, import_type); | 822 | 216 | return false; | 823 | | | 824 | 221 | default: | 825 | | /* xgettext:c-format */ | 826 | 221 | _bfd_error_handler (_("%pB: unrecognized import type; %x"), | 827 | 221 | abfd, import_type); | 828 | 221 | return false; | 829 | 3.45k | } | 830 | | | 831 | 3.01k | switch (import_name_type) | 832 | 3.01k | { | 833 | 495 | case IMPORT_ORDINAL: | 834 | 1.22k | case IMPORT_NAME: | 835 | 2.39k | case IMPORT_NAME_NOPREFIX: | 836 | 2.89k | case IMPORT_NAME_UNDECORATE: | 837 | 2.89k | break; | 838 | | | 839 | 120 | default: | 840 | | /* xgettext:c-format */ | 841 | 120 | _bfd_error_handler (_("%pB: unrecognized import name type; %x"), | 842 | 120 | abfd, import_name_type); | 843 | 120 | return false; | 844 | 3.01k | } | 845 | | | 846 | | /* Initialise local variables. | 847 | | | 848 | | Note these are kept in a structure rather than being | 849 | | declared as statics since bfd frowns on global variables. | 850 | | | 851 | | We are going to construct the contents of the BFD in memory, | 852 | | so allocate all the space that we will need right now. */ | 853 | 2.89k | vars.bim | 854 | 2.89k | = (struct bfd_in_memory *) bfd_malloc ((bfd_size_type) sizeof (*vars.bim)); | 855 | 2.89k | if (vars.bim == NULL) | 856 | 0 | return false; | 857 | | | 858 | 2.89k | ptr = (bfd_byte *) bfd_zmalloc ((bfd_size_type) ILF_DATA_SIZE); | 859 | 2.89k | vars.bim->buffer = ptr; | 860 | 2.89k | vars.bim->size = ILF_DATA_SIZE; | 861 | 2.89k | if (ptr == NULL) | 862 | 0 | goto error_return; | 863 | | | 864 | | /* Initialise the pointers to regions of the memory and the | 865 | | other contents of the pe_ILF_vars structure as well. */ | 866 | 2.89k | vars.sym_cache = (coff_symbol_type *) ptr; | 867 | 2.89k | vars.sym_ptr = (coff_symbol_type *) ptr; | 868 | 2.89k | vars.sym_index = 0; | 869 | 2.89k | ptr += SIZEOF_ILF_SYMS; | 870 | | | 871 | 2.89k | vars.sym_table = (unsigned int *) ptr; | 872 | 2.89k | vars.table_ptr = (unsigned int *) ptr; | 873 | 2.89k | ptr += SIZEOF_ILF_SYM_TABLE; | 874 | | | 875 | 2.89k | vars.native_syms = (combined_entry_type *) ptr; | 876 | 2.89k | vars.native_ptr = (combined_entry_type *) ptr; | 877 | 2.89k | ptr += SIZEOF_ILF_NATIVE_SYMS; | 878 | | | 879 | 2.89k | vars.sym_ptr_table = (coff_symbol_type **) ptr; | 880 | 2.89k | vars.sym_ptr_ptr = (coff_symbol_type **) ptr; | 881 | 2.89k | ptr += SIZEOF_ILF_SYM_PTR_TABLE; | 882 | | | 883 | 2.89k | vars.esym_table = (SYMENT *) ptr; | 884 | 2.89k | vars.esym_ptr = (SYMENT *) ptr; | 885 | 2.89k | ptr += SIZEOF_ILF_EXT_SYMS; | 886 | | | 887 | 2.89k | vars.reltab = (arelent *) ptr; | 888 | 2.89k | vars.relcount = 0; | 889 | 2.89k | ptr += SIZEOF_ILF_RELOCS; | 890 | | | 891 | 2.89k | vars.int_reltab = (struct internal_reloc *) ptr; | 892 | 2.89k | ptr += SIZEOF_ILF_INT_RELOCS; | 893 | | | 894 | 2.89k | vars.string_table = (char *) ptr; | 895 | 2.89k | vars.string_ptr = (char *) ptr + STRING_SIZE_SIZE; | 896 | 2.89k | ptr += SIZEOF_ILF_STRINGS; | 897 | 2.89k | vars.end_string_ptr = (char *) ptr; | 898 | | | 899 | | /* The remaining space in bim->buffer is used | 900 | | by the pe_ILF_make_a_section() function. */ | 901 | | | 902 | | /* PR 18758: Make sure that the data area is sufficiently aligned for | 903 | | struct coff_section_tdata. __alignof__ is a gcc extension, hence | 904 | | the test of GCC_VERSION. For other compilers we assume 8 byte | 905 | | alignment. */ | 906 | 2.89k | #if GCC_VERSION >= 3000 | 907 | 2.89k | alignment = __alignof__ (struct coff_section_tdata); | 908 | | #else | 909 | | alignment = 8; | 910 | | #endif | 911 | 2.89k | ptr = (bfd_byte *) (((intptr_t) ptr + alignment - 1) & -alignment); | 912 | | | 913 | 2.89k | vars.data = ptr; | 914 | 2.89k | vars.abfd = abfd; | 915 | 2.89k | vars.sec_index = 0; | 916 | 2.89k | vars.magic = magic; | 917 | | | 918 | | /* Create the initial .idata$<n> sections: | 919 | | [.idata$2: Import Directory Table -- not needed] | 920 | | .idata$4: Import Lookup Table | 921 | | .idata$5: Import Address Table | 922 | | | 923 | | Note we do not create a .idata$3 section as this is | 924 | | created for us by the linker script. */ | 925 | 2.89k | id4 = pe_ILF_make_a_section (& vars, ".idata$4", SIZEOF_IDATA4, 0); | 926 | 2.89k | id5 = pe_ILF_make_a_section (& vars, ".idata$5", SIZEOF_IDATA5, 0); | 927 | 2.89k | if (id4 == NULL || id5 == NULL) | 928 | 0 | goto error_return; | 929 | | | 930 | | /* Fill in the contents of these sections. */ | 931 | 2.89k | if (import_name_type == IMPORT_ORDINAL) | 932 | 495 | { | 933 | 495 | if (ordinal == 0) | 934 | | /* See PR 20907 for a reproducer. */ | 935 | 123 | goto error_return; | 936 | | | 937 | | #if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64) | 938 | | ((unsigned int *) id4->contents)[0] = ordinal; | 939 | | ((unsigned int *) id4->contents)[1] = 0x80000000; | 940 | | ((unsigned int *) id5->contents)[0] = ordinal; | 941 | | ((unsigned int *) id5->contents)[1] = 0x80000000; | 942 | | #else | 943 | 372 | * (unsigned int *) id4->contents = ordinal | 0x80000000; | 944 | 372 | * (unsigned int *) id5->contents = ordinal | 0x80000000; | 945 | 372 | #endif | 946 | 372 | } | 947 | 2.40k | else | 948 | 2.40k | { | 949 | 2.40k | char * symbol; | 950 | 2.40k | unsigned int len; | 951 | | | 952 | | /* Create .idata$6 - the Hint Name Table. */ | 953 | 2.40k | id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0); | 954 | 2.40k | if (id6 == NULL) | 955 | 0 | goto error_return; | 956 | | | 957 | | /* If necessary, trim the import symbol name. */ | 958 | 2.40k | symbol = symbol_name; | 959 | | | 960 | | /* As used by MS compiler, '_', '@', and '?' are alternative | 961 | | forms of USER_LABEL_PREFIX, with '?' for c++ mangled names, | 962 | | '@' used for fastcall (in C), '_' everywhere else. Only one | 963 | | of these is used for a symbol. We strip this leading char for | 964 | | IMPORT_NAME_NOPREFIX and IMPORT_NAME_UNDECORATE as per the | 965 | | PE COFF 6.0 spec (section 8.3, Import Name Type). */ | 966 | | | 967 | 2.40k | if (import_name_type != IMPORT_NAME) | 968 | 1.67k | { | 969 | 1.67k | char c = symbol[0]; | 970 | | | 971 | | /* Check that we don't remove for targets with empty | 972 | | USER_LABEL_PREFIX the leading underscore. */ | 973 | 1.67k | if ((c == '_' && abfd->xvec->symbol_leading_char != 0) | 974 | 1.67k | || c == '@' || c == '?') | 975 | 15 | symbol++; | 976 | 1.67k | } | 977 | | | 978 | 2.40k | len = strlen (symbol); | 979 | 2.40k | if (import_name_type == IMPORT_NAME_UNDECORATE) | 980 | 505 | { | 981 | | /* Truncate at the first '@'. */ | 982 | 505 | char *at = strchr (symbol, '@'); | 983 | | | 984 | 505 | if (at != NULL) | 985 | 243 | len = at - symbol; | 986 | 505 | } | 987 | | | 988 | 2.40k | id6->contents[0] = ordinal & 0xff; | 989 | 2.40k | id6->contents[1] = ordinal >> 8; | 990 | | | 991 | 2.40k | memcpy ((char *) id6->contents + 2, symbol, len); | 992 | 2.40k | id6->contents[len + 2] = '\0'; | 993 | 2.40k | } | 994 | | | 995 | 2.77k | if (import_name_type != IMPORT_ORDINAL) | 996 | 2.40k | { | 997 | 2.40k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 998 | 2.40k | pe_ILF_save_relocs (&vars, id4); | 999 | | | 1000 | 2.40k | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6); | 1001 | 2.40k | pe_ILF_save_relocs (&vars, id5); | 1002 | 2.40k | } | 1003 | | | 1004 | | /* Create an import symbol. */ | 1005 | 2.77k | pe_ILF_make_a_symbol (& vars, "__imp_", symbol_name, id5, 0); | 1006 | 2.77k | imp_sym = vars.sym_ptr_ptr - 1; | 1007 | 2.77k | imp_index = vars.sym_index - 1; | 1008 | | | 1009 | | /* Create extra sections depending upon the type of import we are dealing with. */ | 1010 | 2.77k | switch (import_type) | 1011 | 2.77k | { | 1012 | 0 | int i; | 1013 | | | 1014 | 1.10k | case IMPORT_CODE: | 1015 | | /* CODE functions are special, in that they get a trampoline that | 1016 | | jumps to the main import symbol. Create a .text section to hold it. | 1017 | | First we need to look up its contents in the jump table. */ | 1018 | 2.20k | for (i = NUM_ENTRIES (jtab); i--;) | 1019 | 2.20k | { | 1020 | 2.20k | if (jtab[i].size == 0) | 1021 | 1.10k | continue; | 1022 | 1.10k | if (jtab[i].magic == magic) | 1023 | 1.10k | break; | 1024 | 1.10k | } | 1025 | | /* If we did not find a matching entry something is wrong. */ | 1026 | 1.10k | if (i < 0) | 1027 | 0 | abort (); | 1028 | | | 1029 | | /* Create the .text section. */ | 1030 | 1.10k | text = pe_ILF_make_a_section (& vars, ".text", jtab[i].size, SEC_CODE); | 1031 | 1.10k | if (text == NULL) | 1032 | 0 | goto error_return; | 1033 | | | 1034 | | /* Copy in the jump code. */ | 1035 | 1.10k | memcpy (text->contents, jtab[i].data, jtab[i].size); | 1036 | | | 1037 | | /* Create a reloc for the data in the text section. */ | 1038 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1039 | | if (magic == MIPS_ARCH_MAGIC_WINCE) | 1040 | | { | 1041 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S, | 1042 | | (struct bfd_symbol **) imp_sym, | 1043 | | imp_index); | 1044 | | pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text); | 1045 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16, | 1046 | | (struct bfd_symbol **) imp_sym, | 1047 | | imp_index); | 1048 | | } | 1049 | | else | 1050 | | #endif | 1051 | | #ifdef AMD64MAGIC | 1052 | | if (magic == AMD64MAGIC) | 1053 | | { | 1054 | | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1055 | | BFD_RELOC_32_PCREL, (asymbol **) imp_sym, | 1056 | | imp_index); | 1057 | | } | 1058 | | else | 1059 | | #endif | 1060 | 1.10k | pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, | 1061 | 1.10k | BFD_RELOC_32, (asymbol **) imp_sym, | 1062 | 1.10k | imp_index); | 1063 | | | 1064 | 1.10k | pe_ILF_save_relocs (& vars, text); | 1065 | 1.10k | break; | 1066 | | | 1067 | 1.67k | case IMPORT_DATA: | 1068 | 1.67k | break; | 1069 | | | 1070 | 0 | default: | 1071 | | /* XXX code not yet written. */ | 1072 | 0 | abort (); | 1073 | 2.77k | } | 1074 | | | 1075 | | /* Now create a symbol describing the imported value. */ | 1076 | 2.77k | switch (import_type) | 1077 | 2.77k | { | 1078 | 1.10k | case IMPORT_CODE: | 1079 | 1.10k | pe_ILF_make_a_symbol (& vars, "", symbol_name, text, | 1080 | 1.10k | BSF_NOT_AT_END | BSF_FUNCTION); | 1081 | | | 1082 | 1.10k | break; | 1083 | | | 1084 | 1.67k | case IMPORT_DATA: | 1085 | | /* Nothing to do here. */ | 1086 | 1.67k | break; | 1087 | | | 1088 | 0 | default: | 1089 | | /* XXX code not yet written. */ | 1090 | 0 | abort (); | 1091 | 2.77k | } | 1092 | | | 1093 | | /* Create an import symbol for the DLL, without the .dll suffix. */ | 1094 | 2.77k | ptr = (bfd_byte *) strrchr (source_dll, '.'); | 1095 | 2.77k | if (ptr) | 1096 | 243 | * ptr = 0; | 1097 | 2.77k | pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0); | 1098 | 2.77k | if (ptr) | 1099 | 243 | * ptr = '.'; | 1100 | | | 1101 | | /* Initialise the bfd. */ | 1102 | 2.77k | memset (& internal_f, 0, sizeof (internal_f)); | 1103 | | | 1104 | 2.77k | internal_f.f_magic = magic; | 1105 | 2.77k | internal_f.f_symptr = 0; | 1106 | 2.77k | internal_f.f_nsyms = 0; | 1107 | 2.77k | internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */ | 1108 | | | 1109 | 2.77k | if ( ! bfd_set_start_address (abfd, (bfd_vma) 0) | 1110 | 2.77k | || ! bfd_coff_set_arch_mach_hook (abfd, & internal_f)) | 1111 | 0 | goto error_return; | 1112 | | | 1113 | 2.77k | if (bfd_coff_mkobject_hook (abfd, (void *) & internal_f, NULL) == NULL) | 1114 | 0 | goto error_return; | 1115 | | | 1116 | 2.77k | obj_pe (abfd) = true; | 1117 | | #ifdef THUMBPEMAGIC | 1118 | | if (vars.magic == THUMBPEMAGIC) | 1119 | | /* Stop some linker warnings about thumb code not supporting interworking. */ | 1120 | | coff_data (abfd)->flags |= F_INTERWORK | F_INTERWORK_SET; | 1121 | | #endif | 1122 | | | 1123 | | /* Switch from file contents to memory contents. */ | 1124 | 2.77k | bfd_cache_close (abfd); | 1125 | | | 1126 | 2.77k | abfd->iostream = (void *) vars.bim; | 1127 | 2.77k | abfd->flags |= BFD_IN_MEMORY | HAS_SYMS; | 1128 | 2.77k | abfd->iovec = &_bfd_memory_iovec; | 1129 | 2.77k | abfd->where = 0; | 1130 | 2.77k | abfd->origin = 0; | 1131 | 2.77k | abfd->size = 0; | 1132 | 2.77k | obj_sym_filepos (abfd) = 0; | 1133 | | | 1134 | | /* Point the bfd at the symbol table. */ | 1135 | 2.77k | obj_symbols (abfd) = vars.sym_cache; | 1136 | 2.77k | abfd->symcount = vars.sym_index; | 1137 | | | 1138 | 2.77k | obj_raw_syments (abfd) = vars.native_syms; | 1139 | 2.77k | obj_raw_syment_count (abfd) = vars.sym_index; | 1140 | | | 1141 | 2.77k | obj_coff_external_syms (abfd) = (void *) vars.esym_table; | 1142 | 2.77k | obj_coff_keep_syms (abfd) = true; | 1143 | | | 1144 | 2.77k | obj_convert (abfd) = vars.sym_table; | 1145 | 2.77k | obj_conv_table_size (abfd) = vars.sym_index; | 1146 | | | 1147 | 2.77k | obj_coff_strings (abfd) = vars.string_table; | 1148 | 2.77k | obj_coff_strings_len (abfd) = vars.string_ptr - vars.string_table; | 1149 | 2.77k | obj_coff_keep_strings (abfd) = true; | 1150 | | | 1151 | 2.77k | return true; | 1152 | | | 1153 | 123 | error_return: | 1154 | 123 | free (vars.bim->buffer); | 1155 | 123 | free (vars.bim); | 1156 | 123 | return false; | 1157 | 2.77k | } |
|
1158 | | |
1159 | | /* Cleanup function, returned from check_format hook. */ |
1160 | | |
1161 | | static void |
1162 | | pe_ILF_cleanup (bfd *abfd) |
1163 | 102 | { |
1164 | 102 | coff_object_cleanup (abfd); |
1165 | | |
1166 | 102 | struct bfd_in_memory *bim = abfd->iostream; |
1167 | 102 | free (bim->buffer); |
1168 | 102 | free (bim); |
1169 | 102 | abfd->iostream = NULL; |
1170 | 102 | } 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 | 1163 | 51 | { | 1164 | 51 | coff_object_cleanup (abfd); | 1165 | | | 1166 | 51 | struct bfd_in_memory *bim = abfd->iostream; | 1167 | 51 | free (bim->buffer); | 1168 | 51 | free (bim); | 1169 | 51 | abfd->iostream = NULL; | 1170 | 51 | } |
Line | Count | Source | 1163 | 51 | { | 1164 | 51 | coff_object_cleanup (abfd); | 1165 | | | 1166 | 51 | struct bfd_in_memory *bim = abfd->iostream; | 1167 | 51 | free (bim->buffer); | 1168 | 51 | free (bim); | 1169 | 51 | abfd->iostream = NULL; | 1170 | 51 | } |
Unexecuted instantiation: pei-mcore.c:pe_ILF_cleanup Unexecuted instantiation: pei-sh.c:pe_ILF_cleanup |
1171 | | |
1172 | | /* We have detected an Import Library Format archive element. |
1173 | | Decode the element and return the appropriate target. */ |
1174 | | |
1175 | | static bfd_cleanup |
1176 | | pe_ILF_object_p (bfd * abfd) |
1177 | 275k | { |
1178 | 275k | bfd_byte buffer[14]; |
1179 | 275k | bfd_byte * ptr; |
1180 | 275k | char * symbol_name; |
1181 | 275k | char * source_dll; |
1182 | 275k | unsigned int machine; |
1183 | 275k | bfd_size_type size; |
1184 | 275k | unsigned int ordinal; |
1185 | 275k | unsigned int types; |
1186 | 275k | unsigned int magic; |
1187 | | |
1188 | | /* Upon entry the first six bytes of the ILF header have |
1189 | | already been read. Now read the rest of the header. */ |
1190 | 275k | if (bfd_read (buffer, 14, abfd) != 14) |
1191 | 4.93k | return NULL; |
1192 | | |
1193 | 270k | ptr = buffer; |
1194 | | |
1195 | 270k | machine = H_GET_16 (abfd, ptr); |
1196 | 270k | ptr += 2; |
1197 | | |
1198 | | /* Check that the machine type is recognised. */ |
1199 | 270k | magic = 0; |
1200 | | |
1201 | 270k | switch (machine) |
1202 | 270k | { |
1203 | 3.17k | case IMAGE_FILE_MACHINE_UNKNOWN: |
1204 | 3.21k | case IMAGE_FILE_MACHINE_ALPHA: |
1205 | 3.22k | case IMAGE_FILE_MACHINE_ALPHA64: |
1206 | 3.32k | case IMAGE_FILE_MACHINE_IA64: |
1207 | 3.32k | break; |
1208 | | |
1209 | 42.1k | case IMAGE_FILE_MACHINE_I386: |
1210 | | #ifdef I386MAGIC |
1211 | 6.61k | magic = I386MAGIC; |
1212 | | #endif |
1213 | 42.1k | break; |
1214 | | |
1215 | 59.4k | case IMAGE_FILE_MACHINE_AMD64: |
1216 | | #ifdef AMD64MAGIC |
1217 | 7.03k | magic = AMD64MAGIC; |
1218 | | #endif |
1219 | 59.4k | break; |
1220 | | |
1221 | 50 | case IMAGE_FILE_MACHINE_R3000: |
1222 | 82 | case IMAGE_FILE_MACHINE_R4000: |
1223 | 127 | case IMAGE_FILE_MACHINE_R10000: |
1224 | | |
1225 | 142 | case IMAGE_FILE_MACHINE_MIPS16: |
1226 | 157 | case IMAGE_FILE_MACHINE_MIPSFPU: |
1227 | 166 | case IMAGE_FILE_MACHINE_MIPSFPU16: |
1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE |
1229 | | magic = MIPS_ARCH_MAGIC_WINCE; |
1230 | | #endif |
1231 | 166 | break; |
1232 | | |
1233 | 13.6k | case IMAGE_FILE_MACHINE_SH3: |
1234 | 39.8k | case IMAGE_FILE_MACHINE_SH4: |
1235 | | #ifdef SH_ARCH_MAGIC_WINCE |
1236 | 5.01k | magic = SH_ARCH_MAGIC_WINCE; |
1237 | | #endif |
1238 | 39.8k | break; |
1239 | | |
1240 | 29.9k | case IMAGE_FILE_MACHINE_ARM: |
1241 | | #ifdef ARMPEMAGIC |
1242 | 8.68k | magic = ARMPEMAGIC; |
1243 | | #endif |
1244 | 29.9k | break; |
1245 | | |
1246 | 18.7k | case IMAGE_FILE_MACHINE_ARM64: |
1247 | | #ifdef AARCH64MAGIC |
1248 | 5.17k | magic = AARCH64MAGIC; |
1249 | | #endif |
1250 | 18.7k | break; |
1251 | | |
1252 | 36.7k | case IMAGE_FILE_MACHINE_LOONGARCH64: |
1253 | | #ifdef LOONGARCH64MAGIC |
1254 | 4.10k | magic = LOONGARCH64MAGIC; |
1255 | | #endif |
1256 | 36.7k | break; |
1257 | | |
1258 | 9.31k | case IMAGE_FILE_MACHINE_RISCV64: |
1259 | | #ifdef RISCV64MAGIC |
1260 | 1.23k | magic = RISCV64MAGIC; |
1261 | | #endif |
1262 | 9.31k | break; |
1263 | | |
1264 | 5.94k | case IMAGE_FILE_MACHINE_THUMB: |
1265 | | #ifdef THUMBPEMAGIC |
1266 | | { |
1267 | | extern const bfd_target TARGET_LITTLE_SYM; |
1268 | | |
1269 | 1.83k | if (abfd->xvec == & TARGET_LITTLE_SYM) |
1270 | 1.82k | magic = THUMBPEMAGIC; |
1271 | | } |
1272 | | #endif |
1273 | 5.94k | break; |
1274 | | |
1275 | 0 | case IMAGE_FILE_MACHINE_POWERPC: |
1276 | | /* We no longer support PowerPC. */ |
1277 | 24.6k | default: |
1278 | 24.6k | _bfd_error_handler |
1279 | | /* xgettext:c-format */ |
1280 | 24.6k | (_("%pB: unrecognised machine type (0x%x)" |
1281 | 24.6k | " in Import Library Format archive"), |
1282 | 24.6k | abfd, machine); |
1283 | 24.6k | bfd_set_error (bfd_error_malformed_archive); |
1284 | | |
1285 | 24.6k | return NULL; |
1286 | 0 | break; |
1287 | 270k | } |
1288 | | |
1289 | 245k | if (magic == 0) |
1290 | 205k | { |
1291 | 205k | _bfd_error_handler |
1292 | | /* xgettext:c-format */ |
1293 | 205k | (_("%pB: recognised but unhandled machine type (0x%x)" |
1294 | 205k | " in Import Library Format archive"), |
1295 | 205k | abfd, machine); |
1296 | 205k | bfd_set_error (bfd_error_wrong_format); |
1297 | | |
1298 | 205k | return NULL; |
1299 | 205k | } |
1300 | | |
1301 | | /* We do not bother to check the date. |
1302 | | date = H_GET_32 (abfd, ptr); */ |
1303 | 39.6k | ptr += 4; |
1304 | | |
1305 | 39.6k | size = H_GET_32 (abfd, ptr); |
1306 | 39.6k | ptr += 4; |
1307 | | |
1308 | 39.6k | if (size == 0) |
1309 | 1.71k | { |
1310 | 1.71k | _bfd_error_handler |
1311 | 1.71k | (_("%pB: size field is zero in Import Library Format header"), abfd); |
1312 | 1.71k | bfd_set_error (bfd_error_malformed_archive); |
1313 | | |
1314 | 1.71k | return NULL; |
1315 | 1.71k | } |
1316 | | |
1317 | 37.9k | ordinal = H_GET_16 (abfd, ptr); |
1318 | 37.9k | ptr += 2; |
1319 | | |
1320 | 37.9k | types = H_GET_16 (abfd, ptr); |
1321 | | /* ptr += 2; */ |
1322 | | |
1323 | | /* Now read in the two strings that follow. */ |
1324 | 37.9k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); |
1325 | 37.9k | if (ptr == NULL) |
1326 | 7.49k | return NULL; |
1327 | | |
1328 | 30.4k | symbol_name = (char *) ptr; |
1329 | | /* See PR 20905 for an example of where the strnlen is necessary. */ |
1330 | 30.4k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; |
1331 | | |
1332 | | /* Verify that the strings are null terminated. */ |
1333 | 30.4k | if (ptr[size - 1] != 0 |
1334 | 30.4k | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) |
1335 | 3.59k | { |
1336 | 3.59k | _bfd_error_handler |
1337 | 3.59k | (_("%pB: string not null terminated in ILF object file"), abfd); |
1338 | 3.59k | bfd_set_error (bfd_error_malformed_archive); |
1339 | 3.59k | bfd_release (abfd, ptr); |
1340 | 3.59k | return NULL; |
1341 | 3.59k | } |
1342 | | |
1343 | | /* Now construct the bfd. */ |
1344 | 26.8k | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, |
1345 | 26.8k | source_dll, ordinal, types)) |
1346 | 6.30k | { |
1347 | 6.30k | bfd_release (abfd, ptr); |
1348 | 6.30k | return NULL; |
1349 | 6.30k | } |
1350 | | |
1351 | 20.5k | return pe_ILF_cleanup; |
1352 | 26.8k | } pei-i386.c:pe_ILF_object_p Line | Count | Source | 1177 | 32.3k | { | 1178 | 32.3k | bfd_byte buffer[14]; | 1179 | 32.3k | bfd_byte * ptr; | 1180 | 32.3k | char * symbol_name; | 1181 | 32.3k | char * source_dll; | 1182 | 32.3k | unsigned int machine; | 1183 | 32.3k | bfd_size_type size; | 1184 | 32.3k | unsigned int ordinal; | 1185 | 32.3k | unsigned int types; | 1186 | 32.3k | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 32.3k | if (bfd_read (buffer, 14, abfd) != 14) | 1191 | 548 | return NULL; | 1192 | | | 1193 | 31.8k | ptr = buffer; | 1194 | | | 1195 | 31.8k | machine = H_GET_16 (abfd, ptr); | 1196 | 31.8k | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 31.8k | magic = 0; | 1200 | | | 1201 | 31.8k | switch (machine) | 1202 | 31.8k | { | 1203 | 354 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 359 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 360 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 371 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 371 | break; | 1208 | | | 1209 | 6.61k | case IMAGE_FILE_MACHINE_I386: | 1210 | 6.61k | #ifdef I386MAGIC | 1211 | 6.61k | magic = I386MAGIC; | 1212 | 6.61k | #endif | 1213 | 6.61k | break; | 1214 | | | 1215 | 7.02k | case IMAGE_FILE_MACHINE_AMD64: | 1216 | | #ifdef AMD64MAGIC | 1217 | | magic = AMD64MAGIC; | 1218 | | #endif | 1219 | 7.02k | break; | 1220 | | | 1221 | 6 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 10 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 15 | case IMAGE_FILE_MACHINE_R10000: | 1224 | | | 1225 | 16 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 17 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 18 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 18 | break; | 1232 | | | 1233 | 1.90k | case IMAGE_FILE_MACHINE_SH3: | 1234 | 5.03k | case IMAGE_FILE_MACHINE_SH4: | 1235 | | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | | magic = SH_ARCH_MAGIC_WINCE; | 1237 | | #endif | 1238 | 5.03k | break; | 1239 | | | 1240 | 2.52k | case IMAGE_FILE_MACHINE_ARM: | 1241 | | #ifdef ARMPEMAGIC | 1242 | | magic = ARMPEMAGIC; | 1243 | | #endif | 1244 | 2.52k | break; | 1245 | | | 1246 | 1.69k | case IMAGE_FILE_MACHINE_ARM64: | 1247 | | #ifdef AARCH64MAGIC | 1248 | | magic = AARCH64MAGIC; | 1249 | | #endif | 1250 | 1.69k | break; | 1251 | | | 1252 | 4.08k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | | #ifdef LOONGARCH64MAGIC | 1254 | | magic = LOONGARCH64MAGIC; | 1255 | | #endif | 1256 | 4.08k | break; | 1257 | | | 1258 | 1.22k | case IMAGE_FILE_MACHINE_RISCV64: | 1259 | | #ifdef RISCV64MAGIC | 1260 | | magic = RISCV64MAGIC; | 1261 | | #endif | 1262 | 1.22k | break; | 1263 | | | 1264 | 456 | case IMAGE_FILE_MACHINE_THUMB: | 1265 | | #ifdef THUMBPEMAGIC | 1266 | | { | 1267 | | extern const bfd_target TARGET_LITTLE_SYM; | 1268 | | | 1269 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1270 | | magic = THUMBPEMAGIC; | 1271 | | } | 1272 | | #endif | 1273 | 456 | break; | 1274 | | | 1275 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1276 | | /* We no longer support PowerPC. */ | 1277 | 2.73k | default: | 1278 | 2.73k | _bfd_error_handler | 1279 | | /* xgettext:c-format */ | 1280 | 2.73k | (_("%pB: unrecognised machine type (0x%x)" | 1281 | 2.73k | " in Import Library Format archive"), | 1282 | 2.73k | abfd, machine); | 1283 | 2.73k | bfd_set_error (bfd_error_malformed_archive); | 1284 | | | 1285 | 2.73k | return NULL; | 1286 | 0 | break; | 1287 | 31.8k | } | 1288 | | | 1289 | 29.0k | if (magic == 0) | 1290 | 22.4k | { | 1291 | 22.4k | _bfd_error_handler | 1292 | | /* xgettext:c-format */ | 1293 | 22.4k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1294 | 22.4k | " in Import Library Format archive"), | 1295 | 22.4k | abfd, machine); | 1296 | 22.4k | bfd_set_error (bfd_error_wrong_format); | 1297 | | | 1298 | 22.4k | return NULL; | 1299 | 22.4k | } | 1300 | | | 1301 | | /* We do not bother to check the date. | 1302 | | date = H_GET_32 (abfd, ptr); */ | 1303 | 6.61k | ptr += 4; | 1304 | | | 1305 | 6.61k | size = H_GET_32 (abfd, ptr); | 1306 | 6.61k | ptr += 4; | 1307 | | | 1308 | 6.61k | if (size == 0) | 1309 | 314 | { | 1310 | 314 | _bfd_error_handler | 1311 | 314 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1312 | 314 | bfd_set_error (bfd_error_malformed_archive); | 1313 | | | 1314 | 314 | return NULL; | 1315 | 314 | } | 1316 | | | 1317 | 6.30k | ordinal = H_GET_16 (abfd, ptr); | 1318 | 6.30k | ptr += 2; | 1319 | | | 1320 | 6.30k | types = H_GET_16 (abfd, ptr); | 1321 | | /* ptr += 2; */ | 1322 | | | 1323 | | /* Now read in the two strings that follow. */ | 1324 | 6.30k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1325 | 6.30k | if (ptr == NULL) | 1326 | 1.17k | return NULL; | 1327 | | | 1328 | 5.12k | symbol_name = (char *) ptr; | 1329 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1330 | 5.12k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1331 | | | 1332 | | /* Verify that the strings are null terminated. */ | 1333 | 5.12k | if (ptr[size - 1] != 0 | 1334 | 5.12k | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1335 | 534 | { | 1336 | 534 | _bfd_error_handler | 1337 | 534 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1338 | 534 | bfd_set_error (bfd_error_malformed_archive); | 1339 | 534 | bfd_release (abfd, ptr); | 1340 | 534 | return NULL; | 1341 | 534 | } | 1342 | | | 1343 | | /* Now construct the bfd. */ | 1344 | 4.59k | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1345 | 4.59k | source_dll, ordinal, types)) | 1346 | 1.07k | { | 1347 | 1.07k | bfd_release (abfd, ptr); | 1348 | 1.07k | return NULL; | 1349 | 1.07k | } | 1350 | | | 1351 | 3.52k | return pe_ILF_cleanup; | 1352 | 4.59k | } |
pei-x86_64.c:pe_ILF_object_p Line | Count | Source | 1177 | 25.6k | { | 1178 | 25.6k | bfd_byte buffer[14]; | 1179 | 25.6k | bfd_byte * ptr; | 1180 | 25.6k | char * symbol_name; | 1181 | 25.6k | char * source_dll; | 1182 | 25.6k | unsigned int machine; | 1183 | 25.6k | bfd_size_type size; | 1184 | 25.6k | unsigned int ordinal; | 1185 | 25.6k | unsigned int types; | 1186 | 25.6k | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 25.6k | if (bfd_read (buffer, 14, abfd) != 14) | 1191 | 548 | return NULL; | 1192 | | | 1193 | 25.0k | ptr = buffer; | 1194 | | | 1195 | 25.0k | machine = H_GET_16 (abfd, ptr); | 1196 | 25.0k | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 25.0k | magic = 0; | 1200 | | | 1201 | 25.0k | switch (machine) | 1202 | 25.0k | { | 1203 | 354 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 359 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 360 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 371 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 371 | break; | 1208 | | | 1209 | 3.14k | case IMAGE_FILE_MACHINE_I386: | 1210 | | #ifdef I386MAGIC | 1211 | | magic = I386MAGIC; | 1212 | | #endif | 1213 | 3.14k | break; | 1214 | | | 1215 | 7.03k | case IMAGE_FILE_MACHINE_AMD64: | 1216 | 7.03k | #ifdef AMD64MAGIC | 1217 | 7.03k | magic = AMD64MAGIC; | 1218 | 7.03k | #endif | 1219 | 7.03k | break; | 1220 | | | 1221 | 6 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 10 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 15 | case IMAGE_FILE_MACHINE_R10000: | 1224 | | | 1225 | 16 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 17 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 18 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 18 | break; | 1232 | | | 1233 | 211 | case IMAGE_FILE_MACHINE_SH3: | 1234 | 2.33k | case IMAGE_FILE_MACHINE_SH4: | 1235 | | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | | magic = SH_ARCH_MAGIC_WINCE; | 1237 | | #endif | 1238 | 2.33k | break; | 1239 | | | 1240 | 2.52k | case IMAGE_FILE_MACHINE_ARM: | 1241 | | #ifdef ARMPEMAGIC | 1242 | | magic = ARMPEMAGIC; | 1243 | | #endif | 1244 | 2.52k | break; | 1245 | | | 1246 | 1.69k | case IMAGE_FILE_MACHINE_ARM64: | 1247 | | #ifdef AARCH64MAGIC | 1248 | | magic = AARCH64MAGIC; | 1249 | | #endif | 1250 | 1.69k | break; | 1251 | | | 1252 | 4.08k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | | #ifdef LOONGARCH64MAGIC | 1254 | | magic = LOONGARCH64MAGIC; | 1255 | | #endif | 1256 | 4.08k | break; | 1257 | | | 1258 | 656 | case IMAGE_FILE_MACHINE_RISCV64: | 1259 | | #ifdef RISCV64MAGIC | 1260 | | magic = RISCV64MAGIC; | 1261 | | #endif | 1262 | 656 | break; | 1263 | | | 1264 | 456 | case IMAGE_FILE_MACHINE_THUMB: | 1265 | | #ifdef THUMBPEMAGIC | 1266 | | { | 1267 | | extern const bfd_target TARGET_LITTLE_SYM; | 1268 | | | 1269 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1270 | | magic = THUMBPEMAGIC; | 1271 | | } | 1272 | | #endif | 1273 | 456 | break; | 1274 | | | 1275 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1276 | | /* We no longer support PowerPC. */ | 1277 | 2.73k | default: | 1278 | 2.73k | _bfd_error_handler | 1279 | | /* xgettext:c-format */ | 1280 | 2.73k | (_("%pB: unrecognised machine type (0x%x)" | 1281 | 2.73k | " in Import Library Format archive"), | 1282 | 2.73k | abfd, machine); | 1283 | 2.73k | bfd_set_error (bfd_error_malformed_archive); | 1284 | | | 1285 | 2.73k | return NULL; | 1286 | 0 | break; | 1287 | 25.0k | } | 1288 | | | 1289 | 22.3k | if (magic == 0) | 1290 | 15.2k | { | 1291 | 15.2k | _bfd_error_handler | 1292 | | /* xgettext:c-format */ | 1293 | 15.2k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1294 | 15.2k | " in Import Library Format archive"), | 1295 | 15.2k | abfd, machine); | 1296 | 15.2k | bfd_set_error (bfd_error_wrong_format); | 1297 | | | 1298 | 15.2k | return NULL; | 1299 | 15.2k | } | 1300 | | | 1301 | | /* We do not bother to check the date. | 1302 | | date = H_GET_32 (abfd, ptr); */ | 1303 | 7.03k | ptr += 4; | 1304 | | | 1305 | 7.03k | size = H_GET_32 (abfd, ptr); | 1306 | 7.03k | ptr += 4; | 1307 | | | 1308 | 7.03k | if (size == 0) | 1309 | 316 | { | 1310 | 316 | _bfd_error_handler | 1311 | 316 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1312 | 316 | bfd_set_error (bfd_error_malformed_archive); | 1313 | | | 1314 | 316 | return NULL; | 1315 | 316 | } | 1316 | | | 1317 | 6.71k | ordinal = H_GET_16 (abfd, ptr); | 1318 | 6.71k | ptr += 2; | 1319 | | | 1320 | 6.71k | types = H_GET_16 (abfd, ptr); | 1321 | | /* ptr += 2; */ | 1322 | | | 1323 | | /* Now read in the two strings that follow. */ | 1324 | 6.71k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1325 | 6.71k | if (ptr == NULL) | 1326 | 853 | return NULL; | 1327 | | | 1328 | 5.86k | symbol_name = (char *) ptr; | 1329 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1330 | 5.86k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1331 | | | 1332 | | /* Verify that the strings are null terminated. */ | 1333 | 5.86k | if (ptr[size - 1] != 0 | 1334 | 5.86k | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1335 | 837 | { | 1336 | 837 | _bfd_error_handler | 1337 | 837 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1338 | 837 | bfd_set_error (bfd_error_malformed_archive); | 1339 | 837 | bfd_release (abfd, ptr); | 1340 | 837 | return NULL; | 1341 | 837 | } | 1342 | | | 1343 | | /* Now construct the bfd. */ | 1344 | 5.02k | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1345 | 5.02k | source_dll, ordinal, types)) | 1346 | 1.26k | { | 1347 | 1.26k | bfd_release (abfd, ptr); | 1348 | 1.26k | return NULL; | 1349 | 1.26k | } | 1350 | | | 1351 | 3.76k | return pe_ILF_cleanup; | 1352 | 5.02k | } |
pei-aarch64.c:pe_ILF_object_p Line | Count | Source | 1177 | 40.2k | { | 1178 | 40.2k | bfd_byte buffer[14]; | 1179 | 40.2k | bfd_byte * ptr; | 1180 | 40.2k | char * symbol_name; | 1181 | 40.2k | char * source_dll; | 1182 | 40.2k | unsigned int machine; | 1183 | 40.2k | bfd_size_type size; | 1184 | 40.2k | unsigned int ordinal; | 1185 | 40.2k | unsigned int types; | 1186 | 40.2k | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 40.2k | if (bfd_read (buffer, 14, abfd) != 14) | 1191 | 548 | return NULL; | 1192 | | | 1193 | 39.6k | ptr = buffer; | 1194 | | | 1195 | 39.6k | machine = H_GET_16 (abfd, ptr); | 1196 | 39.6k | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 39.6k | magic = 0; | 1200 | | | 1201 | 39.6k | switch (machine) | 1202 | 39.6k | { | 1203 | 354 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 359 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 360 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 371 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 371 | break; | 1208 | | | 1209 | 6.60k | case IMAGE_FILE_MACHINE_I386: | 1210 | | #ifdef I386MAGIC | 1211 | | magic = I386MAGIC; | 1212 | | #endif | 1213 | 6.60k | break; | 1214 | | | 1215 | 7.02k | case IMAGE_FILE_MACHINE_AMD64: | 1216 | | #ifdef AMD64MAGIC | 1217 | | magic = AMD64MAGIC; | 1218 | | #endif | 1219 | 7.02k | break; | 1220 | | | 1221 | 6 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 10 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 15 | case IMAGE_FILE_MACHINE_R10000: | 1224 | | | 1225 | 16 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 17 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 18 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 18 | break; | 1232 | | | 1233 | 1.90k | case IMAGE_FILE_MACHINE_SH3: | 1234 | 5.03k | case IMAGE_FILE_MACHINE_SH4: | 1235 | | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | | magic = SH_ARCH_MAGIC_WINCE; | 1237 | | #endif | 1238 | 5.03k | break; | 1239 | | | 1240 | 5.99k | case IMAGE_FILE_MACHINE_ARM: | 1241 | | #ifdef ARMPEMAGIC | 1242 | | magic = ARMPEMAGIC; | 1243 | | #endif | 1244 | 5.99k | break; | 1245 | | | 1246 | 5.17k | case IMAGE_FILE_MACHINE_ARM64: | 1247 | 5.17k | #ifdef AARCH64MAGIC | 1248 | 5.17k | magic = AARCH64MAGIC; | 1249 | 5.17k | #endif | 1250 | 5.17k | break; | 1251 | | | 1252 | 4.08k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | | #ifdef LOONGARCH64MAGIC | 1254 | | magic = LOONGARCH64MAGIC; | 1255 | | #endif | 1256 | 4.08k | break; | 1257 | | | 1258 | 1.22k | case IMAGE_FILE_MACHINE_RISCV64: | 1259 | | #ifdef RISCV64MAGIC | 1260 | | magic = RISCV64MAGIC; | 1261 | | #endif | 1262 | 1.22k | break; | 1263 | | | 1264 | 1.41k | case IMAGE_FILE_MACHINE_THUMB: | 1265 | | #ifdef THUMBPEMAGIC | 1266 | | { | 1267 | | extern const bfd_target TARGET_LITTLE_SYM; | 1268 | | | 1269 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1270 | | magic = THUMBPEMAGIC; | 1271 | | } | 1272 | | #endif | 1273 | 1.41k | break; | 1274 | | | 1275 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1276 | | /* We no longer support PowerPC. */ | 1277 | 2.73k | default: | 1278 | 2.73k | _bfd_error_handler | 1279 | | /* xgettext:c-format */ | 1280 | 2.73k | (_("%pB: unrecognised machine type (0x%x)" | 1281 | 2.73k | " in Import Library Format archive"), | 1282 | 2.73k | abfd, machine); | 1283 | 2.73k | bfd_set_error (bfd_error_malformed_archive); | 1284 | | | 1285 | 2.73k | return NULL; | 1286 | 0 | break; | 1287 | 39.6k | } | 1288 | | | 1289 | 36.9k | if (magic == 0) | 1290 | 31.7k | { | 1291 | 31.7k | _bfd_error_handler | 1292 | | /* xgettext:c-format */ | 1293 | 31.7k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1294 | 31.7k | " in Import Library Format archive"), | 1295 | 31.7k | abfd, machine); | 1296 | 31.7k | bfd_set_error (bfd_error_wrong_format); | 1297 | | | 1298 | 31.7k | return NULL; | 1299 | 31.7k | } | 1300 | | | 1301 | | /* We do not bother to check the date. | 1302 | | date = H_GET_32 (abfd, ptr); */ | 1303 | 5.17k | ptr += 4; | 1304 | | | 1305 | 5.17k | size = H_GET_32 (abfd, ptr); | 1306 | 5.17k | ptr += 4; | 1307 | | | 1308 | 5.17k | if (size == 0) | 1309 | 114 | { | 1310 | 114 | _bfd_error_handler | 1311 | 114 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1312 | 114 | bfd_set_error (bfd_error_malformed_archive); | 1313 | | | 1314 | 114 | return NULL; | 1315 | 114 | } | 1316 | | | 1317 | 5.05k | ordinal = H_GET_16 (abfd, ptr); | 1318 | 5.05k | ptr += 2; | 1319 | | | 1320 | 5.05k | types = H_GET_16 (abfd, ptr); | 1321 | | /* ptr += 2; */ | 1322 | | | 1323 | | /* Now read in the two strings that follow. */ | 1324 | 5.05k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1325 | 5.05k | if (ptr == NULL) | 1326 | 451 | return NULL; | 1327 | | | 1328 | 4.60k | symbol_name = (char *) ptr; | 1329 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1330 | 4.60k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1331 | | | 1332 | | /* Verify that the strings are null terminated. */ | 1333 | 4.60k | if (ptr[size - 1] != 0 | 1334 | 4.60k | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1335 | 432 | { | 1336 | 432 | _bfd_error_handler | 1337 | 432 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1338 | 432 | bfd_set_error (bfd_error_malformed_archive); | 1339 | 432 | bfd_release (abfd, ptr); | 1340 | 432 | return NULL; | 1341 | 432 | } | 1342 | | | 1343 | | /* Now construct the bfd. */ | 1344 | 4.17k | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1345 | 4.17k | source_dll, ordinal, types)) | 1346 | 656 | { | 1347 | 656 | bfd_release (abfd, ptr); | 1348 | 656 | return NULL; | 1349 | 656 | } | 1350 | | | 1351 | 3.51k | return pe_ILF_cleanup; | 1352 | 4.17k | } |
Unexecuted instantiation: pei-ia64.c:pe_ILF_object_p pei-loongarch64.c:pe_ILF_object_p Line | Count | Source | 1177 | 21.9k | { | 1178 | 21.9k | bfd_byte buffer[14]; | 1179 | 21.9k | bfd_byte * ptr; | 1180 | 21.9k | char * symbol_name; | 1181 | 21.9k | char * source_dll; | 1182 | 21.9k | unsigned int machine; | 1183 | 21.9k | bfd_size_type size; | 1184 | 21.9k | unsigned int ordinal; | 1185 | 21.9k | unsigned int types; | 1186 | 21.9k | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 21.9k | if (bfd_read (buffer, 14, abfd) != 14) | 1191 | 548 | return NULL; | 1192 | | | 1193 | 21.3k | ptr = buffer; | 1194 | | | 1195 | 21.3k | machine = H_GET_16 (abfd, ptr); | 1196 | 21.3k | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 21.3k | magic = 0; | 1200 | | | 1201 | 21.3k | switch (machine) | 1202 | 21.3k | { | 1203 | 354 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 359 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 360 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 371 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 371 | break; | 1208 | | | 1209 | 3.14k | case IMAGE_FILE_MACHINE_I386: | 1210 | | #ifdef I386MAGIC | 1211 | | magic = I386MAGIC; | 1212 | | #endif | 1213 | 3.14k | break; | 1214 | | | 1215 | 3.32k | case IMAGE_FILE_MACHINE_AMD64: | 1216 | | #ifdef AMD64MAGIC | 1217 | | magic = AMD64MAGIC; | 1218 | | #endif | 1219 | 3.32k | break; | 1220 | | | 1221 | 6 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 10 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 15 | case IMAGE_FILE_MACHINE_R10000: | 1224 | | | 1225 | 16 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 17 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 18 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 18 | break; | 1232 | | | 1233 | 211 | case IMAGE_FILE_MACHINE_SH3: | 1234 | 2.33k | case IMAGE_FILE_MACHINE_SH4: | 1235 | | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | | magic = SH_ARCH_MAGIC_WINCE; | 1237 | | #endif | 1238 | 2.33k | break; | 1239 | | | 1240 | 2.52k | case IMAGE_FILE_MACHINE_ARM: | 1241 | | #ifdef ARMPEMAGIC | 1242 | | magic = ARMPEMAGIC; | 1243 | | #endif | 1244 | 2.52k | break; | 1245 | | | 1246 | 1.69k | case IMAGE_FILE_MACHINE_ARM64: | 1247 | | #ifdef AARCH64MAGIC | 1248 | | magic = AARCH64MAGIC; | 1249 | | #endif | 1250 | 1.69k | break; | 1251 | | | 1252 | 4.10k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | 4.10k | #ifdef LOONGARCH64MAGIC | 1254 | 4.10k | magic = LOONGARCH64MAGIC; | 1255 | 4.10k | #endif | 1256 | 4.10k | break; | 1257 | | | 1258 | 656 | case IMAGE_FILE_MACHINE_RISCV64: | 1259 | | #ifdef RISCV64MAGIC | 1260 | | magic = RISCV64MAGIC; | 1261 | | #endif | 1262 | 656 | break; | 1263 | | | 1264 | 456 | case IMAGE_FILE_MACHINE_THUMB: | 1265 | | #ifdef THUMBPEMAGIC | 1266 | | { | 1267 | | extern const bfd_target TARGET_LITTLE_SYM; | 1268 | | | 1269 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1270 | | magic = THUMBPEMAGIC; | 1271 | | } | 1272 | | #endif | 1273 | 456 | break; | 1274 | | | 1275 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1276 | | /* We no longer support PowerPC. */ | 1277 | 2.73k | default: | 1278 | 2.73k | _bfd_error_handler | 1279 | | /* xgettext:c-format */ | 1280 | 2.73k | (_("%pB: unrecognised machine type (0x%x)" | 1281 | 2.73k | " in Import Library Format archive"), | 1282 | 2.73k | abfd, machine); | 1283 | 2.73k | bfd_set_error (bfd_error_malformed_archive); | 1284 | | | 1285 | 2.73k | return NULL; | 1286 | 0 | break; | 1287 | 21.3k | } | 1288 | | | 1289 | 18.6k | if (magic == 0) | 1290 | 14.5k | { | 1291 | 14.5k | _bfd_error_handler | 1292 | | /* xgettext:c-format */ | 1293 | 14.5k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1294 | 14.5k | " in Import Library Format archive"), | 1295 | 14.5k | abfd, machine); | 1296 | 14.5k | bfd_set_error (bfd_error_wrong_format); | 1297 | | | 1298 | 14.5k | return NULL; | 1299 | 14.5k | } | 1300 | | | 1301 | | /* We do not bother to check the date. | 1302 | | date = H_GET_32 (abfd, ptr); */ | 1303 | 4.10k | ptr += 4; | 1304 | | | 1305 | 4.10k | size = H_GET_32 (abfd, ptr); | 1306 | 4.10k | ptr += 4; | 1307 | | | 1308 | 4.10k | if (size == 0) | 1309 | 219 | { | 1310 | 219 | _bfd_error_handler | 1311 | 219 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1312 | 219 | bfd_set_error (bfd_error_malformed_archive); | 1313 | | | 1314 | 219 | return NULL; | 1315 | 219 | } | 1316 | | | 1317 | 3.88k | ordinal = H_GET_16 (abfd, ptr); | 1318 | 3.88k | ptr += 2; | 1319 | | | 1320 | 3.88k | types = H_GET_16 (abfd, ptr); | 1321 | | /* ptr += 2; */ | 1322 | | | 1323 | | /* Now read in the two strings that follow. */ | 1324 | 3.88k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1325 | 3.88k | if (ptr == NULL) | 1326 | 581 | return NULL; | 1327 | | | 1328 | 3.30k | symbol_name = (char *) ptr; | 1329 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1330 | 3.30k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1331 | | | 1332 | | /* Verify that the strings are null terminated. */ | 1333 | 3.30k | if (ptr[size - 1] != 0 | 1334 | 3.30k | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1335 | 435 | { | 1336 | 435 | _bfd_error_handler | 1337 | 435 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1338 | 435 | bfd_set_error (bfd_error_malformed_archive); | 1339 | 435 | bfd_release (abfd, ptr); | 1340 | 435 | return NULL; | 1341 | 435 | } | 1342 | | | 1343 | | /* Now construct the bfd. */ | 1344 | 2.87k | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1345 | 2.87k | source_dll, ordinal, types)) | 1346 | 1.06k | { | 1347 | 1.06k | bfd_release (abfd, ptr); | 1348 | 1.06k | return NULL; | 1349 | 1.06k | } | 1350 | | | 1351 | 1.80k | return pe_ILF_cleanup; | 1352 | 2.87k | } |
pei-riscv64.c:pe_ILF_object_p Line | Count | Source | 1177 | 28.8k | { | 1178 | 28.8k | bfd_byte buffer[14]; | 1179 | 28.8k | bfd_byte * ptr; | 1180 | 28.8k | char * symbol_name; | 1181 | 28.8k | char * source_dll; | 1182 | 28.8k | unsigned int machine; | 1183 | 28.8k | bfd_size_type size; | 1184 | 28.8k | unsigned int ordinal; | 1185 | 28.8k | unsigned int types; | 1186 | 28.8k | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 28.8k | if (bfd_read (buffer, 14, abfd) != 14) | 1191 | 548 | return NULL; | 1192 | | | 1193 | 28.3k | ptr = buffer; | 1194 | | | 1195 | 28.3k | machine = H_GET_16 (abfd, ptr); | 1196 | 28.3k | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 28.3k | magic = 0; | 1200 | | | 1201 | 28.3k | switch (machine) | 1202 | 28.3k | { | 1203 | 354 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 359 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 360 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 371 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 371 | break; | 1208 | | | 1209 | 3.14k | case IMAGE_FILE_MACHINE_I386: | 1210 | | #ifdef I386MAGIC | 1211 | | magic = I386MAGIC; | 1212 | | #endif | 1213 | 3.14k | break; | 1214 | | | 1215 | 7.02k | case IMAGE_FILE_MACHINE_AMD64: | 1216 | | #ifdef AMD64MAGIC | 1217 | | magic = AMD64MAGIC; | 1218 | | #endif | 1219 | 7.02k | break; | 1220 | | | 1221 | 6 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 10 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 15 | case IMAGE_FILE_MACHINE_R10000: | 1224 | | | 1225 | 16 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 17 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 18 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 18 | break; | 1232 | | | 1233 | 1.90k | case IMAGE_FILE_MACHINE_SH3: | 1234 | 5.03k | case IMAGE_FILE_MACHINE_SH4: | 1235 | | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | | magic = SH_ARCH_MAGIC_WINCE; | 1237 | | #endif | 1238 | 5.03k | break; | 1239 | | | 1240 | 2.52k | case IMAGE_FILE_MACHINE_ARM: | 1241 | | #ifdef ARMPEMAGIC | 1242 | | magic = ARMPEMAGIC; | 1243 | | #endif | 1244 | 2.52k | break; | 1245 | | | 1246 | 1.69k | case IMAGE_FILE_MACHINE_ARM64: | 1247 | | #ifdef AARCH64MAGIC | 1248 | | magic = AARCH64MAGIC; | 1249 | | #endif | 1250 | 1.69k | break; | 1251 | | | 1252 | 4.08k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | | #ifdef LOONGARCH64MAGIC | 1254 | | magic = LOONGARCH64MAGIC; | 1255 | | #endif | 1256 | 4.08k | break; | 1257 | | | 1258 | 1.23k | case IMAGE_FILE_MACHINE_RISCV64: | 1259 | 1.23k | #ifdef RISCV64MAGIC | 1260 | 1.23k | magic = RISCV64MAGIC; | 1261 | 1.23k | #endif | 1262 | 1.23k | break; | 1263 | | | 1264 | 456 | case IMAGE_FILE_MACHINE_THUMB: | 1265 | | #ifdef THUMBPEMAGIC | 1266 | | { | 1267 | | extern const bfd_target TARGET_LITTLE_SYM; | 1268 | | | 1269 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1270 | | magic = THUMBPEMAGIC; | 1271 | | } | 1272 | | #endif | 1273 | 456 | break; | 1274 | | | 1275 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1276 | | /* We no longer support PowerPC. */ | 1277 | 2.73k | default: | 1278 | 2.73k | _bfd_error_handler | 1279 | | /* xgettext:c-format */ | 1280 | 2.73k | (_("%pB: unrecognised machine type (0x%x)" | 1281 | 2.73k | " in Import Library Format archive"), | 1282 | 2.73k | abfd, machine); | 1283 | 2.73k | bfd_set_error (bfd_error_malformed_archive); | 1284 | | | 1285 | 2.73k | return NULL; | 1286 | 0 | break; | 1287 | 28.3k | } | 1288 | | | 1289 | 25.6k | if (magic == 0) | 1290 | 24.3k | { | 1291 | 24.3k | _bfd_error_handler | 1292 | | /* xgettext:c-format */ | 1293 | 24.3k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1294 | 24.3k | " in Import Library Format archive"), | 1295 | 24.3k | abfd, machine); | 1296 | 24.3k | bfd_set_error (bfd_error_wrong_format); | 1297 | | | 1298 | 24.3k | return NULL; | 1299 | 24.3k | } | 1300 | | | 1301 | | /* We do not bother to check the date. | 1302 | | date = H_GET_32 (abfd, ptr); */ | 1303 | 1.23k | ptr += 4; | 1304 | | | 1305 | 1.23k | size = H_GET_32 (abfd, ptr); | 1306 | 1.23k | ptr += 4; | 1307 | | | 1308 | 1.23k | if (size == 0) | 1309 | 10 | { | 1310 | 10 | _bfd_error_handler | 1311 | 10 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1312 | 10 | bfd_set_error (bfd_error_malformed_archive); | 1313 | | | 1314 | 10 | return NULL; | 1315 | 10 | } | 1316 | | | 1317 | 1.22k | ordinal = H_GET_16 (abfd, ptr); | 1318 | 1.22k | ptr += 2; | 1319 | | | 1320 | 1.22k | types = H_GET_16 (abfd, ptr); | 1321 | | /* ptr += 2; */ | 1322 | | | 1323 | | /* Now read in the two strings that follow. */ | 1324 | 1.22k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1325 | 1.22k | if (ptr == NULL) | 1326 | 235 | return NULL; | 1327 | | | 1328 | 988 | symbol_name = (char *) ptr; | 1329 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1330 | 988 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1331 | | | 1332 | | /* Verify that the strings are null terminated. */ | 1333 | 988 | if (ptr[size - 1] != 0 | 1334 | 988 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1335 | 122 | { | 1336 | 122 | _bfd_error_handler | 1337 | 122 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1338 | 122 | bfd_set_error (bfd_error_malformed_archive); | 1339 | 122 | bfd_release (abfd, ptr); | 1340 | 122 | return NULL; | 1341 | 122 | } | 1342 | | | 1343 | | /* Now construct the bfd. */ | 1344 | 866 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1345 | 866 | source_dll, ordinal, types)) | 1346 | 247 | { | 1347 | 247 | bfd_release (abfd, ptr); | 1348 | 247 | return NULL; | 1349 | 247 | } | 1350 | | | 1351 | 619 | return pe_ILF_cleanup; | 1352 | 866 | } |
pei-arm-wince.c:pe_ILF_object_p Line | Count | Source | 1177 | 32.3k | { | 1178 | 32.3k | bfd_byte buffer[14]; | 1179 | 32.3k | bfd_byte * ptr; | 1180 | 32.3k | char * symbol_name; | 1181 | 32.3k | char * source_dll; | 1182 | 32.3k | unsigned int machine; | 1183 | 32.3k | bfd_size_type size; | 1184 | 32.3k | unsigned int ordinal; | 1185 | 32.3k | unsigned int types; | 1186 | 32.3k | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 32.3k | if (bfd_read (buffer, 14, abfd) != 14) | 1191 | 551 | return NULL; | 1192 | | | 1193 | 31.7k | ptr = buffer; | 1194 | | | 1195 | 31.7k | machine = H_GET_16 (abfd, ptr); | 1196 | 31.7k | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 31.7k | magic = 0; | 1200 | | | 1201 | 31.7k | switch (machine) | 1202 | 31.7k | { | 1203 | 352 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 358 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 359 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 369 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 369 | break; | 1208 | | | 1209 | 6.59k | case IMAGE_FILE_MACHINE_I386: | 1210 | | #ifdef I386MAGIC | 1211 | | magic = I386MAGIC; | 1212 | | #endif | 1213 | 6.59k | break; | 1214 | | | 1215 | 7.00k | case IMAGE_FILE_MACHINE_AMD64: | 1216 | | #ifdef AMD64MAGIC | 1217 | | magic = AMD64MAGIC; | 1218 | | #endif | 1219 | 7.00k | break; | 1220 | | | 1221 | 5 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 8 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 13 | case IMAGE_FILE_MACHINE_R10000: | 1224 | | | 1225 | 16 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 19 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 20 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 20 | break; | 1232 | | | 1233 | 1.88k | case IMAGE_FILE_MACHINE_SH3: | 1234 | 5.00k | case IMAGE_FILE_MACHINE_SH4: | 1235 | | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | | magic = SH_ARCH_MAGIC_WINCE; | 1237 | | #endif | 1238 | 5.00k | break; | 1239 | | | 1240 | 2.60k | case IMAGE_FILE_MACHINE_ARM: | 1241 | 2.60k | #ifdef ARMPEMAGIC | 1242 | 2.60k | magic = ARMPEMAGIC; | 1243 | 2.60k | #endif | 1244 | 2.60k | break; | 1245 | | | 1246 | 1.68k | case IMAGE_FILE_MACHINE_ARM64: | 1247 | | #ifdef AARCH64MAGIC | 1248 | | magic = AARCH64MAGIC; | 1249 | | #endif | 1250 | 1.68k | break; | 1251 | | | 1252 | 4.07k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | | #ifdef LOONGARCH64MAGIC | 1254 | | magic = LOONGARCH64MAGIC; | 1255 | | #endif | 1256 | 4.07k | break; | 1257 | | | 1258 | 1.22k | case IMAGE_FILE_MACHINE_RISCV64: | 1259 | | #ifdef RISCV64MAGIC | 1260 | | magic = RISCV64MAGIC; | 1261 | | #endif | 1262 | 1.22k | break; | 1263 | | | 1264 | 439 | case IMAGE_FILE_MACHINE_THUMB: | 1265 | 439 | #ifdef THUMBPEMAGIC | 1266 | 439 | { | 1267 | 439 | extern const bfd_target TARGET_LITTLE_SYM; | 1268 | | | 1269 | 439 | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1270 | 433 | magic = THUMBPEMAGIC; | 1271 | 439 | } | 1272 | 439 | #endif | 1273 | 439 | break; | 1274 | | | 1275 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1276 | | /* We no longer support PowerPC. */ | 1277 | 2.74k | default: | 1278 | 2.74k | _bfd_error_handler | 1279 | | /* xgettext:c-format */ | 1280 | 2.74k | (_("%pB: unrecognised machine type (0x%x)" | 1281 | 2.74k | " in Import Library Format archive"), | 1282 | 2.74k | abfd, machine); | 1283 | 2.74k | bfd_set_error (bfd_error_malformed_archive); | 1284 | | | 1285 | 2.74k | return NULL; | 1286 | 0 | break; | 1287 | 31.7k | } | 1288 | | | 1289 | 29.0k | if (magic == 0) | 1290 | 25.9k | { | 1291 | 25.9k | _bfd_error_handler | 1292 | | /* xgettext:c-format */ | 1293 | 25.9k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1294 | 25.9k | " in Import Library Format archive"), | 1295 | 25.9k | abfd, machine); | 1296 | 25.9k | bfd_set_error (bfd_error_wrong_format); | 1297 | | | 1298 | 25.9k | return NULL; | 1299 | 25.9k | } | 1300 | | | 1301 | | /* We do not bother to check the date. | 1302 | | date = H_GET_32 (abfd, ptr); */ | 1303 | 3.03k | ptr += 4; | 1304 | | | 1305 | 3.03k | size = H_GET_32 (abfd, ptr); | 1306 | 3.03k | ptr += 4; | 1307 | | | 1308 | 3.03k | if (size == 0) | 1309 | 213 | { | 1310 | 213 | _bfd_error_handler | 1311 | 213 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1312 | 213 | bfd_set_error (bfd_error_malformed_archive); | 1313 | | | 1314 | 213 | return NULL; | 1315 | 213 | } | 1316 | | | 1317 | 2.82k | ordinal = H_GET_16 (abfd, ptr); | 1318 | 2.82k | ptr += 2; | 1319 | | | 1320 | 2.82k | types = H_GET_16 (abfd, ptr); | 1321 | | /* ptr += 2; */ | 1322 | | | 1323 | | /* Now read in the two strings that follow. */ | 1324 | 2.82k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1325 | 2.82k | if (ptr == NULL) | 1326 | 1.65k | return NULL; | 1327 | | | 1328 | 1.16k | symbol_name = (char *) ptr; | 1329 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1330 | 1.16k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1331 | | | 1332 | | /* Verify that the strings are null terminated. */ | 1333 | 1.16k | if (ptr[size - 1] != 0 | 1334 | 1.16k | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1335 | 437 | { | 1336 | 437 | _bfd_error_handler | 1337 | 437 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1338 | 437 | bfd_set_error (bfd_error_malformed_archive); | 1339 | 437 | bfd_release (abfd, ptr); | 1340 | 437 | return NULL; | 1341 | 437 | } | 1342 | | | 1343 | | /* Now construct the bfd. */ | 1344 | 727 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1345 | 727 | source_dll, ordinal, types)) | 1346 | 659 | { | 1347 | 659 | bfd_release (abfd, ptr); | 1348 | 659 | return NULL; | 1349 | 659 | } | 1350 | | | 1351 | 68 | return pe_ILF_cleanup; | 1352 | 727 | } |
pei-arm.c:pe_ILF_object_p Line | Count | Source | 1177 | 36.7k | { | 1178 | 36.7k | bfd_byte buffer[14]; | 1179 | 36.7k | bfd_byte * ptr; | 1180 | 36.7k | char * symbol_name; | 1181 | 36.7k | char * source_dll; | 1182 | 36.7k | unsigned int machine; | 1183 | 36.7k | bfd_size_type size; | 1184 | 36.7k | unsigned int ordinal; | 1185 | 36.7k | unsigned int types; | 1186 | 36.7k | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 36.7k | if (bfd_read (buffer, 14, abfd) != 14) | 1191 | 551 | return NULL; | 1192 | | | 1193 | 36.1k | ptr = buffer; | 1194 | | | 1195 | 36.1k | machine = H_GET_16 (abfd, ptr); | 1196 | 36.1k | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 36.1k | magic = 0; | 1200 | | | 1201 | 36.1k | switch (machine) | 1202 | 36.1k | { | 1203 | 352 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 358 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 359 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 369 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 369 | break; | 1208 | | | 1209 | 6.59k | case IMAGE_FILE_MACHINE_I386: | 1210 | | #ifdef I386MAGIC | 1211 | | magic = I386MAGIC; | 1212 | | #endif | 1213 | 6.59k | break; | 1214 | | | 1215 | 7.00k | case IMAGE_FILE_MACHINE_AMD64: | 1216 | | #ifdef AMD64MAGIC | 1217 | | magic = AMD64MAGIC; | 1218 | | #endif | 1219 | 7.00k | break; | 1220 | | | 1221 | 5 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 8 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 13 | case IMAGE_FILE_MACHINE_R10000: | 1224 | | | 1225 | 16 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 19 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 20 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 20 | break; | 1232 | | | 1233 | 1.88k | case IMAGE_FILE_MACHINE_SH3: | 1234 | 5.00k | case IMAGE_FILE_MACHINE_SH4: | 1235 | | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | | magic = SH_ARCH_MAGIC_WINCE; | 1237 | | #endif | 1238 | 5.00k | break; | 1239 | | | 1240 | 6.08k | case IMAGE_FILE_MACHINE_ARM: | 1241 | 6.08k | #ifdef ARMPEMAGIC | 1242 | 6.08k | magic = ARMPEMAGIC; | 1243 | 6.08k | #endif | 1244 | 6.08k | break; | 1245 | | | 1246 | 1.68k | case IMAGE_FILE_MACHINE_ARM64: | 1247 | | #ifdef AARCH64MAGIC | 1248 | | magic = AARCH64MAGIC; | 1249 | | #endif | 1250 | 1.68k | break; | 1251 | | | 1252 | 4.07k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | | #ifdef LOONGARCH64MAGIC | 1254 | | magic = LOONGARCH64MAGIC; | 1255 | | #endif | 1256 | 4.07k | break; | 1257 | | | 1258 | 1.22k | case IMAGE_FILE_MACHINE_RISCV64: | 1259 | | #ifdef RISCV64MAGIC | 1260 | | magic = RISCV64MAGIC; | 1261 | | #endif | 1262 | 1.22k | break; | 1263 | | | 1264 | 1.39k | case IMAGE_FILE_MACHINE_THUMB: | 1265 | 1.39k | #ifdef THUMBPEMAGIC | 1266 | 1.39k | { | 1267 | 1.39k | extern const bfd_target TARGET_LITTLE_SYM; | 1268 | | | 1269 | 1.39k | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1270 | 1.39k | magic = THUMBPEMAGIC; | 1271 | 1.39k | } | 1272 | 1.39k | #endif | 1273 | 1.39k | break; | 1274 | | | 1275 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1276 | | /* We no longer support PowerPC. */ | 1277 | 2.74k | default: | 1278 | 2.74k | _bfd_error_handler | 1279 | | /* xgettext:c-format */ | 1280 | 2.74k | (_("%pB: unrecognised machine type (0x%x)" | 1281 | 2.74k | " in Import Library Format archive"), | 1282 | 2.74k | abfd, machine); | 1283 | 2.74k | bfd_set_error (bfd_error_malformed_archive); | 1284 | | | 1285 | 2.74k | return NULL; | 1286 | 0 | break; | 1287 | 36.1k | } | 1288 | | | 1289 | 33.4k | if (magic == 0) | 1290 | 25.9k | { | 1291 | 25.9k | _bfd_error_handler | 1292 | | /* xgettext:c-format */ | 1293 | 25.9k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1294 | 25.9k | " in Import Library Format archive"), | 1295 | 25.9k | abfd, machine); | 1296 | 25.9k | bfd_set_error (bfd_error_wrong_format); | 1297 | | | 1298 | 25.9k | return NULL; | 1299 | 25.9k | } | 1300 | | | 1301 | | /* We do not bother to check the date. | 1302 | | date = H_GET_32 (abfd, ptr); */ | 1303 | 7.47k | ptr += 4; | 1304 | | | 1305 | 7.47k | size = H_GET_32 (abfd, ptr); | 1306 | 7.47k | ptr += 4; | 1307 | | | 1308 | 7.47k | if (size == 0) | 1309 | 213 | { | 1310 | 213 | _bfd_error_handler | 1311 | 213 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1312 | 213 | bfd_set_error (bfd_error_malformed_archive); | 1313 | | | 1314 | 213 | return NULL; | 1315 | 213 | } | 1316 | | | 1317 | 7.25k | ordinal = H_GET_16 (abfd, ptr); | 1318 | 7.25k | ptr += 2; | 1319 | | | 1320 | 7.25k | types = H_GET_16 (abfd, ptr); | 1321 | | /* ptr += 2; */ | 1322 | | | 1323 | | /* Now read in the two strings that follow. */ | 1324 | 7.25k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1325 | 7.25k | if (ptr == NULL) | 1326 | 1.65k | return NULL; | 1327 | | | 1328 | 5.60k | symbol_name = (char *) ptr; | 1329 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1330 | 5.60k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1331 | | | 1332 | | /* Verify that the strings are null terminated. */ | 1333 | 5.60k | if (ptr[size - 1] != 0 | 1334 | 5.60k | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1335 | 437 | { | 1336 | 437 | _bfd_error_handler | 1337 | 437 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1338 | 437 | bfd_set_error (bfd_error_malformed_archive); | 1339 | 437 | bfd_release (abfd, ptr); | 1340 | 437 | return NULL; | 1341 | 437 | } | 1342 | | | 1343 | | /* Now construct the bfd. */ | 1344 | 5.16k | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1345 | 5.16k | source_dll, ordinal, types)) | 1346 | 659 | { | 1347 | 659 | bfd_release (abfd, ptr); | 1348 | 659 | return NULL; | 1349 | 659 | } | 1350 | | | 1351 | 4.50k | return pe_ILF_cleanup; | 1352 | 5.16k | } |
pei-mcore.c:pe_ILF_object_p Line | Count | Source | 1177 | 28.8k | { | 1178 | 28.8k | bfd_byte buffer[14]; | 1179 | 28.8k | bfd_byte * ptr; | 1180 | 28.8k | char * symbol_name; | 1181 | 28.8k | char * source_dll; | 1182 | 28.8k | unsigned int machine; | 1183 | 28.8k | bfd_size_type size; | 1184 | 28.8k | unsigned int ordinal; | 1185 | 28.8k | unsigned int types; | 1186 | 28.8k | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 28.8k | if (bfd_read (buffer, 14, abfd) != 14) | 1191 | 551 | return NULL; | 1192 | | | 1193 | 28.3k | ptr = buffer; | 1194 | | | 1195 | 28.3k | machine = H_GET_16 (abfd, ptr); | 1196 | 28.3k | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 28.3k | magic = 0; | 1200 | | | 1201 | 28.3k | switch (machine) | 1202 | 28.3k | { | 1203 | 352 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 358 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 359 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 369 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 369 | break; | 1208 | | | 1209 | 3.13k | case IMAGE_FILE_MACHINE_I386: | 1210 | | #ifdef I386MAGIC | 1211 | | magic = I386MAGIC; | 1212 | | #endif | 1213 | 3.13k | break; | 1214 | | | 1215 | 7.00k | case IMAGE_FILE_MACHINE_AMD64: | 1216 | | #ifdef AMD64MAGIC | 1217 | | magic = AMD64MAGIC; | 1218 | | #endif | 1219 | 7.00k | break; | 1220 | | | 1221 | 5 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 8 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 13 | case IMAGE_FILE_MACHINE_R10000: | 1224 | | | 1225 | 16 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 19 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 20 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 20 | break; | 1232 | | | 1233 | 1.88k | case IMAGE_FILE_MACHINE_SH3: | 1234 | 5.00k | case IMAGE_FILE_MACHINE_SH4: | 1235 | | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | | magic = SH_ARCH_MAGIC_WINCE; | 1237 | | #endif | 1238 | 5.00k | break; | 1239 | | | 1240 | 2.60k | case IMAGE_FILE_MACHINE_ARM: | 1241 | | #ifdef ARMPEMAGIC | 1242 | | magic = ARMPEMAGIC; | 1243 | | #endif | 1244 | 2.60k | break; | 1245 | | | 1246 | 1.68k | case IMAGE_FILE_MACHINE_ARM64: | 1247 | | #ifdef AARCH64MAGIC | 1248 | | magic = AARCH64MAGIC; | 1249 | | #endif | 1250 | 1.68k | break; | 1251 | | | 1252 | 4.07k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | | #ifdef LOONGARCH64MAGIC | 1254 | | magic = LOONGARCH64MAGIC; | 1255 | | #endif | 1256 | 4.07k | break; | 1257 | | | 1258 | 1.22k | case IMAGE_FILE_MACHINE_RISCV64: | 1259 | | #ifdef RISCV64MAGIC | 1260 | | magic = RISCV64MAGIC; | 1261 | | #endif | 1262 | 1.22k | break; | 1263 | | | 1264 | 439 | case IMAGE_FILE_MACHINE_THUMB: | 1265 | | #ifdef THUMBPEMAGIC | 1266 | | { | 1267 | | extern const bfd_target TARGET_LITTLE_SYM; | 1268 | | | 1269 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1270 | | magic = THUMBPEMAGIC; | 1271 | | } | 1272 | | #endif | 1273 | 439 | break; | 1274 | | | 1275 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1276 | | /* We no longer support PowerPC. */ | 1277 | 2.74k | default: | 1278 | 2.74k | _bfd_error_handler | 1279 | | /* xgettext:c-format */ | 1280 | 2.74k | (_("%pB: unrecognised machine type (0x%x)" | 1281 | 2.74k | " in Import Library Format archive"), | 1282 | 2.74k | abfd, machine); | 1283 | 2.74k | bfd_set_error (bfd_error_malformed_archive); | 1284 | | | 1285 | 2.74k | return NULL; | 1286 | 0 | break; | 1287 | 28.3k | } | 1288 | | | 1289 | 25.5k | if (magic == 0) | 1290 | 25.5k | { | 1291 | 25.5k | _bfd_error_handler | 1292 | | /* xgettext:c-format */ | 1293 | 25.5k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1294 | 25.5k | " in Import Library Format archive"), | 1295 | 25.5k | abfd, machine); | 1296 | 25.5k | bfd_set_error (bfd_error_wrong_format); | 1297 | | | 1298 | 25.5k | return NULL; | 1299 | 25.5k | } | 1300 | | | 1301 | | /* We do not bother to check the date. | 1302 | | date = H_GET_32 (abfd, ptr); */ | 1303 | 0 | ptr += 4; | 1304 | |
| 1305 | 0 | size = H_GET_32 (abfd, ptr); | 1306 | 0 | ptr += 4; | 1307 | |
| 1308 | 0 | if (size == 0) | 1309 | 0 | { | 1310 | 0 | _bfd_error_handler | 1311 | 0 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1312 | 0 | bfd_set_error (bfd_error_malformed_archive); | 1313 | |
| 1314 | 0 | return NULL; | 1315 | 0 | } | 1316 | | | 1317 | 0 | ordinal = H_GET_16 (abfd, ptr); | 1318 | 0 | ptr += 2; | 1319 | |
| 1320 | 0 | types = H_GET_16 (abfd, ptr); | 1321 | | /* ptr += 2; */ | 1322 | | | 1323 | | /* Now read in the two strings that follow. */ | 1324 | 0 | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1325 | 0 | if (ptr == NULL) | 1326 | 0 | return NULL; | 1327 | | | 1328 | 0 | symbol_name = (char *) ptr; | 1329 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1330 | 0 | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1331 | | | 1332 | | /* Verify that the strings are null terminated. */ | 1333 | 0 | if (ptr[size - 1] != 0 | 1334 | 0 | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1335 | 0 | { | 1336 | 0 | _bfd_error_handler | 1337 | 0 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1338 | 0 | bfd_set_error (bfd_error_malformed_archive); | 1339 | 0 | bfd_release (abfd, ptr); | 1340 | 0 | return NULL; | 1341 | 0 | } | 1342 | | | 1343 | | /* Now construct the bfd. */ | 1344 | 0 | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1345 | 0 | source_dll, ordinal, types)) | 1346 | 0 | { | 1347 | 0 | bfd_release (abfd, ptr); | 1348 | 0 | return NULL; | 1349 | 0 | } | 1350 | | | 1351 | 0 | return pe_ILF_cleanup; | 1352 | 0 | } |
Line | Count | Source | 1177 | 28.1k | { | 1178 | 28.1k | bfd_byte buffer[14]; | 1179 | 28.1k | bfd_byte * ptr; | 1180 | 28.1k | char * symbol_name; | 1181 | 28.1k | char * source_dll; | 1182 | 28.1k | unsigned int machine; | 1183 | 28.1k | bfd_size_type size; | 1184 | 28.1k | unsigned int ordinal; | 1185 | 28.1k | unsigned int types; | 1186 | 28.1k | unsigned int magic; | 1187 | | | 1188 | | /* Upon entry the first six bytes of the ILF header have | 1189 | | already been read. Now read the rest of the header. */ | 1190 | 28.1k | if (bfd_read (buffer, 14, abfd) != 14) | 1191 | 545 | return NULL; | 1192 | | | 1193 | 27.5k | ptr = buffer; | 1194 | | | 1195 | 27.5k | machine = H_GET_16 (abfd, ptr); | 1196 | 27.5k | ptr += 2; | 1197 | | | 1198 | | /* Check that the machine type is recognised. */ | 1199 | 27.5k | magic = 0; | 1200 | | | 1201 | 27.5k | switch (machine) | 1202 | 27.5k | { | 1203 | 346 | case IMAGE_FILE_MACHINE_UNKNOWN: | 1204 | 350 | case IMAGE_FILE_MACHINE_ALPHA: | 1205 | 351 | case IMAGE_FILE_MACHINE_ALPHA64: | 1206 | 361 | case IMAGE_FILE_MACHINE_IA64: | 1207 | 361 | break; | 1208 | | | 1209 | 3.13k | case IMAGE_FILE_MACHINE_I386: | 1210 | | #ifdef I386MAGIC | 1211 | | magic = I386MAGIC; | 1212 | | #endif | 1213 | 3.13k | break; | 1214 | | | 1215 | 7.00k | case IMAGE_FILE_MACHINE_AMD64: | 1216 | | #ifdef AMD64MAGIC | 1217 | | magic = AMD64MAGIC; | 1218 | | #endif | 1219 | 7.00k | break; | 1220 | | | 1221 | 5 | case IMAGE_FILE_MACHINE_R3000: | 1222 | 8 | case IMAGE_FILE_MACHINE_R4000: | 1223 | 13 | case IMAGE_FILE_MACHINE_R10000: | 1224 | | | 1225 | 14 | case IMAGE_FILE_MACHINE_MIPS16: | 1226 | 15 | case IMAGE_FILE_MACHINE_MIPSFPU: | 1227 | 16 | case IMAGE_FILE_MACHINE_MIPSFPU16: | 1228 | | #ifdef MIPS_ARCH_MAGIC_WINCE | 1229 | | magic = MIPS_ARCH_MAGIC_WINCE; | 1230 | | #endif | 1231 | 16 | break; | 1232 | | | 1233 | 1.88k | case IMAGE_FILE_MACHINE_SH3: | 1234 | 5.01k | case IMAGE_FILE_MACHINE_SH4: | 1235 | 5.01k | #ifdef SH_ARCH_MAGIC_WINCE | 1236 | 5.01k | magic = SH_ARCH_MAGIC_WINCE; | 1237 | 5.01k | #endif | 1238 | 5.01k | break; | 1239 | | | 1240 | 2.52k | case IMAGE_FILE_MACHINE_ARM: | 1241 | | #ifdef ARMPEMAGIC | 1242 | | magic = ARMPEMAGIC; | 1243 | | #endif | 1244 | 2.52k | break; | 1245 | | | 1246 | 1.68k | case IMAGE_FILE_MACHINE_ARM64: | 1247 | | #ifdef AARCH64MAGIC | 1248 | | magic = AARCH64MAGIC; | 1249 | | #endif | 1250 | 1.68k | break; | 1251 | | | 1252 | 4.07k | case IMAGE_FILE_MACHINE_LOONGARCH64: | 1253 | | #ifdef LOONGARCH64MAGIC | 1254 | | magic = LOONGARCH64MAGIC; | 1255 | | #endif | 1256 | 4.07k | break; | 1257 | | | 1258 | 648 | case IMAGE_FILE_MACHINE_RISCV64: | 1259 | | #ifdef RISCV64MAGIC | 1260 | | magic = RISCV64MAGIC; | 1261 | | #endif | 1262 | 648 | break; | 1263 | | | 1264 | 433 | case IMAGE_FILE_MACHINE_THUMB: | 1265 | | #ifdef THUMBPEMAGIC | 1266 | | { | 1267 | | extern const bfd_target TARGET_LITTLE_SYM; | 1268 | | | 1269 | | if (abfd->xvec == & TARGET_LITTLE_SYM) | 1270 | | magic = THUMBPEMAGIC; | 1271 | | } | 1272 | | #endif | 1273 | 433 | break; | 1274 | | | 1275 | 0 | case IMAGE_FILE_MACHINE_POWERPC: | 1276 | | /* We no longer support PowerPC. */ | 1277 | 2.70k | default: | 1278 | 2.70k | _bfd_error_handler | 1279 | | /* xgettext:c-format */ | 1280 | 2.70k | (_("%pB: unrecognised machine type (0x%x)" | 1281 | 2.70k | " in Import Library Format archive"), | 1282 | 2.70k | abfd, machine); | 1283 | 2.70k | bfd_set_error (bfd_error_malformed_archive); | 1284 | | | 1285 | 2.70k | return NULL; | 1286 | 0 | break; | 1287 | 27.5k | } | 1288 | | | 1289 | 24.8k | if (magic == 0) | 1290 | 19.8k | { | 1291 | 19.8k | _bfd_error_handler | 1292 | | /* xgettext:c-format */ | 1293 | 19.8k | (_("%pB: recognised but unhandled machine type (0x%x)" | 1294 | 19.8k | " in Import Library Format archive"), | 1295 | 19.8k | abfd, machine); | 1296 | 19.8k | bfd_set_error (bfd_error_wrong_format); | 1297 | | | 1298 | 19.8k | return NULL; | 1299 | 19.8k | } | 1300 | | | 1301 | | /* We do not bother to check the date. | 1302 | | date = H_GET_32 (abfd, ptr); */ | 1303 | 5.01k | ptr += 4; | 1304 | | | 1305 | 5.01k | size = H_GET_32 (abfd, ptr); | 1306 | 5.01k | ptr += 4; | 1307 | | | 1308 | 5.01k | if (size == 0) | 1309 | 319 | { | 1310 | 319 | _bfd_error_handler | 1311 | 319 | (_("%pB: size field is zero in Import Library Format header"), abfd); | 1312 | 319 | bfd_set_error (bfd_error_malformed_archive); | 1313 | | | 1314 | 319 | return NULL; | 1315 | 319 | } | 1316 | | | 1317 | 4.69k | ordinal = H_GET_16 (abfd, ptr); | 1318 | 4.69k | ptr += 2; | 1319 | | | 1320 | 4.69k | types = H_GET_16 (abfd, ptr); | 1321 | | /* ptr += 2; */ | 1322 | | | 1323 | | /* Now read in the two strings that follow. */ | 1324 | 4.69k | ptr = (bfd_byte *) _bfd_alloc_and_read (abfd, size, size); | 1325 | 4.69k | if (ptr == NULL) | 1326 | 882 | return NULL; | 1327 | | | 1328 | 3.81k | symbol_name = (char *) ptr; | 1329 | | /* See PR 20905 for an example of where the strnlen is necessary. */ | 1330 | 3.81k | source_dll = symbol_name + strnlen (symbol_name, size - 1) + 1; | 1331 | | | 1332 | | /* Verify that the strings are null terminated. */ | 1333 | 3.81k | if (ptr[size - 1] != 0 | 1334 | 3.81k | || (bfd_size_type) ((bfd_byte *) source_dll - ptr) >= size) | 1335 | 361 | { | 1336 | 361 | _bfd_error_handler | 1337 | 361 | (_("%pB: string not null terminated in ILF object file"), abfd); | 1338 | 361 | bfd_set_error (bfd_error_malformed_archive); | 1339 | 361 | bfd_release (abfd, ptr); | 1340 | 361 | return NULL; | 1341 | 361 | } | 1342 | | | 1343 | | /* Now construct the bfd. */ | 1344 | 3.45k | if (! pe_ILF_build_a_bfd (abfd, magic, symbol_name, | 1345 | 3.45k | source_dll, ordinal, types)) | 1346 | 680 | { | 1347 | 680 | bfd_release (abfd, ptr); | 1348 | 680 | return NULL; | 1349 | 680 | } | 1350 | | | 1351 | 2.77k | return pe_ILF_cleanup; | 1352 | 3.45k | } |
|
1353 | | |
1354 | | static void |
1355 | | pe_bfd_read_buildid (bfd *abfd) |
1356 | 302k | { |
1357 | 302k | pe_data_type *pe = pe_data (abfd); |
1358 | 302k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; |
1359 | 302k | asection *section; |
1360 | 302k | bfd_byte *data = 0; |
1361 | 302k | bfd_size_type dataoff; |
1362 | 302k | unsigned int i; |
1363 | 302k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; |
1364 | 302k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; |
1365 | | |
1366 | 302k | if (size == 0) |
1367 | 103k | return; |
1368 | | |
1369 | 198k | addr += extra->ImageBase; |
1370 | | |
1371 | | /* Search for the section containing the DebugDirectory. */ |
1372 | 1.38M | for (section = abfd->sections; section != NULL; section = section->next) |
1373 | 1.28M | { |
1374 | 1.28M | if ((addr >= section->vma) && (addr < (section->vma + section->size))) |
1375 | 95.0k | break; |
1376 | 1.28M | } |
1377 | | |
1378 | 198k | if (section == NULL) |
1379 | 103k | return; |
1380 | | |
1381 | 95.0k | if (!(section->flags & SEC_HAS_CONTENTS)) |
1382 | 10.4k | return; |
1383 | | |
1384 | 84.5k | dataoff = addr - section->vma; |
1385 | | |
1386 | | /* PR 20605 and 22373: Make sure that the data is really there. |
1387 | | Note - since we are dealing with unsigned quantities we have |
1388 | | to be careful to check for potential overflows. */ |
1389 | 84.5k | if (dataoff >= section->size |
1390 | 84.5k | || size > section->size - dataoff) |
1391 | 33.2k | { |
1392 | 33.2k | _bfd_error_handler |
1393 | 33.2k | (_("%pB: error: debug data ends beyond end of debug directory"), |
1394 | 33.2k | abfd); |
1395 | 33.2k | return; |
1396 | 33.2k | } |
1397 | | |
1398 | | /* Read the whole section. */ |
1399 | 51.2k | if (!bfd_malloc_and_get_section (abfd, section, &data)) |
1400 | 28.1k | { |
1401 | 28.1k | free (data); |
1402 | 28.1k | return; |
1403 | 28.1k | } |
1404 | | |
1405 | | /* Search for a CodeView entry in the DebugDirectory */ |
1406 | 6.79M | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) |
1407 | 6.78M | { |
1408 | 6.78M | struct external_IMAGE_DEBUG_DIRECTORY *ext |
1409 | 6.78M | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; |
1410 | 6.78M | struct internal_IMAGE_DEBUG_DIRECTORY idd; |
1411 | | |
1412 | 6.78M | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); |
1413 | | |
1414 | 6.78M | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) |
1415 | 12.1k | { |
1416 | 12.1k | char buffer[256 + 1]; |
1417 | 12.1k | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; |
1418 | | |
1419 | | /* |
1420 | | The debug entry doesn't have to have to be in a section, in which |
1421 | | case AddressOfRawData is 0, so always use PointerToRawData. |
1422 | | */ |
1423 | 12.1k | if (_bfd_XXi_slurp_codeview_record (abfd, |
1424 | 12.1k | (file_ptr) idd.PointerToRawData, |
1425 | 12.1k | idd.SizeOfData, cvinfo, NULL)) |
1426 | 70 | { |
1427 | 70 | struct bfd_build_id* build_id = bfd_alloc (abfd, |
1428 | 70 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); |
1429 | 70 | if (build_id) |
1430 | 70 | { |
1431 | 70 | build_id->size = cvinfo->SignatureLength; |
1432 | 70 | memcpy(build_id->data, cvinfo->Signature, |
1433 | 70 | cvinfo->SignatureLength); |
1434 | 70 | abfd->build_id = build_id; |
1435 | 70 | } |
1436 | 70 | } |
1437 | 12.1k | break; |
1438 | 12.1k | } |
1439 | 6.78M | } |
1440 | | |
1441 | 23.1k | free (data); |
1442 | 23.1k | } pei-i386.c:pe_bfd_read_buildid Line | Count | Source | 1356 | 42.5k | { | 1357 | 42.5k | pe_data_type *pe = pe_data (abfd); | 1358 | 42.5k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1359 | 42.5k | asection *section; | 1360 | 42.5k | bfd_byte *data = 0; | 1361 | 42.5k | bfd_size_type dataoff; | 1362 | 42.5k | unsigned int i; | 1363 | 42.5k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1364 | 42.5k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1365 | | | 1366 | 42.5k | if (size == 0) | 1367 | 22.9k | return; | 1368 | | | 1369 | 19.6k | addr += extra->ImageBase; | 1370 | | | 1371 | | /* Search for the section containing the DebugDirectory. */ | 1372 | 39.0k | for (section = abfd->sections; section != NULL; section = section->next) | 1373 | 28.0k | { | 1374 | 28.0k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1375 | 8.67k | break; | 1376 | 28.0k | } | 1377 | | | 1378 | 19.6k | if (section == NULL) | 1379 | 11.0k | return; | 1380 | | | 1381 | 8.67k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1382 | 868 | return; | 1383 | | | 1384 | 7.80k | dataoff = addr - section->vma; | 1385 | | | 1386 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1387 | | Note - since we are dealing with unsigned quantities we have | 1388 | | to be careful to check for potential overflows. */ | 1389 | 7.80k | if (dataoff >= section->size | 1390 | 7.80k | || size > section->size - dataoff) | 1391 | 4.38k | { | 1392 | 4.38k | _bfd_error_handler | 1393 | 4.38k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1394 | 4.38k | abfd); | 1395 | 4.38k | return; | 1396 | 4.38k | } | 1397 | | | 1398 | | /* Read the whole section. */ | 1399 | 3.41k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1400 | 2.33k | { | 1401 | 2.33k | free (data); | 1402 | 2.33k | return; | 1403 | 2.33k | } | 1404 | | | 1405 | | /* Search for a CodeView entry in the DebugDirectory */ | 1406 | 3.27k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1407 | 2.73k | { | 1408 | 2.73k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1409 | 2.73k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1410 | 2.73k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1411 | | | 1412 | 2.73k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1413 | | | 1414 | 2.73k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1415 | 541 | { | 1416 | 541 | char buffer[256 + 1]; | 1417 | 541 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1418 | | | 1419 | | /* | 1420 | | The debug entry doesn't have to have to be in a section, in which | 1421 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1422 | | */ | 1423 | 541 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1424 | 541 | (file_ptr) idd.PointerToRawData, | 1425 | 541 | idd.SizeOfData, cvinfo, NULL)) | 1426 | 18 | { | 1427 | 18 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1428 | 18 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1429 | 18 | if (build_id) | 1430 | 18 | { | 1431 | 18 | build_id->size = cvinfo->SignatureLength; | 1432 | 18 | memcpy(build_id->data, cvinfo->Signature, | 1433 | 18 | cvinfo->SignatureLength); | 1434 | 18 | abfd->build_id = build_id; | 1435 | 18 | } | 1436 | 18 | } | 1437 | 541 | break; | 1438 | 541 | } | 1439 | 2.73k | } | 1440 | | | 1441 | 1.08k | free (data); | 1442 | 1.08k | } |
pei-x86_64.c:pe_bfd_read_buildid Line | Count | Source | 1356 | 50.3k | { | 1357 | 50.3k | pe_data_type *pe = pe_data (abfd); | 1358 | 50.3k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1359 | 50.3k | asection *section; | 1360 | 50.3k | bfd_byte *data = 0; | 1361 | 50.3k | bfd_size_type dataoff; | 1362 | 50.3k | unsigned int i; | 1363 | 50.3k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1364 | 50.3k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1365 | | | 1366 | 50.3k | if (size == 0) | 1367 | 23.4k | return; | 1368 | | | 1369 | 26.8k | addr += extra->ImageBase; | 1370 | | | 1371 | | /* Search for the section containing the DebugDirectory. */ | 1372 | 71.4k | for (section = abfd->sections; section != NULL; section = section->next) | 1373 | 62.8k | { | 1374 | 62.8k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1375 | 18.2k | break; | 1376 | 62.8k | } | 1377 | | | 1378 | 26.8k | if (section == NULL) | 1379 | 8.60k | return; | 1380 | | | 1381 | 18.2k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1382 | 1.46k | return; | 1383 | | | 1384 | 16.7k | dataoff = addr - section->vma; | 1385 | | | 1386 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1387 | | Note - since we are dealing with unsigned quantities we have | 1388 | | to be careful to check for potential overflows. */ | 1389 | 16.7k | if (dataoff >= section->size | 1390 | 16.7k | || size > section->size - dataoff) | 1391 | 4.13k | { | 1392 | 4.13k | _bfd_error_handler | 1393 | 4.13k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1394 | 4.13k | abfd); | 1395 | 4.13k | return; | 1396 | 4.13k | } | 1397 | | | 1398 | | /* Read the whole section. */ | 1399 | 12.6k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1400 | 4.70k | { | 1401 | 4.70k | free (data); | 1402 | 4.70k | return; | 1403 | 4.70k | } | 1404 | | | 1405 | | /* Search for a CodeView entry in the DebugDirectory */ | 1406 | 6.46M | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1407 | 6.45M | { | 1408 | 6.45M | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1409 | 6.45M | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1410 | 6.45M | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1411 | | | 1412 | 6.45M | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1413 | | | 1414 | 6.45M | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1415 | 4.80k | { | 1416 | 4.80k | char buffer[256 + 1]; | 1417 | 4.80k | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1418 | | | 1419 | | /* | 1420 | | The debug entry doesn't have to have to be in a section, in which | 1421 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1422 | | */ | 1423 | 4.80k | if (_bfd_XXi_slurp_codeview_record (abfd, | 1424 | 4.80k | (file_ptr) idd.PointerToRawData, | 1425 | 4.80k | idd.SizeOfData, cvinfo, NULL)) | 1426 | 34 | { | 1427 | 34 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1428 | 34 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1429 | 34 | if (build_id) | 1430 | 34 | { | 1431 | 34 | build_id->size = cvinfo->SignatureLength; | 1432 | 34 | memcpy(build_id->data, cvinfo->Signature, | 1433 | 34 | cvinfo->SignatureLength); | 1434 | 34 | abfd->build_id = build_id; | 1435 | 34 | } | 1436 | 34 | } | 1437 | 4.80k | break; | 1438 | 4.80k | } | 1439 | 6.45M | } | 1440 | | | 1441 | 7.94k | free (data); | 1442 | 7.94k | } |
pei-aarch64.c:pe_bfd_read_buildid Line | Count | Source | 1356 | 26.8k | { | 1357 | 26.8k | pe_data_type *pe = pe_data (abfd); | 1358 | 26.8k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1359 | 26.8k | asection *section; | 1360 | 26.8k | bfd_byte *data = 0; | 1361 | 26.8k | bfd_size_type dataoff; | 1362 | 26.8k | unsigned int i; | 1363 | 26.8k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1364 | 26.8k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1365 | | | 1366 | 26.8k | if (size == 0) | 1367 | 7.35k | return; | 1368 | | | 1369 | 19.5k | addr += extra->ImageBase; | 1370 | | | 1371 | | /* Search for the section containing the DebugDirectory. */ | 1372 | 43.3k | for (section = abfd->sections; section != NULL; section = section->next) | 1373 | 30.7k | { | 1374 | 30.7k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1375 | 6.97k | break; | 1376 | 30.7k | } | 1377 | | | 1378 | 19.5k | if (section == NULL) | 1379 | 12.5k | return; | 1380 | | | 1381 | 6.97k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1382 | 972 | return; | 1383 | | | 1384 | 6.00k | dataoff = addr - section->vma; | 1385 | | | 1386 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1387 | | Note - since we are dealing with unsigned quantities we have | 1388 | | to be careful to check for potential overflows. */ | 1389 | 6.00k | if (dataoff >= section->size | 1390 | 6.00k | || size > section->size - dataoff) | 1391 | 3.15k | { | 1392 | 3.15k | _bfd_error_handler | 1393 | 3.15k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1394 | 3.15k | abfd); | 1395 | 3.15k | return; | 1396 | 3.15k | } | 1397 | | | 1398 | | /* Read the whole section. */ | 1399 | 2.85k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1400 | 2.28k | { | 1401 | 2.28k | free (data); | 1402 | 2.28k | return; | 1403 | 2.28k | } | 1404 | | | 1405 | | /* Search for a CodeView entry in the DebugDirectory */ | 1406 | 74.6k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1407 | 74.2k | { | 1408 | 74.2k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1409 | 74.2k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1410 | 74.2k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1411 | | | 1412 | 74.2k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1413 | | | 1414 | 74.2k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1415 | 119 | { | 1416 | 119 | char buffer[256 + 1]; | 1417 | 119 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1418 | | | 1419 | | /* | 1420 | | The debug entry doesn't have to have to be in a section, in which | 1421 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1422 | | */ | 1423 | 119 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1424 | 119 | (file_ptr) idd.PointerToRawData, | 1425 | 119 | idd.SizeOfData, cvinfo, NULL)) | 1426 | 1 | { | 1427 | 1 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1428 | 1 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1429 | 1 | if (build_id) | 1430 | 1 | { | 1431 | 1 | build_id->size = cvinfo->SignatureLength; | 1432 | 1 | memcpy(build_id->data, cvinfo->Signature, | 1433 | 1 | cvinfo->SignatureLength); | 1434 | 1 | abfd->build_id = build_id; | 1435 | 1 | } | 1436 | 1 | } | 1437 | 119 | break; | 1438 | 119 | } | 1439 | 74.2k | } | 1440 | | | 1441 | 565 | free (data); | 1442 | 565 | } |
pei-ia64.c:pe_bfd_read_buildid Line | Count | Source | 1356 | 34.3k | { | 1357 | 34.3k | pe_data_type *pe = pe_data (abfd); | 1358 | 34.3k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1359 | 34.3k | asection *section; | 1360 | 34.3k | bfd_byte *data = 0; | 1361 | 34.3k | bfd_size_type dataoff; | 1362 | 34.3k | unsigned int i; | 1363 | 34.3k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1364 | 34.3k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1365 | | | 1366 | 34.3k | if (size == 0) | 1367 | 10.4k | return; | 1368 | | | 1369 | 23.8k | addr += extra->ImageBase; | 1370 | | | 1371 | | /* Search for the section containing the DebugDirectory. */ | 1372 | 72.2k | for (section = abfd->sections; section != NULL; section = section->next) | 1373 | 55.8k | { | 1374 | 55.8k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1375 | 7.51k | break; | 1376 | 55.8k | } | 1377 | | | 1378 | 23.8k | if (section == NULL) | 1379 | 16.3k | return; | 1380 | | | 1381 | 7.51k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1382 | 982 | return; | 1383 | | | 1384 | 6.52k | dataoff = addr - section->vma; | 1385 | | | 1386 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1387 | | Note - since we are dealing with unsigned quantities we have | 1388 | | to be careful to check for potential overflows. */ | 1389 | 6.52k | if (dataoff >= section->size | 1390 | 6.52k | || size > section->size - dataoff) | 1391 | 3.32k | { | 1392 | 3.32k | _bfd_error_handler | 1393 | 3.32k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1394 | 3.32k | abfd); | 1395 | 3.32k | return; | 1396 | 3.32k | } | 1397 | | | 1398 | | /* Read the whole section. */ | 1399 | 3.20k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1400 | 1.89k | { | 1401 | 1.89k | free (data); | 1402 | 1.89k | return; | 1403 | 1.89k | } | 1404 | | | 1405 | | /* Search for a CodeView entry in the DebugDirectory */ | 1406 | 5.25k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1407 | 4.73k | { | 1408 | 4.73k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1409 | 4.73k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1410 | 4.73k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1411 | | | 1412 | 4.73k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1413 | | | 1414 | 4.73k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1415 | 794 | { | 1416 | 794 | char buffer[256 + 1]; | 1417 | 794 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1418 | | | 1419 | | /* | 1420 | | The debug entry doesn't have to have to be in a section, in which | 1421 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1422 | | */ | 1423 | 794 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1424 | 794 | (file_ptr) idd.PointerToRawData, | 1425 | 794 | idd.SizeOfData, cvinfo, NULL)) | 1426 | 0 | { | 1427 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1428 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1429 | 0 | if (build_id) | 1430 | 0 | { | 1431 | 0 | build_id->size = cvinfo->SignatureLength; | 1432 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1433 | 0 | cvinfo->SignatureLength); | 1434 | 0 | abfd->build_id = build_id; | 1435 | 0 | } | 1436 | 0 | } | 1437 | 794 | break; | 1438 | 794 | } | 1439 | 4.73k | } | 1440 | | | 1441 | 1.30k | free (data); | 1442 | 1.30k | } |
pei-loongarch64.c:pe_bfd_read_buildid Line | Count | Source | 1356 | 24.6k | { | 1357 | 24.6k | pe_data_type *pe = pe_data (abfd); | 1358 | 24.6k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1359 | 24.6k | asection *section; | 1360 | 24.6k | bfd_byte *data = 0; | 1361 | 24.6k | bfd_size_type dataoff; | 1362 | 24.6k | unsigned int i; | 1363 | 24.6k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1364 | 24.6k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1365 | | | 1366 | 24.6k | if (size == 0) | 1367 | 7.49k | return; | 1368 | | | 1369 | 17.1k | addr += extra->ImageBase; | 1370 | | | 1371 | | /* Search for the section containing the DebugDirectory. */ | 1372 | 51.9k | for (section = abfd->sections; section != NULL; section = section->next) | 1373 | 40.4k | { | 1374 | 40.4k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1375 | 5.57k | break; | 1376 | 40.4k | } | 1377 | | | 1378 | 17.1k | if (section == NULL) | 1379 | 11.5k | return; | 1380 | | | 1381 | 5.57k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1382 | 744 | return; | 1383 | | | 1384 | 4.82k | dataoff = addr - section->vma; | 1385 | | | 1386 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1387 | | Note - since we are dealing with unsigned quantities we have | 1388 | | to be careful to check for potential overflows. */ | 1389 | 4.82k | if (dataoff >= section->size | 1390 | 4.82k | || size > section->size - dataoff) | 1391 | 1.95k | { | 1392 | 1.95k | _bfd_error_handler | 1393 | 1.95k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1394 | 1.95k | abfd); | 1395 | 1.95k | return; | 1396 | 1.95k | } | 1397 | | | 1398 | | /* Read the whole section. */ | 1399 | 2.87k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1400 | 1.55k | { | 1401 | 1.55k | free (data); | 1402 | 1.55k | return; | 1403 | 1.55k | } | 1404 | | | 1405 | | /* Search for a CodeView entry in the DebugDirectory */ | 1406 | 13.3k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1407 | 12.3k | { | 1408 | 12.3k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1409 | 12.3k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1410 | 12.3k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1411 | | | 1412 | 12.3k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1413 | | | 1414 | 12.3k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1415 | 323 | { | 1416 | 323 | char buffer[256 + 1]; | 1417 | 323 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1418 | | | 1419 | | /* | 1420 | | The debug entry doesn't have to have to be in a section, in which | 1421 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1422 | | */ | 1423 | 323 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1424 | 323 | (file_ptr) idd.PointerToRawData, | 1425 | 323 | idd.SizeOfData, cvinfo, NULL)) | 1426 | 3 | { | 1427 | 3 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1428 | 3 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1429 | 3 | if (build_id) | 1430 | 3 | { | 1431 | 3 | build_id->size = cvinfo->SignatureLength; | 1432 | 3 | memcpy(build_id->data, cvinfo->Signature, | 1433 | 3 | cvinfo->SignatureLength); | 1434 | 3 | abfd->build_id = build_id; | 1435 | 3 | } | 1436 | 3 | } | 1437 | 323 | break; | 1438 | 323 | } | 1439 | 12.3k | } | 1440 | | | 1441 | 1.31k | free (data); | 1442 | 1.31k | } |
pei-riscv64.c:pe_bfd_read_buildid Line | Count | Source | 1356 | 14.3k | { | 1357 | 14.3k | pe_data_type *pe = pe_data (abfd); | 1358 | 14.3k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1359 | 14.3k | asection *section; | 1360 | 14.3k | bfd_byte *data = 0; | 1361 | 14.3k | bfd_size_type dataoff; | 1362 | 14.3k | unsigned int i; | 1363 | 14.3k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1364 | 14.3k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1365 | | | 1366 | 14.3k | if (size == 0) | 1367 | 1.86k | return; | 1368 | | | 1369 | 12.4k | addr += extra->ImageBase; | 1370 | | | 1371 | | /* Search for the section containing the DebugDirectory. */ | 1372 | 148k | for (section = abfd->sections; section != NULL; section = section->next) | 1373 | 138k | { | 1374 | 138k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1375 | 3.01k | break; | 1376 | 138k | } | 1377 | | | 1378 | 12.4k | if (section == NULL) | 1379 | 9.47k | return; | 1380 | | | 1381 | 3.01k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1382 | 110 | return; | 1383 | | | 1384 | 2.90k | dataoff = addr - section->vma; | 1385 | | | 1386 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1387 | | Note - since we are dealing with unsigned quantities we have | 1388 | | to be careful to check for potential overflows. */ | 1389 | 2.90k | if (dataoff >= section->size | 1390 | 2.90k | || size > section->size - dataoff) | 1391 | 1.62k | { | 1392 | 1.62k | _bfd_error_handler | 1393 | 1.62k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1394 | 1.62k | abfd); | 1395 | 1.62k | return; | 1396 | 1.62k | } | 1397 | | | 1398 | | /* Read the whole section. */ | 1399 | 1.28k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1400 | 1.22k | { | 1401 | 1.22k | free (data); | 1402 | 1.22k | return; | 1403 | 1.22k | } | 1404 | | | 1405 | | /* Search for a CodeView entry in the DebugDirectory */ | 1406 | 4.10k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1407 | 4.08k | { | 1408 | 4.08k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1409 | 4.08k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1410 | 4.08k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1411 | | | 1412 | 4.08k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1413 | | | 1414 | 4.08k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1415 | 37 | { | 1416 | 37 | char buffer[256 + 1]; | 1417 | 37 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1418 | | | 1419 | | /* | 1420 | | The debug entry doesn't have to have to be in a section, in which | 1421 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1422 | | */ | 1423 | 37 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1424 | 37 | (file_ptr) idd.PointerToRawData, | 1425 | 37 | idd.SizeOfData, cvinfo, NULL)) | 1426 | 0 | { | 1427 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1428 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1429 | 0 | if (build_id) | 1430 | 0 | { | 1431 | 0 | build_id->size = cvinfo->SignatureLength; | 1432 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1433 | 0 | cvinfo->SignatureLength); | 1434 | 0 | abfd->build_id = build_id; | 1435 | 0 | } | 1436 | 0 | } | 1437 | 37 | break; | 1438 | 37 | } | 1439 | 4.08k | } | 1440 | | | 1441 | 56 | free (data); | 1442 | 56 | } |
pei-arm-wince.c:pe_bfd_read_buildid Line | Count | Source | 1356 | 17.0k | { | 1357 | 17.0k | pe_data_type *pe = pe_data (abfd); | 1358 | 17.0k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1359 | 17.0k | asection *section; | 1360 | 17.0k | bfd_byte *data = 0; | 1361 | 17.0k | bfd_size_type dataoff; | 1362 | 17.0k | unsigned int i; | 1363 | 17.0k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1364 | 17.0k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1365 | | | 1366 | 17.0k | if (size == 0) | 1367 | 2.76k | return; | 1368 | | | 1369 | 14.2k | addr += extra->ImageBase; | 1370 | | | 1371 | | /* Search for the section containing the DebugDirectory. */ | 1372 | 48.2k | for (section = abfd->sections; section != NULL; section = section->next) | 1373 | 43.9k | { | 1374 | 43.9k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1375 | 9.88k | break; | 1376 | 43.9k | } | 1377 | | | 1378 | 14.2k | if (section == NULL) | 1379 | 4.36k | return; | 1380 | | | 1381 | 9.88k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1382 | 1.32k | return; | 1383 | | | 1384 | 8.55k | dataoff = addr - section->vma; | 1385 | | | 1386 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1387 | | Note - since we are dealing with unsigned quantities we have | 1388 | | to be careful to check for potential overflows. */ | 1389 | 8.55k | if (dataoff >= section->size | 1390 | 8.55k | || size > section->size - dataoff) | 1391 | 1.95k | { | 1392 | 1.95k | _bfd_error_handler | 1393 | 1.95k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1394 | 1.95k | abfd); | 1395 | 1.95k | return; | 1396 | 1.95k | } | 1397 | | | 1398 | | /* Read the whole section. */ | 1399 | 6.60k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1400 | 3.41k | { | 1401 | 3.41k | free (data); | 1402 | 3.41k | return; | 1403 | 3.41k | } | 1404 | | | 1405 | | /* Search for a CodeView entry in the DebugDirectory */ | 1406 | 66.6k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1407 | 65.7k | { | 1408 | 65.7k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1409 | 65.7k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1410 | 65.7k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1411 | | | 1412 | 65.7k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1413 | | | 1414 | 65.7k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1415 | 2.27k | { | 1416 | 2.27k | char buffer[256 + 1]; | 1417 | 2.27k | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1418 | | | 1419 | | /* | 1420 | | The debug entry doesn't have to have to be in a section, in which | 1421 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1422 | | */ | 1423 | 2.27k | if (_bfd_XXi_slurp_codeview_record (abfd, | 1424 | 2.27k | (file_ptr) idd.PointerToRawData, | 1425 | 2.27k | idd.SizeOfData, cvinfo, NULL)) | 1426 | 1 | { | 1427 | 1 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1428 | 1 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1429 | 1 | if (build_id) | 1430 | 1 | { | 1431 | 1 | build_id->size = cvinfo->SignatureLength; | 1432 | 1 | memcpy(build_id->data, cvinfo->Signature, | 1433 | 1 | cvinfo->SignatureLength); | 1434 | 1 | abfd->build_id = build_id; | 1435 | 1 | } | 1436 | 1 | } | 1437 | 2.27k | break; | 1438 | 2.27k | } | 1439 | 65.7k | } | 1440 | | | 1441 | 3.18k | free (data); | 1442 | 3.18k | } |
pei-arm.c:pe_bfd_read_buildid Line | Count | Source | 1356 | 26.0k | { | 1357 | 26.0k | pe_data_type *pe = pe_data (abfd); | 1358 | 26.0k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1359 | 26.0k | asection *section; | 1360 | 26.0k | bfd_byte *data = 0; | 1361 | 26.0k | bfd_size_type dataoff; | 1362 | 26.0k | unsigned int i; | 1363 | 26.0k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1364 | 26.0k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1365 | | | 1366 | 26.0k | if (size == 0) | 1367 | 5.82k | return; | 1368 | | | 1369 | 20.1k | addr += extra->ImageBase; | 1370 | | | 1371 | | /* Search for the section containing the DebugDirectory. */ | 1372 | 778k | for (section = abfd->sections; section != NULL; section = section->next) | 1373 | 769k | { | 1374 | 769k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1375 | 10.9k | break; | 1376 | 769k | } | 1377 | | | 1378 | 20.1k | if (section == NULL) | 1379 | 9.21k | return; | 1380 | | | 1381 | 10.9k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1382 | 1.94k | return; | 1383 | | | 1384 | 9.02k | dataoff = addr - section->vma; | 1385 | | | 1386 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1387 | | Note - since we are dealing with unsigned quantities we have | 1388 | | to be careful to check for potential overflows. */ | 1389 | 9.02k | if (dataoff >= section->size | 1390 | 9.02k | || size > section->size - dataoff) | 1391 | 4.69k | { | 1392 | 4.69k | _bfd_error_handler | 1393 | 4.69k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1394 | 4.69k | abfd); | 1395 | 4.69k | return; | 1396 | 4.69k | } | 1397 | | | 1398 | | /* Read the whole section. */ | 1399 | 4.32k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1400 | 2.18k | { | 1401 | 2.18k | free (data); | 1402 | 2.18k | return; | 1403 | 2.18k | } | 1404 | | | 1405 | | /* Search for a CodeView entry in the DebugDirectory */ | 1406 | 39.4k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1407 | 38.2k | { | 1408 | 38.2k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1409 | 38.2k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1410 | 38.2k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1411 | | | 1412 | 38.2k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1413 | | | 1414 | 38.2k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1415 | 948 | { | 1416 | 948 | char buffer[256 + 1]; | 1417 | 948 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1418 | | | 1419 | | /* | 1420 | | The debug entry doesn't have to have to be in a section, in which | 1421 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1422 | | */ | 1423 | 948 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1424 | 948 | (file_ptr) idd.PointerToRawData, | 1425 | 948 | idd.SizeOfData, cvinfo, NULL)) | 1426 | 9 | { | 1427 | 9 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1428 | 9 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1429 | 9 | if (build_id) | 1430 | 9 | { | 1431 | 9 | build_id->size = cvinfo->SignatureLength; | 1432 | 9 | memcpy(build_id->data, cvinfo->Signature, | 1433 | 9 | cvinfo->SignatureLength); | 1434 | 9 | abfd->build_id = build_id; | 1435 | 9 | } | 1436 | 9 | } | 1437 | 948 | break; | 1438 | 948 | } | 1439 | 38.2k | } | 1440 | | | 1441 | 2.14k | free (data); | 1442 | 2.14k | } |
pei-mcore.c:pe_bfd_read_buildid Line | Count | Source | 1356 | 34.6k | { | 1357 | 34.6k | pe_data_type *pe = pe_data (abfd); | 1358 | 34.6k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1359 | 34.6k | asection *section; | 1360 | 34.6k | bfd_byte *data = 0; | 1361 | 34.6k | bfd_size_type dataoff; | 1362 | 34.6k | unsigned int i; | 1363 | 34.6k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1364 | 34.6k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1365 | | | 1366 | 34.6k | if (size == 0) | 1367 | 8.52k | return; | 1368 | | | 1369 | 26.1k | addr += extra->ImageBase; | 1370 | | | 1371 | | /* Search for the section containing the DebugDirectory. */ | 1372 | 85.5k | for (section = abfd->sections; section != NULL; section = section->next) | 1373 | 73.4k | { | 1374 | 73.4k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1375 | 14.0k | break; | 1376 | 73.4k | } | 1377 | | | 1378 | 26.1k | if (section == NULL) | 1379 | 12.0k | return; | 1380 | | | 1381 | 14.0k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1382 | 1.34k | return; | 1383 | | | 1384 | 12.7k | dataoff = addr - section->vma; | 1385 | | | 1386 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1387 | | Note - since we are dealing with unsigned quantities we have | 1388 | | to be careful to check for potential overflows. */ | 1389 | 12.7k | if (dataoff >= section->size | 1390 | 12.7k | || size > section->size - dataoff) | 1391 | 4.49k | { | 1392 | 4.49k | _bfd_error_handler | 1393 | 4.49k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1394 | 4.49k | abfd); | 1395 | 4.49k | return; | 1396 | 4.49k | } | 1397 | | | 1398 | | /* Read the whole section. */ | 1399 | 8.22k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1400 | 4.97k | { | 1401 | 4.97k | free (data); | 1402 | 4.97k | return; | 1403 | 4.97k | } | 1404 | | | 1405 | | /* Search for a CodeView entry in the DebugDirectory */ | 1406 | 107k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1407 | 105k | { | 1408 | 105k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1409 | 105k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1410 | 105k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1411 | | | 1412 | 105k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1413 | | | 1414 | 105k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1415 | 1.48k | { | 1416 | 1.48k | char buffer[256 + 1]; | 1417 | 1.48k | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1418 | | | 1419 | | /* | 1420 | | The debug entry doesn't have to have to be in a section, in which | 1421 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1422 | | */ | 1423 | 1.48k | if (_bfd_XXi_slurp_codeview_record (abfd, | 1424 | 1.48k | (file_ptr) idd.PointerToRawData, | 1425 | 1.48k | idd.SizeOfData, cvinfo, NULL)) | 1426 | 0 | { | 1427 | 0 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1428 | 0 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1429 | 0 | if (build_id) | 1430 | 0 | { | 1431 | 0 | build_id->size = cvinfo->SignatureLength; | 1432 | 0 | memcpy(build_id->data, cvinfo->Signature, | 1433 | 0 | cvinfo->SignatureLength); | 1434 | 0 | abfd->build_id = build_id; | 1435 | 0 | } | 1436 | 0 | } | 1437 | 1.48k | break; | 1438 | 1.48k | } | 1439 | 105k | } | 1440 | | | 1441 | 3.24k | free (data); | 1442 | 3.24k | } |
pei-sh.c:pe_bfd_read_buildid Line | Count | Source | 1356 | 31.7k | { | 1357 | 31.7k | pe_data_type *pe = pe_data (abfd); | 1358 | 31.7k | struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; | 1359 | 31.7k | asection *section; | 1360 | 31.7k | bfd_byte *data = 0; | 1361 | 31.7k | bfd_size_type dataoff; | 1362 | 31.7k | unsigned int i; | 1363 | 31.7k | bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; | 1364 | 31.7k | bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; | 1365 | | | 1366 | 31.7k | if (size == 0) | 1367 | 13.1k | return; | 1368 | | | 1369 | 18.5k | addr += extra->ImageBase; | 1370 | | | 1371 | | /* Search for the section containing the DebugDirectory. */ | 1372 | 45.5k | for (section = abfd->sections; section != NULL; section = section->next) | 1373 | 37.0k | { | 1374 | 37.0k | if ((addr >= section->vma) && (addr < (section->vma + section->size))) | 1375 | 10.1k | break; | 1376 | 37.0k | } | 1377 | | | 1378 | 18.5k | if (section == NULL) | 1379 | 8.46k | return; | 1380 | | | 1381 | 10.1k | if (!(section->flags & SEC_HAS_CONTENTS)) | 1382 | 740 | return; | 1383 | | | 1384 | 9.36k | dataoff = addr - section->vma; | 1385 | | | 1386 | | /* PR 20605 and 22373: Make sure that the data is really there. | 1387 | | Note - since we are dealing with unsigned quantities we have | 1388 | | to be careful to check for potential overflows. */ | 1389 | 9.36k | if (dataoff >= section->size | 1390 | 9.36k | || size > section->size - dataoff) | 1391 | 3.51k | { | 1392 | 3.51k | _bfd_error_handler | 1393 | 3.51k | (_("%pB: error: debug data ends beyond end of debug directory"), | 1394 | 3.51k | abfd); | 1395 | 3.51k | return; | 1396 | 3.51k | } | 1397 | | | 1398 | | /* Read the whole section. */ | 1399 | 5.84k | if (!bfd_malloc_and_get_section (abfd, section, &data)) | 1400 | 3.53k | { | 1401 | 3.53k | free (data); | 1402 | 3.53k | return; | 1403 | 3.53k | } | 1404 | | | 1405 | | /* Search for a CodeView entry in the DebugDirectory */ | 1406 | 17.1k | for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) | 1407 | 15.6k | { | 1408 | 15.6k | struct external_IMAGE_DEBUG_DIRECTORY *ext | 1409 | 15.6k | = &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; | 1410 | 15.6k | struct internal_IMAGE_DEBUG_DIRECTORY idd; | 1411 | | | 1412 | 15.6k | _bfd_XXi_swap_debugdir_in (abfd, ext, &idd); | 1413 | | | 1414 | 15.6k | if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) | 1415 | 779 | { | 1416 | 779 | char buffer[256 + 1]; | 1417 | 779 | CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; | 1418 | | | 1419 | | /* | 1420 | | The debug entry doesn't have to have to be in a section, in which | 1421 | | case AddressOfRawData is 0, so always use PointerToRawData. | 1422 | | */ | 1423 | 779 | if (_bfd_XXi_slurp_codeview_record (abfd, | 1424 | 779 | (file_ptr) idd.PointerToRawData, | 1425 | 779 | idd.SizeOfData, cvinfo, NULL)) | 1426 | 4 | { | 1427 | 4 | struct bfd_build_id* build_id = bfd_alloc (abfd, | 1428 | 4 | sizeof (struct bfd_build_id) + cvinfo->SignatureLength); | 1429 | 4 | if (build_id) | 1430 | 4 | { | 1431 | 4 | build_id->size = cvinfo->SignatureLength; | 1432 | 4 | memcpy(build_id->data, cvinfo->Signature, | 1433 | 4 | cvinfo->SignatureLength); | 1434 | 4 | abfd->build_id = build_id; | 1435 | 4 | } | 1436 | 4 | } | 1437 | 779 | break; | 1438 | 779 | } | 1439 | 15.6k | } | 1440 | | | 1441 | 2.31k | free (data); | 1442 | 2.31k | } |
|
1443 | | |
1444 | | static bfd_cleanup |
1445 | | pe_bfd_object_p (bfd * abfd) |
1446 | 21.0M | { |
1447 | 21.0M | bfd_byte buffer[6]; |
1448 | 21.0M | struct external_DOS_hdr dos_hdr; |
1449 | 21.0M | struct external_PEI_IMAGE_hdr image_hdr; |
1450 | 21.0M | struct internal_filehdr internal_f; |
1451 | 21.0M | struct internal_aouthdr internal_a; |
1452 | 21.0M | bfd_size_type opt_hdr_size; |
1453 | 21.0M | file_ptr offset; |
1454 | 21.0M | bfd_cleanup result; |
1455 | | |
1456 | | /* Detect if this a Microsoft Import Library Format element. */ |
1457 | | /* First read the beginning of the header. */ |
1458 | 21.0M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 |
1459 | 21.0M | || bfd_read (buffer, 6, abfd) != 6) |
1460 | 58.1k | { |
1461 | 58.1k | if (bfd_get_error () != bfd_error_system_call) |
1462 | 50.0k | bfd_set_error (bfd_error_wrong_format); |
1463 | 58.1k | return NULL; |
1464 | 58.1k | } |
1465 | | |
1466 | | /* Then check the magic and the version (only 0 is supported). */ |
1467 | 20.9M | if (H_GET_32 (abfd, buffer) == 0xffff0000 |
1468 | 20.9M | && H_GET_16 (abfd, buffer + 4) == 0) |
1469 | 275k | return pe_ILF_object_p (abfd); |
1470 | | |
1471 | 20.7M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 |
1472 | 20.7M | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) |
1473 | 3.81M | { |
1474 | 3.81M | if (bfd_get_error () != bfd_error_system_call) |
1475 | 3.81M | bfd_set_error (bfd_error_wrong_format); |
1476 | 3.81M | return NULL; |
1477 | 3.81M | } |
1478 | | |
1479 | | /* There are really two magic numbers involved; the magic number |
1480 | | that says this is a NT executable (PEI) and the magic number that |
1481 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in |
1482 | | the e_magic field. The latter is stored in the f_magic field. |
1483 | | If the NT magic number isn't valid, the architecture magic number |
1484 | | could be mimicked by some other field (specifically, the number |
1485 | | of relocs in section 3). Since this routine can only be called |
1486 | | correctly for a PEI file, check the e_magic number here, and, if |
1487 | | it doesn't match, clobber the f_magic number so that we don't get |
1488 | | a false match. */ |
1489 | 16.9M | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) |
1490 | 10.8M | { |
1491 | 10.8M | bfd_set_error (bfd_error_wrong_format); |
1492 | 10.8M | return NULL; |
1493 | 10.8M | } |
1494 | | |
1495 | 6.08M | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); |
1496 | 6.08M | if (bfd_seek (abfd, offset, SEEK_SET) != 0 |
1497 | 6.08M | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) |
1498 | 53.1k | { |
1499 | 53.1k | if (bfd_get_error () != bfd_error_system_call) |
1500 | 53.1k | bfd_set_error (bfd_error_wrong_format); |
1501 | 53.1k | return NULL; |
1502 | 53.1k | } |
1503 | | |
1504 | 6.02M | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) |
1505 | 134k | { |
1506 | 134k | bfd_set_error (bfd_error_wrong_format); |
1507 | 134k | return NULL; |
1508 | 134k | } |
1509 | | |
1510 | | /* Swap file header, so that we get the location for calling |
1511 | | real_object_p. */ |
1512 | 5.89M | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); |
1513 | | |
1514 | 5.89M | if (! bfd_coff_bad_format_hook (abfd, &internal_f) |
1515 | 5.89M | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) |
1516 | 5.17M | { |
1517 | 5.17M | bfd_set_error (bfd_error_wrong_format); |
1518 | 5.17M | return NULL; |
1519 | 5.17M | } |
1520 | | |
1521 | 717k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, |
1522 | 717k | sizeof (internal_f.pe.dos_message)); |
1523 | | |
1524 | | /* Read the optional header, which has variable size. */ |
1525 | 717k | opt_hdr_size = internal_f.f_opthdr; |
1526 | | |
1527 | 717k | if (opt_hdr_size != 0) |
1528 | 497k | { |
1529 | 497k | bfd_size_type amt = opt_hdr_size; |
1530 | 497k | bfd_byte * opthdr; |
1531 | | |
1532 | | /* PR 17521 file: 230-131433-0.004. */ |
1533 | 497k | if (amt < sizeof (PEAOUTHDR)) |
1534 | 297k | amt = sizeof (PEAOUTHDR); |
1535 | | |
1536 | 497k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); |
1537 | 497k | if (opthdr == NULL) |
1538 | 19.0k | return NULL; |
1539 | 478k | if (amt > opt_hdr_size) |
1540 | 289k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); |
1541 | | |
1542 | 478k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); |
1543 | | |
1544 | 478k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; |
1545 | | |
1546 | | #ifdef ARM |
1547 | | /* Use Subsystem to distinguish between pei-arm-little and |
1548 | | pei-arm-wince-little. */ |
1549 | | #ifdef WINCE |
1550 | 66.8k | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) |
1551 | | #else |
1552 | 66.9k | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) |
1553 | 26.2k | #endif |
1554 | 66.8k | { |
1555 | 66.8k | bfd_set_error (bfd_error_wrong_format); |
1556 | 66.8k | return NULL; |
1557 | 66.8k | } |
1558 | 67.0k | #endif |
1559 | | |
1560 | 411k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment |
1561 | 411k | || a->SectionAlignment >= 0x80000000) |
1562 | 240k | { |
1563 | 240k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), |
1564 | 240k | abfd); |
1565 | 240k | a->SectionAlignment &= -a->SectionAlignment; |
1566 | 240k | if (a->SectionAlignment >= 0x80000000) |
1567 | 5.46k | a->SectionAlignment = 0x40000000; |
1568 | 240k | } |
1569 | | |
1570 | 411k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment |
1571 | 411k | || a->FileAlignment > a->SectionAlignment) |
1572 | 288k | { |
1573 | 288k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), |
1574 | 288k | abfd); |
1575 | 288k | a->FileAlignment &= -a->FileAlignment; |
1576 | 288k | if (a->FileAlignment > a->SectionAlignment) |
1577 | 141k | a->FileAlignment = a->SectionAlignment; |
1578 | 288k | } |
1579 | | |
1580 | 411k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) |
1581 | 290k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); |
1582 | 67.0k | } |
1583 | | |
1584 | 631k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, |
1585 | 631k | (opt_hdr_size != 0 |
1586 | 631k | ? &internal_a |
1587 | 631k | : (struct internal_aouthdr *) NULL)); |
1588 | | |
1589 | 631k | if (result) |
1590 | 302k | { |
1591 | | /* Now the whole header has been processed, see if there is a build-id */ |
1592 | 302k | pe_bfd_read_buildid(abfd); |
1593 | 302k | } |
1594 | | |
1595 | 631k | return result; |
1596 | 717k | } pei-i386.c:pe_bfd_object_p Line | Count | Source | 1446 | 1.72M | { | 1447 | 1.72M | bfd_byte buffer[6]; | 1448 | 1.72M | struct external_DOS_hdr dos_hdr; | 1449 | 1.72M | struct external_PEI_IMAGE_hdr image_hdr; | 1450 | 1.72M | struct internal_filehdr internal_f; | 1451 | 1.72M | struct internal_aouthdr internal_a; | 1452 | 1.72M | bfd_size_type opt_hdr_size; | 1453 | 1.72M | file_ptr offset; | 1454 | 1.72M | bfd_cleanup result; | 1455 | | | 1456 | | /* Detect if this a Microsoft Import Library Format element. */ | 1457 | | /* First read the beginning of the header. */ | 1458 | 1.72M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1459 | 1.72M | || bfd_read (buffer, 6, abfd) != 6) | 1460 | 4.91k | { | 1461 | 4.91k | if (bfd_get_error () != bfd_error_system_call) | 1462 | 4.23k | bfd_set_error (bfd_error_wrong_format); | 1463 | 4.91k | return NULL; | 1464 | 4.91k | } | 1465 | | | 1466 | | /* Then check the magic and the version (only 0 is supported). */ | 1467 | 1.71M | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1468 | 1.71M | && H_GET_16 (abfd, buffer + 4) == 0) | 1469 | 32.3k | return pe_ILF_object_p (abfd); | 1470 | | | 1471 | 1.68M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1472 | 1.68M | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1473 | 312k | { | 1474 | 312k | if (bfd_get_error () != bfd_error_system_call) | 1475 | 312k | bfd_set_error (bfd_error_wrong_format); | 1476 | 312k | return NULL; | 1477 | 312k | } | 1478 | | | 1479 | | /* There are really two magic numbers involved; the magic number | 1480 | | that says this is a NT executable (PEI) and the magic number that | 1481 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1482 | | the e_magic field. The latter is stored in the f_magic field. | 1483 | | If the NT magic number isn't valid, the architecture magic number | 1484 | | could be mimicked by some other field (specifically, the number | 1485 | | of relocs in section 3). Since this routine can only be called | 1486 | | correctly for a PEI file, check the e_magic number here, and, if | 1487 | | it doesn't match, clobber the f_magic number so that we don't get | 1488 | | a false match. */ | 1489 | 1.37M | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1490 | 751k | { | 1491 | 751k | bfd_set_error (bfd_error_wrong_format); | 1492 | 751k | return NULL; | 1493 | 751k | } | 1494 | | | 1495 | 620k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1496 | 620k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1497 | 620k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1498 | 5.76k | { | 1499 | 5.76k | if (bfd_get_error () != bfd_error_system_call) | 1500 | 5.76k | bfd_set_error (bfd_error_wrong_format); | 1501 | 5.76k | return NULL; | 1502 | 5.76k | } | 1503 | | | 1504 | 614k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1505 | 14.7k | { | 1506 | 14.7k | bfd_set_error (bfd_error_wrong_format); | 1507 | 14.7k | return NULL; | 1508 | 14.7k | } | 1509 | | | 1510 | | /* Swap file header, so that we get the location for calling | 1511 | | real_object_p. */ | 1512 | 599k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1513 | | | 1514 | 599k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1515 | 599k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1516 | 527k | { | 1517 | 527k | bfd_set_error (bfd_error_wrong_format); | 1518 | 527k | return NULL; | 1519 | 527k | } | 1520 | | | 1521 | 72.6k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1522 | 72.6k | sizeof (internal_f.pe.dos_message)); | 1523 | | | 1524 | | /* Read the optional header, which has variable size. */ | 1525 | 72.6k | opt_hdr_size = internal_f.f_opthdr; | 1526 | | | 1527 | 72.6k | if (opt_hdr_size != 0) | 1528 | 52.5k | { | 1529 | 52.5k | bfd_size_type amt = opt_hdr_size; | 1530 | 52.5k | bfd_byte * opthdr; | 1531 | | | 1532 | | /* PR 17521 file: 230-131433-0.004. */ | 1533 | 52.5k | if (amt < sizeof (PEAOUTHDR)) | 1534 | 38.4k | amt = sizeof (PEAOUTHDR); | 1535 | | | 1536 | 52.5k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1537 | 52.5k | if (opthdr == NULL) | 1538 | 1.06k | return NULL; | 1539 | 51.5k | if (amt > opt_hdr_size) | 1540 | 38.2k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1541 | | | 1542 | 51.5k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1543 | | | 1544 | 51.5k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1545 | | | 1546 | | #ifdef ARM | 1547 | | /* Use Subsystem to distinguish between pei-arm-little and | 1548 | | pei-arm-wince-little. */ | 1549 | | #ifdef WINCE | 1550 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1551 | | #else | 1552 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1553 | | #endif | 1554 | | { | 1555 | | bfd_set_error (bfd_error_wrong_format); | 1556 | | return NULL; | 1557 | | } | 1558 | | #endif | 1559 | | | 1560 | 51.5k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1561 | 51.5k | || a->SectionAlignment >= 0x80000000) | 1562 | 33.5k | { | 1563 | 33.5k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1564 | 33.5k | abfd); | 1565 | 33.5k | a->SectionAlignment &= -a->SectionAlignment; | 1566 | 33.5k | if (a->SectionAlignment >= 0x80000000) | 1567 | 1.47k | a->SectionAlignment = 0x40000000; | 1568 | 33.5k | } | 1569 | | | 1570 | 51.5k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1571 | 51.5k | || a->FileAlignment > a->SectionAlignment) | 1572 | 37.3k | { | 1573 | 37.3k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1574 | 37.3k | abfd); | 1575 | 37.3k | a->FileAlignment &= -a->FileAlignment; | 1576 | 37.3k | if (a->FileAlignment > a->SectionAlignment) | 1577 | 17.4k | a->FileAlignment = a->SectionAlignment; | 1578 | 37.3k | } | 1579 | | | 1580 | 51.5k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1581 | 23.7k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1582 | 51.5k | } | 1583 | | | 1584 | 71.6k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1585 | 71.6k | (opt_hdr_size != 0 | 1586 | 71.6k | ? &internal_a | 1587 | 71.6k | : (struct internal_aouthdr *) NULL)); | 1588 | | | 1589 | 71.6k | if (result) | 1590 | 42.5k | { | 1591 | | /* Now the whole header has been processed, see if there is a build-id */ | 1592 | 42.5k | pe_bfd_read_buildid(abfd); | 1593 | 42.5k | } | 1594 | | | 1595 | 71.6k | return result; | 1596 | 72.6k | } |
pei-x86_64.c:pe_bfd_object_p Line | Count | Source | 1446 | 1.72M | { | 1447 | 1.72M | bfd_byte buffer[6]; | 1448 | 1.72M | struct external_DOS_hdr dos_hdr; | 1449 | 1.72M | struct external_PEI_IMAGE_hdr image_hdr; | 1450 | 1.72M | struct internal_filehdr internal_f; | 1451 | 1.72M | struct internal_aouthdr internal_a; | 1452 | 1.72M | bfd_size_type opt_hdr_size; | 1453 | 1.72M | file_ptr offset; | 1454 | 1.72M | bfd_cleanup result; | 1455 | | | 1456 | | /* Detect if this a Microsoft Import Library Format element. */ | 1457 | | /* First read the beginning of the header. */ | 1458 | 1.72M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1459 | 1.72M | || bfd_read (buffer, 6, abfd) != 6) | 1460 | 4.91k | { | 1461 | 4.91k | if (bfd_get_error () != bfd_error_system_call) | 1462 | 4.23k | bfd_set_error (bfd_error_wrong_format); | 1463 | 4.91k | return NULL; | 1464 | 4.91k | } | 1465 | | | 1466 | | /* Then check the magic and the version (only 0 is supported). */ | 1467 | 1.72M | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1468 | 1.72M | && H_GET_16 (abfd, buffer + 4) == 0) | 1469 | 25.6k | return pe_ILF_object_p (abfd); | 1470 | | | 1471 | 1.69M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1472 | 1.69M | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1473 | 312k | { | 1474 | 312k | if (bfd_get_error () != bfd_error_system_call) | 1475 | 312k | bfd_set_error (bfd_error_wrong_format); | 1476 | 312k | return NULL; | 1477 | 312k | } | 1478 | | | 1479 | | /* There are really two magic numbers involved; the magic number | 1480 | | that says this is a NT executable (PEI) and the magic number that | 1481 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1482 | | the e_magic field. The latter is stored in the f_magic field. | 1483 | | If the NT magic number isn't valid, the architecture magic number | 1484 | | could be mimicked by some other field (specifically, the number | 1485 | | of relocs in section 3). Since this routine can only be called | 1486 | | correctly for a PEI file, check the e_magic number here, and, if | 1487 | | it doesn't match, clobber the f_magic number so that we don't get | 1488 | | a false match. */ | 1489 | 1.38M | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1490 | 757k | { | 1491 | 757k | bfd_set_error (bfd_error_wrong_format); | 1492 | 757k | return NULL; | 1493 | 757k | } | 1494 | | | 1495 | 627k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1496 | 627k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1497 | 627k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1498 | 5.76k | { | 1499 | 5.76k | if (bfd_get_error () != bfd_error_system_call) | 1500 | 5.76k | bfd_set_error (bfd_error_wrong_format); | 1501 | 5.76k | return NULL; | 1502 | 5.76k | } | 1503 | | | 1504 | 621k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1505 | 14.7k | { | 1506 | 14.7k | bfd_set_error (bfd_error_wrong_format); | 1507 | 14.7k | return NULL; | 1508 | 14.7k | } | 1509 | | | 1510 | | /* Swap file header, so that we get the location for calling | 1511 | | real_object_p. */ | 1512 | 607k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1513 | | | 1514 | 607k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1515 | 607k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1516 | 523k | { | 1517 | 523k | bfd_set_error (bfd_error_wrong_format); | 1518 | 523k | return NULL; | 1519 | 523k | } | 1520 | | | 1521 | 84.0k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1522 | 84.0k | sizeof (internal_f.pe.dos_message)); | 1523 | | | 1524 | | /* Read the optional header, which has variable size. */ | 1525 | 84.0k | opt_hdr_size = internal_f.f_opthdr; | 1526 | | | 1527 | 84.0k | if (opt_hdr_size != 0) | 1528 | 56.6k | { | 1529 | 56.6k | bfd_size_type amt = opt_hdr_size; | 1530 | 56.6k | bfd_byte * opthdr; | 1531 | | | 1532 | | /* PR 17521 file: 230-131433-0.004. */ | 1533 | 56.6k | if (amt < sizeof (PEAOUTHDR)) | 1534 | 50.0k | amt = sizeof (PEAOUTHDR); | 1535 | | | 1536 | 56.6k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1537 | 56.6k | if (opthdr == NULL) | 1538 | 1.57k | return NULL; | 1539 | 55.1k | if (amt > opt_hdr_size) | 1540 | 48.8k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1541 | | | 1542 | 55.1k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1543 | | | 1544 | 55.1k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1545 | | | 1546 | | #ifdef ARM | 1547 | | /* Use Subsystem to distinguish between pei-arm-little and | 1548 | | pei-arm-wince-little. */ | 1549 | | #ifdef WINCE | 1550 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1551 | | #else | 1552 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1553 | | #endif | 1554 | | { | 1555 | | bfd_set_error (bfd_error_wrong_format); | 1556 | | return NULL; | 1557 | | } | 1558 | | #endif | 1559 | | | 1560 | 55.1k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1561 | 55.1k | || a->SectionAlignment >= 0x80000000) | 1562 | 32.0k | { | 1563 | 32.0k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1564 | 32.0k | abfd); | 1565 | 32.0k | a->SectionAlignment &= -a->SectionAlignment; | 1566 | 32.0k | if (a->SectionAlignment >= 0x80000000) | 1567 | 451 | a->SectionAlignment = 0x40000000; | 1568 | 32.0k | } | 1569 | | | 1570 | 55.1k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1571 | 55.1k | || a->FileAlignment > a->SectionAlignment) | 1572 | 37.2k | { | 1573 | 37.2k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1574 | 37.2k | abfd); | 1575 | 37.2k | a->FileAlignment &= -a->FileAlignment; | 1576 | 37.2k | if (a->FileAlignment > a->SectionAlignment) | 1577 | 22.8k | a->FileAlignment = a->SectionAlignment; | 1578 | 37.2k | } | 1579 | | | 1580 | 55.1k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1581 | 37.8k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1582 | 55.1k | } | 1583 | | | 1584 | 82.4k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1585 | 82.4k | (opt_hdr_size != 0 | 1586 | 82.4k | ? &internal_a | 1587 | 82.4k | : (struct internal_aouthdr *) NULL)); | 1588 | | | 1589 | 82.4k | if (result) | 1590 | 50.3k | { | 1591 | | /* Now the whole header has been processed, see if there is a build-id */ | 1592 | 50.3k | pe_bfd_read_buildid(abfd); | 1593 | 50.3k | } | 1594 | | | 1595 | 82.4k | return result; | 1596 | 84.0k | } |
pei-aarch64.c:pe_bfd_object_p Line | Count | Source | 1446 | 1.70M | { | 1447 | 1.70M | bfd_byte buffer[6]; | 1448 | 1.70M | struct external_DOS_hdr dos_hdr; | 1449 | 1.70M | struct external_PEI_IMAGE_hdr image_hdr; | 1450 | 1.70M | struct internal_filehdr internal_f; | 1451 | 1.70M | struct internal_aouthdr internal_a; | 1452 | 1.70M | bfd_size_type opt_hdr_size; | 1453 | 1.70M | file_ptr offset; | 1454 | 1.70M | bfd_cleanup result; | 1455 | | | 1456 | | /* Detect if this a Microsoft Import Library Format element. */ | 1457 | | /* First read the beginning of the header. */ | 1458 | 1.70M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1459 | 1.70M | || bfd_read (buffer, 6, abfd) != 6) | 1460 | 4.91k | { | 1461 | 4.91k | if (bfd_get_error () != bfd_error_system_call) | 1462 | 4.23k | bfd_set_error (bfd_error_wrong_format); | 1463 | 4.91k | return NULL; | 1464 | 4.91k | } | 1465 | | | 1466 | | /* Then check the magic and the version (only 0 is supported). */ | 1467 | 1.70M | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1468 | 1.70M | && H_GET_16 (abfd, buffer + 4) == 0) | 1469 | 40.2k | return pe_ILF_object_p (abfd); | 1470 | | | 1471 | 1.66M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1472 | 1.66M | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1473 | 311k | { | 1474 | 311k | if (bfd_get_error () != bfd_error_system_call) | 1475 | 311k | bfd_set_error (bfd_error_wrong_format); | 1476 | 311k | return NULL; | 1477 | 311k | } | 1478 | | | 1479 | | /* There are really two magic numbers involved; the magic number | 1480 | | that says this is a NT executable (PEI) and the magic number that | 1481 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1482 | | the e_magic field. The latter is stored in the f_magic field. | 1483 | | If the NT magic number isn't valid, the architecture magic number | 1484 | | could be mimicked by some other field (specifically, the number | 1485 | | of relocs in section 3). Since this routine can only be called | 1486 | | correctly for a PEI file, check the e_magic number here, and, if | 1487 | | it doesn't match, clobber the f_magic number so that we don't get | 1488 | | a false match. */ | 1489 | 1.35M | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1490 | 742k | { | 1491 | 742k | bfd_set_error (bfd_error_wrong_format); | 1492 | 742k | return NULL; | 1493 | 742k | } | 1494 | | | 1495 | 609k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1496 | 609k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1497 | 609k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1498 | 6.21k | { | 1499 | 6.21k | if (bfd_get_error () != bfd_error_system_call) | 1500 | 6.21k | bfd_set_error (bfd_error_wrong_format); | 1501 | 6.21k | return NULL; | 1502 | 6.21k | } | 1503 | | | 1504 | 603k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1505 | 15.4k | { | 1506 | 15.4k | bfd_set_error (bfd_error_wrong_format); | 1507 | 15.4k | return NULL; | 1508 | 15.4k | } | 1509 | | | 1510 | | /* Swap file header, so that we get the location for calling | 1511 | | real_object_p. */ | 1512 | 588k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1513 | | | 1514 | 588k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1515 | 588k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1516 | 530k | { | 1517 | 530k | bfd_set_error (bfd_error_wrong_format); | 1518 | 530k | return NULL; | 1519 | 530k | } | 1520 | | | 1521 | 58.1k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1522 | 58.1k | sizeof (internal_f.pe.dos_message)); | 1523 | | | 1524 | | /* Read the optional header, which has variable size. */ | 1525 | 58.1k | opt_hdr_size = internal_f.f_opthdr; | 1526 | | | 1527 | 58.1k | if (opt_hdr_size != 0) | 1528 | 45.7k | { | 1529 | 45.7k | bfd_size_type amt = opt_hdr_size; | 1530 | 45.7k | bfd_byte * opthdr; | 1531 | | | 1532 | | /* PR 17521 file: 230-131433-0.004. */ | 1533 | 45.7k | if (amt < sizeof (PEAOUTHDR)) | 1534 | 17.8k | amt = sizeof (PEAOUTHDR); | 1535 | | | 1536 | 45.7k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1537 | 45.7k | if (opthdr == NULL) | 1538 | 1.79k | return NULL; | 1539 | 43.9k | if (amt > opt_hdr_size) | 1540 | 17.1k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1541 | | | 1542 | 43.9k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1543 | | | 1544 | 43.9k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1545 | | | 1546 | | #ifdef ARM | 1547 | | /* Use Subsystem to distinguish between pei-arm-little and | 1548 | | pei-arm-wince-little. */ | 1549 | | #ifdef WINCE | 1550 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1551 | | #else | 1552 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1553 | | #endif | 1554 | | { | 1555 | | bfd_set_error (bfd_error_wrong_format); | 1556 | | return NULL; | 1557 | | } | 1558 | | #endif | 1559 | | | 1560 | 43.9k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1561 | 43.9k | || a->SectionAlignment >= 0x80000000) | 1562 | 27.6k | { | 1563 | 27.6k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1564 | 27.6k | abfd); | 1565 | 27.6k | a->SectionAlignment &= -a->SectionAlignment; | 1566 | 27.6k | if (a->SectionAlignment >= 0x80000000) | 1567 | 243 | a->SectionAlignment = 0x40000000; | 1568 | 27.6k | } | 1569 | | | 1570 | 43.9k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1571 | 43.9k | || a->FileAlignment > a->SectionAlignment) | 1572 | 28.9k | { | 1573 | 28.9k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1574 | 28.9k | abfd); | 1575 | 28.9k | a->FileAlignment &= -a->FileAlignment; | 1576 | 28.9k | if (a->FileAlignment > a->SectionAlignment) | 1577 | 9.63k | a->FileAlignment = a->SectionAlignment; | 1578 | 28.9k | } | 1579 | | | 1580 | 43.9k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1581 | 37.0k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1582 | 43.9k | } | 1583 | | | 1584 | 56.3k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1585 | 56.3k | (opt_hdr_size != 0 | 1586 | 56.3k | ? &internal_a | 1587 | 56.3k | : (struct internal_aouthdr *) NULL)); | 1588 | | | 1589 | 56.3k | if (result) | 1590 | 26.8k | { | 1591 | | /* Now the whole header has been processed, see if there is a build-id */ | 1592 | 26.8k | pe_bfd_read_buildid(abfd); | 1593 | 26.8k | } | 1594 | | | 1595 | 56.3k | return result; | 1596 | 58.1k | } |
pei-ia64.c:pe_bfd_object_p Line | Count | Source | 1446 | 571k | { | 1447 | 571k | bfd_byte buffer[6]; | 1448 | 571k | struct external_DOS_hdr dos_hdr; | 1449 | 571k | struct external_PEI_IMAGE_hdr image_hdr; | 1450 | 571k | struct internal_filehdr internal_f; | 1451 | 571k | struct internal_aouthdr internal_a; | 1452 | 571k | bfd_size_type opt_hdr_size; | 1453 | 571k | file_ptr offset; | 1454 | 571k | bfd_cleanup result; | 1455 | | | 1456 | | /* Detect if this a Microsoft Import Library Format element. */ | 1457 | | /* First read the beginning of the header. */ | 1458 | 571k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1459 | 571k | || bfd_read (buffer, 6, abfd) != 6) | 1460 | 0 | { | 1461 | 0 | if (bfd_get_error () != bfd_error_system_call) | 1462 | 0 | bfd_set_error (bfd_error_wrong_format); | 1463 | 0 | return NULL; | 1464 | 0 | } | 1465 | | | 1466 | | /* Then check the magic and the version (only 0 is supported). */ | 1467 | 571k | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1468 | 571k | && H_GET_16 (abfd, buffer + 4) == 0) | 1469 | 0 | return pe_ILF_object_p (abfd); | 1470 | | | 1471 | 571k | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1472 | 571k | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1473 | 0 | { | 1474 | 0 | if (bfd_get_error () != bfd_error_system_call) | 1475 | 0 | bfd_set_error (bfd_error_wrong_format); | 1476 | 0 | return NULL; | 1477 | 0 | } | 1478 | | | 1479 | | /* There are really two magic numbers involved; the magic number | 1480 | | that says this is a NT executable (PEI) and the magic number that | 1481 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1482 | | the e_magic field. The latter is stored in the f_magic field. | 1483 | | If the NT magic number isn't valid, the architecture magic number | 1484 | | could be mimicked by some other field (specifically, the number | 1485 | | of relocs in section 3). Since this routine can only be called | 1486 | | correctly for a PEI file, check the e_magic number here, and, if | 1487 | | it doesn't match, clobber the f_magic number so that we don't get | 1488 | | a false match. */ | 1489 | 571k | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1490 | 0 | { | 1491 | 0 | bfd_set_error (bfd_error_wrong_format); | 1492 | 0 | return NULL; | 1493 | 0 | } | 1494 | | | 1495 | 571k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1496 | 571k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1497 | 571k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1498 | 0 | { | 1499 | 0 | if (bfd_get_error () != bfd_error_system_call) | 1500 | 0 | bfd_set_error (bfd_error_wrong_format); | 1501 | 0 | return NULL; | 1502 | 0 | } | 1503 | | | 1504 | 571k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1505 | 0 | { | 1506 | 0 | bfd_set_error (bfd_error_wrong_format); | 1507 | 0 | return NULL; | 1508 | 0 | } | 1509 | | | 1510 | | /* Swap file header, so that we get the location for calling | 1511 | | real_object_p. */ | 1512 | 571k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1513 | | | 1514 | 571k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1515 | 571k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1516 | 494k | { | 1517 | 494k | bfd_set_error (bfd_error_wrong_format); | 1518 | 494k | return NULL; | 1519 | 494k | } | 1520 | | | 1521 | 77.0k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1522 | 77.0k | sizeof (internal_f.pe.dos_message)); | 1523 | | | 1524 | | /* Read the optional header, which has variable size. */ | 1525 | 77.0k | opt_hdr_size = internal_f.f_opthdr; | 1526 | | | 1527 | 77.0k | if (opt_hdr_size != 0) | 1528 | 51.2k | { | 1529 | 51.2k | bfd_size_type amt = opt_hdr_size; | 1530 | 51.2k | bfd_byte * opthdr; | 1531 | | | 1532 | | /* PR 17521 file: 230-131433-0.004. */ | 1533 | 51.2k | if (amt < sizeof (PEAOUTHDR)) | 1534 | 42.6k | amt = sizeof (PEAOUTHDR); | 1535 | | | 1536 | 51.2k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1537 | 51.2k | if (opthdr == NULL) | 1538 | 2.02k | return NULL; | 1539 | 49.2k | if (amt > opt_hdr_size) | 1540 | 41.1k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1541 | | | 1542 | 49.2k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1543 | | | 1544 | 49.2k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1545 | | | 1546 | | #ifdef ARM | 1547 | | /* Use Subsystem to distinguish between pei-arm-little and | 1548 | | pei-arm-wince-little. */ | 1549 | | #ifdef WINCE | 1550 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1551 | | #else | 1552 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1553 | | #endif | 1554 | | { | 1555 | | bfd_set_error (bfd_error_wrong_format); | 1556 | | return NULL; | 1557 | | } | 1558 | | #endif | 1559 | | | 1560 | 49.2k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1561 | 49.2k | || a->SectionAlignment >= 0x80000000) | 1562 | 27.1k | { | 1563 | 27.1k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1564 | 27.1k | abfd); | 1565 | 27.1k | a->SectionAlignment &= -a->SectionAlignment; | 1566 | 27.1k | if (a->SectionAlignment >= 0x80000000) | 1567 | 652 | a->SectionAlignment = 0x40000000; | 1568 | 27.1k | } | 1569 | | | 1570 | 49.2k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1571 | 49.2k | || a->FileAlignment > a->SectionAlignment) | 1572 | 34.0k | { | 1573 | 34.0k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1574 | 34.0k | abfd); | 1575 | 34.0k | a->FileAlignment &= -a->FileAlignment; | 1576 | 34.0k | if (a->FileAlignment > a->SectionAlignment) | 1577 | 13.7k | a->FileAlignment = a->SectionAlignment; | 1578 | 34.0k | } | 1579 | | | 1580 | 49.2k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1581 | 39.1k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1582 | 49.2k | } | 1583 | | | 1584 | 75.0k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1585 | 75.0k | (opt_hdr_size != 0 | 1586 | 75.0k | ? &internal_a | 1587 | 75.0k | : (struct internal_aouthdr *) NULL)); | 1588 | | | 1589 | 75.0k | if (result) | 1590 | 34.3k | { | 1591 | | /* Now the whole header has been processed, see if there is a build-id */ | 1592 | 34.3k | pe_bfd_read_buildid(abfd); | 1593 | 34.3k | } | 1594 | | | 1595 | 75.0k | return result; | 1596 | 77.0k | } |
pei-loongarch64.c:pe_bfd_object_p Line | Count | Source | 1446 | 1.70M | { | 1447 | 1.70M | bfd_byte buffer[6]; | 1448 | 1.70M | struct external_DOS_hdr dos_hdr; | 1449 | 1.70M | struct external_PEI_IMAGE_hdr image_hdr; | 1450 | 1.70M | struct internal_filehdr internal_f; | 1451 | 1.70M | struct internal_aouthdr internal_a; | 1452 | 1.70M | bfd_size_type opt_hdr_size; | 1453 | 1.70M | file_ptr offset; | 1454 | 1.70M | bfd_cleanup result; | 1455 | | | 1456 | | /* Detect if this a Microsoft Import Library Format element. */ | 1457 | | /* First read the beginning of the header. */ | 1458 | 1.70M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1459 | 1.70M | || bfd_read (buffer, 6, abfd) != 6) | 1460 | 4.91k | { | 1461 | 4.91k | if (bfd_get_error () != bfd_error_system_call) | 1462 | 4.23k | bfd_set_error (bfd_error_wrong_format); | 1463 | 4.91k | return NULL; | 1464 | 4.91k | } | 1465 | | | 1466 | | /* Then check the magic and the version (only 0 is supported). */ | 1467 | 1.70M | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1468 | 1.70M | && H_GET_16 (abfd, buffer + 4) == 0) | 1469 | 21.9k | return pe_ILF_object_p (abfd); | 1470 | | | 1471 | 1.68M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1472 | 1.68M | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1473 | 314k | { | 1474 | 314k | if (bfd_get_error () != bfd_error_system_call) | 1475 | 314k | bfd_set_error (bfd_error_wrong_format); | 1476 | 314k | return NULL; | 1477 | 314k | } | 1478 | | | 1479 | | /* There are really two magic numbers involved; the magic number | 1480 | | that says this is a NT executable (PEI) and the magic number that | 1481 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1482 | | the e_magic field. The latter is stored in the f_magic field. | 1483 | | If the NT magic number isn't valid, the architecture magic number | 1484 | | could be mimicked by some other field (specifically, the number | 1485 | | of relocs in section 3). Since this routine can only be called | 1486 | | correctly for a PEI file, check the e_magic number here, and, if | 1487 | | it doesn't match, clobber the f_magic number so that we don't get | 1488 | | a false match. */ | 1489 | 1.36M | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1490 | 759k | { | 1491 | 759k | bfd_set_error (bfd_error_wrong_format); | 1492 | 759k | return NULL; | 1493 | 759k | } | 1494 | | | 1495 | 608k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1496 | 608k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1497 | 608k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1498 | 5.76k | { | 1499 | 5.76k | if (bfd_get_error () != bfd_error_system_call) | 1500 | 5.76k | bfd_set_error (bfd_error_wrong_format); | 1501 | 5.76k | return NULL; | 1502 | 5.76k | } | 1503 | | | 1504 | 602k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1505 | 14.7k | { | 1506 | 14.7k | bfd_set_error (bfd_error_wrong_format); | 1507 | 14.7k | return NULL; | 1508 | 14.7k | } | 1509 | | | 1510 | | /* Swap file header, so that we get the location for calling | 1511 | | real_object_p. */ | 1512 | 587k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1513 | | | 1514 | 587k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1515 | 587k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1516 | 544k | { | 1517 | 544k | bfd_set_error (bfd_error_wrong_format); | 1518 | 544k | return NULL; | 1519 | 544k | } | 1520 | | | 1521 | 43.5k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1522 | 43.5k | sizeof (internal_f.pe.dos_message)); | 1523 | | | 1524 | | /* Read the optional header, which has variable size. */ | 1525 | 43.5k | opt_hdr_size = internal_f.f_opthdr; | 1526 | | | 1527 | 43.5k | if (opt_hdr_size != 0) | 1528 | 33.0k | { | 1529 | 33.0k | bfd_size_type amt = opt_hdr_size; | 1530 | 33.0k | bfd_byte * opthdr; | 1531 | | | 1532 | | /* PR 17521 file: 230-131433-0.004. */ | 1533 | 33.0k | if (amt < sizeof (PEAOUTHDR)) | 1534 | 19.1k | amt = sizeof (PEAOUTHDR); | 1535 | | | 1536 | 33.0k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1537 | 33.0k | if (opthdr == NULL) | 1538 | 1.29k | return NULL; | 1539 | 31.7k | if (amt > opt_hdr_size) | 1540 | 18.5k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1541 | | | 1542 | 31.7k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1543 | | | 1544 | 31.7k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1545 | | | 1546 | | #ifdef ARM | 1547 | | /* Use Subsystem to distinguish between pei-arm-little and | 1548 | | pei-arm-wince-little. */ | 1549 | | #ifdef WINCE | 1550 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1551 | | #else | 1552 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1553 | | #endif | 1554 | | { | 1555 | | bfd_set_error (bfd_error_wrong_format); | 1556 | | return NULL; | 1557 | | } | 1558 | | #endif | 1559 | | | 1560 | 31.7k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1561 | 31.7k | || a->SectionAlignment >= 0x80000000) | 1562 | 16.8k | { | 1563 | 16.8k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1564 | 16.8k | abfd); | 1565 | 16.8k | a->SectionAlignment &= -a->SectionAlignment; | 1566 | 16.8k | if (a->SectionAlignment >= 0x80000000) | 1567 | 453 | a->SectionAlignment = 0x40000000; | 1568 | 16.8k | } | 1569 | | | 1570 | 31.7k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1571 | 31.7k | || a->FileAlignment > a->SectionAlignment) | 1572 | 24.4k | { | 1573 | 24.4k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1574 | 24.4k | abfd); | 1575 | 24.4k | a->FileAlignment &= -a->FileAlignment; | 1576 | 24.4k | if (a->FileAlignment > a->SectionAlignment) | 1577 | 12.0k | a->FileAlignment = a->SectionAlignment; | 1578 | 24.4k | } | 1579 | | | 1580 | 31.7k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1581 | 23.8k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1582 | 31.7k | } | 1583 | | | 1584 | 42.2k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1585 | 42.2k | (opt_hdr_size != 0 | 1586 | 42.2k | ? &internal_a | 1587 | 42.2k | : (struct internal_aouthdr *) NULL)); | 1588 | | | 1589 | 42.2k | if (result) | 1590 | 24.6k | { | 1591 | | /* Now the whole header has been processed, see if there is a build-id */ | 1592 | 24.6k | pe_bfd_read_buildid(abfd); | 1593 | 24.6k | } | 1594 | | | 1595 | 42.2k | return result; | 1596 | 43.5k | } |
pei-riscv64.c:pe_bfd_object_p Line | Count | Source | 1446 | 1.70M | { | 1447 | 1.70M | bfd_byte buffer[6]; | 1448 | 1.70M | struct external_DOS_hdr dos_hdr; | 1449 | 1.70M | struct external_PEI_IMAGE_hdr image_hdr; | 1450 | 1.70M | struct internal_filehdr internal_f; | 1451 | 1.70M | struct internal_aouthdr internal_a; | 1452 | 1.70M | bfd_size_type opt_hdr_size; | 1453 | 1.70M | file_ptr offset; | 1454 | 1.70M | bfd_cleanup result; | 1455 | | | 1456 | | /* Detect if this a Microsoft Import Library Format element. */ | 1457 | | /* First read the beginning of the header. */ | 1458 | 1.70M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1459 | 1.70M | || bfd_read (buffer, 6, abfd) != 6) | 1460 | 4.91k | { | 1461 | 4.91k | if (bfd_get_error () != bfd_error_system_call) | 1462 | 4.23k | bfd_set_error (bfd_error_wrong_format); | 1463 | 4.91k | return NULL; | 1464 | 4.91k | } | 1465 | | | 1466 | | /* Then check the magic and the version (only 0 is supported). */ | 1467 | 1.70M | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1468 | 1.70M | && H_GET_16 (abfd, buffer + 4) == 0) | 1469 | 28.8k | return pe_ILF_object_p (abfd); | 1470 | | | 1471 | 1.67M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1472 | 1.67M | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1473 | 312k | { | 1474 | 312k | if (bfd_get_error () != bfd_error_system_call) | 1475 | 312k | bfd_set_error (bfd_error_wrong_format); | 1476 | 312k | return NULL; | 1477 | 312k | } | 1478 | | | 1479 | | /* There are really two magic numbers involved; the magic number | 1480 | | that says this is a NT executable (PEI) and the magic number that | 1481 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1482 | | the e_magic field. The latter is stored in the f_magic field. | 1483 | | If the NT magic number isn't valid, the architecture magic number | 1484 | | could be mimicked by some other field (specifically, the number | 1485 | | of relocs in section 3). Since this routine can only be called | 1486 | | correctly for a PEI file, check the e_magic number here, and, if | 1487 | | it doesn't match, clobber the f_magic number so that we don't get | 1488 | | a false match. */ | 1489 | 1.36M | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1490 | 754k | { | 1491 | 754k | bfd_set_error (bfd_error_wrong_format); | 1492 | 754k | return NULL; | 1493 | 754k | } | 1494 | | | 1495 | 608k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1496 | 608k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1497 | 608k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1498 | 5.76k | { | 1499 | 5.76k | if (bfd_get_error () != bfd_error_system_call) | 1500 | 5.76k | bfd_set_error (bfd_error_wrong_format); | 1501 | 5.76k | return NULL; | 1502 | 5.76k | } | 1503 | | | 1504 | 602k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1505 | 14.7k | { | 1506 | 14.7k | bfd_set_error (bfd_error_wrong_format); | 1507 | 14.7k | return NULL; | 1508 | 14.7k | } | 1509 | | | 1510 | | /* Swap file header, so that we get the location for calling | 1511 | | real_object_p. */ | 1512 | 587k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1513 | | | 1514 | 587k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1515 | 587k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1516 | 559k | { | 1517 | 559k | bfd_set_error (bfd_error_wrong_format); | 1518 | 559k | return NULL; | 1519 | 559k | } | 1520 | | | 1521 | 28.2k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1522 | 28.2k | sizeof (internal_f.pe.dos_message)); | 1523 | | | 1524 | | /* Read the optional header, which has variable size. */ | 1525 | 28.2k | opt_hdr_size = internal_f.f_opthdr; | 1526 | | | 1527 | 28.2k | if (opt_hdr_size != 0) | 1528 | 24.9k | { | 1529 | 24.9k | bfd_size_type amt = opt_hdr_size; | 1530 | 24.9k | bfd_byte * opthdr; | 1531 | | | 1532 | | /* PR 17521 file: 230-131433-0.004. */ | 1533 | 24.9k | if (amt < sizeof (PEAOUTHDR)) | 1534 | 6.89k | amt = sizeof (PEAOUTHDR); | 1535 | | | 1536 | 24.9k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1537 | 24.9k | if (opthdr == NULL) | 1538 | 674 | return NULL; | 1539 | 24.2k | if (amt > opt_hdr_size) | 1540 | 6.56k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1541 | | | 1542 | 24.2k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1543 | | | 1544 | 24.2k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1545 | | | 1546 | | #ifdef ARM | 1547 | | /* Use Subsystem to distinguish between pei-arm-little and | 1548 | | pei-arm-wince-little. */ | 1549 | | #ifdef WINCE | 1550 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1551 | | #else | 1552 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1553 | | #endif | 1554 | | { | 1555 | | bfd_set_error (bfd_error_wrong_format); | 1556 | | return NULL; | 1557 | | } | 1558 | | #endif | 1559 | | | 1560 | 24.2k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1561 | 24.2k | || a->SectionAlignment >= 0x80000000) | 1562 | 12.8k | { | 1563 | 12.8k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1564 | 12.8k | abfd); | 1565 | 12.8k | a->SectionAlignment &= -a->SectionAlignment; | 1566 | 12.8k | if (a->SectionAlignment >= 0x80000000) | 1567 | 240 | a->SectionAlignment = 0x40000000; | 1568 | 12.8k | } | 1569 | | | 1570 | 24.2k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1571 | 24.2k | || a->FileAlignment > a->SectionAlignment) | 1572 | 15.2k | { | 1573 | 15.2k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1574 | 15.2k | abfd); | 1575 | 15.2k | a->FileAlignment &= -a->FileAlignment; | 1576 | 15.2k | if (a->FileAlignment > a->SectionAlignment) | 1577 | 7.27k | a->FileAlignment = a->SectionAlignment; | 1578 | 15.2k | } | 1579 | | | 1580 | 24.2k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1581 | 19.6k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1582 | 24.2k | } | 1583 | | | 1584 | 27.6k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1585 | 27.6k | (opt_hdr_size != 0 | 1586 | 27.6k | ? &internal_a | 1587 | 27.6k | : (struct internal_aouthdr *) NULL)); | 1588 | | | 1589 | 27.6k | if (result) | 1590 | 14.3k | { | 1591 | | /* Now the whole header has been processed, see if there is a build-id */ | 1592 | 14.3k | pe_bfd_read_buildid(abfd); | 1593 | 14.3k | } | 1594 | | | 1595 | 27.6k | return result; | 1596 | 28.2k | } |
pei-arm-wince.c:pe_bfd_object_p Line | Count | Source | 1446 | 3.40M | { | 1447 | 3.40M | bfd_byte buffer[6]; | 1448 | 3.40M | struct external_DOS_hdr dos_hdr; | 1449 | 3.40M | struct external_PEI_IMAGE_hdr image_hdr; | 1450 | 3.40M | struct internal_filehdr internal_f; | 1451 | 3.40M | struct internal_aouthdr internal_a; | 1452 | 3.40M | bfd_size_type opt_hdr_size; | 1453 | 3.40M | file_ptr offset; | 1454 | 3.40M | bfd_cleanup result; | 1455 | | | 1456 | | /* Detect if this a Microsoft Import Library Format element. */ | 1457 | | /* First read the beginning of the header. */ | 1458 | 3.40M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1459 | 3.40M | || bfd_read (buffer, 6, abfd) != 6) | 1460 | 9.58k | { | 1461 | 9.58k | if (bfd_get_error () != bfd_error_system_call) | 1462 | 8.24k | bfd_set_error (bfd_error_wrong_format); | 1463 | 9.58k | return NULL; | 1464 | 9.58k | } | 1465 | | | 1466 | | /* Then check the magic and the version (only 0 is supported). */ | 1467 | 3.39M | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1468 | 3.39M | && H_GET_16 (abfd, buffer + 4) == 0) | 1469 | 32.3k | return pe_ILF_object_p (abfd); | 1470 | | | 1471 | 3.35M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1472 | 3.35M | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1473 | 646k | { | 1474 | 646k | if (bfd_get_error () != bfd_error_system_call) | 1475 | 646k | bfd_set_error (bfd_error_wrong_format); | 1476 | 646k | return NULL; | 1477 | 646k | } | 1478 | | | 1479 | | /* There are really two magic numbers involved; the magic number | 1480 | | that says this is a NT executable (PEI) and the magic number that | 1481 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1482 | | the e_magic field. The latter is stored in the f_magic field. | 1483 | | If the NT magic number isn't valid, the architecture magic number | 1484 | | could be mimicked by some other field (specifically, the number | 1485 | | of relocs in section 3). Since this routine can only be called | 1486 | | correctly for a PEI file, check the e_magic number here, and, if | 1487 | | it doesn't match, clobber the f_magic number so that we don't get | 1488 | | a false match. */ | 1489 | 2.71M | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1490 | 2.10M | { | 1491 | 2.10M | bfd_set_error (bfd_error_wrong_format); | 1492 | 2.10M | return NULL; | 1493 | 2.10M | } | 1494 | | | 1495 | 609k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1496 | 609k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1497 | 609k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1498 | 6.21k | { | 1499 | 6.21k | if (bfd_get_error () != bfd_error_system_call) | 1500 | 6.21k | bfd_set_error (bfd_error_wrong_format); | 1501 | 6.21k | return NULL; | 1502 | 6.21k | } | 1503 | | | 1504 | 603k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1505 | 15.4k | { | 1506 | 15.4k | bfd_set_error (bfd_error_wrong_format); | 1507 | 15.4k | return NULL; | 1508 | 15.4k | } | 1509 | | | 1510 | | /* Swap file header, so that we get the location for calling | 1511 | | real_object_p. */ | 1512 | 587k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1513 | | | 1514 | 587k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1515 | 587k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1516 | 475k | { | 1517 | 475k | bfd_set_error (bfd_error_wrong_format); | 1518 | 475k | return NULL; | 1519 | 475k | } | 1520 | | | 1521 | 112k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1522 | 112k | sizeof (internal_f.pe.dos_message)); | 1523 | | | 1524 | | /* Read the optional header, which has variable size. */ | 1525 | 112k | opt_hdr_size = internal_f.f_opthdr; | 1526 | | | 1527 | 112k | if (opt_hdr_size != 0) | 1528 | 69.6k | { | 1529 | 69.6k | bfd_size_type amt = opt_hdr_size; | 1530 | 69.6k | bfd_byte * opthdr; | 1531 | | | 1532 | | /* PR 17521 file: 230-131433-0.004. */ | 1533 | 69.6k | if (amt < sizeof (PEAOUTHDR)) | 1534 | 34.0k | amt = sizeof (PEAOUTHDR); | 1535 | | | 1536 | 69.6k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1537 | 69.6k | if (opthdr == NULL) | 1538 | 2.78k | return NULL; | 1539 | 66.8k | if (amt > opt_hdr_size) | 1540 | 33.1k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1541 | | | 1542 | 66.8k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1543 | | | 1544 | 66.8k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1545 | | | 1546 | 66.8k | #ifdef ARM | 1547 | | /* Use Subsystem to distinguish between pei-arm-little and | 1548 | | pei-arm-wince-little. */ | 1549 | 66.8k | #ifdef WINCE | 1550 | 66.8k | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1551 | | #else | 1552 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1553 | | #endif | 1554 | 40.5k | { | 1555 | 40.5k | bfd_set_error (bfd_error_wrong_format); | 1556 | 40.5k | return NULL; | 1557 | 40.5k | } | 1558 | 26.3k | #endif | 1559 | | | 1560 | 26.3k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1561 | 26.3k | || a->SectionAlignment >= 0x80000000) | 1562 | 16.7k | { | 1563 | 16.7k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1564 | 16.7k | abfd); | 1565 | 16.7k | a->SectionAlignment &= -a->SectionAlignment; | 1566 | 16.7k | if (a->SectionAlignment >= 0x80000000) | 1567 | 2 | a->SectionAlignment = 0x40000000; | 1568 | 16.7k | } | 1569 | | | 1570 | 26.3k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1571 | 26.3k | || a->FileAlignment > a->SectionAlignment) | 1572 | 15.4k | { | 1573 | 15.4k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1574 | 15.4k | abfd); | 1575 | 15.4k | a->FileAlignment &= -a->FileAlignment; | 1576 | 15.4k | if (a->FileAlignment > a->SectionAlignment) | 1577 | 9.04k | a->FileAlignment = a->SectionAlignment; | 1578 | 15.4k | } | 1579 | | | 1580 | 26.3k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1581 | 20.3k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1582 | 26.3k | } | 1583 | | | 1584 | 69.2k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1585 | 69.2k | (opt_hdr_size != 0 | 1586 | 69.2k | ? &internal_a | 1587 | 69.2k | : (struct internal_aouthdr *) NULL)); | 1588 | | | 1589 | 69.2k | if (result) | 1590 | 17.0k | { | 1591 | | /* Now the whole header has been processed, see if there is a build-id */ | 1592 | 17.0k | pe_bfd_read_buildid(abfd); | 1593 | 17.0k | } | 1594 | | | 1595 | 69.2k | return result; | 1596 | 112k | } |
pei-arm.c:pe_bfd_object_p Line | Count | Source | 1446 | 3.40M | { | 1447 | 3.40M | bfd_byte buffer[6]; | 1448 | 3.40M | struct external_DOS_hdr dos_hdr; | 1449 | 3.40M | struct external_PEI_IMAGE_hdr image_hdr; | 1450 | 3.40M | struct internal_filehdr internal_f; | 1451 | 3.40M | struct internal_aouthdr internal_a; | 1452 | 3.40M | bfd_size_type opt_hdr_size; | 1453 | 3.40M | file_ptr offset; | 1454 | 3.40M | bfd_cleanup result; | 1455 | | | 1456 | | /* Detect if this a Microsoft Import Library Format element. */ | 1457 | | /* First read the beginning of the header. */ | 1458 | 3.40M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1459 | 3.40M | || bfd_read (buffer, 6, abfd) != 6) | 1460 | 9.58k | { | 1461 | 9.58k | if (bfd_get_error () != bfd_error_system_call) | 1462 | 8.24k | bfd_set_error (bfd_error_wrong_format); | 1463 | 9.58k | return NULL; | 1464 | 9.58k | } | 1465 | | | 1466 | | /* Then check the magic and the version (only 0 is supported). */ | 1467 | 3.39M | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1468 | 3.39M | && H_GET_16 (abfd, buffer + 4) == 0) | 1469 | 36.7k | return pe_ILF_object_p (abfd); | 1470 | | | 1471 | 3.35M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1472 | 3.35M | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1473 | 649k | { | 1474 | 649k | if (bfd_get_error () != bfd_error_system_call) | 1475 | 649k | bfd_set_error (bfd_error_wrong_format); | 1476 | 649k | return NULL; | 1477 | 649k | } | 1478 | | | 1479 | | /* There are really two magic numbers involved; the magic number | 1480 | | that says this is a NT executable (PEI) and the magic number that | 1481 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1482 | | the e_magic field. The latter is stored in the f_magic field. | 1483 | | If the NT magic number isn't valid, the architecture magic number | 1484 | | could be mimicked by some other field (specifically, the number | 1485 | | of relocs in section 3). Since this routine can only be called | 1486 | | correctly for a PEI file, check the e_magic number here, and, if | 1487 | | it doesn't match, clobber the f_magic number so that we don't get | 1488 | | a false match. */ | 1489 | 2.70M | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1490 | 2.09M | { | 1491 | 2.09M | bfd_set_error (bfd_error_wrong_format); | 1492 | 2.09M | return NULL; | 1493 | 2.09M | } | 1494 | | | 1495 | 609k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1496 | 609k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1497 | 609k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1498 | 6.21k | { | 1499 | 6.21k | if (bfd_get_error () != bfd_error_system_call) | 1500 | 6.21k | bfd_set_error (bfd_error_wrong_format); | 1501 | 6.21k | return NULL; | 1502 | 6.21k | } | 1503 | | | 1504 | 603k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1505 | 15.4k | { | 1506 | 15.4k | bfd_set_error (bfd_error_wrong_format); | 1507 | 15.4k | return NULL; | 1508 | 15.4k | } | 1509 | | | 1510 | | /* Swap file header, so that we get the location for calling | 1511 | | real_object_p. */ | 1512 | 587k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1513 | | | 1514 | 587k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1515 | 587k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1516 | 475k | { | 1517 | 475k | bfd_set_error (bfd_error_wrong_format); | 1518 | 475k | return NULL; | 1519 | 475k | } | 1520 | | | 1521 | 112k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1522 | 112k | sizeof (internal_f.pe.dos_message)); | 1523 | | | 1524 | | /* Read the optional header, which has variable size. */ | 1525 | 112k | opt_hdr_size = internal_f.f_opthdr; | 1526 | | | 1527 | 112k | if (opt_hdr_size != 0) | 1528 | 69.7k | { | 1529 | 69.7k | bfd_size_type amt = opt_hdr_size; | 1530 | 69.7k | bfd_byte * opthdr; | 1531 | | | 1532 | | /* PR 17521 file: 230-131433-0.004. */ | 1533 | 69.7k | if (amt < sizeof (PEAOUTHDR)) | 1534 | 34.0k | amt = sizeof (PEAOUTHDR); | 1535 | | | 1536 | 69.7k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1537 | 69.7k | if (opthdr == NULL) | 1538 | 2.78k | return NULL; | 1539 | 66.9k | if (amt > opt_hdr_size) | 1540 | 33.1k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1541 | | | 1542 | 66.9k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1543 | | | 1544 | 66.9k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1545 | | | 1546 | 66.9k | #ifdef ARM | 1547 | | /* Use Subsystem to distinguish between pei-arm-little and | 1548 | | pei-arm-wince-little. */ | 1549 | | #ifdef WINCE | 1550 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1551 | | #else | 1552 | 66.9k | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1553 | 26.2k | #endif | 1554 | 26.2k | { | 1555 | 26.2k | bfd_set_error (bfd_error_wrong_format); | 1556 | 26.2k | return NULL; | 1557 | 26.2k | } | 1558 | 40.6k | #endif | 1559 | | | 1560 | 40.6k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1561 | 40.6k | || a->SectionAlignment >= 0x80000000) | 1562 | 28.0k | { | 1563 | 28.0k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1564 | 28.0k | abfd); | 1565 | 28.0k | a->SectionAlignment &= -a->SectionAlignment; | 1566 | 28.0k | if (a->SectionAlignment >= 0x80000000) | 1567 | 963 | a->SectionAlignment = 0x40000000; | 1568 | 28.0k | } | 1569 | | | 1570 | 40.6k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1571 | 40.6k | || a->FileAlignment > a->SectionAlignment) | 1572 | 27.7k | { | 1573 | 27.7k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1574 | 27.7k | abfd); | 1575 | 27.7k | a->FileAlignment &= -a->FileAlignment; | 1576 | 27.7k | if (a->FileAlignment > a->SectionAlignment) | 1577 | 12.0k | a->FileAlignment = a->SectionAlignment; | 1578 | 27.7k | } | 1579 | | | 1580 | 40.6k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1581 | 23.4k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1582 | 40.6k | } | 1583 | | | 1584 | 83.5k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1585 | 83.5k | (opt_hdr_size != 0 | 1586 | 83.5k | ? &internal_a | 1587 | 83.5k | : (struct internal_aouthdr *) NULL)); | 1588 | | | 1589 | 83.5k | if (result) | 1590 | 26.0k | { | 1591 | | /* Now the whole header has been processed, see if there is a build-id */ | 1592 | 26.0k | pe_bfd_read_buildid(abfd); | 1593 | 26.0k | } | 1594 | | | 1595 | 83.5k | return result; | 1596 | 112k | } |
pei-mcore.c:pe_bfd_object_p Line | Count | Source | 1446 | 3.40M | { | 1447 | 3.40M | bfd_byte buffer[6]; | 1448 | 3.40M | struct external_DOS_hdr dos_hdr; | 1449 | 3.40M | struct external_PEI_IMAGE_hdr image_hdr; | 1450 | 3.40M | struct internal_filehdr internal_f; | 1451 | 3.40M | struct internal_aouthdr internal_a; | 1452 | 3.40M | bfd_size_type opt_hdr_size; | 1453 | 3.40M | file_ptr offset; | 1454 | 3.40M | bfd_cleanup result; | 1455 | | | 1456 | | /* Detect if this a Microsoft Import Library Format element. */ | 1457 | | /* First read the beginning of the header. */ | 1458 | 3.40M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1459 | 3.40M | || bfd_read (buffer, 6, abfd) != 6) | 1460 | 9.58k | { | 1461 | 9.58k | if (bfd_get_error () != bfd_error_system_call) | 1462 | 8.24k | bfd_set_error (bfd_error_wrong_format); | 1463 | 9.58k | return NULL; | 1464 | 9.58k | } | 1465 | | | 1466 | | /* Then check the magic and the version (only 0 is supported). */ | 1467 | 3.39M | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1468 | 3.39M | && H_GET_16 (abfd, buffer + 4) == 0) | 1469 | 28.8k | return pe_ILF_object_p (abfd); | 1470 | | | 1471 | 3.36M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1472 | 3.36M | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1473 | 643k | { | 1474 | 643k | if (bfd_get_error () != bfd_error_system_call) | 1475 | 643k | bfd_set_error (bfd_error_wrong_format); | 1476 | 643k | return NULL; | 1477 | 643k | } | 1478 | | | 1479 | | /* There are really two magic numbers involved; the magic number | 1480 | | that says this is a NT executable (PEI) and the magic number that | 1481 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1482 | | the e_magic field. The latter is stored in the f_magic field. | 1483 | | If the NT magic number isn't valid, the architecture magic number | 1484 | | could be mimicked by some other field (specifically, the number | 1485 | | of relocs in section 3). Since this routine can only be called | 1486 | | correctly for a PEI file, check the e_magic number here, and, if | 1487 | | it doesn't match, clobber the f_magic number so that we don't get | 1488 | | a false match. */ | 1489 | 2.71M | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1490 | 2.11M | { | 1491 | 2.11M | bfd_set_error (bfd_error_wrong_format); | 1492 | 2.11M | return NULL; | 1493 | 2.11M | } | 1494 | | | 1495 | 608k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1496 | 608k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1497 | 608k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1498 | 5.76k | { | 1499 | 5.76k | if (bfd_get_error () != bfd_error_system_call) | 1500 | 5.76k | bfd_set_error (bfd_error_wrong_format); | 1501 | 5.76k | return NULL; | 1502 | 5.76k | } | 1503 | | | 1504 | 602k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1505 | 14.7k | { | 1506 | 14.7k | bfd_set_error (bfd_error_wrong_format); | 1507 | 14.7k | return NULL; | 1508 | 14.7k | } | 1509 | | | 1510 | | /* Swap file header, so that we get the location for calling | 1511 | | real_object_p. */ | 1512 | 587k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1513 | | | 1514 | 587k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1515 | 587k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1516 | 522k | { | 1517 | 522k | bfd_set_error (bfd_error_wrong_format); | 1518 | 522k | return NULL; | 1519 | 522k | } | 1520 | | | 1521 | 65.5k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1522 | 65.5k | sizeof (internal_f.pe.dos_message)); | 1523 | | | 1524 | | /* Read the optional header, which has variable size. */ | 1525 | 65.5k | opt_hdr_size = internal_f.f_opthdr; | 1526 | | | 1527 | 65.5k | if (opt_hdr_size != 0) | 1528 | 47.9k | { | 1529 | 47.9k | bfd_size_type amt = opt_hdr_size; | 1530 | 47.9k | bfd_byte * opthdr; | 1531 | | | 1532 | | /* PR 17521 file: 230-131433-0.004. */ | 1533 | 47.9k | if (amt < sizeof (PEAOUTHDR)) | 1534 | 27.3k | amt = sizeof (PEAOUTHDR); | 1535 | | | 1536 | 47.9k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1537 | 47.9k | if (opthdr == NULL) | 1538 | 2.57k | return NULL; | 1539 | 45.3k | if (amt > opt_hdr_size) | 1540 | 26.0k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1541 | | | 1542 | 45.3k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1543 | | | 1544 | 45.3k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1545 | | | 1546 | | #ifdef ARM | 1547 | | /* Use Subsystem to distinguish between pei-arm-little and | 1548 | | pei-arm-wince-little. */ | 1549 | | #ifdef WINCE | 1550 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1551 | | #else | 1552 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1553 | | #endif | 1554 | | { | 1555 | | bfd_set_error (bfd_error_wrong_format); | 1556 | | return NULL; | 1557 | | } | 1558 | | #endif | 1559 | | | 1560 | 45.3k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1561 | 45.3k | || a->SectionAlignment >= 0x80000000) | 1562 | 23.1k | { | 1563 | 23.1k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1564 | 23.1k | abfd); | 1565 | 23.1k | a->SectionAlignment &= -a->SectionAlignment; | 1566 | 23.1k | if (a->SectionAlignment >= 0x80000000) | 1567 | 723 | a->SectionAlignment = 0x40000000; | 1568 | 23.1k | } | 1569 | | | 1570 | 45.3k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1571 | 45.3k | || a->FileAlignment > a->SectionAlignment) | 1572 | 35.0k | { | 1573 | 35.0k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1574 | 35.0k | abfd); | 1575 | 35.0k | a->FileAlignment &= -a->FileAlignment; | 1576 | 35.0k | if (a->FileAlignment > a->SectionAlignment) | 1577 | 15.9k | a->FileAlignment = a->SectionAlignment; | 1578 | 35.0k | } | 1579 | | | 1580 | 45.3k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1581 | 35.4k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1582 | 45.3k | } | 1583 | | | 1584 | 62.9k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1585 | 62.9k | (opt_hdr_size != 0 | 1586 | 62.9k | ? &internal_a | 1587 | 62.9k | : (struct internal_aouthdr *) NULL)); | 1588 | | | 1589 | 62.9k | if (result) | 1590 | 34.6k | { | 1591 | | /* Now the whole header has been processed, see if there is a build-id */ | 1592 | 34.6k | pe_bfd_read_buildid(abfd); | 1593 | 34.6k | } | 1594 | | | 1595 | 62.9k | return result; | 1596 | 65.5k | } |
Line | Count | Source | 1446 | 1.70M | { | 1447 | 1.70M | bfd_byte buffer[6]; | 1448 | 1.70M | struct external_DOS_hdr dos_hdr; | 1449 | 1.70M | struct external_PEI_IMAGE_hdr image_hdr; | 1450 | 1.70M | struct internal_filehdr internal_f; | 1451 | 1.70M | struct internal_aouthdr internal_a; | 1452 | 1.70M | bfd_size_type opt_hdr_size; | 1453 | 1.70M | file_ptr offset; | 1454 | 1.70M | bfd_cleanup result; | 1455 | | | 1456 | | /* Detect if this a Microsoft Import Library Format element. */ | 1457 | | /* First read the beginning of the header. */ | 1458 | 1.70M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1459 | 1.70M | || bfd_read (buffer, 6, abfd) != 6) | 1460 | 4.79k | { | 1461 | 4.79k | if (bfd_get_error () != bfd_error_system_call) | 1462 | 4.12k | bfd_set_error (bfd_error_wrong_format); | 1463 | 4.79k | return NULL; | 1464 | 4.79k | } | 1465 | | | 1466 | | /* Then check the magic and the version (only 0 is supported). */ | 1467 | 1.69M | if (H_GET_32 (abfd, buffer) == 0xffff0000 | 1468 | 1.69M | && H_GET_16 (abfd, buffer + 4) == 0) | 1469 | 28.1k | return pe_ILF_object_p (abfd); | 1470 | | | 1471 | 1.66M | if (bfd_seek (abfd, 0, SEEK_SET) != 0 | 1472 | 1.66M | || bfd_read (&dos_hdr, sizeof (dos_hdr), abfd) != sizeof (dos_hdr)) | 1473 | 309k | { | 1474 | 309k | if (bfd_get_error () != bfd_error_system_call) | 1475 | 309k | bfd_set_error (bfd_error_wrong_format); | 1476 | 309k | return NULL; | 1477 | 309k | } | 1478 | | | 1479 | | /* There are really two magic numbers involved; the magic number | 1480 | | that says this is a NT executable (PEI) and the magic number that | 1481 | | determines the architecture. The former is IMAGE_DOS_SIGNATURE, stored in | 1482 | | the e_magic field. The latter is stored in the f_magic field. | 1483 | | If the NT magic number isn't valid, the architecture magic number | 1484 | | could be mimicked by some other field (specifically, the number | 1485 | | of relocs in section 3). Since this routine can only be called | 1486 | | correctly for a PEI file, check the e_magic number here, and, if | 1487 | | it doesn't match, clobber the f_magic number so that we don't get | 1488 | | a false match. */ | 1489 | 1.35M | if (H_GET_16 (abfd, dos_hdr.e_magic) != IMAGE_DOS_SIGNATURE) | 1490 | 750k | { | 1491 | 750k | bfd_set_error (bfd_error_wrong_format); | 1492 | 750k | return NULL; | 1493 | 750k | } | 1494 | | | 1495 | 607k | offset = H_GET_32 (abfd, dos_hdr.e_lfanew); | 1496 | 607k | if (bfd_seek (abfd, offset, SEEK_SET) != 0 | 1497 | 607k | || bfd_read (&image_hdr, sizeof (image_hdr), abfd) != sizeof (image_hdr)) | 1498 | 5.75k | { | 1499 | 5.75k | if (bfd_get_error () != bfd_error_system_call) | 1500 | 5.75k | bfd_set_error (bfd_error_wrong_format); | 1501 | 5.75k | return NULL; | 1502 | 5.75k | } | 1503 | | | 1504 | 602k | if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550) | 1505 | 14.7k | { | 1506 | 14.7k | bfd_set_error (bfd_error_wrong_format); | 1507 | 14.7k | return NULL; | 1508 | 14.7k | } | 1509 | | | 1510 | | /* Swap file header, so that we get the location for calling | 1511 | | real_object_p. */ | 1512 | 587k | bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); | 1513 | | | 1514 | 587k | if (! bfd_coff_bad_format_hook (abfd, &internal_f) | 1515 | 587k | || internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) | 1516 | 524k | { | 1517 | 524k | bfd_set_error (bfd_error_wrong_format); | 1518 | 524k | return NULL; | 1519 | 524k | } | 1520 | | | 1521 | 63.3k | memcpy (internal_f.pe.dos_message, dos_hdr.dos_message, | 1522 | 63.3k | sizeof (internal_f.pe.dos_message)); | 1523 | | | 1524 | | /* Read the optional header, which has variable size. */ | 1525 | 63.3k | opt_hdr_size = internal_f.f_opthdr; | 1526 | | | 1527 | 63.3k | if (opt_hdr_size != 0) | 1528 | 45.3k | { | 1529 | 45.3k | bfd_size_type amt = opt_hdr_size; | 1530 | 45.3k | bfd_byte * opthdr; | 1531 | | | 1532 | | /* PR 17521 file: 230-131433-0.004. */ | 1533 | 45.3k | if (amt < sizeof (PEAOUTHDR)) | 1534 | 27.2k | amt = sizeof (PEAOUTHDR); | 1535 | | | 1536 | 45.3k | opthdr = _bfd_alloc_and_read (abfd, amt, opt_hdr_size); | 1537 | 45.3k | if (opthdr == NULL) | 1538 | 2.45k | return NULL; | 1539 | 42.9k | if (amt > opt_hdr_size) | 1540 | 26.5k | memset (opthdr + opt_hdr_size, 0, amt - opt_hdr_size); | 1541 | | | 1542 | 42.9k | bfd_coff_swap_aouthdr_in (abfd, opthdr, &internal_a); | 1543 | | | 1544 | 42.9k | struct internal_extra_pe_aouthdr *a = &internal_a.pe; | 1545 | | | 1546 | | #ifdef ARM | 1547 | | /* Use Subsystem to distinguish between pei-arm-little and | 1548 | | pei-arm-wince-little. */ | 1549 | | #ifdef WINCE | 1550 | | if (a->Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1551 | | #else | 1552 | | if (a->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) | 1553 | | #endif | 1554 | | { | 1555 | | bfd_set_error (bfd_error_wrong_format); | 1556 | | return NULL; | 1557 | | } | 1558 | | #endif | 1559 | | | 1560 | 42.9k | if ((a->SectionAlignment & -a->SectionAlignment) != a->SectionAlignment | 1561 | 42.9k | || a->SectionAlignment >= 0x80000000) | 1562 | 22.0k | { | 1563 | 22.0k | _bfd_error_handler (_("%pB: adjusting invalid SectionAlignment"), | 1564 | 22.0k | abfd); | 1565 | 22.0k | a->SectionAlignment &= -a->SectionAlignment; | 1566 | 22.0k | if (a->SectionAlignment >= 0x80000000) | 1567 | 264 | a->SectionAlignment = 0x40000000; | 1568 | 22.0k | } | 1569 | | | 1570 | 42.9k | if ((a->FileAlignment & -a->FileAlignment) != a->FileAlignment | 1571 | 42.9k | || a->FileAlignment > a->SectionAlignment) | 1572 | 33.1k | { | 1573 | 33.1k | _bfd_error_handler (_("%pB: adjusting invalid FileAlignment"), | 1574 | 33.1k | abfd); | 1575 | 33.1k | a->FileAlignment &= -a->FileAlignment; | 1576 | 33.1k | if (a->FileAlignment > a->SectionAlignment) | 1577 | 20.9k | a->FileAlignment = a->SectionAlignment; | 1578 | 33.1k | } | 1579 | | | 1580 | 42.9k | if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) | 1581 | 29.9k | _bfd_error_handler (_("%pB: invalid NumberOfRvaAndSizes"), abfd); | 1582 | 42.9k | } | 1583 | | | 1584 | 60.8k | result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, | 1585 | 60.8k | (opt_hdr_size != 0 | 1586 | 60.8k | ? &internal_a | 1587 | 60.8k | : (struct internal_aouthdr *) NULL)); | 1588 | | | 1589 | 60.8k | if (result) | 1590 | 31.7k | { | 1591 | | /* Now the whole header has been processed, see if there is a build-id */ | 1592 | 31.7k | pe_bfd_read_buildid(abfd); | 1593 | 31.7k | } | 1594 | | | 1595 | 60.8k | return result; | 1596 | 63.3k | } |
|
1597 | | |
1598 | 571k | #define coff_object_p pe_bfd_object_p |
1599 | | #endif /* COFF_IMAGE_WITH_PE */ |