2015-10-02 Jose E. Marchesi <jose.marchesi@oracle.com>
+ * sparc_init.c (RELOC_TYPE_ID): Defined.
+ * common-reloc.c (reloc_type_name): Apply target-specific
+ relocation ID extractors if defined.
+ (reloc_type_check): Likewise.
+ (reloc_valid_use): Likewise.
+
+2015-10-02 Jose E. Marchesi <jose.marchesi@oracle.com>
+
* sparc_reloc.def: Added relocation types WDISP10, JMP_IREL and
IRELATIVE.
char *buf __attribute__ ((unused)),
size_t len __attribute__ ((unused)))
{
+#ifdef RELOC_TYPE_ID
+ reloc = RELOC_TYPE_ID (reloc);
+#endif
+
if (reloc >= 0 && reloc < nreloc && EBLHOOK(reloc_nameidx)[reloc] != 0)
return &reloc_namestr[EBLHOOK(reloc_nameidx)[reloc]];
return NULL;
bool
EBLHOOK(reloc_type_check) (int reloc)
{
+#ifdef RELOC_TYPE_ID
+ reloc = RELOC_TYPE_ID (reloc);
+#endif
+
return reloc >= 0 && reloc < nreloc && EBLHOOK(reloc_nameidx)[reloc] != 0;
}
bool
EBLHOOK(reloc_valid_use) (Elf *elf, int reloc)
{
- uint8_t uses = EBLHOOK(reloc_valid)[reloc];
+ uint8_t uses;
GElf_Ehdr ehdr_mem;
GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
assert (ehdr != NULL);
uint8_t type = ehdr->e_type;
+#ifdef RELOC_TYPE_ID
+ reloc = RELOC_TYPE_ID (reloc);
+#endif
+
+ uses = EBLHOOK(reloc_valid)[reloc];
return type > ET_NONE && type < ET_CORE && (uses & (1 << (type - 1)));
}
#define RELOC_PREFIX R_SPARC_
#include "libebl_CPU.h"
+/* In SPARC some relocations use the most significative 24 bits of the
+ r_type field to encode a secondary addend. Make sure the routines
+ in common-reloc.c acknowledge this. */
+#define RELOC_TYPE_ID(type) ((type) & 0xff)
+
/* This defines the common reloc hooks based on sparc_reloc.def. */
#include "common-reloc.c"