diff --git a/compiler/aggas.pas b/compiler/aggas.pas index 84cdeb05bb..7e13045aa2 100644 --- a/compiler/aggas.pas +++ b/compiler/aggas.pas @@ -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'); diff --git a/compiler/ogelf.pas b/compiler/ogelf.pas index aa4807a0a9..03d8034979 100644 --- a/compiler/ogelf.pas +++ b/compiler/ogelf.pas @@ -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