diff mbox series

[1/4] xen/link: Cope with .rodata.cst* sections

Message ID 1560975087-25632-2-git-send-email-andrew.cooper3@citrix.com (mailing list archive)
State New, archived
Headers show
Series xen/link: Fixes and improvements to Xen's linking | expand

Commit Message

Andrew Cooper June 19, 2019, 8:11 p.m. UTC
.rodata.cst* sections are used for mergable constant data, and the clang/llvm
8 toolchain has been observed to create .rodata.cst8 in a default Xen build.

Unfortunately, this section (and its .init counterpart) aren't captured by
Xen's linker globs, and end up as orphaned sections.

Generalise the data globbing to pick up cst and future special sections.

Reported-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wl@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>
---
 xen/arch/arm/xen.lds.S | 9 +++------
 xen/arch/x86/xen.lds.S | 9 +++------
 2 files changed, 6 insertions(+), 12 deletions(-)

Comments

Julien Grall June 19, 2019, 9:18 p.m. UTC | #1
Hi Andrew,

On 6/19/19 9:11 PM, Andrew Cooper wrote:
> .rodata.cst* sections are used for mergable constant data, and the clang/llvm
> 8 toolchain has been observed to create .rodata.cst8 in a default Xen build.
> 
> Unfortunately, this section (and its .init counterpart) aren't captured by
> Xen's linker globs, and end up as orphaned sections.
> 
> Generalise the data globbing to pick up cst and future special sections.
> 
> Reported-by: Roger Pau Monné <roger.pau@citrix.com>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Wei Liu <wl@xen.org>
> CC: Roger Pau Monné <roger.pau@citrix.com>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Julien Grall <julien.grall@arm.com>
> ---
>   xen/arch/arm/xen.lds.S | 9 +++------
>   xen/arch/x86/xen.lds.S | 9 +++------
>   2 files changed, 6 insertions(+), 12 deletions(-)
> 
> diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
> index e664c44..31d74a8 100644
> --- a/xen/arch/arm/xen.lds.S
> +++ b/xen/arch/arm/xen.lds.S
> @@ -96,8 +96,7 @@ SECTIONS
>          __start_schedulers_array = .;
>          *(.data.schedulers)
>          __end_schedulers_array = .;
> -       *(.data.rel)
> -       *(.data.rel.*)
> +       *(.data.*)

My knowledge of linker is quite limited, so I might be wrong. But will 
not this match .data.vcpi & co?

Cheers,
Roger Pau Monné June 20, 2019, 8:26 a.m. UTC | #2
On Wed, Jun 19, 2019 at 10:18:42PM +0100, Julien Grall wrote:
> Hi Andrew,
> 
> On 6/19/19 9:11 PM, Andrew Cooper wrote:
> > .rodata.cst* sections are used for mergable constant data, and the clang/llvm
> > 8 toolchain has been observed to create .rodata.cst8 in a default Xen build.
> > 
> > Unfortunately, this section (and its .init counterpart) aren't captured by
> > Xen's linker globs, and end up as orphaned sections.
> > 
> > Generalise the data globbing to pick up cst and future special sections.
> > 
> > Reported-by: Roger Pau Monné <roger.pau@citrix.com>
> > Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> > ---
> > CC: Jan Beulich <JBeulich@suse.com>
> > CC: Wei Liu <wl@xen.org>
> > CC: Roger Pau Monné <roger.pau@citrix.com>
> > CC: Stefano Stabellini <sstabellini@kernel.org>
> > CC: Julien Grall <julien.grall@arm.com>
> > ---
> >   xen/arch/arm/xen.lds.S | 9 +++------
> >   xen/arch/x86/xen.lds.S | 9 +++------
> >   2 files changed, 6 insertions(+), 12 deletions(-)
> > 
> > diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
> > index e664c44..31d74a8 100644
> > --- a/xen/arch/arm/xen.lds.S
> > +++ b/xen/arch/arm/xen.lds.S
> > @@ -96,8 +96,7 @@ SECTIONS
> >          __start_schedulers_array = .;
> >          *(.data.schedulers)
> >          __end_schedulers_array = .;
> > -       *(.data.rel)
> > -       *(.data.rel.*)
> > +       *(.data.*)
> 
> My knowledge of linker is quite limited, so I might be wrong. But will not
> this match .data.vcpi & co?

AFAICT the x86 part of this change is fine, because the wildcard
matches are added after the more narrow matches of .data.* sections.

However for ARM the change is not correct, since the .data.* wildcard
is added before the more narrow match of .data.vpci.*. This could be
solved by moving the .data section at the end of the script (ie: after
the .init sections), like it's done on x86.

Thanks, Roger.
Jan Beulich June 21, 2019, 9:05 a.m. UTC | #3
>>> On 19.06.19 at 22:11, <andrew.cooper3@citrix.com> wrote:
> .rodata.cst* sections are used for mergable constant data, and the clang/llvm
> 8 toolchain has been observed to create .rodata.cst8 in a default Xen build.

Neither this nor ...

> Unfortunately, this section (and its .init counterpart) aren't captured by
> Xen's linker globs, and end up as orphaned sections.

... this are problems on their own. The issue is if these sections end up
first in the binary (which, as we all appear to agree, should never have
happened).

> Generalise the data globbing to pick up cst and future special sections.

I'm a little wary of this, and had in the past specifically avoided adding
"too wide" a glob pattern: There's a small risk of covering a section
that's meant to be covered elsewhere. The observation of the issue
with the Arm side change is an example of such. Therefore I'd prefer
if we could get away with just adding .init.rodata.cst* and .rodata.cst*.

Jan
diff mbox series

Patch

diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
index e664c44..31d74a8 100644
--- a/xen/arch/arm/xen.lds.S
+++ b/xen/arch/arm/xen.lds.S
@@ -96,8 +96,7 @@  SECTIONS
        __start_schedulers_array = .;
        *(.data.schedulers)
        __end_schedulers_array = .;
-       *(.data.rel)
-       *(.data.rel.*)
+       *(.data.*)
        CONSTRUCTORS
   } :text
 
@@ -154,8 +153,7 @@  SECTIONS
   . = ALIGN(PAGE_SIZE);
   .init.data : {
        *(.init.rodata)
-       *(.init.rodata.rel)
-       *(.init.rodata.str*)
+       *(.init.rodata.*)
 
        . = ALIGN(POINTER_ALIGN);
        __setup_start = .;
@@ -176,8 +174,7 @@  SECTIONS
        *(.altinstr_replacement)
 
        *(.init.data)
-       *(.init.data.rel)
-       *(.init.data.rel.*)
+       *(.init.data.*)
 
        . = ALIGN(8);
        __ctors_start = .;
diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index cb42dc8..ec37d38 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -206,8 +206,7 @@  SECTIONS
 #endif
 
        *(.init.rodata)
-       *(.init.rodata.rel)
-       *(.init.rodata.str*)
+       *(.init.rodata.*)
 
        . = ALIGN(POINTER_ALIGN);
        __setup_start = .;
@@ -221,8 +220,7 @@  SECTIONS
        __initcall_end = .;
 
        *(.init.data)
-       *(.init.data.rel)
-       *(.init.data.rel.*)
+       *(.init.data.*)
        . = ALIGN(4);
        __trampoline_rel_start = .;
        *(.trampoline_rel)
@@ -272,8 +270,7 @@  SECTIONS
   DECL_SECTION(.data) {
        *(.data.page_aligned)
        *(.data)
-       *(.data.rel)
-       *(.data.rel.*)
+       *(.data.*)
        CONSTRUCTORS
   } :text