• Josh Poimboeuf's avatar
    x86/mm: Fix RESERVE_BRK() for older binutils · e32683c6
    Josh Poimboeuf authored
    With binutils 2.26, RESERVE_BRK() causes a build failure:
    
      /tmp/ccnGOKZ5.s: Assembler messages:
      /tmp/ccnGOKZ5.s:98: Error: missing ')'
      /tmp/ccnGOKZ5.s:98: Error: missing ')'
      /tmp/ccnGOKZ5.s:98: Error: missing ')'
      /tmp/ccnGOKZ5.s:98: Error: junk at end of line, first unrecognized
      character is `U'
    
    The problem is this line:
    
      RESERVE_BRK(early_pgt_alloc, INIT_PGT_BUF_SIZE)
    
    Specifically, the INIT_PGT_BUF_SIZE macro which (via PAGE_SIZE's use
    _AC()) has a "1UL", which makes older versions of the assembler unhappy.
    Unfortunately the _AC() macro doesn't work for inline asm.
    
    Inline asm was only needed here to convince the toolchain to add the
    STT_NOBITS flag.  However, if a C variable is placed in a section whose
    name is prefixed with ".bss", GCC and Clang automatically set
    STT_NOBITS.  In fact, ".bss..page_aligned" already relies on this trick.
    
    So fix the build failure (and simplify the macro) by allocating the
    variable in C.
    
    Also, add NOLOAD to the ".brk" output section clause in the linker
    script.  This is a failsafe in case the ".bss" prefix magic trick ever
    stops working somehow.  If there's a section type mismatch, the GNU
    linker will force the ".brk" output section to be STT_NOBITS.  The LLVM
    linker will fail with a "section type mismatch" error.
    
    Note this also changes the name of the variable from .brk.##name to
    __brk_##name.  The variable names aren't actually used anywhere, so it's
    harmless.
    
    Fixes: a1e2c031 ("x86/mm: Simplify RESERVE_BRK()")
    Reported-by: default avatarJoe Damato <jdamato@fastly.com>
    Reported-by: default avatarByungchul Park <byungchul.park@lge.com>
    Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@kernel.org>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Tested-by: default avatarJoe Damato <jdamato@fastly.com>
    Link: https://lore.kernel.org/r/22d07a44c80d8e8e1e82b9a806ddc8c6bbb2606e.1654759036.git.jpoimboe@kernel.org
    e32683c6
vmlinux.lds.S 12.3 KB