[BOLT] Fix use-after-free in RewriteInstance::mapCodeSections
authorJob Noorman <jnoorman@igalia.com>
Mon, 17 Apr 2023 12:55:11 +0000 (14:55 +0200)
committerJob Noorman <jnoorman@igalia.com>
Mon, 17 Apr 2023 14:16:49 +0000 (16:16 +0200)
commit48ad4296f7847db15b6bee7a465fc2cbe687ba6a
tree0de04412f495cf8ab92bc606d7518c427b5ed8e6
parent56f7052d9226838b745970c4156be30ee209ee03
[BOLT] Fix use-after-free in RewriteInstance::mapCodeSections

When a cold function is too large, its section gets deregistered.
However, the section is still dereferenced later to get its RuntimeDyld
ID. This patch moves the deregistration to after the last dereference.

Reviewed By: Amir

Differential Revision: https://reviews.llvm.org/D148427
bolt/lib/Rewrite/RewriteInstance.cpp