Skip to contentSkip to conversation

xen: arm: include .text.cold and .text.unlikely in text area

PATCH In review Ian Campbell 3 participants 6 messages Jun 9, 2014 – Jun 10, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: arm: include .text.cold and .text.unlikely in text area

Otherwise functions in these sections can end up between .text and .rodata which is after _etext and therefore gets made non-executable.

This matches x86 (although it was done there for different reasons).

---
Jan, any reason why x86 doesn't just use .text.*?

---
 xen/arch/arm/xen.lds.S |    2 ++
 1 file changed, 2 insertions(+)
xen/arch/arm/xen.lds.S +2 -0
index e8b4f47..be55dad 100644
@@ -30,6 +30,8 @@ SECTIONS
   .text : /* XXX should be AT ( XEN_PHYS_START ) */ {
         _stext = .;            /* Text section */
        *(.text)
+       *(.text.cold)
+       *(.text.unlikely)
        *(.fixup)
        *(.gnu.warning)
        _etext = .;             /* End of text section */
Signature · 1 line
1.7.10.4
author Applied
#2 lore raw
Quoted 6 lines · Julien Grall

Hi Ian,

Quoted 3 lines · Ian Campbell

Otherwise functions in these sections can end up between .text and .rodata which is after _etext and therefore gets made non-executable.

Quoted 6 lines
Quoted 4 lines

This matches x86 (although it was done there for different reasons).

Applied, thanks.

Ian.

#3 lore raw
In reply to Ian Campbell
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 09.06.14 at 16:28, <[email protected]> wrote:

Otherwise functions in these sections can end up between .text and .rodata which is after _etext and therefore gets made non-executable.

This matches x86 (although it was done there for different reasons).

---
Jan, any reason why x86 doesn't just use .text.*?

Because we want the .cold and .unlikely all adjacent, rather than intermixed with eventual other ones (imagine mixing in a hypothetical .text.hot).

Jan

Quoted 19 lines
---
 xen/arch/arm/xen.lds.S |    2 ++
 1 file changed, 2 insertions(+)
xen/arch/arm/xen.lds.S +2 -0
index e8b4f47..be55dad 100644
@@ -30,6 +30,8 @@ SECTIONS
   .text : /* XXX should be AT ( XEN_PHYS_START ) */ {
         _stext = .;            /* Text section */
        *(.text)
+       *(.text.cold)
+       *(.text.unlikely)
        *(.fixup)
        *(.gnu.warning)
        _etext = .;             /* End of text section */
Signature · 1 line
1.7.10.4
#4 lore raw
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 09.06.14 at 16:28, <[email protected]> wrote:

Otherwise functions in these sections can end up between .text and .rodata which is after _etext and therefore gets made non-executable.

This matches x86 (although it was done there for different reasons).

Quoted 8 lines
Quoted 4 lines

---
Jan, any reason why x86 doesn't just use .text.*?

Because we want the .cold and .unlikely all adjacent, rather than intermixed with eventual other ones (imagine mixing in a hypothetical .text.hot).

That makes sense. Could we specify .text.* after those as a fallback or would we rather deal with each new section specifically so we can have a think about the right location?

I don't suppose there is a linker option to make it barf on non-explicitly placed sections, is there? That would have turned this silent (and hard to diagnose) failure into something more explicit.

Ian.

Quoted 25 lines

Jan

Quoted 19 lines
---
 xen/arch/arm/xen.lds.S |    2 ++
 1 file changed, 2 insertions(+)
xen/arch/arm/xen.lds.S +2 -0
index e8b4f47..be55dad 100644
@@ -30,6 +30,8 @@ SECTIONS
   .text : /* XXX should be AT ( XEN_PHYS_START ) */ {
         _stext = .;            /* Text section */
        *(.text)
+       *(.text.cold)
+       *(.text.unlikely)
        *(.fixup)
        *(.gnu.warning)
        _etext = .;             /* End of text section */
Signature · 1 line
1.7.10.4
#5 lore raw
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 10.06.14 at 11:07, <[email protected]> wrote:
Quoted 11 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 09.06.14 at 16:28, <[email protected]> wrote:

Otherwise functions in these sections can end up between .text and .rodata which is after _etext and therefore gets made non-executable.

This matches x86 (although it was done there for different reasons).

---
Jan, any reason why x86 doesn't just use .text.*?

Quoted 7 lines
Quoted 3 lines

Because we want the .cold and .unlikely all adjacent, rather than intermixed with eventual other ones (imagine mixing in a hypothetical .text.hot).

That makes sense. Could we specify .text.* after those as a fallback or would we rather deal with each new section specifically so we can have a think about the right location?

That's certainly an option - placing them inefficiently is clearly better than placing them wrongly.

Quoted 3 lines

I don't suppose there is a linker option to make it barf on non-explicitly placed sections, is there? That would have turned this silent (and hard to diagnose) failure into something more explicit.

I'm not aware of any such option.

Jan