Solved

Putting 32 bit code into different sections

Posted on 1998-08-24
2
204 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
Comment Utility
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
Comment Utility
Sorry for the delay in grading your excellent answer. It seems I did not receive notification by email!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

772 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

12 Experts available now in Live!

Get 1:1 Help Now