[llvm] r235222 - Compute A-B if both A and B are in the same comdat section.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Mon Apr 20 05:10:49 PDT 2015


What is the triple? What is the error? What is the corresponding gas output?


On 20 April 2015 at 07:16, Vasileios Kalintiris
<Vasileios.Kalintiris at imgtec.com> wrote:
> Hi Rafael,
>
> This change broke our out-of-tree MIPS buildbots that use the integrated assembler. I've attached a minimal example that reproduces the error we are getting. I'll try to investigate the problem but if you could take a look as well it would be helpful.
>
> Thanks,
> Vasileios
>
> ________________________________________
> From: llvm-commits-bounces at cs.uiuc.edu [llvm-commits-bounces at cs.uiuc.edu] on behalf of Rafael Espindola [rafael.espindola at gmail.com]
> Sent: 17 April 2015 21:05
> To: llvm-commits at cs.uiuc.edu
> Subject: [llvm] r235222 - Compute A-B if both A and B are in the same comdat    section.
>
> Author: rafael
> Date: Fri Apr 17 15:05:17 2015
> New Revision: 235222
>
> URL: http://llvm.org/viewvc/llvm-project?rev=235222&view=rev
> Log:
> Compute A-B if both A and B are in the same comdat section.
>
> Part of pr23272.
>
> A small annoyance with the assembly syntax we implement is that given an
> expression there is no way to know if what is desired is the value of that
> expression for the symbols in this file or for the final values of those
> symbols in a link.
>
> The first case is useful for use in sections that get discarded or ignored
> if the section they are describing is discarded.
>
> For axample, consider A-B where A and B are in the same comdat section.
>
> We can compute the value of the difference in the section that is present in
> the current .o and if that section survives to the final DSO the value will
> still will be correct.
>
> But the section is in a comdat. Another section from another object file
> might be used istead. We know that that section will define A and B, but
> we have no idea what the value of A-B might be.
>
> In practice we have to assume that the intention is to compute the value
> in the current section since otherwise the is no way to create something like
> the debug aranges section.
>
> Modified:
>     llvm/trunk/lib/MC/ELFObjectWriter.cpp
>     llvm/trunk/test/MC/ELF/relocation.s
>
> Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=235222&r1=235221&r2=235222&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
> +++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Fri Apr 17 15:05:17 2015
> @@ -765,6 +765,9 @@ static const MCSymbol *getWeakRef(const
>    return nullptr;
>  }
>
> +// True if the assembler knows nothing about the final value of the symbol.
> +// This doesn't cover the comdat issues, since in those cases the assembler
> +// can at least know that all symbols in the section will move together.
>  static bool isWeak(const MCSymbolData &D) {
>    if (MCELF::GetType(D) == ELF::STT_GNU_IFUNC)
>      return true;
> @@ -775,27 +778,11 @@ static bool isWeak(const MCSymbolData &D
>    case ELF::STB_LOCAL:
>      return false;
>    case ELF::STB_GLOBAL:
> -    break;
> +    return false;
>    case ELF::STB_WEAK:
>    case ELF::STB_GNU_UNIQUE:
>      return true;
>    }
> -
> -  const MCSymbol &Sym = D.getSymbol();
> -  if (!Sym.isInSection())
> -    return false;
> -
> -  const auto &Sec = cast<MCSectionELF>(Sym.getSection());
> -  if (!Sec.getGroup())
> -    return false;
> -
> -  // It is invalid to replace a reference to a global in a comdat
> -  // with a reference to a local since out of comdat references
> -  // to a local are forbidden.
> -  // We could try to return false for more cases, like the reference
> -  // being in the same comdat or Sym being an alias to another global,
> -  // but it is not clear if it is worth the effort.
> -  return true;
>  }
>
>  void ELFObjectWriter::RecordRelocation(MCAssembler &Asm,
> @@ -1692,7 +1679,25 @@ bool ELFObjectWriter::IsSymbolRefDiffere
>  }
>
>  bool ELFObjectWriter::isWeak(const MCSymbolData &SD) const {
> -  return ::isWeak(SD);
> +  if (::isWeak(SD))
> +    return true;
> +
> +  const MCSymbol &Sym = SD.getSymbol();
> +  if (!Sym.isInSection())
> +    return false;
> +
> +  const auto &Sec = cast<MCSectionELF>(Sym.getSection());
> +  if (!Sec.getGroup())
> +    return false;
> +
> +  // It is invalid to replace a reference to a global in a comdat
> +  // with a reference to a local since out of comdat references
> +  // to a local are forbidden.
> +  // We could try to return false for more cases, like the reference
> +  // being in the same comdat or Sym being an alias to another global,
> +  // but it is not clear if it is worth the effort.
> +  return true;
> +
>  }
>
>  MCObjectWriter *llvm::createELFObjectWriter(MCELFObjectTargetWriter *MOTW,
>
> Modified: llvm/trunk/test/MC/ELF/relocation.s
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/relocation.s?rev=235222&r1=235221&r2=235222&view=diff
> ==============================================================================
> --- llvm/trunk/test/MC/ELF/relocation.s (original)
> +++ llvm/trunk/test/MC/ELF/relocation.s Fri Apr 17 15:05:17 2015
> @@ -2,6 +2,13 @@
>
>  // Test that we produce the correct relocation.
>
> +
> +        .section       .pr23272,"aGw", at progbits,pr23272,comdat
> +       .globl pr23272
> +pr23272:
> +pr23272_2:
> +
> +        .text
>  bar:
>          movl   $bar, %edx        # R_X86_64_32
>          movq   $bar, %rdx        # R_X86_64_32S
> @@ -43,6 +50,8 @@ bar:
>
>          .long   foo at gotpcrel
>          .long foo at plt
> +
> +        .quad  pr23272_2 - pr23272
>  // CHECK:        Section {
>  // CHECK:          Name: .rela.text
>  // CHECK:          Relocations [
> @@ -89,5 +98,5 @@ bar:
>  // CHECK-NEXT:     Binding: Local
>  // CHECK-NEXT:     Type: Section
>  // CHECK-NEXT:     Other: 0
> -// CHECK-NEXT:     Section: .text (0x1)
> +// CHECK-NEXT:     Section: .text
>  // CHECK-NEXT:   }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list