瀏覽代碼

--- Merging r41640 into '.':
U rtl/bsd/ostypes.inc
--- Recording mergeinfo for merge of r41640 into '.':
U .
--- Merging r41642 into '.':
G rtl/bsd/ostypes.inc
--- Recording mergeinfo for merge of r41642 into '.':
G .
--- Merging r41643 into '.':
G rtl/bsd/ostypes.inc
--- Recording mergeinfo for merge of r41643 into '.':
G .
--- Merging r41645 into '.':
U rtl/openbsd/i386/prt0.as
U rtl/openbsd/i386/cprt0.as
U rtl/openbsd/x86_64/gprt0.as
U rtl/openbsd/x86_64/prt0.as
U rtl/openbsd/x86_64/cprt0.as
--- Recording mergeinfo for merge of r41645 into '.':
G .
--- Merging r41649 into '.':
G rtl/openbsd/i386/prt0.as
G rtl/openbsd/i386/cprt0.as
G rtl/openbsd/x86_64/prt0.as
G rtl/openbsd/x86_64/cprt0.as
--- Recording mergeinfo for merge of r41649 into '.':
G .
--- Merging r41653 into '.':
U rtl/openbsd/x86_64/prt0.as
--- Recording mergeinfo for merge of r41653 into '.':
G .
--- Merging r41654 into '.':
G rtl/openbsd/x86_64/prt0.as
--- Recording mergeinfo for merge of r41654 into '.':
G .
--- Merging r41659 into '.':
G rtl/openbsd/x86_64/prt0.as
--- Recording mergeinfo for merge of r41659 into '.':
G .
--- Merging r41660 into '.':
G rtl/openbsd/x86_64/prt0.as
--- Recording mergeinfo for merge of r41660 into '.':
G .
--- Merging r41669 into '.':
U rtl/openbsd/x86_64/cprt0.as
--- Recording mergeinfo for merge of r41669 into '.':
G .
--- Merging r41670 into '.':
G rtl/openbsd/x86_64/cprt0.as
--- Recording mergeinfo for merge of r41670 into '.':
G .
--- Merging r41671 into '.':
G rtl/openbsd/x86_64/cprt0.as
--- Recording mergeinfo for merge of r41671 into '.':
G .
--- Merging r41672 into '.':
U tests/test/cg/obj/openbsd/x86_64/cpptcl2.o
U tests/test/cg/obj/openbsd/x86_64/tcext3.o
U tests/test/cg/obj/openbsd/x86_64/tcext4.o
U tests/test/cg/obj/openbsd/x86_64/tcext5.o
U tests/test/cg/obj/openbsd/x86_64/tcext6.o
U tests/test/cg/obj/openbsd/x86_64/ctest.o
U tests/test/cg/obj/openbsd/x86_64/cpptcl1.o
--- Recording mergeinfo for merge of r41672 into '.':
G .
--- Merging r41677 into '.':
U rtl/openbsd/termios.inc
--- Recording mergeinfo for merge of r41677 into '.':
G .
--- Merging r41678 into '.':
U packages/rtl-console/src/unix/keyboard.pp
--- Recording mergeinfo for merge of r41678 into '.':
G .
--- Merging r41682 into '.':
U rtl/openbsd/i386/prt0.as
--- Recording mergeinfo for merge of r41682 into '.':
G .
--- Merging r41683 into '.':
G rtl/openbsd/i386/prt0.as
--- Recording mergeinfo for merge of r41683 into '.':
G .
--- Merging r41685 into '.':
G rtl/openbsd/i386/prt0.as
--- Recording mergeinfo for merge of r41685 into '.':
G .
--- Merging r41686 into '.':
G rtl/openbsd/i386/cprt0.as
--- Recording mergeinfo for merge of r41686 into '.':
G .
--- Merging r41687 into '.':
G rtl/openbsd/i386/cprt0.as
--- Recording mergeinfo for merge of r41687 into '.':
G .
--- Merging r41688 into '.':
U tests/test/cg/obj/openbsd/i386/tcext3.o
U tests/test/cg/obj/openbsd/i386/tcext4.o
U tests/test/cg/obj/openbsd/i386/tcext5.o
U tests/test/cg/obj/openbsd/i386/tcext6.o
U tests/test/cg/obj/openbsd/i386/ctest.o
U tests/test/cg/obj/openbsd/i386/cpptcl1.o
U tests/test/cg/obj/openbsd/i386/cpptcl2.o
--- Recording mergeinfo for merge of r41688 into '.':
G .
--- Merging r41692 into '.':
A rtl/openbsd/si_dll.pp
A rtl/openbsd/i386/si_c.inc
A rtl/openbsd/i386/si_prc.inc
A rtl/openbsd/i386/si_dll.inc
A rtl/openbsd/si_c.pp
A rtl/openbsd/si_prc.pp
A rtl/openbsd/x86_64/si_c.inc
A rtl/openbsd/x86_64/si_prc.inc
A rtl/openbsd/x86_64/si_dll.inc
A rtl/openbsd/si_intf.inc
--- Recording mergeinfo for merge of r41692 into '.':
G .

# revisions: 41640,41642,41643,41645,41649,41653,41654,41659,41660,41669,41670,41671,41672,41677,41678,41682,41683,41685,41686,41687,41688,41692
r41640 | nickysn | 2019-03-08 17:14:40 +0100 (Fri, 08 Mar 2019) | 2 lines
Changed paths:
M /trunk/rtl/bsd/ostypes.inc

* Adjust for OpenBSD struct changes in the 'stat' structure. Based on OpenBSD
ports patch patch-fpcsrc_rtl_bsd_ostypes_inc
r41642 | nickysn | 2019-03-08 17:22:53 +0100 (Fri, 08 Mar 2019) | 2 lines
Changed paths:
M /trunk/rtl/bsd/ostypes.inc

* Adjust for OpenBSD struct changes in the 'dirent' structure. Based on OpenBSD
ports patch patch-fpcsrc_rtl_bsd_ostypes_inc
r41643 | nickysn | 2019-03-08 17:26:40 +0100 (Fri, 08 Mar 2019) | 2 lines
Changed paths:
M /trunk/rtl/bsd/ostypes.inc

* Adjust for OpenBSD struct changes in the 'dir' structure. Based on OpenBSD
ports patch patch-fpcsrc_rtl_bsd_ostypes_inc
r41645 | nickysn | 2019-03-09 15:33:25 +0100 (Sat, 09 Mar 2019) | 3 lines
Changed paths:
M /trunk/rtl/openbsd/i386/cprt0.as
M /trunk/rtl/openbsd/i386/prt0.as
M /trunk/rtl/openbsd/x86_64/cprt0.as
M /trunk/rtl/openbsd/x86_64/gprt0.as
M /trunk/rtl/openbsd/x86_64/prt0.as

* applied all the OpenBSD startup code patches from the OpenBSD ports tree
r41649 | nickysn | 2019-03-09 16:40:34 +0100 (Sat, 09 Mar 2019) | 3 lines
Changed paths:
M /trunk/rtl/openbsd/i386/cprt0.as
M /trunk/rtl/openbsd/i386/prt0.as
M /trunk/rtl/openbsd/x86_64/cprt0.as
M /trunk/rtl/openbsd/x86_64/prt0.as

- removed duplicated ".note.openbsd.ident" sections, committed erroneously in r41645
r41653 | nickysn | 2019-03-09 17:54:39 +0100 (Sat, 09 Mar 2019) | 3 lines
Changed paths:
M /trunk/rtl/openbsd/x86_64/prt0.as

* PIC fixes in OpenBSD's prt0.as for x86_64
r41654 | nickysn | 2019-03-09 17:58:25 +0100 (Sat, 09 Mar 2019) | 3 lines
Changed paths:
M /trunk/rtl/openbsd/x86_64/prt0.as

* fixed bug, due to a typo in the previous commit
r41659 | nickysn | 2019-03-09 18:48:28 +0100 (Sat, 09 Mar 2019) | 3 lines
Changed paths:
M /trunk/rtl/openbsd/x86_64/prt0.as

* use PIC in the eh_frame section as well
r41660 | nickysn | 2019-03-09 19:30:31 +0100 (Sat, 09 Mar 2019) | 3 lines
Changed paths:
M /trunk/rtl/openbsd/x86_64/prt0.as

* changed the type of the .eh_frame section to 'unwind'
r41669 | nickysn | 2019-03-10 17:08:46 +0100 (Sun, 10 Mar 2019) | 4 lines
Changed paths:
M /trunk/rtl/openbsd/x86_64/cprt0.as

* some PIC fixes in OpenBSD x86_64 cprt0.as
* use the correct section type for .eh_frame
r41670 | nickysn | 2019-03-10 17:20:33 +0100 (Sun, 10 Mar 2019) | 3 lines
Changed paths:
M /trunk/rtl/openbsd/x86_64/cprt0.as

* more PIC fixes in OpenBSD's x86_64 cprt0.as
r41671 | nickysn | 2019-03-10 17:53:47 +0100 (Sun, 10 Mar 2019) | 3 lines
Changed paths:
M /trunk/rtl/openbsd/x86_64/cprt0.as

* more PIC fixes in OpenBSD's x86_64 cprt0.as
r41672 | nickysn | 2019-03-10 18:38:07 +0100 (Sun, 10 Mar 2019) | 5 lines
Changed paths:
M /trunk/tests/test/cg/obj/openbsd/x86_64/cpptcl1.o
M /trunk/tests/test/cg/obj/openbsd/x86_64/cpptcl2.o
M /trunk/tests/test/cg/obj/openbsd/x86_64/ctest.o
M /trunk/tests/test/cg/obj/openbsd/x86_64/tcext3.o
M /trunk/tests/test/cg/obj/openbsd/x86_64/tcext4.o
M /trunk/tests/test/cg/obj/openbsd/x86_64/tcext5.o
M /trunk/tests/test/cg/obj/openbsd/x86_64/tcext6.o

* recompiled the OpenBSD x86_64 C and C++ .o test files; GCC version is the
same (so, no need to update readme.txt), but OpenBSD's default compile
settings have changed (PIC is enabled by default)
r41677 | nickysn | 2019-03-11 17:53:00 +0100 (Mon, 11 Mar 2019) | 1 line
Changed paths:
M /trunk/rtl/openbsd/termios.inc

* OpenBSD termios interface updates
r41678 | nickysn | 2019-03-11 19:08:21 +0100 (Mon, 11 Mar 2019) | 4 lines
Changed paths:
M /trunk/packages/rtl-console/src/unix/keyboard.pp

* use stdin instead of stdout to switch the console to raw mode; this fixes
keyboard input in OpenBSD
r41682 | nickysn | 2019-03-12 02:33:06 +0100 (Tue, 12 Mar 2019) | 3 lines
Changed paths:
M /trunk/rtl/openbsd/i386/prt0.as

* partial PIC conversion of the i386 OpenBSD startup code
r41683 | nickysn | 2019-03-12 02:58:11 +0100 (Tue, 12 Mar 2019) | 3 lines
Changed paths:
M /trunk/rtl/openbsd/i386/prt0.as

* more PIC fixes in the i386 OpenBSD startup code
r41685 | nickysn | 2019-03-12 14:55:54 +0100 (Tue, 12 Mar 2019) | 3 lines
Changed paths:
M /trunk/rtl/openbsd/i386/prt0.as

* more PIC fixes in i386 OpenBSD's startup code. prt0.as is now completely PIC
r41686 | nickysn | 2019-03-12 15:56:27 +0100 (Tue, 12 Mar 2019) | 3 lines
Changed paths:
M /trunk/rtl/openbsd/i386/cprt0.as

* PIC fixes in cprt0 for i386-openbsd
r41687 | nickysn | 2019-03-12 17:00:12 +0100 (Tue, 12 Mar 2019) | 3 lines
Changed paths:
M /trunk/rtl/openbsd/i386/cprt0.as

* yet another PIC fix in cprt0 for i386-openbsd
r41688 | nickysn | 2019-03-12 17:04:57 +0100 (Tue, 12 Mar 2019) | 3 lines
Changed paths:
M /trunk/tests/test/cg/obj/openbsd/i386/cpptcl1.o
M /trunk/tests/test/cg/obj/openbsd/i386/cpptcl2.o
M /trunk/tests/test/cg/obj/openbsd/i386/ctest.o
M /trunk/tests/test/cg/obj/openbsd/i386/tcext3.o
M /trunk/tests/test/cg/obj/openbsd/i386/tcext4.o
M /trunk/tests/test/cg/obj/openbsd/i386/tcext5.o
M /trunk/tests/test/cg/obj/openbsd/i386/tcext6.o

* the i386-openbsd C and C++ test modules recompiled with -fPIC
r41692 | nickysn | 2019-03-13 16:59:36 +0100 (Wed, 13 Mar 2019) | 3 lines
Changed paths:
A /trunk/rtl/openbsd/i386/si_c.inc
A /trunk/rtl/openbsd/i386/si_dll.inc
A /trunk/rtl/openbsd/i386/si_prc.inc
A /trunk/rtl/openbsd/si_c.pp
A /trunk/rtl/openbsd/si_dll.pp
A /trunk/rtl/openbsd/si_intf.inc
A /trunk/rtl/openbsd/si_prc.pp
A /trunk/rtl/openbsd/x86_64/si_c.inc
A /trunk/rtl/openbsd/x86_64/si_dll.inc
A /trunk/rtl/openbsd/x86_64/si_prc.inc

+ initial (only a stub for now) implementation of pascal-based startup code units for OpenBSD

git-svn-id: branches/fixes_3_2@41782 -

marco 6 年之前
父節點
當前提交
5c0a5db4bd
共有 33 個文件被更改,包括 357 次插入70 次删除
  1. 10 0
      .gitattributes
  2. 2 2
      packages/rtl-console/src/unix/keyboard.pp
  3. 21 3
      rtl/bsd/ostypes.inc
  4. 37 17
      rtl/openbsd/i386/cprt0.as
  5. 35 15
      rtl/openbsd/i386/prt0.as
  6. 17 0
      rtl/openbsd/i386/si_c.inc
  7. 17 0
      rtl/openbsd/i386/si_dll.inc
  8. 17 0
      rtl/openbsd/i386/si_prc.inc
  9. 27 0
      rtl/openbsd/si_c.pp
  10. 27 0
      rtl/openbsd/si_dll.pp
  11. 22 0
      rtl/openbsd/si_intf.inc
  12. 28 0
      rtl/openbsd/si_prc.pp
  13. 18 15
      rtl/openbsd/termios.inc
  14. 12 12
      rtl/openbsd/x86_64/cprt0.as
  15. 8 0
      rtl/openbsd/x86_64/gprt0.as
  16. 8 6
      rtl/openbsd/x86_64/prt0.as
  17. 17 0
      rtl/openbsd/x86_64/si_c.inc
  18. 17 0
      rtl/openbsd/x86_64/si_dll.inc
  19. 17 0
      rtl/openbsd/x86_64/si_prc.inc
  20. 二進制
      tests/test/cg/obj/openbsd/i386/cpptcl1.o
  21. 二進制
      tests/test/cg/obj/openbsd/i386/cpptcl2.o
  22. 二進制
      tests/test/cg/obj/openbsd/i386/ctest.o
  23. 二進制
      tests/test/cg/obj/openbsd/i386/tcext3.o
  24. 二進制
      tests/test/cg/obj/openbsd/i386/tcext4.o
  25. 二進制
      tests/test/cg/obj/openbsd/i386/tcext5.o
  26. 二進制
      tests/test/cg/obj/openbsd/i386/tcext6.o
  27. 二進制
      tests/test/cg/obj/openbsd/x86_64/cpptcl1.o
  28. 二進制
      tests/test/cg/obj/openbsd/x86_64/cpptcl2.o
  29. 二進制
      tests/test/cg/obj/openbsd/x86_64/ctest.o
  30. 二進制
      tests/test/cg/obj/openbsd/x86_64/tcext3.o
  31. 二進制
      tests/test/cg/obj/openbsd/x86_64/tcext4.o
  32. 二進制
      tests/test/cg/obj/openbsd/x86_64/tcext5.o
  33. 二進制
      tests/test/cg/obj/openbsd/x86_64/tcext6.o

+ 10 - 0
.gitattributes

@@ -10087,6 +10087,9 @@ rtl/openbsd/i386/bsyscall.inc svneol=native#text/plain
 rtl/openbsd/i386/cprt0.as svneol=native#text/plain
 rtl/openbsd/i386/dllprt0.as svneol=native#text/plain
 rtl/openbsd/i386/prt0.as svneol=native#text/plain
+rtl/openbsd/i386/si_c.inc svneol=native#text/plain
+rtl/openbsd/i386/si_dll.inc svneol=native#text/plain
+rtl/openbsd/i386/si_prc.inc svneol=native#text/plain
 rtl/openbsd/i386/sighnd.inc svneol=native#text/plain
 rtl/openbsd/osdefs.inc svneol=native#text/plain
 rtl/openbsd/pmutext.inc svneol=native#text/plain
@@ -10094,6 +10097,10 @@ rtl/openbsd/pthread.inc svneol=native#text/plain
 rtl/openbsd/ptypes.inc svneol=native#text/plain
 rtl/openbsd/rtldefs.inc svneol=native#text/plain
 rtl/openbsd/setsysnr.inc svneol=native#text/plain
+rtl/openbsd/si_c.pp svneol=native#text/plain
+rtl/openbsd/si_dll.pp svneol=native#text/plain
+rtl/openbsd/si_intf.inc svneol=native#text/plain
+rtl/openbsd/si_prc.pp svneol=native#text/plain
 rtl/openbsd/signal.inc svneol=native#text/plain
 rtl/openbsd/syscalls.inc svneol=native#text/plain
 rtl/openbsd/sysconst.inc svneol=native#text/plain
@@ -10114,6 +10121,9 @@ rtl/openbsd/x86_64/crt0.s svneol=native#text/plain
 rtl/openbsd/x86_64/dllprt0.as svneol=native#text/plain
 rtl/openbsd/x86_64/gprt0.as svneol=native#text/plain
 rtl/openbsd/x86_64/prt0.as svneol=native#text/plain
+rtl/openbsd/x86_64/si_c.inc svneol=native#text/plain
+rtl/openbsd/x86_64/si_dll.inc svneol=native#text/plain
+rtl/openbsd/x86_64/si_prc.inc svneol=native#text/plain
 rtl/openbsd/x86_64/sighnd.inc svneol=native#text/plain
 rtl/os2/Makefile svneol=native#text/plain
 rtl/os2/Makefile.fpc svneol=native#text/plain

+ 2 - 2
packages/rtl-console/src/unix/keyboard.pp

@@ -118,7 +118,7 @@ procedure SetRawMode(b:boolean);
 var Tio:Termios;
 
 begin
-  TCGetAttr(1,Tio);
+  TCGetAttr(0,Tio);
   if b then
    begin
      {Standard output now needs #13#10.}
@@ -132,7 +132,7 @@ begin
       {Standard output normally needs just a linefeed.}
       settextlineending(output,#10);
     end;
-  TCsetattr(1,TCSANOW,Tio);
+  TCsetattr(0,TCSANOW,Tio);
 end;
 
 {$ifdef linux}

+ 21 - 3
rtl/bsd/ostypes.inc

@@ -87,6 +87,9 @@ TYPE
         st_qspare1    : cint64;            // was recursive change detect
         st_qspare2    : cint64;
 {$else dragonfly}
+{$ifdef openbsd}
+        st_mode       : mode_t;            // inode protection mode
+{$endif openbsd}
         st_dev        : dev_t;             // inode's device
 {$ifdef darwin_new_iostructs}
         st_mode       : mode_t;            // inode protection mode
@@ -99,16 +102,15 @@ TYPE
         st_ino        : ino_t;             // inode's number
 {$else not netbsd}
         st_ino        : ino_t;             // inode's number
+{$ifndef openbsd}
         st_mode       : mode_t;            // inode protection mode
+{$endif not openbsd}
 {$endif not netbsd}
         st_nlink      : nlink_t;           // number of hard links
 {$endif}
         st_uid        : uid_t;             // user ID of the file's owner
         st_gid        : gid_t;             // group ID of the file's group
         st_rdev       : dev_t;             // device type
-{$ifdef openbsd}
-        st_padd0      : cint;
-{$endif}
         st_atime      : time_t;            // time of last access
         st_atimensec  : clong;             // nsec of last access
         st_mtime      : time_t;            // time of last data modification
@@ -154,6 +156,16 @@ TYPE
         d_unused2     : cuint32;                        // reserved
         d_name        : array[0..255] of char;          // name, null terminated
    end;
+{$elseif defined(openbsd)}
+   dirent  = record
+        d_fileno      : ino_t;
+        d_off         : off_t;
+        d_reclen      : cuint16;                        // length of this record
+        d_type        : cuint8;                         // file type, see below
+        d_namlen      : cuint8;                         // length of string in d_name
+        d_padding     : array[0..3] of cuint8;
+        d_name        : array[0..(255 + 1)-1] of char;  // name must be no longer than this
+   end;
 {$else}
    dirent  = record
         d_fileno      : cuint32;                        // file number of entry
@@ -185,6 +197,11 @@ TYPE
         dd_size   : clong;        // amount of data returned by getdirentries
         dd_buf    : pchar;        // data buffer
         dd_len    : cint;         // size of data buffer
+{$ifdef openbsd}
+        dd_curpos : off_t;
+        dd_lock   : pointer;
+        dd_rewind : clong;
+{$else not openbsd}
 {$ifdef netbsdpowerpc}
         dd_pad1   : cint;
         dd_seek   : cint64;        // magic cookie returned by getdirentries
@@ -197,6 +214,7 @@ TYPE
         __dd_lock : pthread_mutex_t; // for thread locking
         __dd_td : pointer;        // telldir position recording
 {$endif}
+{$endif not openbsd}
    end;
    TDir    = dir;
    pDir    = ^dir;

+ 37 - 17
rtl/openbsd/i386/cprt0.as

@@ -68,10 +68,15 @@ ___start:
 	subl $16,%esp
 	pushl %esi
 	pushl %ebx
+	call fpc_geteipasecx
+	addl $_GLOBAL_OFFSET_TABLE_,%ecx
+	movl %ecx,%edi
 	movl 12(%ebp),%esi
 	movl 16(%ebp),%eax
-	movl %eax,environ
-	movl %eax,operatingsystem_parameter_envp
+	movl environ@GOT(%edi),%ecx
+	movl %eax,(%ecx)
+	movl operatingsystem_parameter_envp@GOT(%edi),%ecx
+	movl %eax,(%ecx)
 	movl (%esi),%ebx
 	testl %ebx,%ebx
 	je .L3
@@ -79,61 +84,76 @@ ___start:
 	pushl $47
 	pushl %ebx
 	call _strrchr
-	movl %eax,__progname
+	movl __progname@GOT(%edi),%ecx
+	movl %eax,(%ecx)
 	addl $16,%esp
 	testl %eax,%eax
 	jne .L4
-	movl %ebx,__progname
+	movl %ebx,(%ecx)
 	jmp .L5
 	.p2align 4,,7
 .L4:
 	incl %eax
-	movl %eax,__progname
+	movl %eax,(%ecx)
 .L5:
-	movl $__progname_storage,%edx
+	movl __progname_storage@GOT(%edi),%edx
 	jmp .L12
 	.p2align 4,,7
 .L9:
 	movb (%eax),%al
 	movb %al,(%edx)
-	incl __progname
+	movl __progname@GOT(%edi),%ecx
+	incl (%ecx)
 	incl %edx
 .L12:
-	movl __progname,%eax
+	movl __progname@GOT(%edi),%ecx
+	movl (%ecx),%eax
 	cmpb $0,(%eax)
 	je .L7
-	cmpl $__progname_storage+255,%edx
+	movl __progname_storage@GOT(%edi),%ecx
+	addl $255,%ecx
+	cmpl %ecx,%edx
 	jb .L9
 .L7:
 	movb $0,(%edx)
-	movl $__progname_storage,__progname
+	pushl %eax
+	movl __progname_storage@GOT(%edi),%eax
+	movl __progname@GOT(%edi),%ecx
+	movl %eax,(%ecx)
+	popl %eax
 .L3:
-	call __init
+#	call __init
 	subl $16,%esp
 	pushl %eax
 	movl 8(%ebp),%eax
-	movl %eax,operatingsystem_parameter_argc
-	movl %esi,operatingsystem_parameter_argv
+	movl operatingsystem_parameter_argc@GOT(%edi),%ecx
+	movl %eax,(%ecx)
+	movl operatingsystem_parameter_argv@GOT(%edi),%ecx
+	movl %esi,(%ecx)
 	popl %eax
 #	pushl environ
 #	pushl %esi
 #	pushl 8(%ebp)
+	movl ___fpucw@GOT(%edi),%ecx
 	finit
 	fwait
-	fldcw ___fpucw
+	fldcw (%ecx)
 	xorl  %ebp,%ebp
 	call main
 	pushl %eax
-	call exit
+	call exit@PLT
         .p2align 2,0x90
 
 .globl _haltproc
 .type _haltproc,@function
 
 _haltproc:
-           mov $1,%eax
-           movzwl operatingsystem_result,%ebx
+           call fpc_geteipasebx
+           addl $_GLOBAL_OFFSET_TABLE_,%ebx
+           movl operatingsystem_result@GOT(%ebx),%ebx
+           movzwl (%ebx),%ebx
            pushl %ebx
+           mov $1,%eax
            call .Lactualsyscall
            addl  $4,%esp
            jmp   _haltproc

+ 35 - 15
rtl/openbsd/i386/prt0.as

@@ -64,10 +64,15 @@ ___start:
 	subl $16,%esp
 	pushl %esi
 	pushl %ebx
+	call fpc_geteipasecx
+	addl $_GLOBAL_OFFSET_TABLE_,%ecx
+	movl %ecx,%edi
 	movl 12(%ebp),%esi
 	movl 16(%ebp),%eax
-	movl %eax,environ
-	movl %eax,operatingsystem_parameter_envp
+	movl environ@GOT(%edi),%ecx
+	movl %eax,(%ecx)
+	movl operatingsystem_parameter_envp@GOT(%edi),%ecx
+	movl %eax,(%ecx)
 	movl (%esi),%ebx
 	testl %ebx,%ebx
 	je .L3
@@ -75,48 +80,60 @@ ___start:
 	pushl $47
 	pushl %ebx
 	call _strrchr
-	movl %eax,__progname
+	movl __progname@GOT(%edi),%ecx
+	movl %eax,(%ecx)
 	addl $16,%esp
 	testl %eax,%eax
 	jne .L4
-	movl %ebx,__progname
+	movl %ebx,(%ecx)
 	jmp .L5
 	.p2align 4,,7
 .L4:
 	incl %eax
-	movl %eax,__progname
+	movl %eax,(%ecx)
 .L5:
-	movl $__progname_storage,%edx
+	movl __progname_storage@GOT(%edi),%edx
 	jmp .L12
 	.p2align 4,,7
 .L9:
 	movb (%eax),%al
 	movb %al,(%edx)
-	incl __progname
+	movl __progname@GOT(%edi),%ecx
+	incl (%ecx)
 	incl %edx
 .L12:
-	movl __progname,%eax
+	movl __progname@GOT(%edi),%ecx
+	movl (%ecx),%eax
 	cmpb $0,(%eax)
 	je .L7
-	cmpl $__progname_storage+255,%edx
+	movl __progname_storage@GOT(%edi),%ecx
+	addl $255,%ecx
+	cmpl %ecx,%edx
 	jb .L9
 .L7:
 	movb $0,(%edx)
-	movl $__progname_storage,__progname
+	pushl %eax
+	movl __progname_storage@GOT(%edi),%eax
+	movl __progname@GOT(%edi),%ecx
+	movl %eax,(%ecx)
+	popl %eax
 .L3:
 #	call __init
 	subl $16,%esp
 	pushl %eax
 	movl 8(%ebp),%eax
-	movl %eax,operatingsystem_parameter_argc
-	movl %esi,operatingsystem_parameter_argv
+	movl operatingsystem_parameter_argc@GOT(%edi),%ecx
+	movl %eax,(%ecx)
+	movl operatingsystem_parameter_argv@GOT(%edi),%ecx
+	movl %esi,(%ecx)
 	popl %eax
 #	pushl environ
 #	pushl %esi
 #	pushl 8(%ebp)
+	movl ___fpucw@GOT(%edi),%ecx
 	finit
 	fwait
-	fldcw ___fpucw
+	fldcw (%ecx)
 	xorl  %ebp,%ebp
 	call main
 #	pushl %eax
@@ -128,9 +145,12 @@ ___start:
 .type _haltproc,@function
 
 _haltproc:
-           mov $1,%eax
-           movzwl operatingsystem_result,%ebx
+           call fpc_geteipasebx
+           addl $_GLOBAL_OFFSET_TABLE_,%ebx
+           movl operatingsystem_result@GOT(%ebx),%ebx
+           movzwl (%ebx),%ebx
            pushl %ebx
+           mov $1,%eax
            call .Lactualsyscall
            addl  $4,%esp
            jmp   _haltproc

+ 17 - 0
rtl/openbsd/i386/si_c.inc

@@ -0,0 +1,17 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2019 by Free Pascal development team
+
+    This file implements parts of the startup code for OpenBSD
+    programs that link to the C library.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+

+ 17 - 0
rtl/openbsd/i386/si_dll.inc

@@ -0,0 +1,17 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2019 by Free Pascal development team
+
+    This file implements parts of the startup code for OpenBSD
+    shared object (.so) libraries.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+

+ 17 - 0
rtl/openbsd/i386/si_prc.inc

@@ -0,0 +1,17 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2019 by Free Pascal development team
+
+    This file implements parts of the startup code for OpenBSD
+    programs that don't link to the C library.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+

+ 27 - 0
rtl/openbsd/si_c.pp

@@ -0,0 +1,27 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2019 by Free Pascal development team
+
+    This file implements the startup code for OpenBSD programs that
+    link to the C library.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit si_c;
+
+interface
+
+{$i si_intf.inc}
+
+implementation
+
+{$i si_c.inc}
+
+end.

+ 27 - 0
rtl/openbsd/si_dll.pp

@@ -0,0 +1,27 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2019 by Free Pascal development team
+
+    This file implements the startup code for OpenBSD shared object
+    (.so) libraries.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit si_dll;
+
+interface
+
+{$i si_intf.inc}
+
+implementation
+
+{$i si_dll.inc}
+
+end.

+ 22 - 0
rtl/openbsd/si_intf.inc

@@ -0,0 +1,22 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2019 by Free Pascal development team
+
+    This file implements the public interface parts of the startup
+    code for OpenBSD programs or shared object (.so) libraries.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{$SMARTLINK OFF}
+
+var
+  operatingsystem_parameter_envp: ppchar; public name 'operatingsystem_parameter_envp';
+  operatingsystem_parameter_argc: longint; public name 'operatingsystem_parameter_argc';
+  operatingsystem_parameter_argv: ppchar; public name 'operatingsystem_parameter_argv';

+ 28 - 0
rtl/openbsd/si_prc.pp

@@ -0,0 +1,28 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2019 by Free Pascal development team
+
+    This file implements the startup code for OpenBSD programs that
+    don't link to the C library.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+
+unit si_prc;
+
+interface
+
+{$i si_intf.inc}
+
+implementation
+
+{$i si_prc.inc}
+
+end.

+ 18 - 15
rtl/openbsd/termios.inc

@@ -55,17 +55,16 @@ Type
 
 
 type
-  Termios = packed record
+  tcflag_t = cuint;
+  cc_t = cuchar;
+  Termios = record
     c_iflag,
     c_oflag,
     c_cflag,
-    c_lflag  : longint;
-//    c_line   : char;
-    c_cc     : array[0..NCCS-1] of byte;
-   {$IFDEF BSD}
+    c_lflag  : tcflag_t;
+    c_cc     : array[0..NCCS-1] of cc_t;
     c_ispeed,
-    c_ospeed : longint;
-   {$endif}
+    c_ospeed : cint;
   end;
   TTermios=Termios;
 
@@ -92,6 +91,7 @@ CONST
         IXON            =     $200;     { enable output flow control }
         IXOFF           =     $400;     { enable input flow control }
         IXANY           =     $800;     { any char will restart after stop }
+        IUCLC           =    $1000;     { translate upper to lower case }
         IMAXBEL         =    $2000;     { ring bell on input queue full }
 
 {
@@ -101,6 +101,10 @@ CONST
         ONLCR           =       $2;     { map NL to CR-NL (ala CRMOD) }
         OXTABS          =       $4;     { expand tabs to spaces }
         ONOEOT          =       $8;     { discard EOT's (^D) on output) }
+        OCRNL           =      $10;     { map CR to NL }
+        OLCUC           =      $20;     { translate lower case to upper case }
+        ONOCR           =      $40;     { No CR output at column 0 }
+        ONLRET          =      $80;     { NL performs the CR function }
 
 {
  * Control flags - hardware control of terminal
@@ -117,13 +121,11 @@ CONST
         PARODD          =    $2000;     { odd parity, else even }
         HUPCL           =    $4000;     { hang up on last close }
         CLOCAL          =    $8000;     { ignore modem status lines }
-        CCTS_OFLOW      =   $10000;     { CTS flow control of output }
-        CRTS_IFLOW      =   $20000;     { RTS flow control of input }
-        CRTSCTS         =   (CCTS_OFLOW or CRTS_IFLOW);
-        CDTR_IFLOW      =   $40000;     { DTR flow control of input }
-        CDSR_OFLOW      =   $80000;     { DSR flow control of output }
-        CCAR_OFLOW      =  $100000;     { DCD flow control of output }
-        MDMBUF          =  $100000;     { old name for CCAR_OFLOW }
+        CRTSCTS         =   $10000;     { RTS/CTS full-duplex flow control }
+        CRTS_IFLOW      =  CRTSCTS;     { XXX compat }
+        CCTS_OFLOW      =  CRTSCTS;     { XXX compat }
+        MDMBUF          =  $100000;     { DTR/DCD hardware flow control }
+        CHWFLOW    = MDMBUF or CRTSCTS; { all types of hw flow control }
 
 {
  * "Local" flags - dumping ground for other state
@@ -144,9 +146,10 @@ CONST
         ICANON          =     $100;     { canonicalize input lines }
         ALTWERASE       =     $200;     { use alternate WERASE algorithm }
         IEXTEN          =     $400;     { enable DISCARD and LNEXT }
-        EXTPROC         =     $800;      { external processing }
+        EXTPROC         =     $800;     { external processing }
         TOSTOP          =  $400000;     { stop background jobs from output }
         FLUSHO          =  $800000;     { output being flushed (state) }
+        XCASE           = $1000000;     { canonical upper/lower case }
         NOKERNINFO      = $2000000;     { no kernel output from VSTATUS }
         PENDIN          =$20000000;     { XXX retype pending input (state) }
         NOFLSH          =$80000000;     { don't flush after interrupt }

+ 12 - 12
rtl/openbsd/x86_64/cprt0.as

@@ -76,7 +76,8 @@ ___start:
 	addq	$1, %rax
 	movq	%rax, __progname(%rip)
 .L6:
-	movq	$__progname_storage, -16(%rbp)
+	leaq	__progname_storage(%rip), %rax
+	movq	%rax, -16(%rbp)
 	jmp	.L7
 .L8:
 	movq	__progname(%rip), %rcx
@@ -91,21 +92,20 @@ ___start:
 	movzbl	(%rax), %eax
 	testb	%al, %al
 	je	.L9
-	movq	$__progname_storage+255, %rax
+	leaq	__progname_storage+255(%rip), %rax
 	cmpq	%rax, -16(%rbp)
 	jb	.L8
 .L9:
+	leaq	__progname_storage(%rip), %rax
+	movq	%rax, __progname(%rip)
 	movq	-16(%rbp), %rax
 	movb	$0, (%rax)
-	movq	$__progname_storage, __progname(%rip)
 .L2:
-	movl	$_mcleanup, %edi
+	movq	_mcleanup@GOTPCREL(%rip), %rdi
 	call	atexit
-	movl	$_etext, %eax
-	movq	%rax, %rsi
-	movl	$_eprol, %eax
-	movq	%rax, %rdi
-	call	monstartup
+	movq	_etext@GOTPCREL(%rip), %rsi
+	leaq	_eprol(%rip), %rdi
+	call	monstartup@plt
 	movl	$0, %eax
 	call	_init
 	movq	environ(%rip), %rdx
@@ -184,7 +184,7 @@ _strrchr:
         .comm   operatingsystem_parameter_envp,8,8
         .comm   operatingsystem_parameter_argc,8,8
         .comm   operatingsystem_parameter_argv,8,8
-	.section	.eh_frame,"a",@progbits
+	.section	.eh_frame,"a",@unwind
 .Lframe1:
 	.long	.LECIE1-.LSCIE1
 .LSCIE1:
@@ -207,7 +207,7 @@ _strrchr:
 	.long	.LEFDE1-.LASFDE1
 .LASFDE1:
 	.long	.LASFDE1-.Lframe1
-	.long	.LFB9
+	.long	.LFB9-.
 	.long	.LFE9-.LFB9
 	.uleb128 0x0
 	.byte	0x4
@@ -226,7 +226,7 @@ _strrchr:
 	.long	.LEFDE3-.LASFDE3
 .LASFDE3:
 	.long	.LASFDE3-.Lframe1
-	.long	.LFB10
+	.long	.LFB10-.
 	.long	.LFE10-.LFB10
 	.uleb128 0x0
 	.byte	0x4

+ 8 - 0
rtl/openbsd/x86_64/gprt0.as

@@ -1,3 +1,11 @@
+	.section ".note.openbsd.ident", "a"
+	.p2align 2
+	.long	8
+	.long	4
+	.long	1
+	.ascii "OpenBSD\0"
+	.long	0
+	.previous
 	.file	"crt0.c"
 	.globl	__progname
 	.section	.rodata

+ 8 - 6
rtl/openbsd/x86_64/prt0.as

@@ -76,7 +76,8 @@ ___start:
 	addq	$1, %rax
 	movq	%rax, __progname(%rip)
 .L6:
-	movq	$__progname_storage, -16(%rbp)
+	leaq	__progname_storage(%rip), %rax
+	movq	%rax, -16(%rbp)
 	jmp	.L7
 .L8:
 	movq	__progname(%rip), %rcx
@@ -91,13 +92,14 @@ ___start:
 	movzbl	(%rax), %eax
 	testb	%al, %al
 	je	.L9
-	movq	$__progname_storage+255, %rax
+	leaq	__progname_storage+255(%rip), %rax
 	cmpq	%rax, -16(%rbp)
 	jb	.L8
 .L9:
+	leaq	__progname_storage(%rip), %rax
+	movq	%rax, __progname(%rip)
 	movq	-16(%rbp), %rax
 	movb	$0, (%rax)
-	movq	$__progname_storage, __progname(%rip)
 .L2:
 	# movl	$_mcleanup, %edi
 	# call	atexit
@@ -185,7 +187,7 @@ _strrchr:
         .comm   operatingsystem_parameter_envp,8,8
         .comm   operatingsystem_parameter_argc,8,8
         .comm   operatingsystem_parameter_argv,8,8
-	.section	.eh_frame,"a",@progbits
+	.section	.eh_frame,"a",@unwind
 .Lframe1:
 	.long	.LECIE1-.LSCIE1
 .LSCIE1:
@@ -208,7 +210,7 @@ _strrchr:
 	.long	.LEFDE1-.LASFDE1
 .LASFDE1:
 	.long	.LASFDE1-.Lframe1
-	.long	.LFB9
+	.long	.LFB9-.
 	.long	.LFE9-.LFB9
 	.uleb128 0x0
 	.byte	0x4
@@ -227,7 +229,7 @@ _strrchr:
 	.long	.LEFDE3-.LASFDE3
 .LASFDE3:
 	.long	.LASFDE3-.Lframe1
-	.long	.LFB10
+	.long	.LFB10-.
 	.long	.LFE10-.LFB10
 	.uleb128 0x0
 	.byte	0x4

+ 17 - 0
rtl/openbsd/x86_64/si_c.inc

@@ -0,0 +1,17 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2019 by Free Pascal development team
+
+    This file implements parts of the startup code for OpenBSD
+    programs that link to the C library.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+

+ 17 - 0
rtl/openbsd/x86_64/si_dll.inc

@@ -0,0 +1,17 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2019 by Free Pascal development team
+
+    This file implements parts of the startup code for OpenBSD
+    shared object (.so) libraries.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+

+ 17 - 0
rtl/openbsd/x86_64/si_prc.inc

@@ -0,0 +1,17 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2019 by Free Pascal development team
+
+    This file implements parts of the startup code for OpenBSD
+    programs that don't link to the C library.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+

二進制
tests/test/cg/obj/openbsd/i386/cpptcl1.o


二進制
tests/test/cg/obj/openbsd/i386/cpptcl2.o


二進制
tests/test/cg/obj/openbsd/i386/ctest.o


二進制
tests/test/cg/obj/openbsd/i386/tcext3.o


二進制
tests/test/cg/obj/openbsd/i386/tcext4.o


二進制
tests/test/cg/obj/openbsd/i386/tcext5.o


二進制
tests/test/cg/obj/openbsd/i386/tcext6.o


二進制
tests/test/cg/obj/openbsd/x86_64/cpptcl1.o


二進制
tests/test/cg/obj/openbsd/x86_64/cpptcl2.o


二進制
tests/test/cg/obj/openbsd/x86_64/ctest.o


二進制
tests/test/cg/obj/openbsd/x86_64/tcext3.o


二進制
tests/test/cg/obj/openbsd/x86_64/tcext4.o


二進制
tests/test/cg/obj/openbsd/x86_64/tcext5.o


二進制
tests/test/cg/obj/openbsd/x86_64/tcext6.o