{
/* Only append to table if not already appended */
elf_symtab_entry *entry = yasm_symrec_get_data(sym, &elf_symrec_data);
- if (!entry) {
- elf_strtab_entry *name = elf_strtab_append_str(objfmt_elf->strtab,
- yasm_symrec_get_name(sym));
- entry = elf_symtab_entry_create(name, sym);
+ if (!entry || !elf_sym_in_table(entry)) {
+ if (!entry) {
+ elf_strtab_entry *name =
+ elf_strtab_append_str(objfmt_elf->strtab,
+ yasm_symrec_get_name(sym));
+ entry = elf_symtab_entry_create(name, sym);
+ }
elf_symtab_append_entry(objfmt_elf->elf_symtab, entry);
+ yasm_symrec_add_data(sym, &elf_symrec_data, entry);
}
elf_symtab_set_nonzero(entry, NULL, sectidx, bind, type, size, value);
elf_sym_set_visibility(entry, vis);
- yasm_symrec_add_data(sym, &elf_symrec_data, entry);
return entry;
}
assert(info != NULL);
- if (!yasm_symrec_get_data(sym, &elf_symrec_data)) {
+ if (!yasm_symrec_get_label(sym, &precbc))
+ return 1;
+ sect = yasm_bc_get_section(precbc);
+
+ entry = yasm_symrec_get_data(sym, &elf_symrec_data);
+ if (!entry || !elf_sym_in_table(entry)) {
int is_sect = 0;
- if (!yasm_symrec_get_label(sym, &precbc))
- return 1;
- sect = yasm_bc_get_section(precbc);
if (!yasm_section_is_absolute(sect) &&
strcmp(yasm_symrec_get_name(sym), yasm_section_get_name(sect))==0)
is_sect = 1;
/* neither sections nor locals (except when debugging) need names */
- entry = elf_symtab_insert_local_sym(info->objfmt_elf->elf_symtab,
- info->local_names && !is_sect ?
- info->objfmt_elf->strtab : NULL, sym);
+ if (!entry) {
+ elf_strtab_entry *name = info->local_names && !is_sect
+ ? elf_strtab_append_str(info->objfmt_elf->strtab,
+ yasm_symrec_get_name(sym))
+ : NULL;
+ entry = elf_symtab_entry_create(name, sym);
+ }
+ elf_symtab_insert_local_sym(info->objfmt_elf->elf_symtab, entry);
elf_symtab_set_nonzero(entry, sect, 0, STB_LOCAL,
is_sect ? STT_SECTION : 0, NULL, 0);
yasm_symrec_add_data(sym, &elf_symrec_data, entry);
if (is_sect)
return 1;
}
- else {
- if (!yasm_symrec_get_label(sym, &precbc))
- return 1;
- sect = yasm_bc_get_section(precbc);
- }
- entry = yasm_symrec_get_data(sym, &elf_symrec_data);
if (precbc)
value = precbc->offset + precbc->len;
elf_symtab_set_nonzero(entry, sect, 0, 0, 0, NULL, value);
if (!entry) {
entry = elf_symtab_entry_create(
elf_strtab_append_str(objfmt_elf->strtab, symname), sym);
- elf_symtab_append_entry(objfmt_elf->elf_symtab, entry);
yasm_symrec_add_data(sym, &elf_symrec_data, entry);
}
if (!entry) {
entry = elf_symtab_entry_create(
elf_strtab_append_str(objfmt_elf->strtab, symname), sym);
- elf_symtab_append_entry(objfmt_elf->elf_symtab, entry);
yasm_symrec_add_data(sym, &elf_symrec_data, entry);
}
yasm_symrec *sym)
{
elf_symtab_entry *entry = yasm_xmalloc(sizeof(elf_symtab_entry));
+ entry->in_table = 0;
entry->sym = sym;
entry->sect = NULL;
entry->name = name;
elf_symtab_entry *entry = yasm_xmalloc(sizeof(elf_symtab_entry));
STAILQ_INIT(symtab);
+ entry->in_table = 1;
entry->sym = NULL;
entry->sect = NULL;
entry->name = NULL;
entry->xsize = NULL;
entry->size = 0;
entry->index = SHN_UNDEF;
- entry->bind = 0;
+ entry->bind = STB_LOCAL;
entry->type = STT_NOTYPE;
entry->vis = STV_DEFAULT;
entry->symindex = 0;
return symtab;
}
-elf_symtab_entry *
+void
elf_symtab_append_entry(elf_symtab_head *symtab, elf_symtab_entry *entry)
{
if (symtab == NULL)
yasm_internal_error(N_("symtab is missing initial dummy entry"));
STAILQ_INSERT_TAIL(symtab, entry, qlink);
- return entry;
+ entry->in_table = 1;
}
-elf_symtab_entry *
-elf_symtab_insert_local_sym(elf_symtab_head *symtab,
- elf_strtab_head *strtab,
- yasm_symrec *sym)
-{
- elf_strtab_entry *name = strtab
- ? elf_strtab_append_str(strtab, yasm_symrec_get_name(sym))
- : NULL;
- elf_symtab_entry *entry = elf_symtab_entry_create(name, sym);
+void
+elf_symtab_insert_local_sym(elf_symtab_head *symtab, elf_symtab_entry *entry)
+{
elf_symtab_entry *after = STAILQ_FIRST(symtab);
elf_symtab_entry *before = NULL;
after = STAILQ_NEXT(after, qlink);
}
STAILQ_INSERT_AFTER(symtab, before, entry, qlink);
-
- return entry;
+ entry->in_table = 1;
}
void
entry->xsize = size;
}
+int
+elf_sym_in_table(elf_symtab_entry *entry)
+{
+ return entry->in_table;
+}
+
elf_secthead *
elf_secthead_create(elf_strtab_entry *name,
elf_section_type type,
STAILQ_HEAD(elf_symtab_head, elf_symtab_entry);
struct elf_symtab_entry {
STAILQ_ENTRY(elf_symtab_entry) qlink;
+ int in_table;
yasm_symrec *sym;
yasm_section *sect;
elf_strtab_entry *name;
elf_symtab_entry *elf_symtab_entry_create(elf_strtab_entry *name,
struct yasm_symrec *sym);
elf_symtab_head *elf_symtab_create(void);
-elf_symtab_entry *elf_symtab_append_entry(elf_symtab_head *symtab,
- elf_symtab_entry *entry);
-elf_symtab_entry *elf_symtab_insert_local_sym(elf_symtab_head *symtab,
- elf_strtab_head *strtab,
- struct yasm_symrec *sym);
+void elf_symtab_append_entry(elf_symtab_head *symtab, elf_symtab_entry *entry);
+void elf_symtab_insert_local_sym(elf_symtab_head *symtab,
+ elf_symtab_entry *entry);
void elf_symtab_destroy(elf_symtab_head *head);
unsigned long elf_symtab_assign_indices(elf_symtab_head *symtab);
unsigned long elf_symtab_write_to_file(FILE *f, elf_symtab_head *symtab);
elf_symbol_vis vis);
void elf_sym_set_type(elf_symtab_entry *entry, elf_symbol_type type);
void elf_sym_set_size(elf_symtab_entry *entry, struct yasm_expr *size);
+int elf_sym_in_table(elf_symtab_entry *entry);
/* section header functions */
elf_secthead *elf_secthead_create(elf_strtab_entry *name,