diff options
author | jonas <jonas@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2015-09-14 16:10:51 +0000 |
---|---|---|
committer | jonas <jonas@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2015-09-14 16:10:51 +0000 |
commit | aa511bb3437f4bb0f93c1b34704862ce46cf8b55 (patch) | |
tree | 3114e6de37e0692366c7da41a1757f2be6214daa /compiler | |
parent | e7b55bc4df2fb0cc339d43a17a433b3fad60ca8c (diff) | |
download | fpc-aa511bb3437f4bb0f93c1b34704862ce46cf8b55.tar.gz |
+ new tcalo_no_dead_strip flag for the high level typed const builder to
indicate symbols that should never be removed by the linker
o TODO for llvm, needs support for the @llvm.used array (only used for
the compiler ident, so it's not that important
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@31677 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/aasmcnst.pas | 22 | ||||
-rw-r--r-- | compiler/llvm/nllvmtcon.pas | 1 |
2 files changed, 21 insertions, 2 deletions
diff --git a/compiler/aasmcnst.pas b/compiler/aasmcnst.pas index a1d34a3bb1..89c857e439 100644 --- a/compiler/aasmcnst.pas +++ b/compiler/aasmcnst.pas @@ -113,7 +113,9 @@ type { this symbol is the start of a block of data that should be dead-stripable/smartlinkable; may imply starting a new section, but not necessarily (depends on what the platform requirements are) } - tcalo_make_dead_strippable + tcalo_make_dead_strippable, + { this symbol should never be removed by the linker } + tcalo_no_dead_strip ); ttcasmlistoptions = set of ttcasmlistoption; @@ -865,7 +867,11 @@ implementation prelist:=tasmlist.create; { only now add items based on the symbolname, because it may be modified by the "section" specifier in case of a typed constant } - if tcalo_make_dead_strippable in options then + + { both in case the data should be dead strippable and never dead + stripped, it should be in a separate section (so this property doesn't + affect other data) } + if ([tcalo_no_dead_strip,tcalo_make_dead_strippable]*options)<>[] then begin maybe_new_object_file(prelist); { we always need a new section here, since if we started a new @@ -877,6 +883,18 @@ implementation new_section(prelist,section,secname,const_align(alignment)) else prelist.concat(cai_align.Create(const_align(alignment))); + + { On Darwin, use .reference to ensure the data doesn't get dead stripped. + On other platforms, the data must be in the .fpc section (which is + kept via the linker script) } + if tcalo_no_dead_strip in options then + begin + if target_info.system in systems_darwin then + prelist.concat(tai_directive.Create(asd_reference,sym.name)) + else if section<>sec_fpc then + internalerror(2015101402); + end; + if not(tcalo_is_lab in options) then if sym.bind=AB_GLOBAL then prelist.concat(tai_symbol.Create_Global(sym,0)) diff --git a/compiler/llvm/nllvmtcon.pas b/compiler/llvm/nllvmtcon.pas index 7819db4339..76354a3a90 100644 --- a/compiler/llvm/nllvmtcon.pas +++ b/compiler/llvm/nllvmtcon.pas @@ -171,6 +171,7 @@ implementation decl:=taillvmdecl.createdef(sym,def,fasmlist,section,alignment); if tcalo_is_lab in options then include(decl.flags,ldf_unnamed_addr); + { TODO: tcalo_no_dead_strip: add to @llvm.user meta-variable } newasmlist.concat(decl); fasmlist:=newasmlist; end; |