File tree Expand file tree Collapse file tree 2 files changed +89
-2
lines changed Expand file tree Collapse file tree 2 files changed +89
-2
lines changed Original file line number Diff line number Diff line change @@ -1119,10 +1119,26 @@ Error writeArchiveToStream(raw_ostream &Out,
1119
1119
// to switch to 64-bit. Note that the file can be larger than 4GB as long as
1120
1120
// the last member starts before the 4GB offset.
1121
1121
if (*HeadersSize + LastMemberHeaderOffset >= Sym64Threshold) {
1122
- if (Kind == object::Archive::K_DARWIN)
1122
+ switch (Kind) {
1123
+ case object::Archive::K_COFF:
1124
+ // COFF format has no 64-bit version, so we use GNU64 instead.
1125
+ if (!SymMap.Map .empty () && !SymMap.ECMap .empty ())
1126
+ // Only the COFF format supports the ECSYMBOLS section, so don’t use
1127
+ // GNU64 when two symbol maps are required.
1128
+ return make_error<object::GenericBinaryError>(
1129
+ " Archive is too large: ARM64X does not support archives larger "
1130
+ " than 4GB" );
1131
+ // Since this changes the headers, we need to recalculate everything.
1132
+ return writeArchiveToStream (Out, NewMembers, WriteSymtab,
1133
+ object::Archive::K_GNU64, Deterministic,
1134
+ Thin, IsEC, Warn);
1135
+ case object::Archive::K_DARWIN:
1123
1136
Kind = object::Archive::K_DARWIN64;
1124
- else
1137
+ break ;
1138
+ default :
1125
1139
Kind = object::Archive::K_GNU64;
1140
+ break ;
1141
+ }
1126
1142
HeadersSize.reset ();
1127
1143
}
1128
1144
}
Original file line number Diff line number Diff line change
1
+ # RUN: yaml2obj --docnum=1 %s -o %t01234567890234567789.obj
2
+ # RUN: yaml2obj --docnum=2 %s -o %t-ec.obj
3
+ # RUN: env SYM64_THRESHOLD=100 llvm-lib -machine:amd64 -out:%t.lib %t01234567890234567789.obj
4
+ # RUN: llvm-nm --print-armap %t.lib | FileCheck --check-prefix=ARMAP %s
5
+ # ARMAP: Archive map
6
+ # ARMAP-NEXT: sym
7
+
8
+ # RUN: env SYM64_THRESHOLD=100 not llvm-lib -machine:arm64x -out:%t-ec.lib %t-ec.obj %t01234567890234567789.obj 2>&1 | FileCheck %s
9
+ # CHECK: Archive is too large: ARM64X does not support archives larger than 4GB
10
+
11
+ --- !COFF
12
+ header:
13
+ Machine: IMAGE_FILE_MACHINE_AMD64
14
+ Characteristics: [ ]
15
+ sections:
16
+ - Name: .text
17
+ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
18
+ Alignment: 4
19
+ SectionData: ''
20
+ symbols:
21
+ - Name: .text
22
+ Value: 0
23
+ SectionNumber: 1
24
+ SimpleType: IMAGE_SYM_TYPE_NULL
25
+ ComplexType: IMAGE_SYM_DTYPE_NULL
26
+ StorageClass: IMAGE_SYM_CLASS_STATIC
27
+ SectionDefinition:
28
+ Length: 0
29
+ NumberOfRelocations: 0
30
+ NumberOfLinenumbers: 0
31
+ CheckSum: 0
32
+ Number: 1
33
+ - !Symbol
34
+ Name: sym
35
+ Value: 0
36
+ SectionNumber: 1
37
+ SimpleType: IMAGE_SYM_TYPE_NULL # (0)
38
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION # (2)
39
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL # (2)
40
+ ...
41
+
42
+ --- !COFF
43
+ header:
44
+ Machine: IMAGE_FILE_MACHINE_ARM64
45
+ Characteristics: [ ]
46
+ sections:
47
+ - Name: .text
48
+ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
49
+ Alignment: 4
50
+ SectionData: ''
51
+ symbols:
52
+ - Name: .text
53
+ Value: 0
54
+ SectionNumber: 1
55
+ SimpleType: IMAGE_SYM_TYPE_NULL
56
+ ComplexType: IMAGE_SYM_DTYPE_NULL
57
+ StorageClass: IMAGE_SYM_CLASS_STATIC
58
+ SectionDefinition:
59
+ Length: 0
60
+ NumberOfRelocations: 0
61
+ NumberOfLinenumbers: 0
62
+ CheckSum: 0
63
+ Number: 1
64
+ - !Symbol
65
+ Name: sym
66
+ Value: 0
67
+ SectionNumber: 1
68
+ SimpleType: IMAGE_SYM_TYPE_NULL # (0)
69
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION # (2)
70
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL # (2)
71
+ ...
You can’t perform that action at this time.
0 commit comments