[LLVMdev] How to set constant pool section?

Joerg Sonnenberger joerg at britannica.bec.de
Thu Mar 15 00:40:01 PDT 2012


On Thu, Mar 15, 2012 at 11:00:54AM +0400, Konstantin Vladimirov wrote:
> 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?

I think you are off the mark here. The fragment above is used to create

	.text

instead of

	.section ".text"

or other more ugly forms. This is really just an optimisation for
readiblity and compatibility with ancient tools.

Joerg



More information about the llvm-dev mailing list