[llvm-bugs] [Bug 43789] New: Cannot disable stack protector for particular functions for LTO build with "-Os"

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Oct 24 09:02:30 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=43789

            Bug ID: 43789
           Summary: Cannot disable stack protector for particular
                    functions for LTO build with "-Os"
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: gsorron at gmail.com
                CC: llvm-bugs at lists.llvm.org, peter.smith at linaro.org

Created attachment 22718
  --> https://bugs.llvm.org/attachment.cgi?id=22718&action=edit
Build example

When building code with LTO and -Os sometimes callee function code gets
inserted into caller. Problem arose when disabling stack protector for such
caller function: linker inserts protector to caller body even if caller
compiled with -fno-stack-protector or attribute.

Please see attached example.
To build example: tar -xvf stack_protector_issue.tar ; cd stack_protector_issue
; make
Check main() in dump.txt after build.

I've got following result:

0000000000201164 <main>:
  201164:       50                      push   %rax
  201165:       64 48 8b 04 25 28 00    mov    %fs:0x28,%rax
  20116c:       00 00 
  20116e:       48 89 04 24             mov    %rax,(%rsp)
  201172:       48 8b 7e 08             mov    0x8(%rsi),%rdi
  201176:       e8 55 00 00 00          callq  2011d0 <atoi at plt>
  20117b:       64 48 8b 0c 25 28 00    mov    %fs:0x28,%rcx
  201182:       00 00 
  201184:       48 3b 0c 24             cmp    (%rsp),%rcx
  201188:       75 05                   jne    20118f <main+0x2b>
  20118a:       0f af c0                imul   %eax,%eax
  20118d:       59                      pop    %rcx
  20118e:       c3                      retq   
  20118f:       e8 4c 00 00 00          callq  2011e0 <__stack_chk_fail at plt>

Expected result: main() should not contain stack protector
setting/verification. Maybe callee function shouldn't be inlined in this case.

clang -v:
clang version 8.0.0 (tags/RELEASE_800/final)
Target: x86_64-unknown-linux-gnu

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191024/9628f53c/attachment-0001.html>


More information about the llvm-bugs mailing list