[llvm] r240367 - Compute correct symbol sizes for MachO and COFF.
Rafael Espindola
rafael.espindola at gmail.com
Mon Jun 22 19:20:37 PDT 2015
Author: rafael
Date: Mon Jun 22 21:20:37 2015
New Revision: 240367
URL: http://llvm.org/viewvc/llvm-project?rev=240367&view=rev
Log:
Compute correct symbol sizes for MachO and COFF.
Before this would dump from the symbol start to the end of the section.
Added:
llvm/trunk/test/tools/llvm-cxxdump/sym-size.s
Modified:
llvm/trunk/tools/llvm-cxxdump/llvm-cxxdump.cpp
Added: llvm/trunk/test/tools/llvm-cxxdump/sym-size.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cxxdump/sym-size.s?rev=240367&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-cxxdump/sym-size.s (added)
+++ llvm/trunk/test/tools/llvm-cxxdump/sym-size.s Mon Jun 22 21:20:37 2015
@@ -0,0 +1,44 @@
+// RUN: llvm-mc %s -o %t -filetype=obj -triple=x86_64-pc-win32
+// RUN: llvm-cxxdump %t | FileCheck %s
+
+// CHECK: ??_8B@@7B@[0]: 8
+// CHECK-NEXT: ??_8B@@7B@[4]: 9
+// CHECK-NEXT: ??_8C@@7B@[0]: 10
+// CHECK-NEXT: ??_8C@@7B@[4]: 11
+// CHECK-NEXT: ??_8D@@7B0@@[0]: 0
+// CHECK-NEXT: ??_8D@@7B0@@[4]: 1
+// CHECK-NEXT: ??_8D@@7B0@@[8]: 2
+// CHECK-NEXT: ??_8D@@7B0@@[12]: 3
+// CHECK-NEXT: ??_8D@@7BB@@@[0]: 4
+// CHECK-NEXT: ??_8D@@7BB@@@[4]: 5
+// CHECK-NEXT: ??_8D@@7BC@@@[0]: 6
+// CHECK-NEXT: ??_8D@@7BC@@@[4]: 7
+
+ .section .rdata,"dr"
+ .globl "??_8D@@7B0@@"
+"??_8D@@7B0@@":
+ .long 0
+ .long 1
+ .long 2
+ .long 3
+
+ .globl "??_8D@@7BB@@@"
+"??_8D@@7BB@@@":
+ .long 4
+ .long 5
+
+ .globl "??_8D@@7BC@@@"
+"??_8D@@7BC@@@":
+ .long 6
+ .long 7
+
+ .globl "??_8B@@7B@"
+"??_8B@@7B@":
+ .long 8
+ .long 9
+
+ .globl "??_8C@@7B@"
+"??_8C@@7B@":
+ .long 10
+ .long 11
+
Modified: llvm/trunk/tools/llvm-cxxdump/llvm-cxxdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cxxdump/llvm-cxxdump.cpp?rev=240367&r1=240366&r2=240367&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cxxdump/llvm-cxxdump.cpp (original)
+++ llvm/trunk/tools/llvm-cxxdump/llvm-cxxdump.cpp Mon Jun 22 21:20:37 2015
@@ -16,6 +16,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Object/Archive.h"
#include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/SymbolSize.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/FileSystem.h"
@@ -187,7 +188,14 @@ static void dumpCXXData(const ObjectFile
uint8_t BytesInAddress = Obj->getBytesInAddress();
- for (const object::SymbolRef &Sym : Obj->symbols()) {
+ ErrorOr<std::vector<std::pair<SymbolRef, uint64_t>>> SymAddrOrErr =
+ object::computeSymbolSizes(*Obj);
+ if (error(SymAddrOrErr.getError()))
+ return;
+
+ for (auto &P : *SymAddrOrErr) {
+ object::SymbolRef Sym = P.first;
+ uint64_t SymSize = P.second;
StringRef SymName;
if (error(Sym.getName(SymName)))
return;
@@ -207,7 +215,6 @@ static void dumpCXXData(const ObjectFile
uint64_t SymAddress;
if (error(Sym.getAddress(SymAddress)))
return;
- uint64_t SymSize = Sym.getSize();
uint64_t SecAddress = Sec.getAddress();
uint64_t SecSize = Sec.getSize();
uint64_t SymOffset = SymAddress - SecAddress;
More information about the llvm-commits
mailing list