[ping] RE: [PATCH] review for MC ELF header e_flags setting
Robinson, Paul
Paul.Robinson at am.sony.com
Wed Jan 30 12:04:53 PST 2013
Sorry for coming late to the party; I've only recently realized that
something I'm doing requires me to set an e_flags bit and that this
stuff might be helpful.
One comment on the changes:
> void MipsAsmPrinter::EmitEndOfAsmFile(Module &M) {
>
> + if (OutStreamer.hasRawTextSupport()) return;
> +
> // Emit Mips ELF register info
> Subtarget->getMReginfo().emitMipsReginfoSectionCG(
> OutStreamer, getObjFileLowering(), *Subtarget);
> + MipsELFStreamer & MES = static_cast<MipsELFStreamer &>(OutStreamer);
> + MES.emitELFHeaderFlagsCG(*Subtarget);
> }
Okay, for writing a .s file you skip the flags stuff, and for writing
a .o file you set the flags in the assembler object. Then the ELF
streamer just uses the flags it was told to use.
I didn't see a change to MipsAsmParser.cpp that would set the flags
in the standalone assembler? It looked like you did have a change of
that nature for ARMAsmParser.
Granted it's a little late to suggest other approaches, but wouldn't
it be more natural to deal with this in the target-specific assembler
backend? Now that you have ELFObjectWriter::WriteHeader getting a
handle on MCAssembler, it can easily call a new hook in the
(target-specific) assembler backend to return the (target-specific)
e_flags word.
If there's info you need that the assembler backend doesn't have
(which may be why you don't have a MipsAsmParser change?) that makes
things trickier of course; maybe you'd need to invent new assembler
directives to pass that from AsmPrinter to the backend. This could
require more tweaks, like making MCELFStreamer::EmitAssemblerFlag call
the assembler backend, the way MCMachOStreamer already does, but then
the assembler backend can remember the flags.
Apologies if you've already worked through that idea and abandoned it;
like I said, I didn't realize this could be useful to me until lately.
Thanks,
--paulr
More information about the llvm-commits
mailing list