Estoy tratando de compilar en Linux, un cargador de sistemas operativos que se llama gujin, que es parecido al GRUB.
Cuando voy a compilar con make
, me sale restricción imposible en asm:
library.h:1736:3: error: restricción imposible en ‘asm’
1736 | asm (
| ^~~
make[1]: *** [Makefile:850: boot.S] Error 1
make: *** [Makefile:877: gujin] Error 2
Código de library.h:1736:3:, que falla:
asm (
" pushl %2 \n"
" popw %w0 \n"
" popw %%fs \n"
" movzbl %%fs:(%w0),%1 \n"
: "=bSDB" (scratch), "=r" (returned)
: "g" (adr), "m" (*memory)
);
Registro completo:
make --trace
Makefile:874: actualizar el objetivo 'gujin' a causa de: instboot.c boot.c user.c debug.c library.c disk.c util.c gzlib.c kbd.c fs.c vmlinuz.c mouse.c main.c font.c gzcopy.c fntbin2h.c fnthex2h.c addhole.c showmap.c cleandisk.c showmbr.c gujin-cmdline.c hello_32bits.c hello_64bits.c hello_bios.c hello_gpl.c boot.h user.h debug.h library.h disk.h util.h gzlib.h kbd.h fs.h vmlinuz.h mouse.h font.h make.h gmem.h e2fs.h instboot.h messages.h vesabios.h vgabios.h ide.h bios.h dos.h ega.h xms.h
rm -rf gujin_images
mkdir gujin_images
echo "# generating gujin_images/boot.bin, GCCFLAGS=-fomit-frame-pointer -mrtd -march=i386 -fno-builtin -fverbose-asm -g1 -fno-stack-protector -fno-optimize-sibling-calls -m32 -minline-all-stringops -mno-align-stringops -fno-function-cse -Os -ffunction-sections."
# generating gujin_images/boot.bin, GCCFLAGS=-fomit-frame-pointer -mrtd -march=i386 -fno-builtin -fverbose-asm -g1 -fno-stack-protector -fno-optimize-sibling-calls -m32 -minline-all-stringops -mno-align-stringops -fno-function-cse -Os -ffunction-sections.
make -s DISK_SUPPORT="BIOS_SUPPORT|EBIOS_SUPPORT|IDE_SUPPORT|DOS_SUPPORT|CDBIOS_SUPPORT|ATAPI_SUPPORT|E2FS_PROBE|FAT12_PROBE|FAT16_PROBE|FAT32_PROBE|BOOTSECT_PROBE|ISOFS_PROBE" USER_SUPPORT="VGA_SUPPORT|VGA_EXTENDED|VESA_WINDOW|VESA_WINFUNCTION|VESA_LINEAR|VESA_EDID|VESA_RECALC|VESA_2WINDOWS|VESA_HARDWINDOW|VESA_PMINFO|VESA_16BPP|VESA_32BPP|VESA_1BPP|VESA_24BPP|VESA_4BPP_EGA|VESA_4BPP_TEXT|VESA_8BPP|VESA_4BPP|SERIAL_VT100|SERIAL_VT420|BIOS_MOUSE_SUPPORT|SERIAL_MOUSE_SUPPORT|JOYSTICK_SUPPORT" SETUP="CODE_SEGMENT|XCODE_SEGMENT|XDATA_SEGMENT|ASSEMBLY_CISC|UPDATE_BOOTPARAM|USE_INT1587|MULTILINGUAL|XSTRING_SEGMENT|UNICODE_FONT" INSTBOOT_DEFAULT_PARAMETER='--cmdline=""' clean dep boot.bin
Makefile:2393: el objetivo 'clean' no existe
rm -f gujin.tar.gz gujin.shar tiny_img.asm mingujin.asm floppy.144.gz USB?Gb.img
rm -f boot.[sSio] user.[sSio] debug.[sSio] library.[sSio] disk.[sSio] util.[sSio] gzlib.[sSio] kbd.[sSio] fs.[sSio] vmlinuz.[sSio] mouse.[sSio] main.[sSio] font.[sSio] instboot.[sSio] gzcopy.[sSio] fntbin2h.[sSio] fnthex2h.[sSio] addhole.[sSio] showmap.[sSio] cleandisk.[sSio] showmbr.[sSio] gujin-cmdline.[sSio] hello_32bits.[sSio] hello_64bits.[sSio] hello_bios.[sSio] hello_gpl.[sSio]
rm -f boot.lis user.lis debug.lis library.lis disk.lis util.lis gzlib.lis kbd.lis fs.lis vmlinuz.lis mouse.lis main.lis font.lis instboot.lis gzcopy.lis fntbin2h.lis fnthex2h.lis addhole.lis showmap.lis cleandisk.lis showmbr.lis gujin-cmdline.lis hello_32bits.lis hello_64bits.lis hello_bios.lis hello_gpl.lis
rm -f boot.c~ user.c~ debug.c~ library.c~ disk.c~ util.c~ gzlib.c~ kbd.c~ fs.c~ vmlinuz.c~ mouse.c~ main.c~ font.c~ instboot.c~ gzcopy.c~ fntbin2h.c~ fnthex2h.c~ addhole.c~ showmap.c~ cleandisk.c~ showmbr.c~ gujin-cmdline.c~ hello_32bits.c~ hello_64bits.c~ hello_bios.c~ hello_gpl.c~ boot.h~ user.h~ debug.h~ library.h~ disk.h~ util.h~ gzlib.h~ kbd.h~ fs.h~ vmlinuz.h~ mouse.h~ font.h~ make.h~ gmem.h~ e2fs.h~ instboot.h~ messages.h~ vesabios.h~ vgabios.h~ ide.h~ bios.h~ dos.h~ ega.h~ xms.h~ bochs.png~ cmd.png~ color16.png~ color4.png~ main.png~ minicom.png~ mode0.png~ setup.png~ setup2.png~ setup-fr.png~ simple.png~ start.png~ ttys0.png~ gujin-scfrg.htm~ README.htm~ install.txt~ gpg_sign.txt~ gpl.txt~ toolchain.txt~ gujin.8~ changelog.wri~ Makefile~ boot.ld~ awk.cmd~ cleandisk.ld~ cleandisk_bin.ld~ gujin.spec~ gujin.cmd~ gujin.sh~
rm -f Makefile.tmp code16.h instboot gzcopy fntbin2h fnthex2h addhole showmap showmbr gujin-cmdline null.o gujin.8.gz
rm -f boot.bin boot.lnk gujin.com gujin.exe gujin.pic gujin.bcd boot.map boot.asm boot.elf
rm -f boot.360 boot.120 boot.720 boot.144 boot.168 boot.288 bf144.img.gz
rm -f cleandisk cleandisk.map cleandisk.S cleandisk.s cleandisk.o
rm -f cleandisk.elf cleandisk.bin cleandisk.elf.gz cleandisk.bin.gz
rm -f hello_bios.elf hello_bios.kgz hello_32bits.elf hello_32bits.kgz hello_32bits_r.elf hello_32bits_r.elf.gz hello_32bits_r.kgz
rm -f hello_64bits.elf hello_64bits.kgz hello_64bits_r.elf hello_64bits_r.elf.gz hello_64bits_r.kgz hello_gpl.elf hello_gpl.elf.gz hello_gpl.kgz
rm -f hello_bad1.kgz hello_bad2.kgz hello_bad3.kgz hello_bad4.kgz hello_good1.kgz hello_good2.kgz
rm -f gzcp* # results of testgzcopy when failure
Makefile:1103: el objetivo 'code16.h' no existe
/bin/echo -e "asm(\" .code16gcc \");" > code16.h
/bin/echo -e "asm(\" .psize 0 \");" >> code16.h
Makefile:952: actualizar el objetivo 'dep' a causa de: code16.h
echo '##### Dependencies' >> Makefile # if it is not there...
sed '/^[# ]*Dependencies/q' < Makefile > Makefile.tmp
# Take care, no dot, i.e. ".o", for instboot/gzcopy dependency:
/usr/bin/cc -E -include code16.h -DDEBUG="(DEBUG_STACK)" -DUSER_SUPPORT="(VGA_SUPPORT|VGA_EXTENDED|VESA_WINDOW|VESA_WINFUNCTION|VESA_LINEAR|VESA_EDID|VESA_RECALC|VESA_2WINDOWS|VESA_HARDWINDOW|VESA_PMINFO|VESA_16BPP|VESA_32BPP|VESA_1BPP|VESA_24BPP|VESA_4BPP_EGA|VESA_4BPP_TEXT|VESA_8BPP|VESA_4BPP|SERIAL_VT100|SERIAL_VT420|BIOS_MOUSE_SUPPORT|SERIAL_MOUSE_SUPPORT|JOYSTICK_SUPPORT)" -DDISK_SUPPORT="(BIOS_SUPPORT|EBIOS_SUPPORT|IDE_SUPPORT|DOS_SUPPORT|CDBIOS_SUPPORT|ATAPI_SUPPORT|E2FS_PROBE|FAT12_PROBE|FAT16_PROBE|FAT32_PROBE|BOOTSECT_PROBE|ISOFS_PROBE)" -DSETUP="(CODE_SEGMENT|XCODE_SEGMENT|XDATA_SEGMENT|ASSEMBLY_CISC|UPDATE_BOOTPARAM|USE_INT1587|MULTILINGUAL|XSTRING_SEGMENT|UNICODE_FONT)" -MM boot.c user.c debug.c library.c disk.c util.c gzlib.c kbd.c fs.c vmlinuz.c mouse.c main.c font.c | sed 's/\.o/.[oisS]/' \
>> Makefile.tmp
/usr/bin/cc -E -MM instboot.c | sed 's/\.o//' >> Makefile.tmp
/usr/bin/cc -E -MM gzcopy.c | sed 's/\.o//' >> Makefile.tmp
/usr/bin/cc -E -MM fntbin2h.c | sed 's/\.o//' >> Makefile.tmp
/usr/bin/cc -E -MM fnthex2h.c | sed 's/\.o//' >> Makefile.tmp
mv -f Makefile.tmp Makefile
echo
echo GCC: `/usr/bin/gcc --version | head -1`, Binutils: `ld --version | head -1`
GCC: gcc (GCC) 11.2.0, Binutils: GNU ld version 2.37-slack15
echo : dependencies rebuilt, depending on Makefile setup.
: dependencies rebuilt, depending on Makefile setup.
Makefile:850: actualizar el objetivo 'boot.S' a causa de: boot.c
/usr/bin/gcc -include code16.h -DDEBUG="(DEBUG_STACK)" -DUSER_SUPPORT="(VGA_SUPPORT|VGA_EXTENDED|VESA_WINDOW|VESA_WINFUNCTION|VESA_LINEAR|VESA_EDID|VESA_RECALC|VESA_2WINDOWS|VESA_HARDWINDOW|VESA_PMINFO|VESA_16BPP|VESA_32BPP|VESA_1BPP|VESA_24BPP|VESA_4BPP_EGA|VESA_4BPP_TEXT|VESA_8BPP|VESA_4BPP|SERIAL_VT100|SERIAL_VT420|BIOS_MOUSE_SUPPORT|SERIAL_MOUSE_SUPPORT|JOYSTICK_SUPPORT)" -DDISK_SUPPORT="(BIOS_SUPPORT|EBIOS_SUPPORT|IDE_SUPPORT|DOS_SUPPORT|CDBIOS_SUPPORT|ATAPI_SUPPORT|E2FS_PROBE|FAT12_PROBE|FAT16_PROBE|FAT32_PROBE|BOOTSECT_PROBE|ISOFS_PROBE)" -DSETUP="(CODE_SEGMENT|XCODE_SEGMENT|XDATA_SEGMENT|ASSEMBLY_CISC|UPDATE_BOOTPARAM|USE_INT1587|MULTILINGUAL|XSTRING_SEGMENT|UNICODE_FONT)" -fomit-frame-pointer -mrtd -march=i386 -fno-builtin -fverbose-asm -g1 -fno-stack-protector -fno-optimize-sibling-calls -m32 -minline-all-stringops -mno-align-stringops -fno-function-cse -Os -ffunction-sections -fno-strict-aliasing -falign-loops=1 -falign-jumps=1 -falign-functions=2 -mpreferred-stack-boundary=2 -mno-align-double -Wall -Wno-main -Wstrict-prototypes -Wundef -Wpointer-arith -Wcast-align -Wwrite-strings -Wsign-compare -Wno-format -Wno-multichar -Wdisabled-optimization -S -o boot.S boot.c
En el fichero incluido desde boot.c:56:
boot.h:122:5: aviso: la alineación 1 de ‘struct <anónimo>’ es menor que 2 [-Wpacked-not-aligned]
122 | } __attribute__ ((packed)) bootsector_t;
| ^
boot.h:133:5: aviso: la alineación 1 de ‘struct <anónimo>’ es menor que 2 [-Wpacked-not-aligned]
133 | } __attribute__ ((packed)) bootsector_FAT32_t;
| ^
boot.c:123:10: aviso: se descarta el atributo ‘packed’ [-Wattributes]
123 | __attribute__ ((section (SECTNAME(A)), _packed, attr_used)) = {
| ^~~~~~~~~~~~~
boot.c:864:9: aviso: se descarta el atributo ‘packed’ [-Wattributes]
864 | = ", ";
| ^
boot.c:867:9: aviso: se descarta el atributo ‘packed’ [-Wattributes]
867 | = ": chksum"; /* position dependancy with next msg */
| ^
boot.c:870:9: aviso: se descarta el atributo ‘packed’ [-Wattributes]
870 | = " ERROR!"; /* position dependancy with previous and next msg */
| ^
boot.c:873:9: aviso: se descarta el atributo ‘packed’ [-Wattributes]
873 | = "\r\n"; /* position dependancy with next msg */
| ^
boot.c:888:9: aviso: se descarta el atributo ‘packed’ [-Wattributes]
888 | = {
| ^
boot.c:905:5: aviso: se descarta el atributo ‘packed’ [-Wattributes]
905 | = {0};
| ^
boot.c:912:1: aviso: se descarta el atributo ‘packed’ [-Wattributes]
912 | static volatile const bootafter_t bootafter __attribute__ ((section (SECTNAME(I)), _packed, attr_used)) = {
| ^~~~~~
boot.c:935:9: aviso: ‘packed’ attribute ignored for type ‘const instboot_info_t *’ [-Wattributes]
935 | instboot_info_ptr = &instboot_info;
| ^~~~~~~~~~~~~~~~~
boot.c:971:9: aviso: se descarta el atributo ‘packed’ [-Wattributes]
971 | __attribute__ ((section (SECTNAME(L)), aligned (2), _packed)) = {
| ^~~~~~~~~~~~~
boot.c:1160:33: aviso: se descarta el atributo ‘packed’ [-Wattributes]
1160 | ] = {};
| ^
boot.c:1612:1: aviso: se descarta el atributo ‘packed’ [-Wattributes]
1612 | bootloader2_t uninstall_mbr[3] = {
| ^~~~~~~~~~~~~
boot.c:2013:9: aviso: se descarta el atributo ‘packed’ [-Wattributes]
2013 | = "Gujin can not run on a 8086!\r\n";
| ^
boot.c:2015:9: aviso: se descarta el atributo ‘packed’ [-Wattributes]
2015 | = "Gujin can not run on a 80286!\r\n";
| ^
boot.c:2018:9: aviso: se descarta el atributo ‘packed’ [-Wattributes]
2018 | = "\r\nExiting Gujin without error...\r\n";
| ^
boot.c:2020:9: aviso: se descarta el atributo ‘packed’ [-Wattributes]
2020 | = "\r\nExiting Gujin with error...\r\n";
| ^
boot.c:2033:1: aviso: se descarta el atributo ‘packed’ [-Wattributes]
2033 | const instboot_info_t instboot_info __attribute__ ((section (".text.start"), _packed, attr_used)) = {
| ^~~~~
En el fichero incluido desde boot.c:56:
boot.c: En la función ‘VIDEO_mode_reset’:
boot.h:403:38: aviso: la iteración 30 invoca comportamiento indefinido [-Waggressive-loop-optimizations]
403 | copy_gujin_param.vga_mode[cpt] = (struct vga_mode_str) {};
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
boot.h:402:21: nota: dentro de este bucle
402 | for (cpt = 0; cpt <= nbof (copy_gujin_param.vga_mode); cpt++)
En el fichero incluido desde boot.c:55:
library.h: En la función ‘peekb_doorclosed’:
library.h:1736:3: error: restricción imposible en ‘asm’
1736 | asm (
| ^~~
make[1]: *** [Makefile:850: boot.S] Error 1
make: *** [Makefile:877: gujin] Error 2
¿Cómo hago que compile?
build toolchain
no está bien?asm (" pushl %2 \n"
...