+
+ /// PPC64 ELF
+ RelocToApply visitELF_PPC64_ADDR32(RelocationRef R, uint64_t Value) {
+ int64_t Addend = getELFAddend(R);
+ uint32_t Res = (Value + Addend) & 0xFFFFFFFF;
+ return RelocToApply(Res, 4);
+ }
+ RelocToApply visitELF_PPC64_ADDR64(RelocationRef R, uint64_t Value) {
+ int64_t Addend = getELFAddend(R);
+ return RelocToApply(Value + Addend, 8);
+ }
+
+ /// PPC32 ELF
+ RelocToApply visitELF_PPC_ADDR32(RelocationRef R, uint64_t Value) {
+ int64_t Addend = getELFAddend(R);
+ uint32_t Res = (Value + Addend) & 0xFFFFFFFF;
+ return RelocToApply(Res, 4);
+ }
+
+ /// MIPS ELF
+ RelocToApply visitELF_MIPS_32(RelocationRef R, uint64_t Value) {
+ uint32_t Res = (Value)&0xFFFFFFFF;
+ return RelocToApply(Res, 4);
+ }
+
+ RelocToApply visitELF_MIPS_64(RelocationRef R, uint64_t Value) {
+ int64_t Addend = getELFAddend(R);
+ uint64_t Res = (Value + Addend);
+ return RelocToApply(Res, 8);
+ }
+
+ // AArch64 ELF
+ RelocToApply visitELF_AARCH64_ABS32(RelocationRef R, uint64_t Value) {
+ int64_t Addend = getELFAddend(R);
+ int64_t Res = Value + Addend;
+
+ // Overflow check allows for both signed and unsigned interpretation.
+ if (Res < INT32_MIN || Res > UINT32_MAX)
+ HasError = true;
+
+ return RelocToApply(static_cast<uint32_t>(Res), 4);
+ }
+
+ RelocToApply visitELF_AARCH64_ABS64(RelocationRef R, uint64_t Value) {
+ int64_t Addend = getELFAddend(R);
+ return RelocToApply(Value + Addend, 8);
+ }
+
+ // SystemZ ELF
+ RelocToApply visitELF_390_32(RelocationRef R, uint64_t Value) {
+ int64_t Addend = getELFAddend(R);
+ int64_t Res = Value + Addend;
+
+ // Overflow check allows for both signed and unsigned interpretation.
+ if (Res < INT32_MIN || Res > UINT32_MAX)
+ HasError = true;
+
+ return RelocToApply(static_cast<uint32_t>(Res), 4);
+ }
+
+ RelocToApply visitELF_390_64(RelocationRef R, uint64_t Value) {
+ int64_t Addend = getELFAddend(R);
+ return RelocToApply(Value + Addend, 8);
+ }
+
+ RelocToApply visitELF_SPARC_32(RelocationRef R, uint32_t Value) {
+ int32_t Addend = getELFAddend(R);
+ return RelocToApply(Value + Addend, 4);
+ }
+
+ RelocToApply visitELF_SPARCV9_32(RelocationRef R, uint64_t Value) {
+ int32_t Addend = getELFAddend(R);
+ return RelocToApply(Value + Addend, 4);
+ }
+
+ RelocToApply visitELF_SPARCV9_64(RelocationRef R, uint64_t Value) {
+ int64_t Addend = getELFAddend(R);
+ return RelocToApply(Value + Addend, 8);
+ }
+
+ RelocToApply visitELF_ARM_ABS32(RelocationRef R, uint64_t Value) {
+ int64_t Res = Value;
+
+ // Overflow check allows for both signed and unsigned interpretation.
+ if (Res < INT32_MIN || Res > UINT32_MAX)
+ HasError = true;
+
+ return RelocToApply(static_cast<uint32_t>(Res), 4);
+ }
+
+ /// I386 COFF
+ RelocToApply visitCOFF_I386_SECREL(RelocationRef R, uint64_t Value) {
+ return RelocToApply(static_cast<uint32_t>(Value), /*Width=*/4);
+ }
+
+ RelocToApply visitCOFF_I386_DIR32(RelocationRef R, uint64_t Value) {
+ return RelocToApply(static_cast<uint32_t>(Value), /*Width=*/4);
+ }
+
+ /// AMD64 COFF
+ RelocToApply visitCOFF_AMD64_SECREL(RelocationRef R, uint64_t Value) {
+ return RelocToApply(static_cast<uint32_t>(Value), /*Width=*/4);
+ }
+
+ RelocToApply visitCOFF_AMD64_ADDR64(RelocationRef R, uint64_t Value) {
+ return RelocToApply(Value, /*Width=*/8);
+ }
+
+ // X86_64 MachO
+ RelocToApply visitMACHO_X86_64_UNSIGNED(RelocationRef R, uint64_t Value) {
+ uint8_t Length = getLengthMachO64(R);
+ Length = 1<<Length;
+ return RelocToApply(Value, Length);
+ }