Skip to content

Commit 8075f0d

Browse files
authored
[BOLT] Use new contents when emitting sections with relocations (#80782)
We can use BinarySection::updateContents() to change section contents. However, if we also add relocations for new contents, then the original data (i.e. not updated) is going to be used. Fix that. A follow-up diff will use the update interface and will include a test case.
1 parent 16d890c commit 8075f0d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

bolt/lib/Core/BinarySection.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ BinarySection::hash(const BinaryData &BD,
7272

7373
void BinarySection::emitAsData(MCStreamer &Streamer,
7474
const Twine &SectionName) const {
75-
StringRef SectionContents = getContents();
75+
StringRef SectionContents =
76+
isFinalized() ? getOutputContents() : getContents();
7677
MCSectionELF *ELFSection =
7778
BC.Ctx->getELFSection(SectionName, getELFType(), getELFFlags());
7879

0 commit comments

Comments
 (0)