Ticket #3472: shared_libstdcpp.patch

File shared_libstdcpp.patch, 8.9 KB (added by aljen, 15 years ago)

gcc hack

  • gcc/gcc/config.gcc

     
    11281128    tmake_file="${tmake_file} i386/t-crtstuff"
    11291129    ;;
    11301130i[34567]86-*-haiku*)
    1131     tmake_file='t-haiku i386/t-crtpic'
     1131    tmake_file="t-haiku i386/t-crtpic i386/t-haiku"
    11321132    tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h svr4.h haiku.h i386/haiku.h"
    11331133    extra_parts='crtbegin.o crtend.o'
     1134        extra_objs="haiku_crti.o haiku_crtn.o haiku_init_term_dyn.o haiku_start_dyn.o"
    11341135    ;;
    11351136i[34567]86-*-netbsdelf*)
    11361137    tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h netbsd.h netbsd-elf.h i386/netbsd-elf.h"
  • gcc/gcc/config/i386/haiku_crti.S

     
     1/*
     2 * Copyright 2005-2006, Axel Dörfler, axeld@pinc-software.de.
     3 * Distributed under the terms of the MIT License.
     4 */
     5
     6/** This file contains the first part of the ".init" and ".fini" sections in
     7 *  the ELF executable.
     8 *  The functions defined here will be called during initialization/termination
     9 *  of the loaded executable/library. The ".init" and ".fini" sections are
     10 *  stacked together like this:
     11 *
     12 *  crti.S      entry point
     13 *              call to _init_before/_term_before
     14 *  crtbegin.S  GCC specific: constructors/destructors are called, ...
     15 *  crtend.S
     16 *  crtn.S      call to _init_after/_term_after
     17 *              exit
     18 */
     19
     20#define FUNCTION(x) .global x; .type x,@function; x
     21
     22.section .init
     23FUNCTION(_init):
     24    pushl   %ebp
     25    movl    %esp, %ebp
     26    pushl   8(%ebp)     // put image ID on the stack again
     27    call    _init_before
     28    // crtbegin.o stuff comes here
     29
     30.section .fini
     31FUNCTION(_fini):
     32    pushl   %ebp
     33    movl    %esp, %ebp
     34    pushl   8(%ebp)
     35    call    _term_before
     36    // crtend.o stuff comes here
  • gcc/gcc/config/i386/haiku_crtn.S

     
     1/*
     2 * Copyright 2005-2006, Axel Dörfler, axeld@pinc-software.de.
     3 * Distributed under the terms of the MIT License.
     4 */
     5
     6/** This file contains the final part of the ".init" and ".fini" sections in
     7 *  the ELF executable. It is tightly connected to crti.S.
     8 *  Have a look at crti.S to find a description of what happens here.
     9 */
     10
     11.section .init
     12    // the image ID is still on the stack
     13    call    _init_after
     14    movl    %ebp, %esp
     15    popl    %ebp
     16    ret
     17
     18.section .fini
     19    // the image ID is still on the stack
     20    call    _term_after
     21    movl    %ebp, %esp
     22    popl    %ebp
     23    ret
  • gcc/gcc/config/i386/haiku_start_dyn.c

     
     1/*
     2 * Copyright 2003-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 *
     5 * Copyright 2001, Travis Geiselbrecht. All rights reserved.
     6 * Distributed under the terms of the NewOS License.
     7 */
     8
     9
     10#include <user_runtime.h>
     11
     12#include <string.h>
     13#include <stdlib.h>
     14
     15
     16extern int main(int argc, char **argv, char **env);
     17extern void _init_c_library_(int argc, char **argv, char **env);
     18extern void _call_init_routines_(void);
     19
     20int _start(int argc, char **argv, char **env);
     21
     22// these are part of libroot.so, and initialized here
     23extern char **argv_save;
     24extern thread_id __main_thread_id;
     25extern char **environ;
     26
     27bool __gHaikuStartupCode = true;
     28
     29
     30int
     31_start(int argc, char **argv, char **environment)
     32{
     33    int returnCode;
     34
     35    argv_save = argv;
     36    __main_thread_id = find_thread(NULL);
     37
     38    // These two are called to make our glue code usable under BeOS R5
     39    // - in Haiku, they are both empty.
     40    _init_c_library_(argc, argv, environment);
     41    _call_init_routines_();
     42
     43    returnCode = main(argc, argv, environment);
     44
     45    exit(returnCode);
     46    return 0;
     47}
     48
  • gcc/gcc/config/i386/t-haiku

     
     1haiku_start_dyn.o: $(srcdir)/config/i386/haiku_start_dyn.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
     2  $(TM_H) $(TM_P_H)
     3    $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) -I$(SYSTEM_HEADER_DIR) -I$(SYSTEM_HEADER_DIR)/os \
     4    -I$(SYSTEM_HEADER_DIR)/os/kernel -I$(SYSTEM_HEADER_DIR)/os/support -I$(SYSTEM_HEADER_DIR)/os/storage \
     5    $(srcdir)/config/i386/haiku_start_dyn.c
     6
     7haiku_crti.o: $(srcdir)/config/i386/haiku_crti.S $(CONFIG_H) $(SYSTEM_H) coretypes.h \
     8  $(TM_H) $(TM_P_H)
     9    $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
     10    $(srcdir)/config/i386/haiku_crti.S
     11
     12haiku_crtn.o: $(srcdir)/config/i386/haiku_crtn.S $(CONFIG_H) $(SYSTEM_H) coretypes.h \
     13  $(TM_H) $(TM_P_H)
     14    $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
     15    $(srcdir)/config/i386/haiku_crtn.S
     16
     17haiku_init_term_dyn.o: $(srcdir)/config/i386/haiku_init_term_dyn.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
     18  $(TM_H) $(TM_P_H)
     19    $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) -I$(SYSTEM_HEADER_DIR) -I$(SYSTEM_HEADER_DIR)/os \
     20    -I$(SYSTEM_HEADER_DIR)/os/kernel -I$(SYSTEM_HEADER_DIR)/os/support -I$(SYSTEM_HEADER_DIR)/os/storage \
     21    $(srcdir)/config/i386/haiku_init_term_dyn.c
     22
  • gcc/gcc/config/i386/haiku_init_term_dyn.c

     
     1/*
     2 * Copyright 2003-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5
     6
     7#include <user_runtime.h>
     8#include <image.h>
     9
     10#include "haiku_init_term_dyn.h"
     11
     12
     13/** These functions are called from _init()/_fini() (in crti.S, crtn.S)
     14 *  _init/_term_before() is called before crtbegin/end code is executed,
     15 *  _init/_term_after() after this.
     16 *  crtbegin contains code to initialize all global constructors and
     17 *  other GCC related things (like exception frames).
     18 */
     19
     20
     21void
     22_init_before(image_id id)
     23{
     24    void (*before)(image_id);
     25
     26    if (get_image_symbol(id, B_INIT_BEFORE_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT, (void **)&before) == B_OK)
     27        before(id);
     28}
     29
     30
     31void
     32_init_after(image_id id)
     33{
     34    void (*after)(image_id);
     35
     36    if (get_image_symbol(id, B_INIT_AFTER_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT, (void **)&after) == B_OK)
     37        after(id);
     38}
     39
     40
     41void
     42_term_before(image_id id)
     43{
     44    void (*before)(image_id);
     45
     46    if (get_image_symbol(id, B_TERM_BEFORE_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT, (void **)&before) == B_OK)
     47        before(id);
     48}
     49
     50
     51void
     52_term_after(image_id id)
     53{
     54    void (*after)(image_id);
     55
     56    if (get_image_symbol(id, B_TERM_AFTER_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT, (void **)&after) == B_OK)
     57        after(id);
     58}
     59
  • gcc/gcc/config/i386/haiku_init_term_dyn.h

     
     1/*
     2 * Copyright 2003-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef INIT_TERM_DYN_H
     6#define INIT_TERM_DYN_H
     7
     8
     9#include <image.h>
     10
     11
     12void _init_before(image_id id);
     13void _init_after(image_id id);
     14void _term_before(image_id id);
     15void _term_after(image_id id);
     16
     17#endif  /* INIT_TERM_DYN_H */
  • gcc/gcc/config/i386/haiku.h

     
    6969/* If ELF is the default format, we should not use /lib/elf.  */
    7070
    7171#undef  LINK_SPEC
    72 #define LINK_SPEC "%{!o*:-o %b} -m elf_i386_haiku -shared -no-undefined -Bsymbolic %{nostart:-e 0}"
     72#define LINK_SPEC "%{!o*:-o %b} -m elf_i386_haiku -shared -no-undefined -Bsymbolic %{nostart:-e 0} %{shared:-e 0}"
    7373
    7474/* A C statement (sans semicolon) to output to the stdio stream
    7575   FILE the assembler definition of uninitialized global DECL named
  • gcc/libstdc++-v3/crossconfig.m4

     
    174174  *-haiku*)
    175175    AC_CHECK_HEADERS([nan.h ieeefp.h endian.h sys/isa_defs.h \
    176176      machine/endian.h machine/param.h sys/machine.h sys/types.h \
    177       fp.h float.h endian.h inttypes.h locale.h float.h stdint.h])
     177      fp.h float.h endian.h inttypes.h locale.h float.h stdint.h \
     178      wchar.h wctype.h])
    178179    SECTION_FLAGS='-ffunction-sections -fdata-sections'
    179180    AC_SUBST(SECTION_FLAGS)
    180181
     
    210211    AC_DEFINE(HAVE_SQRTF)
    211212    AC_DEFINE(HAVE_TANF)
    212213    AC_DEFINE(HAVE_TANHF)
     214    # AC_DEFINE(_GLIBCXX_USE_WCHAR_T)
     215    # AC_DEFINE(HAVE_WCHAR_H)
     216    # AC_DEFINE(HAVE_WCTYPE_H)
    213217    ;;
    214218
    215219  *-hpux*)