is it possible to retrieve section header addresses?

is it possible to retrieve section header addresses?

I?m porting my OS over to C++ (from assembly), and wanted to know if there is anyway to get the address and size of the ?.text?, ?.data?, and ?.data1? sections inserted into a variable at compile time. It?s a cinch to do in MASM but I?m having difficulty in C++, any suggestions.

linux uses the following code to address the various sections:
extern char _text, _etext, _edata, __bss_start, _end;

A last resort would have my PE loader store the section header along with the ?image base? variable and pass it during load of the executable to memory.

I?m using the Intel C++ 7.0 Compiler for Windows (updated as of today)

Thanks for any help,
Jeremy

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Not sure. How do you do this in masm? Could you use inline asm in C++ to do the same. Perhaps some things are best left in asm.

Max

> Not sure. How do you do this in masm?

define labels at the start and end of the .data, .data?, and .code segments, see the attached code and disassembly

> Could you use inline asm in C++ to do the same.

the closest thing I?ve come up with is defining static variables but since .data1 is used to initialize local (stack) variables, I can't assign a start/end, (or can i?)

> Perhaps some things are best left in asm.

Looks like it, Premier Support suggested I ask my question here.

Sorry, I don't think I can provide any further thoughts other than ask, How does Linux provide this functionality?

Max

Leave a Comment

Please sign in to add a comment. Not a member? Join today