How to specify architecture for sde-objcopy?
I need to convert an picture to an object file(.o) use sde-objcopy, then I can use this picture in our no-os system. I had test the objcopy command, it works well on my PC(Fedora 12). For example, the command below will convert test.jpg to test.o.
objcopy -I binary -O elf32-i386 -B i386 ../stdy/test.jpg test.o
Here are my questions:
A. sde-objcopy doesn't has the "-B" option to specify the architecture, but if I don't specify a architecture, it will reponse an warning like this:
$ sde-objcopy -I binary -O elf32-little test.jpg test.o
sde-objcopy: Warning: Output file cannot represent architecture UNKNOWN!
How to fix this warning?
B. It seems that objcopy uses the file's name to generate symbols in the object file. If I use the full path(such as /home/owner/stdy/test.jpg
) as the parameter of objcopy, it will generate long named symbols. 开发者_运维问答Is there any elegant method to fix this issue?
$ objcopy -I binary -O elf32-i386 -B i386 ../stdy/test.jpg test.o
$ nm test.o
00000083 D _binary____stdy_test_jpg_end
00000083 A _binary____stdy_test_jpg_size
00000000 D _binary____stdy_test_jpg_start
$ objcopy -I binary -O elf32-i386 -B i386 test.jpg test.o
$ nm test.o
00000032 D _binary_test_jpg_end
00000032 A _binary_test_jpg_size
00000000 D _binary_test_jpg_start
You could use something like:
# data.s
.section ".rodata"
.globl font_data_start, font_data_end
font_data_start:
.incbin "Zitz-Regular.ttf"
font_data_end:
.size font_data_start, font_data_end - font_data_start
and then access the stuff in your program:
/* prog.c */
extern const char font_data_start[], font_data_end[];
void function() {
fwrite(font_data_start, font_data_end - font_data_start, 1, stdout);
}
精彩评论