-
Notifications
You must be signed in to change notification settings - Fork 275
relocation truncated to fit: R_RISCV_HI20 against symbol `_impure_ptr' defined in .sdata section #153
Comments
riscv/riscv-tools is broken and may never be fixed. Don't use it. Use riscv/riscv-gnu-toolchain directly instead. You compiled with -mcmodel=medany, but your libraries were compiled with the default -mcmodel=medlow which won't work with a load address of 0x80000000 on a 64-bit target. If you use riscv/riscv-gnu-toolchain directly, then you can use --with-cmodel=medany to get a toolchain that defaults to medany cmodel and has libraries compiled for medany. See the README.md file for more info on building it. The missing debug info section error is a cascading error that was fixed over a year ago. That will go away if you use an up to date toolchain. |
as long as there is no deprecation notice right in front of the README in that repo, people will continue to use it. |
I can't fix that. I can only tell people after the fact that they never should have used it in the first place. This needs to be handled higher up inside the RISC-V Foundation. More specifically, riscv-tools is a submodule of rocket-chip, and only changes when a fix is required by rocket-chip. Changing the compiler will likely break the rocket-chip regression tests, which would require a lot of work on the rocket-chip side, which they have no incentive to do, so the compiler may never be upgraded. I'm not a hardware engineer working on rocket-chip, so I can't fix this. The fix needs to come from the rocket-chip folks, and they have no interest in fixing the problem. One fix for instance might be to rename riscv-tools to rocket-chip-tools, to make it clear that this isn't a generic RISC-V tool set, but rather a very specific toolset for rocket-chip development. Another fix might be to remove the compiler from riscv-tools and modify rocket-chip to add riscv-gnu-toolchain as a submodule. |
Hi Jim, cheers |
Hi jim, |
You can build either an embedded elf target toolchain or a linux target toolchain from the riscv-gnu-toolchain sources. There are configure options --disable-linux and --enable-linux that control which target toolchain you get when you run "make". Without the configure options, "make" builds an embedded elf target toolchain and "make linux" builds a linux target toolchain. You probably typed "make linux" thinking it was necessary on a linux host, but the linux actually means linux target which you don't want. |
I faced the following error, please help me out here. prasanth@prasanth-VirtualBox:~/Desktop/temp/SiFive_S2_n6/sifive_rt2_s21/freedom-e-sdk$ make PROGRAM=hello TARGET=design-arty CONFIGURATION=debug software |
Already asked and answered in the forums. Please only report problems in one place. |
I encountered the same problem. I've re-configured the
And error info is:
Thanks for help and I can provide any other details if you need. |
Dear Experts,
I am compiling a small gpio program in riscv64. I am getting a linker error.
Compilation goes well and failure happens at the end of linking.
I am pasting the error below.
Tool information:
Just now I cloned the latest from https://github.com/riscv/riscv-tools
Error snapshot:
Caveat: Code starts at 0x80000000.
/home/shaktilab/riscv/lib/gcc/riscv64-unknown-elf/7.2.0/../../../../riscv64-unknown-elf/lib/libc.a(lib_a-putchar.o): In function
_putchar_r': putchar.c:(.text+0x6): relocation truncated to fit: R_RISCV_HI20 against symbol
_impure_ptr' defined in .sdata section in /home/shaktilab/riscv/lib/gcc/riscv64-unknown-elf/7.2.0/../../../../riscv64-unknown-elf/lib/libc.a(lib_a-impure.o)/home/shaktilab/riscv/lib/gcc/riscv64-unknown-elf/7.2.0/../../../../riscv64-unknown-elf/bin/ld: final link failed: Symbol needs debug section which does not exist
collect2: error: ld returned 1 exit status
compilation command snippet:
riscv64-unknown-elf-gcc -w -mcmodel=medany -static -std=gnu99 -fno-builtin-printf
linker script:
OUTPUT_ARCH( "riscv" )
ENTRY(_start)
/----------------------------------------------------------------------/
/* Sections /
/----------------------------------------------------------------------*/
SECTIONS
{
/* text: test code section /
. = 0x80000000;
/ . = 0x20000; */
.text.init : { *(.text.init) }
.tohost ALIGN(0x1000) : { *(.tohost) }
.text : { *(.text) }
/* data segment */
.data : { *(.data) }
.sdata : {
__global_pointer$ = . + 0x800;
*(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) (.srodata.cst2) (.srodata)
(.sdata .sdata. .gnu.linkonce.s.)
}
/* bss segment /
.sbss : {
(.sbss .sbss. .gnu.linkonce.sb.)
*(.scommon)
}
.bss : { *(.bss) }
/* thread-local data segment */
.tdata :
{
_tls_data = .;
*(.tdata.begin)
*(.tdata)
*(.tdata.end)
}
.tbss :
{
*(.tbss)
*(.tbss.end)
}
/* End of uninitalized data segement */
_end = .;
}
The text was updated successfully, but these errors were encountered: