* [PATCH v2] xen/x86: fix linker script to work with lld
@ 2018-07-11 10:25 Roger Pau Monne
2018-07-11 10:42 ` Daniel Kiper
0 siblings, 1 reply; 4+ messages in thread
From: Roger Pau Monne @ 2018-07-11 10:25 UTC (permalink / raw)
To: xen-devel; +Cc: Andrew Cooper, Daniel Kiper, Jan Beulich, 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: |
>>> 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@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Daniel Kiper <daniel.kiper@oracle.com>
---
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@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] xen/x86: fix linker script to work with lld
2018-07-11 10:25 [PATCH v2] xen/x86: fix linker script to work with lld Roger Pau Monne
@ 2018-07-11 10:42 ` Daniel Kiper
2018-07-11 11:46 ` Roger Pau Monné
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Kiper @ 2018-07-11 10:42 UTC (permalink / raw)
To: Roger Pau Monne; +Cc: xen-devel, Jan Beulich, Andrew Cooper
On Wed, Jul 11, 2018 at 12:25:21PM +0200, Roger Pau Monne wrote:
> 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@citrix.com>
> ---
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> Cc: Daniel Kiper <daniel.kiper@oracle.com>
> ---
> 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
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] xen/x86: fix linker script to work with lld
2018-07-11 10:42 ` Daniel Kiper
@ 2018-07-11 11:46 ` Roger Pau Monné
2018-07-11 11:59 ` Daniel Kiper
0 siblings, 1 reply; 4+ messages in thread
From: Roger Pau Monné @ 2018-07-11 11:46 UTC (permalink / raw)
To: Daniel Kiper; +Cc: xen-devel, Jan Beulich, Andrew Cooper
On Wed, Jul 11, 2018 at 12:42:48PM +0200, Daniel Kiper wrote:
> On Wed, Jul 11, 2018 at 12:25:21PM +0200, Roger Pau Monne wrote:
> > 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@citrix.com>
> > ---
> > Cc: Jan Beulich <jbeulich@suse.com>
> > Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> > Cc: Daniel Kiper <daniel.kiper@oracle.com>
> > ---
> > 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.
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
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] xen/x86: fix linker script to work with lld
2018-07-11 11:46 ` Roger Pau Monné
@ 2018-07-11 11:59 ` Daniel Kiper
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Kiper @ 2018-07-11 11:59 UTC (permalink / raw)
To: Roger Pau Monné; +Cc: xen-devel, Jan Beulich, Andrew Cooper
On Wed, Jul 11, 2018 at 01:46:56PM +0200, Roger Pau Monné wrote:
> On Wed, Jul 11, 2018 at 12:42:48PM +0200, Daniel Kiper wrote:
> > On Wed, Jul 11, 2018 at 12:25:21PM +0200, Roger Pau Monne wrote:
> > > 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@citrix.com>
> > > ---
> > > Cc: Jan Beulich <jbeulich@suse.com>
> > > Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> > > Cc: Daniel Kiper <daniel.kiper@oracle.com>
> > > ---
> > > 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.
>
> 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?
The latter please.
Daniel
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-07-11 11:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-11 10:25 [PATCH v2] xen/x86: fix linker script to work with lld Roger Pau Monne
2018-07-11 10:42 ` Daniel Kiper
2018-07-11 11:46 ` Roger Pau Monné
2018-07-11 11:59 ` Daniel Kiper
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.