This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Please help. GNU As syntax for pointers with ANSI C binding in platform independent way.


On 10.11.2010 19:20, Oleksandr Gavenko wrote:
I want include binary data in executable.

For this purpose I use such techniques (from my Makefile):

%.o %.h: %.bin
echo "extern const char *$*;" >$*.h
echo '.text; .global $*; $*_data:; .incbin "$*.bin"; $*:; .int $*_data;'
| gcc -x assembler -o $*.o -c -

This cryptic code equivalents to .S file (when 'str.bin' processed):

.text
.global str
str_data:
.incbin "str.bin"
str:
.int str_data # XXX .int or .quad ???

To access the data from str.bin I use in .c:

================================================================
#include "str.h" /* here placed: extern const char *str; */

int foo() {
printf(str);
}
================================================================

In case of 32-bit platform I need wrote '.int', in case of
64-bit platform I need wrote '.quad' in assembler.

To work around I can use #if/#define and preprocess output.

But this seems ugly. Is there portable syntax?

I ask incorrect question in some way. Practical asm files written for specific
platform and usually have no common part for 32-/64-bit arch.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]