summaryrefslogtreecommitdiff
path: root/elf_arm_efi.lds
AgeCommit message (Collapse)Author
2021-07-20arm/aa64: fix the size of .rela* sectionsGary Lin
The previous commit(*) merged .rel* and .dyn* into .rodata, and this made ld to generate the wrong size for .rela* sections that covered other unrelated sections. When the EFI image was loaded, _relocate() went through the unexpected data and may cause unexpected crash. This commit moves .rel* and .dyn* out of .rodata in the ld script but also moves the related variables, such as _evrodata, _rodata_size, and _rodata_vsize, to the end of the new .dyn section, so that the crafted pe-coff section header for .rodata still covers our new .rela and .dyn sections. (*) 212ba30544f ("arm/aa64 targets: put .rel* and .dyn* in .rodata") Fix issue: https://github.com/rhboot/shim/issues/371 Signed-off-by: Gary Lin <glin@suse.com>
2021-03-30arm/aa64 targets: put .rel* and .dyn* in .rodataPeter Jones
For every problem, there exists a solution which is simple, elegant, and wrong. d74629207188d290810db15dbfe91a89e7751ffb is that solution. This patch leaves that intact, but adds a .rodata section wrapping .rel/.rela and .dynsym/.dynstr., so that they are correctly incorporated into the authenticode hash. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-25arm/aa64: Swizzle some sections to make old sbsign happier.Peter Jones
xnox reports that with some versions of sbsign/sbcheck, it gets very unhappy with non-contiguous sections and gaps between sections, which we currently produce on targets with hand-coded headers. This is all wrong behavior from sbsigntools, and has been fixed in newer versions, but nevertheless it's not hard for us to avoid. This patch re-arranges the sections so there are no gaps, by padding the file-size of .data and .sbat up to the full page, moving .sbat to be before .vendor_cert, and moving .vendor_cert and .rela out of the range covered by _edata, while still leaving included in the calculation of SizeOfInitializedData. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-18arm and aarch64: include the aligned part in SizeOfRawData of sbatGary Lin
Similar to x86_64, the .sbat section is aligned to 4096, so we should include the aligned part in SizeOfRawData as objcopy does for x86_64. For VirtualSize, _sbat_vsize is used to reflect the actually size of sbat. This also fixes a strange hash mismatching in openSUSE build service when attaching signature to AArch64 EFI images from shim package. Signed-off-by: Gary Lin <glin@suse.com>
2021-03-15arm and aarch64: fix some PE headers.upstream/shim-15.3-rc2shim-15.3-rc2Peter Jones
This fixes the SizeOfImage and SizeOfInitializedData headers on arm and aa64. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-12linker scripts: put .sbat after _edataPeter Jones
Our section headers on arm binaries need to include .sbat on fallback and MokManger, and currently they do not. The reason for this is that gnu-efi provides static, (mostly) hand-coded section headers on arm and aarch64, due to having no efi-app-arm and efi-app-aa64 target support in binutils. Additionally, the assembler also generates (IMO pointless) relocations for _esbat/_sbat_size when those are actually inside the section, and relocated symbols can't be used in our section headers. This patch moves the .sbat section to be after _edata, so the sections don't overlap, and moves _esbat and _sbat_size to be after the section, to avoid the relocation. I'm not 100% sure we can't have overlapping sections, but now doesn't seem like the time to find out. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-12efi bins: add an easy way for vendors to add .sbat dataPeter Jones
In cases where we accept vendor shim binaries with additional patches, it may become necessary to identify those builds with additional SBAT data. When we consider such patches, we should be proactive in asking vendors to include that data in the .sbat sections of their trusted EFI binaries. This patch adds any data in data/sbat.*.csv (after a quick sanitizing pass) after data/sbat.csv in the .sbat section, so that no changes to the upstream data/sbat.csv are ever required. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-12Add a .sbat section to EFI binariesJavier Martinez Canillas
The Secure Boot Advanced Targeting (SBAT) [0] is a Generation Number Based Revocation mechanism that is meant to replace the DBX revocation file list. Binaries must contain a .sbat data section that has a set entries, each of them consisting of UTF-8 strings as comma separated values. Allow to embed this information into the fwupd EFI binary at build time. The SBAT metadata must contain at least two entries. One that defines the SBAT version used and another one that defines the component generation. This patch adds a sbat.csv that contains these two entries and downstream users can override if additional entries are needed due changes that make them diverge from upstream code and potentially add other vulnerabilities. The same SBAT metadata is added to the fallback and MOK manager binaries because these are built from the same shim source. These need to have SBAT metadata as well to be booted if a .sbat section is mandatory. [0]: https://github.com/rhboot/shim/blob/sbat/SBAT.md Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2017-04-26Don't allow anything with a small alignment in our PE files.Peter Jones
When I added 4990d3f I inadvertantly made .data.ident and .rela.got sections appear in the top-level section headers at file offsets not aligned with PE->OptionalHeader.FileAlignment. This results in a section table that looks like: Sections: Idx Name Size VMA LMA File off Algn 0 .eh_frame 00018648 0000000000005000 0000000000005000 00000400 2**3 CONTENTS, ALLOC, LOAD, READONLY, DATA 1 .text 00093f45 000000000001e000 000000000001e000 00018c00 2**4 CONTENTS, ALLOC, LOAD, READONLY, CODE 2 .reloc 0000000a 00000000000b2000 00000000000b2000 000acc00 2**0 CONTENTS, ALLOC, LOAD, READONLY, DATA 3 .data.ident 000000e4 00000000000b3040 00000000000b3040 000ace40 2**5 CONTENTS, ALLOC, LOAD, DATA 4 .data 000291e8 00000000000b4000 00000000000b4000 000ad200 2**5 CONTENTS, ALLOC, LOAD, DATA 5 .vendor_cert 000003e2 00000000000de000 00000000000de000 000d6400 2**0 CONTENTS, ALLOC, LOAD, READONLY, DATA 6 .dynamic 000000f0 00000000000df000 00000000000df000 000d6800 2**3 CONTENTS, ALLOC, LOAD, DATA 7 .rela 0001aef8 00000000000e0000 00000000000e0000 000d6a00 2**3 CONTENTS, ALLOC, LOAD, READONLY, DATA 8 .rela.got 00000060 00000000000faef8 00000000000faef8 000f1af8 2**3 CONTENTS, ALLOC, LOAD, READONLY, DATA 9 .dynsym 0000ecd0 00000000000fb000 00000000000fb000 000f1e00 2**3 CONTENTS, ALLOC, LOAD, READONLY, DATA rather than: Sections: Idx Name Size VMA LMA File off Algn 0 .eh_frame 00018118 0000000000005000 0000000000005000 00000400 2**3 CONTENTS, ALLOC, LOAD, READONLY, DATA 1 .text 00091898 000000000001e000 000000000001e000 00018600 2**4 CONTENTS, ALLOC, LOAD, READONLY, CODE 2 .reloc 0000000a 00000000000b0000 00000000000b0000 000aa000 2**0 CONTENTS, ALLOC, LOAD, READONLY, DATA 3 .data 00028848 00000000000b1000 00000000000b1000 000aa200 2**5 CONTENTS, ALLOC, LOAD, DATA 4 .vendor_cert 00000449 00000000000da000 00000000000da000 000d2c00 2**0 CONTENTS, ALLOC, LOAD, READONLY, DATA 5 .dynamic 00000100 00000000000db000 00000000000db000 000d3200 2**3 CONTENTS, ALLOC, LOAD, DATA 6 .rela 0001ae50 00000000000dc000 00000000000dc000 000d3400 2**3 CONTENTS, ALLOC, LOAD, READONLY, DATA 7 .dynsym 0000ea78 00000000000f7000 00000000000f7000 000ee400 2**3 CONTENTS, ALLOC, LOAD, READONLY, DATA (Note "File off" on sections #3 and #8 on the top one.) This seems to work fine with edk2's loader and shim's loader, as well as their Authenticode implementation, and pesign's as well. While PE loaders seem to be fine with sections with alignments smaller than PE->OptionalHeader.FileAlignment, MS's signtool.exe does ... something else with them. I'm not sure what. What it definitely does *not* do is extend the digest based on their file offset and size. So just don't allow anything that small, and don't allow anything smaller than SectionAlignment either, just to be on the safe side. Since most of our stuff gets stripped into the debuginfo anyway, and shim has relatively few sections, this should not be a very large burden. So just to be clear: If you have a binary with a section that's not aligned on PE->OptionalHeader.FileAlignment: - pesign hashes it to A - tiano hashes it to A - shim hashes it to A - signtool.exe hashes it to B Because that makes sense. This patch works around the bug in signtool.exe . Signed-off-by: Peter Jones <pjones@redhat.com>
2017-02-23Make shim_version live in a special aligned section.Peter Jones
This makes it so two builds of the same .deb on different hosts won't have wildly different file offsets. Signed-off-by: Peter Jones <pjones@redhat.com>
2015-06-29Make sure our build-id notes wind up at a reasonable place.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2015-06-29Add a conditional point for a debugger to attach.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2014-08-27Fix typo from Ard's old tree 32-bit ARM patch.Peter Jones
We don't need to .data entries; the second one should be .data*. He's since fixed this in his tree, but I'd already pulled it and pushed to master. Signed-off-by: Peter Jones <pjones@redhat.com>
2014-08-12Add support for 32-bit ARMArd Biesheuvel
This adds support for building the shim for a 32-bit ARM UEFI environment. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>