Solved

Putting 32 bit code into different sections

Posted on 1998-08-24
2
210 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
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…
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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

816 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now