Skip to contentSkip to conversation

xen/link: Include .debug_str_offsets in DWARF2_DEBUG_SECTIONS

PATCH In review Andrew Cooper 2 participants 4 messages Apr 22, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/link: Include .debug_str_offsets in DWARF2_DEBUG_SECTIONS

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

---
CC: Anthony PERARD <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Julien Grall <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>

---
 xen/include/xen/xen.lds.h | 1 +
 1 file changed, 1 insertion(+)
xen/include/xen/xen.lds.h +1 -0
index 16a9b1ba03db..bf75e22953bc 100644
@@ -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)                     \
Signature · 1 line
2.39.5
Reviewed-by on v1 1/1
#1 lore raw

xen/include/xen/xen.lds.h line 59

Quoted 7 lines · Andrew Cooper
xen/include/xen/xen.lds.h +1 -0
@@ -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:

Jan

#2 lore raw
Quoted 9 lines · Jan Beulich

xen/include/xen/xen.lds.h line 59

Quoted 7 lines · Andrew Cooper
xen/include/xen/xen.lds.h +1 -0
@@ -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:

Quoted 4 lines

[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

#3 lore raw
Quoted 11 lines · Andrew Cooper
Quoted 9 lines · Jan Beulich

xen/include/xen/xen.lds.h line 59

Quoted 7 lines · Andrew Cooper
xen/include/xen/xen.lds.h +1 -0
@@ -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.

Quoted 5 lines

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

Quoted 2 lines

[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.

Quoted 4 lines
Quoted 2 lines

[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