[PATCH] xen: Fix EFI buildid alignment

Marek Marczykowski-Górecki posted 1 patch 3 weeks, 3 days ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20251119191235.863187-1-marmarek@invisiblethingslab.com
xen/arch/x86/xen.lds.S | 2 ++
1 file changed, 2 insertions(+)
[PATCH] xen: Fix EFI buildid alignment
Posted by Marek Marczykowski-Górecki 3 weeks, 3 days ago
Old binutils get confused about .buildid overlapping (in VA space) with
earlier section. That confusion results in weird errors down the road,
like this one:

    objcopy: xen.efi: Data Directory size (1c) exceeds space left in section (8)

While the bug is fixed in later binutils version, force alignment of the
buildid to avoid overlapping and make it work with older versions too.
This can be reverted once toolchain base is raised at or above binutils
2.36.

Details at:
https://lore.kernel.org/all/3TMd7J2u5gCA8ouIG_Xfcw7s5JKMG06XsDIesEB3Fi9htUJ43Lfl057wXohlpCHcszqoCmicpIlneEDO26ZqT8QfC2Y39VxBuqD3nS1j5Q4=@trmm.net/

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Fixes: eee5909e9d1e ("x86/EFI: use less crude a way of generating the build ID")
---
While the actual bug apparently is in binutils, the commit mentioned in
Fixes: tag introduced part that triggers that bug.
---
 xen/arch/x86/xen.lds.S | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index 5d02f83a409c..967f9167f757 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -171,6 +171,8 @@ SECTIONS
        __note_gnu_build_id_end = .;
   } PHDR(note) PHDR(text)
 #elif defined(BUILD_ID_EFI)
+  /* Workaround bug in binutils < 2.38 */
+  . = ALIGN(32);
   DECL_SECTION(.buildid) {
        __note_gnu_build_id_start = .;
        *(.buildid)
-- 
2.51.0


Re: [PATCH] xen: Fix EFI buildid alignment
Posted by Andrew Cooper 3 weeks, 3 days ago
On 19/11/2025 7:12 pm, Marek Marczykowski-Górecki wrote:
> Old binutils get confused about .buildid overlapping (in VA space) with
> earlier section. That confusion results in weird errors down the road,
> like this one:
>
>     objcopy: xen.efi: Data Directory size (1c) exceeds space left in section (8)
>
> While the bug is fixed in later binutils version, force alignment of the
> buildid to avoid overlapping and make it work with older versions too.
> This can be reverted once toolchain base is raised at or above binutils
> 2.36.
>
> Details at:
> https://lore.kernel.org/all/3TMd7J2u5gCA8ouIG_Xfcw7s5JKMG06XsDIesEB3Fi9htUJ43Lfl057wXohlpCHcszqoCmicpIlneEDO26ZqT8QfC2Y39VxBuqD3nS1j5Q4=@trmm.net/
>
> Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> Fixes: eee5909e9d1e ("x86/EFI: use less crude a way of generating the build ID")

We typically put these tags in the other order.  I can fix on commit.

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>, although...

> ---
> While the actual bug apparently is in binutils, the commit mentioned in
> Fixes: tag introduced part that triggers that bug.
> ---
>  xen/arch/x86/xen.lds.S | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
> index 5d02f83a409c..967f9167f757 100644
> --- a/xen/arch/x86/xen.lds.S
> +++ b/xen/arch/x86/xen.lds.S
> @@ -171,6 +171,8 @@ SECTIONS
>         __note_gnu_build_id_end = .;
>    } PHDR(note) PHDR(text)
>  #elif defined(BUILD_ID_EFI)
> +  /* Workaround bug in binutils < 2.38 */

... this says 2.38, but the commit message says 2.36.  Which one is it?

~Andrew

> +  . = ALIGN(32);
>    DECL_SECTION(.buildid) {
>         __note_gnu_build_id_start = .;
>         *(.buildid)


Re: [PATCH] xen: Fix EFI buildid alignment
Posted by Marek Marczykowski-Górecki 3 weeks, 3 days ago
On Thu, Nov 20, 2025 at 12:43:57AM +0000, Andrew Cooper wrote:
> On 19/11/2025 7:12 pm, Marek Marczykowski-Górecki wrote:
> > Old binutils get confused about .buildid overlapping (in VA space) with
> > earlier section. That confusion results in weird errors down the road,
> > like this one:
> >
> >     objcopy: xen.efi: Data Directory size (1c) exceeds space left in section (8)
> >
> > While the bug is fixed in later binutils version, force alignment of the
> > buildid to avoid overlapping and make it work with older versions too.
> > This can be reverted once toolchain base is raised at or above binutils
> > 2.36.
> >
> > Details at:
> > https://lore.kernel.org/all/3TMd7J2u5gCA8ouIG_Xfcw7s5JKMG06XsDIesEB3Fi9htUJ43Lfl057wXohlpCHcszqoCmicpIlneEDO26ZqT8QfC2Y39VxBuqD3nS1j5Q4=@trmm.net/
> >
> > Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> > Fixes: eee5909e9d1e ("x86/EFI: use less crude a way of generating the build ID")
> 
> We typically put these tags in the other order.  I can fix on commit.
> 
> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>, although...
> 
> > ---
> > While the actual bug apparently is in binutils, the commit mentioned in
> > Fixes: tag introduced part that triggers that bug.
> > ---
> >  xen/arch/x86/xen.lds.S | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
> > index 5d02f83a409c..967f9167f757 100644
> > --- a/xen/arch/x86/xen.lds.S
> > +++ b/xen/arch/x86/xen.lds.S
> > @@ -171,6 +171,8 @@ SECTIONS
> >         __note_gnu_build_id_end = .;
> >    } PHDR(note) PHDR(text)
> >  #elif defined(BUILD_ID_EFI)
> > +  /* Workaround bug in binutils < 2.38 */
> 
> ... this says 2.38, but the commit message says 2.36.  Which one is it?

2.36

> ~Andrew
> 
> > +  . = ALIGN(32);
> >    DECL_SECTION(.buildid) {
> >         __note_gnu_build_id_start = .;
> >         *(.buildid)
> 

-- 
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
Re: [PATCH] xen: Fix EFI buildid alignment
Posted by Andrew Cooper 3 weeks, 2 days ago
On 20/11/2025 1:33 am, Marek Marczykowski-Górecki wrote:
> On Thu, Nov 20, 2025 at 12:43:57AM +0000, Andrew Cooper wrote:
>> On 19/11/2025 7:12 pm, Marek Marczykowski-Górecki wrote:
>>> Old binutils get confused about .buildid overlapping (in VA space) with
>>> earlier section. That confusion results in weird errors down the road,
>>> like this one:
>>>
>>>     objcopy: xen.efi: Data Directory size (1c) exceeds space left in section (8)
>>>
>>> While the bug is fixed in later binutils version, force alignment of the
>>> buildid to avoid overlapping and make it work with older versions too.
>>> This can be reverted once toolchain base is raised at or above binutils
>>> 2.36.
>>>
>>> Details at:
>>> https://lore.kernel.org/all/3TMd7J2u5gCA8ouIG_Xfcw7s5JKMG06XsDIesEB3Fi9htUJ43Lfl057wXohlpCHcszqoCmicpIlneEDO26ZqT8QfC2Y39VxBuqD3nS1j5Q4=@trmm.net/
>>>
>>> Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
>>> Fixes: eee5909e9d1e ("x86/EFI: use less crude a way of generating the build ID")
>> We typically put these tags in the other order.  I can fix on commit.
>>
>> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>, although...
>>
>>> ---
>>> While the actual bug apparently is in binutils, the commit mentioned in
>>> Fixes: tag introduced part that triggers that bug.
>>> ---
>>>  xen/arch/x86/xen.lds.S | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
>>> index 5d02f83a409c..967f9167f757 100644
>>> --- a/xen/arch/x86/xen.lds.S
>>> +++ b/xen/arch/x86/xen.lds.S
>>> @@ -171,6 +171,8 @@ SECTIONS
>>>         __note_gnu_build_id_end = .;
>>>    } PHDR(note) PHDR(text)
>>>  #elif defined(BUILD_ID_EFI)
>>> +  /* Workaround bug in binutils < 2.38 */
>> ... this says 2.38, but the commit message says 2.36.  Which one is it?
> 2.36

Thanks.  I'll adjust on commit.

~Andrew