Re: any file -- symbol in .o file
E.B. Dreger [EMAIL PROTECTED] wrote: Greetings all, Eddy, Instead of a system-specific approach, you might want to take advantage of what the C language has to offer. For example, your multi-line issue. You realise that the C preprocessor/compiler will concatentate adjacent character string constants, forming one constant. So, you could code this up as: const char foo[] = \Escape\ chars make strings in 'C' code...\n ...messy. But - at least, line breaks are not an issue.\n; I don't have a nice way around the escapes needed for quotes though... - Dave Rivers - -- [EMAIL PROTECTED]Work: (919) 676-0847 Get your mainframe programming tools at http://www.dignus.com To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-hackers in the body of the message
Re: any file -- symbol in .o file
E.B. Dreger writes: I'm about to whip up a utility that will take any arbitrary file and store the contents in a .o file (complete with symbol names so one can actually link, of course). Why don't you just write a script (sed, awk, perl, whatever) to write the C source for you, from a plaintext file as input. --mkb To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-hackers in the body of the message
any file -- symbol in .o file
Greetings all, While writing CGIs in C, I'm getting a bit sick of escaping quotes and line continuations in strings. Not a huge deal, perhaps, but there must be a better way. Strings end up in .data or .rodata in object files to be linked... I'm about to whip up a utility that will take any arbitrary file and store the contents in a .o file (complete with symbol names so one can actually link, of course). Instead of compiling: const char foo[] = \Escape\ chars make strings in 'C' code...\n\ ...messy. Line breaks can be troublesome and add\ unexpected whitespace to one's code. ; simply put the desired unescaped text in a file: Escape chars make strings in 'C' code... ...messy. Line breaks can be troublesome and add unexpected whitespace to one's code. then run the utility. Large amounts of embedded HTML/XML/XHTML are just beginning to bug me. Note that it wouldn't be limited to text, either. If one wished to take a raw-binary lookup table for a sine wave, that would make no difference. If there's interest, I'll post it for download. I also have a few other ideas, and certainly am open to suggestions. -- Eddy Brotsman Dreger, Inc. - EverQuick Internet Division Phone: +1 (316) 794-8922 Wichita/(Inter)national Phone: +1 (785) 865-5885 Lawrence ~ Date: Mon, 21 May 2001 11:23:58 + (GMT) From: A Trap [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Please ignore this portion of my mail signature. These last few lines are a trap for address-harvesting spambots. Do NOT send mail to [EMAIL PROTECTED], or you are likely to be blocked. To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-hackers in the body of the message
Re: any file -- symbol in .o file
Take a look at file2c. You'll need to run the source through the compiler first, but that is easy to do with make. E.B. Dreger [[EMAIL PROTECTED]] wrote : Greetings all, While writing CGIs in C, I'm getting a bit sick of escaping quotes and line continuations in strings. Not a huge deal, perhaps, but there must be a better way. Strings end up in .data or .rodata in object files to be linked... I'm about to whip up a utility that will take any arbitrary file and store the contents in a .o file (complete with symbol names so one can actually link, of course). Instead of compiling: const char foo[] = \Escape\ chars make strings in 'C' code...\n\ ...messy. Line breaks can be troublesome and add\ unexpected whitespace to one's code. ; simply put the desired unescaped text in a file: Escape chars make strings in 'C' code... ...messy. Line breaks can be troublesome and add unexpected whitespace to one's code. then run the utility. Large amounts of embedded HTML/XML/XHTML are just beginning to bug me. Note that it wouldn't be limited to text, either. If one wished to take a raw-binary lookup table for a sine wave, that would make no difference. If there's interest, I'll post it for download. I also have a few other ideas, and certainly am open to suggestions. -- Eddy Brotsman Dreger, Inc. - EverQuick Internet Division Phone: +1 (316) 794-8922 Wichita/(Inter)national Phone: +1 (785) 865-5885 Lawrence ~ Date: Mon, 21 May 2001 11:23:58 + (GMT) From: A Trap [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Please ignore this portion of my mail signature. These last few lines are a trap for address-harvesting spambots. Do NOT send mail to [EMAIL PROTECTED], or you are likely to be blocked. To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-hackers in the body of the message -- Jonathan Mini [EMAIL PROTECTED] http://www.haikugeek.com He who is not aware of his ignorance will be only misled by his knowledge. -- Richard Whatley To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-hackers in the body of the message
Re: any file -- symbol in .o file
JM Date: Sun, 19 May 2002 21:41:05 -0700 JM From: Jonathan Mini JM Take a look at file2c. You'll need to run the source through JM the compiler first, but that is easy to do with make. H. Definitely produces the desired results for the simple case that I mentioned. In fact, more complex things (hash functions, tries, etc.) can be accomplished by writing a quick bin to perform the proper transform, then feeding that to file2c; a shell script can orchestrate everything. I guess I'll run with that for now. Off the top of my head, the only feature file2c can't provide is user-specified data alignment. (Unless, of course, someone corrects me and alerts me to a C preprocessor directive similar to assembly's .align.) Thanks! -- Eddy Brotsman Dreger, Inc. - EverQuick Internet Division Phone: +1 (316) 794-8922 Wichita/(Inter)national Phone: +1 (785) 865-5885 Lawrence ~ Date: Mon, 21 May 2001 11:23:58 + (GMT) From: A Trap [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Please ignore this portion of my mail signature. These last few lines are a trap for address-harvesting spambots. Do NOT send mail to [EMAIL PROTECTED], or you are likely to be blocked. To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-hackers in the body of the message
Re: any file -- symbol in .o file
Jonathan Mini wrote: Take a look at file2c. You'll need to run the source through the compiler first, but that is easy to do with make. You probably also want to look at objcopy. You can skip the compile step if you're prepared to use a bit of linker magic: peter@overcee[10:28pm]/tmp-192 cat p.c extern char __start_buf[]; /* magic */ extern char __stop_buf[]; /* more magic */ main() { printf(%.100s\n, __start_buf); } peter@overcee[10:28pm]/tmp-193 cc -c p.c peter@overcee[10:28pm]/tmp-194 objcopy --add-section buf=/etc/termcap \ --set-section-flags buf=load,alloc p.o p2.o peter@overcee[10:28pm]/tmp-195 cc -o p2 p2.o peter@overcee[10:29pm]/tmp-196 ./p2 # Copyright (c) 1980, 1985, 1989, 1993 # The Regents of the University of California. All rights re The trick is that __start_[sectionname] and __stop_[sectionname] are magic. The other trick is that you have to set the flags to load,alloc or you will be somewhat disappointed. Bear in mind that the sections are verbatim, ie: not null terminated. You would have to do address arithmetic on the delimiter symbols to get the size. E.B. Dreger [[EMAIL PROTECTED]] wrote : Greetings all, While writing CGIs in C, I'm getting a bit sick of escaping quotes and line continuations in strings. Not a huge deal, perhaps, but there must be a better way. Strings end up in .data or .rodata in object files to be linked... I'm about to whip up a utility that will take any arbitrary file and store the contents in a .o file (complete with symbol names so one can actually link, of course). Instead of compiling: const char foo[] = \Escape\ chars make strings in 'C' code...\n\ ...messy. Line breaks can be troublesome and add\ unexpected whitespace to one's code. ; simply put the desired unescaped text in a file: Escape chars make strings in 'C' code... ...messy. Line breaks can be troublesome and add unexpected whitespace to one's code. then run the utility. Large amounts of embedded HTML/XML/XHTML are just beginning to bug me. Note that it wouldn't be limited to text, either. If one wished to take a raw-binary lookup table for a sine wave, that would make no difference. If there's interest, I'll post it for download. I also have a few other ideas, and certainly am open to suggestions. -- Eddy Brotsman Dreger, Inc. - EverQuick Internet Division Phone: +1 (316) 794-8922 Wichita/(Inter)national Phone: +1 (785) 865-5885 Lawrence ~ Date: Mon, 21 May 2001 11:23:58 + (GMT) From: A Trap [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Please ignore this portion of my mail signature. These last few lines are a trap for address-harvesting spambots. Do NOT send mail to [EMAIL PROTECTED], or you are likely to be blocked. To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-hackers in the body of the message -- Jonathan Mini [EMAIL PROTECTED] http://www.haikugeek.com He who is not aware of his ignorance will be only misled by his knowledge. -- Richard Whatley To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-hackers in the body of the message Cheers, -Peter -- Peter Wemm - [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED] All of this is for nothing if we don't go to the stars - JMS/B5 To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-hackers in the body of the message