[llvm] [RuntimeDyld][ELF][AArch64] Fix resolveAArch64ShortBranch. (PR #92245)

Michał Górny via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 5 05:15:21 PDT 2024


mgorny wrote:

```
(gdb) bt
#0  0xf7fc6579 in __kernel_vsyscall ()
#1  0xf1577347 in ?? () from /usr/lib/libc.so.6
#2  0xf151c2f1 in raise () from /usr/lib/libc.so.6
#3  0xf15032b8 in abort () from /usr/lib/libc.so.6
#4  0xf15031be in ?? () from /usr/lib/libc.so.6
#5  0xf151432b in __assert_fail () from /usr/lib/libc.so.6
#6  0xf478a70e in llvm::RuntimeDyldELF::resolveAArch64Relocation (this=0x565c73a0, Section=..., Offset=0, Value=18446744073468444676, 
    Type=282, Addend=0)
    at /var/tmp/portage/sys-devel/llvm-19.0.0.9999/work/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp:497
#7  0xf478ab1d in llvm::RuntimeDyldELF::resolveRelocation (this=0x565c73a0, Section=..., Offset=0, Value=18446744073468444676, 
    Type=282, Addend=0, SymOffset=0, SectionID=0)
    at /var/tmp/portage/sys-devel/llvm-19.0.0.9999/work/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp:1056
#8  0xf478b427 in llvm::RuntimeDyldELF::resolveAArch64Branch (this=0x565c73a0, SectionID=1, Value=..., RelI=..., 
    Stubs=std::map with 1 element = {...})
    at /var/tmp/portage/sys-devel/llvm-19.0.0.9999/work/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp:1219
#9  0xf478e83d in llvm::RuntimeDyldELF::processRelocationRef (this=<optimized out>, SectionID=<optimized out>, RelI=..., O=..., 
    ObjSectionToID=..., Stubs=...)
    at /var/tmp/portage/sys-devel/llvm-19.0.0.9999/work/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp:1327
#10 0xf4775a4a in llvm::RuntimeDyldImpl::loadObjectImpl (this=<optimized out>, Obj=...)
    at /var/tmp/portage/sys-devel/llvm-19.0.0.9999/work/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp:393
#11 0xf478c175 in llvm::RuntimeDyldELF::loadObject (this=0x565c73a0, O=...)
    at /var/tmp/portage/sys-devel/llvm-19.0.0.9999/work/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp:250
#12 0xf476bd55 in llvm::RuntimeDyld::loadObject (this=0xffffbbd8, Obj=...)
    at /var/tmp/portage/sys-devel/llvm-19.0.0.9999/work/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp:1369
#13 0x5656b776 in linkAndVerify () at /var/tmp/portage/sys-devel/llvm-19.0.0.9999/work/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp:995
#14 0x5656ebb3 in main (argc=<optimized out>, argv=<optimized out>)
    at /var/tmp/portage/sys-devel/llvm-19.0.0.9999/work/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp:1053
```

These numbers are as of 1af0778f9c6e1ac0f6e2dfd0e56063cc21c4eea5.

```
#6  0xf478a70e in llvm::RuntimeDyldELF::resolveAArch64Relocation (this=0x565c73a0, Section=..., Offset=0, Value=18446744073468444676, 
    Type=282, Addend=0)
    at /var/tmp/portage/sys-devel/llvm-19.0.0.9999/work/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp:497
497         assert(isInt<28>(BranchImm));
(gdb) p BranchImm
$1 = <optimized out>
(gdb) l
492         // Operation: S+A-P. Set Call or B immediate value to bits fff_fffc of the
493         // calculation.
494         uint64_t BranchImm = Value + Addend - FinalAddress;
495
496         // "Check that -2^27 <= result < 2^27".
497         assert(isInt<28>(BranchImm));
498         or32le(TargetPtr, (BranchImm & 0x0FFFFFFC) >> 2);
499         break;
500       }
501       case ELF::R_AARCH64_MOVW_UABS_G3:
(gdb) p Value
$2 = 18446744073468444676
(gdb) p Addend
$3 = 0
(gdb) p FinalAddress
$4 = 4053860352
(gdb) up
#7  0xf478ab1d in llvm::RuntimeDyldELF::resolveRelocation (this=0x565c73a0, Section=..., Offset=0, Value=18446744073468444676, 
    Type=282, Addend=0, SymOffset=0, SectionID=0)
    at /var/tmp/portage/sys-devel/llvm-19.0.0.9999/work/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp:1056
1056        resolveAArch64Relocation(Section, Offset, Value, Type, Addend);
(gdb) p Section
$5 = (const llvm::SectionEntry &) @0x565c88a4: {Name = ".text.main", Address = 0xf1a10000 "", Size = 4, LoadAddress = 4053860352, 
  StubOffset = 4, AllocationSize = 24, ObjAddress = 1448898324}
(gdb) p Offset
$6 = 0
(gdb) p Value
$7 = 18446744073468444676
(gdb) p Type
$8 = 282
(gdb) p Addend
$9 = 0

```

https://github.com/llvm/llvm-project/pull/92245


More information about the llvm-commits mailing list