fpc/compiler/sparc/cpuelf.pas
sergei 6d70009f06 + ELF linker. Works on x86_64-linux and i386-linux good enough to pass the testsuite, but still requires a lot of work in nearly all aspects. In particular, no attempt to resolve symbols from shared libs is done, everything is just treated as imports. Symbol versioning isn't supported either.
x86_64 is the most elaborated, has some degree of indirect function (GNU_IFUNC) and TLS support, so it is even able to link with static libc/pthreads code (tw14265) and produce an executable that can launch (but still fails due to invalid DWARF unwind info).

i386 produces working shared libraries if they are compiled with -Cg, without one your mileage may vary. tw14265 does not link yet due to missing COMDAT group support.

git-svn-id: trunk@22775 -
2012-10-19 17:21:08 +00:00

121 lines
3.2 KiB
ObjectPascal

{
Copyright (c) 1998-2006 by Peter Vreman
Includes ELF-related code specific to SPARC
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
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. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
****************************************************************************
}
unit cpuelf;
{$i fpcdefs.inc}
interface
implementation
uses
verbose,
systems,ogbase,ogelf,assemble;
type
TElfTargetSparc=class(TElfTarget)
class function encodereloc(objrel:TObjRelocation):byte;override;
class procedure loadreloc(objrel:TObjRelocation);override;
end;
const
{ Relocation types }
R_SPARC_NONE = 0;
R_SPARC_8 = 1;
R_SPARC_16 = 2;
R_SPARC_32 = 3;
R_SPARC_DISP8 = 4;
R_SPARC_DISP16 = 5;
R_SPARC_DISP32 = 6;
R_SPARC_WDISP30 = 7;
R_SPARC_WDISP22 = 8;
R_SPARC_HI22 = 9;
R_SPARC_22 = 10;
R_SPARC_13 = 11;
R_SPARC_LO10 = 12;
R_SPARC_GOT10 = 13;
R_SPARC_GOT13 = 14;
R_SPARC_GOT22 = 15;
R_SPARC_PC10 = 16;
R_SPARC_PC22 = 17;
R_SPARC_WPLT30 = 18;
R_SPARC_COPY = 19;
R_SPARC_GLOB_DAT = 20;
R_SPARC_JMP_SLOT = 21;
R_SPARC_RELATIVE = 22;
R_SPARC_UA32 = 23;
R_SPARC_GNU_VTINHERIT = 250;
R_SPARC_GNU_VTENTRY = 251;
{****************************************************************************
TElfTargetSparc
****************************************************************************}
class function TElfTargetSparc.encodereloc(objrel:TObjRelocation):byte;
begin
case objrel.typ of
RELOC_NONE :
result:=R_SPARC_NONE;
RELOC_ABSOLUTE :
result:=R_SPARC_32;
{ TODO }
else
result:=0;
InternalError(2012082303);
end;
end;
class procedure TElfTargetSparc.loadreloc(objrel:TObjRelocation);
begin
end;
{*****************************************************************************
Initialize
*****************************************************************************}
const
as_sparc_elf32_info : tasminfo =
(
id : as_sparc_elf32;
idtxt : 'ELF';
asmbin : '';
asmcmd : '';
supported_targets : [system_sparc_linux, system_sparc_solaris,
system_sparc_embedded];
// flags : [af_outputbinary,af_smartlink_sections];
flags : [af_outputbinary,af_supports_dwarf];
labelprefix : '.L';
comment : '';
dollarsign: '$';
);
initialization
RegisterAssembler(as_sparc_elf32_info,TElfAssembler);
ElfTarget:=TElfTargetSparc;
end.