loongson / la-abi-specs

22 stars 6 forks source link

Do you have the plan for draft UEFI Specification for LoongArch about relocation type in PE format(LoongArch specially)? #9

Open TYDQSoft opened 1 month ago

TYDQSoft commented 1 month ago

I have read the code in binutils for loongarch and it only provide three relocation constant.It is too few to use,I think.Do you have the plan for loongarch UEFI specification (for PE format in loongarch)?

SixWeining commented 1 month ago

Did you mean this https://learn.microsoft.com/en-us/windows/win32/debug/pe-format that already supports LoongArch?

image

SixWeining commented 1 month ago

Cc @yetist @kilaterlee who may know more details.

xen0n commented 1 month ago

Context (in Chinese): https://bbs.loongarch.org/d/443

I guess maybe the OP wants more complete relocs in PE, similar to the full set of R_LARCH_B*, R_LARCH_ABS*, R_LARCH_PCALA* etc., so that a complete PE toolchain could be made.

I agree that the OP should provide more information regarding their motivation and background etc. so we don't have to guess as much.

TYDQSoft commented 1 month ago

Did you mean this https://learn.microsoft.com/en-us/windows/win32/debug/pe-format that already supports LoongArch?

image

However,I need more loongarch-specific relocation constants such as IMAGE_REL_LOONGARCH_ABSOLUTE.

driver1998 commented 1 month ago

There are two constants defined in .NET PAL, not documented in PE spec (not sure if they are .NET specific):

IMAGE_REL_LOONGARCH64_PC IMAGE_REL_LOONGARCH64_JIR

https://github.com/dotnet/runtime/blob/a5cc707d976a14495462c9c492a921ff0927b8f5/src/coreclr/pal/inc/rt/ntimage.h#L1021 implementation: https://github.com/dotnet/runtime/blob/af5e7150362294696d3d52aa2302062e4b7c8095/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Relocation.cs#L542

shushanhf commented 1 month ago

There are two constants defined in .NET PAL, not documented in PE spec (not sure if they are .NET specific): IMAGE_REL_LOONGARCH64_PC IMAGE_REL_LOONGARCH64_JIR

No, these are only used for .NET and only LoongArch64's AOT within .NET.

TYDQSoft commented 1 month ago

There are two constants defined in .NET PAL, not documented in PE spec (not sure if they are .NET specific):

IMAGE_REL_LOONGARCH64_PC IMAGE_REL_LOONGARCH64_JIR

https://github.com/dotnet/runtime/blob/a5cc707d976a14495462c9c492a921ff0927b8f5/src/coreclr/pal/inc/rt/ntimage.h#L1021 implementation: https://github.com/dotnet/runtime/blob/af5e7150362294696d3d52aa2302062e4b7c8095/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Relocation.cs#L542

So that's why draft UEFI specification for LoongArch about relocation type in PE format matters.I need a LoongArch64 relocation table for free pascal compiler.These .NET only constants are so disappointed for free pascal compiler users.

driver1998 commented 1 month ago

From the code it looks like there is really only one relocation type supported in UEFI: IMAGE_REL_BASED_LOONGARCH64_MARK_LA.

So if you need to target UEFI, this is the one you need to use.

https://github.com/tianocore/edk2/blob/1bb9f47739ae7993191a36bea76c5a2157fdd10f/MdePkg/Library/BasePeCoffLib/LoongArch/PeCoffLoaderEx.c#L43