mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-16 08:00:52 +02:00
* factored out the generation of the Objective-C section names, so we can
reuse them for llvm too git-svn-id: trunk@32885 -
This commit is contained in:
parent
3f7169e250
commit
3aba28deb7
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -490,6 +490,7 @@ compiler/nopt.pas svneol=native#text/plain
|
||||
compiler/nset.pas svneol=native#text/plain
|
||||
compiler/nstate.pas svneol=native#text/plain
|
||||
compiler/nutils.pas svneol=native#text/plain
|
||||
compiler/objcasm.pas svneol=native#text/plain
|
||||
compiler/objcdef.pas svneol=native#text/plain
|
||||
compiler/objcgutl.pas svneol=native#text/plain
|
||||
compiler/objcutil.pas svneol=native#text/plain
|
||||
|
@ -151,6 +151,8 @@ interface
|
||||
sec_heap
|
||||
);
|
||||
|
||||
TObjCAsmSectionType = sec_objc_class..sec_objc_protolist;
|
||||
|
||||
TAsmSectionOrder = (secorder_begin,secorder_default,secorder_end);
|
||||
|
||||
TAsmSymbol = class(TFPHashObject)
|
||||
|
@ -113,7 +113,7 @@ implementation
|
||||
{$ifdef m68k}
|
||||
cpuinfo,aasmcpu,
|
||||
{$endif m68k}
|
||||
cpubase;
|
||||
cpubase,objcasm;
|
||||
|
||||
const
|
||||
line_length = 70;
|
||||
@ -460,7 +460,7 @@ implementation
|
||||
system_powerpc_aix,
|
||||
system_powerpc64_aix:
|
||||
begin
|
||||
if (atype in [sec_stub,sec_objc_data,sec_objc_const,sec_data_coalesced]) then
|
||||
if (atype in [sec_stub]) then
|
||||
writer.AsmWrite('.section ');
|
||||
end
|
||||
else
|
||||
@ -1671,129 +1671,11 @@ implementation
|
||||
result:='.section __DATA, __mod_term_func, mod_term_funcs';
|
||||
exit;
|
||||
end;
|
||||
sec_objc_protocol_ext:
|
||||
low(TObjCAsmSectionType)..high(TObjCAsmSectionType):
|
||||
begin
|
||||
result:='.section __OBJC, __protocol_ext, regular, no_dead_strip';
|
||||
exit;
|
||||
end;
|
||||
sec_objc_class_ext:
|
||||
begin
|
||||
result:='.section __OBJC, __class_ext, regular, no_dead_strip';
|
||||
exit;
|
||||
end;
|
||||
sec_objc_property:
|
||||
begin
|
||||
result:='.section __OBJC, __property, regular, no_dead_strip';
|
||||
exit;
|
||||
end;
|
||||
sec_objc_image_info:
|
||||
begin
|
||||
if (target_info.system in systems_objc_nfabi) then
|
||||
result:='.section __DATA,__objc_imageinfo,regular,no_dead_strip'
|
||||
else
|
||||
result:='.section __OBJC, __image_info, regular, no_dead_strip';
|
||||
exit;
|
||||
end;
|
||||
sec_objc_cstring_object:
|
||||
begin
|
||||
result:='.section __OBJC, __cstring_object, regular, no_dead_strip';
|
||||
exit;
|
||||
end;
|
||||
sec_objc_sel_fixup:
|
||||
begin
|
||||
result:='.section __OBJC, __sel_fixup, regular, no_dead_strip';
|
||||
exit;
|
||||
end;
|
||||
sec_objc_message_refs:
|
||||
begin
|
||||
if (target_info.system in systems_objc_nfabi) then
|
||||
begin
|
||||
result:='.section __DATA, __objc_selrefs, literal_pointers, no_dead_strip';
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
sec_objc_cls_refs:
|
||||
begin
|
||||
if (target_info.system in systems_objc_nfabi) then
|
||||
begin
|
||||
result:='.section __DATA, __objc_clsrefs, regular, no_dead_strip';
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
sec_objc_meth_var_types:
|
||||
begin
|
||||
if (target_info.system in systems_objc_nfabi) then
|
||||
begin
|
||||
result:='.section __TEXT,__objc_methtype,cstring_literals';
|
||||
exit
|
||||
end;
|
||||
end;
|
||||
sec_objc_meth_var_names:
|
||||
begin
|
||||
if (target_info.system in systems_objc_nfabi) then
|
||||
begin
|
||||
result:='.section __TEXT,__objc_methname,cstring_literals';
|
||||
exit
|
||||
end;
|
||||
end;
|
||||
sec_objc_class_names:
|
||||
begin
|
||||
if (target_info.system in systems_objc_nfabi) then
|
||||
begin
|
||||
result:='.section __TEXT,__objc_classname,cstring_literals';
|
||||
exit
|
||||
end;
|
||||
end;
|
||||
sec_objc_inst_meth,
|
||||
sec_objc_cls_meth,
|
||||
sec_objc_cat_inst_meth,
|
||||
sec_objc_cat_cls_meth:
|
||||
begin
|
||||
if (target_info.system in systems_objc_nfabi) then
|
||||
begin
|
||||
result:='.section __DATA, __objc_const';
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
sec_objc_meta_class,
|
||||
sec_objc_class:
|
||||
begin
|
||||
if (target_info.system in systems_objc_nfabi) then
|
||||
begin
|
||||
result:='.section __DATA, __objc_data';
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
sec_objc_sup_refs:
|
||||
begin
|
||||
result:='.section __DATA, __objc_superrefs, regular, no_dead_strip';
|
||||
result:='.section '+objc_section_name(atype);
|
||||
exit
|
||||
end;
|
||||
sec_objc_classlist:
|
||||
begin
|
||||
result:='.section __DATA, __objc_classlist, regular, no_dead_strip';
|
||||
exit
|
||||
end;
|
||||
sec_objc_nlclasslist:
|
||||
begin
|
||||
result:='.section __DATA, __objc_nlclasslist, regular, no_dead_strip';
|
||||
exit
|
||||
end;
|
||||
sec_objc_catlist:
|
||||
begin
|
||||
result:='.section __DATA, __objc_catlist, regular, no_dead_strip';
|
||||
exit
|
||||
end;
|
||||
sec_objc_nlcatlist:
|
||||
begin
|
||||
result:='.section __DATA, __objc_nlcatlist, regular, no_dead_strip';
|
||||
exit
|
||||
end;
|
||||
sec_objc_protolist:
|
||||
begin
|
||||
result:='.section __DATA, __objc_protolist, coalesced, no_dead_strip';
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
result := inherited sectionname(atype,aname,aorder);
|
||||
end;
|
||||
|
229
compiler/objcasm.pas
Normal file
229
compiler/objcasm.pas
Normal file
@ -0,0 +1,229 @@
|
||||
{
|
||||
Copyright (c) 2016 by Jonas Maebe
|
||||
|
||||
This unit implements Objective-C assembler helper routines.
|
||||
|
||||
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.
|
||||
|
||||
****************************************************************************
|
||||
}
|
||||
|
||||
{$i fpcdefs.inc}
|
||||
|
||||
unit objcasm;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
aasmbase;
|
||||
|
||||
function objc_section_name(sec: TObjCAsmSectionType): string;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
verbose,
|
||||
systems;
|
||||
|
||||
function objc_section_name(sec: TObjCAsmSectionType): string;
|
||||
begin
|
||||
result:='';
|
||||
if target_info.system in systems_darwin then
|
||||
case sec of
|
||||
sec_objc_protocol:
|
||||
begin
|
||||
if not(target_info.system in systems_objc_nfabi) then
|
||||
result:='__OBJC, __protocol, regular, no_dead_strip'
|
||||
else
|
||||
internalerror(2015010605);
|
||||
end;
|
||||
sec_objc_protocol_ext:
|
||||
begin
|
||||
result:='__OBJC, __protocol_ext, regular, no_dead_strip';
|
||||
end;
|
||||
sec_objc_category:
|
||||
begin
|
||||
if not(target_info.system in systems_objc_nfabi) then
|
||||
result:='__OBJC, __category, regular, no_dead_strip'
|
||||
else
|
||||
internalerror(2015010606);
|
||||
end;
|
||||
sec_objc_class_ext:
|
||||
begin
|
||||
result:='__OBJC, __class_ext, regular, no_dead_strip';
|
||||
end;
|
||||
sec_objc_property:
|
||||
begin
|
||||
result:='__OBJC, __property, regular, no_dead_strip';
|
||||
end;
|
||||
sec_objc_image_info:
|
||||
begin
|
||||
if target_info.system in systems_objc_nfabi then
|
||||
result:='__DATA, __objc_imageinfo, regular, no_dead_strip'
|
||||
else
|
||||
result:='__OBJC, __image_info, regular, no_dead_strip';
|
||||
end;
|
||||
sec_objc_cstring_object:
|
||||
begin
|
||||
result:='__OBJC, __cstring_object, regular, no_dead_strip';
|
||||
end;
|
||||
sec_objc_sel_fixup:
|
||||
begin
|
||||
result:='__OBJC, __sel_fixup, regular, no_dead_strip';
|
||||
exit;
|
||||
end;
|
||||
sec_objc_message_refs:
|
||||
begin
|
||||
if target_info.system in systems_objc_nfabi then
|
||||
result:='__DATA, __objc_selrefs, literal_pointers, no_dead_strip'
|
||||
else
|
||||
result:='__OBJC, __message_refs, literal_pointers, no_dead_strip';
|
||||
end;
|
||||
sec_objc_symbols:
|
||||
begin
|
||||
if not(target_info.system in systems_objc_nfabi) then
|
||||
result:='__OBJC, __symbols, regular, no_dead_strip'
|
||||
else
|
||||
internalerror(2016010603);
|
||||
end;
|
||||
sec_objc_instance_vars:
|
||||
begin
|
||||
if target_info.system in systems_objc_nfabi then
|
||||
result:='__DATA, __objc_const'
|
||||
else
|
||||
result:=' __OBJC, __instance_vars, regular, no_dead_strip';
|
||||
end;
|
||||
sec_objc_cls_refs:
|
||||
begin
|
||||
if target_info.system in systems_objc_nfabi then
|
||||
result:='__DATA, __objc_clsrefs, regular, no_dead_strip'
|
||||
else
|
||||
result:='__OBJC, __cls_refs, literal_pointers, no_dead_strip';
|
||||
end;
|
||||
sec_objc_meth_var_types:
|
||||
begin
|
||||
if target_info.system in systems_objc_nfabi then
|
||||
result:='__TEXT, __objc_methtype, cstring_literals'
|
||||
else
|
||||
result:='__TEXT, __cstring, cstring_literals';
|
||||
end;
|
||||
sec_objc_meth_var_names:
|
||||
begin
|
||||
if target_info.system in systems_objc_nfabi then
|
||||
result:='__TEXT, __objc_methname, cstring_literals'
|
||||
else
|
||||
result:='__TEXT, __cstring, cstring_literals';
|
||||
end;
|
||||
sec_objc_class_names:
|
||||
begin
|
||||
if target_info.system in systems_objc_nfabi then
|
||||
result:='__TEXT, __objc_classname, cstring_literals'
|
||||
else
|
||||
result:='__TEXT, __cstring, cstring_literals';
|
||||
end;
|
||||
sec_objc_inst_meth:
|
||||
begin
|
||||
if target_info.system in systems_objc_nfabi then
|
||||
result:='__DATA, __objc_const'
|
||||
else
|
||||
result:='__OBJC, __inst_meth, regular, no_dead_strip';
|
||||
end;
|
||||
sec_objc_cls_meth:
|
||||
begin
|
||||
if target_info.system in systems_objc_nfabi then
|
||||
result:='__DATA, __objc_const'
|
||||
else
|
||||
result:='__OBJC, __cls_meth, regular, no_dead_strip';
|
||||
end;
|
||||
sec_objc_cat_inst_meth:
|
||||
begin
|
||||
if target_info.system in systems_objc_nfabi then
|
||||
result:='__DATA, __objc_const'
|
||||
else
|
||||
result:='__OBJC, __cat_inst_meth, regular, no_dead_strip';
|
||||
end;
|
||||
sec_objc_cat_cls_meth:
|
||||
begin
|
||||
if target_info.system in systems_objc_nfabi then
|
||||
result:='__DATA, __objc_const'
|
||||
else
|
||||
result:='__OBJC, __cat_cls_meth, regular, no_dead_strip';
|
||||
end;
|
||||
sec_objc_meta_class:
|
||||
begin
|
||||
if target_info.system in systems_objc_nfabi then
|
||||
result:='__DATA, __objc_const'
|
||||
else
|
||||
result:='__OBJC, __meta_class, regular, no_dead_strip';
|
||||
end;
|
||||
sec_objc_class:
|
||||
begin
|
||||
if target_info.system in systems_objc_nfabi then
|
||||
result:='__DATA, __objc_const'
|
||||
else
|
||||
result:='__OBJC, __class, regular, no_dead_strip';
|
||||
end;
|
||||
sec_objc_sup_refs:
|
||||
begin
|
||||
result:='__DATA, __objc_superrefs, regular, no_dead_strip';
|
||||
end;
|
||||
sec_objc_classlist:
|
||||
begin
|
||||
result:='__DATA, __objc_classlist, regular, no_dead_strip';
|
||||
end;
|
||||
sec_objc_nlclasslist:
|
||||
begin
|
||||
result:='__DATA, __objc_nlclasslist, regular, no_dead_strip';
|
||||
end;
|
||||
sec_objc_catlist:
|
||||
begin
|
||||
result:='__DATA, __objc_catlist, regular, no_dead_strip';
|
||||
end;
|
||||
sec_objc_nlcatlist:
|
||||
begin
|
||||
result:='__DATA, __objc_nlcatlist, regular, no_dead_strip';
|
||||
end;
|
||||
sec_objc_protolist:
|
||||
begin
|
||||
result:='__DATA, __objc_protolist, coalesced, no_dead_strip';
|
||||
end;
|
||||
sec_objc_module_info:
|
||||
begin
|
||||
if not(target_info.system in systems_objc_nfabi) then
|
||||
result:=' __OBJC, __module_info, regular, no_dead_strip'
|
||||
else
|
||||
internalerror(2016010601);
|
||||
end;
|
||||
sec_objc_data:
|
||||
begin
|
||||
result:='__DATA, __objc_data';
|
||||
end;
|
||||
sec_objc_const:
|
||||
begin
|
||||
result:='__DATA, __objc_const';
|
||||
end;
|
||||
sec_data_coalesced:
|
||||
begin
|
||||
result:='__DATA, __datacoal_nt, coalesced';
|
||||
end;
|
||||
else
|
||||
internalerror(2016010101);
|
||||
end
|
||||
else
|
||||
internalerror(2016010102);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user