xen/x86: fix linker script to work with lld
PATCH v2 1/1 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: |
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
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.
---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Daniel Kiper <[email protected]>
---
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(-)
xen/arch/x86/xen.lds.S +1 -3
@@ -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")
xen/include/xen/compiler.h +2 -0
@@ -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
xen/include/xen/efi.h +1 -1
@@ -21,7 +21,7 @@ struct efi {unsigned long smbios3;/* SMBIOS v3 table */ }; -extern struct efi efi; +extern struct efi __weak efi;#ifndef __ASSEMBLY__
xen/include/xen/livepatch_payload.h +2 -2
@@ -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__ */
Signature · 7 lines
2.17.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 20 lines · Roger Pau Monne
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: |Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
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: efiFix 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é <[email protected]>
Quoted 10 lines
---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Daniel Kiper <[email protected]>
---
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.
May I ask you to split this patch into two separate patches? One for __weak change and one for DEFINED() drop please.
Daniel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 32 lines · Daniel Kiper
Quoted 20 lines · Roger Pau Monne
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: |Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
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: efiFix 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é <[email protected]>Quoted 10 lines
---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Daniel Kiper <[email protected]>
---
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.
Quoted 2 lines
May I ask you to split this patch into two separate patches? One for
__weakchange and one forDEFINED()drop please.
So to introduce and use __weak also for the efi variable and then drop the DEFINED in a following patch?
Or switch efi to use __weak in the same patch where DEFINED is dropped?
Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 33 lines · Roger Pau Monné
Quoted 32 lines · Daniel Kiper
Quoted 30 lines · Roger Pau Monne
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: |Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
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: efiFix 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é <[email protected]>---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Daniel Kiper <[email protected]>
---
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.
Quoted 8 lines
Quoted 2 lines
May I ask you to split this patch into two separate patches? One for
__weakchange and one forDEFINED()drop please.So to introduce and use
__weakalso for the efi variable and then drop the DEFINED in a following patch?Or switch efi to use
__weakin the same patch where DEFINED is dropped?
The latter please.
Daniel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel