LIBUKRELOC_ASINCLUDES-y += -I$(UK_PLAT_COMMON_BASE)/include
LIBUKRELOC_CINCLUDES-y += -I$(UK_PLAT_COMMON_BASE)/include
LIBUKRELOC_CXXINCLUDES-y += -I$(UK_PLAT_COMMON_BASE)/include
+
+LIBUKRELOC_ASFLAGS-y += -DUK_USE_SECTION_SEGMENTS
+LIBUKRELOC_CFLAGS-y += -DUK_USE_SECTION_SEGMENTS
+LIBUKRELOC_CXXFLAGS-y += -DUK_USE_SECTION_SEGMENTS
+
+LIBUKRELOC_SRCS-$(CONFIG_LIBUKRELOC) += $(LIBUKRELOC_BASE)/reloc.lds.S
--- /dev/null
+/* SPDX-License-Identifier: BSD-3-Clause */
+/* Copyright (c) 2023, Unikraft GmbH and The Unikraft Authors.
+ * Licensed under the BSD-3-Clause License (the "License").
+ * You may not use this file except in compliance with the License.
+ */
+
+#include <uk/arch/limits.h> /* for __PAGE_SIZE */
+#include <uk/plat/common/common.lds.h> /* for UK_SEGMENT_DATA */
+
+#define UKRELOC_SIGNATURE_SIZE 4
+
+PHDRS
+{
+ dynamic PT_DYNAMIC;
+}
+
+SECTIONS
+{
+ . = ALIGN(__PAGE_SIZE);
+ .uk_reloc :
+ {
+ _uk_reloc_start = .;
+ /* Start gathering static uk_reloc from the signature onwards */
+ . += UKRELOC_SIGNATURE_SIZE;
+ KEEP(*(.uk_reloc))
+ } UK_SEGMENT_DATA
+
+ /* For whatever reason, .dynsym wants to stay before .rela.dyn.
+ * This does not bother us, even if we strip it, since we are compiling
+ * statically, .dynsym will be insignificantly small.
+ */
+ .dynsym :
+ {
+ *(.dynsym)
+ } UK_SEGMENT_DATA
+
+ .rela.dyn :
+ {
+ *(.rela)
+ *(.rela.*)
+ } UK_SEGMENT_DATA
+ _uk_reloc_end = .;
+}
+INSERT BEFORE .bss
+
+/******************************************************************************/
+/****************************** .bss section **********************************/
+/******************************************************************************/
+
+/******************************************************************************/
+/**************************** .comment section ********************************/
+/******************************************************************************/
+
+SECTIONS
+{
+ .dynamic :
+ {
+ *(.dynamic)
+ } :dynamic UK_SEGMENT_DATA
+
+ .dynstr :
+ {
+ *(.dynstr)
+ } UK_SEGMENT_DATA
+}
+INSERT AFTER .comment
/* _etdata: denotes end of .tdata (and start of .tbss */
extern char _etdata[];
+/* [_uk_reloc_start, _uk_reloc_end]: contains *(.ukeloc) */
+extern char _uk_reloc_start[], _uk_reloc_end[];
+
/* __bss_start: start of BSS sections */
extern char __bss_start[];
#define __EDATA __uk_image_symbol(_edata)
#define __CTORS __uk_image_symbol(_ctors)
#define __ECTORS __uk_image_symbol(_ectors)
+#define __UKRELOC_START __uk_image_symbol(_uk_reloc_start)
+#define __UKRELOC_END __uk_image_symbol(_uk_reloc_end)
#define __BSS_START __uk_image_symbol(__bss_start)
#define __END __uk_image_symbol(_end)