Skip to contentSkip to conversation

x86: have .note.Xen segment contents before other .note.* ones

PATCH In review Juergen Gross 2 participants 3 messages Nov 28, 2025 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: have .note.Xen segment contents before other .note.* ones

Today the linker script of Mini-OS specifies to merge all .note* sections into a single section .note:

 .note : {
          *(.note)
          *(.note.*)

}

It seems as if ld will use the attributes of the first .note* segment found during the linking process for the final .note segment.

Somewhere between binutils 2.43 and 2.45 something changed resulting in .note.GNU-stack being the first .note* segment found. Unfortunately this segment has unusual attributes: it has PROGBITS instead of NOTE as type, resulting in the Xen ELF parsing to no longer look into it for finding the Xen ELF-notes. This in turn will result in failure while trying to parse the binary, which will let domain creation fail.

In order to avoid this issue, enhance the linker script to merge .note.Xen before other .note.* segments, resulting in the final .note segment to still have the NOTE type.

Fixes 6d1cc81d049f ("x86: switch to use elfnote")
---
 arch/x86/minios-x86.lds.S | 1 +
 1 file changed, 1 insertion(+)
arch/x86/minios-x86.lds.S +1 -0
index 8c6e0a60..6367b4b2 100644
@@ -33,6 +33,7 @@ SECTIONS
 
         .note : {
                 *(.note)
+                *(.note.Xen)
                 *(.note.*)
         }
 
Signature · 1 line
2.51.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Juergen Gross

Today the linker script of Mini-OS specifies to merge all .note* sections into a single section .note:

 .note : {
          *(.note)
          *(.note.*)

}

It seems as if ld will use the attributes of the first .note* segment found during the linking process for the final .note segment.

Somewhere between binutils 2.43 and 2.45 something changed resulting in .note.GNU-stack being the first .note* segment found. Unfortunately this segment has unusual attributes: it has PROGBITS instead of NOTE as type, resulting in the Xen ELF parsing to no longer look into it for finding the Xen ELF-notes. This in turn will result in failure while trying to parse the binary, which will let domain creation fail.

Quoted 6 lines

In order to avoid this issue, enhance the linker script to merge .note.Xen before other .note.* segments, resulting in the final .note segment to still have the NOTE type.

Fixes 6d1cc81d049f ("x86: switch to use elfnote")

I wonder though ...

arch/x86/minios-x86.lds.S SECTIONS · line 38

Quoted 9 lines
arch/x86/minios-x86.lds.S +1 -0
@@ -33,6 +33,7 @@ SECTIONS
 
         .note : {
                 *(.note)
+                *(.note.Xen)
                 *(.note.*)
         }

... what use .note here is. Can't it be dropped in exchange?

Jan

#2 lore raw
Quoted 34 lines · Jan Beulich
Quoted 18 lines · Juergen Gross

Today the linker script of Mini-OS specifies to merge all .note* sections into a single section .note:

  .note : {
           *(.note)
           *(.note.*)
   }

It seems as if ld will use the attributes of the first .note* segment found during the linking process for the final .note segment.

Somewhere between binutils 2.43 and 2.45 something changed resulting in .note.GNU-stack being the first .note* segment found. Unfortunately this segment has unusual attributes: it has PROGBITS instead of NOTE as type, resulting in the Xen ELF parsing to no longer look into it for finding the Xen ELF-notes. This in turn will result in failure while trying to parse the binary, which will let domain creation fail.

Quoted 6 lines

In order to avoid this issue, enhance the linker script to merge .note.Xen before other .note.* segments, resulting in the final .note segment to still have the NOTE type.

Fixes 6d1cc81d049f ("x86: switch to use elfnote")

I wonder though ...

Quoted 4 lines
arch/x86/minios-x86.lds.S +0 -0
@@ -33,6 +33,7 @@ SECTIONS
 
Quoted 7 lines

arch/x86/minios-x86.lds.S SECTIONS · line 38

Quoted 5 lines
arch/x86/minios-x86.lds.S +1 -0
          .note : {
                  *(.note)
+                *(.note.Xen)
                  *(.note.*)
          }

... what use .note here is. Can't it be dropped in exchange?

Dropping it seems not to have any negative impact.

In theory this should not be in that patch, though, as its presence was questionable even without my patch.

Juergen