• Arvind Sankar's avatar
    x86/boot: Mark global variables as static · e78d334a
    Arvind Sankar authored
    Mike Lothian reports that after commit
      964124a9 ("efi/x86: Remove extra headroom for setup block")
    gcc 10.1.0 fails with
    
      HOSTCC  arch/x86/boot/tools/build
      /usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../x86_64-pc-linux-gnu/bin/ld:
      error: linker defined: multiple definition of '_end'
      /usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../x86_64-pc-linux-gnu/bin/ld:
      /tmp/ccEkW0jM.o: previous definition here
      collect2: error: ld returned 1 exit status
      make[1]: *** [scripts/Makefile.host:103: arch/x86/boot/tools/build] Error 1
      make: *** [arch/x86/Makefile:303: bzImage] Error 2
    
    The issue is with the _end variable that was added, to hold the end of
    the compressed kernel from zoffsets.h (ZO__end). The name clashes with
    the linker-defined _end symbol that indicates the end of the build
    program itself.
    
    Even when there is no compile-time error, this causes build to use
    memory past the end of its .bss section.
    
    To solve this, mark _end as static, and for symmetry, mark the rest of
    the variables that keep track of symbols from the compressed kernel as
    static as well.
    
    Fixes: 964124a9 ("efi/x86: Remove extra headroom for setup block")
    Reported-by: default avatarMike Lothian <mike@fireburn.co.uk>
    Tested-by: default avatarMike Lothian <mike@fireburn.co.uk>
    Signed-off-by: default avatarArvind Sankar <nivedita@alum.mit.edu>
    Link: https://lore.kernel.org/r/20200511225849.1311869-1-nivedita@alum.mit.eduSigned-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
    e78d334a
build.c 14.6 KB