smithp35 wrote:

> > I don't think that this should necessarily prevent this patch from landing. 
> > To some degree users can just not use the option if the toolchain doesn't 
> > support it.
> 
> The file names for crt files are borrowed from their linux equivalent. 
> However as already pointed out, if a user wants to link against different set 
> of `crt*` files, then they can pass `-nostdlib` or `-nostartfiles and provide 
> their own implementation of startup routines.
> 
> > I'm interested in what the RISCV bare-metal toolchains do in this case?
> 
> In such scenarios, the responsibility for generating startup code with an 
> appropriate relocation resolver is delegated to customer image vendors. They 
> are expected to use options like -nostartfiles or -nostdlib, and provide 
> their own startup routines that include an implementation of a custom 
> relocation resolver. Additionally, they must define linker script symbols to 
> delimit the dynamic relocations. The custom resolver then parses each 
> .rela.dyn relocation entry within the boundaries defined by these symbols. As 
> far as I know, there is nothing RISC-V bare-metal-specific in the toolchains 
> to handle such cases.

Thanks for the information. That sounds like how I'd expect it to work in 
bare-metal platform. 

Although out of scope of this patch, I've often thought if there were enough 
common ground to be able to standardise on the symbols and perhaps have the 
linker define them, with the runtime able to provide a generic relocation 
resolver based on them.

One land-mine I've seen some people run into with LLD, is that it is 
--no-apply-dynamic-relocs by default. This means that if --pie is used then 
there must be a loader. However with --apply-dynamic-relocs no loader is needed 
if the program is run at its static link address.
https://sourceware.org/binutils/docs/ld/ARM.html#index-_002d_002dno_002dapply_002ddynamic_002drelocs
sadly in GNU ld that option is AArch64 only so it couldn't be universally 
applied.

https://github.com/llvm/llvm-project/pull/147589
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to