1

sde-objcopy を使用して画像をオブジェクト ファイル (.o) に変換する必要があります。その後、この画像を no-os システムで使用できます。objcopy コマンドをテストしましたが、私の PC (Fedora 12) でうまく動作します。たとえば、次のコマンドは test.jpg を test.o に変換します。

objcopy -I binary -O elf32-i386 -B i386 ../stdy/test.jpg test.o

ここに私の質問があります:

A. _ sde-objcopy にはアーキテクチャを指定する「-B」オプションがありませんが、アーキテクチャを指定しないと、次のような警告が表示されます。

$ sde-objcopy -I binary -O elf32-little test.jpg test.o

sde-objcopy: 警告: 出力ファイルはアーキテクチャを表すことができません UNKNOWN!

この警告を修正するにはどうすればよいですか?

B. _ objcopy は、ファイルの名前を使用してオブジェクト ファイルにシンボルを生成しているようです。objcopy のパラメーターとしてフル パス (など/home/owner/stdy/test.jpg) を使用すると、長い名前のシンボルが生成されます。この問題を解決するエレガントな方法はありますか?

$ 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
4

1 に答える 1

0

次のようなものを使用できます。

# 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

次に、プログラム内のものにアクセスします。

/* 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);
}
于 2012-08-30T11:17:47.363 に答える