[PATCH] D30080: MC/COFF: Do not emit forward associative section referenceds.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 17 10:11:33 PST 2017
On Fri, Feb 17, 2017 at 10:06 AM, Rafael Avila de Espindola <
rafael.espindola at gmail.com> wrote:
> > +// Write the section header.
> > +void WinCOFFObjectWriter::writeSectionHeaders() {
> > + // Section numbers must be monotonically increasing in the section
> > + // header, but our Sections array is not sorted by section number,
> > + // so make a copy of Sections and sort it.
> > + std::vector<COFFSection *> Arr;
> > + for (auto &Section : Sections)
> > + Arr.push_back(Section.get());
>
> Can you say just std::vector<COFFSection *> Arr = Sections; ?
>
Sections is a std::vector<std::unique_ptr<COFFSection>>, so you can't.
> void WinCOFFObjectWriter::assignSectionNumbers() {
> > size_t I = 1;
> > - for (const auto &Section : Sections) {
> > - Section->Number = I;
> > - Section->Symbol->Data.SectionNumber = I;
> > - Section->Symbol->Aux[0].Aux.SectionDefinition.Number = I;
> > + auto Assign = [&](COFFSection &Section) {
> > + Section.Number = I;
> > + Section.Symbol->Data.SectionNumber = I;
> > + Section.Symbol->Aux[0].Aux.SectionDefinition.Number = I;
> > ++I;
> > - }
> > + };
> > +
> > + // Although it is not explicitly requested by the Microsoft COFF spec,
> > + // we should avoid emitting forward associative section references,
> > + // because MSVC link.exe as of 2017 cannot handle that.
> > + for (const std::unique_ptr<COFFSection> &Section : Sections)
> > + if (!isAssociative(*Section))
> > + Assign(*Section);
> > + for (const std::unique_ptr<COFFSection> &Section : Sections)
> > + if (isAssociative(*Section))
> > + Assign(*Section);
> > }
>
> An associative section cannot refer to another?
>
They can't.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170217/ed246141/attachment.html>
More information about the llvm-commits
mailing list