+ Write 'non-executable stack' marker to object files also on FreeBSD (verified for version 9.0 for i386).

+ Write correct ABI value into ELF header for FreeBSD.

git-svn-id: trunk@26745 -
This commit is contained in:
sergei 2014-02-10 05:46:46 +00:00
parent 74089039e7
commit 3c5345cb4e
2 changed files with 13 additions and 5 deletions

View File

@ -1685,8 +1685,9 @@ implementation
(target_info.system in systems_darwin) then
AsmWriteLn(#9'.subsections_via_symbols');
{ "no executable stack" marker for Linux }
if (target_info.system in (systems_linux + systems_android)) and
{ "no executable stack" marker }
{ TODO: used by OpenBSD/NetBSD as well? }
if (target_info.system in (systems_linux + systems_android + systems_freebsd)) and
not(cs_executable_stack in current_settings.moduleswitches) then
begin
AsmWriteLn('.section .note.GNU-stack,"",%progbits');

View File

@ -1212,8 +1212,9 @@ implementation
{ default sections }
symtabsect:=TElfSymtab.create(data,esk_obj);
shstrtabsect:=TElfObjSection.create_ext(data,'.shstrtab',SHT_STRTAB,0,1,0);
{ "no executable stack" marker for Linux }
if (target_info.system in (systems_linux + systems_android)) and
{ "no executable stack" marker }
{ TODO: used by OpenBSD/NetBSD as well? }
if (target_info.system in (systems_linux + systems_android + systems_freebsd)) and
not(cs_executable_stack in current_settings.moduleswitches) then
TElfObjSection.create_ext(data,'.note.GNU-stack',SHT_PROGBITS,0,1,0);
{ symbol for filename }
@ -1255,7 +1256,9 @@ implementation
header.e_ident[EI_VERSION]:=1;
if target_info.system in systems_openbsd then
header.e_ident[EI_OSABI]:=ELFOSABI_OPENBSD;
header.e_ident[EI_OSABI]:=ELFOSABI_OPENBSD
else if target_info.system in systems_freebsd then
header.e_ident[EI_OSABI]:=ELFOSABI_FREEBSD;
header.e_type:=ET_REL;
header.e_machine:=ElfTarget.machine_code;
header.e_version:=1;
@ -2015,6 +2018,10 @@ implementation
header.e_ident[EI_DATA]:=ELFDATA2LSB;
header.e_ident[EI_VERSION]:=1;
if target_info.system in systems_openbsd then
header.e_ident[EI_OSABI]:=ELFOSABI_OPENBSD
else if target_info.system in systems_freebsd then
header.e_ident[EI_OSABI]:=ELFOSABI_FREEBSD;
if IsSharedLibrary then
header.e_type:=ET_DYN
else