]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
ld/PDB: handle empty LF_FIELDLIST types
authorMark Harmstone <mark@harmstone.com>
Mon, 29 Jul 2024 21:19:36 +0000 (22:19 +0100)
committerMark Harmstone <mark@harmstone.com>
Thu, 1 Aug 2024 00:33:34 +0000 (01:33 +0100)
Empty structs in C++ lead to empty LF_FIELDLIST types in the .debug$T
section, but we were mistakenly rejecting these as invalid. Allow
CodeView types of two bytes, and add a test for this.

ld/pdb.c
ld/testsuite/ld-pe/pdb-types1-typelist.d
ld/testsuite/ld-pe/pdb-types1b.s
ld/testsuite/ld-pe/pdb.exp

index 7a08ae35e79f46ba9d37222365b1e26dc420257b..fcbe325603c9c2d0a7211c1e13f6284bed525d3b 100644 (file)
--- a/ld/pdb.c
+++ b/ld/pdb.c
@@ -3582,7 +3582,7 @@ handle_debugt_section (asection *s, bfd *mod, struct types *types,
       size = bfd_getl16 (data + off);
       off += sizeof (uint16_t);
 
-      if (size + off > s->size || size <= sizeof (uint16_t))
+      if (size + off > s->size || size < sizeof (uint16_t))
        {
          free (data);
          bfd_set_error (bfd_error_bad_value);
index db08b52859fc673164a22a6947f92010291387a6..1caa074ac56be1d9343b2b3fc5c1b89751b8a04f 100644 (file)
@@ -77,4 +77,7 @@ Contents of section .data:
  0480 3a001d15 2a100000 00000000 00000000  :...*...........
  0490 27000000 49556e6b 6e6f776e 00517565  '...IUnknown.Que
  04a0 7279496e 74657266 61636500 41646452  ryInterface.AddR
- 04b0 65660052 656c6561 736500f1           ef.Release..    
+ 04b0 65660052 656c6561 736500f1 02000312  ef.Release......
+ 04c0 22000515 00000000 2c100000 00000000  ".......,.......
+ 04d0 00000000 0100656d 7074795f 73747275  ......empty_stru
+ 04e0 637400f1                             ct..            
index e26b190b78f438c291045b6ab444c732261c548c..8bfc973c1c80a2cfc29c5b5b6043f83f0dd0736e 100644 (file)
 
 /* Type 102a, virtual function table */
 .vftable1:
-.short .types_end - .vftable1 - 2
+.short .fieldlist12 - .vftable1 - 2
 .short LF_VFTABLE
 .long 0x1029 /* type */
 .long 0 /* base vftable */
 .vftable1_names_end:
 .byte 0xf1 /* padding */
 
+/* Type 102b, empty LF_FIELDLIST */
+.fieldlist12:
+.short .struct7 - .fieldlist12 - 2
+.short LF_FIELDLIST
+
+/* Type 102c, empty struct */
+.struct7:
+.short .types_end - .struct7 - 2
+.short LF_STRUCTURE
+.short 0 /* no. members */
+.short 0 /* property */
+.long 0x102b /* field list */
+.long 0 /* type derived from */
+.long 0 /* type of vshape table */
+.short 1 /* size */
+.asciz "empty_struct" /* name */
+.byte 0xf1 /* padding */
+
 .types_end:
index 124765109bf1479ede6e862eabab3176ecc10f34..b583e877f0176f445b8d3352d583ad99296b5981 100644 (file)
@@ -1036,7 +1036,7 @@ proc test5 { } {
     binary scan $data i end_type
 
     # end_type is one greater than the last type in the stream
-    if { $end_type != 0x102c } {
+    if { $end_type != 0x102e } {
        fail "Incorrect end type value in TPI stream."
     } else {
        pass "Correct end type value in TPI stream."