.rdata section in Cygwin executables?

2004-03-12 Thread Joe Buehler
The emacs recompile fails because there is a section in
the initially built emacs.exe named .rdata that the
unexec() code for Cygwin is not expecting.  The section
appears to have something to do with exception handling
and is only 1k in size.
I'm reading up on this at the moment, but a couple
questions occur to me that someone here might be able
to answer off the top of their head:
- can .rdata just be combined with the preceeding .data
  section?
- perhaps there is a way to do this with the linker so
  I don't have to change the emacs unexec() code?
--
Joe Buehler


Re: .rdata section in Cygwin executables?

2004-03-12 Thread Egor Duda
Joe Buehler wrote:
The emacs recompile fails because there is a section in
the initially built emacs.exe named .rdata that the
unexec() code for Cygwin is not expecting.  The section
appears to have something to do with exception handling
and is only 1k in size.
.rdata is a section where read-only data, such as constants, is stored.
Most modern OSes and toolchain try to put as much info as possible to
read-only segments of binary image because it reduce memory required by
programs to run (when program is fork()ed, for instance, read-only pages 
may be shared between processes)

On linux such section is called .rodata, so probably you can take a look 
how linux version of emacs deals with that.

I'm reading up on this at the moment, but a couple
questions occur to me that someone here might be able
to answer off the top of their head:
- can .rdata just be combined with the preceeding .data
  section?
It's possible, but it's not the Right Way (tm).

- perhaps there is a way to do this with the linker so
  I don't have to change the emacs unexec() code?
You may write your own linker script so that all rdata section will be 
put to .data when emacs.exe is linked, but again, it doesn't look as the 
proper way to deal with the problem.

egor.


Re: .rdata section in Cygwin executables?

2004-03-12 Thread Joe Buehler
Egor Duda wrote:

You may write your own linker script so that all rdata section will be 
put to .data when emacs.exe is linked, but again, it doesn't look as the 
proper way to deal with the problem.
According to objdump, there is no readonly flag set for .rdata.

Does Windows know about the name .rdata and know that only one copy
is needed for multiple emacs processes?  Or perhaps Cygwin knows
about the name for similar reasons?
Or perhaps (gasp) the implementation is not currently complete
and .rdata buys me nothing at present?
Thanks for the feedback -- I am looking for something easy to do
here to get the existing 21.2 emacs back in shape for Cygwin.
I already need to rewrite unexec() for the FSF version for
copyright reasons and don't really want to spend any time on the
current unexec() code -- it's throwaway at some point.
--
Joe Buehler


Re: .rdata section in cygwin executables?

2004-03-12 Thread Christopher Faylor
On Fri, Mar 12, 2004 at 10:28:02AM -0500, Joe Buehler wrote:
Egor Duda wrote:
You may write your own linker script so that all rdata section will be
put to .data when emacs.exe is linked, but again, it doesn't look as
the proper way to deal with the problem.

According to objdump, there is no readonly flag set for .rdata.

Try a binutils from CVS.  There was some funkiness with readonly flags
in binutils.  I don't know if it infects the cygwin version of binutils
or not.

I keep rebuilding binutils in preparation for a new release but that
effort invariably triggers someone sending an interesting new bug or
bugfix to the binutils mailing list so I have been waiting for the code
to settle down.

cgf


Re: .rdata section in Cygwin executables?

2004-03-12 Thread Ralf Habacker
On Friday 12 March 2004 15:51, Egor Duda wrote:
 Joe Buehler wrote:
  The emacs recompile fails because there is a section in
  the initially built emacs.exe named .rdata that the
  unexec() code for Cygwin is not expecting.  The section
  appears to have something to do with exception handling
  and is only 1k in size.

 .rdata is a section where read-only data, such as constants, is stored.
 Most modern OSes and toolchain try to put as much info as possible to
 read-only segments of binary image because it reduce memory required by
 programs to run (when program is fork()ed, for instance, read-only pages
 may be shared between processes)

In case of using gcc 3.3x and using auto-imported vars, you should use the 
'-fdata-sections' flags for compiling sources because otherwise these 
variables are not detected as variables. See 
http://sources.redhat.com/ml/binutils/2003-10/msg00256.html for more infos. 

Just a note. 

Ralf