diff options
author | Maksim Panchenko <maks@fb.com> | 2024-02-06 14:38:21 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-06 14:38:21 -0800 |
commit | 8075f0db16f3291beed65cbcd034b047cc7373bf (patch) | |
tree | 2acd3ea2571f8ed8881427ac79aaade7baa34daf | |
parent | 16d890ced68aafae4cc8ba3efc9213bfab84ba54 (diff) | |
download | llvm-8075f0db16f3291beed65cbcd034b047cc7373bf.zip llvm-8075f0db16f3291beed65cbcd034b047cc7373bf.tar.gz llvm-8075f0db16f3291beed65cbcd034b047cc7373bf.tar.bz2 |
[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.
-rw-r--r-- | bolt/lib/Core/BinarySection.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/bolt/lib/Core/BinarySection.cpp b/bolt/lib/Core/BinarySection.cpp index a8fc4f0..97bc251 100644 --- a/bolt/lib/Core/BinarySection.cpp +++ b/bolt/lib/Core/BinarySection.cpp @@ -72,7 +72,8 @@ BinarySection::hash(const BinaryData &BD, void BinarySection::emitAsData(MCStreamer &Streamer, const Twine &SectionName) const { - StringRef SectionContents = getContents(); + StringRef SectionContents = + isFinalized() ? getOutputContents() : getContents(); MCSectionELF *ELFSection = BC.Ctx->getELFSection(SectionName, getELFType(), getELFFlags()); |