Skip to content

Commit 9a02fbd

Browse files
committed
ld: Add pdb support to aarch64-w64-mingw32
This extends PDB support to the aarch64 PE targets. The changes to the test files are just to make it so they can be assembled as either x86, x86_64, or aarch64, mainly by changing the comment style. The only actual code change here is in adding the architecture constants to pdb.c.
1 parent 5cf1148 commit 9a02fbd

File tree

16 files changed

+917
-900
lines changed

16 files changed

+917
-900
lines changed

ld/configure.tgt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ aarch64-*-haiku*) targ_emul=aarch64haiku
121121
aarch64-*-pe* | aarch64-*-mingw*)
122122
targ_emul=aarch64pe
123123
targ_extra_emuls="arm64pe"
124-
targ_extra_ofiles="deffilep.o pep-dll-aarch64.o pe-dll.o"
124+
targ_extra_ofiles="deffilep.o pep-dll-aarch64.o pe-dll.o pdb.o"
125125
;;
126126
alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
127127
targ_emul=elf64alpha_fbsd

ld/emultempl/pep.em

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ EOF
7979

8080
case ${target} in
8181
x86_64-*-mingw* | x86_64-*-pe | x86_64-*-pep | x86_64-*-cygwin | \
82-
i[3-7]86-*-mingw32* | i[3-7]86-*-cygwin* | i[3-7]86-*-winnt | i[3-7]86-*-pe)
82+
i[3-7]86-*-mingw32* | i[3-7]86-*-cygwin* | i[3-7]86-*-winnt | i[3-7]86-*-pe | \
83+
aarch64-*-mingw* | aarch64-*-pe* )
8384
fragment <<EOF
8485
#include "pdb.h"
8586
EOF

ld/pdb.c

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -591,13 +591,20 @@ populate_type_stream (bfd *pdb, bfd *stream, struct types *types)
591591
static uint16_t
592592
get_arch_number (bfd *abfd)
593593
{
594-
if (abfd->arch_info->arch != bfd_arch_i386)
595-
return 0;
594+
switch (abfd->arch_info->arch)
595+
{
596+
case bfd_arch_i386:
597+
if (abfd->arch_info->mach & bfd_mach_x86_64)
598+
return IMAGE_FILE_MACHINE_AMD64;
599+
else
600+
return IMAGE_FILE_MACHINE_I386;
596601

597-
if (abfd->arch_info->mach & bfd_mach_x86_64)
598-
return IMAGE_FILE_MACHINE_AMD64;
602+
case bfd_arch_aarch64:
603+
return IMAGE_FILE_MACHINE_ARM64;
599604

600-
return IMAGE_FILE_MACHINE_I386;
605+
default:
606+
return 0;
607+
}
601608
}
602609

603610
/* Validate the DEBUG_S_FILECHKSMS entry within a module's .debug$S
@@ -3618,13 +3625,20 @@ handle_debugt_section (asection *s, bfd *mod, struct types *types,
36183625
static uint16_t
36193626
target_processor (bfd *abfd)
36203627
{
3621-
if (abfd->arch_info->arch != bfd_arch_i386)
3622-
return 0;
3628+
switch (abfd->arch_info->arch)
3629+
{
3630+
case bfd_arch_i386:
3631+
if (abfd->arch_info->mach & bfd_mach_x86_64)
3632+
return CV_CFL_X64;
3633+
else
3634+
return CV_CFL_80386;
36233635

3624-
if (abfd->arch_info->mach & bfd_mach_x86_64)
3625-
return CV_CFL_X64;
3626-
else
3627-
return CV_CFL_80386;
3636+
case bfd_arch_aarch64:
3637+
return CV_CFL_ARM64;
3638+
3639+
default:
3640+
return 0;
3641+
}
36283642
}
36293643

36303644
/* Create the symbols that go in "* Linker *", the dummy module created

ld/pdb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,7 @@ struct objname
820820

821821
#define CV_CFL_80386 0x03
822822
#define CV_CFL_X64 0xD0
823+
#define CV_CFL_ARM64 0xF6
823824

824825
#define CV_CFL_LINK 0x07
825826

ld/testsuite/ld-pe/pdb-syms1a.s

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@
2626
.gproc2:
2727
.short .gproc2_end - .gproc2 - 2
2828
.short S_GPROC32
29-
.long 0 # parent
30-
.long 0 # end
31-
.long 0 # next symbol
32-
.long 1 # length
33-
.long 0 # debug start offset
34-
.long 0 # debug end offset
35-
.long 0x1002 # type
29+
.long 0 /* parent */
30+
.long 0 /* end */
31+
.long 0 /* next symbol */
32+
.long 1 /* length */
33+
.long 0 /* debug start offset */
34+
.long 0 /* debug end offset */
35+
.long 0x1002 /* type */
3636
.secrel32 proc2
3737
.secidx proc2
38-
.byte 0 # flags
38+
.byte 0 /* flags */
3939
.asciz "proc2"
40-
.byte 0xf3 # padding
41-
.byte 0xf2 # padding
42-
.byte 0xf1 # padding
40+
.byte 0xf3 /* padding */
41+
.byte 0xf2 /* padding */
42+
.byte 0xf1 /* padding */
4343

4444
.gproc2_end:
4545
.short .udt1 - .gproc2_end - 2
@@ -48,7 +48,7 @@
4848
.udt1:
4949
.short .syms_end - .udt1 - 2
5050
.short S_UDT
51-
.long 0x1004 # struct bar
51+
.long 0x1004 /* struct bar */
5252
.asciz "bar"
5353

5454
.syms_end:
@@ -57,54 +57,54 @@
5757

5858
.long CV_SIGNATURE_C13
5959

60-
# Type 1000, const uint32_t
60+
/* Type 1000, const uint32_t */
6161
.mod1:
6262
.short .arglist1 - .mod1 - 2
6363
.short LF_MODIFIER
6464
.long T_UINT4
65-
.short 1 # const
65+
.short 1 /* const */
6666
.p2align 2
6767

68-
# Type 1001, arglist (uint32_t)
68+
/* Type 1001, arglist (uint32_t) */
6969
.arglist1:
7070
.short .proctype1 - .arglist1 - 2
7171
.short LF_ARGLIST
72-
.long 1 # no. entries
72+
.long 1 /* no. entries */
7373
.long T_UINT4
7474

7575
# Type 1002, procedure (return type T_VOID, arglist 1001)
7676
.proctype1:
7777
.short .fieldlist1 - .proctype1 - 2
7878
.short LF_PROCEDURE
7979
.long T_VOID
80-
.byte 0 # calling convention
81-
.byte 0 # attributes
82-
.short 1 # no. parameters
80+
.byte 0 /* calling convention */
81+
.byte 0 /* attributes */
82+
.short 1 /* no. parameters */
8383
.long 0x1001
8484

85-
# Type 1003, field list for struct bar
85+
/* Type 1003, field list for struct bar */
8686
.fieldlist1:
8787
.short .struct1 - .fieldlist1 - 2
8888
.short LF_FIELDLIST
8989
.short LF_MEMBER
90-
.short 3 # public
90+
.short 3 /* public */
9191
.long T_UINT4
92-
.short 0 # offset
92+
.short 0 /* offset */
9393
.asciz "num1"
94-
.byte 0xf1 # padding
94+
.byte 0xf1 /* padding */
9595

96-
# Type 1004, declaration of struct bar
96+
/* Type 1004, declaration of struct bar */
9797
.struct1:
9898
.short .types_end - .struct1 - 2
9999
.short LF_STRUCTURE
100-
.short 1 # no. members
101-
.short 0 # property
102-
.long 0x1003 # field list
103-
.long 0 # type derived from
104-
.long 0 # type of vshape table
105-
.short 4 # size
106-
.asciz "bar" # name
107-
.byte 0xf2 # padding
108-
.byte 0xf1 # padding
100+
.short 1 /* no. members */
101+
.short 0 /* property */
102+
.long 0x1003 /* field list */
103+
.long 0 /* type derived from */
104+
.long 0 /* type of vshape table */
105+
.short 4 /* size */
106+
.asciz "bar" /* name */
107+
.byte 0xf2 /* padding */
108+
.byte 0xf1 /* padding */
109109

110110
.types_end:

0 commit comments

Comments
 (0)