1 gnome-shell cores dump on sparc when mesa is build with llvm without this.
2 (to be submitted to upstream).
4 ------------ lwp# 1 / thread# 1 ---------------
5 00000000e7a01a84 fail (e7a017d8, 21, e7a017b0, 1d, f71a7cee, 0) + 108 (ssp.c:169)
6 00000000e7a01ad8 __stack_chk_fail (ff000000, ff000000, ff000000, 0, f3e29970, f3e33d44) + 28
7 00000000ea6c6328 llvm::RuntimeDyldELF::resolveRelocation(const llvm::SectionEntry&,unsigned long,unsignedlong,unsigned,long,unsigned long,unsigned) (3cd2e10, 3cd2ee8, 20, f30a6000, 6, 0) + 1c0
8 00000000ea6c639c llvm::RuntimeDyldELF::resolveRelocation(const llvm::RelocationEntry&,unsigned long) (3cd2e10, 3ee67d8, f30a6000, 0, 0, e7b04430) + 64
9 00000000ea6ab3e0 llvm::RuntimeDyldImpl::resolveRelocationList(const llvm::SmallVector<llvm::RelocationEntry, (unsigned)64>&,unsigned long) (3cd2e10, 3ee67c0, f30a6000, e7b04430, 0, 38) + e0
10 00000000ea6af60c llvm::RuntimeDyldImpl::resolveRelocations() (3cd2e10, 6, 1, e7b04430, 3cd42d0, 3ee67b0) + 2dc
11 00000000ea6af888 llvm::RuntimeDyld::resolveRelocations() (3e13038, 3d801a0, 3fa49a0, 3fa49b0, e7b04430, e7b04430) + 30
13 --- llvm-13.0.0.src/include/llvm/BinaryFormat/ELFRelocs/Sparc.def
14 +++ llvm-13.0.0.src/include/llvm/BinaryFormat/ELFRelocs/Sparc.def
16 ELF_RELOC(R_SPARC_GOTDATA_OP_HIX22, 82)
17 ELF_RELOC(R_SPARC_GOTDATA_OP_LOX10, 83)
18 ELF_RELOC(R_SPARC_GOTDATA_OP, 84)
19 +ELF_RELOC(R_SPARC_H34, 85)
20 +ELF_RELOC(R_SPARC_SIZE32, 86)
21 +ELF_RELOC(R_SPARC_SIZE64, 87)
22 +ELF_RELOC(R_SPARC_WDISP10, 88)
23 +ELF_RELOC(R_SPARC_NUM, 89)
24 --- llvm-13.0.0.src/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h.~1~ 2021-09-24 19:18:10.000000000 +0000
25 +++ llvm-13.0.0.src/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h 2022-01-02 14:26:31.003875610 +0000
27 assert(StubOffset <= AllocationSize && "Not enough space allocated!");
30 + void setStubOffset(unsigned Value) {
32 + assert(StubOffset <= AllocationSize && "Not enough space allocated!");
35 uintptr_t getObjAddress() const { return ObjAddress; }
38 --- llvm-13.0.0.src/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h.~1~ 2021-09-24 19:18:10.000000000 +0000
39 +++ llvm-13.0.0.src/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h 2022-01-02 14:26:31.004157633 +0000
41 void resolvePPC64Relocation(const SectionEntry &Section, uint64_t Offset,
42 uint64_t Value, uint32_t Type, int64_t Addend);
44 + void resolveSPARC3264Relocation(const SectionEntry &Section,
45 + uint64_t Offset, uint64_t Value,
46 + uint32_t Type, int32_t Addend);
48 + void resolveSPARC64Relocation(const SectionEntry &Section,
49 + uint64_t Offset, uint64_t Value,
50 + uint32_t Type, int64_t Addend);
52 void resolveSystemZRelocation(const SectionEntry &Section, uint64_t Offset,
53 uint64_t Value, uint32_t Type, int64_t Addend);
57 else if (Arch == Triple::ppc64 || Arch == Triple::ppc64le)
59 + else if (Arch == Triple::sparc)
61 + else if (Arch == Triple::sparcv9)
63 else if (Arch == Triple::x86_64)
64 return 6; // 2-byte jmp instruction + 32-bit relative address
65 else if (Arch == Triple::systemz)
66 --- llvm-13.0.0.src/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp.~1~ 2021-09-24 19:18:10.000000000 +0000
67 +++ llvm-13.0.0.src/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp 2022-01-02 14:26:31.005058486 +0000
72 +/// SPARC ELF Relocations - common to 32-bit and 64-bit.
73 +/// https://docs.oracle.com/cd/E19683-01/817-3677/chapter6-24/index.html
74 +void RuntimeDyldELF::resolveSPARC3264Relocation(const SectionEntry &Section,
79 + uint64_t *TargetAddress =
80 + reinterpret_cast<uint64_t*>(reinterpret_cast<void*>(Section.getAddress()));
81 + uint64_t *TargetPtr =
82 + reinterpret_cast<uint64_t*>(Section.getAddressWithOffset(Offset));
83 + uint32_t Reloc = 0U;
84 + uint8_t *TargetPtr8 = nullptr;
85 + uint16_t *TargetPtr16 = nullptr;
86 + uint32_t *TargetPtr32 = nullptr;
87 + uint32_t LoadAddress = Section.getLoadAddressWithOffset(Offset) & 0xFFFFFFFF;
88 + uint32_t TargetValue = 0U;
94 + llvm_unreachable("Unimplemented SPARC32 Relocation Type!");
96 + case ELF::R_SPARC_NONE:
98 + case ELF::R_SPARC_SIZE32:
99 + *TargetPtr = Section.getSize() + Addend;
101 + case ELF::R_SPARC_RELATIVE:
102 + *TargetPtr = LoadAddress + Addend;
104 + case ELF::R_SPARC_COPY:
106 + (void) std::memcpy(TargetPtr,
107 + reinterpret_cast<void*>(static_cast<uintptr_t>(Value)),
108 + Section.getSize());
110 + case ELF::R_SPARC_8:
111 + TargetPtr8 = reinterpret_cast<uint8_t*>(TargetPtr);
113 + *TargetPtr8 = Value;
115 + case ELF::R_SPARC_16:
116 + TargetPtr16 = reinterpret_cast<uint16_t*>(TargetPtr);
118 + *TargetPtr16 = Value;
120 + case ELF::R_SPARC_32:
121 + case ELF::R_SPARC_GLOB_DAT:
123 + *TargetPtr = Value;
125 + case ELF::R_SPARC_JMP_SLOT:
127 + case ELF::R_SPARC_TLS_DTPOFF32:
129 + *TargetPtr = Value;
131 + case ELF::R_SPARC_TLS_TPOFF32:
133 + *TargetPtr = Value - Offset;
135 + case ELF::R_SPARC_TLS_LE_HIX22:
138 + *TargetPtr = (*TargetPtr & 0xFFC00000) | ((~Value) & 0x003FFFFFLL);
140 + case ELF::R_SPARC_TLS_LE_LOX10:
143 + *TargetPtr = (*TargetPtr & 0xFFFFE000) | (Value & 0x000003FFLL);
145 + case ELF::R_SPARC_DISP8:
147 + TargetPtr8 = reinterpret_cast<uint8_t*>(TargetAddress);
148 + *TargetPtr8 = (Value - reinterpret_cast<uintptr_t>(TargetPtr8));
150 + case ELF::R_SPARC_DISP16:
152 + TargetPtr16 = reinterpret_cast<uint16_t*>(TargetAddress);
153 + *TargetPtr16 = (Value - reinterpret_cast<uintptr_t>(TargetPtr16));
155 + case ELF::R_SPARC_DISP32:
157 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetAddress);
158 + *TargetPtr32 = (Value - reinterpret_cast<uintptr_t>(TargetPtr32));
160 + case ELF::R_SPARC_WDISP30:
161 + case ELF::R_SPARC_WDISP22:
162 + case ELF::R_SPARC_WDISP19:
163 + case ELF::R_SPARC_WDISP16:
164 + case ELF::R_SPARC_WDISP10:
167 + llvm_unreachable("Impossible default case!");
169 + case ELF::R_SPARC_WDISP30:
173 + case ELF::R_SPARC_WDISP22:
177 + case ELF::R_SPARC_WDISP19:
181 + case ELF::R_SPARC_WDISP16:
184 + case ELF::R_SPARC_WDISP10:
189 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
190 + Reloc = (((Value + Addend) - LoadAddress) >> RS);
191 + TargetValue = *TargetPtr32;
195 + llvm_unreachable("Impossible default case!");
197 + case ELF::R_SPARC_WDISP16:
198 + TargetValue &= ~((0x3 << 20) | 0x3FFF);
199 + Reloc = (((Reloc & 0xC000) << (7 - 1)) | (Reloc & 0x3FFFF));
200 + *TargetPtr32 = TargetValue | Reloc;
202 + case ELF::R_SPARC_WDISP10:
203 + TargetValue &= ~((0x3 << 19) | (0xFF << 5));
204 + Reloc = (((Reloc & 0x300) << (13 - 2)) | ((Reloc & 0xFF) | (7 - 2)));
205 + *TargetPtr32 = TargetValue | Reloc;
207 + case ELF::R_SPARC_WDISP30:
208 + case ELF::R_SPARC_WDISP22:
209 + case ELF::R_SPARC_WDISP19:
210 + TargetValue &= ~RM;
212 + *TargetPtr32 = TargetValue | Reloc;
216 + case ELF::R_SPARC_HI22:
217 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
220 + Reloc = (Value + Addend) >> RS;
221 + TargetValue = *TargetPtr32;
222 + TargetValue &= ~RM;
224 + *TargetPtr32 = TargetValue | Reloc;
226 + case ELF::R_SPARC_10:
228 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
229 + *TargetPtr32 = Value;
231 + case ELF::R_SPARC_11:
233 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
234 + *TargetPtr32 = Value;
236 + case ELF::R_SPARC_13:
238 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
239 + *TargetPtr32 = Value;
241 + case ELF::R_SPARC_22:
243 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
244 + *TargetPtr32 = Value;
246 + case ELF::R_SPARC_LO10:
247 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
250 + Reloc = (Value + Addend) >> RS;
251 + TargetValue = *TargetPtr32;
252 + TargetValue &= ~RM;
254 + *TargetPtr32 = TargetValue | Reloc;
256 + case ELF::R_SPARC_LM22:
257 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
260 + Reloc = (Value + Addend) >> RS;
261 + TargetValue = *TargetPtr32;
262 + TargetValue &= ~RM;
264 + *TargetPtr32 = TargetValue | Reloc;
266 + case ELF::R_SPARC_HIX22:
267 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
270 + Reloc = Value + Addend;
271 + TargetValue = *TargetPtr32;
272 + TargetValue &= ~RM;
276 + *TargetPtr32 = TargetValue | Reloc;
278 + case ELF::R_SPARC_LOX10:
279 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
280 + Reloc = Value + Addend;
281 + TargetValue = *TargetPtr32;
282 + TargetValue &= ~0x1FFF;
285 + *TargetPtr32 = TargetValue | Reloc;
287 + case ELF::R_SPARC_HH22:
288 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
291 + Reloc = (Value + Addend) >> RS;
292 + TargetValue = *TargetPtr32;
293 + TargetValue &= ~RM;
295 + *TargetPtr32 = TargetValue | Reloc;
297 + case ELF::R_SPARC_HM10:
298 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
301 + Reloc = (Value + Addend) >> RS;
302 + TargetValue = *TargetPtr32;
303 + TargetValue &= ~RM;
305 + *TargetPtr32 = TargetValue | Reloc;
307 + case ELF::R_SPARC_H44:
308 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
311 + Reloc = (Value + Addend) >> RS;
312 + TargetValue = *TargetPtr32;
313 + TargetValue &= ~RM;
315 + *TargetPtr32 = TargetValue | Reloc;
317 + case ELF::R_SPARC_M44:
318 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
321 + Reloc = (Value + Addend) >> RS;
322 + TargetValue = *TargetPtr32;
323 + TargetValue &= ~RM;
325 + *TargetPtr32 = TargetValue | Reloc;
327 + case ELF::R_SPARC_L44:
328 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
331 + Reloc = (Value + Addend) >> RS;
332 + TargetValue = *TargetPtr32;
333 + TargetValue &= ~RM;
335 + *TargetPtr32 = TargetValue | Reloc;
337 + case ELF::R_SPARC_GOT10:
338 + assert((Offset != static_cast<uint64_t>(-1)) &&
339 + "R_SPARC_GOT10: Invalid offset!");
340 + if ((Offset & 1) != 0)
347 + Reloc = (Value + Addend) >> RS;
348 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
349 + TargetValue = *TargetPtr32;
350 + TargetValue &= ~RM;
352 + *TargetPtr32 = TargetValue | Reloc;
354 + case ELF::R_SPARC_GOT13:
355 + assert((Offset != static_cast<uint64_t>(-1)) &&
356 + "R_SPARC_GOT13: Invalid offset!");
357 + if ((Offset & 1) != 0)
364 + Reloc = (Value + Addend) >> RS;
366 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
367 + TargetValue = *TargetPtr32;
368 + TargetValue &= ~RM;
370 + *TargetPtr32 = TargetValue | Reloc;
372 + case ELF::R_SPARC_GOT22:
373 + assert((Offset != static_cast<uint64_t>(-1)) &&
374 + "R_SPARC_GOT22: Invalid offset!");
375 + if ((Offset & 1) != 0)
380 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
383 + Reloc = (Value + Addend) >> RS;
384 + TargetValue = *TargetPtr32;
385 + TargetValue &= ~RM;
387 + *TargetPtr32 = TargetValue | Reloc;
389 + case ELF::R_SPARC_PC10:
390 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
393 + Reloc = ((Value + Addend) - LoadAddress) >> RS;
394 + TargetValue = *TargetPtr32;
395 + TargetValue &= ~RM;
397 + *TargetPtr32 = TargetValue | Reloc;
399 + case ELF::R_SPARC_PC22:
400 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
403 + Reloc = ((Value + Addend) - LoadAddress) >> RS;
404 + TargetValue = *TargetPtr32;
405 + TargetValue &= ~RM;
407 + *TargetPtr32 = TargetValue | Reloc;
409 + case ELF::R_SPARC_UA16:
410 + TargetPtr8 = reinterpret_cast<uint8_t*>(TargetPtr);
411 + TargetPtr8[0] = Value >> 8U;
412 + TargetPtr8[1] = Value;
414 + case ELF::R_SPARC_UA32:
415 + TargetPtr8 = reinterpret_cast<uint8_t*>(TargetPtr);
416 + TargetPtr8[0] = Value >> 24U;
417 + TargetPtr8[1] = Value >> 16U;
418 + TargetPtr8[2] = Value >> 8U;
419 + TargetPtr8[3] = Value;
421 + case ELF::R_SPARC_WPLT30:
422 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
425 + Reloc = ((Value + Addend) - LoadAddress) >> RS;
426 + TargetValue = *TargetPtr32;
427 + TargetValue &= ~RM;
429 + *TargetPtr32 = TargetValue | Reloc;
430 + TargetValue = *TargetPtr32;
435 +/// SPARCV9 ELF Relocatinos - valid in 64-bit only.
436 +/// https://docs.oracle.com/cd/E19683-01/817-3677/chapter6-24-1/index.html
437 +void RuntimeDyldELF::resolveSPARC64Relocation(const SectionEntry &Section,
438 + uint64_t Offset, uint64_t Value,
439 + uint32_t Type, int64_t Addend) {
440 + uint64_t *TargetAddress =
441 + reinterpret_cast<uint64_t*>(reinterpret_cast<void*>(Section.getAddress()));
442 + uint64_t *TargetPtr =
443 + reinterpret_cast<uint64_t*>(Section.getAddressWithOffset(Offset));
445 + uintptr_t TargetPtrVal = reinterpret_cast<uintptr_t>(TargetPtr);
446 + uint8_t *TargetPtr8 = nullptr;
447 + uint16_t *TargetPtr16 = nullptr;
448 + uint32_t *TargetPtr32 = nullptr;
449 + uint64_t LoadAddress = Section.getLoadAddressWithOffset(Offset);
450 + uint64_t TargetValue = 0ULL;
455 + case ELF::R_SPARC_HI22:
456 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
459 + Reloc = (Value + Addend) >> RS;
460 + TargetValue = *TargetPtr32;
461 + TargetValue &= ~RM;
463 + *TargetPtr32 = TargetValue | Reloc;
465 + case ELF::R_SPARC_64:
466 + case ELF::R_SPARC_GLOB_DAT:
468 + *TargetPtr = Value;
470 + case ELF::R_SPARC_RELATIVE:
471 + *TargetPtr = LoadAddress + Addend;
473 + case ELF::R_SPARC_OLO10:
474 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
475 + *TargetPtr32 = (*TargetPtr32 & ~0x1FFF) | (((Value + Addend) & 0x3FF) +
476 + ((Offset >> 8) & 0x1FFF));
478 + case ELF::R_SPARC_DISP64:
480 + *TargetPtr = (Value - reinterpret_cast<uintptr_t>(TargetPtr));
482 + case ELF::R_SPARC_REGISTER:
484 + *TargetPtr = Value;
486 + case ELF::R_SPARC_PLT64:
487 + llvm::errs() << __PRETTY_FUNCTION__
488 + << ": Warning: Unimplemented R_SPARC_PLT64 Relocation type.\n" ;
490 + case ELF::R_SPARC_UA64:
492 + if (0 == (TargetPtrVal & 3)) {
493 + TargetPtr32 = reinterpret_cast<uint32_t*>(TargetPtr);
494 + TargetPtr32[0] = Value >> 32;
495 + TargetPtr32[1] = Value;
497 + TargetPtr8 = reinterpret_cast<uint8_t*>(TargetPtr);
498 + TargetPtr8[0] = Value >> 56;
499 + TargetPtr8[0] = Value >> 48;
500 + TargetPtr8[0] = Value >> 40;
501 + TargetPtr8[0] = Value >> 32;
502 + TargetPtr8[0] = Value >> 24;
503 + TargetPtr8[0] = Value >> 16;
504 + TargetPtr8[0] = Value >> 8;
505 + TargetPtr8[0] = Value;
509 + resolveSPARC3264Relocation(Section, Offset, Value, Type, Addend);
514 void RuntimeDyldELF::resolveSystemZRelocation(const SectionEntry &Section,
515 uint64_t Offset, uint64_t Value,
516 uint32_t Type, int64_t Addend) {
517 @@ -1037,6 +1479,12 @@
519 resolveBPFRelocation(Section, Offset, Value, Type, Addend);
521 + case Triple::sparc:
522 + resolveSPARC3264Relocation(Section, Offset, Value, Type, Addend);
524 + case Triple::sparcv9:
525 + resolveSPARC64Relocation(Section, Offset, Value, Type, Addend);
528 llvm_unreachable("Unsupported CPU type!");
530 @@ -1672,6 +2120,160 @@
532 addRelocationForSection(RE, Value.SectionID);
534 + } else if (Arch == Triple::sparc) {
535 + LLVM_DEBUG(dbgs() << "This is a SPARC32 relocation.\n");
536 + SectionEntry &Section = Sections[SectionID];
537 + uint8_t *Target = Section.getAddressWithOffset(Offset);
538 + uint32_t *TargetAddress = reinterpret_cast<uint32_t*>(Target);
539 + uint8_t *SectionAddress = Section.getAddress();
540 + uintptr_t StubOffset = Section.getStubOffset();
541 + uintptr_t StubAddress = static_cast<uintptr_t>(-1);
543 + if (RelType == ELF::R_SPARC_WDISP30) {
544 + // Look up for existing stub.
545 + StubMap::const_iterator i = Stubs.find(Value);
547 + if (i != Stubs.end()) {
548 + LLVM_DEBUG(dbgs() << " Stub function found\n");
550 + reinterpret_cast<uintptr_t>(Section.getAddressWithOffset(i->second));
552 + resolveRelocation(Section, Offset, StubAddress, RelType, 0);
553 + Section.advanceStubOffset(getMaxStubSize());
555 + // Create a new stub function.
556 + LLVM_DEBUG(dbgs() << " Create a new stub function\n");
558 + uintptr_t BaseAddress =
559 + reinterpret_cast<uintptr_t>(Section.getAddress());
560 + uintptr_t StubAlignment = getStubAlignment();
561 + StubAddress = BaseAddress + StubOffset;
562 + StubAddress = llvm::alignTo(StubAddress, 4U);
563 + StubOffset = StubAddress - BaseAddress;
565 + Stubs[Value] = StubOffset;
566 + uint8_t *StubTargetAddr =
567 + createStubFunction(reinterpret_cast<uint8_t*>(StubAddress));
569 + // Creating Hi and Lo relocations for the filled stub instructions.
570 + RelocationEntry REhi(SectionID,
571 + StubTargetAddr - SectionAddress,
572 + ELF::R_SPARC_HI22, Value.Addend);
573 + RelocationEntry RElo(SectionID,
574 + StubTargetAddr - SectionAddress + 4,
575 + ELF::R_SPARC_LO10, Value.Addend);
577 + if (Value.SymbolName) {
578 + addRelocationForSymbol(REhi, Value.SymbolName);
579 + addRelocationForSymbol(RElo, Value.SymbolName);
581 + addRelocationForSection(REhi, Value.SectionID);
582 + addRelocationForSection(RElo, Value.SectionID);
585 + resolveRelocation(Section, Offset, StubAddress, RelType, 0);
586 + Section.advanceStubOffset(getMaxStubSize());
589 + uintptr_t BaseAddress =
590 + reinterpret_cast<uintptr_t>(Section.getAddress());
591 + uintptr_t StubAlignment = getStubAlignment();
592 + StubAddress = BaseAddress + StubOffset;
593 + StubAddress = llvm::alignTo(StubAddress, 4U);
594 + StubOffset = StubAddress - BaseAddress;
596 + RelocationEntry RE(SectionID, Offset, RelType, Addend);
597 + if (Value.SymbolName)
598 + addRelocationForSymbol(RE, Value.SymbolName);
600 + addRelocationForSection(RE, Value.SectionID);
602 + resolveRelocation(Section, Offset, StubOffset, RelType, 0);
603 + Section.advanceStubOffset(getMaxStubSize());
605 + } else if (Arch == Triple::sparcv9) {
606 + LLVM_DEBUG(dbgs() << "This is a SPARC64 relocation.\n");
608 + SectionEntry &Section = Sections[SectionID];
609 + uint8_t *Target = Section.getAddressWithOffset(Offset);
610 + uint32_t *TargetAddress = reinterpret_cast<uint32_t*>(Target);
611 + uint8_t *SectionAddress = Section.getAddress();
612 + uintptr_t StubOffset = Section.getStubOffset();
613 + uintptr_t StubAddress = static_cast<uintptr_t>(-1);
615 + if (RelType == ELF::R_SPARC_WDISP30) {
616 + // Look up for existing stub.
617 + StubMap::const_iterator i = Stubs.find(Value);
618 + if (i != Stubs.end()) {
619 + LLVM_DEBUG(dbgs() << " Stub function found\n");
622 + reinterpret_cast<uintptr_t>(Section.getAddressWithOffset(i->second));
624 + resolveRelocation(Section, Offset, StubAddress, RelType, 0);
625 + Section.advanceStubOffset(getMaxStubSize());
627 + // Create a new stub function.
628 + LLVM_DEBUG(dbgs() << " Create a new stub function\n");
630 + uintptr_t BaseAddress =
631 + reinterpret_cast<uintptr_t>(Section.getAddress());
632 + uintptr_t StubAlignment = getStubAlignment();
634 + StubAddress = BaseAddress + StubOffset;
635 + StubAddress = llvm::alignTo(StubAddress, 8U);
636 + StubOffset = StubAddress - BaseAddress;
637 + Stubs[Value] = StubOffset;
639 + uint8_t *StubTargetAddr =
640 + createStubFunction(reinterpret_cast<uint8_t*>(StubAddress));
642 + // Creating Hi and Lo relocations for the filled stub instructions.
643 + RelocationEntry REhh(SectionID,
644 + StubTargetAddr - SectionAddress,
645 + ELF::R_SPARC_HH22, Value.Addend);
646 + RelocationEntry REhm(SectionID,
647 + StubTargetAddr - SectionAddress + 8,
648 + ELF::R_SPARC_HM10, Value.Addend);
649 + RelocationEntry RElm(SectionID,
650 + StubTargetAddr - SectionAddress + 16,
651 + ELF::R_SPARC_LM22, Value.Addend);
652 + RelocationEntry RElo(SectionID,
653 + StubTargetAddr - SectionAddress + 24,
654 + ELF::R_SPARC_LO10, Value.Addend);
656 + if (Value.SymbolName) {
657 + addRelocationForSymbol(REhh, Value.SymbolName);
658 + addRelocationForSymbol(REhm, Value.SymbolName);
659 + addRelocationForSymbol(RElm, Value.SymbolName);
660 + addRelocationForSymbol(RElo, Value.SymbolName);
662 + addRelocationForSection(REhh, Value.SectionID);
663 + addRelocationForSection(REhm, Value.SectionID);
664 + addRelocationForSection(RElm, Value.SectionID);
665 + addRelocationForSection(RElo, Value.SectionID);
668 + resolveRelocation(Section, Offset, StubAddress, RelType, 0);
669 + Section.advanceStubOffset(getMaxStubSize());
672 + uintptr_t BaseAddress =
673 + reinterpret_cast<uintptr_t>(Section.getAddress());
674 + uintptr_t StubAlignment = getStubAlignment();
675 + StubAddress = BaseAddress + StubOffset;
676 + StubAddress = llvm::alignTo(StubAddress, 8U);
677 + StubOffset = StubAddress - BaseAddress;
679 + RelocationEntry RE(SectionID, Offset, RelType, Addend);
680 + if (Value.SymbolName)
681 + addRelocationForSymbol(RE, Value.SymbolName);
683 + addRelocationForSection(RE, Value.SectionID);
685 + resolveRelocation(Section, Offset, StubAddress, RelType, 0);
686 + Section.advanceStubOffset(getMaxStubSize());
688 } else if (Arch == Triple::systemz &&
689 (RelType == ELF::R_390_PLT32DBL || RelType == ELF::R_390_GOTENT)) {
690 // Create function stubs for both PLT and GOT references, regardless of
691 --- llvm-13.0.0.src/include/llvm/Object/ELFObjectFile.h.~1~ 2021-09-24 19:18:10.000000000 +0000
692 +++ llvm-13.0.0.src/include/llvm/Object/ELFObjectFile.h 2022-01-02 14:26:31.005542785 +0000
693 @@ -1190,8 +1190,9 @@
697 - case ELF::EM_SPARC32PLUS:
698 return "elf32-sparc";
699 + case ELF::EM_SPARC32PLUS:
700 + return "elf32-sparc32plus";
702 return "elf32-amdgpu";
704 @@ -1212,7 +1213,7 @@
707 case ELF::EM_SPARCV9:
708 - return "elf64-sparc";
709 + return "elf64-sparcv9";
713 @@ -1278,8 +1279,8 @@
714 return Triple::systemz;
717 - case ELF::EM_SPARC32PLUS:
718 return IsLittleEndian ? Triple::sparcel : Triple::sparc;
719 + case ELF::EM_SPARC32PLUS:
720 case ELF::EM_SPARCV9:
721 return Triple::sparcv9;