Re: Haiku's ARM efi bootloader


Alexander von Gluck IV
 

July 5, 2020 6:39 PM, "valerij zaporogeci" <vlrzprgts@gmail.com> wrote:

base is BC570000, abort PC is BC570D34. take you "fake" PE and look at
the offset of D34 (or 0xD34 - 0x138 from the .text), what it does.
it's hard to say, it can be anything. it's a broken image, what do you
expect? it's 32 bit ARM and not a single relocation? really? you do
have .data section? so, say, there is some variable X in the data
section. your code references it, and, on 32 bit ARM literal pool
pointers are accessed a PC relative way, but the pointer to X itself
is NOT. where the relocation for it? it's NULL. here, enough reason to
abort, - dereferencing inaccessible address.

.text
LDR r6, [pc, #(LP_X - . - 8)] @ this way r6, holds X address and
can reference it
...
LiteralPool @ it's inside .text section
LP_X: .long X @ X resides inside .data, and LP_X holds its address,
@ it's a subject for base relocations
Thanks! We actually figured it out, just missing our .reloc sections.

virtual size of text section is LESS than the size of raw data...
section alignment is 0x20. why?

using appropriate compilers could save you from getting "desperate".
gnu-efi does it this way because of the *really* inconsistent support in
binutils bfd.

Things seem to be getting a bit better, but documentation is pretty poor
still.

For anyone reading this, semi-recent versions of binutils now support Pe
EFI binaries as long as the Pe target formats are enabled.

objcopy --output-target=pei-x86-64 --subsystem efi-app ...
objcopy --output-target=pei-arm --subsystem efi-app ...

This stuff doesn't seem documented *anywhere*, and everyone is using the
"outdated" efi-app-x86_64 output target.


Maybe tianocore/edk2 should document some real world tool chain examples
generating efi bootloaders? ipxe has literally written their own elf2efi
conversion application due to the inconsistent support and poor documentation.

"fake" PE... it's no wonder it works this way.
There are also no alternatives for aarch64. binutils bfd doesn't have any
code to support Pe aarch64.

-- Alex

Join discuss@edk2.groups.io to automatically receive all group messages.