delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/12/27/16:05:11

From: Laurence Withers <lwithers AT lwithers DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: The DXE mechanism - has anybody used it effectively?
Date: Sun, 27 Dec 1998 19:33:13 +0000
Organization: IP
Message-ID: <VnZKGBA5toh2EA4W@lwithers.demon.co.uk>
References: <zG6T+BAzLpg2EAn$@lwithers.demon.co.uk>
<Pine DOT SUN DOT 3 DOT 91 DOT 981227131519 DOT 113I-100000 AT is>
NNTP-Posting-Host: lwithers.demon.co.uk
X-NNTP-Posting-Host: lwithers.demon.co.uk:194.222.80.1
X-Trace: news.demon.co.uk 914792393 nnrp-11:9071 NO-IDENT lwithers.demon.co.uk:194.222.80.1
X-Complaints-To: abuse AT demon DOT net
MIME-Version: 1.0
X-Newsreader: Turnpike (32) Version 4.00 <WCcCG$mmNL32sYSf46vBeC80CR>
Lines: 72
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

--- Original Message ---
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
Time: Sun, 27 Dec 1998, 13:18:58

[snip]
>> Error: input file has more than one section; use -M for map
>> 
>> Unfortunately, this doesn't mean anything to me :-(
>
>This means what it says: that the produced file a-dxe.o has more than a 
>single section.

Yes, but 'section' is a bit ambiguous, isn't it?

>Does the same work for a C code?  If it does, chances are that the 
>additional section is due to the way C++ exceptions are supported.  (That 
>hint about -M option is there for you to follow it, you know ;-). 

It does work for the equivalent C code. I tried -M and it printed some
sort of map. Not that I understood it, of course...

> In 
>that case, try invoking gcc with the -fno-exceptions option (I hope I 
>spell the option right) and see if that helps.

It does indeed! The file now seems to work correctly, and a DXE file is
generated. However, the C++ file *calling* the DXE now falls over when I
try to link to an .exe; it gives the error:

a-main.o(.text+0x19):a-main.cpp: undefined reference to `_dxe_load(char
*)'
make.exe: *** [a.exe] Error 1

[sorry about word-wrap]

Hrm. However, if I then write the DXE in C++, and the caller in C, the
linking process works fine and the DXE works correctly!

[some time passes]

OK, so now I have:

 - a main() function in C++, which calls the DxeLoad() function...

 - ... which is in another object file, this time a C file.

 - a .DXE generated from two C++ files

The DXE cannot use exceptions. It can use global objects, but only if
they don't have constructors. It can, however, use objects with
constructors/destructors in general. It cannot use the new, delete or
delete [] operators.

The lack of new/delete operators makes the DXE pretty useless (for me at
least; most of my C++ code uses dynamic memory). However, I can get
around it by overloading the operators and importing the malloc() and
free() libc functions.

I can also get around the ctor/dtor problem in an inelegant way; the DXE
provides startup/shutdown functions, which will have to call init() and
deinit() methods in the objects.

If anybody knows of more elegant solutions (not that I need them; this
setup is fine for me) I'd be happy to hear from you.

For now, thanks very much for your time, effort, and patience.

Bye for now,
-- 
Laurence Withers, mailto:lwithers AT lwithers DOT demon DOT co DOT uk
Integrated Peripherals Operating System Project Leader || OPES Project
Projects' homepage is at: http://www.lwithers.demon.co.uk/       Leader

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019