| 1 |
// Run-time support for retrieving platform-specific sections. |
| 2 |
// Copyright (C) 2019-2025 Free Software Foundation, Inc. |
| 3 |
|
| 4 |
// GCC is free software; you can redistribute it and/or modify it under |
| 5 |
// the terms of the GNU General Public License as published by the Free |
| 6 |
// Software Foundation; either version 3, or (at your option) any later |
| 7 |
// version. |
| 8 |
|
| 9 |
// GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
| 10 |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 |
// for more details. |
| 13 |
|
| 14 |
// Under Section 7 of GPL version 3, you are granted additional |
| 15 |
// permissions described in the GCC Runtime Library Exception, version |
| 16 |
// 3.1, as published by the Free Software Foundation. |
| 17 |
|
| 18 |
// You should have received a copy of the GNU General Public License and |
| 19 |
// a copy of the GCC Runtime Library Exception along with this program; |
| 20 |
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 21 |
// <http://www.gnu.org/licenses/>. |
| 22 |
|
| 23 |
module gcc.sections; |
| 24 |
|
| 25 |
version (CRuntime_Glibc) version = SectionsElf; |
| 26 |
version (CRuntime_Musl) version = SectionsElf; |
| 27 |
version (CRuntime_UClibc) version = SectionsElf; |
| 28 |
version (FreeBSD) version = SectionsElf; |
| 29 |
version (NetBSD) version = SectionsElf; |
| 30 |
version (OpenBSD) version = SectionsElf; |
| 31 |
version (DragonFlyBSD) version = SectionsElf; |
| 32 |
version (Solaris) version = SectionsElf; |
| 33 |
version (OSX) version = SectionsMacho; |
| 34 |
version (Windows) version = SectionsPeCoff; |
| 35 |
|
| 36 |
version (SectionsElf) |
| 37 |
public import gcc.sections.elf; |
| 38 |
else version (SectionsMacho) |
| 39 |
public import gcc.sections.macho; |
| 40 |
else version (SectionsPeCoff) |
| 41 |
public import gcc.sections.pecoff; |
| 42 |
else |
| 43 |
static assert(0, "unimplemented"); |
| 44 |
|
| 45 |
import core.internal.traits : externDFunc; |
| 46 |
|
| 47 |
version (Shared) |
| 48 |
{ |
| 49 |
// interface for core.thread.osthread to inherit loaded libraries |
| 50 |
pragma(mangle, externDFunc!("rt.sections_elf_shared.pinLoadedLibraries", |
| 51 |
void* function() @nogc nothrow).mangleof) |
| 52 |
void* pinLoadedLibraries() @nogc nothrow; |
| 53 |
|
| 54 |
pragma(mangle, externDFunc!("rt.sections_elf_shared.unpinLoadedLibraries", |
| 55 |
void function(void*) @nogc nothrow).mangleof) |
| 56 |
void unpinLoadedLibraries(void* p) @nogc nothrow; |
| 57 |
|
| 58 |
pragma(mangle, externDFunc!("rt.sections_elf_shared.inheritLoadedLibraries", |
| 59 |
void function(void*) @nogc nothrow).mangleof) |
| 60 |
void inheritLoadedLibraries(void* p) @nogc nothrow; |
| 61 |
|
| 62 |
pragma(mangle, externDFunc!("rt.sections_elf_shared.cleanupLoadedLibraries", |
| 63 |
void function() @nogc nothrow).mangleof) |
| 64 |
void cleanupLoadedLibraries() @nogc nothrow; |
| 65 |
} |
| 66 |
|
| 67 |
version (SectionsElf) |
| 68 |
{ |
| 69 |
// interface for core.thread.osthread to adjust stack size |
| 70 |
pragma(mangle, externDFunc!("rt.sections_elf_shared.sizeOfTLS", |
| 71 |
size_t function() @nogc nothrow).mangleof) |
| 72 |
size_t sizeOfTLS() @nogc nothrow; |
| 73 |
} |