[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] x86/efi: fix build with linkers that support both coff-x86-64 and pe-x86-64



On Mon, Jan 08, 2018 at 03:11:21AM -0700, Jan Beulich wrote:
> >>> On 05.01.18 at 17:43, <roger.pau@xxxxxxxxxx> wrote:
> > When using a linker that supports both formats the following error
> > will be triggered:
> > 
> > efi/buildid.o: file not recognized: File format is ambiguous
> > efi/buildid.o: matching formats: coff-x86-64 pe-x86-64
> > 
> > Solve this by specifying the buildid.o format to pe-x86-64.
> 
> Nice idea. I don't suppose this works with a linker only
> supporting coff-x86-64 though, but I assume such a linker
> wouldn't be usable for building xen.efi anyway.

I guess you could have in theory a linker that supports i386pep and
coff-x86-64 and doesn't support pe-x86-64 and try to build a Xen efi
binary with it. I'm not sure whether that would work or not, because
AFAICT no distro ships such a linker.

IMHO making sure it works fine as long as the linker has support for
pe-x86-64 is the best option, regardless of whether coff support is
enabled or not.

> > --- a/xen/arch/x86/Makefile
> > +++ b/xen/arch/x86/Makefile
> > @@ -188,20 +188,20 @@ endif
> >  $(TARGET).efi: prelink-efi.o $(note_file) efi.lds efi/relocs-dummy.o 
> > $(BASEDIR)/common/symbols-dummy.o efi/mkreloc
> >     $(foreach base, $(VIRT_BASE) $(ALT_BASE), \
> >               $(guard) $(LD) $(call EFI_LDFLAGS,$(base)) -T efi.lds -N $< 
> > efi/relocs-dummy.o \
> > -                   $(BASEDIR)/common/symbols-dummy.o $(note_file) -o 
> > $(@D)/.$(@F).$(base).0 &&) :
> > +                   $(BASEDIR)/common/symbols-dummy.o -b pe-x86-64 
> > $(note_file) -o $(@D)/.$(@F).$(base).0 &&) :
> 
> I wonder whether introducing e.g
> 
> note_file_options := -b pe-x86-64 $(note_file)
> 
> wouldn't be better than repeating the same thing three times.
> Of course it would need to be clearly spelled out that this
> needs to come last (or another -b would need to follow). This
> would additionally deal with the case where note.o instead of
> efi/buildid.o is being linked in (you don't want -b pe-x86-64
> with that one, I suppose), or when build ID support isn't
> available at all (the new option would then be stray and might
> be warned about).

What about doing something like:

ifneq ($(build_id_linker),)
ifeq ($(call ld-ver-build-id,$(LD) $(filter -m%,$(EFI_LDFLAGS))),y)
CFLAGS += -DBUILD_ID_EFI
EFI_LDFLAGS += $(build_id_linker)
# Note that this must be the last input in the ld call, because
# inputs following the -b option will all be treated as being in the
# specified format.
note_file := -b pe-x86-64 efi/buildid.o
else
note_file := note.o
endif
else
note_file :=
endif

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.