ld/pdb: Handle bigobj input files in handle_debugs_section
Checks
Commit Message
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 | 8 +++++---
ld/testsuite/ld-pe/pdb.exp | 39 +++++++++++++++++++++++---------------
2 files changed, 29 insertions(+), 18 deletions(-)
Comments
On 02.11.2026 23:59, Oleg Tolmatcev wrote:
> --- a/ld/pdb.c
> +++ b/ld/pdb.c
> @@ -1940,20 +1940,22 @@ 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;
> + bfd_size_type symesz;
>
> syment_count = obj_raw_syment_count (mod);
> + symesz = bfd_coff_symesz (mod);
Can't this be the initializer of the variable?
> relocs = bfd_coff_read_internal_relocs (mod, s, false, NULL, true, NULL);
>
> symbols = xmalloc (sizeof (struct internal_syment) * syment_count);
> sectlist = xmalloc (sizeof (asection *) * syment_count);
>
> - ext = (struct external_syment *) (coff_data (mod)->external_syms);
> + ext = (bfd_byte *) coff_data (mod)->external_syms;
Same here, perhaps. Additionally there's no need for a cast here (we're
trying to get rid of such unnecessary casts as we touch code).
> @@ -1862,7 +1868,10 @@ proc test11 { } {
> test1
> test2
> test3
> -test4
> +test4 ""
> +if { [istarget i*86-*-*] || [istarget x86_64-*-*] } {
> + test4 "-mbig-obj"
> +}
Judging from gas/testsuite/gas/pe/pe.exp aarch64 may want including here,
and interix may need excluding. (Perhaps
binutils/testsuite/lib/binutils-common.exp should gain a suitable predicate,
but that's nothing I'm going to demand doing here.)
Jan
пт, 6 нояб. 2026 г. в 14:07, Jan Beulich <jbeulich@suse.com>:
>
> On 02.11.2026 23:59, Oleg Tolmatcev wrote:
> > --- a/ld/pdb.c
> > +++ b/ld/pdb.c
> > @@ -1940,20 +1940,22 @@ 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;
> > + bfd_size_type symesz;
> >
> > syment_count = obj_raw_syment_count (mod);
> > + symesz = bfd_coff_symesz (mod);
>
> Can't this be the initializer of the variable?
>
> > relocs = bfd_coff_read_internal_relocs (mod, s, false, NULL, true, NULL);
> >
> > symbols = xmalloc (sizeof (struct internal_syment) * syment_count);
> > sectlist = xmalloc (sizeof (asection *) * syment_count);
> >
> > - ext = (struct external_syment *) (coff_data (mod)->external_syms);
> > + ext = (bfd_byte *) coff_data (mod)->external_syms;
>
> Same here, perhaps. Additionally there's no need for a cast here (we're
> trying to get rid of such unnecessary casts as we touch code).
>
> > @@ -1862,7 +1868,10 @@ proc test11 { } {
> > test1
> > test2
> > test3
> > -test4
> > +test4 ""
> > +if { [istarget i*86-*-*] || [istarget x86_64-*-*] } {
> > + test4 "-mbig-obj"
> > +}
>
> Judging from gas/testsuite/gas/pe/pe.exp aarch64 may want including here,
> and interix may need excluding. (Perhaps
I included aarch64, but interix is already excluded by the guard at
the top of the file.
> binutils/testsuite/lib/binutils-common.exp should gain a suitable predicate,
> but that's nothing I'm going to demand doing here.)
>
> Jan
Oleg
@@ -1940,20 +1940,22 @@ 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;
+ bfd_size_type symesz;
syment_count = obj_raw_syment_count (mod);
+ symesz = bfd_coff_symesz (mod);
relocs = bfd_coff_read_internal_relocs (mod, s, false, NULL, true, NULL);
symbols = xmalloc (sizeof (struct internal_syment) * syment_count);
sectlist = xmalloc (sizeof (asection *) * syment_count);
- ext = (struct external_syment *) (coff_data (mod)->external_syms);
+ ext = (bfd_byte *) 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);
i += symbols[i].n_numaux;
@@ -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-*-*] } {
+ test4 "-mbig-obj"
+}
test5
test6
test7