From 2a516d7eb9bce055a3e88ade482a00a119161783 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Thu, 28 Oct 2004 18:08:46 +0000 Subject: [PATCH] add support for BeOS-target git-svn-id: file:///srv/svn/repos/haiku/trunk/buildtools@9573 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- binutils/bfd/bfdio.c | 44 +++++++++++++++++++++++++++++++++++++ binutils/bfd/configure | 2 +- binutils/bfd/doc/elf.texi | 3 +-- binutils/bfd/elflink.c | 4 +++- binutils/binutils/dlltool.c | 4 ++++ binutils/ld/ldmain.c | 3 ++- binutils/ld/lexsup.c | 5 +++++ 7 files changed, 60 insertions(+), 5 deletions(-) diff --git a/binutils/bfd/bfdio.c b/binutils/bfd/bfdio.c index a90cb33ea5..1c39c2c03b 100644 --- a/binutils/bfd/bfdio.c +++ b/binutils/bfd/bfdio.c @@ -38,6 +38,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define S_IXOTH 0001 /* Execute by others. */ #endif +#ifdef __BEOS__ +static unsigned char _bfdio_files[OPEN_MAX+1]; +#endif + file_ptr real_ftell (FILE *file) { @@ -53,6 +57,9 @@ real_ftell (FILE *file) int real_fseek (FILE *file, file_ptr offset, int whence) { +#ifdef __BEOS__ + _bfdio_files[fileno(file)] = 1; +#endif #if defined (HAVE_FSEEKO64) return fseeko64 (file, offset, whence); #elif defined (HAVE_FSEEKO) @@ -175,7 +182,44 @@ bfd_bwrite (const void *ptr, bfd_size_type size, bfd *abfd) return size; } +#if defined __BEOS__ + { + FILE *f; + f = bfd_cache_lookup (abfd); + if (_bfdio_files[fileno(f)] == 1) + { + file_ptr eof; + file_ptr pos; + + pos = ftell (f); + fseek (f, 0L, SEEK_END); + eof = ftell(f); + + if (eof < pos) + { + file_ptr diff; + static char zeros[512]; + + diff = pos - eof; + + while (diff >= sizeof (zeros)) + { + fwrite(zeros, sizeof (zeros), 1, f); + diff -= sizeof (zeros); + } + if (diff > 0) + fwrite(zeros, diff, 1, f); + } + else + fseek (f, pos, SEEK_SET); + + _bfdio_files[fileno(f)] = 0; + } + nwrote = fwrite (ptr, 1, (size_t) size, f); + } +#else nwrote = fwrite (ptr, 1, (size_t) size, bfd_cache_lookup (abfd)); +#endif if (nwrote != (size_t) -1) abfd->where += nwrote; if (nwrote != size) diff --git a/binutils/bfd/configure b/binutils/bfd/configure index 46c8170edd..428b7c21b1 100755 --- a/binutils/bfd/configure +++ b/binutils/bfd/configure @@ -919,7 +919,7 @@ fi PACKAGE=bfd -VERSION=2.15 +VERSION=2.15-beos-041025 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } diff --git a/binutils/bfd/doc/elf.texi b/binutils/bfd/doc/elf.texi index 101001c7d9..8f93445bdc 100644 --- a/binutils/bfd/doc/elf.texi +++ b/binutils/bfd/doc/elf.texi @@ -1,5 +1,4 @@ -@section -ELF backends +@section ELF backends BFD support for ELF formats is being worked on. Currently, the best supported back ends are for sparc and i386 diff --git a/binutils/bfd/elflink.c b/binutils/bfd/elflink.c index 6628db34cc..2cd2f7a13e 100644 --- a/binutils/bfd/elflink.c +++ b/binutils/bfd/elflink.c @@ -7813,6 +7813,8 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) { default: continue; +/* BeOS (R5) doesn't know about DT_RELCOUNT, so we avoid using it */ +#ifndef __BEOS__ case DT_NULL: if (relativecount > 0 && dyncon + bed->s->sizeof_dyn < dynconend) { @@ -7827,7 +7829,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) break; } continue; - +#endif case DT_INIT: name = info->init_function; goto get_sym; diff --git a/binutils/binutils/dlltool.c b/binutils/binutils/dlltool.c index 5f921ae095..a44e48577b 100644 --- a/binutils/binutils/dlltool.c +++ b/binutils/binutils/dlltool.c @@ -386,6 +386,10 @@ static int verbose; static FILE *output_def; static FILE *base_file; +#ifdef DLLTOOL_BEOS +static const char *mname = "beos"; +#endif + #ifdef DLLTOOL_ARM #ifdef DLLTOOL_ARM_EPOC static const char *mname = "arm-epoc"; diff --git a/binutils/ld/ldmain.c b/binutils/ld/ldmain.c index d0e0b12a88..a81d3b71f9 100644 --- a/binutils/ld/ldmain.c +++ b/binutils/ld/ldmain.c @@ -301,7 +301,8 @@ main (int argc, char **argv) link_info.notice_all = FALSE; link_info.nocopyreloc = FALSE; link_info.new_dtags = FALSE; - link_info.combreloc = TRUE; + /* disable combreloc by default for BeOS: */ + link_info.combreloc = FALSE; link_info.eh_frame_hdr = FALSE; link_info.strip_discarded = TRUE; link_info.strip = strip_none; diff --git a/binutils/ld/lexsup.c b/binutils/ld/lexsup.c index b377bd4c7c..de3cb5106b 100644 --- a/binutils/ld/lexsup.c +++ b/binutils/ld/lexsup.c @@ -985,7 +985,12 @@ parse_args (unsigned argc, char **argv) /* When creating a shared library, the default behaviour is to ignore any unresolved references. */ if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET) +#ifdef __BEOS__ + /* BeOS uses -shared for apps, but wants to report undefined symbols for them */ + link_info.unresolved_syms_in_objects = how_to_report_unresolved_symbols; +#else link_info.unresolved_syms_in_objects = RM_IGNORE; +#endif if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET) link_info.unresolved_syms_in_shared_libs = RM_IGNORE; }