Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

Unknown relocation type #24

Closed
tmsri opened this issue Jul 2, 2018 · 7 comments
Closed

Unknown relocation type #24

tmsri opened this issue Jul 2, 2018 · 7 comments

Comments

@tmsri
Copy link

tmsri commented Jul 2, 2018

BOLT fails with the following stack trace:
Breakpoint 1, llvm::bolt::Relocation::isPCRelative (Type=24) at llvm/tools/llvm-bolt/src/Relocation.cpp:235
235 llvm_unreachable("Unknown relocation type");
gdb) bt
#0 llvm::bolt::Relocation::isPCRelative (Type=24) at llvm/tools/llvm-bolt/src/Relocation.cpp:235
#1 0x0000555555a72a65 in llvm::bolt::RewriteInstance::analyzeRelocation (this=0x7fffffffd620, Rel=..., RelocatedSection=..., SymbolName="", SymbolAddress=@0x7fffffffbfb8: 654552064,
Addend=@0x7fffffffbfb0: -4, ExtractedValue=@0x7fffffffbfa8: 304121793) at lvm/tools/llvm-bolt/src/RewriteInstance.cpp:1853
#2 0x0000555555a752c4 in llvm::bolt::RewriteInstance::readRelocations (this=0x7fffffffd620, Section=...)
at lvm/tools/llvm-bolt/src/RewriteInstance.cpp:2055
#3 0x0000555555a70535 in llvm::bolt::RewriteInstance::discoverFileObjects (this=0x7fffffffd620)
at llvm/tools/llvm-bolt/src/RewriteInstance.cpp:1471
#4 0x0000555555a6c866 in llvm::bolt::RewriteInstance::<lambda(const std::set<long unsigned int, std::less, std::allocator >&)>::operator()(const std::set<unsigned long, std::less, std::allocator > &) const (__closure=0x7fffffffd208, NonSimpleFunctions=std::set with 0 elements)
at llvm/tools/llvm-bolt/src/RewriteInstance.cpp:970
#5 0x0000555555a6cbe3 in llvm::bolt::RewriteInstance::run (this=0x7fffffffd620) at llvm/tools/llvm-bolt/src/RewriteInstance.cpp:1003
#6 0x00005555559170be in main (argc=4, argv=0x7fffffffde78) at llvm/tools/llvm-bolt/src/llvm-bolt.cpp:270

The relocation type 24 corresponds to ELF::R_X86_64_PC64.

@tmsri
Copy link
Author

tmsri commented Jul 2, 2018

This is a bug because I am unable to find a R_X86_64_PC64 in my binary. Still digging to give more information to debug this.

@tmsri
Copy link
Author

tmsri commented Jul 24, 2018

I ran into the same problem one more time but with perf2bolt.

@maksfb
Copy link
Contributor

maksfb commented Jul 24, 2018

Does readelf -r <binary> | grep R_X86_64_PC64 return anything?

@tmsri
Copy link
Author

tmsri commented Jul 24, 2018

Yes, I see a R_X86_64_PC64 relocation corresponding to openssl code. I am wondering how this got in. But then, shouldn't this relocation be handled?

@maksfb
Copy link
Contributor

maksfb commented Jul 24, 2018

Interesting, I wonder what they use it for. Sure, let me reproduce it, and then it should be trivial to add the support for it.

@tmsri
Copy link
Author

tmsri commented Jul 24, 2018

https://github.com/google/boringssl/blob/master/util/fipstools/delocate.go#L1402

This code will produce the relocation:

00000000046b5446 <OPENSSL_ia32cap_addr_delta>:
46b5446: 8a 68 04 06 00 00 00 00 .h......
46b5446: R_X86_64_PC64 OPENSSL_ia32cap_P

@maksfb
Copy link
Contributor

maksfb commented Jul 24, 2018

The main problem with openssl code is that it has data objects embedded in code.

@maksfb maksfb closed this as completed Oct 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants