Eugene Zelenko | ffec81c | 2015-11-04 22:32:32 +0000 | [diff] [blame] | 1 | //===-- llvm-size.cpp - Print the size of each object section ---*- C++ -*-===// |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This program is a utility that works like traditional Unix "size", |
| 11 | // that is, it prints out the size of each section, and the total size of all |
| 12 | // sections. |
| 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
| 16 | #include "llvm/ADT/APInt.h" |
| 17 | #include "llvm/Object/Archive.h" |
Rafael Espindola | a0ff556 | 2016-02-09 21:39:49 +0000 | [diff] [blame] | 18 | #include "llvm/Object/ELFObjectFile.h" |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 19 | #include "llvm/Object/MachO.h" |
Kevin Enderby | 4b8fc28 | 2014-06-18 22:04:40 +0000 | [diff] [blame] | 20 | #include "llvm/Object/MachOUniversal.h" |
Chandler Carruth | d990388 | 2015-01-14 11:23:27 +0000 | [diff] [blame] | 21 | #include "llvm/Object/ObjectFile.h" |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 22 | #include "llvm/Support/Casting.h" |
| 23 | #include "llvm/Support/CommandLine.h" |
| 24 | #include "llvm/Support/FileSystem.h" |
| 25 | #include "llvm/Support/Format.h" |
| 26 | #include "llvm/Support/ManagedStatic.h" |
| 27 | #include "llvm/Support/MemoryBuffer.h" |
| 28 | #include "llvm/Support/PrettyStackTrace.h" |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 29 | #include "llvm/Support/Signals.h" |
Chandler Carruth | 4d88a1c | 2012-12-04 10:44:52 +0000 | [diff] [blame] | 30 | #include "llvm/Support/raw_ostream.h" |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 31 | #include <algorithm> |
| 32 | #include <string> |
Rafael Espindola | a6e9c3e | 2014-06-12 17:38:55 +0000 | [diff] [blame] | 33 | #include <system_error> |
Eugene Zelenko | ffec81c | 2015-11-04 22:32:32 +0000 | [diff] [blame] | 34 | |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 35 | using namespace llvm; |
| 36 | using namespace object; |
| 37 | |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 38 | enum OutputFormatTy { berkeley, sysv, darwin }; |
Michael J. Spencer | cc5f8d4 | 2011-09-29 00:59:18 +0000 | [diff] [blame] | 39 | static cl::opt<OutputFormatTy> |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 40 | OutputFormat("format", cl::desc("Specify output format"), |
| 41 | cl::values(clEnumVal(sysv, "System V format"), |
| 42 | clEnumVal(berkeley, "Berkeley format"), |
| 43 | clEnumVal(darwin, "Darwin -m format"), clEnumValEnd), |
| 44 | cl::init(berkeley)); |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 45 | |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 46 | static cl::opt<OutputFormatTy> OutputFormatShort( |
| 47 | cl::desc("Specify output format"), |
| 48 | cl::values(clEnumValN(sysv, "A", "System V format"), |
| 49 | clEnumValN(berkeley, "B", "Berkeley format"), |
| 50 | clEnumValN(darwin, "m", "Darwin -m format"), clEnumValEnd), |
| 51 | cl::init(berkeley)); |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 52 | |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 53 | static bool BerkeleyHeaderPrinted = false; |
| 54 | static bool MoreThanOneFile = false; |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 55 | |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 56 | cl::opt<bool> |
| 57 | DarwinLongFormat("l", cl::desc("When format is darwin, use long format " |
| 58 | "to include addresses and offsets.")); |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 59 | |
Hemant Kulkarni | 274457e | 2016-03-28 16:48:10 +0000 | [diff] [blame] | 60 | cl::opt<bool> |
| 61 | ELFCommons("common", |
| 62 | cl::desc("Print common symbols in the ELF file. When using " |
| 63 | "Berkely format, this is added to bss."), |
| 64 | cl::init(false)); |
| 65 | |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 66 | static cl::list<std::string> |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 67 | ArchFlags("arch", cl::desc("architecture(s) from a Mach-O file to dump"), |
| 68 | cl::ZeroOrMore); |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 69 | bool ArchAll = false; |
| 70 | |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 71 | enum RadixTy { octal = 8, decimal = 10, hexadecimal = 16 }; |
Michael J. Spencer | cc5f8d4 | 2011-09-29 00:59:18 +0000 | [diff] [blame] | 72 | static cl::opt<unsigned int> |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 73 | Radix("-radix", cl::desc("Print size in radix. Only 8, 10, and 16 are valid"), |
| 74 | cl::init(decimal)); |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 75 | |
Michael J. Spencer | cc5f8d4 | 2011-09-29 00:59:18 +0000 | [diff] [blame] | 76 | static cl::opt<RadixTy> |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 77 | RadixShort(cl::desc("Print size in radix:"), |
| 78 | cl::values(clEnumValN(octal, "o", "Print size in octal"), |
| 79 | clEnumValN(decimal, "d", "Print size in decimal"), |
| 80 | clEnumValN(hexadecimal, "x", "Print size in hexadecimal"), |
| 81 | clEnumValEnd), |
| 82 | cl::init(decimal)); |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 83 | |
Michael J. Spencer | cc5f8d4 | 2011-09-29 00:59:18 +0000 | [diff] [blame] | 84 | static cl::list<std::string> |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 85 | InputFilenames(cl::Positional, cl::desc("<input files>"), cl::ZeroOrMore); |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 86 | |
Kevin Enderby | 64f7a99 | 2016-05-02 21:41:03 +0000 | [diff] [blame] | 87 | bool HadError = false; |
| 88 | |
Michael J. Spencer | cc5f8d4 | 2011-09-29 00:59:18 +0000 | [diff] [blame] | 89 | static std::string ToolName; |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 90 | |
Rafael Espindola | 49a0e5e | 2016-02-09 21:32:56 +0000 | [diff] [blame] | 91 | /// If ec is not success, print the error and return true. |
Rafael Espindola | 4453e4294 | 2014-06-13 03:07:50 +0000 | [diff] [blame] | 92 | static bool error(std::error_code ec) { |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 93 | if (!ec) |
| 94 | return false; |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 95 | |
Kevin Enderby | 64f7a99 | 2016-05-02 21:41:03 +0000 | [diff] [blame] | 96 | HadError = true; |
Davide Italiano | 911eb31 | 2016-01-25 01:24:15 +0000 | [diff] [blame] | 97 | errs() << ToolName << ": error reading file: " << ec.message() << ".\n"; |
| 98 | errs().flush(); |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 99 | return true; |
| 100 | } |
| 101 | |
Kevin Enderby | ac9e155 | 2016-05-17 17:10:12 +0000 | [diff] [blame^] | 102 | // This version of error() prints the archive name and member name, for example: |
| 103 | // "libx.a(foo.o)" after the ToolName before the error message. It sets |
| 104 | // HadError but returns allowing the code to move on to other archive members. |
| 105 | static void error(llvm::Error E, StringRef FileName, const Archive::Child &C) { |
| 106 | HadError = true; |
| 107 | errs() << ToolName << ": " << FileName; |
| 108 | |
| 109 | ErrorOr<StringRef> NameOrErr = C.getName(); |
| 110 | // TODO: if we have a error getting the name then it would be nice to print |
| 111 | // the index of which archive member this is and or its offset in the |
| 112 | // archive instead of "???" as the name. |
| 113 | if (NameOrErr.getError()) |
| 114 | errs() << "(" << "???" << ")"; |
| 115 | else |
| 116 | errs() << "(" << NameOrErr.get() << ")"; |
| 117 | |
| 118 | std::string Buf; |
| 119 | raw_string_ostream OS(Buf); |
| 120 | logAllUnhandledErrors(std::move(E), OS, ""); |
| 121 | OS.flush(); |
| 122 | errs() << " " << Buf << "\n"; |
| 123 | } |
| 124 | |
Rafael Espindola | 49a0e5e | 2016-02-09 21:32:56 +0000 | [diff] [blame] | 125 | /// Get the length of the string that represents @p num in Radix including the |
| 126 | /// leading 0x or 0 for hexadecimal and octal respectively. |
Andrew Trick | 7dc278d | 2011-09-29 01:22:31 +0000 | [diff] [blame] | 127 | static size_t getNumLengthAsString(uint64_t num) { |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 128 | APInt conv(64, num); |
| 129 | SmallString<32> result; |
Michael J. Spencer | cc5f8d4 | 2011-09-29 00:59:18 +0000 | [diff] [blame] | 130 | conv.toString(result, Radix, false, true); |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 131 | return result.size(); |
| 132 | } |
| 133 | |
Rafael Espindola | 49a0e5e | 2016-02-09 21:32:56 +0000 | [diff] [blame] | 134 | /// Return the printing format for the Radix. |
Eugene Zelenko | ffec81c | 2015-11-04 22:32:32 +0000 | [diff] [blame] | 135 | static const char *getRadixFmt() { |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 136 | switch (Radix) { |
| 137 | case octal: |
| 138 | return PRIo64; |
| 139 | case decimal: |
| 140 | return PRIu64; |
| 141 | case hexadecimal: |
| 142 | return PRIx64; |
| 143 | } |
| 144 | return nullptr; |
| 145 | } |
| 146 | |
Rafael Espindola | a0ff556 | 2016-02-09 21:39:49 +0000 | [diff] [blame] | 147 | /// Remove unneeded ELF sections from calculation |
| 148 | static bool considerForSize(ObjectFile *Obj, SectionRef Section) { |
| 149 | if (!Obj->isELF()) |
| 150 | return true; |
| 151 | switch (static_cast<ELFSectionRef>(Section).getType()) { |
| 152 | case ELF::SHT_NULL: |
| 153 | case ELF::SHT_SYMTAB: |
| 154 | case ELF::SHT_STRTAB: |
| 155 | case ELF::SHT_REL: |
| 156 | case ELF::SHT_RELA: |
| 157 | return false; |
| 158 | } |
| 159 | return true; |
| 160 | } |
| 161 | |
Hemant Kulkarni | 274457e | 2016-03-28 16:48:10 +0000 | [diff] [blame] | 162 | /// Total size of all ELF common symbols |
| 163 | static uint64_t getCommonSize(ObjectFile *Obj) { |
| 164 | uint64_t TotalCommons = 0; |
| 165 | for (auto &Sym : Obj->symbols()) |
| 166 | if (Obj->getSymbolFlags(Sym.getRawDataRefImpl()) & SymbolRef::SF_Common) |
| 167 | TotalCommons += Obj->getCommonSymbolSize(Sym.getRawDataRefImpl()); |
| 168 | return TotalCommons; |
| 169 | } |
| 170 | |
Rafael Espindola | 49a0e5e | 2016-02-09 21:32:56 +0000 | [diff] [blame] | 171 | /// Print the size of each Mach-O segment and section in @p MachO. |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 172 | /// |
| 173 | /// This is when used when @c OutputFormat is darwin and produces the same |
| 174 | /// output as darwin's size(1) -m output. |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 175 | static void printDarwinSectionSizes(MachOObjectFile *MachO) { |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 176 | std::string fmtbuf; |
| 177 | raw_string_ostream fmt(fmtbuf); |
| 178 | const char *radix_fmt = getRadixFmt(); |
| 179 | if (Radix == hexadecimal) |
| 180 | fmt << "0x"; |
| 181 | fmt << "%" << radix_fmt; |
| 182 | |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 183 | uint32_t Filetype = MachO->getHeader().filetype; |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 184 | |
| 185 | uint64_t total = 0; |
Alexey Samsonov | d319c4f | 2015-06-03 22:19:36 +0000 | [diff] [blame] | 186 | for (const auto &Load : MachO->load_commands()) { |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 187 | if (Load.C.cmd == MachO::LC_SEGMENT_64) { |
| 188 | MachO::segment_command_64 Seg = MachO->getSegment64LoadCommand(Load); |
| 189 | outs() << "Segment " << Seg.segname << ": " |
| 190 | << format(fmt.str().c_str(), Seg.vmsize); |
| 191 | if (DarwinLongFormat) |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 192 | outs() << " (vmaddr 0x" << format("%" PRIx64, Seg.vmaddr) << " fileoff " |
| 193 | << Seg.fileoff << ")"; |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 194 | outs() << "\n"; |
| 195 | total += Seg.vmsize; |
| 196 | uint64_t sec_total = 0; |
| 197 | for (unsigned J = 0; J < Seg.nsects; ++J) { |
| 198 | MachO::section_64 Sec = MachO->getSection64(Load, J); |
| 199 | if (Filetype == MachO::MH_OBJECT) |
| 200 | outs() << "\tSection (" << format("%.16s", &Sec.segname) << ", " |
| 201 | << format("%.16s", &Sec.sectname) << "): "; |
| 202 | else |
| 203 | outs() << "\tSection " << format("%.16s", &Sec.sectname) << ": "; |
| 204 | outs() << format(fmt.str().c_str(), Sec.size); |
| 205 | if (DarwinLongFormat) |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 206 | outs() << " (addr 0x" << format("%" PRIx64, Sec.addr) << " offset " |
| 207 | << Sec.offset << ")"; |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 208 | outs() << "\n"; |
| 209 | sec_total += Sec.size; |
| 210 | } |
| 211 | if (Seg.nsects != 0) |
| 212 | outs() << "\ttotal " << format(fmt.str().c_str(), sec_total) << "\n"; |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 213 | } else if (Load.C.cmd == MachO::LC_SEGMENT) { |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 214 | MachO::segment_command Seg = MachO->getSegmentLoadCommand(Load); |
Kevin Enderby | 2058e9d | 2016-02-09 18:33:15 +0000 | [diff] [blame] | 215 | uint64_t Seg_vmsize = Seg.vmsize; |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 216 | outs() << "Segment " << Seg.segname << ": " |
Kevin Enderby | 2058e9d | 2016-02-09 18:33:15 +0000 | [diff] [blame] | 217 | << format(fmt.str().c_str(), Seg_vmsize); |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 218 | if (DarwinLongFormat) |
Kevin Enderby | 2058e9d | 2016-02-09 18:33:15 +0000 | [diff] [blame] | 219 | outs() << " (vmaddr 0x" << format("%" PRIx32, Seg.vmaddr) << " fileoff " |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 220 | << Seg.fileoff << ")"; |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 221 | outs() << "\n"; |
| 222 | total += Seg.vmsize; |
| 223 | uint64_t sec_total = 0; |
| 224 | for (unsigned J = 0; J < Seg.nsects; ++J) { |
| 225 | MachO::section Sec = MachO->getSection(Load, J); |
| 226 | if (Filetype == MachO::MH_OBJECT) |
| 227 | outs() << "\tSection (" << format("%.16s", &Sec.segname) << ", " |
| 228 | << format("%.16s", &Sec.sectname) << "): "; |
| 229 | else |
| 230 | outs() << "\tSection " << format("%.16s", &Sec.sectname) << ": "; |
Kevin Enderby | 2058e9d | 2016-02-09 18:33:15 +0000 | [diff] [blame] | 231 | uint64_t Sec_size = Sec.size; |
| 232 | outs() << format(fmt.str().c_str(), Sec_size); |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 233 | if (DarwinLongFormat) |
Kevin Enderby | 2058e9d | 2016-02-09 18:33:15 +0000 | [diff] [blame] | 234 | outs() << " (addr 0x" << format("%" PRIx32, Sec.addr) << " offset " |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 235 | << Sec.offset << ")"; |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 236 | outs() << "\n"; |
| 237 | sec_total += Sec.size; |
| 238 | } |
| 239 | if (Seg.nsects != 0) |
| 240 | outs() << "\ttotal " << format(fmt.str().c_str(), sec_total) << "\n"; |
| 241 | } |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 242 | } |
| 243 | outs() << "total " << format(fmt.str().c_str(), total) << "\n"; |
| 244 | } |
| 245 | |
Rafael Espindola | 49a0e5e | 2016-02-09 21:32:56 +0000 | [diff] [blame] | 246 | /// Print the summary sizes of the standard Mach-O segments in @p MachO. |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 247 | /// |
| 248 | /// This is when used when @c OutputFormat is berkeley with a Mach-O file and |
| 249 | /// produces the same output as darwin's size(1) default output. |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 250 | static void printDarwinSegmentSizes(MachOObjectFile *MachO) { |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 251 | uint64_t total_text = 0; |
| 252 | uint64_t total_data = 0; |
| 253 | uint64_t total_objc = 0; |
| 254 | uint64_t total_others = 0; |
Alexey Samsonov | d319c4f | 2015-06-03 22:19:36 +0000 | [diff] [blame] | 255 | for (const auto &Load : MachO->load_commands()) { |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 256 | if (Load.C.cmd == MachO::LC_SEGMENT_64) { |
| 257 | MachO::segment_command_64 Seg = MachO->getSegment64LoadCommand(Load); |
| 258 | if (MachO->getHeader().filetype == MachO::MH_OBJECT) { |
| 259 | for (unsigned J = 0; J < Seg.nsects; ++J) { |
| 260 | MachO::section_64 Sec = MachO->getSection64(Load, J); |
| 261 | StringRef SegmentName = StringRef(Sec.segname); |
| 262 | if (SegmentName == "__TEXT") |
| 263 | total_text += Sec.size; |
| 264 | else if (SegmentName == "__DATA") |
| 265 | total_data += Sec.size; |
| 266 | else if (SegmentName == "__OBJC") |
| 267 | total_objc += Sec.size; |
| 268 | else |
| 269 | total_others += Sec.size; |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 270 | } |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 271 | } else { |
| 272 | StringRef SegmentName = StringRef(Seg.segname); |
| 273 | if (SegmentName == "__TEXT") |
| 274 | total_text += Seg.vmsize; |
| 275 | else if (SegmentName == "__DATA") |
| 276 | total_data += Seg.vmsize; |
| 277 | else if (SegmentName == "__OBJC") |
| 278 | total_objc += Seg.vmsize; |
| 279 | else |
| 280 | total_others += Seg.vmsize; |
| 281 | } |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 282 | } else if (Load.C.cmd == MachO::LC_SEGMENT) { |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 283 | MachO::segment_command Seg = MachO->getSegmentLoadCommand(Load); |
| 284 | if (MachO->getHeader().filetype == MachO::MH_OBJECT) { |
| 285 | for (unsigned J = 0; J < Seg.nsects; ++J) { |
| 286 | MachO::section Sec = MachO->getSection(Load, J); |
| 287 | StringRef SegmentName = StringRef(Sec.segname); |
| 288 | if (SegmentName == "__TEXT") |
| 289 | total_text += Sec.size; |
| 290 | else if (SegmentName == "__DATA") |
| 291 | total_data += Sec.size; |
| 292 | else if (SegmentName == "__OBJC") |
| 293 | total_objc += Sec.size; |
| 294 | else |
| 295 | total_others += Sec.size; |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 296 | } |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 297 | } else { |
| 298 | StringRef SegmentName = StringRef(Seg.segname); |
| 299 | if (SegmentName == "__TEXT") |
| 300 | total_text += Seg.vmsize; |
| 301 | else if (SegmentName == "__DATA") |
| 302 | total_data += Seg.vmsize; |
| 303 | else if (SegmentName == "__OBJC") |
| 304 | total_objc += Seg.vmsize; |
| 305 | else |
| 306 | total_others += Seg.vmsize; |
| 307 | } |
| 308 | } |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 309 | } |
| 310 | uint64_t total = total_text + total_data + total_objc + total_others; |
| 311 | |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 312 | if (!BerkeleyHeaderPrinted) { |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 313 | outs() << "__TEXT\t__DATA\t__OBJC\tothers\tdec\thex\n"; |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 314 | BerkeleyHeaderPrinted = true; |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 315 | } |
| 316 | outs() << total_text << "\t" << total_data << "\t" << total_objc << "\t" |
| 317 | << total_others << "\t" << total << "\t" << format("%" PRIx64, total) |
| 318 | << "\t"; |
| 319 | } |
| 320 | |
Rafael Espindola | 49a0e5e | 2016-02-09 21:32:56 +0000 | [diff] [blame] | 321 | /// Print the size of each section in @p Obj. |
Michael J. Spencer | cc5f8d4 | 2011-09-29 00:59:18 +0000 | [diff] [blame] | 322 | /// |
| 323 | /// The format used is determined by @c OutputFormat and @c Radix. |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 324 | static void printObjectSectionSizes(ObjectFile *Obj) { |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 325 | uint64_t total = 0; |
| 326 | std::string fmtbuf; |
| 327 | raw_string_ostream fmt(fmtbuf); |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 328 | const char *radix_fmt = getRadixFmt(); |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 329 | |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 330 | // If OutputFormat is darwin and we have a MachOObjectFile print as darwin's |
| 331 | // size(1) -m output, else if OutputFormat is darwin and not a Mach-O object |
| 332 | // let it fall through to OutputFormat berkeley. |
| 333 | MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(Obj); |
| 334 | if (OutputFormat == darwin && MachO) |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 335 | printDarwinSectionSizes(MachO); |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 336 | // If we have a MachOObjectFile and the OutputFormat is berkeley print as |
| 337 | // darwin's default berkeley format for Mach-O files. |
| 338 | else if (MachO && OutputFormat == berkeley) |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 339 | printDarwinSegmentSizes(MachO); |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 340 | else if (OutputFormat == sysv) { |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 341 | // Run two passes over all sections. The first gets the lengths needed for |
| 342 | // formatting the output. The second actually does the output. |
| 343 | std::size_t max_name_len = strlen("section"); |
Michael J. Spencer | cc5f8d4 | 2011-09-29 00:59:18 +0000 | [diff] [blame] | 344 | std::size_t max_size_len = strlen("size"); |
| 345 | std::size_t max_addr_len = strlen("addr"); |
Alexey Samsonov | 48803e5 | 2014-03-13 14:37:36 +0000 | [diff] [blame] | 346 | for (const SectionRef &Section : Obj->sections()) { |
Rafael Espindola | a0ff556 | 2016-02-09 21:39:49 +0000 | [diff] [blame] | 347 | if (!considerForSize(Obj, Section)) |
| 348 | continue; |
Rafael Espindola | 8029127 | 2014-10-08 15:28:58 +0000 | [diff] [blame] | 349 | uint64_t size = Section.getSize(); |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 350 | total += size; |
| 351 | |
| 352 | StringRef name; |
Alexey Samsonov | 48803e5 | 2014-03-13 14:37:36 +0000 | [diff] [blame] | 353 | if (error(Section.getName(name))) |
| 354 | return; |
Rafael Espindola | 8029127 | 2014-10-08 15:28:58 +0000 | [diff] [blame] | 355 | uint64_t addr = Section.getAddress(); |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 356 | max_name_len = std::max(max_name_len, name.size()); |
Andrew Trick | 7dc278d | 2011-09-29 01:22:31 +0000 | [diff] [blame] | 357 | max_size_len = std::max(max_size_len, getNumLengthAsString(size)); |
| 358 | max_addr_len = std::max(max_addr_len, getNumLengthAsString(addr)); |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 359 | } |
| 360 | |
Michael J. Spencer | cc5f8d4 | 2011-09-29 00:59:18 +0000 | [diff] [blame] | 361 | // Add extra padding. |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 362 | max_name_len += 2; |
| 363 | max_size_len += 2; |
| 364 | max_addr_len += 2; |
| 365 | |
Michael J. Spencer | cc5f8d4 | 2011-09-29 00:59:18 +0000 | [diff] [blame] | 366 | // Setup header format. |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 367 | fmt << "%-" << max_name_len << "s " |
| 368 | << "%" << max_size_len << "s " |
| 369 | << "%" << max_addr_len << "s\n"; |
| 370 | |
| 371 | // Print header |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 372 | outs() << format(fmt.str().c_str(), static_cast<const char *>("section"), |
| 373 | static_cast<const char *>("size"), |
| 374 | static_cast<const char *>("addr")); |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 375 | fmtbuf.clear(); |
| 376 | |
| 377 | // Setup per section format. |
| 378 | fmt << "%-" << max_name_len << "s " |
| 379 | << "%#" << max_size_len << radix_fmt << " " |
| 380 | << "%#" << max_addr_len << radix_fmt << "\n"; |
| 381 | |
| 382 | // Print each section. |
Alexey Samsonov | 48803e5 | 2014-03-13 14:37:36 +0000 | [diff] [blame] | 383 | for (const SectionRef &Section : Obj->sections()) { |
Rafael Espindola | a0ff556 | 2016-02-09 21:39:49 +0000 | [diff] [blame] | 384 | if (!considerForSize(Obj, Section)) |
| 385 | continue; |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 386 | StringRef name; |
Alexey Samsonov | 48803e5 | 2014-03-13 14:37:36 +0000 | [diff] [blame] | 387 | if (error(Section.getName(name))) |
| 388 | return; |
Rafael Espindola | 8029127 | 2014-10-08 15:28:58 +0000 | [diff] [blame] | 389 | uint64_t size = Section.getSize(); |
| 390 | uint64_t addr = Section.getAddress(); |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 391 | std::string namestr = name; |
| 392 | |
Alexey Samsonov | 48803e5 | 2014-03-13 14:37:36 +0000 | [diff] [blame] | 393 | outs() << format(fmt.str().c_str(), namestr.c_str(), size, addr); |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 394 | } |
| 395 | |
Hemant Kulkarni | 274457e | 2016-03-28 16:48:10 +0000 | [diff] [blame] | 396 | if (ELFCommons) { |
| 397 | uint64_t CommonSize = getCommonSize(Obj); |
| 398 | total += CommonSize; |
| 399 | outs() << format(fmt.str().c_str(), std::string("*COM*").c_str(), |
| 400 | CommonSize, static_cast<uint64_t>(0)); |
| 401 | } |
| 402 | |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 403 | // Print total. |
| 404 | fmtbuf.clear(); |
| 405 | fmt << "%-" << max_name_len << "s " |
| 406 | << "%#" << max_size_len << radix_fmt << "\n"; |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 407 | outs() << format(fmt.str().c_str(), static_cast<const char *>("Total"), |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 408 | total); |
| 409 | } else { |
Michael J. Spencer | cc5f8d4 | 2011-09-29 00:59:18 +0000 | [diff] [blame] | 410 | // The Berkeley format does not display individual section sizes. It |
| 411 | // displays the cumulative size for each section type. |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 412 | uint64_t total_text = 0; |
| 413 | uint64_t total_data = 0; |
| 414 | uint64_t total_bss = 0; |
| 415 | |
Michael J. Spencer | cc5f8d4 | 2011-09-29 00:59:18 +0000 | [diff] [blame] | 416 | // Make one pass over the section table to calculate sizes. |
Alexey Samsonov | 48803e5 | 2014-03-13 14:37:36 +0000 | [diff] [blame] | 417 | for (const SectionRef &Section : Obj->sections()) { |
Rafael Espindola | 8029127 | 2014-10-08 15:28:58 +0000 | [diff] [blame] | 418 | uint64_t size = Section.getSize(); |
| 419 | bool isText = Section.isText(); |
| 420 | bool isData = Section.isData(); |
| 421 | bool isBSS = Section.isBSS(); |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 422 | if (isText) |
| 423 | total_text += size; |
| 424 | else if (isData) |
| 425 | total_data += size; |
| 426 | else if (isBSS) |
| 427 | total_bss += size; |
| 428 | } |
| 429 | |
Hemant Kulkarni | 274457e | 2016-03-28 16:48:10 +0000 | [diff] [blame] | 430 | if (ELFCommons) |
| 431 | total_bss += getCommonSize(Obj); |
| 432 | |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 433 | total = total_text + total_data + total_bss; |
| 434 | |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 435 | if (!BerkeleyHeaderPrinted) { |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 436 | outs() << " text data bss " |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 437 | << (Radix == octal ? "oct" : "dec") << " hex filename\n"; |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 438 | BerkeleyHeaderPrinted = true; |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 439 | } |
| 440 | |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 441 | // Print result. |
| 442 | fmt << "%#7" << radix_fmt << " " |
| 443 | << "%#7" << radix_fmt << " " |
| 444 | << "%#7" << radix_fmt << " "; |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 445 | outs() << format(fmt.str().c_str(), total_text, total_data, total_bss); |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 446 | fmtbuf.clear(); |
Benjamin Kramer | f3da529 | 2011-11-05 08:57:40 +0000 | [diff] [blame] | 447 | fmt << "%7" << (Radix == octal ? PRIo64 : PRIu64) << " " |
| 448 | << "%7" PRIx64 " "; |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 449 | outs() << format(fmt.str().c_str(), total, total); |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 450 | } |
| 451 | } |
| 452 | |
Rafael Espindola | 49a0e5e | 2016-02-09 21:32:56 +0000 | [diff] [blame] | 453 | /// Checks to see if the @p o ObjectFile is a Mach-O file and if it is and there |
| 454 | /// is a list of architecture flags specified then check to make sure this |
| 455 | /// Mach-O file is one of those architectures or all architectures was |
| 456 | /// specificed. If not then an error is generated and this routine returns |
| 457 | /// false. Else it returns true. |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 458 | static bool checkMachOAndArchFlags(ObjectFile *o, StringRef file) { |
| 459 | if (isa<MachOObjectFile>(o) && !ArchAll && ArchFlags.size() != 0) { |
| 460 | MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o); |
| 461 | bool ArchFound = false; |
| 462 | MachO::mach_header H; |
| 463 | MachO::mach_header_64 H_64; |
| 464 | Triple T; |
| 465 | if (MachO->is64Bit()) { |
| 466 | H_64 = MachO->MachOObjectFile::getHeader64(); |
Tim Northover | 9e8eb41 | 2016-04-22 23:21:13 +0000 | [diff] [blame] | 467 | T = MachOObjectFile::getArchTriple(H_64.cputype, H_64.cpusubtype); |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 468 | } else { |
| 469 | H = MachO->MachOObjectFile::getHeader(); |
Tim Northover | 9e8eb41 | 2016-04-22 23:21:13 +0000 | [diff] [blame] | 470 | T = MachOObjectFile::getArchTriple(H.cputype, H.cpusubtype); |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 471 | } |
| 472 | unsigned i; |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 473 | for (i = 0; i < ArchFlags.size(); ++i) { |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 474 | if (ArchFlags[i] == T.getArchName()) |
| 475 | ArchFound = true; |
| 476 | break; |
| 477 | } |
| 478 | if (!ArchFound) { |
| 479 | errs() << ToolName << ": file: " << file |
| 480 | << " does not contain architecture: " << ArchFlags[i] << ".\n"; |
| 481 | return false; |
| 482 | } |
| 483 | } |
| 484 | return true; |
| 485 | } |
| 486 | |
Rafael Espindola | 49a0e5e | 2016-02-09 21:32:56 +0000 | [diff] [blame] | 487 | /// Print the section sizes for @p file. If @p file is an archive, print the |
| 488 | /// section sizes for each archive member. |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 489 | static void printFileSectionSizes(StringRef file) { |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 490 | |
Michael J. Spencer | cc5f8d4 | 2011-09-29 00:59:18 +0000 | [diff] [blame] | 491 | // Attempt to open the binary. |
Kevin Enderby | 3fcdf6a | 2016-04-06 22:14:09 +0000 | [diff] [blame] | 492 | Expected<OwningBinary<Binary>> BinaryOrErr = createBinary(file); |
| 493 | if (!BinaryOrErr) { |
| 494 | error(errorToErrorCode(BinaryOrErr.takeError())); |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 495 | return; |
Kevin Enderby | 3fcdf6a | 2016-04-06 22:14:09 +0000 | [diff] [blame] | 496 | } |
Rafael Espindola | 48af1c2 | 2014-08-19 18:44:46 +0000 | [diff] [blame] | 497 | Binary &Bin = *BinaryOrErr.get().getBinary(); |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 498 | |
Rafael Espindola | 3f6481d | 2014-08-01 14:31:55 +0000 | [diff] [blame] | 499 | if (Archive *a = dyn_cast<Archive>(&Bin)) { |
Michael J. Spencer | cc5f8d4 | 2011-09-29 00:59:18 +0000 | [diff] [blame] | 500 | // This is an archive. Iterate over each member and display its sizes. |
Rafael Espindola | 23a9750 | 2014-01-21 16:09:45 +0000 | [diff] [blame] | 501 | for (object::Archive::child_iterator i = a->child_begin(), |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 502 | e = a->child_end(); |
| 503 | i != e; ++i) { |
Davide Italiano | ff11b90 | 2016-02-13 01:38:16 +0000 | [diff] [blame] | 504 | if (error(i->getError())) |
Kevin Enderby | 7a96942 | 2015-11-05 19:24:56 +0000 | [diff] [blame] | 505 | exit(1); |
Kevin Enderby | ac9e155 | 2016-05-17 17:10:12 +0000 | [diff] [blame^] | 506 | Expected<std::unique_ptr<Binary>> ChildOrErr = i->get().getAsBinary(); |
| 507 | if (!ChildOrErr) { |
| 508 | if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError())) |
| 509 | error(std::move(E), a->getFileName(), i->get()); |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 510 | continue; |
Kevin Enderby | ac9e155 | 2016-05-17 17:10:12 +0000 | [diff] [blame^] | 511 | } |
Rafael Espindola | ae46002 | 2014-06-16 16:08:36 +0000 | [diff] [blame] | 512 | if (ObjectFile *o = dyn_cast<ObjectFile>(&*ChildOrErr.get())) { |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 513 | MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o); |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 514 | if (!checkMachOAndArchFlags(o, file)) |
| 515 | return; |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 516 | if (OutputFormat == sysv) |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 517 | outs() << o->getFileName() << " (ex " << a->getFileName() << "):\n"; |
| 518 | else if (MachO && OutputFormat == darwin) |
| 519 | outs() << a->getFileName() << "(" << o->getFileName() << "):\n"; |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 520 | printObjectSectionSizes(o); |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 521 | if (OutputFormat == berkeley) { |
| 522 | if (MachO) |
| 523 | outs() << a->getFileName() << "(" << o->getFileName() << ")\n"; |
| 524 | else |
| 525 | outs() << o->getFileName() << " (ex " << a->getFileName() << ")\n"; |
| 526 | } |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 527 | } |
| 528 | } |
Kevin Enderby | 4b8fc28 | 2014-06-18 22:04:40 +0000 | [diff] [blame] | 529 | } else if (MachOUniversalBinary *UB = |
Rafael Espindola | 3f6481d | 2014-08-01 14:31:55 +0000 | [diff] [blame] | 530 | dyn_cast<MachOUniversalBinary>(&Bin)) { |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 531 | // If we have a list of architecture flags specified dump only those. |
| 532 | if (!ArchAll && ArchFlags.size() != 0) { |
| 533 | // Look for a slice in the universal binary that matches each ArchFlag. |
| 534 | bool ArchFound; |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 535 | for (unsigned i = 0; i < ArchFlags.size(); ++i) { |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 536 | ArchFound = false; |
| 537 | for (MachOUniversalBinary::object_iterator I = UB->begin_objects(), |
| 538 | E = UB->end_objects(); |
| 539 | I != E; ++I) { |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 540 | if (ArchFlags[i] == I->getArchTypeName()) { |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 541 | ArchFound = true; |
| 542 | ErrorOr<std::unique_ptr<ObjectFile>> UO = I->getAsObjectFile(); |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 543 | if (UO) { |
| 544 | if (ObjectFile *o = dyn_cast<ObjectFile>(&*UO.get())) { |
| 545 | MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o); |
| 546 | if (OutputFormat == sysv) |
| 547 | outs() << o->getFileName() << " :\n"; |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 548 | else if (MachO && OutputFormat == darwin) { |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 549 | if (MoreThanOneFile || ArchFlags.size() > 1) |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 550 | outs() << o->getFileName() << " (for architecture " |
| 551 | << I->getArchTypeName() << "): \n"; |
| 552 | } |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 553 | printObjectSectionSizes(o); |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 554 | if (OutputFormat == berkeley) { |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 555 | if (!MachO || MoreThanOneFile || ArchFlags.size() > 1) |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 556 | outs() << o->getFileName() << " (for architecture " |
| 557 | << I->getArchTypeName() << ")"; |
| 558 | outs() << "\n"; |
| 559 | } |
| 560 | } |
Rafael Espindola | 0bfe828 | 2014-12-09 21:05:36 +0000 | [diff] [blame] | 561 | } else if (ErrorOr<std::unique_ptr<Archive>> AOrErr = |
| 562 | I->getAsArchive()) { |
| 563 | std::unique_ptr<Archive> &UA = *AOrErr; |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 564 | // This is an archive. Iterate over each member and display its |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 565 | // sizes. |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 566 | for (object::Archive::child_iterator i = UA->child_begin(), |
| 567 | e = UA->child_end(); |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 568 | i != e; ++i) { |
Davide Italiano | ff11b90 | 2016-02-13 01:38:16 +0000 | [diff] [blame] | 569 | if (error(i->getError())) |
Kevin Enderby | 7a96942 | 2015-11-05 19:24:56 +0000 | [diff] [blame] | 570 | exit(1); |
Kevin Enderby | ac9e155 | 2016-05-17 17:10:12 +0000 | [diff] [blame^] | 571 | Expected<std::unique_ptr<Binary>> ChildOrErr = |
| 572 | i->get().getAsBinary(); |
| 573 | if (!ChildOrErr) { |
| 574 | if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError())) |
| 575 | error(std::move(E), a->getFileName(), i->get()); |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 576 | continue; |
Kevin Enderby | ac9e155 | 2016-05-17 17:10:12 +0000 | [diff] [blame^] | 577 | } |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 578 | if (ObjectFile *o = dyn_cast<ObjectFile>(&*ChildOrErr.get())) { |
| 579 | MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o); |
| 580 | if (OutputFormat == sysv) |
| 581 | outs() << o->getFileName() << " (ex " << UA->getFileName() |
| 582 | << "):\n"; |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 583 | else if (MachO && OutputFormat == darwin) |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 584 | outs() << UA->getFileName() << "(" << o->getFileName() |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 585 | << ")" |
| 586 | << " (for architecture " << I->getArchTypeName() |
| 587 | << "):\n"; |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 588 | printObjectSectionSizes(o); |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 589 | if (OutputFormat == berkeley) { |
| 590 | if (MachO) { |
| 591 | outs() << UA->getFileName() << "(" << o->getFileName() |
| 592 | << ")"; |
| 593 | if (ArchFlags.size() > 1) |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 594 | outs() << " (for architecture " << I->getArchTypeName() |
| 595 | << ")"; |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 596 | outs() << "\n"; |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 597 | } else |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 598 | outs() << o->getFileName() << " (ex " << UA->getFileName() |
| 599 | << ")\n"; |
| 600 | } |
| 601 | } |
| 602 | } |
| 603 | } |
| 604 | } |
| 605 | } |
| 606 | if (!ArchFound) { |
| 607 | errs() << ToolName << ": file: " << file |
| 608 | << " does not contain architecture" << ArchFlags[i] << ".\n"; |
| 609 | return; |
| 610 | } |
| 611 | } |
| 612 | return; |
| 613 | } |
| 614 | // No architecture flags were specified so if this contains a slice that |
| 615 | // matches the host architecture dump only that. |
| 616 | if (!ArchAll) { |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 617 | StringRef HostArchName = MachOObjectFile::getHostArch().getArchName(); |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 618 | for (MachOUniversalBinary::object_iterator I = UB->begin_objects(), |
| 619 | E = UB->end_objects(); |
| 620 | I != E; ++I) { |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 621 | if (HostArchName == I->getArchTypeName()) { |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 622 | ErrorOr<std::unique_ptr<ObjectFile>> UO = I->getAsObjectFile(); |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 623 | if (UO) { |
| 624 | if (ObjectFile *o = dyn_cast<ObjectFile>(&*UO.get())) { |
| 625 | MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o); |
| 626 | if (OutputFormat == sysv) |
| 627 | outs() << o->getFileName() << " :\n"; |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 628 | else if (MachO && OutputFormat == darwin) { |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 629 | if (MoreThanOneFile) |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 630 | outs() << o->getFileName() << " (for architecture " |
| 631 | << I->getArchTypeName() << "):\n"; |
| 632 | } |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 633 | printObjectSectionSizes(o); |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 634 | if (OutputFormat == berkeley) { |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 635 | if (!MachO || MoreThanOneFile) |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 636 | outs() << o->getFileName() << " (for architecture " |
| 637 | << I->getArchTypeName() << ")"; |
| 638 | outs() << "\n"; |
| 639 | } |
| 640 | } |
Rafael Espindola | 0bfe828 | 2014-12-09 21:05:36 +0000 | [diff] [blame] | 641 | } else if (ErrorOr<std::unique_ptr<Archive>> AOrErr = |
| 642 | I->getAsArchive()) { |
| 643 | std::unique_ptr<Archive> &UA = *AOrErr; |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 644 | // This is an archive. Iterate over each member and display its |
| 645 | // sizes. |
| 646 | for (object::Archive::child_iterator i = UA->child_begin(), |
| 647 | e = UA->child_end(); |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 648 | i != e; ++i) { |
Davide Italiano | ff11b90 | 2016-02-13 01:38:16 +0000 | [diff] [blame] | 649 | if (error(i->getError())) |
Kevin Enderby | 7a96942 | 2015-11-05 19:24:56 +0000 | [diff] [blame] | 650 | exit(1); |
Kevin Enderby | ac9e155 | 2016-05-17 17:10:12 +0000 | [diff] [blame^] | 651 | Expected<std::unique_ptr<Binary>> ChildOrErr = |
| 652 | i->get().getAsBinary(); |
| 653 | if (!ChildOrErr) { |
| 654 | if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError())) |
| 655 | error(std::move(E), a->getFileName(), i->get()); |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 656 | continue; |
Kevin Enderby | ac9e155 | 2016-05-17 17:10:12 +0000 | [diff] [blame^] | 657 | } |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 658 | if (ObjectFile *o = dyn_cast<ObjectFile>(&*ChildOrErr.get())) { |
| 659 | MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o); |
| 660 | if (OutputFormat == sysv) |
| 661 | outs() << o->getFileName() << " (ex " << UA->getFileName() |
| 662 | << "):\n"; |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 663 | else if (MachO && OutputFormat == darwin) |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 664 | outs() << UA->getFileName() << "(" << o->getFileName() << ")" |
| 665 | << " (for architecture " << I->getArchTypeName() |
| 666 | << "):\n"; |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 667 | printObjectSectionSizes(o); |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 668 | if (OutputFormat == berkeley) { |
| 669 | if (MachO) |
| 670 | outs() << UA->getFileName() << "(" << o->getFileName() |
| 671 | << ")\n"; |
| 672 | else |
| 673 | outs() << o->getFileName() << " (ex " << UA->getFileName() |
| 674 | << ")\n"; |
| 675 | } |
| 676 | } |
| 677 | } |
| 678 | } |
| 679 | return; |
| 680 | } |
| 681 | } |
| 682 | } |
| 683 | // Either all architectures have been specified or none have been specified |
| 684 | // and this does not contain the host architecture so dump all the slices. |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 685 | bool MoreThanOneArch = UB->getNumberOfObjects() > 1; |
Kevin Enderby | 4b8fc28 | 2014-06-18 22:04:40 +0000 | [diff] [blame] | 686 | for (MachOUniversalBinary::object_iterator I = UB->begin_objects(), |
| 687 | E = UB->end_objects(); |
| 688 | I != E; ++I) { |
Rafael Espindola | 4f7932b | 2014-06-23 20:41:02 +0000 | [diff] [blame] | 689 | ErrorOr<std::unique_ptr<ObjectFile>> UO = I->getAsObjectFile(); |
Rafael Espindola | 4f7932b | 2014-06-23 20:41:02 +0000 | [diff] [blame] | 690 | if (UO) { |
Kevin Enderby | 4b8fc28 | 2014-06-18 22:04:40 +0000 | [diff] [blame] | 691 | if (ObjectFile *o = dyn_cast<ObjectFile>(&*UO.get())) { |
Kevin Enderby | 1983fcf | 2014-06-19 22:03:18 +0000 | [diff] [blame] | 692 | MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o); |
Kevin Enderby | 4b8fc28 | 2014-06-18 22:04:40 +0000 | [diff] [blame] | 693 | if (OutputFormat == sysv) |
| 694 | outs() << o->getFileName() << " :\n"; |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 695 | else if (MachO && OutputFormat == darwin) { |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 696 | if (MoreThanOneFile || MoreThanOneArch) |
Kevin Enderby | 1983fcf | 2014-06-19 22:03:18 +0000 | [diff] [blame] | 697 | outs() << o->getFileName() << " (for architecture " |
| 698 | << I->getArchTypeName() << "):"; |
| 699 | outs() << "\n"; |
| 700 | } |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 701 | printObjectSectionSizes(o); |
Kevin Enderby | 4b8fc28 | 2014-06-18 22:04:40 +0000 | [diff] [blame] | 702 | if (OutputFormat == berkeley) { |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 703 | if (!MachO || MoreThanOneFile || MoreThanOneArch) |
Kevin Enderby | 1983fcf | 2014-06-19 22:03:18 +0000 | [diff] [blame] | 704 | outs() << o->getFileName() << " (for architecture " |
| 705 | << I->getArchTypeName() << ")"; |
Kevin Enderby | 4b8fc28 | 2014-06-18 22:04:40 +0000 | [diff] [blame] | 706 | outs() << "\n"; |
| 707 | } |
| 708 | } |
Rafael Espindola | 0bfe828 | 2014-12-09 21:05:36 +0000 | [diff] [blame] | 709 | } else if (ErrorOr<std::unique_ptr<Archive>> AOrErr = |
| 710 | I->getAsArchive()) { |
| 711 | std::unique_ptr<Archive> &UA = *AOrErr; |
Kevin Enderby | 4b8fc28 | 2014-06-18 22:04:40 +0000 | [diff] [blame] | 712 | // This is an archive. Iterate over each member and display its sizes. |
| 713 | for (object::Archive::child_iterator i = UA->child_begin(), |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 714 | e = UA->child_end(); |
| 715 | i != e; ++i) { |
Davide Italiano | ff11b90 | 2016-02-13 01:38:16 +0000 | [diff] [blame] | 716 | if (error(i->getError())) |
Kevin Enderby | 7a96942 | 2015-11-05 19:24:56 +0000 | [diff] [blame] | 717 | exit(1); |
Kevin Enderby | ac9e155 | 2016-05-17 17:10:12 +0000 | [diff] [blame^] | 718 | Expected<std::unique_ptr<Binary>> ChildOrErr = i->get().getAsBinary(); |
| 719 | if (!ChildOrErr) { |
| 720 | if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError())) |
| 721 | error(std::move(E), UA->getFileName(), i->get()); |
Kevin Enderby | 4b8fc28 | 2014-06-18 22:04:40 +0000 | [diff] [blame] | 722 | continue; |
Kevin Enderby | ac9e155 | 2016-05-17 17:10:12 +0000 | [diff] [blame^] | 723 | } |
Kevin Enderby | 4b8fc28 | 2014-06-18 22:04:40 +0000 | [diff] [blame] | 724 | if (ObjectFile *o = dyn_cast<ObjectFile>(&*ChildOrErr.get())) { |
| 725 | MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o); |
| 726 | if (OutputFormat == sysv) |
| 727 | outs() << o->getFileName() << " (ex " << UA->getFileName() |
| 728 | << "):\n"; |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 729 | else if (MachO && OutputFormat == darwin) |
Kevin Enderby | 1983fcf | 2014-06-19 22:03:18 +0000 | [diff] [blame] | 730 | outs() << UA->getFileName() << "(" << o->getFileName() << ")" |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 731 | << " (for architecture " << I->getArchTypeName() << "):\n"; |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 732 | printObjectSectionSizes(o); |
Kevin Enderby | 4b8fc28 | 2014-06-18 22:04:40 +0000 | [diff] [blame] | 733 | if (OutputFormat == berkeley) { |
| 734 | if (MachO) |
Kevin Enderby | 1983fcf | 2014-06-19 22:03:18 +0000 | [diff] [blame] | 735 | outs() << UA->getFileName() << "(" << o->getFileName() << ")" |
| 736 | << " (for architecture " << I->getArchTypeName() |
| 737 | << ")\n"; |
Kevin Enderby | 4b8fc28 | 2014-06-18 22:04:40 +0000 | [diff] [blame] | 738 | else |
| 739 | outs() << o->getFileName() << " (ex " << UA->getFileName() |
| 740 | << ")\n"; |
| 741 | } |
| 742 | } |
| 743 | } |
| 744 | } |
| 745 | } |
Rafael Espindola | 3f6481d | 2014-08-01 14:31:55 +0000 | [diff] [blame] | 746 | } else if (ObjectFile *o = dyn_cast<ObjectFile>(&Bin)) { |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 747 | if (!checkMachOAndArchFlags(o, file)) |
| 748 | return; |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 749 | if (OutputFormat == sysv) |
| 750 | outs() << o->getFileName() << " :\n"; |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 751 | printObjectSectionSizes(o); |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 752 | if (OutputFormat == berkeley) { |
| 753 | MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o); |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 754 | if (!MachO || MoreThanOneFile) |
Kevin Enderby | 246a460 | 2014-06-17 17:54:13 +0000 | [diff] [blame] | 755 | outs() << o->getFileName(); |
| 756 | outs() << "\n"; |
| 757 | } |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 758 | } else { |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 759 | errs() << ToolName << ": " << file << ": " |
| 760 | << "Unrecognized file type.\n"; |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 761 | } |
Michael J. Spencer | cc5f8d4 | 2011-09-29 00:59:18 +0000 | [diff] [blame] | 762 | // System V adds an extra newline at the end of each file. |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 763 | if (OutputFormat == sysv) |
| 764 | outs() << "\n"; |
| 765 | } |
| 766 | |
| 767 | int main(int argc, char **argv) { |
| 768 | // Print a stack trace if we signal out. |
| 769 | sys::PrintStackTraceOnErrorSignal(); |
| 770 | PrettyStackTraceProgram X(argc, argv); |
| 771 | |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 772 | llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 773 | cl::ParseCommandLineOptions(argc, argv, "llvm object size dumper\n"); |
| 774 | |
| 775 | ToolName = argv[0]; |
| 776 | if (OutputFormatShort.getNumOccurrences()) |
Chris Bieneman | e71fb5c | 2015-01-22 01:49:59 +0000 | [diff] [blame] | 777 | OutputFormat = static_cast<OutputFormatTy>(OutputFormatShort); |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 778 | if (RadixShort.getNumOccurrences()) |
Michael J. Spencer | cc5f8d4 | 2011-09-29 00:59:18 +0000 | [diff] [blame] | 779 | Radix = RadixShort; |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 780 | |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 781 | for (unsigned i = 0; i < ArchFlags.size(); ++i) { |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 782 | if (ArchFlags[i] == "all") { |
| 783 | ArchAll = true; |
Kevin Enderby | 1076974 | 2014-07-01 22:26:31 +0000 | [diff] [blame] | 784 | } else { |
Rafael Espindola | 72318b4 | 2014-08-08 16:30:17 +0000 | [diff] [blame] | 785 | if (!MachOObjectFile::isValidArch(ArchFlags[i])) { |
Kevin Enderby | afef4c9 | 2014-07-01 17:19:10 +0000 | [diff] [blame] | 786 | outs() << ToolName << ": for the -arch option: Unknown architecture " |
| 787 | << "named '" << ArchFlags[i] << "'"; |
| 788 | return 1; |
| 789 | } |
| 790 | } |
| 791 | } |
| 792 | |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 793 | if (InputFilenames.size() == 0) |
| 794 | InputFilenames.push_back("a.out"); |
| 795 | |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 796 | MoreThanOneFile = InputFilenames.size() > 1; |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 797 | std::for_each(InputFilenames.begin(), InputFilenames.end(), |
Rafael Espindola | 1dc30a4 | 2016-02-09 21:35:14 +0000 | [diff] [blame] | 798 | printFileSectionSizes); |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 799 | |
Kevin Enderby | 64f7a99 | 2016-05-02 21:41:03 +0000 | [diff] [blame] | 800 | if (HadError) |
| 801 | return 1; |
Michael J. Spencer | c4ad466 | 2011-09-28 20:57:46 +0000 | [diff] [blame] | 802 | } |