mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 11:11:44 +00:00
[NDK][NTOS] Add global definition of INIT_FUNCTION/INIT_SECTION (#779)
* Add an NDK header to define INIT_FUNCTION/INIT_SECTION globally * Use _declspec(allocate(x)) and _declspec(code_seg(x)) on MSVC versions that support it * Use INIT_FUNCTION on functions only and INIT_SECTION on data only (required by MSVC) * Place INIT_FUNCTION before the return type (required by MSVC) * Make sure declarations and implementations share the same modifiers (required by MSVC) * Add a global linker option to suppress warnings about defined but unused INIT section * Merge INIT section into .text in freeldr
This commit is contained in:
parent
7c66247343
commit
71fefa32db
108 changed files with 522 additions and 296 deletions
|
@ -139,9 +139,9 @@ if(RUNTIME_CHECKS)
|
|||
add_compile_flags("/RTC1")
|
||||
endif()
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE ${_hotpatch_link_flag}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE /IGNORE:4104 ${_hotpatch_link_flag}")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE ${_hotpatch_link_flag}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE ${_hotpatch_link_flag} /IGNORE:4039")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE ${_hotpatch_link_flag} /IGNORE:4104 /IGNORE:4039")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE ${_hotpatch_link_flag} /IGNORE:4039")
|
||||
|
||||
# HACK: Remove the /implib argument, implibs are generated separately
|
||||
string(REPLACE "/implib:<TARGET_IMPLIB>" "" CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE}")
|
||||
|
|
|
@ -25,6 +25,7 @@ Author:
|
|||
#include <umtypes.h>
|
||||
#include <haltypes.h>
|
||||
#include <ketypes.h>
|
||||
#include <section_attribs.h>
|
||||
|
||||
#ifndef NTOS_MODE_USER
|
||||
|
||||
|
@ -80,6 +81,7 @@ HalInitializeProcessor(
|
|||
_In_ struct _LOADER_PARAMETER_BLOCK *LoaderBlock
|
||||
);
|
||||
|
||||
INIT_FUNCTION
|
||||
NTHALAPI
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
|
@ -175,6 +177,7 @@ HalGetInterruptSource(
|
|||
);
|
||||
#endif
|
||||
|
||||
INIT_FUNCTION
|
||||
NTHALAPI
|
||||
VOID
|
||||
NTAPI
|
||||
|
|
|
@ -24,6 +24,7 @@ Author:
|
|||
//
|
||||
#include <umtypes.h>
|
||||
#include <inbvtypes.h>
|
||||
#include <section_attribs.h>
|
||||
|
||||
#ifndef NTOS_MODE_USER
|
||||
//
|
||||
|
@ -50,6 +51,7 @@ InbvNotifyDisplayOwnershipLost(
|
|||
//
|
||||
// Installation Functions
|
||||
//
|
||||
INIT_FUNCTION
|
||||
VOID
|
||||
NTAPI
|
||||
InbvEnableBootDriver(
|
||||
|
|
|
@ -24,6 +24,7 @@ Author:
|
|||
//
|
||||
#include <umtypes.h>
|
||||
#include <ketypes.h>
|
||||
#include <section_attribs.h>
|
||||
|
||||
#ifndef NTOS_MODE_USER
|
||||
|
||||
|
@ -244,6 +245,7 @@ KeSignalCallDpcSynchronize(
|
|||
// ARC Configuration Functions. Only enabled if you have ARC Support
|
||||
//
|
||||
#ifdef _ARC_
|
||||
INIT_FUNCTION
|
||||
PCONFIGURATION_COMPONENT_DATA
|
||||
NTAPI
|
||||
KeFindConfigurationNextEntry(
|
||||
|
@ -254,6 +256,7 @@ KeFindConfigurationNextEntry(
|
|||
_In_ PCONFIGURATION_COMPONENT_DATA *NextLink
|
||||
);
|
||||
|
||||
INIT_FUNCTION
|
||||
PCONFIGURATION_COMPONENT_DATA
|
||||
NTAPI
|
||||
KeFindConfigurationEntry(
|
||||
|
|
41
sdk/include/ndk/section_attribs.h
Normal file
41
sdk/include/ndk/section_attribs.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*++ NDK Version: 0099
|
||||
|
||||
Copyright (c) Alex Ionescu. All rights reserved.
|
||||
|
||||
Header Name:
|
||||
|
||||
section_attribs.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Preprocessor definitions to put code and data into the INIT section.
|
||||
|
||||
Author:
|
||||
|
||||
Timo Kreuzer (timo.kreuzer@reactos.org)
|
||||
|
||||
--*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
#define INIT_SECTION __attribute__((section ("INIT")))
|
||||
#define INIT_FUNCTION __attribute__((section ("INIT")))
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
|
||||
#pragma comment(linker, "/SECTION:INIT,ERW")
|
||||
#define INIT_SECTION __declspec(allocate("INIT"))
|
||||
#if (_MSC_VER >= 1800) // Visual Studio 2013 / version 12.0
|
||||
#define INIT_FUNCTION __declspec(code_seg("INIT"))
|
||||
#else
|
||||
#pragma section("INIT", read,execute,discard)
|
||||
#define INIT_FUNCTION
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#error Invalid compiler!
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue