<elf_backend_link_output_symbol_hook>): Return an int.
* elf64-ppc.c (ppc64_elf_output_symbol_hook): Return 2 to drop
symbols on deleted .opd entries.
* elflink.c (elf_link_output_sym): Return without outputting sym
if output_symbol_hook returns 2.
(elf_link_output_extsym): Don't assign h->indx when symbol discarded.
Abort if we must not discard sym.
(elf_link_input_bfd): Similarly, don't set finfo->indices for
local syms.
(bfd_elf_final_link): Adjust elf_link_output_sym calls.
* elf-vxworks.c (elf_vxworks_link_output_symbol_hook): Adjust for
elf_backend_link_output_symbol_hook return type change.
* elf32-arm.c (output_arch_syminfo): Likewise.
(elf32_arm_output_map_sym, elf32_arm_output_stub_sym): Likewise.
(elf32_arm_output_arch_local_syms): Likewise.
* elf32-cr16c.c (elf32_cr16c_link_output_symbol_hook): Likewise.
* elf32-score.c (s3_bfd_score_elf_link_output_symbol_hook): Likewise.
(bfd_score_elf_link_output_symbol_hook): Likewise.
* elf32-score.h (s7_bfd_score_elf_link_output_symbol_hook): Likewise.
* elf32-score7.c (s7_bfd_score_elf_link_output_symbol_hook): Likewise.
* elf32-sh64.c (sh64_elf_link_output_symbol_hook): Likewise.
* elf32-spu.c (spu_elf_output_symbol_hook): Likewise.
* elf32-v850.c (v850_elf_link_output_symbol_hook): Likewise.
* elf64-hppa.c (elf64_hppa_link_output_symbol_hook): Likewise.
* elf64-mmix.c (mmix_elf_link_output_symbol_hook): Likewise.
* elf64-sh64.c (sh64_elf64_link_output_symbol_hook): Likewise.
* elf64-sparc.c (elf64_sparc_output_arch_syms): Likewise.
* elfxx-mips.c (_bfd_mips_elf_link_output_symbol_hook): Likewise.
* elfxx-mips.h (_bfd_mips_elf_link_output_symbol_hook): Likewise.
+2009-05-21 Alan Modra <amodra@bigpond.net.au>
+
+ * elf-bfd.h (struct elf_backend_data
+ <elf_backend_link_output_symbol_hook>): Return an int.
+ * elf64-ppc.c (ppc64_elf_output_symbol_hook): Return 2 to drop
+ symbols on deleted .opd entries.
+ * elflink.c (elf_link_output_sym): Return without outputting sym
+ if output_symbol_hook returns 2.
+ (elf_link_output_extsym): Don't assign h->indx when symbol discarded.
+ Abort if we must not discard sym.
+ (elf_link_input_bfd): Similarly, don't set finfo->indices for
+ local syms.
+ (bfd_elf_final_link): Adjust elf_link_output_sym calls.
+ * elf-vxworks.c (elf_vxworks_link_output_symbol_hook): Adjust for
+ elf_backend_link_output_symbol_hook return type change.
+ * elf32-arm.c (output_arch_syminfo): Likewise.
+ (elf32_arm_output_map_sym, elf32_arm_output_stub_sym): Likewise.
+ (elf32_arm_output_arch_local_syms): Likewise.
+ * elf32-cr16c.c (elf32_cr16c_link_output_symbol_hook): Likewise.
+ * elf32-score.c (s3_bfd_score_elf_link_output_symbol_hook): Likewise.
+ (bfd_score_elf_link_output_symbol_hook): Likewise.
+ * elf32-score.h (s7_bfd_score_elf_link_output_symbol_hook): Likewise.
+ * elf32-score7.c (s7_bfd_score_elf_link_output_symbol_hook): Likewise.
+ * elf32-sh64.c (sh64_elf_link_output_symbol_hook): Likewise.
+ * elf32-spu.c (spu_elf_output_symbol_hook): Likewise.
+ * elf32-v850.c (v850_elf_link_output_symbol_hook): Likewise.
+ * elf64-hppa.c (elf64_hppa_link_output_symbol_hook): Likewise.
+ * elf64-mmix.c (mmix_elf_link_output_symbol_hook): Likewise.
+ * elf64-sh64.c (sh64_elf64_link_output_symbol_hook): Likewise.
+ * elf64-sparc.c (elf64_sparc_output_arch_syms): Likewise.
+ * elfxx-mips.c (_bfd_mips_elf_link_output_symbol_hook): Likewise.
+ * elfxx-mips.h (_bfd_mips_elf_link_output_symbol_hook): Likewise.
+
2009-05-21 Alan Modra <amodra@bigpond.net.au>
* elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Don't segfault on
const char **name, flagword *flags, asection **sec, bfd_vma *value);
/* If this field is not NULL, it is called by the elf_link_output_sym
- phase of a link for each symbol which will appear in the object file. */
- bfd_boolean (*elf_backend_link_output_symbol_hook)
+ phase of a link for each symbol which will appear in the object file.
+ On error, this function returns 0. 1 is returned when the symbol
+ should be output, 2 is returned when the symbol should be discarded. */
+ int (*elf_backend_link_output_symbol_hook)
(struct bfd_link_info *info, const char *, Elf_Internal_Sym *,
asection *, struct elf_link_hash_entry *);
}
/* Tweak magic VxWorks symbols as they are written to the output file. */
-bfd_boolean
+int
elf_vxworks_link_output_symbol_hook (struct bfd_link_info *info
ATTRIBUTE_UNUSED,
const char *name,
&& elf_vxworks_gott_symbol_p (h->root.u.undef.abfd, name))
sym->st_info = ELF_ST_INFO (STB_GLOBAL, ELF_ST_TYPE (sym->st_info));
- return TRUE;
+ return 1;
}
/* Copy relocations into the output file. Fixes up relocations against PLT
struct bfd_link_info *info;
asection *sec;
int sec_shndx;
- bfd_boolean (*func) (void *, const char *, Elf_Internal_Sym *,
- asection *, struct elf_link_hash_entry *);
+ int (*func) (void *, const char *, Elf_Internal_Sym *,
+ asection *, struct elf_link_hash_entry *);
} output_arch_syminfo;
enum map_symbol_type
sym.st_other = 0;
sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_NOTYPE);
sym.st_shndx = osi->sec_shndx;
- if (!osi->func (osi->finfo, names[type], &sym, osi->sec, NULL))
- return FALSE;
- return TRUE;
+ return osi->func (osi->finfo, names[type], &sym, osi->sec, NULL) == 1;
}
sym.st_other = 0;
sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_FUNC);
sym.st_shndx = osi->sec_shndx;
- if (!osi->func (osi->finfo, name, &sym, osi->sec, NULL))
- return FALSE;
- return TRUE;
+ return osi->func (osi->finfo, name, &sym, osi->sec, NULL) == 1;
}
static bfd_boolean
elf32_arm_output_arch_local_syms (bfd *output_bfd,
struct bfd_link_info *info,
void *finfo,
- bfd_boolean (*func) (void *, const char *,
- Elf_Internal_Sym *,
- asection *,
- struct elf_link_hash_entry *))
+ int (*func) (void *, const char *,
+ Elf_Internal_Sym *,
+ asection *,
+ struct elf_link_hash_entry *))
{
output_arch_syminfo osi;
struct elf32_arm_link_hash_table *htab;
return TRUE;
}
-static bfd_boolean
+static int
elf32_cr16c_link_output_symbol_hook (struct bfd_link_info *info ATTRIBUTE_UNUSED,
const char *name ATTRIBUTE_UNUSED,
Elf_Internal_Sym *sym,
sym->st_shndx = SHN_CR16C_NCOMMON;
}
- return TRUE;
+ return 1;
}
/* Definitions for setting CR16C target vector. */
}
}
-static bfd_boolean
+static int
s3_bfd_score_elf_link_output_symbol_hook (struct bfd_link_info *info ATTRIBUTE_UNUSED,
const char *name ATTRIBUTE_UNUSED,
Elf_Internal_Sym *sym,
if (sym->st_shndx == SHN_COMMON && strcmp (input_sec->name, ".scommon") == 0)
sym->st_shndx = SHN_SCORE_SCOMMON;
- return TRUE;
+ return 1;
}
static bfd_boolean
return s7_bfd_score_elf_symbol_processing (abfd, asym);
}
-static bfd_boolean
+static int
_bfd_score_elf_link_output_symbol_hook (struct bfd_link_info *info ATTRIBUTE_UNUSED,
const char *name ATTRIBUTE_UNUSED,
Elf_Internal_Sym *sym,
common in the output file. */
if (sym->st_shndx == SHN_COMMON && strcmp (input_sec->name, ".scommon") == 0)
sym->st_shndx = SHN_SCORE_SCOMMON;
- return TRUE;
+ return 1;
}
if (bfd_get_mach (info->input_bfds) == bfd_mach_score3)
extern void
s7_bfd_score_elf_symbol_processing (bfd *, asymbol *);
-extern bfd_boolean
+extern int
s7_bfd_score_elf_link_output_symbol_hook (struct bfd_link_info *,
const char *,
Elf_Internal_Sym *,
}
}
-bfd_boolean
+int
s7_bfd_score_elf_link_output_symbol_hook (struct bfd_link_info *info ATTRIBUTE_UNUSED,
const char *name ATTRIBUTE_UNUSED,
Elf_Internal_Sym *sym,
if (sym->st_shndx == SHN_COMMON && strcmp (input_sec->name, ".scommon") == 0)
sym->st_shndx = SHN_SCORE_SCOMMON;
- return TRUE;
+ return 1;
}
bfd_boolean
static bfd_boolean sh64_elf_add_symbol_hook
(bfd *, struct bfd_link_info *, Elf_Internal_Sym *, const char **,
flagword *, asection **, bfd_vma *);
-static bfd_boolean sh64_elf_link_output_symbol_hook
+static int sh64_elf_link_output_symbol_hook
(struct bfd_link_info *, const char *, Elf_Internal_Sym *, asection *,
struct elf_link_hash_entry *);
static bfd_boolean sh64_backend_section_from_shdr
we don't need to look up and make sure to emit the main symbol for each
DataLabel symbol. */
-bfd_boolean
+static int
sh64_elf_link_output_symbol_hook (struct bfd_link_info *info,
const char *cname,
Elf_Internal_Sym *sym,
name[strlen (name) - strlen (DATALABEL_SUFFIX)] = 0;
}
- return TRUE;
+ return 1;
}
/* Check a SH64-specific reloc and put the value to relocate to into
/* Adjust _SPUEAR_ syms to point at their overlay stubs. */
-static bfd_boolean
+static int
spu_elf_output_symbol_hook (struct bfd_link_info *info,
const char *sym_name ATTRIBUTE_UNUSED,
Elf_Internal_Sym *sym,
}
}
- return TRUE;
+ return 1;
}
static int spu_plugin = 0;
return TRUE;
}
-static bfd_boolean
+static int
v850_elf_link_output_symbol_hook (struct bfd_link_info *info ATTRIBUTE_UNUSED,
const char *name ATTRIBUTE_UNUSED,
Elf_Internal_Sym *sym,
sym->st_other &= ~(V850_OTHER_SDA | V850_OTHER_ZDA | V850_OTHER_TDA
| V850_OTHER_ERROR);
- return TRUE;
+ return 1;
}
static bfd_boolean
static bfd_boolean elf64_hppa_size_dynamic_sections
(bfd *, struct bfd_link_info *);
-static bfd_boolean elf64_hppa_link_output_symbol_hook
+static int elf64_hppa_link_output_symbol_hook
(struct bfd_link_info *, const char *, Elf_Internal_Sym *,
asection *, struct elf_link_hash_entry *);
the symbols have their expected value in the normal symbol
table. Ick. */
-static bfd_boolean
+static int
elf64_hppa_link_output_symbol_hook (struct bfd_link_info *info ATTRIBUTE_UNUSED,
const char *name,
Elf_Internal_Sym *sym,
/* We may be called with the file symbol or section symbols.
They never need munging, so it is safe to ignore them. */
if (!name || !eh)
- return TRUE;
+ return 1;
/* Function symbols for which we created .opd entries *may* have been
munged by finish_dynamic_symbol and have to be un-munged here.
sym->st_shndx = hh->st_shndx;
}
- return TRUE;
+ return 1;
}
/* Finish up dynamic symbol handling. We set the contents of various
struct bpo_reloc_request *reloc_request;
};
-static bfd_boolean mmix_elf_link_output_symbol_hook
+static int mmix_elf_link_output_symbol_hook
PARAMS ((struct bfd_link_info *, const char *, Elf_Internal_Sym *,
asection *, struct elf_link_hash_entry *));
the register section, and scale them down to correspond to the register
number. */
-static bfd_boolean
+static int
mmix_elf_link_output_symbol_hook (info, name, sym, input_sec, h)
struct bfd_link_info *info ATTRIBUTE_UNUSED;
const char *name ATTRIBUTE_UNUSED;
sym->st_shndx = SHN_REGISTER;
}
- return TRUE;
+ return 1;
}
/* We fake a register section that holds values that are register numbers.
/* Adjust the value of any local symbols in opd sections. */
-static bfd_boolean
+static int
ppc64_elf_output_symbol_hook (struct bfd_link_info *info,
const char *name ATTRIBUTE_UNUSED,
Elf_Internal_Sym *elfsym,
bfd_vma value;
if (h != NULL)
- return TRUE;
+ return 1;
opd = get_opd_info (input_sec);
if (opd == NULL || opd->adjust == NULL)
- return TRUE;
+ return 1;
value = elfsym->st_value - input_sec->output_offset;
if (!info->relocatable)
adjust = opd->adjust[value / 8];
if (adjust == -1)
- elfsym->st_value = 0;
- else
- elfsym->st_value += adjust;
- return TRUE;
+ return 2;
+
+ elfsym->st_value += adjust;
+ return 1;
}
/* Finish up dynamic symbol handling. We set the contents of various
we don't need to look up and make sure to emit the main symbol for each
DataLabel symbol. */
-static bfd_boolean
+static int
sh64_elf64_link_output_symbol_hook (struct bfd_link_info *info,
const char *cname,
Elf_Internal_Sym *sym,
name[strlen (name) - strlen (DATALABEL_SUFFIX)] = 0;
}
- return TRUE;
+ return 1;
}
/* Set bit 0 on the entry address; it always points to SHmedia code. This
static bfd_boolean
elf64_sparc_output_arch_syms (bfd *output_bfd ATTRIBUTE_UNUSED,
struct bfd_link_info *info,
- PTR finfo, bfd_boolean (*func) (PTR, const char *,
- Elf_Internal_Sym *,
- asection *,
- struct elf_link_hash_entry *))
+ PTR finfo,
+ int (*func) (PTR, const char *,
+ Elf_Internal_Sym *,
+ asection *,
+ struct elf_link_hash_entry *))
{
int reg;
struct _bfd_sparc_elf_app_reg *app_regs =
sym.st_other = 0;
sym.st_info = ELF_ST_INFO (app_regs [reg].bind, STT_REGISTER);
sym.st_shndx = app_regs [reg].shndx;
- if (! (*func) (finfo, app_regs [reg].name, &sym,
- sym.st_shndx == SHN_ABS
- ? bfd_abs_section_ptr : bfd_und_section_ptr,
- NULL))
+ if ((*func) (finfo, app_regs [reg].name, &sym,
+ sym.st_shndx == SHN_ABS
+ ? bfd_abs_section_ptr : bfd_und_section_ptr,
+ NULL) != 1)
return FALSE;
}
/* Add a symbol to the output symbol table. */
-static bfd_boolean
+static int
elf_link_output_sym (struct elf_final_link_info *finfo,
const char *name,
Elf_Internal_Sym *elfsym,
{
bfd_byte *dest;
Elf_External_Sym_Shndx *destshndx;
- bfd_boolean (*output_symbol_hook)
+ int (*output_symbol_hook)
(struct bfd_link_info *, const char *, Elf_Internal_Sym *, asection *,
struct elf_link_hash_entry *);
const struct elf_backend_data *bed;
output_symbol_hook = bed->elf_backend_link_output_symbol_hook;
if (output_symbol_hook != NULL)
{
- if (! (*output_symbol_hook) (finfo->info, name, elfsym, input_sec, h))
- return FALSE;
+ int ret = (*output_symbol_hook) (finfo->info, name, elfsym, input_sec, h);
+ if (ret != 1)
+ return ret;
}
if (name == NULL || *name == '\0')
elfsym->st_name = (unsigned long) _bfd_stringtab_add (finfo->symstrtab,
name, TRUE, FALSE);
if (elfsym->st_name == (unsigned long) -1)
- return FALSE;
+ return 0;
}
if (finfo->symbuf_count >= finfo->symbuf_size)
{
if (! elf_link_flush_output_syms (finfo, bed))
- return FALSE;
+ return 0;
}
dest = finfo->symbuf + finfo->symbuf_count * bed->s->sizeof_sym;
amt = finfo->shndxbuf_size * sizeof (Elf_External_Sym_Shndx);
destshndx = bfd_realloc (destshndx, amt * 2);
if (destshndx == NULL)
- return FALSE;
+ return 0;
finfo->symshndxbuf = destshndx;
memset ((char *) destshndx + amt, 0, amt);
finfo->shndxbuf_size *= 2;
finfo->symbuf_count += 1;
bfd_get_symcount (finfo->output_bfd) += 1;
- return TRUE;
+ return 1;
}
/* Return TRUE if the dynamic symbol SYM in ABFD is supported. */
Elf_Internal_Sym sym;
asection *input_sec;
const struct elf_backend_data *bed;
+ long indx;
+ int ret;
if (h->root.type == bfd_link_hash_warning)
{
if (strip || (input_sec->flags & SEC_EXCLUDE) != 0)
return TRUE;
- h->indx = bfd_get_symcount (finfo->output_bfd);
-
- if (! elf_link_output_sym (finfo, h->root.root.string, &sym, input_sec, h))
+ indx = bfd_get_symcount (finfo->output_bfd);
+ ret = elf_link_output_sym (finfo, h->root.root.string, &sym, input_sec, h);
+ if (ret == 0)
{
eoinfo->failed = TRUE;
return FALSE;
}
+ else if (ret == 1)
+ h->indx = indx;
+ else if (h->indx == -2)
+ abort();
return TRUE;
}
asection *isec;
const char *name;
Elf_Internal_Sym osym;
+ long indx;
+ int ret;
*pindex = -1;
&& bfd_is_local_label_name (input_bfd, name)))
continue;
- /* If we get here, we are going to output this symbol. */
-
osym = *isym;
/* Adjust the section index for the output file. */
}
}
- if (! elf_link_output_sym (finfo, name, &osym, isec, NULL))
+ indx = bfd_get_symcount (output_bfd);
+ ret = elf_link_output_sym (finfo, name, &osym, isec, NULL);
+ if (ret == 0)
return FALSE;
+ else if (ret == 1)
+ *pindex = indx;
}
/* Relocate the contents of each section. */
Elf_Internal_Sym sym = isymbuf[symndx];
asection *sec = finfo->sections[symndx]->output_section;
const char *name;
+ long indx;
+ int ret;
name = bfd_elf_string_from_elf_section (input_bfd,
symtab_hdr->sh_link,
sym.st_value += o->output_offset;
- finfo->indices[symndx] = bfd_get_symcount (output_bfd);
- if (! elf_link_output_sym (finfo, name, &sym, o, NULL))
+ indx = bfd_get_symcount (output_bfd);
+ ret = elf_link_output_sym (finfo, name, &sym, o, NULL);
+ if (ret == 0)
return FALSE;
+ else if (ret == 1)
+ finfo->indices[symndx] = indx;
+ else
+ abort ();
}
elf_section_data (osec)->this_hdr.sh_info
= finfo->indices[symndx];
unsigned long shlink;
const char *name;
asection *osec;
+ long indx;
if (finfo->info->strip == strip_all)
{
}
}
- finfo->indices[r_symndx]
- = bfd_get_symcount (output_bfd);
-
- if (! elf_link_output_sym (finfo, name, &sym, sec,
- NULL))
+ indx = bfd_get_symcount (output_bfd);
+ ret = elf_link_output_sym (finfo, name, &sym, sec,
+ NULL);
+ if (ret == 0)
return FALSE;
+ else if (ret == 1)
+ finfo->indices[r_symndx] = indx;
+ else
+ abort ();
}
r_symndx = finfo->indices[r_symndx];
elfsym.st_info = 0;
elfsym.st_other = 0;
elfsym.st_shndx = SHN_UNDEF;
- if (! elf_link_output_sym (&finfo, NULL, &elfsym, bfd_und_section_ptr,
- NULL))
+ if (elf_link_output_sym (&finfo, NULL, &elfsym, bfd_und_section_ptr,
+ NULL) != 1)
goto error_return;
}
elfsym.st_shndx = i;
if (!info->relocatable)
elfsym.st_value = o->vma;
- if (!elf_link_output_sym (&finfo, NULL, &elfsym, o, NULL))
+ if (elf_link_output_sym (&finfo, NULL, &elfsym, o, NULL) != 1)
goto error_return;
}
}
table, do it now. */
if (bed->elf_backend_output_arch_local_syms)
{
- typedef bfd_boolean (*out_sym_func)
+ typedef int (*out_sym_func)
(void *, const char *, Elf_Internal_Sym *, asection *,
struct elf_link_hash_entry *);
table, do it now. */
if (bed->elf_backend_output_arch_syms)
{
- typedef bfd_boolean (*out_sym_func)
+ typedef int (*out_sym_func)
(void *, const char *, Elf_Internal_Sym *, asection *,
struct elf_link_hash_entry *);
symbol. We mark symbols as small common if appropriate. This is
also where we undo the increment of the value for a mips16 symbol. */
-bfd_boolean
+int
_bfd_mips_elf_link_output_symbol_hook
(struct bfd_link_info *info ATTRIBUTE_UNUSED,
const char *name ATTRIBUTE_UNUSED, Elf_Internal_Sym *sym,
if (ELF_ST_IS_MIPS16 (sym->st_other))
sym->st_value &= ~1;
- return TRUE;
+ return 1;
}
\f
/* Functions for the dynamic linker. */
extern bfd_boolean _bfd_mips_elf_add_symbol_hook
(bfd *, struct bfd_link_info *, Elf_Internal_Sym *,
const char **, flagword *, asection **, bfd_vma *);
-extern bfd_boolean _bfd_mips_elf_link_output_symbol_hook
+extern int _bfd_mips_elf_link_output_symbol_hook
(struct bfd_link_info *, const char *, Elf_Internal_Sym *,
asection *, struct elf_link_hash_entry *);
extern bfd_boolean _bfd_mips_elf_create_dynamic_sections