Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 7aa478d

Browse files
committed
Object/COFF: change data type of SymbolNumber from int16 to uint16.
Microsoft PE/COFF Spec clearly states that the field is of signed interger type. However, in reality, it's unsigned. If cl.exe needs to create a large number of sections for COMDAT sections, it will just create more than 32768 sections. Handling large section number as negative number is not correct. I think this is a spec bug. Differential Revision: http://llvm-reviews.chandlerc.com/D3088 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203986 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 1d8c02b commit 7aa478d

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

include/llvm/Object/COFF.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ struct coff_symbol {
193193
} Name;
194194

195195
support::ulittle32_t Value;
196-
support::little16_t SectionNumber;
196+
support::ulittle16_t SectionNumber;
197197

198198
support::ulittle16_t Type;
199199

include/llvm/Support/COFF.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ namespace COFF {
138138
};
139139

140140
enum SymbolSectionNumber {
141-
IMAGE_SYM_DEBUG = -2,
142-
IMAGE_SYM_ABSOLUTE = -1,
141+
IMAGE_SYM_DEBUG = 0xFFFE,
142+
IMAGE_SYM_ABSOLUTE = 0xFFFF,
143143
IMAGE_SYM_UNDEFINED = 0
144144
};
145145

test/MC/COFF/feat00.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// CHECK: Symbol {
77
// CHECK: Name: @feat.00
88
// CHECK: Value: 123
9-
// CHECK: Section: (-1)
9+
// CHECK: Section: (65535)
1010
// CHECK: BaseType: Null (0x0)
1111
// CHECK: ComplexType: Null (0x0)
1212
// CHECK: StorageClass: External (0x2)

test/MC/COFF/weak.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ LBB0_2: # %return
5252
// CHECK: Symbol {
5353
// CHECK: Name: .weak._test_weak.default
5454
// CHECK-NEXT: Value: 0
55-
// CHECK-NEXT: Section: (-1)
55+
// CHECK-NEXT: Section: (65535)
5656
// CHECK-NEXT: BaseType: Null
5757
// CHECK-NEXT: ComplexType: Null
5858
// CHECK-NEXT: StorageClass: External

tools/llvm-nm/llvm-nm.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,9 @@ static char getSymbolNMTypeChar(COFFObjectFile &Obj, symbol_iterator I) {
317317
return Ret;
318318

319319
uint32_t Characteristics = 0;
320-
if (Symb->SectionNumber > 0) {
320+
if (Symb->SectionNumber > 0 &&
321+
Symb->SectionNumber != llvm::COFF::IMAGE_SYM_DEBUG &&
322+
Symb->SectionNumber != llvm::COFF::IMAGE_SYM_ABSOLUTE) {
321323
section_iterator SecI = Obj.section_end();
322324
if (error(SymI->getSection(SecI)))
323325
return '?';

0 commit comments

Comments
 (0)