[llvm] [BOLT] Overwrite .eh_frame and .gcc_except_table (PR #116755)
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 19 07:52:34 PST 2024
================
@@ -3887,6 +3887,43 @@ void RewriteInstance::mapCodeSections(BOLTLinker::SectionMapper MapSection) {
void RewriteInstance::mapAllocatableSections(
BOLTLinker::SectionMapper MapSection) {
+
+ if (opts::UseOldText || opts::StrictMode) {
+ auto tryRewriteSection = [&](BinarySection &OldSection,
+ BinarySection &NewSection) {
+ if (OldSection.getSize() < NewSection.getOutputSize())
+ return;
+
+ BC->outs() << "BOLT-INFO: rewriting " << OldSection.getName()
+ << " in-place\n";
+
+ NewSection.setOutputAddress(OldSection.getAddress());
+ NewSection.setOutputFileOffset(OldSection.getInputFileOffset());
+ MapSection(NewSection, OldSection.getAddress());
+
+ // Pad contents with zeros.
+ NewSection.addPadding(OldSection.getSize() - NewSection.getOutputSize());
----------------
dcci wrote:
I guess the padding is required to make sure the size match? We can add that in a comment
https://github.com/llvm/llvm-project/pull/116755
More information about the llvm-commits
mailing list