[LLVMbugs] [Bug 8762] New: Clang's integrated-as doesn't support --noexecstack

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Dec 8 18:45:15 PST 2010


http://llvm.org/bugs/show_bug.cgi?id=8762

           Summary: Clang's integrated-as doesn't support --noexecstack
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: chandlerc at gmail.com
                CC: rafael.espindola at gmail.com, llvmbugs at cs.uiuc.edu


Take a .s file that doesn't already have the section marking its stack as
noexec:

% cat t.s
        .file   "t.c"
        .text
.globl f
        .type   f, @function
f:
.LFB0:
        .cfi_startproc
        pushq   %rbp
        .cfi_def_cfa_offset 16
        movq    %rsp, %rbp
        .cfi_offset 6, -16
        .cfi_def_cfa_register 6
        leave
        .cfi_def_cfa 7, 8
        ret
        .cfi_endproc
.LFE0:
        .size   f, .-f

With GCC you can ask the GNU as to add the necessary bits during assembling:


% gcc -c t.s -Wa,--noexecstack -o t.o; readelf -S t.o
There are 10 section headers, starting at offset 0xd0:

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .text             PROGBITS         0000000000000000  00000040
       0000000000000006  0000000000000000  AX       0     0     4
  [ 2] .data             PROGBITS         0000000000000000  00000048
       0000000000000000  0000000000000000  WA       0     0     4
  [ 3] .bss              NOBITS           0000000000000000  00000048
       0000000000000000  0000000000000000  WA       0     0     4
  [ 4] .note.GNU-stack   PROGBITS         0000000000000000  00000048
       0000000000000000  0000000000000000           0     0     1
  [ 5] .eh_frame         PROGBITS         0000000000000000  00000048
       0000000000000038  0000000000000000   A       0     0     8
  [ 6] .rela.eh_frame    RELA             0000000000000000  00000418
       0000000000000018  0000000000000018           8     5     8
  [ 7] .shstrtab         STRTAB           0000000000000000  00000080
       000000000000004b  0000000000000000           0     0     1
  [ 8] .symtab           SYMTAB           0000000000000000  00000350
       00000000000000c0  0000000000000018           9     7     8
  [ 9] .strtab           STRTAB           0000000000000000  00000410
       0000000000000007  0000000000000000           0     0     1

Section 4 '.note.GNU-stack' is the interesting one. This is the same result you
would get if the assembly file had the following as its last line:
        .section        .note.GNU-stack,"", at progbits

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list