Forum > FPC development

[SOLVED]Does the data record in elf and in pecoff behaves differently?

(1/1)

TYDQ:
I have tested many times about data record behaviour in elf and in pecoff.I suspected that When reading data record or writing data record,linux's order and windows's order are completely different.However,this conclusion maybe wrong and I am mistaken.
While reading the assembly code fpc have generated,I discovered that the same data record is placing in the .rodata(elf),.data(windows),Does the different position made the data record reading and writing different from platforms?

PascalDragon:

--- Quote from: TYDQ on August 15, 2024, 05:09:43 pm ---I have tested many times about data record behaviour in elf and in pecoff.
--- End quote ---

What kind of data record do you mean?

TYDQ:

--- Quote from: PascalDragon on August 15, 2024, 07:16:40 pm ---
--- Quote from: TYDQ on August 15, 2024, 05:09:43 pm ---I have tested many times about data record behaviour in elf and in pecoff.
--- End quote ---

What kind of data record do you mean?

--- End quote ---
It is just a record like that:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---efi_system_table=record                      hdr:efi_table_header;                      FirmWareVendor:^WideChar;                      FirmWareRevision:dword;                      ConsoleInHandle:efi_handle;                      ConIn:^efi_simple_text_input_protocol;                      ConsoleOutHandle:efi_handle;                      ConOut:^efi_simple_text_output_protocol;                      StandardErrorHandle:efi_handle;                      StdErr:^efi_simple_text_output_protocol;                      RuntimeServices:^efi_runtime_services;                      bootservices:^efi_boot_services;                      numberofTableEntries:NatUint;                      configuration_table:^efi_configuration_table;                      end;When use this record such as efi_allocmem,the assembly code generated by fpc in elf files:

--- Code: ASM  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---EFI_ALLOCMEM:.Lc11:# [2879] begin        leaq    -40(%rsp),%rsp.Lc12:# Var res located at rsp+32, size=OS_64        movq    %rdi,%rdx# Var size located in register rdx# [2880] GlobalSystemTable^.BootServices^.AllocatePool(EfiLoaderData,Size,res);        leaq    32(%rsp),%r8# Var size located in register rdx        movl    $2,%ecx        movq    U_$UEFI_$$_GLOBALSYSTEMTABLE@GOTPCREL(%rip),%rax        movq    (%rax),%rax        movq    96(%rax),%rax        call    *64(%rax)# Var $result located in register rax# [2881] efi_allocmem:=res;        movq    32(%rsp),%rax# [2882] end;        leaq    40(%rsp),%rsp.Lc13:        retAnd that is assembly code in pecoff:

--- Code: ASM  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---EFI_ALLOCMEM:.Lc11:.seh_proc UEFI_$$_EFI_ALLOCMEM$QWORD$$POINTER# [2879] begin        leaq    -40(%rsp),%rsp.Lc12:.seh_stackalloc 40.seh_endprologue# Var res located at rsp+32, size=OS_64        movq    %rcx,%rdx# Var size located in register rdx# [2880] GlobalSystemTable^.BootServices^.AllocatePool(EfiLoaderData,Size,res);        leaq    32(%rsp),%r8# Var size located in register rdx        movl    $2,%ecx        movq    U_$UEFI_$$_GLOBALSYSTEMTABLE(%rip),%rax        movq    96(%rax),%rax        call    *64(%rax)# Var $result located in register rax# [2881] efi_allocmem:=res;        movq    32(%rsp),%rax# [2882] end;        nop        leaq    40(%rsp),%rsp.Lc13:        ret.seh_endproc.Lc10:Does the movq   U_$UEFI_$$_GLOBALSYSTEMTABLE(%rip),%rax and movq   U_$UEFI_$$_GLOBALSYSTEMTABLE@GOTPCREL(%rip),%rax behaves differently?

Laksen:
GOTPCREL refers to the global offset table. This is just a detail of how the target is configured. Since you are relying on the Linux or Windows target as a hack you should set it up during RTL initialization as if you were on windows or Linux

The proper fix is to create a new fpc target for UEFI with a proper RTL

TYDQ:

--- Quote from: Laksen on August 16, 2024, 11:34:23 am ---GOTPCREL refers to the global offset table. This is just a detail of how the target is configured. Since you are relying on the Linux or Windows target as a hack you should set it up during RTL initialization as if you were on windows or Linux

The proper fix is to create a new fpc target for UEFI with a proper RTL

--- End quote ---
I'm developing a software called elf2efi(elf to efi translator),I don't need an new Runtime library.
My code compile with using -n and -Xd these times.

Navigation

[0] Message Index

Go to full version