On Fri, Dec 27, 2019 at 06:24:07PM +0100, Maxime Villard wrote: > .text : AT (ADDR(.text) & 0x0fffffff) > { > + *(.multiboot) > + > . = ALIGN(__PAGE_SIZE); > __text_user_start = . ; > ... > > This guarantees that the structure is at the beginning of text.
That works. We can even make the multiboot section a note, for the sake on cleanliness. (see attached patch. MULTIBOOT is enabled for testing). > Regardless of whether it is needed in this specific case, cutting the 2MBs > of zero in the binary is wanted. Unfortunately last I looked at this (two > years ago) there were some non-obvious consequences, and it needs to be > carefully done. Any hints about the problems you encountered? Perhaps we can work it around with an . = ALIGN(__LARGEE_PAGE_SIZE); before including .text.user ? > Also, my previous remarks haven't been addressed entirely, and still stand. Sure, it's just next in the todo list. -- Emmanuel Dreyfus m...@netbsd.org
? sys/arch/amd64/compile/obj ? sys/arch/amd64/stand/prekern/obj Index: sys/arch/amd64/amd64/locore.S =================================================================== RCS file: /cvsroot/src/sys/arch/amd64/amd64/locore.S,v retrieving revision 1.195 diff -U4 -r1.195 locore.S --- sys/arch/amd64/amd64/locore.S 15 Dec 2019 02:58:21 -0000 1.195 +++ sys/arch/amd64/amd64/locore.S 28 Dec 2019 01:41:03 -0000 @@ -431,10 +431,10 @@ .size tmpstk, tmpstk - . .space 512 tmpstk: -.section multiboot,"a" #if defined(MULTIBOOT) +.section multiboot,"",@note .align 8 .globl Multiboot2_Header _C_LABEL(Multiboot2_Header): .int MULTIBOOT2_HEADER_MAGIC Index: sys/arch/amd64/conf/GENERIC =================================================================== RCS file: /cvsroot/src/sys/arch/amd64/conf/GENERIC,v retrieving revision 1.551 diff -U4 -r1.551 GENERIC --- sys/arch/amd64/conf/GENERIC 14 Dec 2019 07:45:20 -0000 1.551 +++ sys/arch/amd64/conf/GENERIC 28 Dec 2019 01:41:03 -0000 @@ -25,9 +25,9 @@ #ident "GENERIC-$Revision: 1.551 $" maxusers 64 # estimated number of users -#options MULTIBOOT # Multiboot support (see multiboot(8)) +options MULTIBOOT # Multiboot support (see multiboot(8)) # delay between "rebooting ..." message and hardware reset, in milliseconds #options CPURESET_DELAY=2000 Index: sys/arch/amd64/conf/Makefile.amd64 =================================================================== RCS file: /cvsroot/src/sys/arch/amd64/conf/Makefile.amd64,v retrieving revision 1.80 diff -U4 -r1.80 Makefile.amd64 --- sys/arch/amd64/conf/Makefile.amd64 14 Nov 2019 16:23:52 -0000 1.80 +++ sys/arch/amd64/conf/Makefile.amd64 28 Dec 2019 01:41:03 -0000 @@ -90,12 +90,12 @@ ## (5) link settings ## TEXTADDR?= 0xffffffff80200000 .if defined(KASLR) -EXTRA_LINKFLAGS= --split-by-file=0x100000 -r -d +EXTRA_LINKFLAGS= --split-by-file=0x100000 -r -d -n KERNLDSCRIPT?= ${AMD64}/conf/kern.ldscript.kaslr .else -EXTRA_LINKFLAGS= -z max-page-size=0x200000 +EXTRA_LINKFLAGS= -z max-page-size=0x200000 -n KERNLDSCRIPT?= ${AMD64}/conf/kern.ldscript .endif LINKFLAGS_NORMAL= -X Index: sys/arch/amd64/conf/kern.ldscript =================================================================== RCS file: /cvsroot/src/sys/arch/amd64/conf/kern.ldscript,v retrieving revision 1.30 diff -U4 -r1.30 kern.ldscript --- sys/arch/amd64/conf/kern.ldscript 15 Dec 2019 02:56:40 -0000 1.30 +++ sys/arch/amd64/conf/kern.ldscript 28 Dec 2019 01:41:03 -0000 @@ -12,20 +12,11 @@ ENTRY(_start) SECTIONS { - /* - * multiboot (file_offset) : AT (load_address) - * file_offset must be below 32k for multiboot 2 specification - * BIOS boot requires load_address above 0x200000 - */ - multiboot 0x1000 : AT (0x200000) + .text : AT (ADDR(.text) & 0x0fffffff) { - . = ALIGN(8); KEEP(*(multiboot)); - } - .text : AT (0x200000 + SIZEOF(multiboot)) - { . = ALIGN(__PAGE_SIZE); __text_user_start = . ; *(.text.user) . = ALIGN(__PAGE_SIZE);