* mark produced object files as "does not require executable stack" by

default for Linux (overridable using -WX switch) (mantis #11563)

git-svn-id: trunk@12356 -
This commit is contained in:
Jonas Maebe 2008-12-12 16:26:25 +00:00
parent 5c1d4b130b
commit 3216e8c7bc
24 changed files with 125 additions and 25 deletions

1
.gitattributes vendored
View File

@ -8595,6 +8595,7 @@ tests/webtbs/tw11435c.pp svneol=native#text/plain
tests/webtbs/tw11436.pp svneol=native#text/plain
tests/webtbs/tw1152.pp svneol=native#text/plain
tests/webtbs/tw11543.pp svneol=native#text/plain
tests/webtbs/tw11563.pp svneol=native#text/plain
tests/webtbs/tw11568.pp svneol=native#text/plain
tests/webtbs/tw1157.pp svneol=native#text/plain
tests/webtbs/tw1157b.pp svneol=native#text/plain

View File

@ -1138,6 +1138,13 @@ implementation
(target_info.system in systems_darwin) then
AsmWriteLn(#9'.subsections_via_symbols');
{ "no executable stack" marker for Linux }
if (target_info.system in system_linux) and
not(cs_executable_stack in current_settings.moduleswitches) then
begin
AsmWriteLn('.section .note.GNU-stack,"",%progbits');
end;
AsmLn;
{$ifdef EXTDEBUG}
if assigned(current_module.mainsource) then

View File

@ -128,7 +128,9 @@ interface
{ linking }
cs_create_smart,cs_create_dynamic,cs_create_pic,
{ browser switches are back }
cs_browser,cs_local_browser
cs_browser,cs_local_browser,
{ target specific }
cs_executable_stack
);
tmoduleswitches = set of tmoduleswitch;

View File

@ -2859,6 +2859,7 @@ S*2Tlinux_Linux
3*1W<x>_Target-specific options (targets)
A*1W<x>_Target-specific options (targets)
P*1W<x>_Target-specific options (targets)
p*1W<x>_Target-specific options (targets)
3*2Wb_Create a bundle instead of a library (Darwin)
P*2Wb_Create a bundle instead of a library (Darwin)
p*2Wb_Create a bundle instead of a library (Darwin)
@ -2884,6 +2885,10 @@ A*2WN_Do not generate relocation code, needed for debugging (Windows)
3*2WR_Generate relocation code (Windows)
A*2WR_Generate relocation code (Windows)
P*2WT_Specify MPW tool type application (Classic Mac OS)
3*2WX_Enable executable stack (Linux)
A*2WX_Enable executable stack (Linux)
p*2WX_Enable executable stack (Linux)
P*2WX_Enable executable stack (Linux)
**1X_Executable options:
**2Xc_Pass --shared/-dynamic to the linker (BeOS, Darwin, FreeBSD, Linux)
**2Xd_Do not use standard library search path (needed for cross compile)

View File

@ -779,7 +779,7 @@ const
option_info=11024;
option_help_pages=11025;
MsgTxtSize = 50203;
MsgTxtSize = 50397;
MsgIdxMax : array[1..20] of longint=(
24,87,251,84,65,50,108,22,201,62,

View File

@ -1141,55 +1141,60 @@ const msgtxt : array[0..000209,1..240] of char=(
'3*1W<x>_Target-specific options (targets)'#010+
'A*1W<x>_Target-specific options (targets)'#010+
'P*1W<x>_Target-specific options (targets)'#010+
'3*2Wb_Create a bundle instead of a library (Darwin)'#010+
'P*2Wb_Create a bun','dle instead of a library (Darwin)'#010+
'p*1W<x>_Target-specific options (targets)'#010+
'3*2Wb_Create a bundle instea','d of a library (Darwin)'#010+
'P*2Wb_Create a bundle instead of a library (Darwin)'#010+
'p*2Wb_Create a bundle instead of a library (Darwin)'#010+
'3*2WB_Create a relocatable image (Windows)'#010+
'A*2WB_Create a relocatable image (Windows, Symbian)'#010+
'3*2WC_Specify console type application (EMX, OS/2, Windows)',#010+
'3*2WC_Specify con','sole type application (EMX, OS/2, Windows)'#010+
'A*2WC_Specify console type application (Windows)'#010+
'P*2WC_Specify console type application (Classic Mac OS)'#010+
'3*2WD_Use DEFFILE to export functions of DLL or EXE (Windows)'#010+
'A*2WD_Use DEFFILE to export functions of DLL or EXE (Windows)'#010+
'3*2We_Use ','external resources (Darwin)'#010+
'A*2WD_Use DEFFILE to export fu','nctions of DLL or EXE (Windows)'#010+
'3*2We_Use external resources (Darwin)'#010+
'P*2We_Use external resources (Darwin)'#010+
'p*2We_Use external resources (Darwin)'#010+
'3*2WF_Specify full-screen type application (EMX, OS/2)'#010+
'3*2WG_Specify graphic type application (EMX, OS/2, Windows)'#010+
'A*2WG_Specify graphic',' type application (Windows)'#010+
'3*2WG_Specify graphic type application ','(EMX, OS/2, Windows)'#010+
'A*2WG_Specify graphic type application (Windows)'#010+
'P*2WG_Specify graphic type application (Classic Mac OS)'#010+
'3*2Wi_Use internal resources (Darwin)'#010+
'P*2Wi_Use internal resources (Darwin)'#010+
'p*2Wi_Use internal resources (Darwin)'#010+
'3*2WN_Do not generate relocation code, nee','ded for debugging (Windows'+
')'#010+
'p*2Wi_Use internal resources (Darwin)'#010,
'3*2WN_Do not generate relocation code, needed for debugging (Windows)'#010+
'A*2WN_Do not generate relocation code, needed for debugging (Windows)'#010+
'3*2WR_Generate relocation code (Windows)'#010+
'A*2WR_Generate relocation code (Windows)'#010+
'P*2WT_Specify MPW tool type application (Classic Mac OS)'#010+
'**1','X_Executable options:'#010+
'**2Xc_Pass --shared/-dynamic to the linker (BeOS, Darwin, FreeBSD, Lin'+
'ux)'#010+
'P*2WT_Specify MPW ','tool type application (Classic Mac OS)'#010+
'3*2WX_Enable executable stack (Linux)'#010+
'A*2WX_Enable executable stack (Linux)'#010+
'p*2WX_Enable executable stack (Linux)'#010+
'P*2WX_Enable executable stack (Linux)'#010+
'**1X_Executable options:'#010+
'**2Xc_Pass --shared/-dyn','amic to the linker (BeOS, Darwin, FreeBSD, L'+
'inux)'#010+
'**2Xd_Do not use standard library search path (needed for cross compil'+
'e)'#010+
'**2Xe_Use external linker'#010+
'**2Xg_Create debuginfo in a separate file and',' add a debuglink sectio'+
'n to executable'#010+
'**2XD_Try to link units dynamically (defines FPC_LINK_DYNAMIC)'#010+
'**2Xg_Create debuginfo in a separate file and add a debuglink section '+
'to executable'#010+
'**2XD_T','ry to link units dynamically (defines FPC_LINK_DYNAMIC)'#010+
'**2Xi_Use internal linker'#010+
'**2Xm_Generate link map'#010+
'**2XM<x>_Set the name of the '#039'main'#039' program routine (default i'+
's '#039'main'#039')'#010+
'**2XP<x>_Pr','epend the binutils names with the prefix <x>'#010+
'**2Xr<x>_Set library search path to <x> (needed for cross compile) (Be'+
'OS, Linux)'#010+
'**2XP<x>_Prepend the binutils names with the prefix <x>'#010+
'*','*2Xr<x>_Set library search path to <x> (needed for cross compile) ('+
'BeOS, Linux)'#010+
'**2XR<x>_Prepend <x> to all linker search paths (BeOS, Darwin, FreeBSD'+
', Linux, Mac OS, Solaris)'#010+
'**2Xs_Strip all sy','mbols from executable'#010+
'**2XS_Try to link units statically (default, defines FPC_LINK_STATIC)'#010+
'**2Xs_Strip all symbols from executable'#010+
'**2XS_Try to link units ','statically (default, defines FPC_LINK_STATIC'+
')'#010+
'**2Xt_Link with static libraries (-static is passed to linker)'#010+
'**2XX_Try to smartlink units (defines FPC_LINK_SMART)'#010+
'**1*_'#010+
'**1?_Show thi','s help'#010+
'**1?_Show this help'#010+
'**1h_Shows this help without waiting'
);

View File

@ -1021,6 +1021,10 @@ implementation
symtabsect:=TElfObjSection.create_ext(ObjSectionList,'.symtab',SHT_SYMTAB,0,0,0,4,sizeof(telfsymbol));
strtabsect:=TElfObjSection.create_ext(ObjSectionList,'.strtab',SHT_STRTAB,0,0,0,1,0);
shstrtabsect:=TElfObjSection.create_ext(ObjSectionList,'.shstrtab',SHT_STRTAB,0,0,0,1,0);
{ "no executable stack" marker for Linux }
if (target_info.system in system_linux) and
not(cs_executable_stack in current_settings.moduleswitches) then
TElfObjSection.create_ext(ObjSectionList,'.note.GNU-stack',SHT_PROGBITS,0,0,0,1,0);
{ insert the empty and filename as first in strtab }
strtabsect.writestr(#0);
strtabsect.writestr(ExtractFileName(current_module.mainsource^)+#0);

View File

@ -1461,6 +1461,18 @@ begin
else
apptype:=app_tool;
end;
'X':
begin
if (target_info.system in system_linux) then
begin
if UnsetBool(More, j) then
exclude(init_settings.moduleswitches,cs_executable_stack)
else
include(init_settings.moduleswitches,cs_executable_stack)
end
else
IllegalPara(opt);
end
else
IllegalPara(opt);
end;

View File

@ -135,3 +135,5 @@ __data_start:
2: .long 0
.long 2,0,0
3: .align 4
.section .note.GNU-stack,"",%progbits

View File

@ -92,3 +92,4 @@ __data_start:
.long 2,0,0
3: .align 4
.section .note.GNU-stack,"",%progbits

View File

@ -110,3 +110,5 @@ __data_start:
2: .long 0
.long 2,0,0
3: .align 4
.section .note.GNU-stack,"",%progbits

View File

@ -181,3 +181,5 @@ __data_start:
2: .long 0
.long 2,0,0
3: .align 4
.section .note.GNU-stack,"",%progbits

View File

@ -105,3 +105,5 @@ operatingsystem_parameters:
.set operatingsystem_parameter_envp,operatingsystem_parameters+0
.set operatingsystem_parameter_argc,operatingsystem_parameters+4
.set operatingsystem_parameter_argv,operatingsystem_parameters+8
.section .note.GNU-stack,"",%progbits

View File

@ -122,3 +122,5 @@ operatingsystem_parameters:
.set operatingsystem_parameter_envp,operatingsystem_parameters+0
.set operatingsystem_parameter_argc,operatingsystem_parameters+4
.set operatingsystem_parameter_argv,operatingsystem_parameters+8
.section .note.GNU-stack,"",%progbits

View File

@ -72,3 +72,4 @@ operatingsystem_parameters:
.set operatingsystem_parameter_argc,operatingsystem_parameters+4
.set operatingsystem_parameter_argv,operatingsystem_parameters+8
.section .note.GNU-stack,"",%progbits

View File

@ -87,3 +87,5 @@ operatingsystem_parameters:
.set operatingsystem_parameter_envp,operatingsystem_parameters+0
.set operatingsystem_parameter_argc,operatingsystem_parameters+4
.set operatingsystem_parameter_argv,operatingsystem_parameters+8
.section .note.GNU-stack,"",%progbits

View File

@ -136,3 +136,4 @@ operatingsystem_parameters:
.set operatingsystem_parameter_argc,operatingsystem_parameters+4
.set operatingsystem_parameter_argv,operatingsystem_parameters+8
.section .note.GNU-stack,"",%progbits

View File

@ -109,3 +109,4 @@ operatingsystem_parameters:
//.section .threadvar,"aw",@nobits
.comm ___fpc_threadvar_offset,4
.section .note.GNU-stack,"",%progbits

View File

@ -117,3 +117,4 @@ ___fpc_ret: /* return address to libc */
.comm operatingsystem_parameter_argc, 4
.comm operatingsystem_parameter_argv, 4
.section .note.GNU-stack,"",%progbits

View File

@ -67,3 +67,5 @@ data_start:
.comm operatingsystem_parameter_envp,4
.comm operatingsystem_parameter_argc,4
.comm operatingsystem_parameter_argv,4
.section .note.GNU-stack,"",%progbits

View File

@ -433,3 +433,5 @@ ___fpc_ret: /* return address to libc */
.comm operatingsystem_parameter_argc, 4
.comm operatingsystem_parameter_argv, 8
.comm operatingsystem_parameter_envp, 8
.section .note.GNU-stack,"",%progbits

View File

@ -439,3 +439,5 @@ ___fpc_ret: /* return address to libc */
.comm operatingsystem_parameter_argc, 4
.comm operatingsystem_parameter_argv, 8
.comm operatingsystem_parameter_envp, 8
.section .note.GNU-stack,"",%progbits

View File

@ -376,3 +376,4 @@ data_start:
.comm operatingsystem_parameter_argv, 8
.comm operatingsystem_parameter_envp, 8
.section .note.GNU-stack,"",%progbits

40
tests/webtbs/tw11563.pp Normal file
View File

@ -0,0 +1,40 @@
{ %target=linux}
{ %result=216 }
program ExecStack;
procedure DoIt;
type
proc = procedure;
var
{$if defined(cpupowerpc) or defined(cpupowerpc64)}
ret: longint;
{$endif}
{$if defined(cpui386) or defined(cpux86_64)}
ret: Byte;
{$endif}
{$ifdef cpuarm}
'add arm code to test stack execution'
{$endif}
DoNothing: proc;
begin
{$if defined(cpupowerpc) or defined(cpupowerpc64)}
{ can't use proc(@ret) because linux/ppc64 always expects some kind of
trampoline
}
ret := ($4e shl 24) or ($80 shl 16) or ($00 shl 8) or $20;
asm
la r0, ret
mtctr r0
bctrl
end;
{$endif}
{$if defined(cpui386) or defined(cpux86_64)}
ret := $C3;
DoNothing := proc(@ret);
DoNothing;
{$endif}
end;
begin
DoIt;
end.