Hi, In the document: http://llvm.org/docs/WritingAnLLVMBackend.html described example like: SparcTargetAsmInfo::SparcTargetAsmInfo(const SparcTargetMachine &TM) { Data16bitsDirective = "\t.half\t"; Data32bitsDirective = "\t.word\t"; Data64bitsDirective = 0; // .xword is only supported by V9. ZeroDirective = "\t.skip\t"; CommentString = "!"; ConstantPoolSection = "\t.section \".rodata\",#alloc\n"; } That is wrong for LLVM 3.0 In latest LLVM versions, Sparc have MC subtarget and: SparcELFMCAsmInfo::SparcELFMCAsmInfo(const Target &T, StringRef TT) { IsLittleEndian = false; Triple TheTriple(TT); if (TheTriple.getArch() == Triple::sparcv9) PointerSize = 8; Data16bitsDirective = "\t.half\t"; Data32bitsDirective = "\t.word\t"; Data64bitsDirective = 0; // .xword is only supported by V9. ZeroDirective = "\t.skip\t"; CommentString = "!"; HasLEB128 = true; SupportsDebugInformation = true; SunStyleELFSectionSwitchSyntax = true; UsesELFSectionDirectiveForBSS = true; WeakRefDirective = "\t.weak\t"; PrivateGlobalPrefix = ".L"; } But I can not find in Sparc, or any other backend code to set ConstantPoolSection. I tried in my backend deriving MCAsmInfo, but it seems, that ConstantPoolSection is not member of MCAsmInfo. I really need in my backend value for this section, distinct from default. Where can I set it? Thanks in advance for all suggestions. --- With best regards, Konstantin
Hello> I really need in my backend value for this section, distinct from > default. Where can I set it?It was renamed to ReadOnlySection. You might want to check the logic inside CodeGen/TargetLoweringObjectFileImp.cpp (in particular - TargetLoweringObjectFile::SelectionSectionForGlobal) to see how it's used. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University
Hi, Thanks for pointing direction. As far, as I understand by reversing, logic, that I want to overwrite is digged into: lib/MC/MCSectionELF.cpp MCSectionELF::PrintSwitchToSection if (ShouldOmitSectionDirective(SectionName, MAI)) { OS << '\t' << getSectionName() << '\n'; return; } // otherwise print ".section" directive and then section name So I need to overwrite ShouldOmitSectionDirective behavior. But this method of MCSectionELF is not virtual. As a workaround, I stubbed it in core LLVM code (MCSectionELF::ShouldOmitSectionDirective), and everything works, but it is ugly. May be you can advise further? --- With best regards, Konstantin On Wed, Mar 14, 2012 at 9:29 PM, Anton Korobeynikov <anton at korobeynikov.info> wrote:> Hello > >> I really need in my backend value for this section, distinct from >> default. Where can I set it? > It was renamed to ReadOnlySection. You might want to check the logic > inside CodeGen/TargetLoweringObjectFileImp.cpp (in particular - > TargetLoweringObjectFile::SelectionSectionForGlobal) to see how it's > used. > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State University