在 2024-01-22 16:39, Jan Beulich 写道: > Right, I did some work in that direction a while ago. But iirc there are > still cases left to be addressed. Attached is a draft patch for GCC, bootstrapped on {i686,x86_64}-w64-mingw32 with GCC 13.2 and binutils 2.41.0. This addresses the issue when a bad name exists in the same translation unit. In the case of an external symbol there's still an error: ``` extern int bx; int get(const char* p) { return p[bx]; } ``` ``` lh_mouse@lhmouse-pc ~/Desktop $ x86_64-w64-mingw32-gcc -S -o - -masm=intel test.c | fgrep bx mov rax, QWORD PTR .refptr.bx[rip] .section .rdata$.refptr.bx, "dr" .globl .refptr.bx .refptr.bx: .quad bx lh_mouse@lhmouse-pc ~/Desktop $ x86_64-w64-mingw32-gcc -masm=intel test.c | fgrep bx C:\Users\lh_mouse\AppData\Local\Temp\ccuyuu6c.s: Assembler messages: C:\Users\lh_mouse\AppData\Local\Temp\ccuyuu6c.s:29: Error: invalid use of register C:\Users\lh_mouse\AppData\Local\Temp\ccuyuu6c.s:29: Warning: register value used as expression lh_mouse@lhmouse-pc ~/Desktop $ ``` -- Best regards, LIU Hao