|
|
发表于 2015-12-23 11:31:58
|
显示全部楼层
不点 发表于 2015-12-23 11:13
grub4dos 的补丁中
+ unsigned long *bss_end = (unsigned long *)(program + (unsigned long)filemax - ...
嗯,明白了,谢谢.
我今天就把外部命令全部修改了一下.
看了一下,只是把前面签名等定义改一下就行了..
我现在把这些独立出来弄成一个单独的grubprog.h文件
然后只需要在程序的main前面加上一句,这样就行了,可以避免来回修改的麻烦.
#include "grubprog.h"
grubprog.h内容如下,直接从fat.c源码里面复制出来
- /* thank goodness gcc will place the above 8 bytes at the end of the b.out
- * file. Do not insert any other asm lines here.
- */
- /* it seems gcc use end and/or _end for __bss_end */
- #if 1
- #define __BSS_END end
- #else
- #define __BSS_END _end
- #endif
- #if 1
- #define __BSS_START __bss_start
- #elif 1
- #define __BSS_START edata
- #else
- #define __BSS_START _edata
- #endif
- extern int __BSS_END;
- extern int __BSS_START;
- unsigned long long GRUB = 0x534f443442555247LL;/* this is needed, see the following comment. */
- /* gcc treat the following as data only if a global initialization like the
- * above line occurs.
- */
- /* The 40-byte space is structured. */
- asm(".long main"); /* actually not used for now */
- asm(".long .text"); /* actually not used for now */
- asm(".long etext"); /* actually not used for now */
- asm(".long .data"); /* actually not used for now */
- asm(".long edata"); /* actually not used for now */
- asm(".long __bss_start"); /* actually not used for now */
- asm(".long .bss"); /* actually not used for now */
- asm(".long end"); /* this is the process length */
- asm(".ascii \"main\"");
- asm(".ascii \"_end\"");
- /* Don't insert any code/data here! */
- /* these 16 bytes can be used for any purpose. */
- asm(".long 0");
- asm(".long 0");
- asm(".long 0");
- asm(ASM_BUILD_DATE); //asm(".long 0");
- /* Don't insert any code/data here! */
- /* a valid executable file for grub4dos must end with these 8 bytes */
- asm(".long 0x03051805");
- asm(".long 0xBCBAA7BA");
- /* thank goodness gcc will place the above 8 bytes at the end of the program
- * file. Do not insert any other asm lines here.
- */
复制代码 |
|