long bfd_canonicalize_reloc
(bfd *abfd, asection *sec, arelent **loc, asymbol **syms);
-void bfd_finalize_section_relocs
+bool bfd_finalize_section_relocs
(bfd *abfd, asection *sec, arelent **rel, unsigned int count);
#define bfd_finalize_section_relocs(abfd, asect, location, count) \
long (*_get_reloc_upper_bound) (bfd *, sec_ptr);
long (*_bfd_canonicalize_reloc) (bfd *, sec_ptr, arelent **,
struct bfd_symbol **);
- void (*_bfd_finalize_section_relocs) (bfd *, sec_ptr, arelent **,
+ bool (*_bfd_finalize_section_relocs) (bfd *, sec_ptr, arelent **,
unsigned int);
/* See documentation on reloc types. */
reloc_howto_type *
bfd_finalize_section_relocs
SYNOPSIS
- void bfd_finalize_section_relocs
+ bool bfd_finalize_section_relocs
(bfd *abfd, asection *sec, arelent **rel, unsigned int count);
DESCRIPTION
/* Install a new set of internal relocs. */
-static void
+static bool
elf64_sparc_finalize_section_relocs (bfd *abfd ATTRIBUTE_UNUSED,
asection *asect,
arelent **location,
asect->flags |= SEC_RELOC;
else
asect->flags &= ~SEC_RELOC;
+ return true;
}
/* Write out the relocs. */
(bfd *, asection *) ATTRIBUTE_HIDDEN;
extern long _bfd_norelocs_canonicalize_reloc
(bfd *, asection *, arelent **, asymbol **) ATTRIBUTE_HIDDEN;
-extern void _bfd_norelocs_finalize_section_relocs
+extern bool _bfd_norelocs_finalize_section_relocs
(bfd *, asection *, arelent **, unsigned int) ATTRIBUTE_HIDDEN;
extern reloc_howto_type *_bfd_norelocs_bfd_reloc_type_lookup
(bfd *, bfd_reloc_code_real_type) ATTRIBUTE_HIDDEN;
return 0;
}
-void
+bool
_bfd_norelocs_finalize_section_relocs (bfd *abfd ATTRIBUTE_UNUSED,
asection *sec ATTRIBUTE_UNUSED,
arelent **relptr ATTRIBUTE_UNUSED,
unsigned int count ATTRIBUTE_UNUSED)
{
- /* Do nothing. */
+ return true;
}
bool
(bfd *, asection *) ATTRIBUTE_HIDDEN;
extern long _bfd_norelocs_canonicalize_reloc
(bfd *, asection *, arelent **, asymbol **) ATTRIBUTE_HIDDEN;
-extern void _bfd_norelocs_finalize_section_relocs
+extern bool _bfd_norelocs_finalize_section_relocs
(bfd *, asection *, arelent **, unsigned int) ATTRIBUTE_HIDDEN;
extern reloc_howto_type *_bfd_norelocs_bfd_reloc_type_lookup
(bfd *, bfd_reloc_code_real_type) ATTRIBUTE_HIDDEN;
bool relocatable,
asymbol **symbols) ATTRIBUTE_HIDDEN;
-void _bfd_generic_finalize_section_relocs
+bool _bfd_generic_finalize_section_relocs
(bfd *abfd,
sec_ptr section,
arelent **relptr,
_bfd_generic_finalize_section_relocs
SYNOPSIS
- void _bfd_generic_finalize_section_relocs
+ bool _bfd_generic_finalize_section_relocs
(bfd *abfd,
sec_ptr section,
arelent **relptr,
Installs a new set of internal relocations in SECTION.
*/
-void
+bool
_bfd_generic_finalize_section_relocs (bfd *abfd ATTRIBUTE_UNUSED,
sec_ptr section,
arelent **relptr,
section->flags |= SEC_RELOC;
else
section->flags &= ~SEC_RELOC;
+ return true;
}
/*
. long (*_get_reloc_upper_bound) (bfd *, sec_ptr);
. long (*_bfd_canonicalize_reloc) (bfd *, sec_ptr, arelent **,
. struct bfd_symbol **);
-. void (*_bfd_finalize_section_relocs) (bfd *, sec_ptr, arelent **,
+. bool (*_bfd_finalize_section_relocs) (bfd *, sec_ptr, arelent **,
. unsigned int);
. {* See documentation on reloc types. *}
. reloc_howto_type *
}
if (relsize == 0)
- bfd_finalize_section_relocs (obfd, osection, NULL, 0);
+ {
+ if (!bfd_finalize_section_relocs (obfd, osection, NULL, 0))
+ return false;
+ }
else
{
if (isection->orelocation != NULL)
*w_relpp = 0;
}
- bfd_finalize_section_relocs (obfd, osection,
- relcount == 0 ? NULL : relpp, relcount);
+ if (!bfd_finalize_section_relocs (obfd, osection,
+ relcount == 0 ? NULL : relpp,
+ relcount))
+ return false;
}
return true;
}
return false;
}
- bfd_finalize_section_relocs (abfd, sec, cwi.relocs, cwi.reloc_count);
+ if (!bfd_finalize_section_relocs (abfd, sec, cwi.relocs, cwi.reloc_count))
+ {
+ bfd_nonfatal ("bfd_finalize_section_relocs");
+ bfd_close_all_done (abfd);
+ free (cwi.relocs);
+ return false;
+ }
offset = 0;
for (d = cwi.dirs.d; d != NULL; d = d->next)
/* Set relocations for the section and then store the number of relocations
in its aux entry. */
-void
+bool
obj_coff_finalize_section_relocs (asection *sec, arelent **relocs,
unsigned int n)
{
symbolS *sect_sym;
- bfd_finalize_section_relocs (stdoutput, sec, n ? relocs : NULL, n);
+ if (!bfd_finalize_section_relocs (stdoutput, sec, n ? relocs : NULL, n))
+ return false;
sect_sym = section_symbol (sec);
#ifdef OBJ_XCOFF
if (S_GET_STORAGE_CLASS (sect_sym) == C_DWARF)
else
#endif
SA_SET_SCN_NRELOC (sect_sym, n);
+ return true;
}
/* Implement the .section pseudo op:
/* We need to store the number of relocations in the section aux entry. */
#define FINALIZE_SECTION_RELOCS(sec, relocs, n) \
obj_coff_finalize_section_relocs (sec, relocs, n)
-extern void obj_coff_finalize_section_relocs (asection *, arelent **,
+extern bool obj_coff_finalize_section_relocs (asection *, arelent **,
unsigned int);
extern int S_SET_DATA_TYPE (symbolS *, int);
/* Reverse relocations order to make ld happy. */
-void
+bool
obj_mach_o_reorder_section_relocs (asection *sec, arelent **rels, unsigned int n)
{
unsigned int i;
rels[i] = rels[n - i - 1];
rels[n - i - 1] = r;
}
- bfd_finalize_section_relocs (stdoutput, sec, rels, n);
+ return bfd_finalize_section_relocs (stdoutput, sec, rels, n);
}
/* Relocation rules are different in frame sections. */
#define FINALIZE_SECTION_RELOCS(sec, relocs, n) \
obj_mach_o_reorder_section_relocs (sec, relocs, n)
-extern void obj_mach_o_reorder_section_relocs (asection *, arelent **,
+extern bool obj_mach_o_reorder_section_relocs (asection *, arelent **,
unsigned int);
/* Emit relocs for local subtracts, to cater for subsections-via-symbols. */
}
#endif
- FINALIZE_SECTION_RELOCS (sec, relocs, n);
+ if (!FINALIZE_SECTION_RELOCS (sec, relocs, n))
+ as_bad (_("%s: unable to finalize relocations"), sec->name);
#ifdef DEBUG3
{
}
if (relsize == 0)
- bfd_finalize_section_relocs (obfd, osection, NULL, 0);
+ {
+ if (!bfd_finalize_section_relocs (obfd, osection, NULL, 0))
+ {
+ err = _("unable to finalize relocations");
+ goto loser;
+ }
+ }
else
{
relpp = (arelent **) xmalloc (relsize);
goto loser;
}
- bfd_finalize_section_relocs (obfd, osection,
- relcount == 0 ? NULL : relpp, relcount);
+ if (!bfd_finalize_section_relocs (obfd, osection,
+ relcount == 0 ? NULL : relpp,
+ relcount))
+ {
+ free (relpp);
+ err = _("unable to finalize relocations");
+ goto loser;
+ }
if (relcount == 0)
free (relpp);
}