aboutsummaryrefslogtreecommitdiff
path: root/arch/tile/kernel/module.c
diff options
context:
space:
mode:
authorChris Metcalf <cmetcalf@tilera.com>2012-03-29 13:30:31 -0400
committerChris Metcalf <cmetcalf@tilera.com>2012-05-25 12:48:22 -0400
commit1efea40d4172a2a475ccb29b59d6221e9d0c174b (patch)
tree8152b61bb3fa83eb3403bca5cb05731c1063e999 /arch/tile/kernel/module.c
parent73636b1aacb1a07e6fbe0d25e560e69b024a8e25 (diff)
arch/tile: support building big-endian kernel
The toolchain supports big-endian mode now, so add support for building the kernel to run big-endian as well. Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Diffstat (limited to 'arch/tile/kernel/module.c')
-rw-r--r--arch/tile/kernel/module.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/arch/tile/kernel/module.c b/arch/tile/kernel/module.c
index 98d47692010..001cbfa10ac 100644
--- a/arch/tile/kernel/module.c
+++ b/arch/tile/kernel/module.c
@@ -159,7 +159,17 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
switch (ELF_R_TYPE(rel[i].r_info)) {
-#define MUNGE(func) (*location = ((*location & ~func(-1)) | func(value)))
+#ifdef __LITTLE_ENDIAN
+# define MUNGE(func) \
+ (*location = ((*location & ~func(-1)) | func(value)))
+#else
+/*
+ * Instructions are always little-endian, so when we read them as data,
+ * we have to swap them around before and after modifying them.
+ */
+# define MUNGE(func) \
+ (*location = swab64((swab64(*location) & ~func(-1)) | func(value)))
+#endif
#ifndef __tilegx__
case R_TILE_32: