diff options
author | Tom Rini <trini@konsulko.com> | 2019-08-16 07:22:21 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2019-08-16 07:22:21 -0400 |
commit | 3d240d89c4576e98fa04c8bf5c6fe64cf2f1e53a (patch) | |
tree | c15cd3ea46c783dc668e0faeea309da9c8a00c5e /tools/prelink-riscv.c | |
parent | df33f8646855e65b8e7232c7fd5739e1ae1eb58b (diff) | |
parent | 4539926a9c47638951f29f550f3a640e4c223032 (diff) |
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-riscv
- Fix sifive serial y-modem transfer.
- Access CSRs using CSR numbers.
- Update doc sifive-fu540
- Support big endian hosts and target.
Diffstat (limited to 'tools/prelink-riscv.c')
-rw-r--r-- | tools/prelink-riscv.c | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/tools/prelink-riscv.c b/tools/prelink-riscv.c index 52eb78e9d0..b0467949eb 100644 --- a/tools/prelink-riscv.c +++ b/tools/prelink-riscv.c @@ -8,10 +8,6 @@ * without fixup. Both RV32 and RV64 are supported. */ -#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__ -#error "Only little-endian host is supported" -#endif - #include <errno.h> #include <stdbool.h> #include <stdint.h> @@ -25,6 +21,7 @@ #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> +#include <compiler.h> #ifndef EM_RISCV #define EM_RISCV 243 @@ -50,12 +47,28 @@ const char *argv0; exit(EXIT_FAILURE); \ } while (0) +#define PRELINK_BYTEORDER le +#define PRELINK_INC_BITS 32 +#include "prelink-riscv.inc" +#undef PRELINK_BYTEORDER +#undef PRELINK_INC_BITS + +#define PRELINK_BYTEORDER le +#define PRELINK_INC_BITS 64 +#include "prelink-riscv.inc" +#undef PRELINK_BYTEORDER +#undef PRELINK_INC_BITS + +#define PRELINK_BYTEORDER be #define PRELINK_INC_BITS 32 #include "prelink-riscv.inc" +#undef PRELINK_BYTEORDER #undef PRELINK_INC_BITS +#define PRELINK_BYTEORDER be #define PRELINK_INC_BITS 64 #include "prelink-riscv.inc" +#undef PRELINK_BYTEORDER #undef PRELINK_INC_BITS int main(int argc, const char *const *argv) @@ -91,11 +104,19 @@ int main(int argc, const char *const *argv) die("Invalid ELF file %s", argv[1]); bool is64 = e_ident[EI_CLASS] == ELFCLASS64; - - if (is64) - prelink64(data); - else - prelink32(data); + bool isbe = e_ident[EI_DATA] == ELFDATA2MSB; + + if (is64) { + if (isbe) + prelink_be64(data); + else + prelink_le64(data); + } else { + if (isbe) + prelink_be32(data); + else + prelink_le32(data); + } return 0; } |