OSDN Git Service

Revert "Correct size calculations for ELF files"
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 9 Feb 2016 21:30:10 +0000 (21:30 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 9 Feb 2016 21:30:10 +0000 (21:30 +0000)
This reverts commit r259578.

There are enough issues with this small patch that it is better to
revert and then commit a fixed version (will be committed shortly).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260285 91177308-0d34-0410-b5e6-96231b3b80d8

test/tools/llvm-size/Inputs/1.o [deleted file]
test/tools/llvm-size/basic.test
tools/llvm-size/llvm-size.cpp

diff --git a/test/tools/llvm-size/Inputs/1.o b/test/tools/llvm-size/Inputs/1.o
deleted file mode 100644 (file)
index ebcb207..0000000
Binary files a/test/tools/llvm-size/Inputs/1.o and /dev/null differ
index 09827af..8b2d66e 100644 (file)
@@ -1,28 +1,2 @@
 RUN: llvm-size %t.blah 2>&1 | FileCheck --check-prefix=ENOENT %s
-#1.o source
-#int x ; int y ; int z;
-#
-#int main () {
-#  x = 1;
-#  y = 1;
-#  z = 1;
-#  return x + y + z;
-#}
-#Compilation: clang -c -O0
-RUN: llvm-size -A %p/Inputs/1.o | FileCheck --check-prefix="SYSV" %s
-RUN: llvm-size -B %p/Inputs/1.o | FileCheck --check-prefix="BSD" %s
-
 ENOENT: {{.*}}llvm-size{{(\.EXE|\.exe)?}}: {{.*}}.blah: {{[Nn]}}o such file or directory
-SYSV:    {{[ -\(\)_A-Za-z0-9.\\/:]+}}  :
-SYSV-NEXT:    section             size   addr
-SYSV-NEXT:    .text                 67      0
-SYSV-NEXT:    .data                  0      0
-SYSV-NEXT:    .bss                   0      0
-SYSV-NEXT:    .comment              46      0
-SYSV-NEXT:    .note.GNU-stack        0      0
-SYSV-NEXT:    .eh_frame             56      0
-SYSV-NEXT:    Total                169
-
-BSD:        text    data     bss     dec     hex filename
-BSD-NEXT:     67      56       0     123      7b {{[ -\(\)_A-Za-z0-9.\\/:]+}}
-
index 5addbb3..56b9dc5 100644 (file)
 
 #include "llvm/ADT/APInt.h"
 #include "llvm/Object/Archive.h"
-#include "llvm/Object/ELFObjectFile.h"
 #include "llvm/Object/MachO.h"
 #include "llvm/Object/MachOUniversal.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/ELF.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/ManagedStatic.h"
@@ -113,20 +111,6 @@ static const char *getRadixFmt() {
   return nullptr;
 }
 
-/// @brief Remove unneeded ELF sections from calculation
-static bool ConsiderForSize(ObjectFile *Obj, SectionRef Section) {
-  if (Obj->isELF()) {
-    switch (static_cast<ELFSectionRef>(Section).getType()) {
-    case ELF::SHT_NULL:
-    case ELF::SHT_SYMTAB:
-    case ELF::SHT_STRTAB:
-    case ELF::SHT_REL:
-    case ELF::SHT_RELA:
-      return false;
-    }
-  }
-  return true;
-}
 /// @brief Print the size of each Mach-O segment and section in @p MachO.
 ///
 /// This is when used when @c OutputFormat is darwin and produces the same
@@ -303,8 +287,6 @@ static void PrintObjectSectionSizes(ObjectFile *Obj) {
     std::size_t max_size_len = strlen("size");
     std::size_t max_addr_len = strlen("addr");
     for (const SectionRef &Section : Obj->sections()) {
-      if (!ConsiderForSize(Obj, Section))
-        continue;
       uint64_t size = Section.getSize();
       total += size;
 
@@ -340,8 +322,6 @@ static void PrintObjectSectionSizes(ObjectFile *Obj) {
 
     // Print each section.
     for (const SectionRef &Section : Obj->sections()) {
-      if (!ConsiderForSize(Obj, Section))
-        continue;
       StringRef name;
       if (error(Section.getName(name)))
         return;