x86: use ELF notes and unified linker script
cover x86: use ELF notes and unified linker script
Wei Liu (3):
Introduce asm_macros.h
x86: switch to use elfnote
x86: use unified linker script
.gitignore | 1 + Makefile | 6 +- arch/x86/Makefile | 1 + arch/x86/minios-x86.lds.S | 133 +++++++++++++++++++++++++++++++++++++++++++++ arch/x86/minios-x86_32.lds | 74 ------------------------- arch/x86/minios-x86_64.lds | 74 ------------------------- arch/x86/x86_32.S | 17 +++--- arch/x86/x86_64.S | 15 ++--- include/arm/asm_macros.h | 14 +++++ include/asm_macros.h | 40 ++++++++++++++ include/x86/asm_macros.h | 28 ++++++++++ 11 files changed, 235 insertions(+), 168 deletions(-) create mode 100644 arch/x86/minios-x86.lds.S delete mode 100644 arch/x86/minios-x86_32.lds delete mode 100644 arch/x86/minios-x86_64.lds create mode 100644 include/arm/asm_macros.h create mode 100644 include/asm_macros.h create mode 100644 include/x86/asm_macros.h
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 1/3 Introduce asm_macros.h
Ported from Xen Test Framework project (BSD license).
---
v2: Provide a stub for ARM
--- include/arm/asm_macros.h | 14 ++++++++++++++ include/asm_macros.h | 40 ++++++++++++++++++++++++++++++++++++++++ include/x86/asm_macros.h | 28 ++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 include/arm/asm_macros.h create mode 100644 include/asm_macros.h create mode 100644 include/x86/asm_macros.h
include/arm/asm_macros.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef _ARM_ASM_MACRO_H_ +#define _ARM_ASM_MACRO_H_ + +#endif /* _ARM_ASM_MACRO_H_ */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
include/asm_macros.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Macros for assembly files. +*/ + +#ifndef _ASM_MACRO_H_ +#define _ASM_MACRO_H_ + +#if defined(__i386__) || defined(__x86_64__) +#include <x86/asm_macros.h> +#elif defined(__arm__) || defined(__aarch64__) +#include <arm/asm_macros.h> +#endif + +#ifdef __ASSEMBLY__ + +#define ELFNOTE(name, type, desc) \ + .pushsection .note.name ; \ + .align 4 ; \ + .long 2f - 1f /* namesz */ ; \ + .long 4f - 3f /* descsz */ ; \ + .long type /* type */ ; \ +1:.asciz #name /* name */ ; \ +2:.align 4 ; \ +3:desc/* desc */ ; \ +4:.align 4 ; \ + .popsection + +#endif /* __ASSEMBLY__ */ + +#endif /* _ASM_MACRO_H_ */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
include/x86/asm_macros.h new file +28 -0
@@ -0,0 +1,28 @@ +#ifndef _X86_ASM_MACRO_H_ +#define _X86_ASM_MACRO_H_ + +#ifdef __ASSEMBLY__ +# if defined(__x86_64__) +# define _WORD .quad +# elif defined(__i386__) +# define _WORD .long +# endif +#else +# if defined(__x86_64__) +# define _WORD ".quad" +# elif defined(__i386__) +# define _WORD ".long" +# endif +#endif + +#endif /* _X86_ASM_MACRO_H_ */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [MINIOS PATCH 1/3] Introduce asm_macros.h
Quoted 3 lines · Wei Liu
Ported from Xen Test Framework project (BSD license).
Signed-off-by Wei Liu <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Samuel Thibault
Acked-byRe: [MINIOS PATCH 1/3] Introduce asm_macros.h
Quoted 6 lines · Juergen Gross, on Thu 18 Aug 2016 12:34:48 +0200, wrote:
Quoted 3 lines · Wei Liu
Ported from Xen Test Framework project (BSD license).
Signed-off-by Wei Liu <[email protected]>Reviewed-by Juergen Gross <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 2/3 x86: switch to use elfnote
In reply to Wei LiuUse the newer ELF note interface. The generated ELF notes results in equivalent configuration.
Also need to modify linker script to provide a note section.
--- arch/x86/minios-x86_32.lds | 4 ++++ arch/x86/minios-x86_64.lds | 4 ++++ arch/x86/x86_32.S | 17 +++++++---------- arch/x86/x86_64.S | 15 ++++++--------- 4 files changed, 21 insertions(+), 19 deletions(-)
arch/x86/minios-x86_32.lds +4 -0
@@ -15,6 +15,10 @@ SECTIONS .rodata : { *(.rodata) *(.rodata.*) } . = ALIGN(4096); _erodata = .; + .note : { + *(.note) + *(.note.*) + } /* newlib initialization functions */ . = ALIGN(32 / 8);
arch/x86/minios-x86_64.lds +4 -0
@@ -15,6 +15,10 @@ SECTIONS .rodata : { *(.rodata) *(.rodata.*) } . = ALIGN(4096); _erodata = .; + .note : { + *(.note) + *(.note.*) + } /* newlib initialization functions */ . = ALIGN(64 / 8);
arch/x86/x86_32.S +7 -10
@@ -1,17 +1,14 @@ #include <mini-os/os.h> #include <mini-os/x86/arch_limits.h> +#include <mini-os/asm_macros.h> +#include <xen/elfnote.h> #include <xen/arch-x86_32.h> -.section __xen_guest - .ascii "GUEST_OS=Mini-OS" - .ascii ",XEN_VER=xen-3.0" - .ascii ",VIRT_BASE=0x0" /* &_text from minios_x86_32.lds */ - .ascii ",ELF_PADDR_OFFSET=0x0" - .ascii ",HYPERCALL_PAGE=0x2" - .ascii ",PAE=yes[extended-cr3]" - .ascii ",LOADER=generic" - .byte 0 -.text +ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "Mini-OS") +ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic") +ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _WORD hypercall_page) +ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0") +ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz "yes") .globl _start, shared_info, hypercall_page
arch/x86/x86_64.S +6 -9
@@ -1,16 +1,13 @@ #include <mini-os/os.h> #include <mini-os/x86/arch_limits.h> +#include <mini-os/asm_macros.h> +#include <xen/elfnote.h> #include <xen/features.h> -.section __xen_guest - .ascii "GUEST_OS=Mini-OS" - .ascii ",XEN_VER=xen-3.0" - .ascii ",VIRT_BASE=0x0" /* &_text from minios_x86_64.lds */ - .ascii ",ELF_PADDR_OFFSET=0x0" - .ascii ",HYPERCALL_PAGE=0x2" - .ascii ",LOADER=generic" - .byte 0 -.text +ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "Mini-OS") +ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic") +ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _WORD hypercall_page) +ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0") #define ENTRY(X) .globl X ; X : .globl _start, shared_info, hypercall_page
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [MINIOS PATCH 2/3] x86: switch to use elfnote
Quoted 7 lines · Wei Liu, on Thu 18 Aug 2016 11:15:25 +0100, wrote:
Use the newer ELF note interface. The generated ELF notes results in equivalent configuration.
Also need to modify linker script to provide a note section.
Signed-off-by Wei Liu <[email protected]>Reviewed-by Juergen Gross <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 3/3 x86: use unified linker script
In reply to Wei LiuThere are only a few differences between i386 and x86-64 linker scripts. Unify them into one. Re-indent the file at the same time.
Construct a special rule in top-level directory to cope with the change. Ideally the build system should also be made more elegant, but overhauling the build system is out of scope of this patch.
---
v2:
1. fix one typo in code
2. use single-parameter form of OUTPUT_FORMAT
--- .gitignore | 1 + Makefile | 6 +- arch/x86/Makefile | 1 + arch/x86/minios-x86.lds.S | 133 +++++++++++++++++++++++++++++++++++++++++++++ arch/x86/minios-x86_32.lds | 78 -------------------------- arch/x86/minios-x86_64.lds | 78 -------------------------- 6 files changed, 140 insertions(+), 157 deletions(-) create mode 100644 arch/x86/minios-x86.lds.S delete mode 100644 arch/x86/minios-x86_32.lds delete mode 100644 arch/x86/minios-x86_64.lds
.gitignore +1 -0
@@ -2,6 +2,7 @@ *.o *.a *.swp +arch/x86/minios-x86*.lds include/list.h mini-os mini-os.gz
Makefile +5 -1
@@ -148,7 +148,11 @@ ifneq ($(APP_OBJS),) APP_O=$(OBJ_DIR)/$(TARGET)_app.o endif -$(OBJ_DIR)/$(TARGET): $(OBJS) $(APP_O) arch_lib +# Special rule for x86 for now +arch/x86/minios-x86%.lds: arch/x86/minios-x86.lds.S + $(CPP) $(ASFLAGS) -P $< -o $@ + +$(OBJ_DIR)/$(TARGET): $(OBJS) $(APP_O) arch_lib $(TARGET_ARCH_DIR)/minios-$(MINIOS_TARGET_ARCH).lds $(LD) -r $(LDFLAGS) $(HEAD_OBJ) $(APP_O) $(OBJS) $(LDARCHLIB) $(LDLIBS) -o [email protected] $(OBJCOPY) -w -G $(GLOBAL_PREFIX)* -G _start [email protected] [email protected] $(LD) $(LDFLAGS) $(LDFLAGS_FINAL) [email protected] $(EXTRA_OBJS) -o $@
arch/x86/Makefile +1 -0
@@ -24,4 +24,5 @@ $(OBJ_DIR)/$(ARCH_LIB): $(ARCH_OBJS) $(OBJ_DIR)/$(HEAD_ARCH_OBJ) clean: rm -f $(OBJ_DIR)/$(ARCH_LIB) $(ARCH_OBJS) $(OBJ_DIR)/$(HEAD_ARCH_OBJ) + rm -f minios-x86_32.lds minios-x86_64.lds
arch/x86/minios-x86.lds.S new file +133 -0
133 lines not on this page · raw message
arch/x86/minios-x86_32.lds deleted +0 -78
78 lines not on this page · raw message
arch/x86/minios-x86_64.lds deleted +0 -78
78 lines not on this page · raw message
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [MINIOS PATCH 3/3] x86: use unified linker script
Quoted 8 lines · Wei Liu
There are only a few differences between i386 and x86-64 linker scripts. Unify them into one. Re-indent the file at the same time.
Construct a special rule in top-level directory to cope with the change. Ideally the build system should also be made more elegant, but overhauling the build system is out of scope of this patch.
Signed-off-by Wei Liu <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Samuel Thibault
Acked-byRe: [MINIOS PATCH 3/3] x86: use unified linker script
Quoted 11 lines · Juergen Gross, on Thu 18 Aug 2016 12:39:00 +0200, wrote:
Quoted 8 lines · Wei Liu
There are only a few differences between i386 and x86-64 linker scripts. Unify them into one. Re-indent the file at the same time.
Construct a special rule in top-level directory to cope with the change. Ideally the build system should also be made more elegant, but overhauling the build system is out of scope of this patch.
Signed-off-by Wei Liu <[email protected]>Reviewed-by Juergen Gross <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 4 lines · Wei Liu
Wei Liu (3):
Introduceasm_macros.h
x86: switch to use elfnote
x86: use unified linker script
All three Reviewed-by: Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 5 lines · Wei Liu
Wei Liu (3):
Introduceasm_macros.h
x86: switch to use elfnote
x86: use unified linker script
Series pushed.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel