|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCH v3 4/7] plat/xen: Add preinit_array and init_array sections (x86, ARM)
Reviewed-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx>
Simon Kuenzer <simon.kuenzer@xxxxxxxxx> writes:
> Adds preinit_array and init_array sections with the linker script.
> Those sections are populated by the compiler/linker with function
> pointer arrays. Such functions are typically part of initializing
> the language runtime (e.g., C++) and have to be called early during
> bootstrapping. However, they can also be used by Unikraft libraries
> for early initializations (functions with constructor attribute).
>
> Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
> ---
> plat/xen/arm/link32.ld | 43 +++++++++++++++++++------------------------
> plat/xen/memory.c | 10 +++++-----
> plat/xen/x86/link64.ld | 17 +++++++++++++++++
> 3 files changed, 41 insertions(+), 29 deletions(-)
>
> diff --git a/plat/xen/arm/link32.ld b/plat/xen/arm/link32.ld
> index 77184c0..4508e05 100644
> --- a/plat/xen/arm/link32.ld
> +++ b/plat/xen/arm/link32.ld
> @@ -47,37 +47,32 @@ SECTIONS
>
> _etext = .; /* End of text section */
>
> + /* Read-only data */
> _rodata = .;
> - .rodata : { *(.rodata) *(.rodata.*) }
> + .rodata :
> + {
> + *(.rodata)
> + *(.rodata.*)
> + }
> . = ALIGN(4096);
> _erodata = .;
>
> - /* newlib initialization functions */
> - . = ALIGN(32 / 8);
> - PROVIDE (__preinit_array_start = .);
> - .preinit_array : { *(.preinit_array) }
> - PROVIDE (__preinit_array_end = .);
> - PROVIDE (__init_array_start = .);
> - .init_array : { *(.init_array) }
> - PROVIDE (__init_array_end = .);
> - PROVIDE (__fini_array_start = .);
> - .fini_array : { *(.fini_array) }
> - PROVIDE (__fini_array_end = .);
> -
> - .ctors : {
> - __CTOR_LIST__ = .;
> - *(.ctors)
> - CONSTRUCTORS
> - LONG(0)
> - __CTOR_END__ = .;
> + _ctors = .;
> + .preinit_array : {
> + . = ALIGN(0x8);
> + PROVIDE_HIDDEN (__preinit_array_start = .);
> + KEEP (*(.preinit_array))
> + PROVIDE_HIDDEN (__preinit_array_end = .);
> }
>
> - .dtors : {
> - __DTOR_LIST__ = .;
> - *(.dtors)
> - LONG(0)
> - __DTOR_END__ = .;
> + .init_array : {
> + . = ALIGN(0x8);
> + PROVIDE_HIDDEN (__init_array_start = .);
> + KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)
> SORT_BY_INIT_PRIORITY(.ctors.*)))
> + KEEP (*(.init_array .ctors))
> + PROVIDE_HIDDEN (__init_array_end = .);
> }
> + _ectors = .;
>
> .data : { /* Data */
> _data = .;
> diff --git a/plat/xen/memory.c b/plat/xen/memory.c
> index c40ea3d..df56616 100644
> --- a/plat/xen/memory.c
> +++ b/plat/xen/memory.c
> @@ -50,7 +50,7 @@ int ukplat_memregion_count(void)
>
> int ukplat_memregion_get(int i, struct ukplat_memregion_desc *m)
> {
> - extern char _text, _etext, _data, _edata, _rodata, _erodata, _end,
> __bss_start;
> + extern char _text, _etext, _data, _edata, _rodata, _erodata, _ctors,
> _ectors, _end, __bss_start;
>
> UK_ASSERT(m);
>
> @@ -73,13 +73,13 @@ int ukplat_memregion_get(int i, struct
> ukplat_memregion_desc *m)
> m->name = "rodata";
> #endif
> break;
> - case 2: /* ctors, dtors */
> - m->base = &_erodata;
> - m->len = (size_t) &_data - (size_t) &_erodata;
> + case 2: /* ctors */
> + m->base = &_ctors;
> + m->len = (size_t) &_ectors - (size_t) &_ctors;
> m->flags = (UKPLAT_MEMRF_RESERVED
> | UKPLAT_MEMRF_READABLE);
> #if UKPLAT_MEMRNAME
> - m->name = "ctors+dtors";
> + m->name = "ctors";
> #endif
> break;
> case 3: /* data */
> diff --git a/plat/xen/x86/link64.ld b/plat/xen/x86/link64.ld
> index dd092aa..5391dbd 100644
> --- a/plat/xen/x86/link64.ld
> +++ b/plat/xen/x86/link64.ld
> @@ -47,6 +47,23 @@ SECTIONS
> . = ALIGN(4096);
> _erodata = .;
>
> + _ctors = .;
> + .preinit_array : {
> + . = ALIGN(0x8);
> + PROVIDE_HIDDEN (__preinit_array_start = .);
> + KEEP (*(.preinit_array))
> + PROVIDE_HIDDEN (__preinit_array_end = .);
> + }
> +
> + .init_array : {
> + . = ALIGN(0x8);
> + PROVIDE_HIDDEN (__init_array_start = .);
> + KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)
> SORT_BY_INIT_PRIORITY(.ctors.*)))
> + KEEP (*(.init_array .ctors))
> + PROVIDE_HIDDEN (__init_array_end = .);
> + }
> + _ectors = .;
> +
> _data = .;
> .data : { /* Data */
> *(.data)
> --
> 2.7.4
>
>
> _______________________________________________
> Minios-devel mailing list
> Minios-devel@xxxxxxxxxxxxxxxxxxxx
> https://lists.xenproject.org/mailman/listinfo/minios-devel
--
Yuri Volchkov
Software Specialist
NEC Europe Ltd
Kurfürsten-Anlage 36
D-69115 Heidelberg
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |