@@ -53,7 +53,7 @@ static unsigned adjustFixupValue(unsigned Kind, uint64_t Value) {
5353 case Sparc::fixup_sparc_hix22:
5454 return (~Value >> 10 ) & 0x3fffff ;
5555
56- case Sparc::fixup_sparc_pc22 :
56+ case ELF::R_SPARC_PC22 :
5757 case Sparc::fixup_sparc_hi22:
5858 case Sparc::fixup_sparc_lm:
5959 return (Value >> 10 ) & 0x3fffff ;
@@ -64,7 +64,7 @@ static unsigned adjustFixupValue(unsigned Kind, uint64_t Value) {
6464 case Sparc::fixup_sparc_lox10:
6565 return (Value & 0x3ff ) | 0x1c00 ;
6666
67- case Sparc::fixup_sparc_pc10 :
67+ case ELF::R_SPARC_PC10 :
6868 case Sparc::fixup_sparc_lo10:
6969 return Value & 0x3ff ;
7070
@@ -136,8 +136,6 @@ namespace {
136136 { " fixup_sparc_hh" , 10 , 22 , 0 },
137137 { " fixup_sparc_hm" , 22 , 10 , 0 },
138138 { " fixup_sparc_lm" , 10 , 22 , 0 },
139- { " fixup_sparc_pc22" , 10 , 22 , MCFixupKindInfo::FKF_IsPCRel },
140- { " fixup_sparc_pc10" , 22 , 10 , MCFixupKindInfo::FKF_IsPCRel },
141139 { " fixup_sparc_hix22" , 10 , 22 , 0 },
142140 { " fixup_sparc_lox10" , 19 , 13 , 0 },
143141 };
@@ -154,28 +152,35 @@ namespace {
154152 { " fixup_sparc_hh" , 0 , 22 , 0 },
155153 { " fixup_sparc_hm" , 0 , 10 , 0 },
156154 { " fixup_sparc_lm" , 0 , 22 , 0 },
157- { " fixup_sparc_pc22" , 0 , 22 , MCFixupKindInfo::FKF_IsPCRel },
158- { " fixup_sparc_pc10" , 0 , 10 , MCFixupKindInfo::FKF_IsPCRel },
159155 { " fixup_sparc_hix22" , 0 , 22 , 0 },
160156 { " fixup_sparc_lox10" , 0 , 13 , 0 },
161157 };
162158 // clang-format on
163159
164- // Fixup kinds from .reloc directive are like R_SPARC_NONE. They do
165- // not require any extra processing.
166- if (mc::isRelocation (Kind))
167- return MCAsmBackend::getFixupKindInfo (FK_NONE);
160+ if (!mc::isRelocation (Kind)) {
161+ if (Kind < FirstTargetFixupKind)
162+ return MCAsmBackend::getFixupKindInfo (Kind);
163+ assert (unsigned (Kind - FirstTargetFixupKind) <
164+ Sparc::NumTargetFixupKinds &&
165+ " Invalid kind!" );
166+ if (Endian == llvm::endianness::little)
167+ return InfosLE[Kind - FirstTargetFixupKind];
168168
169- if ( Kind < FirstTargetFixupKind)
170- return MCAsmBackend::getFixupKindInfo (Kind);
169+ return InfosBE[ Kind - FirstTargetFixupKind];
170+ }
171171
172- assert (unsigned (Kind - FirstTargetFixupKind) <
173- Sparc::NumTargetFixupKinds &&
174- " Invalid kind!" );
172+ MCFixupKindInfo Info{};
173+ switch (uint16_t (Kind)) {
174+ case ELF::R_SPARC_PC10:
175+ Info = {" " , 22 , 10 , MCFixupKindInfo::FKF_IsPCRel};
176+ break ;
177+ case ELF::R_SPARC_PC22:
178+ Info = {" " , 10 , 22 , MCFixupKindInfo::FKF_IsPCRel};
179+ break ;
180+ }
175181 if (Endian == llvm::endianness::little)
176- return InfosLE[Kind - FirstTargetFixupKind];
177-
178- return InfosBE[Kind - FirstTargetFixupKind];
182+ Info.TargetOffset = 32 - Info.TargetOffset - Info.TargetSize ;
183+ return Info;
179184 }
180185
181186 bool shouldForceRelocation (const MCAssembler &, const MCFixup &,
0 commit comments