From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8069 invoked by alias); 4 Dec 2010 04:47:54 -0000 Received: (qmail 8061 invoked by uid 22791); 4 Dec 2010 04:47:53 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-yw0-f41.google.com (HELO mail-yw0-f41.google.com) (209.85.213.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 04 Dec 2010 04:47:48 +0000 Received: by ywk9 with SMTP id 9so1089176ywk.0 for ; Fri, 03 Dec 2010 20:47:47 -0800 (PST) Received: by 10.151.83.3 with SMTP id k3mr5162753ybl.161.1291438066943; Fri, 03 Dec 2010 20:47:46 -0800 (PST) Received: from localhost.localdomain (206-248-170-50.dsl.teksavvy.com [206.248.170.50]) by mx.google.com with ESMTPS id u68sm1576450yhc.47.2010.12.03.20.47.45 (version=SSLv3 cipher=RC4-MD5); Fri, 03 Dec 2010 20:47:46 -0800 (PST) From: Arnaud Lacombe To: binutils@sourceware.org Cc: Arnaud Lacombe Subject: [PATCH] Fix binutils/gold build on NetBSD Date: Sat, 04 Dec 2010 04:47:00 -0000 Message-Id: <1291438024-7921-1-git-send-email-lacombar@gmail.com> Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2010-12/txt/msg00181.txt.bz2 Hi *, This patch intends to fix gold build on NetBSD host. NetBSD supports mremap(2), but does not support MREMAP_MAYMOVE flags. This patch renames gold's internal version of mremap to avoid namespace conflict as prototypes differs and add an additionnal configure-time check for MREMAP_MAYMOVE. - Arnaud ps: this patch has been wandering around on my disk for quite some time, but as it still applies cleanly, I guess the issue still exists. I'll be able to confirm next time I use gold. ps2: yes, I know, the configure script is not regenerated. and this mail is not in the proper changelog format, but I'm not a particular fan of the change itself (in particular the rename), a better solution certainly exist. --- gold/configure.ac | 11 +++++++++++ gold/gold.h | 4 ++-- gold/mremap.c | 4 ++-- gold/output.cc | 5 +++++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/gold/configure.ac b/gold/configure.ac index 2c50d97..46e526b 100644 --- a/gold/configure.ac +++ b/gold/configure.ac @@ -395,6 +395,17 @@ AC_SUBST(LFS_CFLAGS) AC_CHECK_FUNCS(chsize) AC_REPLACE_FUNCS(pread ftruncate mremap ffsll) +AC_COMPILE_IFELSE([ +AC_LANG_PROGRAM([[ +#include +#ifndef MREMAP_MAYMOVE +#error "MREMAP_MAYMOVE not defined." +#endif +]])], +[AC_DEFINE(HAVE_MREMAP_MAYMOVE, 1, +[Define to 1 if mremap(2) support the MREMAP_MAYMOVE flag.])], +[AC_LIBOBJ(mremap)]) + # Link in zlib if we can. This allows us to write compressed sections. AC_SEARCH_LIBS(zlibVersion, z, [AC_CHECK_HEADERS(zlib.h)]) AM_CONDITIONAL(HAVE_ZLIB, test "$ac_cv_search_zlibVersion" != "no") diff --git a/gold/gold.h b/gold/gold.h index 90f1f7d..a457bc8 100644 --- a/gold/gold.h +++ b/gold/gold.h @@ -135,9 +135,9 @@ extern "C" ssize_t pread(int, void*, size_t, off_t); extern "C" int ftruncate(int, off_t); #endif -#ifndef HAVE_MREMAP +#if !defined(HAVE_MREMAP) || !defined(HAVE_MREMAP_MAYMOVE) #define MREMAP_MAYMOVE 1 -extern "C" void *mremap(void *, size_t, size_t, int, ...); +extern "C" void *gold_mremap(void *, size_t, size_t, int, ...); #endif #ifndef HAVE_FFSLL diff --git a/gold/mremap.c b/gold/mremap.c index 332fded..632bfc8 100644 --- a/gold/mremap.c +++ b/gold/mremap.c @@ -40,10 +40,10 @@ # define MAP_ANONYMOUS MAP_ANON #endif -extern void *mremap (void *, size_t, size_t, int, ...); +extern void *gold_mremap (void *, size_t, size_t, int, ...); void * -mremap (void *old_address, size_t old_size, size_t new_size, +gold_mremap (void *old_address, size_t old_size, size_t new_size, int flags ATTRIBUTE_UNUSED, ...) { void *ret; diff --git a/gold/output.cc b/gold/output.cc index 1158a77..cd75a98 100644 --- a/gold/output.cc +++ b/gold/output.cc @@ -4349,8 +4349,13 @@ Output_file::resize(off_t file_size) // to unmap to flush to the file, then remap after growing the file. if (this->map_is_anonymous_) { +#if defined(HAVE_MREMAP) && defined(HAVE_MREMAP_MAYMOVE) void* base = ::mremap(this->base_, this->file_size_, file_size, MREMAP_MAYMOVE); +#else + void* base = ::gold_mremap(this->base_, this->file_size_, file_size, + MREMAP_MAYMOVE); +#endif if (base == MAP_FAILED) gold_fatal(_("%s: mremap: %s"), this->name_, strerror(errno)); this->base_ = static_cast(base); -- 1.7.2.30.gc37d7.dirty