[PATCH v2] ld/pdb: Handle bigobj input files in handle_debugs_section
Oleg Tolmatcev
oleg.tolmatcev@gmail.com
Fri Nov 6 20:33:41 GMT 2026
handle_debugs_section stepped through the raw COFF symbol table using
sizeof (struct external_syment), but symbol table entries in
pe-bigobj files are 20 bytes rather than 18. Use bfd_coff_symesz
instead.
Run the C13 line info test a second time with objects assembled with
-mbig-obj on x86.
ld/
* pdb.c (handle_debugs_section): Use bfd_coff_symesz to step
through the raw symbol table.
* testsuite/ld-pe/pdb.exp (test4): Take assembler flags. Run it
with -mbig-obj on x86.
Signed-off-by: Oleg Tolmatcev <oleg.tolmatcev@gmail.com>
---
ld/pdb.c | 7 +++----
ld/testsuite/ld-pe/pdb.exp | 39 +++++++++++++++++++++++---------------
2 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/ld/pdb.c b/ld/pdb.c
index c06cc635cbe..df1f88af7fa 100644
--- a/ld/pdb.c
+++ b/ld/pdb.c
@@ -1940,7 +1940,8 @@ handle_debugs_section (asection *s, bfd *mod, struct string_table *strings,
struct internal_syment *symbols;
asection **sectlist;
unsigned int syment_count;
- struct external_syment *ext;
+ bfd_byte *ext = coff_data (mod)->external_syms;
+ bfd_size_type symesz = bfd_coff_symesz (mod);
syment_count = obj_raw_syment_count (mod);
@@ -1949,11 +1950,9 @@ handle_debugs_section (asection *s, bfd *mod, struct string_table *strings,
symbols = xmalloc (sizeof (struct internal_syment) * syment_count);
sectlist = xcalloc (syment_count, sizeof (*sectlist));
- ext = (struct external_syment *) (coff_data (mod)->external_syms);
-
for (unsigned int i = 0; i < syment_count; i++)
{
- bfd_coff_swap_sym_in (mod, &ext[i], &symbols[i]);
+ bfd_coff_swap_sym_in (mod, ext + i * symesz, &symbols[i]);
if (symbols[i].n_scnum > 0)
sectlist[i] = coff_section_from_bfd_index (mod, symbols[i].n_scnum);
diff --git a/ld/testsuite/ld-pe/pdb.exp b/ld/testsuite/ld-pe/pdb.exp
index 48b0f517ec7..477c573fc05 100644
--- a/ld/testsuite/ld-pe/pdb.exp
+++ b/ld/testsuite/ld-pe/pdb.exp
@@ -839,7 +839,7 @@ proc extract_c13_info { pdb mod_info } {
return $data
}
-proc test4 { } {
+proc test4 { asflags } {
global as
global ar
global ld
@@ -847,18 +847,24 @@ proc test4 { } {
global srcdir
global subdir
- if ![ld_assemble $as $srcdir/$subdir/pdb3a.s tmpdir/pdb3a.o] {
- unsupported "Build pdb3a.o"
+ if { $asflags eq "" } {
+ set desc ""
+ } else {
+ set desc " ($asflags)"
+ }
+
+ if ![ld_assemble_flags $as $asflags $srcdir/$subdir/pdb3a.s tmpdir/pdb3a.o] {
+ unsupported "Build pdb3a.o$desc"
return
}
- if ![ld_assemble $as $srcdir/$subdir/pdb3b.s tmpdir/pdb3b.o] {
- unsupported "Build pdb3b.o"
+ if ![ld_assemble_flags $as $asflags $srcdir/$subdir/pdb3b.s tmpdir/pdb3b.o] {
+ unsupported "Build pdb3b.o$desc"
return
}
if ![ld_link $ld "tmpdir/pdb3.exe" "--pdb=tmpdir/pdb3.pdb --gc-sections -e main tmpdir/pdb3a.o tmpdir/pdb3b.o"] {
- unsupported "Create PE image with PDB file"
+ unsupported "Create PE image with PDB file$desc"
return
}
@@ -867,10 +873,10 @@ proc test4 { } {
set exec_output [run_host_cmd "$ar" "x --output tmpdir tmpdir/pdb3.pdb 0003"]
if ![string match "" $exec_output] {
- fail "Could not extract DBI stream"
+ fail "Could not extract DBI stream$desc"
return
} else {
- pass "Extracted DBI stream"
+ pass "Extracted DBI stream$desc"
}
set fi [open tmpdir/0003]
@@ -913,9 +919,9 @@ proc test4 { } {
set got [run_host_cmd "$objdump" "-s --target=binary tmpdir/pdb3-source-info"]
if [string match $exp $got] {
- pass "Correct source info substream"
+ pass "Correct source info substream$desc"
} else {
- fail "Incorrect source info substream"
+ fail "Incorrect source info substream$desc"
}
# check C13 info in first module
@@ -931,9 +937,9 @@ proc test4 { } {
set got [run_host_cmd "$objdump" "-s --target=binary tmpdir/pdb3-c13-info1"]
if [string match $exp $got] {
- pass "Correct C13 info for first module"
+ pass "Correct C13 info for first module$desc"
} else {
- fail "Incorrect C13 info for first module"
+ fail "Incorrect C13 info for first module$desc"
}
# check C13 info in second module
@@ -958,9 +964,9 @@ proc test4 { } {
set got [run_host_cmd "$objdump" "-s --target=binary tmpdir/pdb3-c13-info2"]
if [string match $exp $got] {
- pass "Correct C13 info for second module"
+ pass "Correct C13 info for second module$desc"
} else {
- fail "Incorrect C13 info for second module"
+ fail "Incorrect C13 info for second module$desc"
}
}
@@ -1862,7 +1868,10 @@ proc test11 { } {
test1
test2
test3
-test4
+test4 ""
+if { [istarget i*86-*-*] || [istarget x86_64-*-*] || [istarget aarch64-*-*] } {
+ test4 "-mbig-obj"
+}
test5
test6
test7
--
2.56.0.windows.4
More information about the Binutils
mailing list