-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Aa64 fixes #6
base: rawhide
Are you sure you want to change the base?
Aa64 fixes #6
Conversation
Note.. the UEFI spec does say that for aarch64:
So in theory, 4k is mandated as base page size for EFI binary and thus -DPAGE_SIZE is correct. That means that in theory (again), What do you reckon ? My patch still acts as a workaround... |
So... we have two issues it seems :-) Passing |
Without the change there is no guarantee that .o files will be built after directories are created for them and build fails as: gcc -I/build/gnu-efi-code//lib ... -c lib/runtime/rtstr.c -o runtime/rtstr.o Assembler messages: Fatal error: can't create runtime/rtstr.o: No such file or directory (cherry picked from commit 2ed6486)
binutils-2.39 enabed a few warning by default (https://sourceware.org/pipermail/binutils/2022-August/122246.html): > The ELF linker will now generate a warning message if the stack is made executable. Let's suppress the warnings in assembly files by adding non-executables stack markings. This fixes at least systemd build which uses '-Wl,--fatal-warnings': systemd/systemd#24226 (cherry picked from commit 803b49c)
The assembly code uses fixed offsets into the jmp_buf and leaves an 8 byte gap between the GPRs and the FPRs, but the jmp_buf structure was not laid out to account for this so the code would overrun the jmp_buf by 8 bytes. Found-by: Oskar Engen <[email protected]> Signed-off-by: Dwight Engen <[email protected]> (cherry picked from commit 4a566dd)
Fix link with binutils 2.39 Signed-off-by: Benjamin Herrenschmidt <[email protected]>
Allright, I've updated the PR. This time, I add 4 patches instead of the 2 mentioned earlier:
|
There packages might need fixing for the
|
|
Otherwise it gets blended with .text causing the linker to create a RWX segment, which is bad and causes a fatal warning with newer binutils Signed-off-by: Benjamin Herrenschmidt <[email protected]>
All our lds assume a 4k alignment. Without this, on archs like aarch64 where the linker may assume a larger page size (64k), gnu ld will end up merging .text and .data sections into the same segment. This results in the segment being RWX which will cause a fatal warning (and is a bad thing anyways) Signed-off-by: Benjamin Herrenschmidt <[email protected]>
This follows the change to apps Signed-off-by: Benjamin Herrenschmidt <[email protected]>
LIttle fixup, let's not move .dynamic completely outside of the PE section definition, keep it in the data one. BTW. Why do we keep those dynamic reloc sections around in the final PE ? I though they would be only useful if an ELF linker was interested in the object which ... won't happen. Or am I missing something subtle here ? |
Align RTLIB CopyMem/SetMem with normal versions
These are three backports cherry-picked from a newer upstream (you can drop them if you rebase) and two fixes I added.
WARNING: The second fix might be controversial or might require further changes, see below:
The issue with alignement is that the new binutils assume a 64k alignemnt for aarch64 by default. But the gnu-efi provided .lds doesn't align sections properly (.dynamic isn't aligned at all and it uses 4k for .data), so ld ends up putting everything in the same segment which ends up RWE which the new ld barfs about (and is a bad idea anyways).
Now, It can be overriden from the command line, so one solution would be to fix any user of gnu-efi (and the bundled magic Makefile fragments that Peter conveniently added but aren't upstream) to pass
-z max-page-size=4096
. That would have to be added to things like systemd-boot I suspect and possibly others.The approach I chose instead (patch also sent to upstream gnu-efi mailing list without feedback so far) is to change the .lds to align everything to 64k on aa64.
HOWEVER: I just noticed that the .mk fragments that Fedora provides (not upstream) explicitely pass -DPAGE_SIZE=4096 -DPAGE_SHIFT=12 .. .that will probably need fixing, so that PR is incomplete, but I want to start the discussion (I'll send a fix for that later).
Is this the approach we want to take ? Or did I miss a bit of spec that says that EFI on aa64 only supports 4k pages ? using
-z max-page-size
is inconvenient as it can't be self contained in the .lds ...