I'm (was?) the FreeBSD maintainer, but last summer the last FreeBSD system was turned off, so I'm without production FreeBSD systems for the first time in 25+ years, and with that went most of my motivation. That said, not much new development happened after 2015 anyway, and even in 2010-2015 it already more maintenance than new work.
After 2015 I mostly kept what was there compiling/working with FreeBSD11 if you switched to gld after that. Some changes in FPC to the Linux port were not followed for the freebsd port (like the pascal startup code, initially because it seemed to need working with weak symbols). OpenBSD was recently updated to use this. The releases all worked out of the box with stock kernels up to FreebSD11
Nowadays most non llvm versions are out of support or nearly out of support, and all my release building VMs are outdated, and the port faces some non-trivial work. Anyway some points:
1. The ELF abi tag was generated for 32-bit by identpatch.sh, as the url says. I had a toplevel script that automated things a bit.
However with the retooling of freebsd that broke, like pretty much everything else. I think it never worked for 64-bit releases, but I just copied the 32-bit output to the 64-bit file.
Basically the talk of COMPAT_ in that link is just about the abitag not being updated, and having to brandelf binaries. It is not related to the MMAP thing.
2. FPC does not do anything special, and just calls syscall 197 to do mmap. The call is fpmmap in rtl/bsd/ossysc.inc. Maybe the linker or the ports system detects this and does something special. That said, some syscalls like mmap and ftruncate() are special due to their 64-bit offset use, and probably change more often than others. Sometimes workarounds for other (non FPC) problems get confused by the fact that simple FPC programs don't link to libc.
3. The OS specific parts of a *nix FPC port are:
- a custom startup code. (prt0.as for non libc linking programs, cprt0.as for libc linking programs)
- a large number of constants. syscall numbers and the usual *nix constants and some internals like ioctl values.
- likewise for structures. stat,statfs and a few others.
- Sometimes the syscalls themselves are special (and not generic *nix or *bsd).
- termios and similar bits are usually OS specific too.
- how the linker is called.
- creating libgdb and linking it with the textmode IDE. FPC 3.2+ won't do that anymore though, so that drops off the list.
Probably all need review, since 2010 only things that break have been looked at. Some very old notes (2003-2005 era, the newer date in the PDF were some minor changes) are
here.
There was an option to compile FPC to use libc calls instead of syscalls (pass OPT="-dFPC_USE_LIBC"), but the exact state is unknown, it is not used much. (only solves going through the list of syscalls once every 5 years or so, the other points still must be done, and might even complicate)
// rtl/freebsd/sysnr.inc
syscall_nr_mmap = 197;
// rtl/bsd/ossysc.inc
Function Fpmmap(start:pointer;len:size_t;prot:cint;flags:cint;fd:cint;offst:off_t):pointer; [public, alias: 'FPC_SYSC_MMAP'];
begin
{$ifdef CPU64}
Fpmmap:=pointer(ptruint(do_syscall(TSysParam(syscall_nr_mmap),TSysParam(Start),TSysParam(Len),TSysParam(Prot),TSysParam(Flags),TSysParam(fd),0,TSysParam(offst))));
{$else}
Fpmmap:=pointer(ptruint(do_syscall(syscall_nr_mmap,TSysParam(Start),Len,Prot,Flags,fd,0,
{$ifdef FPC_BIG_ENDIAN} hi(offst),lo(offst){$endif}
{$ifdef FPC_LITTLE_ENDIAN} lo(offst),hi(offst){$endif}
)));
{$endif}
end;