[PATCH] D30129: Fix asm printing of associated sections

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 13 14:15:05 PDT 2017


Evgeniy Stepanov via Phabricator <reviews at reviews.llvm.org> writes:


> -  return createELFSectionImpl(I->getKey(), Type, Flags,
> -                              SectionKind::getReadOnly(), EntrySize, Group,
> -                              true, Associated);
> +  MCSectionELF *Section = createELFSectionImpl(
> +      I->getKey(), Type, Flags, SectionKind::getReadOnly(), EntrySize, Group,
> +      true, cast<MCSymbolELF>(RelInfoSection->getBeginSymbol()));
> +  return Section;

You don't need the variable.

> Index: lib/MC/ELFObjectWriter.cpp
> ===================================================================
> --- lib/MC/ELFObjectWriter.cpp
> +++ lib/MC/ELFObjectWriter.cpp
> @@ -1153,8 +1153,9 @@
>    case ELF::SHT_RELA: {
>      sh_link = SymbolTableIndex;
>      assert(sh_link && ".symtab not found");
> -    const MCSectionELF *InfoSection = Section.getAssociatedSection();
> -    sh_info = SectionIndexMap.lookup(InfoSection);
> +    const MCSection *InfoSection = Section.getAssociatedSection();
> +    assert(InfoSection);
> +    sh_info = SectionIndexMap.lookup(cast<MCSectionELF>(InfoSection));

You don't need the assert, the cast will fail if it is null.

>  
> -  if (Section.getFlags() & ELF::SHF_LINK_ORDER)
> -    sh_link = SectionIndexMap.lookup(Section.getAssociatedSection());
> +  if (Section.getFlags() & ELF::SHF_LINK_ORDER) {
> +    const MCSymbol *Sym = Section.getAssociatedSymbol();
> +    assert(Sym && Sym->isInSection());
> +    const MCSectionELF *Sec = cast<MCSectionELF>(&Sym->getSection());

You also don't need this assert.


LGTM

Cheers,
Rafael


More information about the llvm-commits mailing list