Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--agent/machine/microblaze/tcf/dwarfreloc-mdep.h64
-rw-r--r--agent/tcf/services/dwarfreloc-ext.h7
2 files changed, 70 insertions, 1 deletions
diff --git a/agent/machine/microblaze/tcf/dwarfreloc-mdep.h b/agent/machine/microblaze/tcf/dwarfreloc-mdep.h
new file mode 100644
index 00000000..6d9d9346
--- /dev/null
+++ b/agent/machine/microblaze/tcf/dwarfreloc-mdep.h
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2013, 2017 Xilinx, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ * You may elect to redistribute this code under either of these licenses.
+ *
+ * Contributors:
+ * Xilinx - initial API and implementation
+ *******************************************************************************/
+
+/*
+ * This module provides CPU specific ELF definitions for MicroBlaze.
+ */
+
+#define R_MICROBLAZE_NONE 0
+#define R_MICROBLAZE_32 1
+#define R_MICROBLAZE_32_PCREL 2
+#define R_MICROBLAZE_64_PCREL 3
+#define R_MICROBLAZE_32_PCREL_LO 4
+#define R_MICROBLAZE_64 5
+#define R_MICROBLAZE_32_LO 6
+#define R_MICROBLAZE_SRO32 7
+#define R_MICROBLAZE_SRW32 8
+#define R_MICROBLAZE_64_NONE 9
+#define R_MICROBLAZE_32_SYM_OP_SYM 10
+#define R_MICROBLAZE_32_NONE 30
+
+static void elf_relocate(void) {
+ if (relocs->type == SHT_REL) {
+ U4_T x = *(U4_T *)((char *)section->data + reloc_offset);
+ if (section->file->type != ET_REL) str_exception(ERR_INV_FORMAT, "Invalid relocation record");
+ if (section->file->byte_swap) SWAP(x);
+ assert(reloc_addend == 0);
+ reloc_addend = x;
+ }
+ switch (reloc_type) {
+ case R_MICROBLAZE_NONE:
+ *destination_section = NULL;
+ break;
+ case R_MICROBLAZE_32_NONE:
+ if (data_size < 4) str_exception(ERR_INV_FORMAT, "Invalid relocation record");
+ *destination_section = NULL;
+ break;
+ case R_MICROBLAZE_64_NONE:
+ if (data_size < 8) str_exception(ERR_INV_FORMAT, "Invalid relocation record");
+ *destination_section = NULL;
+ break;
+ case R_MICROBLAZE_32:
+ if (data_size < 4) str_exception(ERR_INV_FORMAT, "Invalid relocation record");
+ *(U4_T *)data_buf = (U4_T)(sym_value + reloc_addend);
+ break;
+ case R_MICROBLAZE_32_PCREL:
+ if (data_size < 4) str_exception(ERR_INV_FORMAT, "Invalid relocation record");
+ *(U4_T *)data_buf = (U4_T)(sym_value + reloc_addend - (section->addr + reloc_offset));
+ break;
+ default:
+ str_exception(ERR_INV_FORMAT, "Unsupported relocation type");
+ }
+}
diff --git a/agent/tcf/services/dwarfreloc-ext.h b/agent/tcf/services/dwarfreloc-ext.h
index f13a46d4..36f74bb3 100644
--- a/agent/tcf/services/dwarfreloc-ext.h
+++ b/agent/tcf/services/dwarfreloc-ext.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014-2015 Wind River Systems, Inc. and others.
+ * Copyright (c) 2011, 2014-2017 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -38,6 +38,10 @@
#include <machine/ppc64/tcf/dwarfreloc-mdep.h>
#undef elf_relocate
+#define elf_relocate elf_relocate_microblaze
+#include <machine/microblaze/tcf/dwarfreloc-mdep.h>
+#undef elf_relocate
+
static ElfRelocateFunc elf_relocate_funcs[] = {
{ EM_386, elf_relocate_i386 },
{ EM_X86_64, elf_relocate_x86_64 },
@@ -45,5 +49,6 @@ static ElfRelocateFunc elf_relocate_funcs[] = {
{ EM_AARCH64, elf_relocate_a64 },
{ EM_PPC, elf_relocate_powerpc },
{ EM_PPC64, elf_relocate_ppc64 },
+ { EM_MICROBLAZE, elf_relocate_microblaze },
{ EM_NONE, NULL }
};

Back to the top