[PATCH] D13055: [ELF2] Handle -m option

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 1 10:27:21 PDT 2015


+static std::unique_ptr<InputFile> createTargetFile(MemoryBufferRef MB) {
+  std::unique_ptr<InputFile> File = createFile(MB);
+  ELFFileBase *ELFFile = dyn_cast<ELFFileBase>(File.get());
+  if (!ELFFile)
+    return File;
+
+  const ELFKind ElfKind = ELFFile->getELFKind();
+  const uint16_t EMachine = ELFFile->getEMachine();
+
+  // Grab target from the first input file if wasn't set by -m option.
+  if (Config->ElfKind == ELFNoneKind) {
+    Config->ElfKind = ElfKind;
+    Config->EMachine = EMachine;
+    return File;
+  }
+  if (ElfKind != Config->ElfKind || EMachine != Config->EMachine)
+    return nullptr;

Why don't you call error() here?

+  bool HasEmulation = false;
+  if (auto *Arg = Args.getLastArg(OPT_emulation)) {
+    applyEmulation(Arg->getValue());

I prefer setELFType or something over applyEmulation.

+def emulation : Separate<["-"], "m">,
+  HelpText<"Set target emulation">;

Stick with "def m" instead of "def emulation" how silly the option is named.


On Thu, Oct 1, 2015 at 10:20 AM, Rafael EspĂ­ndola <
rafael.espindola at gmail.com> wrote:

> This patch makes isCompatibleWith redundant and should remove it (See
> attached patch).
>
> I think this OK once rebased on top of trunk.
> Rui, is this OK with you too?
>
>
> On 1 October 2015 at 05:09, Denis Protivensky
> <dprotivensky at accesssoftek.com> wrote:
> > denis-protivensky updated this revision to Diff 36201.
> > denis-protivensky marked 2 inline comments as done.
> > denis-protivensky added a comment.
> >
> > Updated:
> >
> > - Remove FirstOjbName Config variable, use
> Symtab.getFirstELF()->getName() instead
> > - clang-format sources
> >
> >
> > http://reviews.llvm.org/D13055
> >
> > Files:
> >   ELF/Config.h
> >   ELF/Driver.cpp
> >   ELF/InputFiles.cpp
> >   ELF/InputFiles.h
> >   ELF/Options.td
> >   ELF/SymbolTable.cpp
> >   test/elf2/basic.s
> >   test/elf2/emulation.s
> >   test/elf2/incompatible.s
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151001/f186bb93/attachment.html>


More information about the llvm-commits mailing list