[PATCH] xen/link: Include .debug_str_offsets in DWARF2_DEBUG_SECTIONS

Andrew Cooper posted 1 patch 8 months ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20250422113247.1285339-1-andrew.cooper3@citrix.com
xen/include/xen/xen.lds.h | 1 +
1 file changed, 1 insertion(+)
[PATCH] xen/link: Include .debug_str_offsets in DWARF2_DEBUG_SECTIONS
Posted by Andrew Cooper 8 months ago
Building Xen with Clang-17 yields the following warning:

  ld: warning: orphan section `.debug_str_offsets' from `prelink.o' being placed in section `.debug_str_offsets'
  ld: ./.xen.efi.0xffff82d040000000.0:/4: section below image base
  ld: ./.xen.efi.0xffff82d040000000.1:/4: section below image base
  ld: warning: orphan section `.debug_str_offsets' from `prelink.o' being placed in section `.debug_str_offsets'
  ld: xen.efi:/4: section below image base

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
---
 xen/include/xen/xen.lds.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/xen/include/xen/xen.lds.h b/xen/include/xen/xen.lds.h
index 16a9b1ba03db..bf75e22953bc 100644
--- a/xen/include/xen/xen.lds.h
+++ b/xen/include/xen/xen.lds.h
@@ -56,6 +56,7 @@
   DECL_DEBUG2(.debug_info, .gnu.linkonce.wi.*, 1) \
   DECL_DEBUG(.debug_types, 1)                     \
   DECL_DEBUG(.debug_str, 1)                       \
+  DECL_DEBUG(.debug_str_offsets, 1)               \
   DECL_DEBUG2(.debug_line, .debug_line.*, 1)      \
   DECL_DEBUG(.debug_line_str, 1)                  \
   DECL_DEBUG(.debug_names, 4)                     \
-- 
2.39.5


Re: [PATCH] xen/link: Include .debug_str_offsets in DWARF2_DEBUG_SECTIONS
Posted by Jan Beulich 8 months ago
On 22.04.2025 13:32, Andrew Cooper wrote:
> --- a/xen/include/xen/xen.lds.h
> +++ b/xen/include/xen/xen.lds.h
> @@ -56,6 +56,7 @@
>    DECL_DEBUG2(.debug_info, .gnu.linkonce.wi.*, 1) \
>    DECL_DEBUG(.debug_types, 1)                     \
>    DECL_DEBUG(.debug_str, 1)                       \
> +  DECL_DEBUG(.debug_str_offsets, 1)               \

The alignment wants to be at least 4. I don't think it needs to be 8, as
I don't expect us to require a 64-bit Dwarf container any time soon. Then:
Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan
Re: [PATCH] xen/link: Include .debug_str_offsets in DWARF2_DEBUG_SECTIONS
Posted by Andrew Cooper 8 months ago
On 22/04/2025 1:13 pm, Jan Beulich wrote:
> On 22.04.2025 13:32, Andrew Cooper wrote:
>> --- a/xen/include/xen/xen.lds.h
>> +++ b/xen/include/xen/xen.lds.h
>> @@ -56,6 +56,7 @@
>>    DECL_DEBUG2(.debug_info, .gnu.linkonce.wi.*, 1) \
>>    DECL_DEBUG(.debug_types, 1)                     \
>>    DECL_DEBUG(.debug_str, 1)                       \
>> +  DECL_DEBUG(.debug_str_offsets, 1)               \
> The alignment wants to be at least 4.

I checked before making this patch, and Clang uses alignment 1 on the
section:

> [8134] .debug_str_offsets PROGBITS        0000000000000000 16fe11d
> 21c868 00      0   0  1
> [8135] .rela.debug_str_offsets RELA       0000000000000000 2089e08
> ca6b60 18   I 8136 8134  8

Is there an official spec on the matter?

~Andrew

Re: [PATCH] xen/link: Include .debug_str_offsets in DWARF2_DEBUG_SECTIONS
Posted by Jan Beulich 8 months ago
On 22.04.2025 16:42, Andrew Cooper wrote:
> On 22/04/2025 1:13 pm, Jan Beulich wrote:
>> On 22.04.2025 13:32, Andrew Cooper wrote:
>>> --- a/xen/include/xen/xen.lds.h
>>> +++ b/xen/include/xen/xen.lds.h
>>> @@ -56,6 +56,7 @@
>>>    DECL_DEBUG2(.debug_info, .gnu.linkonce.wi.*, 1) \
>>>    DECL_DEBUG(.debug_types, 1)                     \
>>>    DECL_DEBUG(.debug_str, 1)                       \
>>> +  DECL_DEBUG(.debug_str_offsets, 1)               \
>> The alignment wants to be at least 4.
> 
> I checked before making this patch, and Clang uses alignment 1 on the
> section:
> 
>> [8134] .debug_str_offsets PROGBITS        0000000000000000 16fe11d
>> 21c868 00      0   0  1

Oh, I'm surprised. The table holding 4- (or 8-) byte values, it should
have better alignment already in object files, I would think. Feels like
a bug / oversight in Clang.

>> [8135] .rela.debug_str_offsets RELA       0000000000000000 2089e08
>> ca6b60 18   I 8136 8134  8
> 
> Is there an official spec on the matter?

I did look through the Dwarf5 spec, but could find any detail of this
kind there.

Jan