Define Config::Is64.

This is a shorthand for Config->Wordsize == 8. So this is not strictly
necessary but seems handy. "Is 64 bit?" is easier to read than "Is
wordsize 8 byte?"

llvm-svn: 298463
This commit is contained in:
Rui Ueyama 2017-03-22 00:01:11 +00:00
parent 4226a9f2b8
commit 7ab38c3a12
4 changed files with 10 additions and 7 deletions

View File

@ -173,7 +173,10 @@ struct Configuration {
// output file. Usually false because we consume relocations.
bool CopyRelocs;
// True if the target is little-endian. False if the target is big-endian.
// True if the target is ELF64. False if ELF32.
bool Is64;
// True if the target is little-endian. False if big-endian.
bool IsLE;
// endianness::little if IsLE is true. endianness::big otherwise.

View File

@ -707,20 +707,20 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
static void setConfigs() {
ELFKind Kind = Config->EKind;
uint16_t Machine = Config->EMachine;
bool Is64 = (Kind == ELF64LEKind || Kind == ELF64BEKind);
// There is an ILP32 ABI for x86-64, although it's not very popular.
// It is called the x32 ABI.
bool IsX32 = (Kind == ELF32LEKind && Machine == EM_X86_64);
Config->CopyRelocs = (Config->Relocatable || Config->EmitRelocs);
Config->Is64 = (Kind == ELF64LEKind || Kind == ELF64BEKind);
Config->IsLE = (Kind == ELF32LEKind || Kind == ELF64LEKind);
Config->Endianness =
Config->IsLE ? support::endianness::little : support::endianness::big;
Config->IsMips64EL = (Kind == ELF64LEKind && Machine == EM_MIPS);
Config->IsRela = Is64 || IsX32 || Config->MipsN32Abi;
Config->IsRela = Config->Is64 || IsX32 || Config->MipsN32Abi;
Config->Pic = Config->Pie || Config->Shared;
Config->Wordsize = Is64 ? 8 : 4;
Config->Wordsize = Config->Is64 ? 8 : 4;
}
// Returns a value of "-format" option.

View File

@ -140,8 +140,8 @@ OutputSection *SectionBase::getOutputSection() {
// Uncompress section contents. Note that this function is called
// from parallel_for_each, so it must be thread-safe.
void InputSectionBase::uncompress() {
Decompressor Dec = check(Decompressor::create(
Name, toStringRef(Data), Config->IsLE, Config->Wordsize == 8));
Decompressor Dec = check(Decompressor::create(Name, toStringRef(Data),
Config->IsLE, Config->Is64));
size_t Size = Dec.getDecompressedSize();
char *OutputBuf;

View File

@ -846,7 +846,7 @@ uint64_t MipsGotSection::getGp() const {
}
static void writeUint(uint8_t *Buf, uint64_t Val) {
if (Config->Wordsize == 8)
if (Config->Is64)
write64(Buf, Val, Config->Endianness);
else
write32(Buf, Val, Config->Endianness);