summaryrefslogtreecommitdiffstats
path: root/lld/ELF/Arch/PPC.cpp
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2019-06-20 14:00:08 +0000
committerFangrui Song <maskray@google.com>2019-06-20 14:00:08 +0000
commit249fde85832c33f8b06c6b4ac65d1c4b96d23b83 (patch)
tree1af352336fe97e57ca3fced4b02a07afae6c1031 /lld/ELF/Arch/PPC.cpp
parentffed2c96d9f1379a2af4b1b0827255da0be59d65 (diff)
downloadbcm5719-llvm-249fde85832c33f8b06c6b4ac65d1c4b96d23b83.tar.gz
bcm5719-llvm-249fde85832c33f8b06c6b4ac65d1c4b96d23b83.zip
[ELF][ARM][AARCH64][MIPS][PPC] Simplify the logic to create R_*_RELATIVE for absolute relocation types in writable sections
Summary: Our rule to create R_*_RELATIVE for absolute relocation types were loose. D63121 made it stricter but it failed to create R_*_RELATIVE for R_ARM_TARGET1 and R_PPC64_TOC. rLLD363236 worked around that by reinstating the original behavior for ARM and PPC64. This patch is an attempt to simplify the logic. Note, in ld.bfd, R_ARM_TARGET2 --target2=abs also creates R_ARM_RELATIVE. This seems a very uncommon scenario (moreover, --target2=got-rel is the default), so I do not implement any logic related to it. Also, delete R_AARCH64_ABS32 from AArch64::getDynRel. We don't have working ILP32 support yet. Allowing it would create an incorrect R_AARCH64_RELATIVE. For MIPS, the (if SymbolRel, then RelativeRel) code is to keep its behavior unchanged. Note, in ppc64-abs64-dyn.s, R_PPC64_TOC gets an incorrect addend because computeAddend() doesn't compute the correct address. We seem to have the wrong behavior for a long time. The important thing seems that a dynamic relocation R_PPC64_TOC should not be created as the dynamic loader will error R_PPC64_TOC is not supported. Reviewers: atanasyan, grimar, peter.smith, ruiu, sfertile, espindola Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D63383 llvm-svn: 363928
Diffstat (limited to 'lld/ELF/Arch/PPC.cpp')
-rw-r--r--lld/ELF/Arch/PPC.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/lld/ELF/Arch/PPC.cpp b/lld/ELF/Arch/PPC.cpp
index 45f799c3687..30b6966ffbd 100644
--- a/lld/ELF/Arch/PPC.cpp
+++ b/lld/ELF/Arch/PPC.cpp
@@ -23,6 +23,9 @@ namespace {
class PPC final : public TargetInfo {
public:
PPC();
+ RelExpr getRelExpr(RelType Type, const Symbol &S,
+ const uint8_t *Loc) const override;
+ RelType getDynRel(RelType Type) const override;
void writeGotHeader(uint8_t *Buf) const override;
void writePltHeader(uint8_t *Buf) const override {
llvm_unreachable("should call writePPC32GlinkSection() instead");
@@ -36,8 +39,6 @@ public:
uint64_t BranchAddr, const Symbol &S) const override;
uint32_t getThunkSectionSpacing() const override;
bool inBranchRange(RelType Type, uint64_t Src, uint64_t Dst) const override;
- RelExpr getRelExpr(RelType Type, const Symbol &S,
- const uint8_t *Loc) const override;
void relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const override;
RelExpr adjustRelaxExpr(RelType Type, const uint8_t *Data,
RelExpr Expr) const override;
@@ -230,6 +231,12 @@ RelExpr PPC::getRelExpr(RelType Type, const Symbol &S,
}
}
+RelType PPC::getDynRel(RelType Type) const {
+ if (Type == R_PPC_ADDR32)
+ return Type;
+ return R_PPC_NONE;
+}
+
static std::pair<RelType, uint64_t> fromDTPREL(RelType Type, uint64_t Val) {
uint64_t DTPBiasedVal = Val - 0x8000;
switch (Type) {
OpenPOWER on IntegriCloud