This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
egcs patches for BSD/OS 4.0
- To: egcs-patches at cygnus dot com
- Subject: egcs patches for BSD/OS 4.0
- From: Shigeya Suzuki <shigeya at foretune dot co dot jp>
- Date: Thu, 01 Oct 1998 15:43:00 +0900
- Cc: bsdi-tech at foretune dot co dot jp
- Cc: donn at bsdi dot com
Following, diffs and several mods against snapshot 98/9/21, to
(partially) support BSD/OS 4.0 (ELF)
I still have problem with exception handling (which cause 70+
unexpected errors) but other part, for at lest C and C++ is working,
on i486 configuration. (i386 is not working due to some bug, as
reported.)
1. {gcc/config/i386/}bsdi-elf.h is newly created file.
(temporarly MASK_NO_FANCY_MATH_387 disabled. due to it conflict
to configure with i486)
It still needs clean-up. But at least it is working.
2. patch to configure.in, which uses above config on bsdi4.x.
3. stddef.h need patch -- I provided patch for stddef.h to make it
work on BSD/OS 3.x several months ago, but now, this change cause
failure on BSD/OS 4.0, so I introduced version checking.
4. patch to libio/gen-params. I'm using gcc 2.7.2.1 (comes with
BSD/OS), and libio can't build without this patch on BSD/OS, since
_G_u?llong is not decleared for gcc 2.7.x.
5. patches in libio/isscan.cc, etc. to use _IO_va_list not va_list
I don't know why this happend. I compile only C and C++ with
LANGUAGES="c c++". does this cause libio NOT to be built with the
egcs gcc just built?
Hope these be incorported in tree..
Shigeya Suzuki
/* Configuration for an i386 running BSDI's BSD/OS (formerly known as BSD/386)
as the target machine. using ELF binary based on:
Definitions for Intel 386 running FreeBSD with ELF format
Copyright (C) 1996 Free Software Foundation, Inc.
Contributed by Eric Youngdale.
Modified for stabs-in-ELF by H.J. Lu.
Adapted from GNU/Linux version by John Polstra.
This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU CC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#undef TARGET_VERSION
#define TARGET_VERSION fprintf (stderr, " (i386 ELF BSD/OS)");
/* The svr4 ABI for the i386 says that records and unions are returned
in memory. */
#undef DEFAULT_PCC_STRUCT_RETURN
#define DEFAULT_PCC_STRUCT_RETURN 1
/* This is how to output an element of a case-vector that is relative.
This is only used for PIC code. See comments by the `casesi' insn in
i386.md for an explanation of the expression this outputs. */
#undef ASM_OUTPUT_ADDR_DIFF_ELT
#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE)
/* Indicate that jump tables go in the text section. This is
necessary when compiling PIC code. */
#define JUMP_TABLES_IN_TEXT_SECTION (flag_pic)
/* Copy this from the svr4 specifications... */
/* Define the register numbers to be used in Dwarf debugging information.
The SVR4 reference port C compiler uses the following register numbers
in its Dwarf output code:
0 for %eax (gnu regno = 0)
1 for %ecx (gnu regno = 2)
2 for %edx (gnu regno = 1)
3 for %ebx (gnu regno = 3)
4 for %esp (gnu regno = 7)
5 for %ebp (gnu regno = 6)
6 for %esi (gnu regno = 4)
7 for %edi (gnu regno = 5)
The following three DWARF register numbers are never generated by
the SVR4 C compiler or by the GNU compilers, but SDB on x86/svr4
believes these numbers have these meanings.
8 for %eip (no gnu equivalent)
9 for %eflags (no gnu equivalent)
10 for %trapno (no gnu equivalent)
It is not at all clear how we should number the FP stack registers
for the x86 architecture. If the version of SDB on x86/svr4 were
a bit less brain dead with respect to floating-point then we would
have a precedent to follow with respect to DWARF register numbers
for x86 FP registers, but the SDB on x86/svr4 is so completely
broken with respect to FP registers that it is hardly worth thinking
of it as something to strive for compatibility with.
The version of x86/svr4 SDB I have at the moment does (partially)
seem to believe that DWARF register number 11 is associated with
the x86 register %st(0), but that's about all. Higher DWARF
register numbers don't seem to be associated with anything in
particular, and even for DWARF regno 11, SDB only seems to under-
stand that it should say that a variable lives in %st(0) (when
asked via an `=' command) if we said it was in DWARF regno 11,
but SDB still prints garbage when asked for the value of the
variable in question (via a `/' command).
(Also note that the labels SDB prints for various FP stack regs
when doing an `x' command are all wrong.)
Note that these problems generally don't affect the native SVR4
C compiler because it doesn't allow the use of -O with -g and
because when it is *not* optimizing, it allocates a memory
location for each floating-point variable, and the memory
location is what gets described in the DWARF AT_location
attribute for the variable in question.
Regardless of the severe mental illness of the x86/svr4 SDB, we
do something sensible here and we use the following DWARF
register numbers. Note that these are all stack-top-relative
numbers.
11 for %st(0) (gnu regno = 8)
12 for %st(1) (gnu regno = 9)
13 for %st(2) (gnu regno = 10)
14 for %st(3) (gnu regno = 11)
15 for %st(4) (gnu regno = 12)
16 for %st(5) (gnu regno = 13)
17 for %st(6) (gnu regno = 14)
18 for %st(7) (gnu regno = 15)
*/
#undef DBX_REGISTER_NUMBER
#define DBX_REGISTER_NUMBER(n) \
((n) == 0 ? 0 \
: (n) == 1 ? 2 \
: (n) == 2 ? 1 \
: (n) == 3 ? 3 \
: (n) == 4 ? 6 \
: (n) == 5 ? 7 \
: (n) == 6 ? 5 \
: (n) == 7 ? 4 \
: ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3 \
: (-1))
/* Output assembler code to FILE to increment profiler label # LABELNO
for profiling a function entry. */
#undef FUNCTION_PROFILER
#define FUNCTION_PROFILER(FILE, LABELNO) \
{ \
if (flag_pic) \
{ \
fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n", \
LPREFIX, (LABELNO)); \
fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n"); \
} \
else \
{ \
fprintf (FILE, "\tmovl $%sP%d,%%edx\n", LPREFIX, (LABELNO)); \
fprintf (FILE, "\tcall mcount\n"); \
} \
}
#undef SIZE_TYPE
#define SIZE_TYPE "unsigned int"
#undef PTRDIFF_TYPE
#define PTRDIFF_TYPE "int"
#undef WCHAR_TYPE
#define WCHAR_TYPE "int"
#undef WCHAR_UNSIGNED
#define WCHAR_UNSIGNED 0
#undef WCHAR_TYPE_SIZE
#define WCHAR_TYPE_SIZE 32
/* In FreeBSD.. */
/* #undef WCHAR_TYPE_SIZE */
/* #define WCHAR_TYPE_SIZE BITS_PER_WORD */
/* Don't assume anything about the header files. */
/* (not actually used on bsdi, but should generally be on anyway) */
#define NO_IMPLICIT_EXTERN_C
/* Emulator does not handle sqrt, sin, cos; default to library */
#if 0
#undef TARGET_CPU_DEFAULT
#define TARGET_CPU_DEFAULT MASK_NO_FANCY_MATH_387
#endif
#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
/* Oddly enough, Linux's header seems closer to SVr4 than the SVr4 header. */
/* #include "linux.h" */
/* We exist mostly to add -Dbsdi and such to the predefines. */
#undef CPP_PREDEFINES
#define CPP_PREDEFINES "-Dunix -D__i386__ -Di386 -D__bsdi__ -Dbsdi -D__ELF__ -Asystem(unix) -Asystem(bsd) -Acpu(i386) -Amachine(i386)"
#undef CPP_SPEC
#define CPP_SPEC "%(cpp_cpu) %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}"
/* This is suitable for BSD/OS 3.0; we don't know about earlier releases. */
#undef ASM_COMMENT_START
#define ASM_COMMENT_START " #"
#undef LIB_SPEC
#define LIB_SPEC "%{!shared: %{pg:-lc_p}%{!pg:%{p:-lc_p}%{!p:-lc}}}"
/* Provide a LINK_SPEC appropriate for FreeBSD. Here we provide support
for the special GCC options -static and -shared, which allow us to
link things in one of these three modes by applying the appropriate
combinations of options at link-time. We like to support here for
as many of the other GNU linker options as possible. But I don't
have the time to search for those flags. I am sure how to add
support for -soname shared_object_name. H.J.
I took out %{v:%{!V:-V}}. It is too much :-(. They can use
-Wl,-V.
When the -shared link option is used a final link is not being
done. */
#undef LINK_SPEC
#define LINK_SPEC "-m elf_i386 %{shared:-shared} \
%{!shared: \
%{!static: \
%{rdynamic:-export-dynamic} \
%{!dynamic-linker:-dynamic-linker /shlib/ld-bsdi.so}} \
%{static:-static}}"
/* Get perform_* macros to build libgcc.a. */
/* #include "i386/perform.h" */
/* A C statement (sans semicolon) to output to the stdio stream
FILE the assembler definition of uninitialized global DECL named
NAME whose size is SIZE bytes and alignment is ALIGN bytes.
Try to use asm_output_aligned_bss to implement this macro. */
#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
/* A C statement to output to the stdio stream FILE an assembler
command to advance the location counter to a multiple of 1<<LOG
bytes if it is within MAX_SKIP bytes.
This is used to align code labels according to Intel recommendations. */
#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \
if ((LOG)!=0) \
if ((MAX_SKIP)==0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \
else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP))
#endif
#if 0
/* Until they use ELF or something that handles dwarf2 unwinds
and initialization stuff better. */
#define DWARF2_UNWIND_INFO 0
/* BSD/OS still uses old binutils that don't insert nops by default
when the .align directive demands to insert extra space in the text
segment. */
#undef ASM_OUTPUT_ALIGN
#define ASM_OUTPUT_ALIGN(FILE,LOG) \
if ((LOG)!=0) fprintf ((FILE), "\t.align %d,0x90\n", (LOG))
#endif
Index: gcc/configure.in
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/configure.in,v
retrieving revision 1.162
diff -c -r1.162 configure.in
*** configure.in 1998/09/24 02:44:53 1.162
--- configure.in 1998/10/01 05:58:37
***************
*** 971,976 ****
--- 971,986 ----
tmake_file=i386/t-i386bare
;;
changequote(,)dnl
+ i[34567]86-*-bsdi4*)
+ changequote([,])dnl
+ # 4.0 introduced ELF binary
+ tm_file="i386/i386.h i386/att.h linux.h i386/bsdi-elf.h i386/perform.h"
+ gas=yes
+ gnu_ld=yes
+ stabs=yes
+ # tmake_file=t-libc-ok
+ ;;
+ changequote(,)dnl
i[34567]86-*-bsdi* | i[34567]86-*-bsd386*)
changequote([,])dnl
tm_file=i386/bsd386.h
Index: gcc/ginclude/stddef.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/ginclude/stddef.h,v
retrieving revision 1.3
diff -c -r1.3 stddef.h
*** stddef.h 1998/04/28 21:13:26 1.3
--- stddef.h 1998/10/01 05:59:42
***************
*** 284,292 ****
/* In 4.3bsd-net2, leave these undefined to indicate that size_t, etc.
are already defined. */
! /* BSD/OS 3.1 requires the MACHINE_ANSI_H check here. FreeBSD 2.x apparently
! does not, even though there is a check for MACHINE_ANSI_H above. */
! #if defined(_ANSI_H_) || (defined(__bsdi__) && defined(_MACHINE_ANSI_H_))
/* The references to _GCC_PTRDIFF_T_, _GCC_SIZE_T_, and _GCC_WCHAR_T_
are probably typos and should be removed before 2.8 is released. */
#ifdef _GCC_PTRDIFF_T_
--- 284,293 ----
/* In 4.3bsd-net2, leave these undefined to indicate that size_t, etc.
are already defined. */
! /* BSD/OS 3.1 (but pre-4.0) requires the MACHINE_ANSI_H check here.
! FreeBSD 2.x apparently does not, even though there is a check for
! MACHINE_ANSI_H above. */
! #if defined(_ANSI_H_) || (defined(__bsdi__) && defined(_MACHINE_ANSI_H_) && (_BSDI_VERSION < 199802))
/* The references to _GCC_PTRDIFF_T_, _GCC_SIZE_T_, and _GCC_WCHAR_T_
are probably typos and should be removed before 2.8 is released. */
#ifdef _GCC_PTRDIFF_T_
***************
*** 314,320 ****
#undef _WCHAR_T_
#undef _BSD_WCHAR_T_
#endif
! #endif /* _ANSI_H_ || ( __bsdi__ && _MACHINE_ANSI_H_ ) */
#endif /* __sys_stdtypes_h */
--- 315,321 ----
#undef _WCHAR_T_
#undef _BSD_WCHAR_T_
#endif
! #endif /* _ANSI_H_ || ( __bsdi__ && _MACHINE_ANSI_H_ && (_BSDI_VERSOIN < 199802)) */
#endif /* __sys_stdtypes_h */
Index: libio/gen-params
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/libio/gen-params,v
retrieving revision 1.7
diff -c -r1.7 gen-params
*** gen-params 1998/02/01 12:44:51 1.7
--- gen-params 1998/10/01 06:09:38
***************
*** 385,390 ****
--- 385,393 ----
#if __GNUC__ > 2 || __GNUC_MINOR__ >= 8
__extension__ typedef long long ${macro_prefix}llong;
__extension__ typedef unsigned long long ${macro_prefix}ullong;
+ #else
+ typedef int ${macro_prefix}llong __attribute__((__mode__(__DI__)));
+ typedef unsigned int ${macro_prefix}ullnog __attribute__((__mode__(__DI__)));
#endif
#else
typedef $int16_t ${macro_prefix}int16_t;
Index: libio/isscan.cc
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/libio/isscan.cc,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 isscan.cc
*** isscan.cc 1997/08/21 22:58:19 1.1.1.1
--- isscan.cc 1998/10/01 06:09:39
***************
*** 29,35 ****
istream& istream::scan(const char *format ...)
{
if (ipfx0()) {
! va_list ap;
va_start(ap, format);
_strbuf->vscan(format, ap, this);
va_end(ap);
--- 29,35 ----
istream& istream::scan(const char *format ...)
{
if (ipfx0()) {
! _IO_va_list ap;
va_start(ap, format);
_strbuf->vscan(format, ap, this);
va_end(ap);
Index: libio/osform.cc
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/libio/osform.cc,v
retrieving revision 1.2
diff -c -r1.2 osform.cc
*** osform.cc 1997/09/16 16:00:46 1.2
--- osform.cc 1998/10/01 06:09:39
***************
*** 31,37 ****
if (opfx()) {
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
_strbuf);
! va_list ap;
va_start(ap, format);
_IO_vfprintf(rdbuf(), format, ap);
va_end(ap);
--- 31,37 ----
if (opfx()) {
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
_strbuf);
! _IO_va_list ap;
va_start(ap, format);
_IO_vfprintf(rdbuf(), format, ap);
va_end(ap);
Index: libio/sbform.cc
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/libio/sbform.cc,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 sbform.cc
*** sbform.cc 1997/08/21 22:58:21 1.1.1.1
--- sbform.cc 1998/10/01 06:09:40
***************
*** 32,38 ****
}
int streambuf::form(char const *format ...)
{
! va_list ap;
va_start(ap, format);
int count = _IO_vfprintf(this, format, ap);
va_end(ap);
--- 32,38 ----
}
int streambuf::form(char const *format ...)
{
! _IO_va_list ap;
va_start(ap, format);
int count = _IO_vfprintf(this, format, ap);
va_end(ap);
Index: libio/sbscan.cc
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/libio/sbscan.cc,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 sbscan.cc
*** sbscan.cc 1997/08/21 22:58:21 1.1.1.1
--- sbscan.cc 1998/10/01 06:09:40
***************
*** 37,43 ****
}
int streambuf::scan(char const *format ...)
{
! va_list ap;
va_start(ap, format);
int count = _IO_vfscanf(this, format, ap, NULL);
va_end(ap);
--- 37,43 ----
}
int streambuf::scan(char const *format ...)
{
! _IO_va_list ap;
va_start(ap, format);
int count = _IO_vfscanf(this, format, ap, NULL);
va_end(ap);
Index: libio/stream.cc
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/libio/stream.cc,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 stream.cc
*** stream.cc 1997/08/21 22:58:21 1.1.1.1
--- stream.cc 1998/10/01 06:09:41
***************
*** 41,47 ****
char* buf = next_chunk;
strstreambuf stream(buf, EndBuffer-buf-1, buf);
! va_list ap;
va_start(ap, format);
int count = stream.vform(format, ap);
va_end(ap);
--- 41,47 ----
char* buf = next_chunk;
strstreambuf stream(buf, EndBuffer-buf-1, buf);
! _IO_va_list ap;
va_start(ap, format);
int count = stream.vform(format, ap);
va_end(ap);