forked from OSchip/llvm-project
parent
a62395a4bd
commit
7244708fcd
|
@ -535,8 +535,7 @@ static typename ELFT::uint getOutFlags(InputSectionBase<ELFT> *S) {
|
|||
}
|
||||
|
||||
template <class ELFT>
|
||||
static SectionKey<ELFT::Is64Bits> createKey(InputSectionBase<ELFT> *C,
|
||||
StringRef OutsecName) {
|
||||
static SectionKey createKey(InputSectionBase<ELFT> *C, StringRef OutsecName) {
|
||||
// The ELF spec just says
|
||||
// ----------------------------------------------------------------
|
||||
// In the first phase, input sections that match in name, type and
|
||||
|
@ -598,14 +597,14 @@ static SectionKey<ELFT::Is64Bits> createKey(InputSectionBase<ELFT> *C,
|
|||
(Config->Relocatable && (C->Flags & SHF_MERGE)))
|
||||
Alignment = std::max<uintX_t>(C->Alignment, C->Entsize);
|
||||
|
||||
return SectionKey<ELFT::Is64Bits>{OutsecName, Flags, Alignment};
|
||||
return SectionKey{OutsecName, Flags, Alignment};
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
std::pair<OutputSectionBase *, bool>
|
||||
OutputSectionFactory<ELFT>::create(InputSectionBase<ELFT> *C,
|
||||
StringRef OutsecName) {
|
||||
SectionKey<ELFT::Is64Bits> Key = createKey(C, OutsecName);
|
||||
SectionKey Key = createKey(C, OutsecName);
|
||||
return create(Key, C);
|
||||
}
|
||||
|
||||
|
@ -615,7 +614,7 @@ static uint64_t getIncompatibleFlags(uint64_t Flags) {
|
|||
|
||||
template <class ELFT>
|
||||
std::pair<OutputSectionBase *, bool>
|
||||
OutputSectionFactory<ELFT>::create(const SectionKey<ELFT::Is64Bits> &Key,
|
||||
OutputSectionFactory<ELFT>::create(const SectionKey &Key,
|
||||
InputSectionBase<ELFT> *C) {
|
||||
uintX_t Flags = getOutFlags(C);
|
||||
OutputSectionBase *&Sec = Map[Key];
|
||||
|
@ -645,36 +644,24 @@ OutputSectionFactory<ELFT>::create(const SectionKey<ELFT::Is64Bits> &Key,
|
|||
return {Sec, true};
|
||||
}
|
||||
|
||||
template <bool Is64Bits>
|
||||
typename lld::elf::SectionKey<Is64Bits>
|
||||
DenseMapInfo<lld::elf::SectionKey<Is64Bits>>::getEmptyKey() {
|
||||
return SectionKey<Is64Bits>{DenseMapInfo<StringRef>::getEmptyKey(), 0, 0};
|
||||
SectionKey DenseMapInfo<SectionKey>::getEmptyKey() {
|
||||
return SectionKey{DenseMapInfo<StringRef>::getEmptyKey(), 0, 0};
|
||||
}
|
||||
|
||||
template <bool Is64Bits>
|
||||
typename lld::elf::SectionKey<Is64Bits>
|
||||
DenseMapInfo<lld::elf::SectionKey<Is64Bits>>::getTombstoneKey() {
|
||||
return SectionKey<Is64Bits>{DenseMapInfo<StringRef>::getTombstoneKey(), 0, 0};
|
||||
SectionKey DenseMapInfo<SectionKey>::getTombstoneKey() {
|
||||
return SectionKey{DenseMapInfo<StringRef>::getTombstoneKey(), 0, 0};
|
||||
}
|
||||
|
||||
template <bool Is64Bits>
|
||||
unsigned
|
||||
DenseMapInfo<lld::elf::SectionKey<Is64Bits>>::getHashValue(const Key &Val) {
|
||||
unsigned DenseMapInfo<SectionKey>::getHashValue(const SectionKey &Val) {
|
||||
return hash_combine(Val.Name, Val.Flags, Val.Alignment);
|
||||
}
|
||||
|
||||
template <bool Is64Bits>
|
||||
bool DenseMapInfo<lld::elf::SectionKey<Is64Bits>>::isEqual(const Key &LHS,
|
||||
const Key &RHS) {
|
||||
bool DenseMapInfo<SectionKey>::isEqual(const SectionKey &LHS,
|
||||
const SectionKey &RHS) {
|
||||
return DenseMapInfo<StringRef>::isEqual(LHS.Name, RHS.Name) &&
|
||||
LHS.Flags == RHS.Flags && LHS.Alignment == RHS.Alignment;
|
||||
}
|
||||
|
||||
namespace llvm {
|
||||
template struct DenseMapInfo<SectionKey<true>>;
|
||||
template struct DenseMapInfo<SectionKey<false>>;
|
||||
}
|
||||
|
||||
namespace lld {
|
||||
namespace elf {
|
||||
|
||||
|
|
|
@ -217,11 +217,10 @@ template <class ELFT> struct Out {
|
|||
static OutputSectionBase *FiniArray;
|
||||
};
|
||||
|
||||
template <bool Is64Bits> struct SectionKey {
|
||||
typedef typename std::conditional<Is64Bits, uint64_t, uint32_t>::type uintX_t;
|
||||
struct SectionKey {
|
||||
StringRef Name;
|
||||
uintX_t Flags;
|
||||
uintX_t Alignment;
|
||||
uint64_t Flags;
|
||||
uint64_t Alignment;
|
||||
};
|
||||
|
||||
// This class knows how to create an output section for a given
|
||||
|
@ -231,16 +230,15 @@ template <bool Is64Bits> struct SectionKey {
|
|||
template <class ELFT> class OutputSectionFactory {
|
||||
typedef typename ELFT::Shdr Elf_Shdr;
|
||||
typedef typename ELFT::uint uintX_t;
|
||||
typedef typename elf::SectionKey<ELFT::Is64Bits> Key;
|
||||
|
||||
public:
|
||||
std::pair<OutputSectionBase *, bool> create(InputSectionBase<ELFT> *C,
|
||||
StringRef OutsecName);
|
||||
std::pair<OutputSectionBase *, bool>
|
||||
create(const SectionKey<ELFT::Is64Bits> &Key, InputSectionBase<ELFT> *C);
|
||||
std::pair<OutputSectionBase *, bool> create(const SectionKey &Key,
|
||||
InputSectionBase<ELFT> *C);
|
||||
|
||||
private:
|
||||
llvm::SmallDenseMap<Key, OutputSectionBase *> Map;
|
||||
llvm::SmallDenseMap<SectionKey, OutputSectionBase *> Map;
|
||||
};
|
||||
|
||||
template <class ELFT> uint64_t getHeaderSize() {
|
||||
|
@ -265,13 +263,12 @@ template <class ELFT> OutputSectionBase *Out<ELFT>::FiniArray;
|
|||
} // namespace lld
|
||||
|
||||
namespace llvm {
|
||||
template <bool Is64Bits> struct DenseMapInfo<lld::elf::SectionKey<Is64Bits>> {
|
||||
typedef typename lld::elf::SectionKey<Is64Bits> Key;
|
||||
|
||||
static Key getEmptyKey();
|
||||
static Key getTombstoneKey();
|
||||
static unsigned getHashValue(const Key &Val);
|
||||
static bool isEqual(const Key &LHS, const Key &RHS);
|
||||
template <> struct DenseMapInfo<lld::elf::SectionKey> {
|
||||
static lld::elf::SectionKey getEmptyKey();
|
||||
static lld::elf::SectionKey getTombstoneKey();
|
||||
static unsigned getHashValue(const lld::elf::SectionKey &Val);
|
||||
static bool isEqual(const lld::elf::SectionKey &LHS,
|
||||
const lld::elf::SectionKey &RHS);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue