tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] tips? define asm symbol as global if it is extern in


From: grischka
Subject: Re: [Tinycc-devel] tips? define asm symbol as global if it is extern in C
Date: Mon, 18 May 2015 17:39:36 +0200
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

Sergey Korshunoff wrote:
Hi all,
there is a patch for the problem. Any suggestions?

And why does tinycc need this?  If you want the symbol to be
global, you can add ".globl" to your asm.

Behavior whereby any "extern" declaration in C, provided it
appears above the asm in the file, would have the same effect
as .globl, is not a known feature to anyone.

-- gr

diff -urN tinycc.old/tccasm.c tinycc/tccasm.c
--- tinycc.old/tccasm.c 2015-05-18 12:30:24.000000000 +0300
+++ tinycc/tccasm.c     2015-05-18 16:28:03.000000000 +0300
@@ -779,6 +779,16 @@
             opcode = tok;
             next();
             if (tok == ':') {
+                /* handle "extern void vide(void); __asm__("vide: ret");" as
+                "__asm__("globl vide\nvide: ret");" */
+                Sym *sym = sym_find(opcode);
+                if (sym && (sym->type.t & VT_EXTERN)) {
+                    sym = label_find(opcode);
+                    if (!sym) {
+                        sym = label_push(&s1->asm_labels, opcode, 0);
+                        sym->type.t = VT_VOID;
+                    }
+                }
                 /* new label */
                 asm_new_label(s1, opcode, 0);
                 next();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]