https://github.com/smithp35 commented:
Do we know what -static-pie means in the context of the bare-metal driver? It maybe that the RISCV GNU toolchains do, but this does not look like it is universal [1]. 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. In an ideal world we'd have a warning that it wasn't supported, but I don't think that it is going to be easy to work that out in the compiler driver alone. As an aside on -static-pie As I understand it, -static-pie at least for Linux like platforms creates an ELF file with a dynamic section and .rela.dyn and the glibc startup code includes `_dl_relocate_static_pie` that reads the dynamic section to find the dynamic relocations: https://codebrowser.dev/glibc/glibc/elf/dl-reloc-static-pie.c.html This isn't going to work well with most bare-metal platforms as they may not have an ELF file and the dynamic section would likely not be needed. We'd probably want the .rela.dyn to be delimited by linker defined symbols so that a relocation resolver could find and resolve them. Arm's proprietary toolchain did that with its --baremetal-pie option [2]. I'm interested in what the RISCV bare-metal toolchains do in this case? [1] Some of the bits in this patch definitely won't work for the arm-none-eabi and aarch64-none-elf GNU toolchains as there is no rcvrt1.o, crtbeginS.o and crtendS.o provided. [2] https://developer.arm.com/documentation/100748/0624/Mapping-Code-and-Data-to-the-Target/Bare-metal-Position-Independent-Executables 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