|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2] xen/x86: fix linker script to work with lld
lld (the llvm linker) has some issues with Xen linker script. It
doesn't understand '||' in assert expressions:
ld -melf_x86_64_fbsd -T xen.lds -N prelink.o --build-id=sha1 \
/root/src/xen/xen/common/symbols-dummy.o -o /root/src/xen/xen/.xen-syms.0
ld: error: xen.lds:260: malformed number: |
>>> ASSERT(__image_base__ > (((((((((261 >> 8) * 0xffff000000000000) | (261 <<
>>> 39))) + ((1 << 39) / 2)) + (64 << 30)) + (1 << 30)) + (1 << 30))) ||
>>>
>>> ^
And doesn't work properly with the 'DEFINED(foo) ? foo : ...'
expression:
ld -melf_x86_64_fbsd -T xen.lds -N prelink.o --build-id=sha1 \
/root/src/xen/xen/common/symbols-dummy.o -o /root/src/xen/xen/.xen-syms.0
ld: error: xen.lds:233: symbol not found: efi
Fix the first issue by using '|' instead of '||', and the second one
by declaring the efi symbol as a weak symbol.
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Cc: Jan Beulich <jbeulich@xxxxxxxx>
Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Cc: Daniel Kiper <daniel.kiper@xxxxxxxxxx>
---
Changes since v1:
- Export efi as a weak symbol in order to remove the DEFINED
conditional in the linker script.
- Add a define for setting the weak attribute and replace existing
users.
---
xen/arch/x86/xen.lds.S | 4 +---
xen/include/xen/compiler.h | 2 ++
xen/include/xen/efi.h | 2 +-
xen/include/xen/livepatch_payload.h | 4 ++--
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index 70afedd31d..9fa40a6d48 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -304,8 +304,6 @@ SECTIONS
} :text
#endif
- efi = DEFINED(efi) ? efi : .;
-
/* Sections to be discarded */
/DISCARD/ : {
*(.exit.text)
@@ -331,7 +329,7 @@ SECTIONS
.comment 0 : { *(.comment) }
}
-ASSERT(__image_base__ > XEN_VIRT_START ||
+ASSERT(__image_base__ > XEN_VIRT_START |
__2M_rwdata_end <= XEN_VIRT_END - NR_CPUS * PAGE_SIZE,
"Xen image overlaps stubs area")
diff --git a/xen/include/xen/compiler.h b/xen/include/xen/compiler.h
index a7e05681c9..001f589655 100644
--- a/xen/include/xen/compiler.h
+++ b/xen/include/xen/compiler.h
@@ -18,6 +18,8 @@
#define __packed __attribute__((__packed__))
+#define __weak __attribute__((weak))
+
#if (!defined(__clang__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 5))
#define unreachable() do {} while (1)
#else
diff --git a/xen/include/xen/efi.h b/xen/include/xen/efi.h
index 44b7d3ec3a..5678df72f9 100644
--- a/xen/include/xen/efi.h
+++ b/xen/include/xen/efi.h
@@ -21,7 +21,7 @@ struct efi {
unsigned long smbios3; /* SMBIOS v3 table */
};
-extern struct efi efi;
+extern struct efi __weak efi;
#ifndef __ASSEMBLY__
diff --git a/xen/include/xen/livepatch_payload.h
b/xen/include/xen/livepatch_payload.h
index 8f38cc2c60..4a1a96d054 100644
--- a/xen/include/xen/livepatch_payload.h
+++ b/xen/include/xen/livepatch_payload.h
@@ -24,7 +24,7 @@ typedef void livepatch_unloadcall_t(void);
* executed in series by the livepatch infrastructure at patch load time.
*/
#define LIVEPATCH_LOAD_HOOK(_fn) \
- livepatch_loadcall_t *__attribute__((weak)) \
+ livepatch_loadcall_t *__weak \
const livepatch_load_data_##_fn __section(".livepatch.hooks.load") =
_fn;
/*
@@ -33,7 +33,7 @@ typedef void livepatch_unloadcall_t(void);
* Same as LOAD hook with s/load/unload/
*/
#define LIVEPATCH_UNLOAD_HOOK(_fn) \
- livepatch_unloadcall_t *__attribute__((weak)) \
+ livepatch_unloadcall_t *__weak \
const livepatch_unload_data_##_fn __section(".livepatch.hooks.unload")
= _fn;
#endif /* __XEN_LIVEPATCH_PAYLOAD_H__ */
--
2.17.1
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |