aboutsummaryrefslogtreecommitdiff
path: root/deps/lld/ELF/Arch/AMDGPU.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-01-17 17:29:21 -0500
committerAndrew Kelley <superjoe30@gmail.com>2018-01-17 17:29:21 -0500
commit4aed7ea6f89a091aede10ccf0fb45b3ce12c710d (patch)
tree1e29f13ad17bfc841c33f6ac3d0ccb092404f409 /deps/lld/ELF/Arch/AMDGPU.cpp
parent48cd808185f54e935714539d101585a9a0a41673 (diff)
downloadzig-4aed7ea6f89a091aede10ccf0fb45b3ce12c710d.tar.gz
zig-4aed7ea6f89a091aede10ccf0fb45b3ce12c710d.zip
update embedded LLD to 6.0.0rc1
Diffstat (limited to 'deps/lld/ELF/Arch/AMDGPU.cpp')
-rw-r--r--deps/lld/ELF/Arch/AMDGPU.cpp34
1 files changed, 26 insertions, 8 deletions
diff --git a/deps/lld/ELF/Arch/AMDGPU.cpp b/deps/lld/ELF/Arch/AMDGPU.cpp
index de566c617a..505e0e6ad4 100644
--- a/deps/lld/ELF/Arch/AMDGPU.cpp
+++ b/deps/lld/ELF/Arch/AMDGPU.cpp
@@ -7,10 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#include "Error.h"
#include "InputFiles.h"
#include "Symbols.h"
#include "Target.h"
+#include "lld/Common/ErrorHandler.h"
#include "llvm/Object/ELF.h"
#include "llvm/Support/Endian.h"
@@ -25,19 +25,38 @@ namespace {
class AMDGPU final : public TargetInfo {
public:
AMDGPU();
- void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
- RelExpr getRelExpr(uint32_t Type, const SymbolBody &S,
+ uint32_t calcEFlags() const override;
+ void relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const override;
+ RelExpr getRelExpr(RelType Type, const Symbol &S,
const uint8_t *Loc) const override;
};
} // namespace
AMDGPU::AMDGPU() {
- RelativeRel = R_AMDGPU_REL64;
+ RelativeRel = R_AMDGPU_RELATIVE64;
GotRel = R_AMDGPU_ABS64;
GotEntrySize = 8;
}
-void AMDGPU::relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const {
+static uint32_t getEFlags(InputFile *File) {
+ return cast<ObjFile<ELF64LE>>(File)->getObj().getHeader()->e_flags;
+}
+
+uint32_t AMDGPU::calcEFlags() const {
+ assert(!ObjectFiles.empty());
+ uint32_t Ret = getEFlags(ObjectFiles[0]);
+
+ // Verify that all input files have the same e_flags.
+ for (InputFile *F : makeArrayRef(ObjectFiles).slice(1)) {
+ if (Ret == getEFlags(F))
+ continue;
+ error("incompatible e_flags: " + toString(F));
+ return 0;
+ }
+ return Ret;
+}
+
+void AMDGPU::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {
switch (Type) {
case R_AMDGPU_ABS32:
case R_AMDGPU_GOTPCREL:
@@ -58,7 +77,7 @@ void AMDGPU::relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const {
}
}
-RelExpr AMDGPU::getRelExpr(uint32_t Type, const SymbolBody &S,
+RelExpr AMDGPU::getRelExpr(RelType Type, const Symbol &S,
const uint8_t *Loc) const {
switch (Type) {
case R_AMDGPU_ABS32:
@@ -73,8 +92,7 @@ RelExpr AMDGPU::getRelExpr(uint32_t Type, const SymbolBody &S,
case R_AMDGPU_GOTPCREL32_HI:
return R_GOT_PC;
default:
- error(toString(S.File) + ": unknown relocation type: " + toString(Type));
- return R_HINT;
+ return R_INVALID;
}
}