]> git.pld-linux.org Git - packages/binutils.git/blame - pr-17422.patch
- x32 rebuild
[packages/binutils.git] / pr-17422.patch
CommitLineData
b31a0c51
JR
1From e44f5bef12a54b9c1cc24a5783dedde6f158ad15 Mon Sep 17 00:00:00 2001
2From: Markus Trippelsdorf <markus@trippelsdorf.de>
3Date: Wed, 24 Sep 2014 18:04:53 +0930
4Subject: [PATCH] BFD: Add support for more than one plugin in lib/bfd-plugins
5
6ar, nm and ranlib currently lack the ability to handle more than one
7plugin in lib/bfd-plugins. This patch reshuffles the logic in plugin.c
8to add this functionality. One can now place both llvm and gcc plugins
9in this directory and have them loaded automatically.
10Mixed gcc/llvm archives are also supported (but not very useful until
11ld.bfd and ld.gold also would load multiple plugins and use them to
12claim different object files).
13
14 PR 17422
15 * plugin.c (try_claim): New function. Moved from
16 bfd_plugin_object_p.
17 (try_load_plugin): Pass through bfd. Add test.
18 (load_plugin): Pass through bfd.
19 (bfd_plugin_object_p): Move logic to try_claim.
20---
21 bfd/ChangeLog | 9 +++++
22 bfd/plugin.c | 106 +++++++++++++++++++++++++++++----------------------------
23 2 files changed, 63 insertions(+), 52 deletions(-)
24
25diff --git a/bfd/ChangeLog b/bfd/ChangeLog
26index d8559ea..f70cad6 100644
27--- a/bfd/ChangeLog
28+++ b/bfd/ChangeLog
29@@ -1,3 +1,12 @@
30+2014-09-24 Markus Trippelsdorf <markus@trippelsdorf.de>
31+
32+ PR 17422
33+ * plugin.c (try_claim): New function. Moved from
34+ bfd_plugin_object_p.
35+ (try_load_plugin): Pass through bfd. Add test.
36+ (load_plugin): Pass through bfd.
37+ (bfd_plugin_object_p): Move logic to try_claim.
38+
39 2014-09-23 Sterling Augustine <augustine.sterling@gmail.com>
40
41 * elf32-xtensa.c (is_resolvable_asm_expansion): for cross-section
42diff --git a/bfd/plugin.c b/bfd/plugin.c
43index c9d53c8..d336b67 100644
44--- a/bfd/plugin.c
45+++ b/bfd/plugin.c
46@@ -156,9 +156,54 @@ bfd_plugin_set_program_name (const char *program_name)
47 }
48
49 static int
50-try_load_plugin (const char *pname)
51+try_claim (bfd *abfd)
52 {
53- static void *plugin_handle;
54+ int claimed = 0;
55+ struct ld_plugin_input_file file;
56+ bfd *iobfd;
57+
58+ file.name = abfd->filename;
59+
60+ if (abfd->my_archive)
61+ {
62+ iobfd = abfd->my_archive;
63+ file.offset = abfd->origin;
64+ file.filesize = arelt_size (abfd);
65+ }
66+ else
67+ {
68+ iobfd = abfd;
69+ file.offset = 0;
70+ file.filesize = 0;
71+ }
72+
73+ if (!iobfd->iostream && !bfd_open_file (iobfd))
74+ return 0;
75+
76+ file.fd = fileno ((FILE *) iobfd->iostream);
77+
78+ if (!abfd->my_archive)
79+ {
80+ struct stat stat_buf;
81+ if (fstat (file.fd, &stat_buf))
82+ return 0;
83+ file.filesize = stat_buf.st_size;
84+ }
85+
86+ file.handle = abfd;
87+ off_t cur_offset = lseek(file.fd, 0, SEEK_CUR);
88+ claim_file (&file, &claimed);
89+ lseek(file.fd, cur_offset, SEEK_SET);
90+ if (!claimed)
91+ return 0;
92+
93+ return 1;
94+}
95+
96+static int
97+try_load_plugin (const char *pname, bfd *abfd)
98+{
99+ void *plugin_handle;
100 int tv_size = 4;
101 struct ld_plugin_tv tv[tv_size];
102 int i;
103@@ -200,6 +245,9 @@ try_load_plugin (const char *pname)
104 if (!claim_file)
105 goto err;
106
107+ if (!try_claim (abfd))
108+ goto err;
109+
110 return 1;
111
112 err:
113@@ -216,7 +264,7 @@ bfd_plugin_set_plugin (const char *p)
114 }
115
116 static int
117-load_plugin (void)
118+load_plugin (bfd *abfd)
119 {
120 char *plugin_dir;
121 char *p;
122@@ -225,7 +273,7 @@ load_plugin (void)
123 int found = 0;
124
125 if (plugin_name)
126- return try_load_plugin (plugin_name);
127+ return try_load_plugin (plugin_name, abfd);
128
129 if (plugin_program_name == NULL)
130 return 0;
131@@ -248,7 +296,7 @@ load_plugin (void)
132
133 full_name = concat (p, "/", ent->d_name, NULL);
134 if (stat(full_name, &s) == 0 && S_ISREG (s.st_mode))
135- found = try_load_plugin (full_name);
136+ found = try_load_plugin (full_name, abfd);
137 free (full_name);
138 if (found)
139 break;
140@@ -266,53 +314,7 @@ load_plugin (void)
141 static const bfd_target *
142 bfd_plugin_object_p (bfd *abfd)
143 {
144- int claimed = 0;
145- struct ld_plugin_input_file file;
146- bfd *iobfd;
147- static int have_loaded = 0;
148- static int have_plugin = 0;
149-
150- if (!have_loaded)
151- {
152- have_loaded = 1;
153- have_plugin = load_plugin ();
154- }
155- if (!have_plugin)
156- return NULL;
157-
158- file.name = abfd->filename;
159-
160- if (abfd->my_archive)
161- {
162- iobfd = abfd->my_archive;
163- file.offset = abfd->origin;
164- file.filesize = arelt_size (abfd);
165- }
166- else
167- {
168- iobfd = abfd;
169- file.offset = 0;
170- file.filesize = 0;
171- }
172-
173- if (!iobfd->iostream && !bfd_open_file (iobfd))
174- return NULL;
175-
176- file.fd = fileno ((FILE *) iobfd->iostream);
177-
178- if (!abfd->my_archive)
179- {
180- struct stat stat_buf;
181- if (fstat (file.fd, &stat_buf))
182- return NULL;
183- file.filesize = stat_buf.st_size;
184- }
185-
186- file.handle = abfd;
187- off_t cur_offset = lseek(file.fd, 0, SEEK_CUR);
188- claim_file (&file, &claimed);
189- lseek(file.fd, cur_offset, SEEK_SET);
190- if (!claimed)
191+ if (!load_plugin (abfd))
192 return NULL;
193
194 return abfd->xvec;
195--
1961.7.1
197
This page took 0.049786 seconds and 4 git commands to generate.