ld: Move the .note.build-id section to near the start of the memory map.
[binutils-gdb.git] / sim / ppc / ld-cache.c
blob67e60ebbb49267f57c9d9ab75e4ae2614c8ce070
1 /* This file is part of the program psim.
3 Copyright 1994, 1995, 1996, 1997, 2003 Andrew Cagney
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "misc.h"
22 #include "lf.h"
23 #include "table.h"
24 #include "ld-cache.h"
25 #include "dumpf.h"
28 enum {
29 ca_type,
30 ca_field_name,
31 ca_derived_name,
32 ca_type_def,
33 ca_expression,
34 nr_cache_rule_fields,
37 static const name_map cache_type_map[] = {
38 { "cache", cache_value },
39 { "compute", compute_value },
40 { "scratch", scratch_value },
41 { NULL, 0 },
45 void
46 append_cache_rule (cache_table **table, const char *type,
47 const char *field_name, const char *derived_name,
48 const char *type_def, const char *expression,
49 table_entry *file_entry)
51 while ((*table) != NULL)
52 table = &(*table)->next;
53 (*table) = ZALLOC(cache_table);
54 (*table)->type = name2i(type, cache_type_map);
55 (*table)->field_name = field_name;
56 (*table)->derived_name = derived_name;
57 (*table)->type_def = (strlen(type_def) > 0 ? type_def : NULL);
58 (*table)->expression = (strlen(expression) > 0 ? expression : NULL);
59 (*table)->file_entry = file_entry;
60 (*table)->next = NULL;
64 cache_table *
65 load_cache_table(const char *file_name,
66 int hi_bit_nr)
68 table *file = table_open(file_name, nr_cache_rule_fields, 0);
69 table_entry *entry;
70 cache_table *table = NULL;
71 cache_table **curr_rule = &table;
72 while ((entry = table_entry_read(file)) != NULL) {
73 append_cache_rule (curr_rule, entry->fields[ca_type],
74 entry->fields[ca_field_name],
75 entry->fields[ca_derived_name],
76 entry->fields[ca_type_def],
77 entry->fields[ca_expression],
78 entry);
79 curr_rule = &(*curr_rule)->next;
81 return table;
86 #ifdef MAIN
88 static void
89 dump_cache_rule(cache_table* rule,
90 int indent)
92 dumpf(indent, "((cache_table*)%p\n", rule);
93 dumpf(indent, " (type %s)\n", i2name(rule->type, cache_type_map));
94 dumpf(indent, " (field_name \"%s\")\n", rule->field_name);
95 dumpf(indent, " (derived_name \"%s\")\n", rule->derived_name);
96 dumpf(indent, " (type-def \"%s\")\n", rule->type_def);
97 dumpf(indent, " (expression \"%s\")\n", rule->expression);
98 dumpf(indent, " (next %p)\n", rule->next);
99 dumpf(indent, " )\n");
103 static void
104 dump_cache_rules(cache_table* rule,
105 int indent)
107 while (rule) {
108 dump_cache_rule(rule, indent);
109 rule = rule->next;
115 main(int argc, char **argv)
117 cache_table *rules;
118 if (argc != 3)
119 ERROR("Usage: cache <cache-file> <hi-bit-nr>\n");
120 rules = load_cache_table(argv[1], a2i(argv[2]));
121 dump_cache_rules(rules, 0);
122 return 0;
124 #endif