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

[Minios-devel] [UNIKRAFT PATCH 1/4] plat: prepare linker script for thread-local storage



Aggregate all .tdata and .tbss variables in the correct sections, and
define global variables that point at section beginning and end.

Signed-off-by: Florian Schmidt <florian.schmidt@xxxxxxxxx>
---
 plat/common/include/sections.h |  5 +++++
 plat/kvm/x86/link64.lds        | 18 ++++++++++++++++++
 plat/linuxu/Linker.uk          |  1 +
 plat/linuxu/link.ld            | 22 ++++++++++++++++++++++
 plat/xen/x86/link64.lds        | 18 ++++++++++++++++++
 5 files changed, 64 insertions(+)
 create mode 100644 plat/linuxu/link.ld

diff --git a/plat/common/include/sections.h b/plat/common/include/sections.h
index 1052cfc7..a2677ce8 100644
--- a/plat/common/include/sections.h
+++ b/plat/common/include/sections.h
@@ -63,6 +63,11 @@ extern char _data[], _edata[];
 /* [_ctors, _ectors]: contains constructor tables (read-only) */
 extern char _ctors[], _ectors[];
 
+/* [_tls_start, _tls_end]: contains .tdata.* and .tbss.* sections */
+extern char _tls_start[], _tls_end[];
+/* _etdata: denotes end of .tdata (and start of .tbss */
+extern char _etdata[];
+
 /* __bss_start: start of BSS sections */
 extern char __bss_start[];
 
diff --git a/plat/kvm/x86/link64.lds b/plat/kvm/x86/link64.lds
index c96f7501..4e52da49 100644
--- a/plat/kvm/x86/link64.lds
+++ b/plat/kvm/x86/link64.lds
@@ -71,6 +71,24 @@ SECTIONS
        }
        _ectors = .;
 
+       . = ALIGN(0x8);
+       _tls_start = .;
+       .tdata :
+       {
+               *(.tdata)
+               *(.tdata.*)
+               *(.gnu.linkonce.td.*)
+       }
+       _etdata = .;
+       .tbss :
+       {
+               *(.tbss)
+               *(.tbss.*)
+               *(.gnu.linkonce.tb.*)
+               . = ALIGN(0x8);
+       }
+       _tls_end = . + SIZEOF(.tbss);
+
        /* Read-write data (initialized) */
        . = ALIGN(0x1000);
        _data = .;
diff --git a/plat/linuxu/Linker.uk b/plat/linuxu/Linker.uk
index ef4b201c..e0cd1743 100644
--- a/plat/linuxu/Linker.uk
+++ b/plat/linuxu/Linker.uk
@@ -1,4 +1,5 @@
 LINUXU_LDFLAGS-y += -Wl,-e,_liblinuxuplat_start
+EXTRA_LD_SCRIPT-y  += $(CONFIG_UK_BASE)/plat/linuxu/link.ld
 
 ##
 ## Link image
diff --git a/plat/linuxu/link.ld b/plat/linuxu/link.ld
new file mode 100644
index 00000000..3f5cd682
--- /dev/null
+++ b/plat/linuxu/link.ld
@@ -0,0 +1,22 @@
+SECTIONS
+{
+       . = ALIGN(0x8);
+       _tls_start = .;
+       .tdata :
+       {
+               *(.tdata)
+               *(.tdata.*)
+               *(.gnu.linkonce.td.*)
+       }
+       _etdata = .;
+       .tbss :
+       {
+               *(.tbss)
+               *(.tbss.*)
+               *(.gnu.linkonce.tb.*)
+               . = ALIGN(0x8);
+       }
+       _tls_end = . + SIZEOF(.tbss);
+}
+
+INSERT BEFORE .data
diff --git a/plat/xen/x86/link64.lds b/plat/xen/x86/link64.lds
index 82ab653a..c8af67c0 100644
--- a/plat/xen/x86/link64.lds
+++ b/plat/xen/x86/link64.lds
@@ -67,6 +67,24 @@ SECTIONS
        . = ALIGN(4096);
        _ectors = .;
 
+       . = ALIGN(0x8);
+       _tls_start = .;
+       .tdata :
+       {
+               *(.tdata)
+               *(.tdata.*)
+               *(.gnu.linkonce.td.*)
+       }
+       _etdata = .;
+       .tbss :
+       {
+               *(.tbss)
+               *(.tbss.*)
+               *(.gnu.linkonce.tb.*)
+               . = ALIGN(0x8);
+       }
+       _tls_end = . + SIZEOF(.tbss);
+
        /* Data */
        _data = .;
        .data : {
-- 
2.21.0


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

 


Rackspace

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