浏览代码

Author: Callum Farmer <gmbr3@opensuse.org>
Date: Tue Feb 7 21:48:27 2023 +0000

ARM32/x86_64 lds: Force data segment align to 4KiB

Some newer versions of binutils can set invalid COMMONPAGESIZE
and MAXPAGESIZE values on these architectures

git fetch git.code.sf.net/u/gmbr3/gnu-efi arm-pagesize
git merge 89d55b364d5f7fb7614e19646e06230ea90dc9c1

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>

Nigel Croxon 2 年之前
父节点
当前提交
637b3bdb9b
共有 4 个文件被更改,包括 8 次插入8 次删除
  1. 5 2
      Make.defaults
  2. 1 2
      gnuefi/elf_aarch64_efi.lds
  3. 1 2
      gnuefi/elf_arm_efi.lds
  4. 1 2
      gnuefi/elf_x86_64_efi.lds

+ 5 - 2
Make.defaults

@@ -139,7 +139,6 @@ endif
 # Set HAVE_EFI_OBJCOPY if objcopy understands --target efi-[app|bsdrv|rtdrv],
 # otherwise we need to compose the PE/COFF header using the assembler
 #
-ifneq ($(ARCH),aarch64)
 ifneq ($(ARCH),arm)
 ifneq ($(ARCH),mips64el)
 ifneq ($(ARCH),riscv64)
@@ -149,7 +148,6 @@ endif
 endif
 endif
 endif
-endif
 
 ifneq ($(ARCH),arm)
 export LIBGCC=$(shell $(CC) $(ARCH3264) -print-libgcc-file-name)
@@ -159,6 +157,11 @@ ifeq ($(ARCH),arm)
 CFLAGS += -marm
 endif
 
+ifeq ($(ARCH),aarch64)
+LDFLAGS += -z common-page-size=4096
+LDFLAGS += -z max-page-size=4096
+endif
+
 # Generic compilation flags
 INCDIR  += -I$(SRCDIR) -I$(TOPDIR)/inc -I$(TOPDIR)/inc/$(ARCH) \
            -I$(TOPDIR)/inc/protocol

+ 1 - 2
gnuefi/elf_aarch64_efi.lds

@@ -29,7 +29,7 @@ SECTIONS
   {
    *(.reloc)
   }
-  . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
+  . = ALIGN(65536);
   .dynamic  : { *(.dynamic) }
   .data :
   {
@@ -69,7 +69,6 @@ SECTIONS
   .dynstr   : { *(.dynstr) }
   . = ALIGN(4096);
   .note.gnu.build-id : { *(.note.gnu.build-id) }
-  . = DATA_SEGMENT_END (.);
   .ignored.reloc :
   {
     *(.rela.reloc)

+ 1 - 2
gnuefi/elf_arm_efi.lds

@@ -15,7 +15,7 @@ SECTIONS
   }
   _etext = .;
   _text_size = . - _text;
-  . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
+  . = ALIGN(4096);
   .dynamic  : { *(.dynamic) }
   .data :
   {
@@ -54,7 +54,6 @@ SECTIONS
   .dynstr   : { *(.dynstr) }
   . = ALIGN(4096);
   .note.gnu.build-id : { *(.note.gnu.build-id) }
-  . = DATA_SEGMENT_END (.);
   /DISCARD/ :
   {
     *(.rel.reloc)

+ 1 - 2
gnuefi/elf_x86_64_efi.lds

@@ -30,7 +30,7 @@ SECTIONS
   {
    *(.reloc)
   }
-  . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
+  . = ALIGN(4096);
   .data :
   {
    _data = .;
@@ -66,7 +66,6 @@ SECTIONS
   . = ALIGN(4096);
   .dynstr   : { *(.dynstr) }
   . = ALIGN(4096);
-  . = DATA_SEGMENT_END (.);
   .ignored.reloc :
   {
     *(.rela.reloc)