This is a feature (or bug) of MCSectionELF::PrintSwitchToSection. For ELF target this function tries to escape string if it founds 'suspicious' character, see implementation in MCSectionELF.cpp: StringRef name = getSectionName(); if (name.find_first_not_of("0123456789_." "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ") == name.npos) { OS << "\t.section\t" << name; } else { OS << "\t.section\t\""; As section "name" is something like .mySection,\"aw\", at progbits# , this method puts all the string in quotes. Other targets (COFF and MachO) doesn't have such treatment. If looks like the code that transforms section names should be removed. Does anybody know what this transformation is for? 2013/4/19 Joerg Sonnenberger <joerg at britannica.bec.de>:> On Thu, Apr 18, 2013 at 06:57:29PM -0700, reed kotler wrote: >> I'm going to file this bug but it's kind of a blocker for me so >> maybe someone has time >> to look at it. Should be nearly trivial to fix. > > I don't think this is a bug, but a misfeature in GCC due to the way it > does (non-)escaping. > > Joerg > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-- Thanks, --Serge
On Fri, Apr 19, 2013 at 04:38:20PM +0700, Serge Pavlov wrote:> This is a feature (or bug) of MCSectionELF::PrintSwitchToSection. For > ELF target this function tries to escape string if it founds > 'suspicious' character, see implementation in MCSectionELF.cpp: > > StringRef name = getSectionName(); > if (name.find_first_not_of("0123456789_." > "abcdefghijklmnopqrstuvwxyz" > "ABCDEFGHIJKLMNOPQRSTUVWXYZ") == name.npos) { > OS << "\t.section\t" << name; > } else { > OS << "\t.section\t\""; > > As section "name" is something like .mySection,\"aw\", at progbits# , > this method puts all the string in quotes. > Other targets (COFF and MachO) doesn't have such treatment. > > If looks like the code that transforms section names should be > removed. Does anybody know what this transformation is for?It is exactly intended to handle section names as what they are -- section names. The only reason it works with GCC is because it writes an assembler stream. reed: correct use is to declare the section with inline asm first with the desired attributes, followed by .previous to reset the old section. Joerg
Yes, I see, the test MC/ELF/section-quoting.s checks that. Description of this attbitute in GCC manual also implies names only, not attributes. Thank you for clarification! 2013/4/19 Joerg Sonnenberger <joerg at britannica.bec.de>:> On Fri, Apr 19, 2013 at 04:38:20PM +0700, Serge Pavlov wrote: >> This is a feature (or bug) of MCSectionELF::PrintSwitchToSection. For >> ELF target this function tries to escape string if it founds >> 'suspicious' character, see implementation in MCSectionELF.cpp: >> >> StringRef name = getSectionName(); >> if (name.find_first_not_of("0123456789_." >> "abcdefghijklmnopqrstuvwxyz" >> "ABCDEFGHIJKLMNOPQRSTUVWXYZ") == name.npos) { >> OS << "\t.section\t" << name; >> } else { >> OS << "\t.section\t\""; >> >> As section "name" is something like .mySection,\"aw\", at progbits# , >> this method puts all the string in quotes. >> Other targets (COFF and MachO) doesn't have such treatment. >> >> If looks like the code that transforms section names should be >> removed. Does anybody know what this transformation is for? > > It is exactly intended to handle section names as what they are -- > section names. The only reason it works with GCC is because it writes an > assembler stream. > > reed: correct use is to declare the section with inline asm first with > the desired attributes, followed by .previous to reset the old section. > > Joerg > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-- Thanks, --Serge
> It is exactly intended to handle section names as what they are -- > section names. The only reason it works with GCC is because it writes an > assembler stream.+1 Reed, this fails in gcc if you do LTO, no?> JoergCheers, Rafael