gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / ld / testplug4.c
CommitLineData
3355cb3b
L
1/* Test plugin for the GNU linker. Check non-object IR file as well as
2 get_input_file, get_view, release_input_file and get_symbols interfaces.
b3adc24a 3 Copyright (C) 2016-2020 Free Software Foundation, Inc.
3355cb3b
L
4
5 This file is part of the GNU Binutils.
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#include "sysdep.h"
23#include "bfd.h"
24#include "plugin-api.h"
25#include "filenames.h"
26/* For ARRAY_SIZE macro only - we don't link the library itself. */
27#include "libiberty.h"
28
29extern enum ld_plugin_status onload (struct ld_plugin_tv *tv);
30static enum ld_plugin_status onclaim_file (const struct ld_plugin_input_file *file,
31 int *claimed);
32static enum ld_plugin_status onall_symbols_read (void);
33static enum ld_plugin_status oncleanup (void);
34
35/* Helper for calling plugin api message function. */
36#define TV_MESSAGE if (tv_message) (*tv_message)
37
38/* Struct for recording files to claim / files claimed. */
39typedef struct claim_file
40{
41 struct claim_file *next;
42 struct ld_plugin_input_file file;
43 bfd_boolean claimed;
44 struct ld_plugin_symbol *symbols;
45 int n_syms_allocated;
46 int n_syms_used;
47} claim_file_t;
48
49/* Types of things that can be added at all symbols read time. */
50typedef enum addfile_enum
51{
52 ADD_FILE,
53 ADD_LIB,
54 ADD_DIR
55} addfile_enum_t;
56
57/* Struct for recording files to add to final link. */
58typedef struct add_file
59{
60 struct add_file *next;
61 const char *name;
62 addfile_enum_t type;
63} add_file_t;
64
65/* Helper macro for defining array of transfer vector tags and names. */
66#define ADDENTRY(tag) { tag, #tag }
67
68/* Struct for looking up human-readable versions of tag names. */
69typedef struct tag_name
70{
71 enum ld_plugin_tag tag;
72 const char *name;
73} tag_name_t;
74
75/* Array of all known tags and their names. */
76static const tag_name_t tag_names[] =
77{
78 ADDENTRY(LDPT_NULL),
79 ADDENTRY(LDPT_API_VERSION),
80 ADDENTRY(LDPT_GOLD_VERSION),
81 ADDENTRY(LDPT_LINKER_OUTPUT),
82 ADDENTRY(LDPT_OPTION),
83 ADDENTRY(LDPT_REGISTER_CLAIM_FILE_HOOK),
84 ADDENTRY(LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK),
85 ADDENTRY(LDPT_REGISTER_CLEANUP_HOOK),
86 ADDENTRY(LDPT_ADD_SYMBOLS),
87 ADDENTRY(LDPT_GET_SYMBOLS),
88 ADDENTRY(LDPT_GET_SYMBOLS_V2),
89 ADDENTRY(LDPT_ADD_INPUT_FILE),
90 ADDENTRY(LDPT_MESSAGE),
91 ADDENTRY(LDPT_GET_INPUT_FILE),
92 ADDENTRY(LDPT_GET_VIEW),
93 ADDENTRY(LDPT_RELEASE_INPUT_FILE),
94 ADDENTRY(LDPT_ADD_INPUT_LIBRARY),
95 ADDENTRY(LDPT_OUTPUT_NAME),
96 ADDENTRY(LDPT_SET_EXTRA_LIBRARY_PATH),
97 ADDENTRY(LDPT_GNU_LD_VERSION)
98};
99
100/* Function pointers to cache hooks passed at onload time. */
101static ld_plugin_register_claim_file tv_register_claim_file = 0;
102static ld_plugin_register_all_symbols_read tv_register_all_symbols_read = 0;
103static ld_plugin_register_cleanup tv_register_cleanup = 0;
104static ld_plugin_add_symbols tv_add_symbols = 0;
105static ld_plugin_get_symbols tv_get_symbols = 0;
106static ld_plugin_get_symbols tv_get_symbols_v2 = 0;
107static ld_plugin_add_input_file tv_add_input_file = 0;
108static ld_plugin_message tv_message = 0;
109static ld_plugin_get_input_file tv_get_input_file = 0;
110static ld_plugin_get_view tv_get_view = 0;
111static ld_plugin_release_input_file tv_release_input_file = 0;
112static ld_plugin_add_input_library tv_add_input_library = 0;
113static ld_plugin_set_extra_library_path tv_set_extra_library_path = 0;
114
115/* Other cached info from the transfer vector. */
116static enum ld_plugin_output_file_type linker_output;
117static const char *output_name;
118
119/* Behaviour control flags set by plugin options. */
120static enum ld_plugin_status onload_ret = LDPS_OK;
121static enum ld_plugin_status claim_file_ret = LDPS_OK;
122static enum ld_plugin_status all_symbols_read_ret = LDPS_OK;
123static enum ld_plugin_status cleanup_ret = LDPS_OK;
124static bfd_boolean register_claimfile_hook = TRUE;
125static bfd_boolean register_allsymbolsread_hook = FALSE;
126static bfd_boolean register_cleanup_hook = FALSE;
127static bfd_boolean dumpresolutions = FALSE;
128static bfd_boolean allsymbolsread_silent = FALSE;
129
130/* The master list of all claimable/claimed files. */
131static claim_file_t *claimfiles_list = NULL;
132
133/* We keep a tail pointer for easy linking on the end. */
134static claim_file_t **claimfiles_tail_chain_ptr = &claimfiles_list;
135
136/* The last claimed file added to the list, for receiving syms. */
137static claim_file_t *last_claimfile = NULL;
138
139/* The master list of all files to add to the final link. */
140static add_file_t *addfiles_list = NULL;
141
142/* We keep a tail pointer for easy linking on the end. */
143static add_file_t **addfiles_tail_chain_ptr = &addfiles_list;
144
145/* Add a new claimfile on the end of the chain. */
146static enum ld_plugin_status
147record_claim_file (const char *file, off_t filesize)
148{
149 claim_file_t *newfile;
150
151 newfile = malloc (sizeof *newfile);
152 if (!newfile)
153 return LDPS_ERR;
154 memset (newfile, 0, sizeof *newfile);
155 /* Only setup for now is remembering the name to look for. */
156 newfile->file.name = file;
157 newfile->file.filesize = filesize;
158 /* Chain it on the end of the list. */
159 *claimfiles_tail_chain_ptr = newfile;
160 claimfiles_tail_chain_ptr = &newfile->next;
161 /* Record it as active for receiving symbols to register. */
162 last_claimfile = newfile;
163 return LDPS_OK;
164}
165
166/* Add a new addfile on the end of the chain. */
167static enum ld_plugin_status
168record_add_file (const char *file, addfile_enum_t type)
169{
170 add_file_t *newfile;
171
172 newfile = malloc (sizeof *newfile);
173 if (!newfile)
174 return LDPS_ERR;
175 newfile->next = NULL;
176 newfile->name = file;
177 newfile->type = type;
178 /* Chain it on the end of the list. */
179 *addfiles_tail_chain_ptr = newfile;
180 addfiles_tail_chain_ptr = &newfile->next;
181 return LDPS_OK;
182}
183
184/* Parse a command-line argument string into a symbol definition.
185 Symbol-strings follow the colon-separated format:
186 NAME:VERSION:def:vis:size:COMDATKEY
187 where the fields in capitals are strings and those in lower
188 case are integers. We don't allow to specify a resolution as
189 doing so is not meaningful when calling the add symbols hook. */
190static enum ld_plugin_status
191parse_symdefstr (const char *str, struct ld_plugin_symbol *sym)
192{
193 int n;
194 long long size;
195 const char *colon1, *colon2, *colon5;
196
197 /* Locate the colons separating the first two strings. */
198 colon1 = strchr (str, ':');
199 if (!colon1)
200 return LDPS_ERR;
201 colon2 = strchr (colon1+1, ':');
202 if (!colon2)
203 return LDPS_ERR;
204 /* Name must not be empty (version may be). */
205 if (colon1 == str)
206 return LDPS_ERR;
207
208 /* The fifth colon and trailing comdat key string are optional,
209 but the intermediate ones must all be present. */
210 colon5 = strchr (colon2+1, ':'); /* Actually only third so far. */
211 if (!colon5)
212 return LDPS_ERR;
213 colon5 = strchr (colon5+1, ':'); /* Hopefully fourth now. */
214 if (!colon5)
215 return LDPS_ERR;
216 colon5 = strchr (colon5+1, ':'); /* Optional fifth now. */
217
218 /* Finally we'll use sscanf to parse the numeric fields, then
219 we'll split out the strings which we need to allocate separate
220 storage for anyway so that we can add nul termination. */
c02d6661 221 n = sscanf (colon2 + 1, "%hhi:%i:%lli", &sym->def, &sym->visibility, &size);
3355cb3b
L
222 if (n != 3)
223 return LDPS_ERR;
224
225 /* Parsed successfully, so allocate strings and fill out fields. */
226 sym->size = size;
c02d6661
AM
227 sym->unused = 0;
228 sym->section_kind = 0;
229 sym->symbol_type = 0;
3355cb3b
L
230 sym->resolution = LDPR_UNKNOWN;
231 sym->name = malloc (colon1 - str + 1);
232 if (!sym->name)
233 return LDPS_ERR;
234 memcpy (sym->name, str, colon1 - str);
235 sym->name[colon1 - str] = '\0';
236 if (colon2 > (colon1 + 1))
237 {
238 sym->version = malloc (colon2 - colon1);
239 if (!sym->version)
240 return LDPS_ERR;
241 memcpy (sym->version, colon1 + 1, colon2 - (colon1 + 1));
242 sym->version[colon2 - (colon1 + 1)] = '\0';
243 }
244 else
245 sym->version = NULL;
246 if (colon5 && colon5[1])
247 {
248 sym->comdat_key = malloc (strlen (colon5 + 1) + 1);
249 if (!sym->comdat_key)
250 return LDPS_ERR;
251 strcpy (sym->comdat_key, colon5 + 1);
252 }
253 else
254 sym->comdat_key = 0;
255 return LDPS_OK;
256}
257
258/* Record a symbol to be added for the last-added claimfile. */
259static enum ld_plugin_status
260record_claimed_file_symbol (const char *symdefstr)
261{
262 struct ld_plugin_symbol sym;
263
264 /* Can't add symbols except as belonging to claimed files. */
265 if (!last_claimfile)
266 return LDPS_ERR;
267
268 /* If string doesn't parse correctly, give an error. */
269 if (parse_symdefstr (symdefstr, &sym) != LDPS_OK)
270 return LDPS_ERR;
271
272 /* Check for enough space, resize array if needed, and add it. */
273 if (last_claimfile->n_syms_allocated == last_claimfile->n_syms_used)
274 {
275 int new_n_syms = last_claimfile->n_syms_allocated
276 ? 2 * last_claimfile->n_syms_allocated
277 : 10;
278 last_claimfile->symbols = realloc (last_claimfile->symbols,
279 new_n_syms * sizeof *last_claimfile->symbols);
280 if (!last_claimfile->symbols)
281 return LDPS_ERR;
282 last_claimfile->n_syms_allocated = new_n_syms;
283 }
284 last_claimfile->symbols[last_claimfile->n_syms_used++] = sym;
285
286 return LDPS_OK;
287}
288
289/* Records the status to return from one of the registered hooks. */
290static enum ld_plugin_status
291set_ret_val (const char *whichval, enum ld_plugin_status retval)
292{
293 if (!strcmp ("onload", whichval))
294 onload_ret = retval;
295 else if (!strcmp ("claimfile", whichval))
296 claim_file_ret = retval;
297 else if (!strcmp ("allsymbolsread", whichval))
298 all_symbols_read_ret = retval;
299 else if (!strcmp ("cleanup", whichval))
300 cleanup_ret = retval;
301 else
302 return LDPS_ERR;
303 return LDPS_OK;
304}
305
306/* Records hooks which should be registered. */
307static enum ld_plugin_status
308set_register_hook (const char *whichhook, bfd_boolean yesno)
309{
310 if (!strcmp ("claimfile", whichhook))
311 register_claimfile_hook = yesno;
312 else if (!strcmp ("allsymbolsread", whichhook))
313 register_allsymbolsread_hook = yesno;
314 else if (!strcmp ("allsymbolsreadsilent", whichhook))
315 {
316 register_allsymbolsread_hook = yesno;
317 allsymbolsread_silent = TRUE;
318 }
319 else if (!strcmp ("cleanup", whichhook))
320 register_cleanup_hook = yesno;
321 else
322 return LDPS_ERR;
323 return LDPS_OK;
324}
325
326/* Determine type of plugin option and pass to individual parsers. */
327static enum ld_plugin_status
328parse_option (const char *opt)
329{
330 if (!strncmp ("fatal", opt, 5))
331 {
332 TV_MESSAGE (LDPL_FATAL, "Fatal error");
333 fflush (NULL);
334 }
335 else if (!strncmp ("error", opt, 5))
336 {
337 TV_MESSAGE (LDPL_ERROR, "Error");
338 fflush (NULL);
339 }
340 else if (!strncmp ("warning", opt, 7))
341 {
342 TV_MESSAGE (LDPL_WARNING, "Warning");
343 fflush (NULL);
344 }
345 else if (!strncmp ("fail", opt, 4))
346 return set_ret_val (opt + 4, LDPS_ERR);
347 else if (!strncmp ("pass", opt, 4))
348 return set_ret_val (opt + 4, LDPS_OK);
349 else if (!strncmp ("register", opt, 8))
350 return set_register_hook (opt + 8, TRUE);
351 else if (!strncmp ("noregister", opt, 10))
352 return set_register_hook (opt + 10, FALSE);
353 else if (!strncmp ("claim:", opt, 6))
354 return record_claim_file (opt + 6, 0);
355 else if (!strncmp ("sym:", opt, 4))
356 return record_claimed_file_symbol (opt + 4);
357 else if (!strncmp ("add:", opt, 4))
358 return record_add_file (opt + 4, ADD_FILE);
359 else if (!strncmp ("lib:", opt, 4))
360 return record_add_file (opt + 4, ADD_LIB);
361 else if (!strncmp ("dir:", opt, 4))
362 return record_add_file (opt + 4, ADD_DIR);
363 else if (!strcmp ("dumpresolutions", opt))
364 dumpresolutions = TRUE;
365 else
366 return LDPS_ERR;
367 return LDPS_OK;
368}
369
370/* Handle/record information received in a transfer vector entry. */
371static enum ld_plugin_status
372parse_tv_tag (struct ld_plugin_tv *tv)
373{
374#define SETVAR(x) x = tv->tv_u.x
375 switch (tv->tv_tag)
376 {
377 case LDPT_OPTION:
378 return parse_option (tv->tv_u.tv_string);
379 case LDPT_NULL:
380 case LDPT_GOLD_VERSION:
381 case LDPT_GNU_LD_VERSION:
382 case LDPT_API_VERSION:
383 default:
384 break;
385 case LDPT_OUTPUT_NAME:
386 output_name = tv->tv_u.tv_string;
387 break;
388 case LDPT_LINKER_OUTPUT:
389 linker_output = tv->tv_u.tv_val;
390 break;
391 case LDPT_REGISTER_CLAIM_FILE_HOOK:
392 SETVAR(tv_register_claim_file);
393 break;
394 case LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK:
395 SETVAR(tv_register_all_symbols_read);
396 break;
397 case LDPT_REGISTER_CLEANUP_HOOK:
398 SETVAR(tv_register_cleanup);
399 break;
400 case LDPT_ADD_SYMBOLS:
401 SETVAR(tv_add_symbols);
402 break;
403 case LDPT_GET_SYMBOLS:
404 SETVAR(tv_get_symbols);
405 break;
406 case LDPT_GET_SYMBOLS_V2:
407 tv_get_symbols_v2 = tv->tv_u.tv_get_symbols;
408 break;
409 case LDPT_ADD_INPUT_FILE:
410 SETVAR(tv_add_input_file);
411 break;
412 case LDPT_MESSAGE:
413 SETVAR(tv_message);
414 break;
415 case LDPT_GET_INPUT_FILE:
416 SETVAR(tv_get_input_file);
417 break;
418 case LDPT_GET_VIEW:
419 SETVAR(tv_get_view);
420 break;
421 case LDPT_RELEASE_INPUT_FILE:
422 SETVAR(tv_release_input_file);
423 break;
424 case LDPT_ADD_INPUT_LIBRARY:
425 SETVAR(tv_add_input_library);
426 break;
427 case LDPT_SET_EXTRA_LIBRARY_PATH:
428 SETVAR(tv_set_extra_library_path);
429 break;
430 }
431#undef SETVAR
432 return LDPS_OK;
433}
434
435/* Standard plugin API entry point. */
436enum ld_plugin_status
437onload (struct ld_plugin_tv *tv)
438{
439 enum ld_plugin_status rv;
440
441 /* This plugin does nothing but dump the tv array. It would
442 be an error if this function was called without one. */
443 if (!tv)
444 return LDPS_ERR;
445
446 /* First entry should always be LDPT_MESSAGE, letting us get
447 hold of it easily so we can send output straight away. */
448 if (tv[0].tv_tag == LDPT_MESSAGE)
449 tv_message = tv[0].tv_u.tv_message;
450
451 do
452 if ((rv = parse_tv_tag (tv)) != LDPS_OK)
453 return rv;
454 while ((tv++)->tv_tag != LDPT_NULL);
455
456 /* Register hooks only if instructed by options. */
457 if (register_claimfile_hook)
458 {
459 if (!tv_register_claim_file)
460 {
461 TV_MESSAGE (LDPL_FATAL, "No register_claim_file hook");
462 fflush (NULL);
463 return LDPS_ERR;
464 }
465 (*tv_register_claim_file) (onclaim_file);
466 }
467 if (register_allsymbolsread_hook)
468 {
469 if (!tv_register_all_symbols_read)
470 {
471 TV_MESSAGE (LDPL_FATAL, "No register_all_symbols_read hook");
472 fflush (NULL);
473 return LDPS_ERR;
474 }
475 (*tv_register_all_symbols_read) (onall_symbols_read);
476 }
477 if (register_cleanup_hook)
478 {
479 if (!tv_register_cleanup)
480 {
481 TV_MESSAGE (LDPL_FATAL, "No register_cleanup hook");
482 fflush (NULL);
483 return LDPS_ERR;
484 }
485 (*tv_register_cleanup) (oncleanup);
486 }
487
488 /* Claim testsuite/ld-plugin/pr20070b.c, standalone or in a library.
489 Its size must be SIZE_OF_PR20070B_C bytes. */
490#define SIZE_OF_PR20070B_C 248
491 if (onload_ret == LDPS_OK
492 && (record_claim_file ("pr20070b.c", SIZE_OF_PR20070B_C) != LDPS_OK
493 || record_claimed_file_symbol ("def::0:0:0") != LDPS_OK
494 || record_claimed_file_symbol ("weakdef::1:0:0") != LDPS_OK
495 || record_claimed_file_symbol ("undef::2:0:0") != LDPS_OK
496 || record_claimed_file_symbol ("weakundef::3:0:0") != LDPS_OK
497 || record_claimed_file_symbol ("common::4:0:0") != LDPS_OK
498 || record_claim_file ("libpr20070.a", SIZE_OF_PR20070B_C) != LDPS_OK
499 || record_claimed_file_symbol ("def::0:0:0") != LDPS_OK
500 || record_claimed_file_symbol ("weakdef::1:0:0") != LDPS_OK
501 || record_claimed_file_symbol ("undef::2:0:0") != LDPS_OK
502 || record_claimed_file_symbol ("weakundef::3:0:0") != LDPS_OK
503 || record_claimed_file_symbol ("common::4:0:0") != LDPS_OK))
504 onload_ret = LDPS_ERR;
505
506 return onload_ret;
507}
508
509char *
510xstrdup (const char *s)
511{
512 size_t len = strlen (s) + 1;
513 char *ret = malloc (len + 1);
514 return (char *) memcpy (ret, s, len);
515}
516
517/* Standard plugin API registerable hook. */
518static enum ld_plugin_status
519onclaim_file (const struct ld_plugin_input_file *file, int *claimed)
520{
521 /* Let's see if we want to claim this file. */
522 claim_file_t *claimfile = claimfiles_list;
523 size_t len = strlen (file->name);
524 char *name = xstrdup (file->name);
525 char *p = name + len;
526 bfd_boolean islib;
527
528 /* Only match the file name without the directory part. */
529 islib = *p == 'a' && *(p - 1) == '.';
530 for (; p != name; p--)
531 if (IS_DIR_SEPARATOR (*p))
532 {
533 p++;
534 break;
535 }
536
537 while (claimfile)
538 {
539 /* Claim the file only if the file name and size match and don't
540 match the whole library. */
541 if (!strcmp (p, claimfile->file.name)
542 && claimfile->file.filesize == file->filesize
543 && (!islib || file->offset != 0))
544 break;
545 claimfile = claimfile->next;
546 }
547
548 free (name);
549
550 /* If we decided to claim it, record that fact, and add any symbols
551 that were defined for it by plugin options. */
552 *claimed = (claimfile != 0);
553 if (claimfile)
554 {
555 claimfile->claimed = TRUE;
556 claimfile->file = *file;
557 if (claimfile->n_syms_used && !tv_add_symbols)
558 return LDPS_ERR;
559 else if (claimfile->n_syms_used)
560 return (*tv_add_symbols) (claimfile->file.handle,
561 claimfile->n_syms_used, claimfile->symbols);
562 }
563
564 return claim_file_ret;
565}
566
567/* Standard plugin API registerable hook. */
568static enum ld_plugin_status
569onall_symbols_read (void)
570{
571 static const char *resolutions[] =
572 {
573 "LDPR_UNKNOWN",
574 "LDPR_UNDEF",
575 "LDPR_PREVAILING_DEF",
576 "LDPR_PREVAILING_DEF_IRONLY",
577 "LDPR_PREEMPTED_REG",
578 "LDPR_PREEMPTED_IR",
579 "LDPR_RESOLVED_IR",
580 "LDPR_RESOLVED_EXEC",
581 "LDPR_RESOLVED_DYN",
582 "LDPR_PREVAILING_DEF_IRONLY_EXP",
583 };
584 claim_file_t *claimfile = dumpresolutions ? claimfiles_list : NULL;
585 add_file_t *addfile = addfiles_list;
586 struct ld_plugin_input_file file;
587 const void *view;
588 char buffer[30];
589 int fd;
590 char *filename;
591 if (! allsymbolsread_silent)
592 TV_MESSAGE (LDPL_INFO, "hook called: all symbols read.");
593 for ( ; claimfile; claimfile = claimfile->next)
594 {
595 enum ld_plugin_status rv;
596 int n;
597 if (claimfile->n_syms_used && !tv_get_symbols_v2)
598 return LDPS_ERR;
599 else if (!claimfile->n_syms_used)
600 continue;
601 else if (!claimfile->file.handle)
602 continue;
603 rv = tv_get_input_file (claimfile->file.handle, &file);
604 if (rv != LDPS_OK)
605 return rv;
606 TV_MESSAGE (LDPL_INFO, "Input: %s (%s)", file.name,
607 claimfile->file.name);
608 rv = tv_get_view (claimfile->file.handle, &view);
609 if (rv != LDPS_OK)
610 return rv;
611#define EXPECTED_VIEW "/* The first line of this file must match the expectation of"
612#define EXPECTED_VIEW_LENGTH (sizeof (EXPECTED_VIEW) - 1)
613 if (file.filesize != SIZE_OF_PR20070B_C
bf6f87e7 614 || SIZE_OF_PR20070B_C < EXPECTED_VIEW_LENGTH
3355cb3b
L
615 || memcmp (view, EXPECTED_VIEW, EXPECTED_VIEW_LENGTH) != 0)
616 {
617 char result[EXPECTED_VIEW_LENGTH + 1];
618 memcpy (result, view, sizeof (result));
619 result[EXPECTED_VIEW_LENGTH] = '\0';
620 TV_MESSAGE (LDPL_INFO, "Incorrect view:");
621 TV_MESSAGE (LDPL_INFO, " Expect: " EXPECTED_VIEW);
622 TV_MESSAGE (LDPL_INFO, " Result: %s", result);
623 }
624 rv = tv_get_symbols_v2 (claimfile->file.handle, claimfile->n_syms_used,
625 claimfile->symbols);
626 if (rv != LDPS_OK)
627 return rv;
628 for (n = 0; n < claimfile->n_syms_used; n++)
629 TV_MESSAGE (LDPL_INFO, "Sym: '%s%s%s' Resolution: %s",
630 claimfile->symbols[n].name,
631 claimfile->symbols[n].version ? "@" : "",
632 (claimfile->symbols[n].version
633 ? claimfile->symbols[n].version : ""),
634 resolutions[claimfile->symbols[n].resolution]);
635 fd = claimfile->file.fd;
636 filename = xstrdup (claimfile->file.name);
637 rv = tv_release_input_file (claimfile->file.handle);
638 if (rv != LDPS_OK)
639 {
640 free (filename);
641 return rv;
642 }
643 if (read (fd, buffer, sizeof (buffer)) >= 0)
644 {
645 TV_MESSAGE (LDPL_FATAL, "Unreleased file descriptor on: %s",
646 claimfile->file.name);
647 free (filename);
648 return LDPS_ERR;
649 }
650 free (filename);
651 }
652 for ( ; addfile ; addfile = addfile->next)
653 {
654 enum ld_plugin_status rv;
655 if (addfile->type == ADD_LIB && tv_add_input_library)
656 rv = (*tv_add_input_library) (addfile->name);
657 else if (addfile->type == ADD_FILE && tv_add_input_file)
658 rv = (*tv_add_input_file) (addfile->name);
659 else if (addfile->type == ADD_DIR && tv_set_extra_library_path)
660 rv = (*tv_set_extra_library_path) (addfile->name);
661 else
662 rv = LDPS_ERR;
663 if (rv != LDPS_OK)
664 return rv;
665 }
666 fflush (NULL);
667 return all_symbols_read_ret;
668}
669
670/* Standard plugin API registerable hook. */
671static enum ld_plugin_status
672oncleanup (void)
673{
674 TV_MESSAGE (LDPL_INFO, "hook called: cleanup.");
675 fflush (NULL);
676 return cleanup_ret;
677}
This page took 0.230991 seconds and 4 git commands to generate.