From owner-freebsd-questions@FreeBSD.ORG Thu Nov 15 17:36:52 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5C63316A419 for ; Thu, 15 Nov 2007 17:36:52 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id CC44713C455 for ; Thu, 15 Nov 2007 17:36:51 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from kobe.laptop (vader.bytemobile-rio.ondsl.gr [83.235.57.37]) (authenticated bits=128) by igloo.linux.gr (8.14.1/8.14.1/Debian-9) with ESMTP id lAFHaSSj015749 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 15 Nov 2007 19:36:38 +0200 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.2/8.14.2) with ESMTP id lAFHaN6Z001956; Thu, 15 Nov 2007 19:36:23 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.2/8.14.2/Submit) id lAFHaNP5001955; Thu, 15 Nov 2007 19:36:23 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Thu, 15 Nov 2007 19:36:23 +0200 From: Giorgos Keramidas To: Wojciech Puchar Message-ID: <20071115173623.GA1749@kobe.laptop> References: <20071115171510.D59698@wojtek.tensor.gdynia.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20071115171510.D59698@wojtek.tensor.gdynia.pl> X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-3.996, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.40, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Spam-Status: No Cc: freebsd-questions@freebsd.org Subject: Re: OT: gcc/binutils question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Nov 2007 17:36:52 -0000 On 2007-11-15 17:17, Wojciech Puchar wrote: > how to convert arbitrary data (in file) to object file, so i will be able > to do > > extern char something[] > > and use it - in C. Try to file2c(1) utility. Quoting from its manpage: % EXAMPLES % The command: % % date | file2c 'const char date[] = {' ',0};' % % will produce: % % const char date[] = { % 83,97,116,32,74,97,110,32,50,56,32,49,54,58,50,56,58,48,53, % 32,80,83,84,32,49,57,57,53,10 % ,0}; > i did wrote converter that converts data from file to > > const char something[]={firstbyte,secondbyte,.....}; > > and then cc to compile it. > > and it's VERY SLOW when data are few megs - while it's no work in fact. I think there's something wrong with the converter, then. The file2c(1) utility converts my kernel (6 MB of data) in less than 3 seconds: $ /usr/bin/time file2c 'const char kernel[] = {' '};' \ < /boot/kernel/kernel > /dev/null 2.98 real 2.92 user 0.11 sys $