[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v2 16/62] x86/link: Relocate program headers



From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

When the xen binary is loaded by libelf (in the future) we rely on the
elf loader to load the binary accordingly. Specify the load address so
that the resulting binary can make p_vaddr and p_paddr have different
values.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
v2:
Clarify commit message. Haven't tested grub1 boot.
---
 xen/arch/x86/xen.lds.S | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index 6164ad094f..400d8a56c4 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -13,6 +13,7 @@
 #undef __XEN_VIRT_START
 #define __XEN_VIRT_START __image_base__
 #define SECTION_ALIGN MB(2)
+#define DECL_SECTION(x) x :
 
 ENTRY(efi_start)
 
@@ -20,8 +21,9 @@ ENTRY(efi_start)
 
 #define FORMAT "elf64-x86-64"
 #define SECTION_ALIGN PAGE_SIZE
+#define DECL_SECTION(x) x : AT(ADDR(x) - __XEN_VIRT_START)
 
-ENTRY(start)
+ENTRY(start_pa)
 
 #endif /* EFI */
 
@@ -56,9 +58,11 @@ SECTIONS
   __2M_text_start = .;         /* Start of 2M superpages, mapped RX. */
 #endif
 
+  start_pa = ABSOLUTE(start - __XEN_VIRT_START);
+
   . = __XEN_VIRT_START + XEN_IMG_OFFSET;
   _start = .;
-  .text : {
+  DECL_SECTION(.text) {
         _stext = .;            /* Text and read-only data */
        *(.text)
        *(.text.cold)
@@ -73,7 +77,7 @@ SECTIONS
   __2M_text_end = .;
 
   __2M_rodata_start = .;       /* Start of 2M superpages, mapped RO. */
-  .rodata : {
+  DECL_SECTION(.rodata) {
        _srodata = .;
        /* Bug frames table */
        __start_bug_frames = .;
@@ -132,13 +136,13 @@ SECTIONS
  * compiler may want to inject other things in the .note which we don't care
  * about - hence this unique name.
  */
-  .note.gnu.build-id : {
+  DECL_SECTION(.note.gnu.build-id) {
        __note_gnu_build_id_start = .;
        *(.note.gnu.build-id)
        __note_gnu_build_id_end = .;
   } :note :text
 #elif defined(BUILD_ID_EFI)
-  .buildid : {
+  DECL_SECTION(.buildid) {
        __note_gnu_build_id_start = .;
        *(.buildid)
        __note_gnu_build_id_end = .;
@@ -153,7 +157,7 @@ SECTIONS
   __2M_init_start = .;         /* Start of 2M superpages, mapped RWX (boot 
only). */
   . = ALIGN(PAGE_SIZE);             /* Init code and data */
   __init_begin = .;
-  .init : {
+  DECL_SECTION(.init) {
        _sinittext = .;
        *(.init.text)
        /*
@@ -215,7 +219,7 @@ SECTIONS
 
   __2M_rwdata_start = .;       /* Start of 2M superpages, mapped RW. */
   . = ALIGN(SMP_CACHE_BYTES);
-  .data.read_mostly : {
+  DECL_SECTION(.data.read_mostly) {
        *(.data.read_mostly)
        . = ALIGN(8);
        __start_schedulers_array = .;
@@ -223,7 +227,7 @@ SECTIONS
        __end_schedulers_array = .;
   } :text
 
-  .data : {                    /* Data */
+  DECL_SECTION(.data) {
        *(.data.page_aligned)
        *(.data)
        *(.data.rel)
@@ -231,7 +235,7 @@ SECTIONS
        CONSTRUCTORS
   } :text
 
-  .bss : {                     /* BSS */
+  DECL_SECTION(.bss) {
        __bss_start = .;
        *(.bss.stack_aligned)
        *(.bss.page_aligned*)
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.