Solved

Putting 32 bit code into different sections

Posted on 1998-08-24
2
211 Views
Last Modified: 2010-04-01
How do I tell the compiler to put a function (or group of functions) into a specific named PE file section?

The default is for code to go into the .text section. I want to put some routines into a .txt1 section and some others into a .txt2 section.

I am using Microsoft Developer Studio (MSVC++ 4.1)
0
Comment
Question by:icd
2 Comments
 
LVL 2

Accepted Solution

by:
warmcat earned 200 total points
ID: 1171060
data_seg
#pragma data_seg( ["section-name"[, "section-class"] ] )

Specifies the default section for data. For example:




#pragma data_seg( "MY_DATA" )
causes data allocated following the #pragma statement to be placed in a section called MY_DATA.

Data allocated using the data_seg pragma does not retain any information about its location.

The second parameter, section-class, is included for compatibilty with versions of Visual C++ prior to version 2.0, and is now ignored.

. and ...

code_seg
#pragma code_seg( ["section-name"[,"section-class"] ] )

Specifies a code section where functions are to be allocated. The code_seg pragma specifies the default section for functions. You can, optionally, specify the class as well as the section name. Using #pragma code_seg without a section-name string resets allocation to whatever it was when compilation began.

. and ...

const_seg
#pragma const_seg( ["section-name"[, "section-class"] ] )

Specifies the default section for constant data. The data_seg pragma has the same effect but works with all data. You can use this pragma to put all your constant data in one read-only section.




#pragma const_seg( "MY_DATA" )
causes constant data allocated following the #pragma statement to be placed in a section called MY_DATA.

Data allocated using the const_seg pragma does not retain any information about its location.

The second parameter, section-class, is included for compatibilty with versions of Visual C++ prior to version 2.0, and is now ignored.


0
 
LVL 5

Author Comment

by:icd
ID: 1171061
Sorry for the delay in grading your excellent answer. It seems I did not receive notification by email!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question