diff options
author | Mark Harmstone <mark@harmstone.com> | 2022-10-31 00:15:54 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2022-10-31 12:57:26 +1030 |
commit | 0882710510059d9bf10d3e2324e0441029b50ce9 (patch) | |
tree | b358e0a0a93cba04e81c5ef8f1af392b1a74d654 /ld/testsuite/ld-pe | |
parent | a72672224093ca600154b934ba662b677ae10ba8 (diff) | |
download | gdb-0882710510059d9bf10d3e2324e0441029b50ce9.zip gdb-0882710510059d9bf10d3e2324e0441029b50ce9.tar.gz gdb-0882710510059d9bf10d3e2324e0441029b50ce9.tar.bz2 |
ld: Add publics stream to PDB files
Diffstat (limited to 'ld/testsuite/ld-pe')
-rw-r--r-- | ld/testsuite/ld-pe/pdb.exp | 107 | ||||
-rw-r--r-- | ld/testsuite/ld-pe/pdb1-publics.d | 41 | ||||
-rw-r--r-- | ld/testsuite/ld-pe/pdb1-sym-record.d | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-pe/pdb1.s | 18 |
4 files changed, 171 insertions, 2 deletions
diff --git a/ld/testsuite/ld-pe/pdb.exp b/ld/testsuite/ld-pe/pdb.exp index cee0721..ee314c4 100644 --- a/ld/testsuite/ld-pe/pdb.exp +++ b/ld/testsuite/ld-pe/pdb.exp @@ -395,12 +395,111 @@ proc check_section_stream { img pdb } { return 1 } +proc get_publics_stream_index { pdb } { + global ar + + set exec_output [run_host_cmd "$ar" "x --output tmpdir $pdb 0003"] + + if ![string match "" $exec_output] { + return -1 + } + + set fi [open tmpdir/0003] + fconfigure $fi -translation binary + + # skip fields + seek $fi 16 + + # read substream sizes + + set data [read $fi 2] + binary scan $data s index + + close $fi + + return $index +} + +proc get_sym_record_stream_index { pdb } { + global ar + + set exec_output [run_host_cmd "$ar" "x --output tmpdir $pdb 0003"] + + if ![string match "" $exec_output] { + return -1 + } + + set fi [open tmpdir/0003] + fconfigure $fi -translation binary + + # skip fields + seek $fi 20 + + # read substream sizes + + set data [read $fi 2] + binary scan $data s index + + close $fi + + return $index +} + +proc check_publics_stream { pdb } { + global ar + global objdump + global srcdir + global subdir + + set publics_index [get_publics_stream_index $pdb] + + if { $publics_index == -1 } { + return 0 + } + + set index_str [format "%04x" $publics_index] + + set exec_output [run_host_cmd "$ar" "x --output tmpdir $pdb $index_str"] + + if ![string match "" $exec_output] { + return 0 + } + + set exp [file_contents "$srcdir/$subdir/pdb1-publics.d"] + set got [run_host_cmd "$objdump" "-s --target=binary tmpdir/$index_str"] + if ![string match $exp $got] { + return 0 + } + + set sym_record_index [get_sym_record_stream_index $pdb] + + if { $sym_record_index == -1 } { + return 0 + } + + set index_str [format "%04x" $sym_record_index] + + set exec_output [run_host_cmd "$ar" "x --output tmpdir $pdb $index_str"] + + if ![string match "" $exec_output] { + return 0 + } + + set exp [file_contents "$srcdir/$subdir/pdb1-sym-record.d"] + set got [run_host_cmd "$objdump" "-s --target=binary tmpdir/$index_str"] + if ![string match $exp $got] { + return 0 + } + + return 1 +} + if ![ld_assemble $as $srcdir/$subdir/pdb1.s tmpdir/pdb1.o] { unsupported "Build pdb1.o" return } -if ![ld_link $ld "tmpdir/pdb1.exe" "--pdb=tmpdir/pdb1.pdb tmpdir/pdb1.o"] { +if ![ld_link $ld "tmpdir/pdb1.exe" "--pdb=tmpdir/pdb1.pdb --gc-sections -e foo tmpdir/pdb1.o"] { fail "Could not create a PE image with a PDB file" return } @@ -441,3 +540,9 @@ if [check_section_stream tmpdir/pdb1.exe tmpdir/pdb1.pdb] { } else { fail "Invalid section stream" } + +if [check_publics_stream tmpdir/pdb1.pdb] { + pass "Valid publics stream" +} else { + fail "Invalid publics stream" +} diff --git a/ld/testsuite/ld-pe/pdb1-publics.d b/ld/testsuite/ld-pe/pdb1-publics.d new file mode 100644 index 0000000..f7df2d9 --- /dev/null +++ b/ld/testsuite/ld-pe/pdb1-publics.d @@ -0,0 +1,41 @@ + +*: file format binary + +Contents of section .data: + 0000 2c020000 08000000 00000000 00000000 ,............... + 0010 00000000 00000000 00000000 ffffffff ................ + 0020 1a092ff1 10000000 0c020000 15000000 ../............. + 0030 01000000 01000000 01000000 00000000 ................ + 0040 00000000 00000000 00000000 00000000 ................ + 0050 00000000 00000000 00000000 00000000 ................ + 0060 00000000 00000000 00000000 00000000 ................ + 0070 00000000 00000000 00000000 00000000 ................ + 0080 00000000 00000000 00000000 00000000 ................ + 0090 00000000 00000000 00000000 00000000 ................ + 00a0 00000000 00000000 00000000 00000000 ................ + 00b0 00000000 00000000 00000000 00000000 ................ + 00c0 00000000 00000000 00000000 00000000 ................ + 00d0 00000000 00000000 00000000 00000001 ................ + 00e0 00000000 00000000 00000000 00000000 ................ + 00f0 00000000 00000000 00000000 00000000 ................ + 0100 00000000 00000000 00000000 00000000 ................ + 0110 00000000 00000000 00000000 00000000 ................ + 0120 00000000 00000000 00000000 00000000 ................ + 0130 00000000 00000000 00000000 00000000 ................ + 0140 00000000 00000000 00000000 00000000 ................ + 0150 00000000 00000000 00000000 00000000 ................ + 0160 00000000 00000000 00000000 00000000 ................ + 0170 00000000 00000000 00000000 00000000 ................ + 0180 00000000 00000000 00000000 00000000 ................ + 0190 00000000 00000000 00000000 01000000 ................ + 01a0 00000000 00000000 00000000 00000000 ................ + 01b0 00000000 00000000 00000000 00000000 ................ + 01c0 00000000 00000000 00000000 00000000 ................ + 01d0 00000000 00000000 00000000 00000000 ................ + 01e0 00000000 00000000 00000000 00000000 ................ + 01f0 00000000 00000000 00000000 00000000 ................ + 0200 00000000 00000000 00000000 00000000 ................ + 0210 00000000 00000000 00000000 00000000 ................ + 0220 00000000 00000000 00000000 00000000 ................ + 0230 00000000 00000000 00000000 00000000 ................ + 0240 00000000 0c000000 00000000 14000000 ................
\ No newline at end of file diff --git a/ld/testsuite/ld-pe/pdb1-sym-record.d b/ld/testsuite/ld-pe/pdb1-sym-record.d new file mode 100644 index 0000000..2078a5e --- /dev/null +++ b/ld/testsuite/ld-pe/pdb1-sym-record.d @@ -0,0 +1,7 @@ + +*: file format binary + +Contents of section .data: + 0000 12000e11 02000000 08000000 0100666f ..............fo + 0010 6f000000 12000e11 00000000 04000000 o............... + 0020 02006261 72000000 ..bar...
\ No newline at end of file diff --git a/ld/testsuite/ld-pe/pdb1.s b/ld/testsuite/ld-pe/pdb1.s index 30a8cfc..846814b 100644 --- a/ld/testsuite/ld-pe/pdb1.s +++ b/ld/testsuite/ld-pe/pdb1.s @@ -1,5 +1,21 @@ .text + .long 0x12345678 + .long 0x9abcdef0 + .global foo -foo: +foo: # section 0001, offset 00000008 + .secrel32 bar + +.data + .long 0x12345678 + +.global bar +bar: # section 0002, offset 00000004 + .long 0x9abcdef0 + +.section "gcsect" + +.global baz +baz: # unreferenced, will be GC'd out .long 0x12345678 |