@@ -1947,8 +1947,13 @@ Error MCDataFragmentMerger::tryMerge(const MCFragment &F, unsigned Size,
1947
1947
}
1948
1948
1949
1949
static Error writeAlignFragment (MCCASBuilder &Builder, const MCFragment &AF,
1950
- raw_ostream &OS, unsigned FragmentSize) {
1951
- OS << StringRef (AF.getContents ().data (), AF.getContents ().size ());
1950
+ raw_ostream &OS, unsigned FragmentSize,
1951
+ bool WriteFragmentContents = true ) {
1952
+ // Do not always write the contents of the FT_Align fragment into the OS, this
1953
+ // is because that data can contain addend values as well and is undesirable
1954
+ // when creating AlignFragment CAS Objects.
1955
+ if (WriteFragmentContents)
1956
+ OS << StringRef (AF.getContents ().data (), AF.getContents ().size ());
1952
1957
uint64_t Count = (FragmentSize - AF.getFixedSize ()) / AF.getAlignFillLen ();
1953
1958
if (AF.hasAlignEmitNops ()) {
1954
1959
if (!Builder.Asm .getBackend ().writeNopData (OS, Count,
@@ -2006,8 +2011,14 @@ Error MCDataFragmentMerger::emitMergedFragments() {
2006
2011
#define MCFRAGMENT_ENCODED_FRAGMENT_ONLY
2007
2012
#include " llvm/MCCAS/MCCASObjectV1.def"
2008
2013
case MCFragment::FT_Align: {
2014
+ // Since an FT_Align can contain Addend Values, only write the
2015
+ // post-fragment partitioned contents into the FragmentData and make sure
2016
+ // that the writeAlignFragment function doesn't write any of the fragment
2017
+ // data into FragmentData.
2018
+ FragmentData.append (CandidateContents);
2009
2019
if (auto E = writeAlignFragment (Builder, *Candidate.first , FragmentOS,
2010
- Candidate.second ))
2020
+ Candidate.second ,
2021
+ false /* WriteFragmentContents*/ ))
2011
2022
return E;
2012
2023
break ;
2013
2024
}
0 commit comments