OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 11:22 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: TARGET riscv64-elf- vs riscv64-linux-
PostPosted: Wed Feb 15, 2023 1:44 am 
Offline

Joined: Fri Feb 03, 2023 4:53 am
Posts: 9
What I'm trying to do is

- compile OpenSBI with u-boot as payload
- start QEMU with the previously compiled OpenSBI as BIOS, which should load u-boot
- use u-boot to load my own risc-v kernel from some partition (the partition is from a block device that I've created for QEMU)

I've build my gcc cross-compile toolchain with TARGET=riscv64-elf- but apparently u-boot doesn't compile with it. At some point during compilation I get this error

riscv64-elf-ld.bfd: warning: -z nocombreloc ignored
riscv64-elf-ld.bfd: -shared not supported
make[2]: *** [scripts/Makefile.lib:442: lib/efi_loader/helloworld_efi.so] Error 1
make[1]: *** [scripts/Makefile.build:398: lib/efi_loader] Error 2
make: *** [Makefile:1871: lib] Error 2

I've researched the issue and as far as I understand the riscv64-elf target is not supported, but riscv64-linux is. My question is what's the practical difference between the two targets?


Top
 Profile  
 
 Post subject: Re: TARGET riscv64-elf- vs riscv64-linux-
PostPosted: Wed Feb 15, 2023 9:56 am 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1593
exo wrote:
I've researched the issue and as far as I understand the riscv64-elf target is not supported, but riscv64-linux is. My question is what's the practical difference between the two targets?

The -elf target does not associate with any OS, whereas -linux does. This has side-effects such as where GCC searches for the stack canary when compiling with -fstack-protector. In your case, you are noticing that it also fails to add a few linker scripts (that is all the -z options change, in the end), and it disables shared libraries. I presume that is because without an OS, there is nothing that can interpret relocation entries. Now, in your case there actually is, the UEFI runtime will do it for you. I don't know what the best solution here is. I usually just use a compiler that outputs PE directly for the purpose of compiling UEFI bootloaders. But that wouldn't work for the u-boot build system, since it clearly expects to create an ELF file and then objcopy it.

_________________
Carpe diem!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: DotBot [Bot], Garnek0, Google [Bot] and 74 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group