1 /** 2 * 3 * Copyright: Copyright Digital Mars 2000 - 2012. 4 * License: Distributed under the 5 * $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0). 6 * (See accompanying file LICENSE) 7 * Authors: Walter Bright, Sean Kelly, Martin Nowak 8 * Source: $(DRUNTIMESRC src/rt/_sections.d) 9 */ 10 11 /* NOTE: This file has been patched from the original DMD distribution to 12 * work with the GDC compiler. 13 */ 14 module rt.sections; 15 16 version (OSX) 17 version = Darwin; 18 else version (iOS) 19 version = Darwin; 20 else version (TVOS) 21 version = Darwin; 22 else version (WatchOS) 23 version = Darwin; 24 25 version (GNU) 26 public import gcc.sections; 27 else version (CRuntime_Glibc) 28 public import rt.sections_elf_shared; 29 else version (FreeBSD) 30 public import rt.sections_elf_shared; 31 else version (NetBSD) 32 public import rt.sections_elf_shared; 33 else version (Solaris) 34 public import rt.sections_solaris; version(Darwin)35else version (Darwin) 36 { 37 version (X86_64) 38 public import rt.sections_osx_x86_64; 39 else version (X86) 40 public import rt.sections_osx_x86; 41 else 42 static assert(0, "unimplemented"); 43 } 44 else version (CRuntime_DigitalMars) 45 public import rt.sections_win32; 46 else version (CRuntime_Microsoft) 47 public import rt.sections_win64; 48 else version (CRuntime_Bionic) 49 public import rt.sections_android; 50 else 51 static assert(0, "unimplemented"); 52 53 import rt.deh, rt.minfo; 54 isSectionGroup(T)55template isSectionGroup(T) 56 { 57 enum isSectionGroup = 58 is(typeof(T.init.modules) == immutable(ModuleInfo*)[]) && 59 is(typeof(T.init.moduleGroup) == ModuleGroup) && 60 (!is(typeof(T.init.ehTables)) || is(typeof(T.init.ehTables) == immutable(FuncTable)[])) && 61 is(typeof(T.init.gcRanges) == void[][]) && 62 is(typeof({ foreach (ref T; T) {}})) && 63 is(typeof({ foreach_reverse (ref T; T) {}})); 64 } 65 static assert(isSectionGroup!(SectionGroup)); 66 static assert(is(typeof(&initSections) == void function() nothrow @nogc)); 67 static assert(is(typeof(&finiSections) == void function() nothrow @nogc)); 68 static assert(is(typeof(&initTLSRanges) RT == return) && 69 is(typeof(&initTLSRanges) == RT function() nothrow @nogc) && 70 is(typeof(&finiTLSRanges) == void function(RT) nothrow @nogc) && 71 is(typeof(&scanTLSRanges) == void function(RT, scope void delegate(void*, void*) nothrow) nothrow)); 72 version(Shared)73version (Shared) 74 { 75 static assert(is(typeof(&pinLoadedLibraries) == void* function() nothrow @nogc)); 76 static assert(is(typeof(&unpinLoadedLibraries) == void function(void*) nothrow @nogc)); 77 static assert(is(typeof(&inheritLoadedLibraries) == void function(void*) nothrow @nogc)); 78 static assert(is(typeof(&cleanupLoadedLibraries) == void function() nothrow @nogc)); 79 } 80 scanDataSegPrecisely()81bool scanDataSegPrecisely() nothrow @nogc 82 { 83 import rt.config; 84 string opt = rt_configOption("scanDataSeg"); 85 switch (opt) 86 { 87 case "": 88 case "conservative": 89 return false; 90 case "precise": 91 return true; 92 default: 93 __gshared err = new Error("DRT invalid scanDataSeg option, must be 'precise' or 'conservative'"); 94 throw err; 95 } 96 } 97