Skip to content
  • Josh Poimboeuf's avatar
    objtool: Handle GCC stack pointer adjustment bug · dd88a0a0
    Josh Poimboeuf authored
    Arnd Bergmann reported the following warning with GCC 7.1.1:
    
      fs/fs_pin.o: warning: objtool: pin_kill()+0x139: stack state mismatch: cfa1=7+88 cfa2=7+96
    
    And the kbuild robot reported the following warnings with GCC 5.4.1:
    
      fs/fs_pin.o: warning: objtool: pin_kill()+0x182: return with modified stack frame
      fs/quota/dquot.o: warning: objtool: dquot_alloc_inode()+0x140: stack state mismatch: cfa1=7+120 cfa2=7+128
      fs/quota/dquot.o: warning: objtool: dquot_free_inode()+0x11a: stack state mismatch: cfa1=7+112 cfa2=7+120
    
    Those warnings are caused by an unusual GCC non-optimization where it
    uses an intermediate register to adjust the stack pointer.  It does:
    
      lea    0x8(%rsp), %rcx
      ...
      mov    %rcx, %rsp
    
    Instead of the obvious:
    
      add    $0x8, %rsp
    
    It makes no sense to use an intermediate register, so I opened a GCC bug
    to track it:
    
      https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81813
    
    But it's not exactly a high-priority bug and it looks like we'll...
    dd88a0a0