[PATCH] D28898: [ELF] - Allow emulation to be different from input objects target.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 20 09:21:53 PST 2017

grimar added a comment.

In https://reviews.llvm.org/D28898#651627, @ruiu wrote:

> In https://reviews.llvm.org/D28898#651623, @grimar wrote:
> > In https://reviews.llvm.org/D28898#651577, @ruiu wrote:
> >
> > > I don't think this patch works if all object files are in static archives.
> >
> >
> > Original code also does not work when all files in static archives, no ? It requires -m or at least one .o file.
> I think you actually changed the behavior. Now it needs at least one .o even if -m is given.

No, it does not need. I added a testcase for demonstration.

Comment at: ELF/Driver.cpp:700-701
 void LinkerDriver::inferMachineType() {
-  if (Config->EKind != ELFNoneKind)
-    return;
ruiu wrote:
> I think you could just remove this piece of code from inferMachineTypes to do the same thing, no?
Since current logic is "assign parameters from -m and right after that override them with  values from objects", I think it is better to localize this logic in a single place.

Its even may be worth some refactoring. I believe it is possible to get rid of that overriding. What we could to is check that -m is one of supported early. Then logic could be in different, correct order: first try to set machine type from files and then, if not successed - set it from -m. I had to use overriding only because we still want (I think) to check -m values even if it is ignored.


More information about the llvm-commits mailing list