file->offset = offset;
}
-/* Returns a hash code for P. */
-
-static hashval_t
-hash_name (const void *p)
-{
- const struct lto_section_slot *ds = (const struct lto_section_slot *) p;
- return (hashval_t) htab_hash_string (ds->name);
-}
-
-/* Returns nonzero if P1 and P2 are equal. */
-
-static int
-eq_name (const void *p1, const void *p2)
-{
- const struct lto_section_slot *s1 =
- (const struct lto_section_slot *) p1;
- const struct lto_section_slot *s2 =
- (const struct lto_section_slot *) p2;
-
- return strcmp (s1->name, s2->name) == 0;
-}
-
-
/* Build a hash table whose key is the section names and whose data is
the start and size of each section in the .o file. */
ssize_t strtab_size;
char *strtab;
- section_hash_table = htab_create (37, hash_name, eq_name, free);
+ section_hash_table = lto_obj_create_section_hash_table ();
/* Seek to start of string table. */
if (coff_file->strtab_offs != lseek (coff_file->fd,
free (shdr);
}
-
-/* Returns a hash code for P. */
-
-static hashval_t
-hash_name (const void *p)
-{
- const struct lto_section_slot *ds = (const struct lto_section_slot *) p;
- return (hashval_t) htab_hash_string (ds->name);
-}
-
-
-/* Returns nonzero if P1 and P2 are equal. */
-
-static int
-eq_name (const void *p1, const void *p2)
-{
- const struct lto_section_slot *s1 =
- (const struct lto_section_slot *) p1;
- const struct lto_section_slot *s2 =
- (const struct lto_section_slot *) p2;
-
- return strcmp (s1->name, s2->name) == 0;
-}
-
-
/* Build a hash table whose key is the section names and whose data is
the start and size of each section in the .o file. */
Elf_Scn *section;
size_t base_offset;
- section_hash_table = htab_create (37, hash_name, eq_name, free);
+ section_hash_table = lto_obj_create_section_hash_table ();
base_offset = elf_getbase (elf_file->elf);
/* We are reasonably sure that elf_getbase does not fail at this
file->offset = offset;
}
-/* Returns a hash code for P. */
-
-static hashval_t
-hash_name (const void *p)
-{
- const struct lto_section_slot *s = (const struct lto_section_slot *) p;
- return (hashval_t) htab_hash_string (s->name);
-}
-
-/* Returns nonzero if P1 and P2 are equal. */
-
-static int
-eq_name (const void *p1, const void *p2)
-{
- const struct lto_section_slot *s1 =
- (const struct lto_section_slot *) p1;
- const struct lto_section_slot *s2 =
- (const struct lto_section_slot *) p2;
-
- return strcmp (s1->name, s2->name) == 0;
-}
-
/* Build a hash table whose key is the section names and whose data is
the start and size of each section in the .o file. */
char *strtab = NULL;
int i;
- section_hash_table = htab_create (37, hash_name, eq_name, free);
+ section_hash_table = lto_obj_create_section_hash_table ();
/* Seek the string table. */
/* FIXME The segment name should be in darwin.h, but can we include it
static GTY(()) tree first_personality_decl;
+/* Returns a hash code for P. */
+
+static hashval_t
+hash_name (const void *p)
+{
+ const struct lto_section_slot *ds = (const struct lto_section_slot *) p;
+ return (hashval_t) htab_hash_string (ds->name);
+}
+
+
+/* Returns nonzero if P1 and P2 are equal. */
+
+static int
+eq_name (const void *p1, const void *p2)
+{
+ const struct lto_section_slot *s1 =
+ (const struct lto_section_slot *) p1;
+ const struct lto_section_slot *s2 =
+ (const struct lto_section_slot *) p2;
+
+ return strcmp (s1->name, s2->name) == 0;
+}
+
+/* Free lto_section_slot */
+
+static void
+free_with_string (void *arg)
+{
+ struct lto_section_slot *s = (struct lto_section_slot *)arg;
+
+ free (CONST_CAST (char *, s->name));
+ free (arg);
+}
+
+/* Create section hash table */
+
+htab_t
+lto_obj_create_section_hash_table (void)
+{
+ return htab_create (37, hash_name, eq_name, free_with_string);
+}
/* Read the constructors and inits. */
extern lto_file *lto_obj_file_open (const char *filename, bool writable);
extern void lto_obj_file_close (lto_file *file);
extern htab_t lto_obj_build_section_table (lto_file *file);
+extern htab_t lto_obj_create_section_hash_table (void);
extern void lto_obj_begin_section (const char *name);
extern void lto_obj_append_data (const void *data, size_t len, void *block);
extern void lto_obj_end_section (void);