summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2017-09-16 14:29:51 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2017-09-16 14:29:51 +0000
commit762abff698af1c2f5c243a90018ad846211aac9e (patch)
treed7d6ee489b10aef111384cecdb826c510a2c4a01 /llvm/tools
parent65d67807039df6a6b5e879fcf4686493680a4812 (diff)
downloadbcm5719-llvm-762abff698af1c2f5c243a90018ad846211aac9e.tar.gz
bcm5719-llvm-762abff698af1c2f5c243a90018ad846211aac9e.zip
[llvm-readobj] - Teach tool to report error if some section is in multiple COMDAT groups at once.
readelf tool reports an error when output contains the same section in multiple COMDAT groups. That can be useful. Path teaches llvm-readobj to do the same. Differential revision: https://reviews.llvm.org/D37567 llvm-svn: 313459
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-readobj/ELFDumper.cpp40
1 files changed, 38 insertions, 2 deletions
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 4867b473fec..a826e041ecd 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -18,6 +18,7 @@
#include "StackMapPrinter.h"
#include "llvm-readobj.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/SmallString.h"
@@ -2489,18 +2490,40 @@ std::vector<GroupSection> getGroups(const ELFFile<ELFT> *Obj) {
}
return Ret;
}
+
+DenseMap<uint64_t, const GroupSection *>
+mapSectionsToGroups(ArrayRef<GroupSection> Groups) {
+ DenseMap<uint64_t, const GroupSection *> Ret;
+ for (const GroupSection &G : Groups)
+ for (const GroupMember &GM : G.Members)
+ Ret.insert({GM.Index, &G});
+ return Ret;
+}
+
} // namespace
template <class ELFT> void GNUStyle<ELFT>::printGroupSections(const ELFO *Obj) {
std::vector<GroupSection> V = getGroups<ELFT>(Obj);
+ DenseMap<uint64_t, const GroupSection *> Map = mapSectionsToGroups(V);
for (const GroupSection &G : V) {
OS << "\n"
<< getGroupType(G.Type) << " group section ["
<< format_decimal(G.Index, 5) << "] `" << G.Name << "' [" << G.Signature
<< "] contains " << G.Members.size() << " sections:\n"
<< " [Index] Name\n";
- for (const GroupMember &GM : G.Members)
+ for (const GroupMember &GM : G.Members) {
+ const GroupSection *MainGroup = Map[GM.Index];
+ if (MainGroup != &G) {
+ OS.flush();
+ errs() << "Error: section [" << format_decimal(GM.Index, 5)
+ << "] in group section [" << format_decimal(G.Index, 5)
+ << "] already in group section ["
+ << format_decimal(MainGroup->Index, 5) << "]";
+ errs().flush();
+ continue;
+ }
OS << " [" << format_decimal(GM.Index, 5) << "] " << GM.Name << "\n";
+ }
}
if (V.empty())
@@ -3525,6 +3548,7 @@ template <class ELFT>
void LLVMStyle<ELFT>::printGroupSections(const ELFO *Obj) {
DictScope Lists(W, "Groups");
std::vector<GroupSection> V = getGroups<ELFT>(Obj);
+ DenseMap<uint64_t, const GroupSection *> Map = mapSectionsToGroups(V);
for (const GroupSection &G : V) {
DictScope D(W, "Group");
W.printNumber("Name", G.Name, G.ShName);
@@ -3533,13 +3557,25 @@ void LLVMStyle<ELFT>::printGroupSections(const ELFO *Obj) {
W.startLine() << "Signature: " << G.Signature << "\n";
ListScope L(W, "Section(s) in group");
- for (const GroupMember &GM : G.Members)
+ for (const GroupMember &GM : G.Members) {
+ const GroupSection *MainGroup = Map[GM.Index];
+ if (MainGroup != &G) {
+ W.flush();
+ errs() << "Error: " << GM.Name << " (" << GM.Index
+ << ") in a group " + G.Name + " (" << G.Index
+ << ") is already in a group " + MainGroup->Name + " ("
+ << MainGroup->Index << ")\n";
+ errs().flush();
+ continue;
+ }
W.startLine() << GM.Name << " (" << GM.Index << ")\n";
+ }
}
if (V.empty())
W.startLine() << "There are no group sections in the file.\n";
}
+
template <class ELFT> void LLVMStyle<ELFT>::printRelocations(const ELFO *Obj) {
ListScope D(W, "Relocations");
OpenPOWER on IntegriCloud