diff options
author | Hesham Almatary <Hesham.Almatary@cl.cam.ac.uk> | 2019-11-03 09:44:51 +0000 |
---|---|---|
committer | Hesham Almatary <Hesham.Almatary@cl.cam.ac.uk> | 2019-11-12 10:19:58 +0000 |
commit | a1c0f9288378461ef0213e503dcce4c5bd70932a (patch) | |
tree | cf8906a37bc359bdd3ba9ca093fc2f55128e1ae4 | |
parent | Add RISC-V machine to rld-elf (diff) | |
download | rtems-tools-a1c0f9288378461ef0213e503dcce4c5bd70932a.tar.bz2 |
rtems-syms: Use .quad instead of .long for riscv64
.long in RISC-V assembly is 4 bytes, while the address in riscv64
is 8 bytes (.quad). Moreover, RTEMS' libdl increases the symbols
pointer by sizeof(long) in C when iterating over global symbols.
-rw-r--r-- | linkers/rtems-syms.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/linkers/rtems-syms.cpp b/linkers/rtems-syms.cpp index 5ebdceb..bfe2a48 100644 --- a/linkers/rtems-syms.cpp +++ b/linkers/rtems-syms.cpp @@ -244,13 +244,21 @@ output_sym::operator ()(const rld::symbols::symtab::value_type& value) if (embed) { + c.write_line ("#if __riscv_xlen == 64"); + c.write_line ("asm(\" .quad " + sym.name () + "\");"); + c.write_line ("#else"); c.write_line ("asm(\" .long " + sym.name () + "\");"); + c.write_line ("#endif"); } else { std::stringstream oss; oss << std::hex << std::setfill ('0') << std::setw (8) << sym.value (); + c.write_line ("#if __riscv_xlen == 64"); + c.write_line ("asm(\" .quad 0x" + oss.str () + "\");"); + c.write_line ("#else"); c.write_line ("asm(\" .long 0x" + oss.str () + "\");"); + c.write_line ("#endif"); } } |