summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2014-03-15 00:04:08 +0000
committerRui Ueyama <ruiu@google.com>2014-03-15 00:04:08 +0000
commitcec949af13c639887abaa119ba32251bb357c7c5 (patch)
tree94c029f54b3fe7630d53332ab236f73fafcfbd37
parent26c1fe356801a966945e858b699cd7b1e85c83af (diff)
downloadbcm5719-llvm-cec949af13c639887abaa119ba32251bb357c7c5.tar.gz
bcm5719-llvm-cec949af13c639887abaa119ba32251bb357c7c5.zip
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 llvm-svn: 203986
-rw-r--r--llvm/include/llvm/Object/COFF.h2
-rw-r--r--llvm/include/llvm/Support/COFF.h4
-rw-r--r--llvm/test/MC/COFF/feat00.s2
-rw-r--r--llvm/test/MC/COFF/weak.s2
-rw-r--r--llvm/tools/llvm-nm/llvm-nm.cpp4
5 files changed, 8 insertions, 6 deletions
diff --git a/llvm/include/llvm/Object/COFF.h b/llvm/include/llvm/Object/COFF.h
index 6bf059b9ea4..8c292164e9a 100644
--- a/llvm/include/llvm/Object/COFF.h
+++ b/llvm/include/llvm/Object/COFF.h
@@ -193,7 +193,7 @@ struct coff_symbol {
} Name;
support::ulittle32_t Value;
- support::little16_t SectionNumber;
+ support::ulittle16_t SectionNumber;
support::ulittle16_t Type;
diff --git a/llvm/include/llvm/Support/COFF.h b/llvm/include/llvm/Support/COFF.h
index 7e796ed0926..c408e828106 100644
--- a/llvm/include/llvm/Support/COFF.h
+++ b/llvm/include/llvm/Support/COFF.h
@@ -138,8 +138,8 @@ namespace COFF {
};
enum SymbolSectionNumber {
- IMAGE_SYM_DEBUG = -2,
- IMAGE_SYM_ABSOLUTE = -1,
+ IMAGE_SYM_DEBUG = 0xFFFE,
+ IMAGE_SYM_ABSOLUTE = 0xFFFF,
IMAGE_SYM_UNDEFINED = 0
};
diff --git a/llvm/test/MC/COFF/feat00.s b/llvm/test/MC/COFF/feat00.s
index d08f407cef5..bfd47ad4abc 100644
--- a/llvm/test/MC/COFF/feat00.s
+++ b/llvm/test/MC/COFF/feat00.s
@@ -6,7 +6,7 @@
// CHECK: Symbol {
// CHECK: Name: @feat.00
// CHECK: Value: 123
-// CHECK: Section: (-1)
+// CHECK: Section: (65535)
// CHECK: BaseType: Null (0x0)
// CHECK: ComplexType: Null (0x0)
// CHECK: StorageClass: External (0x2)
diff --git a/llvm/test/MC/COFF/weak.s b/llvm/test/MC/COFF/weak.s
index b9df0f1df2f..accd3f452ea 100644
--- a/llvm/test/MC/COFF/weak.s
+++ b/llvm/test/MC/COFF/weak.s
@@ -52,7 +52,7 @@ LBB0_2: # %return
// CHECK: Symbol {
// CHECK: Name: .weak._test_weak.default
// CHECK-NEXT: Value: 0
-// CHECK-NEXT: Section: (-1)
+// CHECK-NEXT: Section: (65535)
// CHECK-NEXT: BaseType: Null
// CHECK-NEXT: ComplexType: Null
// CHECK-NEXT: StorageClass: External
diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp
index 70c789f328c..88603d45753 100644
--- a/llvm/tools/llvm-nm/llvm-nm.cpp
+++ b/llvm/tools/llvm-nm/llvm-nm.cpp
@@ -317,7 +317,9 @@ static char getSymbolNMTypeChar(COFFObjectFile &Obj, symbol_iterator I) {
return Ret;
uint32_t Characteristics = 0;
- if (Symb->SectionNumber > 0) {
+ if (Symb->SectionNumber > 0 &&
+ Symb->SectionNumber != llvm::COFF::IMAGE_SYM_DEBUG &&
+ Symb->SectionNumber != llvm::COFF::IMAGE_SYM_ABSOLUTE) {
section_iterator SecI = Obj.section_end();
if (error(SymI->getSection(SecI)))
return '?';
OpenPOWER on IntegriCloud