Make 32-bit member offset in Archive::Symbol::getMember 64-bit
authorJake Ehrlich <jakehehrlich@google.com>
Fri, 27 Oct 2017 21:47:38 +0000 (21:47 +0000)
committerJake Ehrlich <jakehehrlich@google.com>
Fri, 27 Oct 2017 21:47:38 +0000 (21:47 +0000)
When accessing a member for a symbol with an offset greater than 2^32 -
1 the current Archive::Symbol::getMember implementation will overflow
and cause unexpected behavior. This change simply fixes that. In
particular if you call "llvm-nm --print-armap" on an archive that has
this behavior you'll get an error.

Differential Revision: https://reviews.llvm.org/D39379

llvm-svn: 316801

llvm/lib/Object/Archive.cpp

index 20aaa1f..b17eefd 100644 (file)
@@ -801,7 +801,7 @@ Expected<Archive::Child> Archive::Symbol::getMember() const {
     Offsets += sizeof(uint64_t);
   else
     Offsets += sizeof(uint32_t);
-  uint32_t Offset = 0;
+  uint64_t Offset = 0;
   if (Parent->kind() == K_GNU) {
     Offset = read32be(Offsets + SymbolIndex * 4);
   } else if (Parent->kind() == K_GNU64) {