@@ -63,6 +63,7 @@ template <class ELFT> class OutputSection {
63
63
template <class ELFT > class Writer {
64
64
public:
65
65
typedef typename llvm::object::ELFFile<ELFT>::uintX_t uintX_t;
66
+ typedef typename llvm::object::ELFFile<ELFT>::Elf_Shdr Elf_Shdr;
66
67
Writer (SymbolTable *T) : Symtab(T) {}
67
68
void run ();
68
69
@@ -140,13 +141,44 @@ template <class ELFT> void OutputSection<ELFT>::writeHeaderTo(Elf_Shdr *SHdr) {
140
141
*SHdr = Header;
141
142
}
142
143
144
+ namespace {
145
+ template <bool Is64Bits> struct SectionKey {
146
+ typedef typename std::conditional<Is64Bits, uint64_t , uint32_t >::type uintX_t;
147
+ StringRef Name;
148
+ uint32_t sh_type;
149
+ uintX_t sh_flags;
150
+ };
151
+ }
152
+ namespace llvm {
153
+ template <bool Is64Bits> struct DenseMapInfo <SectionKey<Is64Bits>> {
154
+ static SectionKey<Is64Bits> getEmptyKey () {
155
+ return SectionKey<Is64Bits>{DenseMapInfo<StringRef>::getEmptyKey (), 0 , 0 };
156
+ }
157
+ static SectionKey<Is64Bits> getTombstoneKey () {
158
+ return SectionKey<Is64Bits>{DenseMapInfo<StringRef>::getTombstoneKey (), 0 ,
159
+ 0 };
160
+ }
161
+ static unsigned getHashValue (const SectionKey<Is64Bits> &Val) {
162
+ return hash_combine (Val.Name , Val.sh_type , Val.sh_flags );
163
+ }
164
+ static bool isEqual (const SectionKey<Is64Bits> &LHS,
165
+ const SectionKey<Is64Bits> &RHS) {
166
+ return DenseMapInfo<StringRef>::isEqual (LHS.Name , RHS.Name ) &&
167
+ LHS.sh_type == RHS.sh_type && LHS.sh_flags == RHS.sh_flags ;
168
+ }
169
+ };
170
+ }
171
+
143
172
// Create output section objects and add them to OutputSections.
144
173
template <class ELFT > void Writer<ELFT>::createSections() {
145
- SmallDenseMap<StringRef , OutputSection<ELFT> *> Map;
174
+ SmallDenseMap<SectionKey<ELFT::Is64Bits> , OutputSection<ELFT> *> Map;
146
175
for (std::unique_ptr<ObjectFileBase> &FileB : Symtab->ObjectFiles ) {
147
176
auto &File = cast<ObjectFile<ELFT>>(*FileB);
148
177
for (SectionChunk<ELFT> *C : File.getChunks ()) {
149
- OutputSection<ELFT> *&Sec = Map[C->getSectionName ()];
178
+ const Elf_Shdr *H = C->getSectionHdr ();
179
+ SectionKey<ELFT::Is64Bits> Key{C->getSectionName (), H->sh_type ,
180
+ H->sh_flags };
181
+ OutputSection<ELFT> *&Sec = Map[Key];
150
182
if (!Sec) {
151
183
Sec = new (CAlloc.Allocate ()) OutputSection<ELFT>(C->getSectionName ());
152
184
OutputSections.push_back (Sec);
0 commit comments