summaryrefslogtreecommitdiff
path: root/lto-plugin/lto-plugin.h
blob: 09eb85003a7b5d14606c48af360c59c9d3a71065 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* Common declarations for LTO plugin for gold and/or GNU ld.
   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
   Contributed by Rafael Avila de Espindola (espindola@google.com).

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.  */

#include <stdbool.h>
#include "plugin-api.h"

/* LTO magic section name.  */

#define LTO_SECTION_PREFIX ".gnu.lto_.symtab"

/* The part of the symbol table the plugin has to keep track of. Note that we
   must keep SYMS until all_symbols_read is called to give the linker time to
   copy the symbol information. */

struct sym_aux
{
  uint32_t slot;
  unsigned id;
  unsigned next_conflict;
};

struct plugin_symtab
{
  int nsyms;
  struct sym_aux *aux;
  struct ld_plugin_symbol *syms;
  unsigned id;
};

/* All that we have to remember about a file. */

struct plugin_file_info
{
  char *name;
  void *handle;
  struct plugin_symtab symtab;
  struct plugin_symtab conflicts;
};

/* These are the methods supplied by one of the object format
   dependent files lto-plugin-elf.c or lto-plugin-coff.c  */

extern enum ld_plugin_status claim_file_handler 
		(const struct ld_plugin_input_file *file, int *claimed);

extern enum ld_plugin_status onload_format_checks (struct ld_plugin_tv *tv);

/* These methods are made available to the object format
   dependent files.  */

extern void check (bool gate, enum ld_plugin_level level, const char *text);

extern void translate (char *data, char *end, struct plugin_symtab *out);

extern char *parse_table_entry (char *p, struct ld_plugin_symbol *entry,
			struct sym_aux *aux);

extern void resolve_conflicts (struct plugin_symtab *t,
			struct plugin_symtab *conflicts);

/* And this callback function is exposed.  */

extern ld_plugin_add_symbols add_symbols;

/* Along with these two variables.  */

extern struct plugin_file_info *claimed_files;
extern unsigned int num_claimed_files;