ebc825b549
Some versions of gcc include a plugin called "annobin", and in some build systems this is enabled by default. This plugin creates special ELF note sections to track which ABI-breaking features are used by a binary, as well as a series of relocations to annotate where. If grub is compiled with this feature, then when grub-mkimage translates the binary to another file format which does not strongly associate relocation data with sections (i.e. when platform is *-efi), these relocations appear to be against the .text section rather than the original note section. When the binary is loaded by the PE runtime loader, hilarity ensues. This issue is not necessarily limited to the annobin, but could arise any time there are relocations in sections that are not represented in grub-mkimage's output. This patch seeks to avoid this issue by only including relocations that refer to sections which will be included in the final binary. As an aside, this should also obviate the need to avoid -funwind-tables, -fasynchronous-unwind-tables, and any sections similar to .eh_frame in the future. I've tested it on x86-64-efi with the following gcc command line options (as recorded by -grecord-gcc-flags), but I still need to test the result on some other platforms that have been problematic in the past (especially ARM Aarch64) before I feel comfortable making changes to the configure.ac bits: GNU C11 7.2.1 20180116 (Red Hat 7.2.1-7) -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow -msoft-float -mno-stack-arg-probe -mcmodel=large -mno-red-zone -m64 -mtune=generic -march=x86-64 -g3 -Os -freg-struct-return -fno-stack-protector -ffreestanding -funwind-tables -fasynchronous-unwind-tables -fno-strict-aliasing -fstack-clash-protection -fno-ident -fplugin=annobin Signed-off-by: Peter Jones <pjones@redhat.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> |
||
---|---|---|
.. | ||
bash-completion.d | ||
grub.d | ||
i386/efi | ||
ieee1275 | ||
bin2h.c | ||
config.c | ||
editenv.c | ||
garbage-gen.c | ||
getroot.c | ||
glue-efi.c | ||
grub-editenv.c | ||
grub-file.c | ||
grub-fstest.c | ||
grub-gen-asciih.c | ||
grub-gen-widthspec.c | ||
grub-glue-efi.c | ||
grub-install-common.c | ||
grub-install.c | ||
grub-kbdcomp.in | ||
grub-macbless.c | ||
grub-macho2img.c | ||
grub-menulst2cfg.c | ||
grub-mkconfig.in | ||
grub-mkconfig_lib.in | ||
grub-mkfont.c | ||
grub-mkimage.c | ||
grub-mkimage32.c | ||
grub-mkimage64.c | ||
grub-mkimagexx.c | ||
grub-mklayout.c | ||
grub-mknetdir.c | ||
grub-mkpasswd-pbkdf2.c | ||
grub-mkrelpath.c | ||
grub-mkrescue.c | ||
grub-mkstandalone.c | ||
grub-module-verifier.c | ||
grub-module-verifier32.c | ||
grub-module-verifier64.c | ||
grub-module-verifierXX.c | ||
grub-mount.c | ||
grub-pe2elf.c | ||
grub-probe.c | ||
grub-reboot.in | ||
grub-render-label.c | ||
grub-script-check.c | ||
grub-set-default.in | ||
grub-setup.c | ||
grub-syslinux2cfg.c | ||
import_gcry.py | ||
import_gcrypth.sed | ||
import_unicode.py | ||
misc.c | ||
mkimage.c | ||
probe.c | ||
render-label.c | ||
resolve.c | ||
setup.c | ||
setup_bios.c | ||
setup_sparc.c | ||
spkmodem-recv.c |