delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/03/17/17:52:53

Message-ID: <350EF478.C51FE3CB@gmx.net>
Date: Tue, 17 Mar 1998 23:08:56 +0100
From: Robert Hoehne <robert DOT hoehne AT gmx DOT net>
Organization: none provided
MIME-Version: 1.0
To: DJ Delorie <dj AT delorie DOT com>
CC: djgpp-workers AT delorie DOT com
Subject: Re: Bugs in 2.8.0?
References: <199803162334 DOT SAA10647 AT delorie DOT com>

DJ Delorie wrote :
> 
> > The changes will be needed either in crt0.o or in the specs
> > file and then providing additional startup files.
> 
> Can you describe what needs to be added, and how it works?  Then we
> can talk about the best way to add it to djgpp.

Here now the currently needed changes to use the exceptions with
gcc 2.8.0 on DJGPP. Because DJ asked for it, I send it first to
the workers list to get your comments.

At first here a small C source file:

---CUT HERE FILE: crtf.c---------
extern void __EH_FRAME_BEGIN__();
extern void __register_frame_info (void *, void *);

static void __attribute__((constructor))
frame_dummy ()
{
  /* normally this should be a
  struct object {
    void *pc_begin;
    void *pc_end;
    void *fde_begin;
    void **fde_array;
    size_t count;
    struct object *next;
  };
  but a placeholder of the same size does it also */
  static int object[6];

  __register_frame_info (__EH_FRAME_BEGIN__, &object);
}
-----CUT HERE END OF FILE crtf.c-----------

This file simply initializes the exception tables. Since all exception
tables are stored in the .eh_frame section, this gives us the
start of the tables if we link this file as the first object
file.

Compile now the file with

gcc -O -c crtf.c

and then place it in

$DJDIR/lib/gcc-lib/djgpp/2.80/

Now to use the file, we need to modify the specs file, so this
startupfile will be linked in each program

*** lib/specs.ori	Wed Sep 11 21:41:04 1996
--- lib/specs	Tue Mar 17 22:43:00 1998
***************
*** 31,37 ****
  -lc
  
  *startfile:
! %{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}
  
  *switches_need_spaces:
  
--- 31,37 ----
  -lc
  
  *startfile:
! %{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crtf.o%s crt0.o%s}}
  
  *switches_need_spaces:
  

And finally we need also to modify the DJGPP linker script. This
is needed because the linker will add the sections not known via
the builtin or explicit linker script at the end (or as they occour)
of the sections and also the DJGPP stub does not (currently) load
additional sections beside .data .text and .bss and we need also two
labels for the start and the end of the exception tables. The tables are
placed with this in the .data section.

*** lib/djgpp.ori	Sun Sep  8 22:40:06 1996
--- lib/djgpp.djl	Tue Mar 17 22:58:58 1998
***************
*** 15,20 ****
--- 15,25 ----
      *(.dtor)
      djgpp_last_dtor = . ;
      *(.data)
+     *(.gcc_exc)
+     ___EH_FRAME_BEGIN__ = . ;
+     *(.eh_fram)
+     ___EH_FRAME_END__ = . ;
+     LONG(0)
       edata  =  . ; _edata = .;
       . = ALIGN(0x200);
    }

OK, that's all. The above things are meant only as a first
idea. Probably the crtf.c stuff can go in the future in _main.c
and I don't know exactly if we need to deregister the exception
tables (which is normally done with a crtend.o file) but for now
it should work.

PS: Please send you replies not only to the workers list but
also to me since I'm not subscribed to the list.

Robert
-- 
******************************************************
* email:   Robert Hoehne <robert DOT hoehne AT gmx DOT net>     *
* Post:    Am Berg 3, D-09573 Dittmannsdorf, Germany *
* WWW:     http://www.tu-chemnitz.de/~sho/rho        *
******************************************************


- Raw text -


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