This patch fixes the R_AARCH64_TLSLE_ADD_TPREL_HI12 and R_AARCH64_TLSLE_ADD_TPREL_LO12_NC handling by using the correct offset by using the target layout along with aarch64 alignments requirements. It fixes the TLS test-suite SingleSource failures for aarch64: * SingleSource/UnitTests/Threads/2010-12-08-tls.execution_time * SingleSource/UnitTests/Threads/tls.execution_time llvm-svn: 238258
63 lines
1.7 KiB
C++
63 lines
1.7 KiB
C++
//===- lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h ----------------===//
|
|
//
|
|
// The LLVM Linker
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLD_READER_WRITER_ELF_AARCH64_AARCH64_TARGET_HANDLER_H
|
|
#define LLD_READER_WRITER_ELF_AARCH64_AARCH64_TARGET_HANDLER_H
|
|
|
|
#include "AArch64RelocationHandler.h"
|
|
#include "ELFReader.h"
|
|
#include "TargetLayout.h"
|
|
#include "lld/Core/Simple.h"
|
|
|
|
namespace lld {
|
|
namespace elf {
|
|
class AArch64LinkingContext;
|
|
|
|
class AArch64TargetLayout final : public TargetLayout<ELF64LE> {
|
|
public:
|
|
AArch64TargetLayout(ELFLinkingContext &ctx) : TargetLayout(ctx) {}
|
|
|
|
uint64_t getAlignedTLSSize() const {
|
|
return llvm::RoundUpToAlignment(TCB_ALIGNMENT, this->getTLSSize());
|
|
}
|
|
|
|
private:
|
|
// Alignment requirement for TCB.
|
|
enum { TCB_ALIGNMENT = 0x10 };
|
|
};
|
|
|
|
class AArch64TargetHandler final : public TargetHandler {
|
|
public:
|
|
AArch64TargetHandler(AArch64LinkingContext &ctx);
|
|
|
|
const TargetRelocationHandler &getRelocationHandler() const override {
|
|
return *_relocationHandler;
|
|
}
|
|
|
|
std::unique_ptr<Reader> getObjReader() override {
|
|
return llvm::make_unique<ELFReader<ELFFile<ELF64LE>>>(_ctx);
|
|
}
|
|
|
|
std::unique_ptr<Reader> getDSOReader() override {
|
|
return llvm::make_unique<ELFReader<DynamicFile<ELF64LE>>>(_ctx);
|
|
}
|
|
|
|
std::unique_ptr<Writer> getWriter() override;
|
|
|
|
private:
|
|
AArch64LinkingContext &_ctx;
|
|
std::unique_ptr<AArch64TargetLayout> _targetLayout;
|
|
std::unique_ptr<AArch64TargetRelocationHandler> _relocationHandler;
|
|
};
|
|
|
|
} // end namespace elf
|
|
} // end namespace lld
|
|
|
|
#endif
|