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)
Mar 8 2024, 6:25 PM
Unknown Object (File)
Dec 22 2023, 12:02 PM
Unknown Object (File)
Dec 22 2023, 12:01 PM
Unknown Object (File)
Dec 20 2023, 12:50 AM
Unknown Object (File)
Nov 6 2023, 10:33 AM
Unknown Object (File)
Oct 5 2023, 9:31 AM
Unknown Object (File)
Aug 19 2023, 8:36 PM
Unknown Object (File)
Jul 21 2023, 9:19 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 Not Applicable
Unit
Tests Not Applicable

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 ↗(On Diff #23791)

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 ↗(On Diff #23791)

Is this intentional?

sys/boot/efi/boot1/Makefile
73 ↗(On Diff #23791)

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

sys/boot/efi/loader/bootinfo.c
354–368 ↗(On Diff #23791)

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 Diff #23791)

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.