Просмотр исходного кода

+ 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 -

sergei 11 лет назад
Родитель
Сommit
3c5345cb4e
2 измененных файлов с 13 добавлено и 5 удалено
  1. 3 2
      compiler/aggas.pas
  2. 10 3
      compiler/ogelf.pas

+ 3 - 2
compiler/aggas.pas

@@ -1685,8 +1685,9 @@ implementation
          (target_info.system in systems_darwin) then
          (target_info.system in systems_darwin) then
         AsmWriteLn(#9'.subsections_via_symbols');
         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
          not(cs_executable_stack in current_settings.moduleswitches) then
         begin
         begin
           AsmWriteLn('.section .note.GNU-stack,"",%progbits');
           AsmWriteLn('.section .note.GNU-stack,"",%progbits');

+ 10 - 3
compiler/ogelf.pas

@@ -1212,8 +1212,9 @@ implementation
            { default sections }
            { default sections }
            symtabsect:=TElfSymtab.create(data,esk_obj);
            symtabsect:=TElfSymtab.create(data,esk_obj);
            shstrtabsect:=TElfObjSection.create_ext(data,'.shstrtab',SHT_STRTAB,0,1,0);
            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
               not(cs_executable_stack in current_settings.moduleswitches) then
              TElfObjSection.create_ext(data,'.note.GNU-stack',SHT_PROGBITS,0,1,0);
              TElfObjSection.create_ext(data,'.note.GNU-stack',SHT_PROGBITS,0,1,0);
            { symbol for filename }
            { symbol for filename }
@@ -1255,7 +1256,9 @@ implementation
 
 
            header.e_ident[EI_VERSION]:=1;
            header.e_ident[EI_VERSION]:=1;
            if target_info.system in systems_openbsd then
            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_type:=ET_REL;
            header.e_machine:=ElfTarget.machine_code;
            header.e_machine:=ElfTarget.machine_code;
            header.e_version:=1;
            header.e_version:=1;
@@ -2015,6 +2018,10 @@ implementation
           header.e_ident[EI_DATA]:=ELFDATA2LSB;
           header.e_ident[EI_DATA]:=ELFDATA2LSB;
 
 
         header.e_ident[EI_VERSION]:=1;
         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
         if IsSharedLibrary then
           header.e_type:=ET_DYN
           header.e_type:=ET_DYN
         else
         else