gcc/binutils: apply codeview fixes (#24205)

See #24148

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120051
This commit is contained in:
Christoph Reiter
2025-05-09 23:11:33 +02:00
committed by GitHub
parent fcecb88a6f
commit 4f92ed7ae9
4 changed files with 151 additions and 3 deletions

View File

@@ -0,0 +1,11 @@
--- binutils-2.44/ld/pdb.c.orig 2025-02-02 03:00:00 +0300
+++ binutils-2.44/ld/pdb.c 2025-05-05 13:20:14 +0300
@@ -1880,7 +1880,7 @@
return false;
}
- version = bfd_getl32 (data + sizeof (uint32_t) + sizeof (uint32_t));
+ version = bfd_getl32 (data);
if (version != CV_INLINEE_SOURCE_LINE_SIGNATURE)
{
einfo (_("%P: warning: unexpected DEBUG_S_INLINEELINES version %u\n"),

View File

@@ -6,7 +6,7 @@ _realname=binutils
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.44
pkgrel=1
pkgrel=2
pkgdesc="A set of programs to assemble and manipulate binary and object files (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64')
@@ -32,6 +32,7 @@ source=(https://ftp.gnu.org/gnu/binutils/${_realname}-${pkgver}.tar.bz2{,.sig}
reproducible-import-libraries.patch
libiberty-unlink-handle-windows-nul.patch
3001-hack-libiberty-link-order.patch
4000-fix-DEBUG_S_INLINEELINES.patch
)
sha256sums=('f66390a661faa117d00fab2e79cf2dc9d097b42cc296bf3f8677d1e7b452dc3a'
'SKIP'
@@ -42,7 +43,8 @@ sha256sums=('f66390a661faa117d00fab2e79cf2dc9d097b42cc296bf3f8677d1e7b452dc3a'
'd584f1cd9e94cba0e9b27625c4acc8ad5242cd625c9b44839d42fc116072568c'
'a094660ec95996c00b598429843b7869037732146442af567ada9f539bd40480'
'7ccbd418695733c50966068fa9755a6abb156f53af23701d2bc097c63e9e0030'
'604628156c08f3e361de60329af250fab6839e23e61e289f8369a7e18a04e277')
'604628156c08f3e361de60329af250fab6839e23e61e289f8369a7e18a04e277'
'bf5d75aa342ccbc450fe48d99278567efc5a7973432b0966e98109fb0029fc42')
validpgpkeys=('EAF1C276A747E9ED86210CBAC3126D3B4AE55E93' # Tristan Gingold <gingold@adacore.com>
'3A24BC1E8FB409FA9F14371813FCEF89DD9E3C4F') # Nick Clifton <nickc@redhat.com>
@@ -89,6 +91,10 @@ prepare() {
# search paths, so imho if things link against the system lib or the just
# built one is just luck, and I don't know how that is supposed to work.
patch -p1 -i "${srcdir}/3001-hack-libiberty-link-order.patch"
# https://github.com/msys2/MINGW-packages/issues/24148
# https://sourceware.org/bugzilla/show_bug.cgi?id=32942
patch -p1 -i "${srcdir}/4000-fix-DEBUG_S_INLINEELINES.patch"
}
build() {

View File

@@ -0,0 +1,125 @@
--- ./gcc/dwarf2codeview.cc.orig 2025-04-25 11:18:00 +0300
+++ ./gcc/dwarf2codeview.cc 2025-05-09 12:23:01 +0300
@@ -1178,6 +1178,7 @@
codeview_function *next;
codeview_function *htab_next;
function *func;
+ dw_die_ref decl_die;
unsigned int end_label;
codeview_line_block *blocks, *last_block;
codeview_function *parent;
@@ -1472,7 +1473,7 @@
static bool equal (const codeview_function *f, dw_die_ref die)
{
- return lookup_decl_die (f->func->decl) == die;
+ return f->decl_die == die;
}
};
@@ -1566,7 +1567,7 @@
if (!cv_func_htab)
cv_func_htab = new hash_table<cv_func_hasher> (10);
- die = lookup_decl_die (cfun->decl);
+ f->decl_die = die = lookup_decl_die (cfun->decl);
slot = cv_func_htab->find_slot_with_hash (die, htab_hash_pointer (die),
INSERT);
@@ -2281,6 +2282,9 @@
const char *name = get_AT_string (die, DW_AT_name);
uint32_t type;
+ if (!name)
+ return;
+
/* This is struct LOCALSYM in Microsoft's cvinfo.h:
struct LOCALSYM {
@@ -2597,7 +2601,7 @@
} ATTRIBUTE_PACKED;
*/
- if (!fbloc)
+ if (!fbloc || !name)
return;
if (fbloc->dw_loc_opc >= DW_OP_breg0 && fbloc->dw_loc_opc <= DW_OP_breg31)
@@ -3455,6 +3459,9 @@
codeview_function *top_parent;
unsigned int line_no, label_num;
+ if (!inlinee_lines_htab)
+ return;
+
slot = inlinee_lines_htab->find_slot_with_hash (func_id, func_id, NO_INSERT);
if (!slot || !*slot)
return;
@@ -4465,8 +4472,9 @@
fprint_whex (asm_out_file, t->lf_enum.fieldlist);
putc ('\n', asm_out_file);
- name_len = strlen (t->lf_enum.name) + 1;
- ASM_OUTPUT_ASCII (asm_out_file, t->lf_enum.name, name_len);
+ const char* ename = t->lf_enum.name ? t->lf_enum.name : "<unnamed-tag>";
+ name_len = strlen (ename) + 1;
+ ASM_OUTPUT_ASCII (asm_out_file, ename, name_len);
leaf_len = 14 + name_len;
write_cv_padding (4 - (leaf_len % 4));
@@ -5175,11 +5183,11 @@
write_source_files ();
write_line_numbers ();
+ write_codeview_symbols ();
+
if (inlinee_lines_htab)
write_inlinee_lines ();
- write_codeview_symbols ();
-
/* If we reference a nested struct but not its parent, add_deferred_type
gets called if we create a forward reference for this, even though we've
already flushed this in codeview_debug_early_finish. In this case we will
@@ -6318,6 +6326,7 @@
codeview_custom_type *ct;
uint16_t num_members = 0;
uint32_t last_type = 0;
+ codeview_type **slot;
parent = dw_get_die_parent(type);
@@ -6335,6 +6344,20 @@
*is_fwd_ref = false;
+ /* Let's check if there was a declaration of our type and, if not, add it -
+ otherwise, infinite recursion is possible when processing fields and
+ member-functions. */
+ slot = types_htab->find_slot_with_hash (type, htab_hash_pointer (type), INSERT);
+ if (!*slot)
+ {
+ *slot = (codeview_type *) xmalloc (sizeof (codeview_type));
+ (*slot)->die = type;
+ (*slot)->is_fwd_ref = true;
+ (*slot)->num = 0;
+ }
+ if (!(*slot)->num)
+ (*slot)->num = add_struct_forward_def (type);
+
/* First, add an LF_FIELDLIST for the structure's members. We don't need to
worry about deduplication here, as ld will take care of that for us.
If there's a lot of entries, add more LF_FIELDLISTs with LF_INDEXes
@@ -6784,7 +6807,11 @@
ct = (codeview_custom_type *) xmalloc (sizeof (codeview_custom_type));
- size *= get_AT_unsigned (dimension_arr[i], DW_AT_upper_bound) + 1;
+ { /* skip variable size array */
+ dw_attr_node *a = get_AT (dimension_arr[i], DW_AT_upper_bound);
+ if (a && AT_class (a) != dw_val_class_loc)
+ size *= AT_unsigned (a) + 1;
+ }
index = get_AT_ref (dimension_arr[i], DW_AT_type);

View File

@@ -51,7 +51,7 @@ else
_sourcedir=${_realname}-${_version}-${_snapshot}
_url=https://gcc.gnu.org/pub/gcc/snapshots/${_version}-${_snapshot}
fi
pkgrel=2
pkgrel=3
pkgdesc="GCC for the MinGW-w64"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64')
@@ -93,6 +93,7 @@ source=(${_url}/${_sourcedir}.tar.xz{,.sig}
0140-gcc-diagnostic-color.patch
0200-add-m-no-align-vector-insn-option-for-i386.patch
2001-fix-building-rust-on-mingw-w64.patch
3001-fix-codeview-crashes.patch
9002-native-tls.patch)
sha256sums=('e2b09ec21660f01fecffb715e0120265216943f038d0e48a9868713e54f06cea'
'SKIP'
@@ -109,6 +110,7 @@ sha256sums=('e2b09ec21660f01fecffb715e0120265216943f038d0e48a9868713e54f06cea'
'ba3649f29049f6d4eea4a481975d9f6851c0c2604d847881b46084a943c4c8f2'
'1484911163634f30324827619c873a6267b377abba0df8bbedfd128163c53ea4'
'a411f59953553a3d01dd64c79b1acbb91eca092c4cb01bfd26b1c51c3eb798e8'
'335aa549e3ba2b86704c9a261497b2fc8eb9f18d41485b3d8494f95c184d9bdf'
'd977683efc6f6b4dd675a8f1978416d22d5b5d1fa53614b9a18bc18efa231391')
validpgpkeys=(F3691687D867B81B51CE07D9BBE43771487328A9 # bpiotrowski@archlinux.org
86CFFCA918CF3AF47147588051E8B148A9999C34 # evangelos@foutrelis.com
@@ -165,6 +167,10 @@ prepare() {
apply_patch_with_msg \
2001-fix-building-rust-on-mingw-w64.patch
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120051
apply_patch_with_msg \
3001-fix-codeview-crashes.patch
# apply_patch_with_msg \
# 9002-native-tls.patch