[U-Boot] [PATCH 1/5] efi_loader: Generate Microsoft PE format complaint images

Heinrich Schuchardt xypron.glpk at gmx.de
Wed Sep 26 18:40:38 UTC 2018


On 09/26/2018 08:03 AM, Bin Meng wrote:
> Per Microsoft PE Format documentation [1], PointerToSymbolTable and
> NumberOfSymbols should be zero for an image in the COFF file header.
> Currently U-Boot is generating *.efi images (eg: helloworld.efi) in
> which these two members are not zero.
> 
> This updates the build rules to tell linker to remove the symbol
> table completely so that we can generate compliant *.efi images.
> 
> [1] https://docs.microsoft.com/zh-cn/windows/desktop/Debug/pe-format
> 
> Reported-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
> ---


With the -s switch
- PointerToSymbolTable is 0,
- NumberOfSymbols is 0.

$ objdump -T  lib/efi_loader/helloworld.efi

lib/efi_loader/helloworld.efi:     file format pei-i386

objdump: lib/efi_loader/helloworld.efi: not a dynamic object
DYNAMIC SYMBOL TABLE:
no symbols

So the binaries are now conforming the PE standard.

qemu-x86_defconfig lib/efi_loader/helloworld.efi still contains these
sections:

Section[3] .dynamic
Section[5] .dynsym

Is this what you expect when you have 0 symbols? Should these sections
be removed with strip -R? But anyway these empty tables do no harm.

Reviewed-by: Heinrich Schuchardt <xypron.glpk at gmx.de>

> 
>  scripts/Makefile.lib | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index f8c3fff..91f0b20 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -381,7 +381,7 @@ $(obj)/%.efi: $(obj)/%_efi.so
>  
>  quiet_cmd_efi_ld = LD      $@
>  cmd_efi_ld = $(LD) -nostdlib -znocombreloc -T $(EFI_LDS_PATH) -shared \
> -		-Bsymbolic $^ -o $@
> +		-Bsymbolic -s $^ -o $@
>  
>  EFI_LDS_PATH = $(srctree)/arch/$(ARCH)/lib/$(EFI_LDS)
>  
>               




More information about the U-Boot mailing list