Opened 5 years ago

Last modified 5 years ago

#15673 new bug

.bss segment ends up in EFI bootloader binary

Reported by: pulkomandy Owned by: nobody
Priority: low Milestone: Unscheduled
Component: System/Boot Loader/EFI Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

For debugging of the EFI loader we added a static 16K buffer for storage of logs (as is done in the BIOS loader). This buffer is not initialized so it should be in the .bss section (to be cleared at program initialization). However we found out that the generated EFI file became larger according to the size of the buffer.

This likely means the BSS segments are included inside the binary, and we end up with a larger than needed loader, filled with zeros.

We should review the linker scripts and conversion to PE format to make sure the bss segment is not included in the binary, and if needed, add the startup code to allocate and clear it.

Change History (6)

comment:1 by pulkomandy, 5 years ago

Component: System/Boot LoaderSystem/Boot Loader/EFI

comment:2 by tqh, 5 years ago

We probably want to compare FreeBSD and Fuchsia linker scripts. Not sure if we still use the one I derived from FreeBSD. Not assigning to me, since I am not an expert on linker script, but I can I help.

Also EFI firmware are kind of picky on file layout :(

comment:3 by pulkomandy, 5 years ago

Untested change: https://review.haiku-os.org/c/haiku/+/2199

Indeed the .bss is packed together with the .data in FreeBSD, I'm not sure why. We should check that this works (no EFI machine at hand at the moment).

comment:5 by tqh, 5 years ago

It seems you can have a .bss section. You just need to zero it as that is usually done by crt0?

https://lists.denx.de/pipermail/u-boot/2018-October/344268.html

comment:6 by pulkomandy, 5 years ago

Yes, that's exactly what I did in the change linked above.

Note: See TracTickets for help on using tickets.