+1999-12-16 Nick Clifton <nickc@cygnus.com>
+
+ * coff-arm.c (NUM_ELEM): New macro.
+ (NUM_RELOCS): New macro: The number of known ARM relocs.
+ (RTYPE2HOWTO): Return NULL if the reloc type is out of range.
+ (coff_arm_rtype_to_howto): Return NULL if the reloc type is out
+ of range.
+ (bfd_arm_process_before_allocation): Produce a warning message if
+ an out of range symbol index is encountered.
+
1999-12-14 Nick Clifton <nickc@cygnus.com>
* elflink.h (is_global_symbol_definition): New Function: Return
#define SET_INTERWORK_FLAG( abfd, flg ) (coff_data (abfd)->flags = \
(coff_data (abfd)->flags & ~ F_INTERWORK) \
| (flg | F_INTERWORK_SET))
+
+#ifndef NUM_ELEM
+#define NUM_ELEM(a) ((sizeof (a)) / sizeof ((a)[0]))
+#endif
typedef enum {bunknown, b9, b12, b23} thumb_pcrel_branchtype;
/* some typedefs for holding instructions */
PCRELOFFSET),
};
+#define NUM_RELOCS NUM_ELEM (aoutarm_std_reloc_howto)
+
#ifdef COFF_WITH_PE
/* Return true if this relocation should
appear in the output .reloc section. */
}
#endif
-
-#define RTYPE2HOWTO(cache_ptr, dst) \
- (cache_ptr)->howto = aoutarm_std_reloc_howto + (dst)->r_type;
+#define RTYPE2HOWTO(cache_ptr, dst) \
+ (cache_ptr)->howto = \
+ (dst)->r_type < NUM_RELOCS \
+ ? aoutarm_std_reloc_howto + (dst)->r_type \
+ : NULL
#define coff_rtype_to_howto coff_arm_rtype_to_howto
struct internal_syment *sym ATTRIBUTE_UNUSED;
bfd_vma *addendp;
{
- reloc_howto_type *howto;
+ reloc_howto_type * howto;
+ if (rel->r_type >= NUM_RELOCS)
+ return NULL;
+
howto = aoutarm_std_reloc_howto + rel->r_type;
if (rel->r_type == ARM_RVA32)
- {
- *addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
- }
+ *addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
return howto;
-
}
/* Used by the assembler. */
bfd * abfd;
bfd_reloc_code_real_type code;
{
-#define ASTD(i,j) case i: return &aoutarm_std_reloc_howto[j]
+#define ASTD(i,j) case i: return aoutarm_std_reloc_howto + j
+
if (code == BFD_RELOC_CTOR)
switch (bfd_get_arch_info (abfd)->bits_per_address)
{
for (rel = i; rel < i + sec->reloc_count; ++rel)
{
unsigned short r_type = rel->r_type;
- long symndx;
+ unsigned long symndx;
struct coff_link_hash_entry * h;
symndx = rel->r_symndx;
if (symndx == -1)
continue;
+ if (symndx >= obj_conv_table_size (abfd))
+ {
+ _bfd_error_handler (_("%s: illegal symbol index in reloc: %d"),
+ bfd_get_filename (abfd), symndx);
+ continue;
+ }
+
h = obj_coff_sym_hashes (abfd)[symndx];
/* If the relocation is against a static symbol it must be within