-
Notifications
You must be signed in to change notification settings - Fork 332
Aarch64: make section alignment larger #781
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
Open
vathpela
wants to merge
7
commits into
rhboot:main
Choose a base branch
from
vathpela:m2549
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This fixes a case where we're not handling getopt_long()'s return value properly. Signed-off-by: Peter Jones <pjones@redhat.com>
This moves FileAlignment from being a local in load_pe() to being in the PE context header, so that later functions can more easily access it. Signed-off-by: Peter Jones <pjones@redhat.com>
This adds some debug information and a test that FileAlignment is compatible with PAGE_SIZE to the validate_nx_compat() function. Signed-off-by: Peter Jones <pjones@redhat.com>
In validate_nx_compat() we're testing SectionAlignment against our 4kB page size, but the requirement is actually only that it should be a multiple of it. This tests for that instead. Signed-off-by: Peter Jones <pjones@redhat.com>
This adds a test to verify_nx_compat() to check if section VMAs are aligned with our PE header's SectionAlignment. Signed-off-by: Peter Jones <pjones@redhat.com>
This changes our linking to have a per-arch section alignment and apply it when we link. Note that this will produce incorrect results if the alignment used in the linker scripts do not match. Signed-off-by: Peter Jones <pjones@redhat.com>
In UEFI Mantis 2549, ARM proposes to recommend 64kB section alignment in
UEFI binaries. The reason for this is that some machines may be
configured to have no pages smaller than 64kB for performance reasons,
and in such a scenario things like W^X will be impossible to correctly
implement on binaries where one section ends and another begins on the
same 64kB page.
This change makes aarch64 binaries use a 64kB rather than 4kB section
alignment. Note that this only actually changes virtual addresses, not
file addresses, so the size is unchanged:
Before:
SectionAlignment 00001000
FileAlignment 00001000
Sections:
Idx Name Size VMA LMA File off Algn
0 .eh_frame 00018c64 0000000000005000 0000000000005000 00001000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .text 0006bd9c 000000000001e000 000000000001e000 0001a000 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .reloc 0000000a 000000000008a000 000000000008a000 00086000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .data.ident 00000088 000000000008c000 000000000008c000 00087000 2**2
CONTENTS, ALLOC, LOAD, DATA
4 .sbatlevel 0000006c 000000000008d000 000000000008d000 00088000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .data 0002f268 000000000008e000 000000000008e000 00089000 2**2
CONTENTS, ALLOC, LOAD, DATA
6 .vendor_cert 00000010 00000000000be000 00000000000be000 000b9000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
7 .dynamic 000000f0 00000000000bf000 00000000000bf000 000ba000 2**2
CONTENTS, ALLOC, LOAD, DATA
8 .rela 0001d760 00000000000c0000 00000000000c0000 000bb000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
9 .sbat 00000083 00000000000de000 00000000000de000 000d9000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
$ /bin/ls -l shimaa64.efi
-rwxr-xr-x. 1 pjones pjones 1036357 Oct 28 13:34 shimaa64.efi
After:
SectionAlignment 00010000
FileAlignment 00001000
Sections:
Idx Name Size VMA LMA File off Algn
0 .eh_frame 00018c64 0000000000010000 0000000000010000 00001000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .text 0006bd9c 0000000000030000 0000000000030000 0001a000 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .reloc 0000000a 00000000000a0000 00000000000a0000 00086000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .data.ident 00000088 00000000000c0000 00000000000c0000 00087000 2**2
CONTENTS, ALLOC, LOAD, DATA
4 .sbatlevel 0000006c 00000000000d0000 00000000000d0000 00088000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .data 0002f268 00000000000e0000 00000000000e0000 00089000 2**2
CONTENTS, ALLOC, LOAD, DATA
6 .vendor_cert 00000010 0000000000110000 0000000000110000 000b9000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
7 .dynamic 000000f0 0000000000120000 0000000000120000 000ba000 2**2
CONTENTS, ALLOC, LOAD, DATA
8 .rela 0001d760 0000000000130000 0000000000130000 000bb000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
9 .sbat 00000083 0000000000150000 0000000000150000 000d9000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
$ /bin/ls -l shimaa64.efi
-rwxr-xr-x. 1 pjones pjones 1036357 Oct 28 13:18 shimaa64.efi
On my test machine, that changes the text and data load addresses (both
physical and virtual, we're still on a 1:1 map) as follows:
Before: _text:0x0000000092FF7000 _data:0x0000000093067000
After: _text:0x0000000092F80000 _data:0x0000000093030000
Signed-off-by: Peter Jones <pjones@redhat.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In UEFI Mantis 2549, ARM proposes to recommend 64kB section alignment in
UEFI binaries. The reason for this is that some machines may be
configured to have no pages smaller than 64kB for performance reasons,
and in such a scenario things like W^X will be impossible to correctly
implement on binaries where one section ends and another begins on the
same 64kB page.
This change makes aarch64 binaries use a 64kB rather than 4kB section
alignment. Note that this only actually changes virtual addresses, not
file addresses, so the size is unchanged.
FWIW I ran this by ardb and he said it looks sane to him.