Page MenuHomeFreeBSD

Fix UEFI support for ARM
ClosedPublic

Authored by gonzo on Jan 9 2017, 7:52 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sep 26 2024, 9:22 AM
Unknown Object (File)
Sep 18 2024, 5:29 AM
Unknown Object (File)
Sep 17 2024, 4:06 AM
Unknown Object (File)
Sep 8 2024, 5:14 PM
Unknown Object (File)
Aug 31 2024, 4:53 PM
Unknown Object (File)
Aug 18 2024, 10:33 PM
Unknown Object (File)
Aug 18 2024, 5:58 PM
Unknown Object (File)
Aug 3 2024, 9:22 PM
Subscribers

Details

Summary

ARM UEFI support is borken on clang 3.9.0 because for two reasons:

  • without -fPIC clang generates abosulte jump tables for switch statement
  • ldscript merges .rel.data.rel.ro into .data section, so some relocations are lost in final binary (boot1.sym.full)
Test Plan

boot QEMU VIRT kernel using EFI

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 6669
Build 6887: arc lint + arc unit

Event Timeline

gonzo retitled this revision from to Fix UEFI support for ARM.
gonzo updated this object.
gonzo edited the test plan for this revision. (Show Details)
gonzo added a reviewer: andrew.
sys/boot/efi/boot1/Makefile
73

Do we need this in the loader.efi Makefile? If so it should be moved to sys/boot/efi/Makefile.inc

sys/boot/efi/loader/bootinfo.c
354–368

Is this intentional?

sys/boot/efi/boot1/Makefile
73

I assume that it's required. But I will check

sys/boot/efi/loader/bootinfo.c
354–368

Yes. Without this change relocation happens twice. I think previously it wasn't relocated because .rel.data.rel.ro was merged into .data and that relocations were lost. With fixed ldscript these values relocated EFI loader.

sys/boot/efi/loader/bootinfo.c
354–368

On arm when building for EFI __elfN(relocation_offset) is set to 0 so this code should have been a nop. If it is now non-zero that would indicate a bug somewhere that this is picking up.

Remove unnecessary -fPIC and also fix one-off error in .bss zeroing code

Move -fPIC to proper location

  • -fPIC is required by loader.efi so I moved the flag to proper location
  • the relocation_offset bug was due to off-by-one error in .bss zeroing routine. It wrote zero to __bss_end which AFAIU should be excluded from range. That address was actually entry for elf32_relocation_offset in offset table.
andrew edited edge metadata.

Looks good, although it might pay to split into a few commits. We should also look at removing relocation_offset from the EFI code in a follow up.

This revision is now accepted and ready to land.Jan 10 2017, 9:25 AM
This revision was automatically updated to reflect the committed changes.