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

Denis Protivensky via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 06:19:03 PDT 2015


On 10/01/2015 08:27 PM, Rui Ueyama wrote:

+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?

I removed Config->FirstObjName in favor of Symtab.getFirstELF()->getName() as was requested.
I don't want to pass Symtab to this method as a parameter, so I return nullptr as an indicator and check it outside.

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

I prefer setELFType or something over applyEmulation.

Good.

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

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

Good.

On Thu, Oct 1, 2015 at 10:20 AM, Rafael EspĂ­ndola <rafael.espindola at gmail.com<mailto: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<mailto: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/20151002/60a1e99e/attachment.html>


More information about the llvm-commits mailing list