From 4c5e43da7792f75567b693105cc53e3f1992ad98 Mon Sep 17 00:00:00 2001 From: Pirama Arumuga Nainar Date: Wed, 8 Apr 2015 08:55:49 -0700 Subject: Update aosp/master llvm for rebase to r233350 Change-Id: I07d935f8793ee8ec6b7da003f6483046594bca49 --- tools/llvm-nm/Android.mk | 2 +- tools/llvm-nm/llvm-nm.cpp | 130 +++++++++++++++++++++------------------------- 2 files changed, 60 insertions(+), 72 deletions(-) (limited to 'tools/llvm-nm') diff --git a/tools/llvm-nm/Android.mk b/tools/llvm-nm/Android.mk index e3b66f0..4510fa9 100644 --- a/tools/llvm-nm/Android.mk +++ b/tools/llvm-nm/Android.mk @@ -39,8 +39,8 @@ llvm_nm_STATIC_LIBRARIES := \ libLLVMX86Disassembler \ libLLVMCodeGen \ libLLVMTransformUtils \ - libLLVMAnalysis \ libLLVMTarget \ + libLLVMAnalysis \ libLLVMObject \ libLLVMBitReader \ libLLVMMC \ diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index f911c72..b62b547 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -188,85 +188,77 @@ static bool compareSymbolAddress(const NMSymbol &A, const NMSymbol &B) { if (!ReverseSort) { if (A.Address < B.Address) return true; - else if (A.Address == B.Address && A.Name < B.Name) + if (A.Address == B.Address && A.Name < B.Name) return true; - else if (A.Address == B.Address && A.Name == B.Name && A.Size < B.Size) + if (A.Address == B.Address && A.Name == B.Name && A.Size < B.Size) return true; - else - return false; - } else { - if (A.Address > B.Address) - return true; - else if (A.Address == B.Address && A.Name > B.Name) - return true; - else if (A.Address == B.Address && A.Name == B.Name && A.Size > B.Size) - return true; - else - return false; + return false; } + + if (A.Address > B.Address) + return true; + if (A.Address == B.Address && A.Name > B.Name) + return true; + if (A.Address == B.Address && A.Name == B.Name && A.Size > B.Size) + return true; + return false; } static bool compareSymbolSize(const NMSymbol &A, const NMSymbol &B) { if (!ReverseSort) { if (A.Size < B.Size) return true; - else if (A.Size == B.Size && A.Name < B.Name) - return true; - else if (A.Size == B.Size && A.Name == B.Name && A.Address < B.Address) - return true; - else - return false; - } else { - if (A.Size > B.Size) + if (A.Size == B.Size && A.Name < B.Name) return true; - else if (A.Size == B.Size && A.Name > B.Name) + if (A.Size == B.Size && A.Name == B.Name && A.Address < B.Address) return true; - else if (A.Size == B.Size && A.Name == B.Name && A.Address > B.Address) - return true; - else - return false; + return false; } + + if (A.Size > B.Size) + return true; + if (A.Size == B.Size && A.Name > B.Name) + return true; + if (A.Size == B.Size && A.Name == B.Name && A.Address > B.Address) + return true; + return false; } static bool compareSymbolName(const NMSymbol &A, const NMSymbol &B) { if (!ReverseSort) { if (A.Name < B.Name) return true; - else if (A.Name == B.Name && A.Size < B.Size) - return true; - else if (A.Name == B.Name && A.Size == B.Size && A.Address < B.Address) - return true; - else - return false; - } else { - if (A.Name > B.Name) + if (A.Name == B.Name && A.Size < B.Size) return true; - else if (A.Name == B.Name && A.Size > B.Size) + if (A.Name == B.Name && A.Size == B.Size && A.Address < B.Address) return true; - else if (A.Name == B.Name && A.Size == B.Size && A.Address > B.Address) - return true; - else - return false; + return false; } + if (A.Name > B.Name) + return true; + if (A.Name == B.Name && A.Size > B.Size) + return true; + if (A.Name == B.Name && A.Size == B.Size && A.Address > B.Address) + return true; + return false; } static char isSymbolList64Bit(SymbolicFile &Obj) { if (isa(Obj)) return false; - else if (isa(Obj)) + if (isa(Obj)) return false; - else if (MachOObjectFile *MachO = dyn_cast(&Obj)) + if (MachOObjectFile *MachO = dyn_cast(&Obj)) return MachO->is64Bit(); - else if (isa(Obj)) + if (isa(Obj)) return false; - else if (isa(Obj)) + if (isa(Obj)) return true; - else if (isa(Obj)) + if (isa(Obj)) return false; - else if (isa(Obj)) + if (isa(Obj)) return true; - else - return false; + return false; } static StringRef CurrentFilename; @@ -973,30 +965,26 @@ static void dumpSymbolNamesFromObject(SymbolicFile &Obj, bool printName, // architectures was specificed. If not then an error is generated and this // routine returns false. Else it returns true. static bool checkMachOAndArchFlags(SymbolicFile *O, std::string &Filename) { - if (isa(O) && !ArchAll && ArchFlags.size() != 0) { - MachOObjectFile *MachO = dyn_cast(O); - bool ArchFound = false; - MachO::mach_header H; - MachO::mach_header_64 H_64; - Triple T; - if (MachO->is64Bit()) { - H_64 = MachO->MachOObjectFile::getHeader64(); - T = MachOObjectFile::getArch(H_64.cputype, H_64.cpusubtype); - } else { - H = MachO->MachOObjectFile::getHeader(); - T = MachOObjectFile::getArch(H.cputype, H.cpusubtype); - } - unsigned i; - for (i = 0; i < ArchFlags.size(); ++i) { - if (ArchFlags[i] == T.getArchName()) - ArchFound = true; - break; - } - if (!ArchFound) { - error(ArchFlags[i], - "file: " + Filename + " does not contain architecture"); - return false; - } + MachOObjectFile *MachO = dyn_cast(O); + + if (!MachO || ArchAll || ArchFlags.size() == 0) + return true; + + MachO::mach_header H; + MachO::mach_header_64 H_64; + Triple T; + if (MachO->is64Bit()) { + H_64 = MachO->MachOObjectFile::getHeader64(); + T = MachOObjectFile::getArch(H_64.cputype, H_64.cpusubtype); + } else { + H = MachO->MachOObjectFile::getHeader(); + T = MachOObjectFile::getArch(H.cputype, H.cpusubtype); + } + if (std::none_of( + ArchFlags.begin(), ArchFlags.end(), + [&](const std::string &Name) { return Name == T.getArchName(); })) { + error("No architecture specified", Filename); + return false; } return true; } -- cgit v1.1