You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BOLT currently callsRTDyld->finalizeWithMemoryManagerLocking();, which is documented to do three things:
apply relocations;
register .eh_frames;
update memory permissions.
The second step will ultimately call __register_frame if its present (e.g. here).
In PIC builds the personality function is encoded with indirection (DW_EH_PE_indirect) via a DW.ref.__gxx_personality_v0 symbol located in the .data section, which is not mapped to the RuntimeDyld.
compiled with clang++ main.cc -o main -fpic -Wl,-q and processed with BOLT using llvm-bolt main -o main.bolted -keep-tmp one can see that the intermediary output object file doesn't contain the .data section.
Unfortunately this means that __register_frame can read unmapped data, e.g. LLVM's libunwind will do so when trying to read the address of the personality routine and trying to handle the DW_EH_PE_indirect case there.
I think that llvm-bolt doesn't need .eh_frames to be registered in process and probably doesn't need to update memory permissions either (as it won't execute anything from the intermediary output object file in process), so probably the call to RTDyld->finalizeWithMemoryManagerLocking() should be changed to a call to RTDyld->resolveRelocations() - but I might be wrong and this may need a more careful approach, so filing this as a bug instead of just sending a patch for review.
The text was updated successfully, but these errors were encountered:
BOLT currently calls
RTDyld->finalizeWithMemoryManagerLocking();
, which is documented to do three things:.eh_frame
s;The second step will ultimately call
__register_frame
if its present (e.g. here).In PIC builds the personality function is encoded with indirection (
DW_EH_PE_indirect
) via aDW.ref.__gxx_personality_v0
symbol located in the.data
section, which is not mapped to theRuntimeDyld
.For example, for the following
main.cc
:compiled with
clang++ main.cc -o main -fpic -Wl,-q
and processed with BOLT usingllvm-bolt main -o main.bolted -keep-tmp
one can see that the intermediary output object file doesn't contain the.data
section.Unfortunately this means that
__register_frame
can read unmapped data, e.g. LLVM's libunwind will do so when trying to read the address of the personality routine and trying to handle theDW_EH_PE_indirect
case there.I think that
llvm-bolt
doesn't need.eh_frame
s to be registered in process and probably doesn't need to update memory permissions either (as it won't execute anything from the intermediary output object file in process), so probably the call toRTDyld->finalizeWithMemoryManagerLocking()
should be changed to a call toRTDyld->resolveRelocations()
- but I might be wrong and this may need a more careful approach, so filing this as a bug instead of just sending a patch for review.The text was updated successfully, but these errors were encountered: