论坛首页 编程语言技术论坛

Cleanups Done

浏览 2589 次
锁定老帖子 主题:Cleanups Done
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2007-08-04  
C
Clean up two old blogs, which was edited in opera (the edit box was so small). In firefox, I can review these blogs easily, and some clean up done.

NASM 0.99.01 was buggy for the 32bit/16bit codegen. When an instruction which access register and mem, it would be generated with 0x67 prefix for a 16bit segment. This blocks the elf2 bootsect, which has size limitation, extra 0x67 makes the code bloated, so the compilation breaks.
I did a quick hack, and posted the new compiled binary to the ReactOS Build Environment maintainer. Also I filed it as a bug, though the nasm64developer told me that this couldn't be reproduced in 0.99.02 CVS snapshot. O_O , after a try , yes, it's already fixed. ;) so my hacking over nasm is useless.

Though another thing interesting is spotted about GDB. GDB itself is a nice debugger. But...

c 代码
 
  1. #include "stdio.h"  
  2. void __stdcall call()  
  3. {  
  4.     printf("hello!");  
  5. }  
  6. void main()  
  7. {  
  8.     call();  
  9. }  

when you try to
gdb下调试
  1. b call  
gdb fails.

This is the reason why gdb couldn't get all symbols work in Kernel Debugging.

Remarks:
__stdcall __fastcall are calling convention in Windows, they both add @ to the mangled name, seems like gdb fail to deal with mangle name with '@'

mangle name(link time symbol):
c mangle convention: underscore prefix, so every C symbols in asm would be prefixed with an underscore.
so a typical link with ASM files would be
test.c
c 代码
 
  1. extern int myasmSymbol;    
  2. int main()    
  3. {    
  4.       return myasmSymbol;    
  5. }    
myasm.S
asm 代码
 
  1. .text  
  2. .global _myasmSymbol  
  3. _myasmSymbol: .int 0   


gcc -c myasm.S
gcc -c test.c

gcc test.o myasm.o -o test.exe






论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics